PageSourceSearch

https://offsideornot.com/_next/static/chunks/b2622374.892db586280321895a88.js

js offsideornot.com collected 2026-10-06 08:49:23 UTC 265,500 bytes, 1 lines download raw bytes

1(window.webpackJsonp_N_E=window.webpackJsonp_N_E||[]).push([[7],{"7i7y":function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return hc})),n.d(e,"b",(function(){return lc})),n.d(e,"c",(function(){return V})),n.d(e,"d",(function(){return ic})),n.d(e,"e",(function(){return uc})),n.d(e,"f",(function(){return oc})),n.d(e,"g",(function(){return ac})),n.d(e,"h",(function(){return ga})),n.d(e,"i",(function(){return ba})),n.d(e,"j",(function(){return Ds})),n.d(e,"k",(function(){return yc})),n.d(e,"l",(function(){return Oc})),n.d(e,"m",(function(){return bc})),n.d(e,"n",(function(){return _c})),n.d(e,"o",(function(){return cc})),n.d(e,"p",(function(){return Ec})),n.d(e,"q",(function(){return wc})),n.d(e,"r",(function(){return mc}));var r=n("MxOq"),i=n("1iQ0"),o=n("VClI"),u=n("bb6g"),s=function(t,e,n,r,i,o){this.t=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i,this.i=o},a=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"o",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t}(),c=new r.b("@firebase/firestore");function h(){return c.logLevel}function f(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(c.logLevel<=r.a.DEBUG){var i=e.map(d);c.debug.apply(c,Object(u.g)(["Firestore (8.2.9): "+t],i))}}function l(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(c.logLevel<=r.a.ERROR){var i=e.map(d);c.error.apply(c,Object(u.g)(["Firestore (8.2.9): "+t],i))}}function p(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(c.logLevel<=r.a.WARN){var i=e.map(d);c.warn.apply(c,Object(u.g)(["Firestore (8.2.9): "+t],i))}}function d(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function v(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (8.2.9) INTERNAL ASSERTION FAILED: "+t;throw l(e),new Error(e)}function y(t,e){t||v()}function m(t,e){return t}function b(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}var g=function(){function t(){}return t.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=b(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},t}();function w(t,e){return t<e?-1:t>e?1:0}function _(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}function I(t){return t+"\0"}var E=function(){function t(t){this.h=t}return t.fromBase64String=function(e){return new t(atob(e))},t.fromUint8Array=function(e){return new t(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e))},t.prototype.toBase64=function(){return t=this.h,btoa(t);var t},t.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.h)},t.prototype.l=function(){return 2*this.h.length},t.prototype._=function(t){return w(this.h,t.h)},t.prototype.isEqual=function(t){return this.h===t.h},t}();E.T=new E("");var O={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},T=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).code=e,r.message=n,r.name="FirebaseError",r.toString=function(){return r.name+": [code="+r.code+"]: "+r.message},r}return Object(u.c)(e,t),e}(Error),N=function(){function t(t){this.I=t}return t.fromBase64String=function(e){try{return new t(E.fromBase64String(e))}catch(e){throw new T(O.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}},t.fromUint8Array=function(e){return new t(E.fromUint8Array(e))},t.prototype.toBase64=function(){return this.I.toBase64()},t.prototype.toUint8Array=function(){return this.I.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this.I.isEqual(t.I)},t}(),j=function(){function t(t){this.uid=t}return t.prototype.m=function(){return null!=this.uid},t.prototype.A=function(){return this.m()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();j.UNAUTHENTICATED=new j(null),j.R=new j("google-credentials-uid"),j.P=new j("first-party-uid");var A=function(t,e){this.user=e,this.type="OAuth",this.g={},this.g.Authorization="Bearer "+t},D=function(){function t(){this.V=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.p=function(){},t.prototype.v=function(t){this.V=t,t(j.UNAUTHENTICATED)},t.prototype.S=function(){this.V=null},t}(),S=function(){function t(t){var e=this;this.D=null,this.currentUser=j.UNAUTHENTICATED,this.C=!1,this.N=0,this.V=null,this.forceRefresh=!1,this.D=function(){e.N++,e.currentUser=e.$(),e.C=!0,e.V&&e.V(e.currentUser)},this.N=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.D):(this.D(null),t.get().then((function(t){e.auth=t,e.D&&e.auth.addAuthTokenListener(e.D)}),(function(){})))}return t.prototype.getToken=function(){var t=this,e=this.N,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.N!==e?(f("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(y("string"==typeof n.accessToken),new A(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.p=function(){this.forceRefresh=!0},t.prototype.v=function(t){this.V=t,this.C&&t(this.currentUser)},t.prototype.S=function(){this.auth&&this.auth.removeAuthTokenListener(this.D),this.D=null,this.V=null},t.prototype.$=function(){var t=this.auth&&this.auth.getUid();return y(null===t||"string"==typeof t),new j(t)},t}(),x=function(){function t(t,e){this.F=t,this.O=e,this.type="FirstParty",this.user=j.P}return Object.defineProperty(t.prototype,"g",{get:function(){var t={"X-Goog-AuthUser":this.O},e=this.F.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),t}
1,enumerable:!1,configurable:!0}),t}(),k=function(){function t(t,e){this.F=t,this.O=e}return t.prototype.getToken=function(){return Promise.resolve(new x(this.F,this.O))},t.prototype.v=function(t){t(j.P)},t.prototype.S=function(){},t.prototype.p=function(){},t}(),P=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.k=function(t){return n.M(t)},this.L=function(t){return e.B(t)})}return t.prototype.M=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.L&&this.L(t),t},t}();P.q=-1;var V=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new T(O.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new T(O.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new T(O.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new T(O.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return t.now=function(){return t.fromMillis(Date.now())},t.fromDate=function(e){return t.fromMillis(e.getTime())},t.fromMillis=function(e){var n=Math.floor(e/1e3);return new t(n,1e6*(e-1e3*n))},t.prototype.toDate=function(){return new Date(this.toMillis())},t.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},t.prototype.U=function(t){return this.seconds===t.seconds?w(this.nanoseconds,t.nanoseconds):w(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},t.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},t}(),C=function(){function t(t){this.timestamp=t}return t.K=function(e){return new t(e)},t.min=function(){return new t(new V(0,0))},t.prototype._=function(t){return this.timestamp.U(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.W=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.j=function(){return this.timestamp},t}(),L=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&v(),void 0===n?n=t.length-e:n>t.length-e&&v(),this.segments=t,this.offset=e,this.G=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.G},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.H(this,e)},t.prototype.child=function(e){var n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach((function(t){n.push(t)})):n.push(e),this.J(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.Y=function(t){return t=void 0===t?1:t,this.J(this.segments,this.offset+t,this.length-t)},t.prototype.X=function(){return this.J(this.segments,this.offset,this.length-1)},t.prototype.Z=function(){return this.segments[this.offset]},t.prototype.tt=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.et=function(){return 0===this.length},t.prototype.nt=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.st=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},t.prototype.it=function(){return this.segments.slice(this.offset,this.limit())},t.H=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(i>o)return 1}return t.length<e.length?-1:t.length>e.length?1:0},t}(),R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.J=function(t,n,r){return new e(t,n,r)},e.prototype.rt=function(){return this.it().join("/")},e.prototype.toString=function(){return this.rt()},e.ot=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=[],i=0,o=t;i<o.length;i++){var u=o[i];if(u.indexOf("//")>=0)throw new T(O.INVALID_ARGUMENT,"Invalid segment ("+u+"). Paths must not contain // in them.");r.push.apply(r,u.split("/").filter((function(t){return t.length>0})))}return new e(r)},e.ct=function(){return new e([])},e}(L),U=/^[_a-zA-Z][_a-zA-Z0-9]*$/,M=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.J=function(t,n,r){return new e(t,n,r)},e.at=function(t){return U.test(t)},e.prototype.rt=function(){return this.it().map((function(t){return t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e.at(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.rt()},e.prototype.ut=function(){return 1===this.length&&"__name__"===this.get(0)},e.ht=function(){return new e(["__name__"])},e.lt=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new T(O.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");n.push(r),r=""},u=!1;i<t.length;){var s=t[i];if("\\"===s){if(i+1===t.length)throw new T(O.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[i+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new T(O.INVALID_ARGUMENT,"Path has invali
1d escape sequence: "+t);r+=a,i+=2}else"`"===s?(u=!u,i++):"."!==s||u?(r+=s,i++):(o(),i++)}if(o(),u)throw new T(O.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.ct=function(){return new e([])},e}(L),q=function(){function t(t){this.path=t}return t._t=function(e){return new t(R.ot(e))},t.ft=function(e){return new t(R.ot(e).Y(5))},t.prototype.dt=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===R.H(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.H=function(t,e){return R.H(t.path,e.path)},t.wt=function(t){return t.length%2==0},t.Et=function(e){return new t(new R(e.slice()))},t}();function F(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function z(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function G(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var B=function(){function t(t){this.fields=t,t.sort(M.H)}return t.prototype.Tt=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].nt(t))return!0;return!1},t.prototype.isEqual=function(t){return _(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),Q=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Y(t){if(y(!!t),"string"==typeof t){var e=0,n=Q.exec(t);if(y(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:H(t.seconds),nanos:H(t.nanos)}}function H(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function K(t){return"string"==typeof t?E.fromBase64String(t):E.fromUint8Array(t)}function X(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function W(t){var e=t.mapValue.fields.__previous_value__;return X(e)?W(e):e}function Z(t){var e=Y(t.mapValue.fields.__local_write_time__.timestampValue);return new V(e.seconds,e.nanos)}function J(t){return null==t}function $(t){return 0===t&&1/t==-1/0}function tt(t){return"number"==typeof t&&Number.isInteger(t)&&!$(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}function et(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?X(t)?4:10:v()}function nt(t,e){var n=et(t);if(n!==et(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Z(t).isEqual(Z(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;var n=Y(t.timestampValue),r=Y(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return K(t.bytesValue).isEqual(K(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return H(t.geoPointValue.latitude)===H(e.geoPointValue.latitude)&&H(t.geoPointValue.longitude)===H(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return H(t.integerValue)===H(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=H(t.doubleValue),r=H(e.doubleValue);return n===r?$(n)===$(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return _(t.arrayValue.values||[],e.arrayValue.values||[],nt);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(F(n)!==F(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!nt(n[i],r[i])))return!1;return!0}(t,e);default:return v()}}function rt(t,e){return void 0!==(t.values||[]).find((function(t){return nt(t,e)}))}function it(t,e){var n=et(t),r=et(e);if(n!==r)return w(n,r);switch(n){case 0:return 0;case 1:return w(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=H(t.integerValue||t.doubleValue),r=H(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return ot(t.timestampValue,e.timestampValue);case 4:return ot(Z(t),Z(e));case 5:return w(t.stringValue,e.stringValue);case 6:return function(t,e){var n=K(t),r=K(e);return n._(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=w(n[i],r[i]);if(0!==o)return o}return w(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=w(H(t.latitude),H(e.latitude));return 0!==n?n:w(H(t.longitude),H(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=it(n[i],r[i]);if(o)return o}return w(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var u=0;u<r.length&&u<o.length;++u){var s=w(r[u],o[u]);if(0!==s)return s;var a=it(n[r[u]],i[o[u]]);if(0!==a)return a}return w(r.length,o.length)}(t.mapValue,e.mapValue);default:throw v()}}function ot(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return w(t,e);var n=Y(t),r=Y(e),i=w(n.seconds,r.seconds);return 0!==i?i:w(n.nanos,r.nanos)}function ut(t){return st(t)}function st(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){var e=Y(t);return"time("+e.seconds+","+e.nanos+")"}
1(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?K(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,q.ft(n).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=st(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+st(t.fields[o])}return e+"}"}(t.mapValue):v();var e,n}function at(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.rt()}}function ct(t){return!!t&&"integerValue"in t}function ht(t){return!!t&&"arrayValue"in t}function ft(t){return!!t&&"nullValue"in t}function lt(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function pt(t){return!!t&&"mapValue"in t}var dt=function(){function t(t){this.proto=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(t){if(t.et())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!pt(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t.tt()])||null},t.prototype.isEqual=function(t){return nt(this.proto,t.proto)},t}(),vt=function(){function t(t){void 0===t&&(t=dt.empty()),this.It=t,this.At=new Map}return t.prototype.set=function(t,e){return this.Rt(t,e),this},t.prototype.delete=function(t){return this.Rt(t,null),this},t.prototype.Rt=function(t,e){for(var n=this.At,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map?n=o:o&&10===et(o)?(o=new Map(Object.entries(o.mapValue.fields||{})),n.set(i,o),n=o):(o=new Map,n.set(i,o),n=o)}n.set(t.tt(),e)},t.prototype.Pt=function(){var t=this.yt(M.ct(),this.At);return null!=t?new dt(t):this.It},t.prototype.yt=function(t,e){var n=this,r=!1,i=this.It.field(t),o=pt(i)?Object.assign({},i.mapValue.fields):{};return e.forEach((function(e,i){if(e instanceof Map){var u=n.yt(t.child(i),e);null!=u&&(o[i]=u,r=!0)}else null!==e?(o[i]=e,r=!0):o.hasOwnProperty(i)&&(delete o[i],r=!0)})),r?{mapValue:{fields:o}}:null},t}();function yt(t){var e=[];return z(t.fields||{},(function(t,n){var r=new M([t]);if(pt(n)){var i=yt(n.mapValue).fields;if(0===i.length)e.push(r);else for(var o=0,u=i;o<u.length;o++){var s=u[o];e.push(r.child(s))}}else e.push(r)})),new B(e)}var mt=function(t,e){this.key=t,this.version=e},bt=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this,e,n)||this).gt=r,o.Vt=!!i.Vt,o.hasCommittedMutations=!!i.hasCommittedMutations,o}return Object(u.c)(e,t),e.prototype.field=function(t){return this.gt.field(t)},e.prototype.data=function(){return this.gt},e.prototype.bt=function(){return this.gt.proto},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.Vt===t.Vt&&this.hasCommittedMutations===t.hasCommittedMutations&&this.gt.isEqual(t.gt)},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.gt.toString()+", {hasLocalMutations: "+this.Vt+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.Vt||this.hasCommittedMutations},enumerable:!1,configurable:!0}),e}(mt),gt=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n)||this).hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return Object(u.c)(e,t),e.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(mt),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!0}
1,enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(mt),_t=function(t,e,n,r,i,o,u){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===u&&(u=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=u,this.vt=null};function It(t,e,n,r,i,o,u){return void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===u&&(u=null),new _t(t,e,n,r,i,o,u)}function Et(t){var e=m(t);if(null===e.vt){var n=e.path.rt();null!==e.collectionGroup&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((function(t){return function(t){return t.field.rt()+t.op.toString()+ut(t.value)}(t)})).join(","),n+="|ob:",n+=e.orderBy.map((function(t){return function(t){return t.field.rt()+t.dir}(t)})).join(","),J(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=Lt(e.startAt)),e.endAt&&(n+="|ub:",n+=Lt(e.endAt)),e.vt=n}return e.vt}function Ot(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n=0;n<t.orderBy.length;n++)if(!Ut(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(var r=0;r<t.filters.length;r++)if(i=t.filters[r],o=e.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!nt(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!qt(t.startAt,e.startAt)&&qt(t.endAt,e.endAt)}function Tt(t){return q.wt(t.path)&&null===t.collectionGroup&&0===t.filters.length}var Nt=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).field=e,i.op=n,i.value=r,i}return Object(u.c)(e,t),e.create=function(t,n,r){return t.ut()?"in"===n||"not-in"===n?this.St(t,n,r):new jt(t,n,r):"array-contains"===n?new xt(t,r):"in"===n?new kt(t,r):"not-in"===n?new Pt(t,r):"array-contains-any"===n?new Vt(t,r):new e(t,n,r)},e.St=function(t,e,n){return"in"===e?new At(t,n):new Dt(t,n)},e.prototype.matches=function(t){var e=t.field(this.field);return"!="===this.op?null!==e&&this.Dt(it(e,this.value)):null!==e&&et(this.value)===et(e)&&this.Dt(it(e,this.value))},e.prototype.Dt=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return v()}},e.prototype.Ct=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}((function(){})),jt=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=q.ft(r.referenceValue),i}return Object(u.c)(e,t),e.prototype.matches=function(t){var e=q.H(t.key,this.key);return this.Dt(e)},e}(Nt),At=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=St("in",n),r}return Object(u.c)(e,t),e.prototype.matches=function(t){return this.keys.some((function(e){return e.isEqual(t.key)}))},e}(Nt),Dt=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=St("not-in",n),r}return Object(u.c)(e,t),e.prototype.matches=function(t){return!this.keys.some((function(e){return e.isEqual(t.key)}))},e}(Nt);function St(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((function(t){return q.ft(t.referenceValue)}))}var xt=function(t){function e(e,n){return t.call(this,e,"array-contains",n)||this}return Object(u.c)(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return ht(e)&&rt(e.arrayValue,this.value)},e}(Nt),kt=function(t){function e(e,n){return t.call(this,e,"in",n)||this}return Object(u.c)(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&rt(this.value.arrayValue,e)},e}(Nt),Pt=function(t){function e(e,n){return t.call(this,e,"not-in",n)||this}return Object(u.c)(e,t),e.prototype.matches=function(t){if(rt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.field(this.field);return null!==e&&!rt(this.value.arrayValue,e)},e}(Nt),Vt=function(t){function e(e,n){return t.call(this,e,"array-contains-any",n)||this}return Object(u.c)(e,t),e.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!ht(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return rt(e.value.arrayValue,t)}))},e}(Nt),Ct=function(t,e){this.position=t,this.before=e};function Lt(t){return(t.before?"b":"a")+":"+t.position.map((function(t){return ut(t)})).join(",")}var Rt=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function Ut(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function Mt(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],u=t.position[i];if(r=o.field.ut()?q.H(q.ft(u.referenceValue),n.key):it(u,n.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function qt(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!nt(t.position[n],e.position[n]))return!1;return!0}var Ft=function(t,e,n,r,i,o,u,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===u&&(u=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.xt=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=u,this.endAt=s,this.Nt=null,this.$t
1=null,this.startAt,this.endAt};function zt(t,e,n,r,i,o,u,s){return new Ft(t,e,n,r,i,o,u,s)}function Gt(t){return new Ft(t)}function Bt(t){return!J(t.limit)&&"F"===t.limitType}function Qt(t){return!J(t.limit)&&"L"===t.limitType}function Yt(t){return t.xt.length>0?t.xt[0].field:null}function Ht(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.Ct())return r.field}return null}function Kt(t){return null!==t.collectionGroup}function Xt(t){var e=m(t);if(null===e.Nt){e.Nt=[];var n=Ht(e),r=Yt(e);if(null!==n&&null===r)n.ut()||e.Nt.push(new Rt(n)),e.Nt.push(new Rt(M.ht(),"asc"));else{for(var i=!1,o=0,u=e.xt;o<u.length;o++){var s=u[o];e.Nt.push(s),s.field.ut()&&(i=!0)}if(!i){var a=e.xt.length>0?e.xt[e.xt.length-1].dir:"asc";e.Nt.push(new Rt(M.ht(),a))}}}return e.Nt}function Wt(t){var e=m(t);if(!e.$t)if("F"===e.limitType)e.$t=It(e.path,e.collectionGroup,Xt(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Xt(e);r<i.length;r++){var o=i[r],u="desc"===o.dir?"asc":"desc";n.push(new Rt(o.field,u))}var s=e.endAt?new Ct(e.endAt.position,!e.endAt.before):null,a=e.startAt?new Ct(e.startAt.position,!e.startAt.before):null;e.$t=It(e.path,e.collectionGroup,n,e.filters,e.limit,s,a)}return e.$t}function Zt(t,e,n){return new Ft(t.path,t.collectionGroup,t.xt.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Jt(t,e){return Ot(Wt(t),Wt(e))&&t.limitType===e.limitType}function $t(t){return Et(Wt(t))+"|lt:"+t.limitType}function te(t){return"Query(target="+function(t){var e=t.path.rt();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=", filters: ["+t.filters.map((function(t){return(e=t).field.rt()+" "+e.op+" "+ut(e.value);var e})).join(", ")+"]"),J(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=", orderBy: ["+t.orderBy.map((function(t){return function(t){return t.field.rt()+" ("+t.dir+")"}(t)})).join(", ")+"]"),t.startAt&&(e+=", startAt: "+Lt(t.startAt)),t.endAt&&(e+=", endAt: "+Lt(t.endAt)),"Target("+e+")"}(Wt(t))+"; limitType="+t.limitType+")"}function ee(t,e){return function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.dt(t.collectionGroup)&&t.path.nt(n):q.wt(t.path)?t.path.isEqual(n):t.path.st(n)}(t,e)&&function(t,e){for(var n=0,r=t.xt;n<r.length;n++){var i=r[n];if(!i.field.ut()&&null===e.field(i.field))return!1}return!0}(t,e)&&function(t,e){for(var n=0,r=t.filters;n<r.length;n++)if(!r[n].matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!Mt(t.startAt,Xt(t),e))&&(!t.endAt||!Mt(t.endAt,Xt(t),e))}(t,e)}function ne(t){return function(e,n){for(var r=!1,i=0,o=Xt(t);i<o.length;i++){var u=o[i],s=re(u,e,n);if(0!==s)return s;r=r||u.field.ut()}return 0}}function re(t,e,n){var r=t.field.ut()?q.H(e.key,n.key):function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?it(r,i):v()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return v()}}var ie=function(){function t(t,e,n,r,i,o,u){void 0===i&&(i=C.min()),void 0===o&&(o=C.min()),void 0===u&&(u=E.T),this.target=t,this.targetId=e,this.Ft=n,this.sequenceNumber=r,this.Ot=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=u}return t.prototype.kt=function(e){return new t(this.target,this.targetId,this.Ft,e,this.Ot,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.Mt=function(e,n){return new t(this.target,this.targetId,this.Ft,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.Lt=function(e){return new t(this.target,this.targetId,this.Ft,this.sequenceNumber,this.Ot,e,this.resumeToken)},t}();function oe(t,e){if(t.Bt){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:$(e)?"-0":e}}function ue(t){return{integerValue:""+t}}function se(t,e){return tt(e)?ue(e):oe(t,e)}var ae=function(){this.qt=void 0};function ce(t,e,n){return t instanceof le?function(t,e){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof pe?de(t,e):t instanceof ve?ye(t,e):function(t,e){var n=fe(t,e),r=be(n)+be(t.Ut);return ct(n)&&ct(t.Ut)?ue(r):oe(t.Qt,r)}(t,e)}function he(t,e,n){return t instanceof pe?de(t,e):t instanceof ve?ye(t,e):n}function fe(t,e){return t instanceof me?ct(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}var le=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e}(ae),pe=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return Object(u.c)(e,t),e}(ae);function de(t,e){for(var n=ge(e),r=function(t){n.some((function(e){return nt(e,t)}))||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var ve=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return Object(u.c)(e,t),e}(ae);function ye(t,e){for(var n=ge(e),r=function(t){n=n.filter((function(e){return!nt(e,t)}))},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var me=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Qt=e,r.Ut=n,r}return Object(u.c)(e,t),e}(ae);function be(t){return H(t.integerValue||t.doubleValue)}function ge(t){return ht(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var we=function(t,e){this.field=t,this.transform=e},_e=function(t,e){this.version=t,this.transformResults=e},Ie=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.Kt=function(){return new t},t.exists=function(e){return new t(void 0,e)},t.updateTime=function(e){return new t(e)},Object.defineProperty(t.prototype,"Wt",{get:function(){return void 0===this.updateTime&&void 0===this.exists}
1,enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}();function Ee(t,e){return void 0!==t.updateTime?e instanceof bt&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e instanceof bt}var Oe=function(){};function Te(t,e,n){return t instanceof Se?function(t,e,n){var r=t.value;if(n.transformResults){var i=Pe(t.fieldTransforms,e,n.transformResults);r=Ce(t.fieldTransforms,r,i)}return new bt(t.key,n.version,r,{hasCommittedMutations:!0})}(t,e,n):t instanceof xe?function(t,e,n){if(!Ee(t.jt,e))return new wt(t.key,n.version);var r=ke(t,e,n.transformResults?Pe(t.fieldTransforms,e,n.transformResults):[]);return new bt(t.key,n.version,r,{hasCommittedMutations:!0})}(t,e,n):function(t,e,n){return new gt(t.key,n.version,{hasCommittedMutations:!0})}(t,0,n)}function Ne(t,e,n){return t instanceof Se?function(t,e,n){if(!Ee(t.jt,e))return e;var r=t.value,i=Ve(t.fieldTransforms,n,e);r=Ce(t.fieldTransforms,r,i);var o=De(e);return new bt(t.key,o,r,{Vt:!0})}(t,e,n):t instanceof xe?function(t,e,n){if(!Ee(t.jt,e))return e;var r=De(e),i=ke(t,e,Ve(t.fieldTransforms,n,e));return new bt(t.key,r,i,{Vt:!0})}(t,e,n):function(t,e){return Ee(t.jt,e)?new gt(t.key,C.min()):e}(t,e)}function je(t,e){return function(t,e){for(var n=null,r=0,i=t;r<i.length;r++){var o=i[r],u=e instanceof bt?e.field(o.field):void 0,s=fe(o.transform,u||null);null!=s&&(n=null==n?(new vt).set(o.field,s):n.set(o.field,s))}return n?n.Pt():null}(t.fieldTransforms,e)}function Ae(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.jt.isEqual(e.jt)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&_(t,e,(function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof pe&&e instanceof pe||t instanceof ve&&e instanceof ve?_(t.elements,e.elements,nt):t instanceof me&&e instanceof me?nt(t.Ut,e.Ut):t instanceof le&&e instanceof le}(t.transform,e.transform)}(t,e)}))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.Gt.isEqual(e.Gt))}function De(t){return t instanceof bt?t.version:C.min()}var Se=function(t){function e(e,n,r,i){void 0===i&&(i=[]);var o=this;return(o=t.call(this)||this).key=e,o.value=n,o.jt=r,o.fieldTransforms=i,o.type=0,o}return Object(u.c)(e,t),e}(Oe),xe=function(t){function e(e,n,r,i,o){void 0===o&&(o=[]);var u=this;return(u=t.call(this)||this).key=e,u.data=n,u.Gt=r,u.jt=i,u.fieldTransforms=o,u.type=1,u}return Object(u.c)(e,t),e}(Oe);function ke(t,e,n){var r;return r=function(t,e){var n=new vt(e);return t.Gt.fields.forEach((function(e){if(!e.et()){var r=t.data.field(e);null!==r?n.set(e,r):n.delete(e)}})),n.Pt()}(t,r=e instanceof bt?e.data():dt.empty()),Ce(t.fieldTransforms,r,n)}function Pe(t,e,n){var r=[];y(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],u=o.transform,s=null;e instanceof bt&&(s=e.field(o.field)),r.push(he(u,s,n[i]))}return r}function Ve(t,e,n){for(var r=[],i=0,o=t;i<o.length;i++){var u=o[i],s=u.transform,a=null;n instanceof bt&&(a=n.field(u.field)),r.push(ce(s,a,e))}return r}function Ce(t,e,n){for(var r=new vt(e),i=0;i<t.length;i++){var o=t[i];r.set(o.field,n[i])}return r.Pt()}var Le,Re,Ue=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.jt=n,r.type=2,r.fieldTransforms=[],r}return Object(u.c)(e,t),e}(Oe),Me=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.jt=n,r.type=3,r.fieldTransforms=[],r}return Object(u.c)(e,t),e}(Oe),qe=function(t){this.count=t};function Fe(t){switch(t){case O.OK:return v();case O.CANCELLED:case O.UNKNOWN:case O.DEADLINE_EXCEEDED:case O.RESOURCE_EXHAUSTED:case O.INTERNAL:case O.UNAVAILABLE:case O.UNAUTHENTICATED:return!1;case O.INVALID_ARGUMENT:case O.NOT_FOUND:case O.ALREADY_EXISTS:case O.PERMISSION_DENIED:case O.FAILED_PRECONDITION:case O.ABORTED:case O.OUT_OF_RANGE:case O.UNIMPLEMENTED:case O.DATA_LOSS:return!0;default:return v()}}function ze(t){if(void 0===t)return l("GRPC error has no .code"),O.UNKNOWN;switch(t){case Le.OK:return O.OK;case Le.CANCELLED:return O.CANCELLED;case Le.UNKNOWN:return O.UNKNOWN;case Le.DEADLINE_EXCEEDED:return O.DEADLINE_EXCEEDED;case Le.RESOURCE_EXHAUSTED:return O.RESOURCE_EXHAUSTED;case Le.INTERNAL:return O.INTERNAL;case Le.UNAVAILABLE:return O.UNAVAILABLE;case Le.UNAUTHENTICATED:return O.UNAUTHENTICATED;case Le.INVALID_ARGUMENT:return O.INVALID_ARGUMENT;case Le.NOT_FOUND:return O.NOT_FOUND;case Le.ALREADY_EXISTS:return O.ALREADY_EXISTS;case Le.PERMISSION_DENIED:return O.PERMISSION_DENIED;case Le.FAILED_PRECONDITION:return O.FAILED_PRECONDITION;case Le.ABORTED:return O.ABORTED;case Le.OUT_OF_RANGE:return O.OUT_OF_RANGE;
1case Le.UNIMPLEMENTED:return O.UNIMPLEMENTED;case Le.DATA_LOSS:return O.DATA_LOSS;default:return v()}}(Re=Le||(Le={}))[Re.OK=0]="OK",Re[Re.CANCELLED=1]="CANCELLED",Re[Re.UNKNOWN=2]="UNKNOWN",Re[Re.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Re[Re.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Re[Re.NOT_FOUND=5]="NOT_FOUND",Re[Re.ALREADY_EXISTS=6]="ALREADY_EXISTS",Re[Re.PERMISSION_DENIED=7]="PERMISSION_DENIED",Re[Re.UNAUTHENTICATED=16]="UNAUTHENTICATED",Re[Re.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Re[Re.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Re[Re.ABORTED=10]="ABORTED",Re[Re.OUT_OF_RANGE=11]="OUT_OF_RANGE",Re[Re.UNIMPLEMENTED=12]="UNIMPLEMENTED",Re[Re.INTERNAL=13]="INTERNAL",Re[Re.UNAVAILABLE=14]="UNAVAILABLE",Re[Re.DATA_LOSS=15]="DATA_LOSS";var Ge=function(){function t(t,e){this.H=t,this.root=e||Qe.EMPTY}return t.prototype.zt=function(e,n){return new t(this.H,this.root.zt(e,n,this.H).copy(null,null,Qe.Ht,null,null))},t.prototype.remove=function(e){return new t(this.H,this.root.remove(e,this.H).copy(null,null,Qe.Ht,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.et();){var n=this.H(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null},t.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.et();){var r=this.H(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1},t.prototype.et=function(){return this.root.et()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),t.prototype.Jt=function(){return this.root.Jt()},t.prototype.Yt=function(){return this.root.Yt()},t.prototype.Xt=function(t){return this.root.Xt(t)},t.prototype.forEach=function(t){this.Xt((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.Xt((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.Zt=function(t){return this.root.Zt(t)},t.prototype.te=function(){return new Be(this.root,null,this.H,!1)},t.prototype.ee=function(t){return new Be(this.root,t,this.H,!1)},t.prototype.ne=function(){return new Be(this.root,null,this.H,!0)},t.prototype.se=function(t){return new Be(this.root,t,this.H,!0)},t}(),Be=function(){function t(t,e,n,r){this.ie=r,this.re=[];for(var i=1;!t.et();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.ie?t.left:t.right;else{if(0===i){this.re.push(t);break}this.re.push(t),t=this.ie?t.right:t.left}}return t.prototype.oe=function(){var t=this.re.pop(),e={key:t.key,value:t.value};if(this.ie)for(t=t.left;!t.et();)this.re.push(t),t=t.right;else for(t=t.right;!t.et();)this.re.push(t),t=t.left;return e},t.prototype.ce=function(){return this.re.length>0},t.prototype.ae=function(){if(0===this.re.length)return null;var t=this.re[this.re.length-1];return{key:t.key,value:t.value}},t}(),Qe=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.et=function(){return!1},t.prototype.Xt=function(t){return this.left.Xt(t)||t(this.key,this.value)||this.right.Xt(t)},t.prototype.Zt=function(t){return this.right.Zt(t)||t(this.key,this.value)||this.left.Zt(t)},t.prototype.min=function(){return this.left.et()?this:this.left.min()},t.prototype.Jt=function(){return this.min().key},t.prototype.Yt=function(){return this.right.et()?this.key:this.right.Yt()},t.prototype.zt=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.zt(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.zt(t,e,n))).ue()},t.prototype.he=function(){if(this.left.et())return t.EMPTY;var e=this;return e.left.le()||e.left.left.le()||(e=e._e()),(e=e.copy(null,null,null,e.left.he(),null)).ue()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.et()||i.left.le()||i.left.left.le()||(i=i._e()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.le()&&(i=i.fe()),i.right.et()||i.right.le()||i.right.left.le()||(i=i.de()),0===n(e,i.key)){if(i.right.et())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.he())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.ue()},t.prototype.le=function(){return this.color},t.prototype.ue=function(){var t=this;return t.right.le()&&!t.left.le()&&(t=t.we()),t.left.le()&&t.left.left.le()&&(t=t.fe()),t.left.le()&&t.right.le()&&(t=t.Ee()),t},t.prototype._e=function(){var t=this.Ee();return t.right.left.le()&&(t=(t=(t=t.copy(null,null,null,null,t.right.fe())).we()).Ee()),t},t.prototype.de=function(){var t=this.Ee();
1return t.left.left.le()&&(t=(t=t.fe()).Ee()),t},t.prototype.we=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.fe=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.Ee=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.Te=function(){var t=this.Ie();return Math.pow(2,t)<=this.size+1},t.prototype.Ie=function(){if(this.le()&&this.left.le())throw v();if(this.right.le())throw v();var t=this.left.Ie();if(t!==this.right.Ie())throw v();return t+(this.le()?0:1)},t}();Qe.EMPTY=null,Qe.RED=!0,Qe.Ht=!1,Qe.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw v()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.zt=function(t,e,n){return new Qe(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.et=function(){return!0},t.prototype.Xt=function(t){return!1},t.prototype.Zt=function(t){return!1},t.prototype.Jt=function(){return null},t.prototype.Yt=function(){return null},t.prototype.le=function(){return!1},t.prototype.Te=function(){return!0},t.prototype.Ie=function(){return 0},t}());var Ye=function(){function t(t){this.H=t,this.data=new Ge(this.H)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.Jt()},t.prototype.last=function(){return this.data.Yt()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.Xt((function(e,n){return t(e),!1}))},t.prototype.me=function(t,e){for(var n=this.data.ee(t[0]);n.ce();){var r=n.oe();if(this.H(r.key,t[1])>=0)return;e(r.key)}},t.prototype.Ae=function(t,e){var n;for(n=void 0!==e?this.data.ee(e):this.data.te();n.ce();)if(!t(n.oe().key))return},t.prototype.Re=function(t){var e=this.data.ee(t);return e.ce()?e.oe().key:null},t.prototype.te=function(){return new He(this.data.te())},t.prototype.ee=function(t){return new He(this.data.ee(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).zt(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.et=function(){return this.data.et()},t.prototype.Pe=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach((function(t){e=e.add(t)})),e},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.data.te(),r=e.data.te();n.ce();){var i=n.oe().key,o=r.oe().key;if(0!==this.H(i,o))return!1}return!0},t.prototype.it=function(){var t=[];return this.forEach((function(e){t.push(e)})),t},t.prototype.toString=function(){var t=[];return this.forEach((function(e){return t.push(e)})),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.H);return n.data=e,n},t}(),He=function(){function t(t){this.ye=t}return t.prototype.oe=function(){return this.ye.oe().key},t.prototype.ce=function(){return this.ye.ce()},t}(),Ke=new Ge(q.H);function Xe(){return Ke}function We(){return Xe()}var Ze=new Ge(q.H);function Je(){return Ze}var $e=new Ge(q.H);function tn(){return $e}var en=new Ye(q.H);function nn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=en,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var rn=new Ye(w);function on(){return rn}var un=function(){function t(t){this.H=t?function(e,n){return t(e,n)||q.H(e.key,n.key)}:function(t,e){return q.H(t.key,e.key)},this.ge=Je(),this.Ve=new Ge(this.H)}return t.pe=function(e){return new t(e.H)},t.prototype.has=function(t){return null!=this.ge.get(t)},t.prototype.get=function(t){return this.ge.get(t)},t.prototype.first=function(){return this.Ve.Jt()},t.prototype.last=function(){return this.Ve.Yt()},t.prototype.et=function(){return this.Ve.et()},t.prototype.indexOf=function(t){var e=this.ge.get(t);return e?this.Ve.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.Ve.size}
1,enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.Ve.Xt((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.ge.zt(t.key,t),e.Ve.zt(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.ge.remove(t),this.Ve.remove(e)):this},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.Ve.te(),r=e.Ve.te();n.ce();){var i=n.oe().key,o=r.oe().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach((function(e){t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n  "+t.join("  \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.H=this.H,r.ge=e,r.Ve=n,r},t}(),sn=function(){function t(){this.be=new Ge(q.H)}return t.prototype.track=function(t){var e=t.doc.key,n=this.be.get(e);n?0!==t.type&&3===n.type?this.be=this.be.zt(e,t):3===t.type&&1!==n.type?this.be=this.be.zt(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.be=this.be.zt(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.be=this.be.zt(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.be=this.be.remove(e):1===t.type&&2===n.type?this.be=this.be.zt(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.be=this.be.zt(e,{type:2,doc:t.doc}):v():this.be=this.be.zt(e,t)},t.prototype.ve=function(){var t=[];return this.be.Xt((function(e,n){t.push(n)})),t},t}(),an=function(){function t(t,e,n,r,i,o,u,s){this.query=t,this.docs=e,this.Se=n,this.docChanges=r,this.De=i,this.fromCache=o,this.Ce=u,this.xe=s}return t.Ne=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:0,doc:t})})),new t(e,n,un.pe(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.De.et()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.Ce===t.Ce&&this.De.isEqual(t.De)&&Jt(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.Se.isEqual(t.Se)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},t}(),cn=function(){function t(t,e,n,r,i){this.Ot=t,this.$e=e,this.Fe=n,this.Oe=r,this.ke=i}return t.Me=function(e,n){var r=new Map;return r.set(e,hn.Le(e,n)),new t(C.min(),r,on(),Xe(),nn())},t}(),hn=function(){function t(t,e,n,r,i){this.resumeToken=t,this.Be=e,this.qe=n,this.Ue=r,this.Qe=i}return t.Le=function(e,n){return new t(E.T,n,nn(),nn(),nn())},t}(),fn=function(t,e,n,r){this.Ke=t,this.removedTargetIds=e,this.key=n,this.We=r},ln=function(t,e){this.targetId=t,this.je=e},pn=function(t,e,n,r){void 0===n&&(n=E.T),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},dn=function(){function t(){this.Ge=0,this.ze=mn(),this.He=E.T,this.Je=!1,this.Ye=!0}return Object.defineProperty(t.prototype,"Be",{get:function(){return this.Je},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.He},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Xe",{get:function(){return 0!==this.Ge},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Ze",{get:function(){return this.Ye},enumerable:!1,configurable:!0}),t.prototype.tn=function(t){t.l()>0&&(this.Ye=!0,this.He=t)},t.prototype.en=function(){var t=nn(),e=nn(),n=nn();return this.ze.forEach((function(r,i){switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:v()}})),new hn(this.He,this.Je,t,e,n)},t.prototype.nn=function(){this.Ye=!1,this.ze=mn()},t.prototype.sn=function(t,e){this.Ye=!0,this.ze=this.ze.zt(t,e)},t.prototype.rn=function(t){this.Ye=!0,this.ze=this.ze.remove(t)},t.prototype.on=function(){this.Ge+=1},t.prototype.cn=function(){this.Ge-=1},t.prototype.an=function(){this.Ye=!0,this.Je=!0},t}(),vn=function(){function t(t){this.un=t,this.hn=new Map,this.ln=Xe(),this._n=yn(),this.fn=new Ye(w)}return t.prototype.dn=function(t){for(var e=0,n=t.Ke;e<n.length;e++){var r=n[e];t.We instanceof bt?this.wn(r,t.We):t.We instanceof gt&&this.En(r,t.key,t.We)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.En(r,t.key,t.We)},t.prototype.Tn=function(t){var e=this;this.In(t,(function(n){var r=e.mn(n);switch(t.state){case 0:e.An(n)&&r.tn(t.resumeToken);break;case 1:r.cn(),r.Xe||r.nn(),r.tn(t.resumeToken);break;case 2:r.cn(),r.Xe||e.removeTarget(n);break;case 3:e.An(n)&&(r.an(),r.tn(t.resumeToken));break;case 4:e.An(n)&&(e.Rn(n),r.tn(t.resumeToken));break;default:v()}}))},t.prototype.In=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.hn.forEach((function(t,r){n.An(r)&&e(r)}))},t.prototype.Pn=function(t){var e=t.targetId,n=t.je.count,r=this.yn(e);if(r){var i=r.target;if(Tt(i))if(0===n){var o=new q(i.path);this.En(e,o,new gt(o,C.min()))}else y(1===n);else this.gn(e)!==n&&(this.Rn(e),this.fn=this.fn.add(e))}},t.prototype.Vn=function(t){var e=this,n=new Map;this.hn.forEach((function(r,i){var o=e.yn(i);if(o){if(r.Be&&Tt(o.target)){var u=new q(o.target.path);null!==e.ln.get(u)||e.pn(i,u)||e.En(i,u,new gt(u,t))}r.Ze&&(n.set(i,r.en()),r.nn())}}));var r=nn();
1this._n.forEach((function(t,n){var i=!0;n.Ae((function(t){var n=e.yn(t);return!n||2===n.Ft||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new cn(t,n,this.fn,this.ln,r);return this.ln=Xe(),this._n=yn(),this.fn=new Ye(w),i},t.prototype.wn=function(t,e){if(this.An(t)){var n=this.pn(t,e.key)?2:0;this.mn(t).sn(e.key,n),this.ln=this.ln.zt(e.key,e),this._n=this._n.zt(e.key,this.bn(e.key).add(t))}},t.prototype.En=function(t,e,n){if(this.An(t)){var r=this.mn(t);this.pn(t,e)?r.sn(e,1):r.rn(e),this._n=this._n.zt(e,this.bn(e).delete(t)),n&&(this.ln=this.ln.zt(e,n))}},t.prototype.removeTarget=function(t){this.hn.delete(t)},t.prototype.gn=function(t){var e=this.mn(t).en();return this.un.vn(t).size+e.qe.size-e.Qe.size},t.prototype.on=function(t){this.mn(t).on()},t.prototype.mn=function(t){var e=this.hn.get(t);return e||(e=new dn,this.hn.set(t,e)),e},t.prototype.bn=function(t){var e=this._n.get(t);return e||(e=new Ye(w),this._n=this._n.zt(t,e)),e},t.prototype.An=function(t){var e=null!==this.yn(t);return e||f("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.yn=function(t){var e=this.hn.get(t);return e&&e.Xe?null:this.un.Sn(t)},t.prototype.Rn=function(t){var e=this;this.hn.set(t,new dn),this.un.vn(t).forEach((function(n){e.En(t,n,null)}))},t.prototype.pn=function(t,e){return this.un.vn(t).has(e)},t}();function yn(){return new Ge(q.H)}function mn(){return new Ge(q.H)}var bn={asc:"ASCENDING",desc:"DESCENDING"},gn={"<":"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"},wn=function(t,e){this.t=t,this.Bt=e};function _n(t,e){return t.Bt?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function In(t,e){return t.Bt?e.toBase64():e.toUint8Array()}function En(t,e){return _n(t,e.j())}function On(t){return y(!!t),C.K(function(t){var e=Y(t);return new V(e.seconds,e.nanos)}(t))}function Tn(t,e){return function(t){return new R(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).rt()}function Nn(t){var e=R.ot(t);return y(Wn(e)),e}function jn(t,e){return Tn(t.t,e.path)}function An(t,e){var n=Nn(e);if(n.get(1)!==t.t.projectId)throw new T(O.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.t.projectId);if(n.get(3)!==t.t.database)throw new T(O.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.t.database);return new q(kn(n))}function Dn(t,e){return Tn(t.t,e)}function Sn(t){var e=Nn(t);return 4===e.length?R.ct():kn(e)}function xn(t){return new R(["projects",t.t.projectId,"databases",t.t.database]).rt()}function kn(t){return y(t.length>4&&"documents"===t.get(4)),t.Y(5)}function Pn(t,e,n){return{name:jn(t,e),fields:n.proto.mapValue.fields}}function Vn(t,e,n){var r=An(t,e.name),i=On(e.updateTime),o=new dt({mapValue:{fields:e.fields}});return new bt(r,i,o,{hasCommittedMutations:!!n})}function Cn(t,e){var n;if(e instanceof Se)n={update:Pn(t,e.key,e.value)};else if(e instanceof Ue)n={delete:jn(t,e.key)};else if(e instanceof xe)n={update:Pn(t,e.key,e.data),updateMask:Xn(e.Gt)};else{if(!(e instanceof Me))return v();n={verify:jn(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((function(t){return function(t,e){var n=e.transform;if(n instanceof le)return{fieldPath:e.field.rt(),setToServerValue:"REQUEST_TIME"};if(n instanceof pe)return{fieldPath:e.field.rt(),appendMissingElements:{values:n.elements}};if(n instanceof ve)return{fieldPath:e.field.rt(),removeAllFromArray:{values:n.elements}};if(n instanceof me)return{fieldPath:e.field.rt(),increment:n.Ut};throw v()}(0,t)}))),e.jt.Wt||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:En(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:v()}(t,e.jt)),n}function Ln(t,e){var n=e.currentDocument?function(t){return void 0!==t.updateTime?Ie.updateTime(On(t.updateTime)):void 0!==t.exists?Ie.exists(t.exists):Ie.Kt()}(e.currentDocument):Ie.Kt(),r=e.updateTransforms?e.updateTransforms.map((function(e){return function(t,e){var n=null;if("setToServerValue"in e)y("REQUEST_TIME"===e.setToServerValue),n=new le;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new pe(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new ve(i)}else"increment"in e?n=new me(t,e.increment):v();var o=M.lt(e.fieldPath);return new we(o,n)}(t,e)})):[];if(e.update){e.update.name;var i=An(t,e.update.name),o=new dt({mapValue:{fields:e.update.fields}});if(e.updateMask){var u=function(t){var e=t.fieldPaths||[];return new B(e.map((function(t){return M.lt(t)})))}(e.updateMask);return new xe(i,o,u,n,r)}return new Se(i,o,n,r)}if(e.delete){var s=An(t,e.delete);return new Ue(s,n)}if(e.verify){var a=An(t,e.verify);return new Me(a,n)}return v()}function Rn(t,e){return{documents:[Dn(t,e.path)]}}function Un(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Dn(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Dn(t,r.X()),n.structuredQuery.from=[{collectionId:r.tt()}]);var i=function(t){if(0!==t.length){var e=t.map((function(t){return function(t){if("=="===t.op){if(lt(t.value))return{unaryFilter:{field:Qn(t.field),op:"IS_NAN"}};if(ft(t.value))return{unaryFilter:{field:Qn(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(lt(t.value))return{unaryFilter:{field:Qn(t.field),op:"IS_NOT_NA
1N"}};if(ft(t.value))return{unaryFilter:{field:Qn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Qn(t.field),op:Bn(t.op),value:t.value}}}(t)}));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map((function(t){return function(t){return{field:Qn(t.field),direction:Gn(t.dir)}}(t)}))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var u=function(t,e){return t.Bt||J(e)?e:{value:e}}(t,e.limit);return null!==u&&(n.structuredQuery.limit=u),e.startAt&&(n.structuredQuery.startAt=Fn(e.startAt)),e.endAt&&(n.structuredQuery.endAt=Fn(e.endAt)),n}function Mn(t){var e=Sn(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){y(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var u=[];n.where&&(u=qn(n.where));var s=[];n.orderBy&&(s=n.orderBy.map((function(t){return function(t){return new Rt(Yn(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t)})));var a=null;n.limit&&(a=function(t){var e;return J(e="object"==typeof t?t.value:t)?null:e}(n.limit));var c=null;n.startAt&&(c=zn(n.startAt));var h=null;return n.endAt&&(h=zn(n.endAt)),zt(e,i,s,u,a,"F",c,h)}function qn(t){return t?void 0!==t.unaryFilter?[Kn(t)]:void 0!==t.fieldFilter?[Hn(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return qn(t)})).reduce((function(t,e){return t.concat(e)})):v():[]}function Fn(t){return{before:t.before,values:t.position}}function zn(t){var e=!!t.before,n=t.values||[];return new Ct(n,e)}function Gn(t){return bn[t]}function Bn(t){return gn[t]}function Qn(t){return{fieldPath:t.rt()}}function Yn(t){return M.lt(t.fieldPath)}function Hn(t){return Nt.create(Yn(t.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 v()}}(t.fieldFilter.op),t.fieldFilter.value)}function Kn(t){switch(t.unaryFilter.op){case"IS_NAN":var e=Yn(t.unaryFilter.field);return Nt.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=Yn(t.unaryFilter.field);return Nt.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Yn(t.unaryFilter.field);return Nt.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Yn(t.unaryFilter.field);return Nt.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return v()}}function Xn(t){var e=[];return t.fields.forEach((function(t){return e.push(t.rt())})),{fieldPaths:e}}function Wn(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}var Zn=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},Jn=function(){function t(t){var e=this;this.Dn=null,this.Cn=null,this.result=void 0,this.error=void 0,this.xn=!1,this.Nn=!1,t((function(t){e.xn=!0,e.result=t,e.Dn&&e.Dn(t)}),(function(t){e.xn=!0,e.error=t,e.Cn&&e.Cn(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.Nn&&v(),this.Nn=!0,this.xn?this.error?this.$n(n,this.error):this.Fn(e,this.result):new t((function(t,i){r.Dn=function(n){r.Fn(e,n).next(t,i)},r.Cn=function(e){r.$n(n,e).next(t,i)}}))},t.prototype.On=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.kn=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.Fn=function(e,n){return e?this.kn((function(){return e(n)})):t.resolve(n)},t.prototype.$n=function(e,n){return e?this.kn((function(){return e(n)})):t.reject(n)},t.resolve=function(e){return new t((function(t,n){t(e)}))},t.reject=function(e){return new t((function(t,n){n(e)}))},t.Mn=function(e){return new t((function(t,n){var r=0,i=0,o=!1;e.forEach((function(e){++r,e.next((function(){++i,o&&i===r&&t()}),(function(t){return n(t)}))})),o=!0,i===r&&t()}))},t.Ln=function(e){for(var n=t.resolve(!1),r=function(e){n=n.next((function(n){return n?t.resolve(n):e()}))},i=0,o=e;i<o.length;i++)r(o[i]);return n},t.forEach=function(t,e){var n=this,r=[];return t.forEach((function(t,i){r.push(e.call(n,t,i))})),this.Mn(r)},t}(),$n=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.Bn=new Zn,this.transaction.oncomplete=function(){n.Bn.resolve()},this.transaction.onabort=function(){e.error?n.Bn.reject(new nr(t,e.error)):n.Bn.resolve()},this.transaction.onerror=function(e){var r=sr(e.target.error);n.Bn.reject(new nr(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(e){throw new nr(n,e)}},Object.defineProperty(t.prototype,"qn",{get:function(){return this.Bn.promise}
1,enumerable:!1,configurable:!0}),t.prototype.abort=function(t){t&&this.Bn.reject(t),this.aborted||(f("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new ir(e)},t}(),tr=function(){function e(t,n,r){this.name=t,this.version=n,this.Un=r,12.2===e.Qn(Object(i.n)())&&l("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.")}return e.delete=function(t){return f("SimpleDb","Removing database:",t),or(window.indexedDB.deleteDatabase(t)).On()},e.Kn=function(){if("undefined"==typeof indexedDB)return!1;if(e.Wn())return!0;var t=Object(i.n)(),n=e.Qn(t),r=0<n&&n<10,o=e.jn(t),u=0<o&&o<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||u)},e.Wn=function(){var e;return"undefined"!=typeof t&&"YES"===(null===(e=t.env)||void 0===e?void 0:e.Gn)},e.zn=function(t,e){return t.store(e)},e.Qn=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},e.jn=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},e.prototype.Hn=function(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n=this;return Object(u.d)(this,(function(r){switch(r.label){case 0:return this.db?[3,2]:(f("SimpleDb","Opening database:",this.name),e=this,[4,new Promise((function(e,r){var i=indexedDB.open(n.name,n.version);i.onsuccess=function(t){var n=t.target.result;e(n)},i.onblocked=function(){r(new nr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(e){var n=e.target.error;"VersionError"===n.name?r(new T(O.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.")):r(new nr(t,n))},i.onupgradeneeded=function(t){f("SimpleDb",'Database "'+n.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;n.Un.Jn(e,i.transaction,t.oldVersion,n.version).next((function(){f("SimpleDb","Database upgrade to version "+n.version+" complete")}))}}))]);case 1:e.db=r.sent(),r.label=2;case 2:return[2,(this.Yn&&(this.db.onversionchange=function(t){return n.Yn(t)}),this.db)]}}))}))},e.prototype.Xn=function(t){this.Yn=t,this.db&&(this.db.onversionchange=function(e){return t(e)})},e.prototype.runTransaction=function(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o,s,a,c;return Object(u.d)(this,(function(h){switch(h.label){case 0:i="readonly"===e,o=0,s=function(){var e,s,c,h,l;return Object(u.d)(this,(function(u){switch(u.label){case 0:++o,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,a.Hn(t)];case 2:return a.db=u.sent(),e=$n.open(a.db,t,i?"readonly":"readwrite",n),s=r(e).catch((function(t){return e.abort(t),Jn.reject(t)})).On(),c={},s.catch((function(){})),[4,e.qn];case 3:return[2,(c.value=(u.sent(),s),c)];case 4:return h=u.sent(),l="FirebaseError"!==h.name&&o<3,f("SimpleDb","Transaction failed with error:",h.message,"Retrying:",l),a.close(),l?[3,5]:[2,{value:Promise.reject(h)}];case 5:return[2]}}
1))},a=this,h.label=1;case 1:return[5,s()];case 2:if("object"==typeof(c=h.sent()))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}(),er=function(){function t(t){this.Zn=t,this.ts=!1,this.es=null}return Object.defineProperty(t.prototype,"xn",{get:function(){return this.ts},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ns",{get:function(){return this.es},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.Zn=t},enumerable:!1,configurable:!0}),t.prototype.done=function(){this.ts=!0},t.prototype.ss=function(t){this.es=t},t.prototype.delete=function(){return or(this.Zn.delete())},t}(),nr=function(t){function e(e,n){var r=this;return(r=t.call(this,O.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return Object(u.c)(e,t),e}(T);function rr(t){return"IndexedDbTransactionError"===t.name}var ir=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(f("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(f("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),or(n)},t.prototype.add=function(t){return f("SimpleDb","ADD",this.store.name,t,t),or(this.store.add(t))},t.prototype.get=function(t){var e=this;return or(this.store.get(t)).next((function(n){return void 0===n&&(n=null),f("SimpleDb","GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return f("SimpleDb","DELETE",this.store.name,t),or(this.store.delete(t))},t.prototype.count=function(){return f("SimpleDb","COUNT",this.store.name),or(this.store.count())},t.prototype.rs=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.os(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.cs=function(t,e){f("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.us=!1;var r=this.cursor(n);return this.os(r,(function(t,e,n){return n.delete()}))},t.prototype.hs=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.os(r,e)},t.prototype.ls=function(t){var e=this.cursor({});return new Jn((function(n,r){e.onerror=function(t){var e=sr(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next((function(t){t?r.continue():n()})):n()}}))},t.prototype.os=function(t,e){var n=[];return new Jn((function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new er(i),u=e(i.primaryKey,i.value,o);if(u instanceof Jn){var s=u.catch((function(t){return o.done(),Jn.reject(t)}));n.push(s)}o.xn?r():null===o.ns?i.continue():i.continue(o.ns)}else r()}})).next((function(){return Jn.Mn(n)}))},t.prototype.options=function(t,e){var n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.us?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function or(t){return new Jn((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=sr(t.target.error);n(e)}}))}var ur=!1;function sr(t){var e=tr.Qn(Object(i.n)());if(e>=12.2&&e<13){var n="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(n)>=0){var r=new T("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 ur||(ur=!0,setTimeout((function(){throw r}),0)),r}}return t}var ar=function(){function t(t,e,n,r,i){this._s=t,this.fs=e,this.ds=n,this.op=r,this.ws=i,this.Es=new Zn,this.then=this.Es.promise.then.bind(this.Es.promise),this.Es.promise.catch((function(t){}))}return t.Ts=function(e,n,r,i,o){var u=new t(e,n,Date.now()+r,i,o);return u.start(r),u},t.prototype.start=function(t){var e=this;this.Is=setTimeout((function(){return e.As()}),t)},t.prototype.Rs=function(){return this.As()},t.prototype.cancel=function(t){null!==this.Is&&(this.clearTimeout(),this.Es.reject(new T(O.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
1)},t.prototype.As=function(){var t=this;this._s.Ps((function(){return null!==t.Is?(t.clearTimeout(),t.op().then((function(e){return t.Es.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.Is&&(this.ws(this),clearTimeout(this.Is),this.Is=null)},t}();function cr(t,e){if(l("AsyncQueue",e+": "+t),rr(t))return new T(O.UNAVAILABLE,e+": "+t);throw t}var hr="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",fr=function(){function t(){this.ys=[]}return t.prototype.gs=function(t){this.ys.push(t)},t.prototype.Vs=function(){this.ys.forEach((function(t){return t()}))},t}();function lr(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=dr(e)),e=pr(t.get(n),e);return dr(e)}function pr(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=o}}return n}function dr(t){return t+"\x01\x01"}function vr(t){var e=t.length;if(y(e>=2),2===e)return y("\x01"===t.charAt(0)&&"\x01"===t.charAt(1)),R.ct();for(var n=e-2,r=[],i="",o=0;o<e;){var u=t.indexOf("\x01",o);switch((u<0||u>n)&&v(),t.charAt(u+1)){case"\x01":var s=t.substring(o,u),a=void 0;0===i.length?a=s:(a=i+=s,i=""),r.push(a);break;case"\x10":i+=t.substring(o,u),i+="\0";break;case"\x11":i+=t.substring(o,u+1);break;default:v()}o=u+2}return new R(r)}var yr=function(t,e){this.seconds=t,this.nanoseconds=e},mr=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};mr.store="owner",mr.key="owner";var br=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};br.store="mutationQueues",br.keyPath="userId";var gr=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};gr.store="mutations",gr.keyPath="batchId",gr.userMutationsIndex="userMutationsIndex",gr.userMutationsKeyPath=["userId","batchId"];var wr=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,lr(e)]},t.key=function(t,e,n){return[t,lr(e),n]},t}();wr.store="documentMutations",wr.PLACEHOLDER=new wr;var _r=function(t,e){this.path=t,this.readTime=e},Ir=function(t,e){this.path=t,this.version=e},Er=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Er.store="remoteDocuments",Er.readTimeIndex="readTimeIndex",Er.readTimeIndexPath="readTime",Er.collectionReadTimeIndex="collectionReadTimeIndex",Er.collectionReadTimeIndexPath=["parentPath","readTime"];var Or=function(t){this.byteSize=t};Or.store="remoteDocumentGlobal",Or.key="remoteDocumentGlobalKey";var Tr=function(t,e,n,r,i,o,u){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=u};Tr.store="targets",Tr.keyPath="targetId",Tr.queryTargetsIndexName="queryTargetsIndex",Tr.queryTargetsKeyPath=["canonicalId","targetId"];var Nr=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Nr.store="targetDocuments",Nr.keyPath=["targetId","path"],Nr.documentTargetsIndex="documentTargetsIndex",Nr.documentTargetsKeyPath=["path","targetId"];var jr=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};jr.key="targetGlobalKey",jr.store="targetGlobal";var Ar=function(t,e){this.collectionId=t,this.parent=e};Ar.store="collectionParents",Ar.keyPath=["collectionId","parent"];var Dr=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Dr.store="clientMetadata",Dr.keyPath="clientId";var Sr=function(t,e,n){this.bundleId=t,this.createTime=e,this.version=n};Sr.store="bundles",Sr.keyPath="bundleId";var xr=function(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n};xr.store="namedQueries",xr.keyPath="name";var kr=Object(u.g)(Object(u.g)(Object(u.g)(Object(u.g)([br.store,gr.store,wr.store,Er.store,Tr.store,mr.store,jr.store,Nr.store],[Dr.store]),[Or.store]),[Ar.store]),[Sr.store,xr.store]),Pr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).ps=e,r.bs=n,r}return Object(u.c)(e,t),e}(fr);function Vr(t,e){var n=m(t);return tr.zn(n.ps,e)}var Cr=function(){function t(t,e,n,r){this.batchId=t,this.vs=e,this.baseMutations=n,this.mutations=r}return t.prototype.Ss=function(t,e,n){for(var r=n.Ds,i=0;i<this.mutations.length;i++){var o=this.mutations[i];o.key.isEqual(t)&&(e=Te(o,e,r[i]))}return e},t.prototype.Cs=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++)(u=r[n]).key.isEqual(t)&&(e=Ne(u,e,this.vs));for(var i=0,o=this.mutations;i<o.length;i++){var u;(u=o[i]).key.isEqual(t)&&(e=Ne(u,e,this.vs))}return e},t.prototype.xs=function(t){var e=this,n=t;return this.mutations.forEach((function(r){var i=e.Cs(r.key,t.get(r.key));i&&(n=n.zt(r.key,i))})),n},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),nn())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&_(this.mutations,t.mutations,(function(t,e){return Ae(t,e)}))&&_(this.baseMutations,t.baseMutations,(function(t,e){return Ae(t,e)}))},t}(),Lr=function(){function t(t,e,n,r){this.batch=t,this.Ns=e,this.Ds=n,this.$s=r}return t.from=function(e,n,r){y(e.mutations.length===r.length);for(var i=tn(),o=e.mutations,u=0;u<o.length;u++)i=i.zt(o[u].key,r[u].version);return new t(e,n,r,i)},t}(),Rr=function(t){this.Fs=t};function Ur(t,e){if(e.document)return Vn(t.Fs,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=q.Et(e.noDocument.path),r=Gr(e.noDocument.readTime);return new gt(n,r,{hasCommittedMutations:!!e.hasCommittedMutations})}if(e.unknownDocument){var i=q.Et(e.unknownDocument.path);return r=Gr(e.unknownDocument.version),new wt(i,r)}return v()}function Mr(t,e,n){var r=qr(n),i=e.key.path.X().it();if(e instanceof bt){var o=function(t,e){return{name:jn(t,e.key),fields:e.bt().mapValue.fields,updateTime:_n(t,e.version.j())}}(t.Fs,e),u=e.hasCommittedMutations;return new Er(null,null,o,u,r,i)}if(e instanceof gt){var s=e.key.path.it(),a=zr(e.version);return u=e.hasCommittedMutations,new Er(null,new _r(s,a),null,u,r,i)}if(e instanceof wt){var c=e.key.path.it(),h=zr(e.version);return new Er(new Ir(c,h),null,null,!0,r,i)}return v()}function qr(t){var e=t.j();return[e.seconds,e.nanoseconds]}function Fr(t){var e=new V(t[0],t[1]);return C.K(e)}function zr(t){var e=t.j();return new yr(e.seconds,e.nanoseconds)}function Gr(t){var e=new V(t.seconds,t.nanoseconds);return C.K(e)}function Br(t,e){for(var n=(e.baseMutations||[]).map((function(e){return Ln(t.Fs,e)})),r=0;r<e.mutations.length-1;++r){var i=e.mutations[r];if(r+1<e.mutations.length&&void 0!==e.mutations[r+1].transform){var o=e.mutations[r+1];i.updateTransforms=o.transform.fieldTransforms,e.mutations.splice(r+1,1),++r}}var u=e.mutations.map((function(e){return Ln(t.Fs,e)})),s=V.fromMillis(e.localWriteTimeMs);return new Cr(e.batchId,s,n,u)}function Qr(t){var e,n,r=Gr(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?Gr(t.lastLimboFreeSnapshotVersion):C.min();return void 0!==t.query.documents?(y(1===(n=t.query).documents.length),e=Wt(Gt(Sn(n.documents[0])))):e=function(t){return Wt(Mn(t))}(t.query),new ie(e,t.targetId,0,t.lastListenSequenceNumber,r,i,E.fromBase64String(t.resumeToken))}function Yr(t,e){var n,r=zr(e.Ot),i=zr(e.lastLimboFreeSnapshotVersion);n=Tt(e.target)?Rn(t.Fs,e.target):Un(t.Fs,e.target);var o=e.resumeToken.toBase64();return new Tr(e.targetId,Et(e.target),r,o,e.sequenceNumber,i,n)}function Hr(t){var e=Mn({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Zt(e,e.limit,"L"):e}var Kr=function(){function t(){}return t.prototype.Os=function(t,e){return Xr(t).get(e).next((function(t){if(t)return{id:(e=t).bundleId,createTime:Gr(e.createTime),version:e.version};var e}))},t.prototype.ks=function(t,e){return Xr(t).put({bundleId:(n=e).id,createTime:zr(On(n.createTime)),version:n.version});var n},t.prototype.Ms=function(t,e){return Wr(t).get(e).next((function(t){if(t)return{name:(e=t).name,query:Hr(e.bundledQuery),readTime:Gr(e.readTime)};var e}))},t.prototype.Ls=function(t,e){return Wr(t).put(function(t){return{name:t.name,readTime:zr(On(t.readTime)),bundledQuery:t.bundledQuery}}(e))},t}();function Xr(t){return Vr(t,Sr.store)}function Wr(t){return Vr(t,xr.store)}var Zr=function(){function t(){this.Bs=new Jr}return t.prototype.qs=function(t,e){return this.Bs.add(e),Jn.resolve()},t.prototype.Us=function(t,e){return Jn.resolve(this.Bs.getEntries(e))},t}(),Jr=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.tt(),n=t.X(),r=this.index[e]||new Ye(R.H),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.tt(),n=t.X(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new Ye(R.H)).it()},t}(),$r=function(){function t(){this.Qs=new Jr}return t.prototype.qs=function(t,e){var n=this;if(!this.Qs.has(e)){var r=e.tt(),i=e.X();t.gs((function(){n.Qs.add(e)}));var o={collectionId:r,parent:lr(i)};return ti(t).put(o)}return Jn.resolve()},t.prototype.Us=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[I(e),""],!1,!0);return ti(t).rs(r).next((function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(vr(o.parent))}return n}))},t}();function ti(t){return Vr(t,Ar.store)}var ei={Ks:!1,Ws:0,js:0,Gs:0},ni=function(){function t(t,e,n){this.zs=t,this.Hs=e,this.Js=n}return t.Ys=function(e){return new t(e,t.Xs,t.Zs)},t}();function ri(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){if(t.code!==O.FAILED_PRECONDITION||t.message!==hr)throw t;return f("LocalStore","Unexpectedly lost primary lease"),[2]}))}
1))}ni.Xs=10,ni.Zs=1e3,ni.ti=new ni(41943040,ni.Xs,ni.Zs),ni.ei=new ni(-1,0,0);var ii=function(){function t(t,e){this.ni=t,this.si=e,this.ii={}}return t.prototype.get=function(t){var e=this.ni(t),n=this.ii[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],u=o[0],s=o[1];if(this.si(u,t))return s}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.ni(t),r=this.ii[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.si(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.ii[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.ni(t),n=this.ii[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.si(n[r][0],t))return 1===n.length?delete this.ii[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){z(this.ii,(function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],u=o[0],s=o[1];t(u,s)}}))},t.prototype.et=function(){return G(this.ii)},t}(),oi=function(){function t(){this.ri=new ii((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),this.oi=!1}return t.prototype.ci=function(t){var e=this.ri.get(t);return e?e.readTime:C.min()},t.prototype.ai=function(t,e){this.ui(),this.ri.set(t.key,{hi:t,readTime:e})},t.prototype.li=function(t,e){void 0===e&&(e=null),this.ui(),this.ri.set(t,{hi:null,readTime:e})},t.prototype._i=function(t,e){this.ui();var n=this.ri.get(e);return void 0!==n?Jn.resolve(n.hi):this.fi(t,e)},t.prototype.getEntries=function(t,e){return this.di(t,e)},t.prototype.apply=function(t){return this.ui(),this.oi=!0,this.wi(t)},t.prototype.ui=function(){},t}();function ui(t,e,n){var r=t.store(gr.store),i=t.store(wr.store),o=[],u=IDBKeyRange.only(n.batchId),s=0,a=r.hs({range:u},(function(t,e,n){return s++,n.delete()}));o.push(a.next((function(){y(1===s)})));for(var c=[],h=0,f=n.mutations;h<f.length;h++){var l=f[h],p=wr.key(e,l.key.path,n.batchId);o.push(i.delete(p)),c.push(l.key)}return Jn.Mn(o).next((function(){return c}))}function si(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw v();e=t.noDocument}return JSON.stringify(e).length}var ai=function(){function t(t,e,n,r){this.userId=t,this.Qt=e,this.Ei=n,this.Ti=r,this.Ii={}}return t.mi=function(e,n,r,i){return y(""!==e.uid),new t(e.m()?e.uid:"",n,r,i)},t.prototype.Ai=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return hi(t).hs({index:gr.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.Ri=function(t,e,n,r){var i=this,o=fi(t),u=hi(t);return u.add({}).next((function(s){y("number"==typeof s);for(var a=new Cr(s,e,n,r),c=function(t,e,n){var r=n.baseMutations.map((function(e){return Cn(t.Fs,e)})),i=n.mutations.map((function(e){return Cn(t.Fs,e)}));return new gr(e,n.batchId,n.vs.toMillis(),r,i)}(i.Qt,i.userId,a),h=[],f=new Ye((function(t,e){return w(t.rt(),e.rt())})),l=0,p=r;l<p.length;l++){var d=p[l],v=wr.key(i.userId,d.key.path,s);f=f.add(d.key.path.X()),h.push(u.put(c)),h.push(o.put(v,wr.PLACEHOLDER))}return f.forEach((function(e){h.push(i.Ei.qs(t,e))})),t.gs((function(){i.Ii[s]=a.keys()})),Jn.Mn(h).next((function(){return a}))}))},t.prototype.Pi=function(t,e){var n=this;return hi(t).get(e).next((function(t){return t?(y(t.userId===n.userId),Br(n.Qt,t)):null}))},t.prototype.yi=function(t,e){var n=this;return this.Ii[e]?Jn.resolve(this.Ii[e]):this.Pi(t,e).next((function(t){if(t){var r=t.keys();return n.Ii[e]=r,r}return null}))},t.prototype.gi=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return hi(t).hs({index:gr.userMutationsIndex,range:i},(function(t,e,i){e.userId===n.userId&&(y(e.batchId>=r),o=Br(n.Qt,e)),i.done()})).next((function(){return o}))},t.prototype.Vi=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return hi(t).hs({index:gr.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.pi=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return hi(t).rs(gr.userMutationsIndex,n).next((function(t){return t.map((function(t){return Br(e.Qt,t)}))}))},t.prototype.bi=function(t,e){var n=this,r=wr.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return fi(t).hs({range:i},(function(r,i,u){var s=r[0],a=r[1],c=r[2],h=vr(a);if(s===n.userId&&e.path.isEqual(h))return hi(t).get(c).next((function(t){if(!t)throw v();y(t.userId===n.userId),o.push(Br(n.Qt,t))}));u.done()})).next((function(){return o}
1))},t.prototype.vi=function(t,e){var n=this,r=new Ye(w),i=[];return e.forEach((function(e){var o=wr.prefixForPath(n.userId,e.path),u=IDBKeyRange.lowerBound(o),s=fi(t).hs({range:u},(function(t,i,o){var u=t[0],s=t[1],a=t[2],c=vr(s);u===n.userId&&e.path.isEqual(c)?r=r.add(a):o.done()}));i.push(s)})),Jn.Mn(i).next((function(){return n.Si(t,r)}))},t.prototype.Di=function(t,e){var n=this,r=e.path,i=r.length+1,o=wr.prefixForPath(this.userId,r),u=IDBKeyRange.lowerBound(o),s=new Ye(w);return fi(t).hs({range:u},(function(t,e,o){var u=t[0],a=t[1],c=t[2],h=vr(a);u===n.userId&&r.nt(h)?h.length===i&&(s=s.add(c)):o.done()})).next((function(){return n.Si(t,s)}))},t.prototype.Si=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(hi(t).get(e).next((function(t){if(null===t)throw v();y(t.userId===n.userId),r.push(Br(n.Qt,t))})))})),Jn.Mn(i).next((function(){return r}))},t.prototype.Ci=function(t,e){var n=this;return ui(t.ps,this.userId,e).next((function(r){return t.gs((function(){n.xi(e.batchId)})),Jn.forEach(r,(function(e){return n.Ti.Ni(t,e)}))}))},t.prototype.xi=function(t){delete this.Ii[t]},t.prototype.$i=function(t){var e=this;return this.Ai(t).next((function(n){if(!n)return Jn.resolve();var r=IDBKeyRange.lowerBound(wr.prefixForUser(e.userId)),i=[];return fi(t).hs({range:r},(function(t,n,r){if(t[0]===e.userId){var o=vr(t[1]);i.push(o)}else r.done()})).next((function(){y(0===i.length)}))}))},t.prototype.Fi=function(t,e){return ci(t,this.userId,e)},t.prototype.Oi=function(t){var e=this;return li(t).get(this.userId).next((function(t){return t||new br(e.userId,-1,"")}))},t}();function ci(t,e,n){var r=wr.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),u=!1;return fi(t).hs({range:o,us:!0},(function(t,n,r){var o=t[0],s=t[1];t[2],o===e&&s===i&&(u=!0),r.done()})).next((function(){return u}))}function hi(t){return Vr(t,gr.store)}function fi(t){return Vr(t,wr.store)}function li(t){return Vr(t,br.store)}var pi=function(){function t(t){this.ki=t}return t.prototype.next=function(){return this.ki+=2,this.ki},t.Mi=function(){return new t(0)},t.Li=function(){return new t(-1)},t}(),di=function(){function t(t,e){this.Ti=t,this.Qt=e}return t.prototype.Bi=function(t){var e=this;return this.qi(t).next((function(n){var r=new pi(n.highestTargetId);return n.highestTargetId=r.next(),e.Ui(t,n).next((function(){return n.highestTargetId}))}))},t.prototype.Qi=function(t){return this.qi(t).next((function(t){return C.K(new V(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.Ki=function(t){return this.qi(t).next((function(t){return t.highestListenSequenceNumber}))},t.prototype.Wi=function(t,e,n){var r=this;return this.qi(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.j()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.Ui(t,i)}))},t.prototype.ji=function(t,e){var n=this;return this.Gi(t,e).next((function(){return n.qi(t).next((function(r){return r.targetCount+=1,n.zi(e,r),n.Ui(t,r)}))}))},t.prototype.Hi=function(t,e){return this.Gi(t,e)},t.prototype.Ji=function(t,e){var n=this;return this.Yi(t,e.targetId).next((function(){return vi(t).delete(e.targetId)})).next((function(){return n.qi(t)})).next((function(e){return y(e.targetCount>0),e.targetCount-=1,n.Ui(t,e)}))},t.prototype.Xi=function(t,e,n){var r=this,i=0,o=[];return vi(t).hs((function(u,s){var a=Qr(s);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(i++,o.push(r.Ji(t,a)))})).next((function(){return Jn.Mn(o)})).next((function(){return i}))},t.prototype.In=function(t,e){return vi(t).hs((function(t,n){var r=Qr(n);e(r)}))},t.prototype.qi=function(t){return yi(t).get(jr.key).next((function(t){return y(null!==t),t}))},t.prototype.Ui=function(t,e){return yi(t).put(jr.key,e)},t.prototype.Gi=function(t,e){return vi(t).put(Yr(this.Qt,e))},t.prototype.zi=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.Zi=function(t){return this.qi(t).next((function(t){return t.targetCount}))},t.prototype.tr=function(t,e){var n=Et(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return vi(t).hs({range:r,index:Tr.queryTargetsIndexName},(function(t,n,r){var o=Qr(n);Ot(e,o.target)&&(i=o,r.done())})).next((function(){return i}))},t.prototype.er=function(t,e,n){var r=this,i=[],o=mi(t);return e.forEach((function(e){var u=lr(e.path);i.push(o.put(new Nr(n,u))),i.push(r.Ti.nr(t,n,e))})),Jn.Mn(i)},t.prototype.sr=function(t,e,n){var r=this,i=mi(t);
1return Jn.forEach(e,(function(e){var o=lr(e.path);return Jn.Mn([i.delete([n,o]),r.Ti.ir(t,n,e)])}))},t.prototype.Yi=function(t,e){var n=mi(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.rr=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=mi(t),i=nn();return r.hs({range:n,us:!0},(function(t,e,n){var r=vr(t[1]),o=new q(r);i=i.add(o)})).next((function(){return i}))},t.prototype.Fi=function(t,e){var n=lr(e.path),r=IDBKeyRange.bound([n],[I(n)],!1,!0),i=0;return mi(t).hs({index:Nr.documentTargetsIndex,us:!0,range:r},(function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())})).next((function(){return i>0}))},t.prototype.Sn=function(t,e){return vi(t).get(e).next((function(t){return t?Qr(t):null}))},t}();function vi(t){return Vr(t,Tr.store)}function yi(t){return Vr(t,jr.store)}function mi(t){return Vr(t,Nr.store)}function bi(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],u=w(n,i);return 0===u?w(r,o):u}var gi=function(){function t(t){this.cr=t,this.buffer=new Ye(bi),this.ar=0}return t.prototype.ur=function(){return++this.ar},t.prototype.hr=function(t){var e=[t,this.ur()];if(this.buffer.size<this.cr)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();bi(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),t}(),wi=function(){function t(t,e){this.lr=t,this._s=e,this._r=!1,this.dr=null}return t.prototype.start=function(t){-1!==this.lr.params.zs&&this.wr(t)},t.prototype.stop=function(){this.dr&&(this.dr.cancel(),this.dr=null)},Object.defineProperty(t.prototype,"Er",{get:function(){return null!==this.dr},enumerable:!1,configurable:!0}),t.prototype.wr=function(t){var e=this,n=this._r?3e5:6e4;f("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.dr=this._s.Tr("lru_garbage_collection",n,(function(){return Object(u.b)(e,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:this.dr=null,this._r=!0,n.label=1;case 1:return n.trys.push([1,3,,7]),[4,t.Ir(this.lr)];case 2:return n.sent(),[3,7];case 3:return rr(e=n.sent())?(f("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,ri(e)];case 5:n.sent(),n.label=6;case 6:return[3,7];case 7:return[4,this.wr(t)];case 8:return n.sent(),[2]}}))}))}))},t}(),_i=function(){function t(t,e){this.mr=t,this.params=e}return t.prototype.Ar=function(t,e){return this.mr.Rr(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.Pr=function(t,e){var n=this;if(0===e)return Jn.resolve(P.q);var r=new gi(e);return this.mr.In(t,(function(t){return r.hr(t.sequenceNumber)})).next((function(){return n.mr.yr(t,(function(t){return r.hr(t)}))})).next((function(){return r.maxValue}))},t.prototype.Xi=function(t,e,n){return this.mr.Xi(t,e,n)},t.prototype.gr=function(t,e){return this.mr.gr(t,e)},t.prototype.Vr=function(t,e){var n=this;return-1===this.params.zs?(f("LruGarbageCollector","Garbage collection skipped; disabled"),Jn.resolve(ei)):this.pr(t).next((function(r){return r<n.params.zs?(f("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.zs),ei):n.br(t,e)}))},t.prototype.pr=function(t){return this.mr.pr(t)},t.prototype.br=function(t,e){var n,i,o,u,s,a,c,l=this,p=Date.now();return this.Ar(t,this.params.Hs).next((function(e){return e>l.params.Js?(f("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+l.params.Js+" from "+e),i=l.params.Js):i=e,u=Date.now(),l.Pr(t,i)})).next((function(r){return n=r,s=Date.now(),l.Xi(t,n,e)})).next((function(e){return o=e,a=Date.now(),l.gr(t,n)})).next((function(t){return c=Date.now(),h()<=r.a.DEBUG&&f("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(u-p)+"ms\n\tDetermined least recently used "+i+" in "+(s-u)+"ms\n\tRemoved "+o+" targets in "+(a-s)+"ms\n\tRemoved "+t+" documents in "+(c-a)+"ms\nTotal Duration: "+(c-p)+"ms"),Jn.resolve({Ks:!0,Ws:i,js:o,Gs:t})}))},t}(),Ii=function(){function t(t,e){this.db=t,this.lr=function(t,e){return new _i(t,e)}(this,e)}return t.prototype.Rr=function(t){var e=this.vr(t);return this.db.Sr().Zi(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.vr=function(t){var e=0;return this.yr(t,(function(t){e++})).next((function(){return e}))},t.prototype.In=function(t,e){return this.db.Sr().In(t,e)},t.prototype.yr=function(t,e){return this.Dr(t,(function(t,n){return e(n)}))},t.prototype.nr=function(t,e,n){return Ei(t,n)},t.prototype.ir=function(t,e,n){return Ei(t,n)},t.prototype.Xi=function(t,e,n){return this.db.Sr().Xi(t,e,n)},t.prototype.Ni=function(t,e){return Ei(t,e)},t.prototype.Cr=function(t,e){return function(t,e){var n=!1;return li(t).ls((function(r){return ci(t,r,e).next((function(t){return t&&(n=!0),Jn.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.gr=function(t,e){var n=this,r=this.db.$r().Nr(),i=[],o=0;return this.Dr(t,(function(u,s){if(s<=e){var a=n.Cr(t,u).next((function(e){if(!e)return o++,r._i(t,u).next((function(){return r.li(u),mi(t).delete([0,lr(u.path)])}))}));i.push(a)}})).next((function(){return Jn.Mn(i)})).next((function(){return r.apply(t)})).next((function(){return o}
1))},t.prototype.removeTarget=function(t,e){var n=e.kt(t.bs);return this.db.Sr().Hi(t,n)},t.prototype.Fr=function(t,e){return Ei(t,e)},t.prototype.Dr=function(t,e){var n,r=mi(t),i=P.q;return r.hs({index:Nr.documentTargetsIndex},(function(t,r){var o=t[0],u=(t[1],r.path),s=r.sequenceNumber;0===o?(i!==P.q&&e(new q(vr(n)),i),i=s,n=u):i=P.q})).next((function(){i!==P.q&&e(new q(vr(n)),i)}))},t.prototype.pr=function(t){return this.db.$r().Or(t)},t}();function Ei(t,e){return mi(t).put(function(t,e){return new Nr(0,lr(t.path),e)}(e,t.bs))}var Oi=function(){function t(t,e){this.Qt=t,this.Ei=e}return t.prototype.ai=function(t,e,n){return ji(t).put(Ai(e),n)},t.prototype.li=function(t,e){var n=ji(t),r=Ai(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next((function(r){return r.byteSize+=e,n.kr(t,r)}))},t.prototype._i=function(t,e){var n=this;return ji(t).get(Ai(e)).next((function(t){return n.Mr(t)}))},t.prototype.Lr=function(t,e){var n=this;return ji(t).get(Ai(e)).next((function(t){var e=n.Mr(t);return e?{hi:e,size:si(t)}:null}))},t.prototype.getEntries=function(t,e){var n=this,r=We();return this.Br(t,e,(function(t,e){var i=n.Mr(e);r=r.zt(t,i)})).next((function(){return r}))},t.prototype.qr=function(t,e){var n=this,r=We(),i=new Ge(q.H);return this.Br(t,e,(function(t,e){var o=n.Mr(e);o?(r=r.zt(t,o),i=i.zt(t,si(e))):(r=r.zt(t,null),i=i.zt(t,0))})).next((function(){return{Ur:r,Qr:i}}))},t.prototype.Br=function(t,e,n){if(e.et())return Jn.resolve();var r=IDBKeyRange.bound(e.first().path.it(),e.last().path.it()),i=e.te(),o=i.oe();return ji(t).hs({range:r},(function(t,e,r){for(var u=q.Et(t);o&&q.H(o,u)<0;)n(o,null),o=i.oe();o&&o.isEqual(u)&&(n(o,e),o=i.ce()?i.oe():null),o?r.ss(o.path.it()):r.done()})).next((function(){for(;o;)n(o,null),o=i.ce()?i.oe():null}))},t.prototype.Kr=function(t,e,n){var r=this,i=Je(),o=e.path.length+1,u={};if(n.isEqual(C.min())){var s=e.path.it();u.range=IDBKeyRange.lowerBound(s)}else{var a=e.path.it(),c=qr(n);u.range=IDBKeyRange.lowerBound([a,c],!0),u.index=Er.collectionReadTimeIndex}return ji(t).hs(u,(function(t,n,u){if(t.length===o){var s=Ur(r.Qt,n);e.path.nt(s.key.path)?s instanceof bt&&ee(e,s)&&(i=i.zt(s.key,s)):u.done()}})).next((function(){return i}))},t.prototype.Nr=function(t){return new Ti(this,!!t&&t.Wr)},t.prototype.Or=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return Ni(t).get(Or.key).next((function(t){return y(!!t),t}))},t.prototype.kr=function(t,e){return Ni(t).put(Or.key,e)},t.prototype.Mr=function(t){if(t){var e=Ur(this.Qt,t);return e instanceof gt&&e.version.isEqual(C.min())?null:e}return null},t}(),Ti=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).jr=e,r.Wr=n,r.Gr=new ii((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),r}return Object(u.c)(e,t),e.prototype.wi=function(t){var e=this,n=[],r=0,i=new Ye((function(t,e){return w(t.rt(),e.rt())}));return this.ri.forEach((function(o,u){var s=e.Gr.get(o);if(u.hi){var a=Mr(e.jr.Qt,u.hi,e.ci(o));i=i.add(o.path.X());var c=si(a);r+=c-s,n.push(e.jr.ai(t,o,a))}else if(r-=s,e.Wr){var h=Mr(e.jr.Qt,new gt(o,C.min()),e.ci(o));n.push(e.jr.ai(t,o,h))}else n.push(e.jr.li(t,o))})),i.forEach((function(r){n.push(e.jr.Ei.qs(t,r))})),n.push(this.jr.updateMetadata(t,r)),Jn.Mn(n)},e.prototype.fi=function(t,e){var n=this;return this.jr.Lr(t,e).next((function(t){return null===t?(n.Gr.set(e,0),null):(n.Gr.set(e,t.size),t.hi)}))},e.prototype.di=function(t,e){var n=this;return this.jr.qr(t,e).next((function(t){var e=t.Ur;return t.Qr.forEach((function(t,e){n.Gr.set(t,e)})),e}))},e}(oi);function Ni(t){return Vr(t,Or.store)}function ji(t){return Vr(t,Er.store)}function Ai(t){return t.path.it()}var Di=function(){function t(t){this.Qt=t}return t.prototype.Jn=function(t,e,n,r){var i=this;y(n<r&&n>=0&&r<=11);var o=new $n("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(mr.store)}(t),function(t){t.createObjectStore(br.store,{keyPath:br.keyPath}),t.createObjectStore(gr.store,{keyPath:gr.keyPath,autoIncrement:!0}).createIndex(gr.userMutationsIndex,gr.userMutationsKeyPath,{unique:!0}),t.createObjectStore(wr.store)}(t),Si(t),function(t){t.createObjectStore(Er.store)}(t));var u=Jn.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(Nr.store),t.deleteObjectStore(Tr.store),t.deleteObjectStore(jr.store)}(t),Si(t)),u=u.next((function(){return function(t){var e=t.store(jr.store),n=new jr(0,0,C.min().j(),0);return e.put(jr.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(u=u.next((function(){return function(t,e){return e.store(gr.store).rs().next((function(n){t.deleteObjectStore(gr.store),t.createObjectStore(gr.store,{keyPath:gr.keyPath,autoIncrement:!0}).createIndex(gr.userMutationsIndex,gr.userMutationsKeyPath,{unique:!0});var r=e.store(gr.store),i=n.map((function(t){return r.put(t)}));return Jn.Mn(i)}))}(t,o)}))),u=u.next((function(){!function(t){t.createObjectStore(Dr.store,{keyPath:Dr.keyPath})}(t)}))),n<5&&r>=5&&(u=u.next((function(){return i.zr(o)}))),n<6&&r>=6&&(u=u.next((function(){return function(t){t.createObjectStore(Or.store)}(t),i.Hr(o)}))),n<7&&r>=7&&(u=u.next((function(){return i.Jr(o)}))),n<8&&r>=8&&(u=u.next((function(){return i.Yr(t,o)}))),n<9&&r>=9&&(u=u.next((function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}
1(t),function(t){var e=t.objectStore(Er.store);e.createIndex(Er.readTimeIndex,Er.readTimeIndexPath,{unique:!1}),e.createIndex(Er.collectionReadTimeIndex,Er.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(u=u.next((function(){return i.Xr(o)}))),n<11&&r>=11&&(u=u.next((function(){!function(t){t.createObjectStore(Sr.store,{keyPath:Sr.keyPath})}(t),function(t){t.createObjectStore(xr.store,{keyPath:xr.keyPath})}(t)}))),u},t.prototype.Hr=function(t){var e=0;return t.store(Er.store).hs((function(t,n){e+=si(n)})).next((function(){var n=new Or(e);return t.store(Or.store).put(Or.key,n)}))},t.prototype.zr=function(t){var e=this,n=t.store(br.store),r=t.store(gr.store);return n.rs().next((function(n){return Jn.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.rs(gr.userMutationsIndex,i).next((function(r){return Jn.forEach(r,(function(r){y(r.userId===n.userId);var i=Br(e.Qt,r);return ui(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.Jr=function(t){var e=t.store(Nr.store),n=t.store(Er.store);return t.store(jr.store).get(jr.key).next((function(t){var r=[];return n.hs((function(n,i){var o=new R(n),u=function(t){return[0,lr(t)]}(o);r.push(e.get(u).next((function(n){return n?Jn.resolve():function(n){return e.put(new Nr(0,lr(n),t.highestListenSequenceNumber))}(o)})))})).next((function(){return Jn.Mn(r)}))}))},t.prototype.Yr=function(t,e){t.createObjectStore(Ar.store,{keyPath:Ar.keyPath});var n=e.store(Ar.store),r=new Jr,i=function(t){if(r.add(t)){var e=t.tt(),i=t.X();return n.put({collectionId:e,parent:lr(i)})}};return e.store(Er.store).hs({us:!0},(function(t,e){var n=new R(t);return i(n.X())})).next((function(){return e.store(wr.store).hs({us:!0},(function(t,e){t[0];var n=t[1],r=(t[2],vr(n));return i(r.X())}))}))},t.prototype.Xr=function(t){var e=this,n=t.store(Tr.store);return n.hs((function(t,r){var i=Qr(r),o=Yr(e.Qt,i);return n.put(o)}))},t}();function Si(t){t.createObjectStore(Nr.store,{keyPath:Nr.keyPath}).createIndex(Nr.documentTargetsIndex,Nr.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Tr.store,{keyPath:Tr.keyPath}).createIndex(Tr.queryTargetsIndexName,Tr.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(jr.store)}var xi="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.",ki=function(){function t(e,n,r,i,o,u,s,a,c,h){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Zr=o,this.window=u,this.document=s,this.eo=c,this.no=h,this.so=null,this.io=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ro=null,this.inForeground=!1,this.oo=null,this.co=null,this.ao=Number.NEGATIVE_INFINITY,this.uo=function(t){return Promise.resolve()},!t.Kn())throw new T(O.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.Ti=new Ii(this,i),this.ho=n+"main",this.Qt=new Rr(a),this.lo=new tr(this.ho,11,new Di(this.Qt)),this._o=new di(this.Ti,this.Qt),this.Ei=new $r,this.fo=function(t,e){return new Oi(t,e)}(this.Qt,this.Ei),this.wo=new Kr,this.window&&this.window.localStorage?this.Eo=this.window.localStorage:(this.Eo=null,!1===h&&l("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.prototype.start=function(){var t=this;return this.To().then((function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new T(O.FAILED_PRECONDITION,xi);return t.Io(),t.mo(),t.Ao(),t.runTransaction("getHighestListenSequenceNumber","readonly",(function(e){return t._o.Ki(e)}))})).then((function(e){t.so=new P(e,t.eo)})).then((function(){t.io=!0})).catch((function(e){return t.lo&&t.lo.close(),Promise.reject(e)}))},t.prototype.Ro=function(t){var e=this;return this.uo=function(n){return Object(u.b)(e,void 0,void 0,(function(){return Object(u.d)(this,(function(e){return this.Er?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.Po=function(t){var e=this;this.lo.Xn((function(n){return Object(u.b)(e,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return null===n.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
1))}))}))},t.prototype.yo=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Zr.Ps((function(){return Object(u.b)(e,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return this.Er?[4,this.To()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.To=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(function(e){return Vi(e).put(new Dr(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t.Vo(e).next((function(e){e||(t.isPrimary=!1,t.Zr.po((function(){return t.uo(!1)})))}))})).next((function(){return t.bo(e)})).next((function(n){return t.isPrimary&&!n?t.vo(e).next((function(){return!1})):!!n&&t.So(e).next((function(){return!0}))}))})).catch((function(e){if(rr(e))return f("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return f("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.Zr.po((function(){return t.uo(e)})),t.isPrimary=e}))},t.prototype.Vo=function(t){var e=this;return Pi(t).get(mr.key).next((function(t){return Jn.resolve(e.Do(t))}))},t.prototype.Co=function(t){return Vi(t).delete(this.clientId)},t.prototype.xo=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e,n,r,i=this;return Object(u.d)(this,(function(o){switch(o.label){case 0:return!this.isPrimary||this.No(this.ao,18e5)?[3,2]:(this.ao=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(function(t){var e=Vr(t,Dr.store);return e.rs().next((function(t){var n=i.$o(t,18e5),r=t.filter((function(t){return-1===n.indexOf(t)}));return Jn.forEach(r,(function(t){return e.delete(t.clientId)})).next((function(){return r}))}))})).catch((function(){return[]}))]);case 1:if(t=o.sent(),this.Eo)for(e=0,n=t;e<n.length;e++)r=n[e],this.Eo.removeItem(this.Fo(r.clientId));o.label=2;case 2:return[2]}}
1))}))},t.prototype.Ao=function(){var t=this;this.co=this.Zr.Tr("client_metadata_refresh",4e3,(function(){return t.To().then((function(){return t.xo()})).then((function(){return t.Ao()}))}))},t.prototype.Do=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.bo=function(t){var e=this;return this.no?Jn.resolve(!0):Pi(t).get(mr.key).next((function(n){if(null!==n&&e.No(n.leaseTimestampMs,5e3)&&!e.Oo(n.ownerId)){if(e.Do(n)&&e.networkEnabled)return!0;if(!e.Do(n)){if(!n.allowTabSynchronization)throw new T(O.FAILED_PRECONDITION,xi);return!1}}return!(!e.networkEnabled||!e.inForeground)||Vi(t).rs().next((function(t){return void 0===e.$o(t,5e3).find((function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1}))}))})).next((function(t){return e.isPrimary!==t&&f("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.ko=function(){return Object(u.b)(this,void 0,void 0,(function(){var t=this;return Object(u.d)(this,(function(e){switch(e.label){case 0:return this.io=!1,this.Mo(),this.co&&(this.co.cancel(),this.co=null),this.Lo(),this.Bo(),[4,this.lo.runTransaction("shutdown","readwrite",[mr.store,Dr.store],(function(e){var n=new Pr(e,P.q);return t.vo(n).next((function(){return t.Co(n)}))}))];case 1:return e.sent(),this.lo.close(),this.qo(),[2]}}))}))},t.prototype.$o=function(t,e){var n=this;return t.filter((function(t){return n.No(t.updateTimeMs,e)&&!n.Oo(t.clientId)}))},t.prototype.Uo=function(){var t=this;return this.runTransaction("getActiveClients","readonly",(function(e){return Vi(e).rs().next((function(e){return t.$o(e,18e5).map((function(t){return t.clientId}))}))}))},Object.defineProperty(t.prototype,"Er",{get:function(){return this.io},enumerable:!1,configurable:!0}),t.prototype.Qo=function(t){return ai.mi(t,this.Qt,this.Ei,this.Ti)},t.prototype.Sr=function(){return this._o},t.prototype.$r=function(){return this.fo},t.prototype.Ko=function(){return this.Ei},t.prototype.Wo=function(){return this.wo},t.prototype.runTransaction=function(t,e,n){var r=this;f("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.lo.runTransaction(t,o,kr,(function(o){return i=new Pr(o,r.s
1o?r.so.next():P.q),"readwrite-primary"===e?r.Vo(i).next((function(t){return!!t||r.bo(i)})).next((function(e){if(!e)throw l("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.Zr.po((function(){return r.uo(!1)})),new T(O.FAILED_PRECONDITION,hr);return n(i)})).next((function(t){return r.So(i).next((function(){return t}))})):r.jo(i).next((function(){return n(i)}))})).then((function(t){return i.Vs(),t}))},t.prototype.jo=function(t){var e=this;return Pi(t).get(mr.key).next((function(t){if(null!==t&&e.No(t.leaseTimestampMs,5e3)&&!e.Oo(t.ownerId)&&!e.Do(t)&&!(e.no||e.allowTabSynchronization&&t.allowTabSynchronization))throw new T(O.FAILED_PRECONDITION,xi)}))},t.prototype.So=function(t){var e=new mr(this.clientId,this.allowTabSynchronization,Date.now());return Pi(t).put(mr.key,e)},t.Kn=function(){return tr.Kn()},t.prototype.vo=function(t){var e=this,n=Pi(t);return n.get(mr.key).next((function(t){return e.Do(t)?(f("IndexedDbPersistence","Releasing primary lease."),n.delete(mr.key)):Jn.resolve()}))},t.prototype.No=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(l("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.Io=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.oo=function(){t.Zr.Ps((function(){return t.inForeground="visible"===t.document.visibilityState,t.To()}))},this.document.addEventListener("visibilitychange",this.oo),this.inForeground="visible"===this.document.visibilityState)},t.prototype.Lo=function(){this.oo&&(this.document.removeEventListener("visibilitychange",this.oo),this.oo=null)},t.prototype.mo=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.ro=function(){e.Mo(),e.Zr.Ps((function(){return e.ko()}))},this.window.addEventListener("unload",this.ro))},t.prototype.Bo=function(){this.ro&&(this.window.removeEventListener("unload",this.ro),this.ro=null)},t.prototype.Oo=function(t){var e;try{var n=null!==(null===(e=this.Eo)||void 0===e?void 0:e.getItem(this.Fo(t)));return f("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return l("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype.Mo=function(){if(this.Eo)try{this.Eo.setItem(this.Fo(this.clientId),String(Date.now()))}catch(t){l("Failed to set zombie client id.",t)}},t.prototype.qo=function(){if(this.Eo)try{this.Eo.removeItem(this.Fo(this.clientId))}catch(t){}},t.prototype.Fo=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function Pi(t){return Vr(t,mr.store)}function Vi(t){return Vr(t,Dr.store)}function Ci(t,e){var n=t.projectId;return t.o||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}var Li=function(t,e){this.progress=t,this.Go=e},Ri=function(){function t(t,e,n){this.fo=t,this.zo=e,this.Ei=n}return t.prototype.Ho=function(t,e){var n=this;return this.zo.bi(t,e).next((function(r){return n.Jo(t,e,r)}))},t.prototype.Jo=function(t,e,n){return this.fo._i(t,e).next((function(t){for(var r=0,i=n;r<i.length;r++)t=i[r].Cs(e,t);return t}))},t.prototype.Yo=function(t,e,n){var r=We();return e.forEach((function(t,e){for(var i=0,o=n;i<o.length;i++)e=o[i].Cs(t,e);r=r.zt(t,e)})),r},t.prototype.Xo=function(t,e){var n=this;return this.fo.getEntries(t,e).next((function(e){return n.Zo(t,e)}))},t.prototype.Zo=function(t,e){var n=this;return this.zo.vi(t,e).next((function(r){var i=n.Yo(t,e,r),o=Xe();return i.forEach((function(t,e){e||(e=new gt(t,C.min())),o=o.zt(t,e)})),o}))},t.prototype.Kr=function(t,e,n){return function(t){return q.wt(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.tc(t,e.path):Kt(e)?this.ec(t,e,n):this.nc(t,e,n)},t.prototype.tc=function(t,e){return this.Ho(t,new q(e)).next((function(t){var e=Je();return t instanceof bt&&(e=e.zt(t.key,t)),e}))},t.prototype.ec=function(t,e,n){var r=this,i=e.collectionGroup,o=Je();return this.Ei.Us(t,i).next((function(u){return Jn.forEach(u,(function(u){var s=function(t,e){return new Ft(e,null,t.xt.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,u.child(i));return r.nc(t,s,n).next((function(t){t.forEach((function(t,e){o=o.zt(t,e)}))}
1))})).next((function(){return o}))}))},t.prototype.nc=function(t,e,n){var r,i,o=this;return this.fo.Kr(t,e,n).next((function(n){return r=n,o.zo.Di(t,e)})).next((function(e){return i=e,o.sc(t,i,r).next((function(t){r=t;for(var e=0,n=i;e<n.length;e++)for(var o=n[e],u=0,s=o.mutations;u<s.length;u++){var a=s[u],c=a.key,h=Ne(a,r.get(c),o.vs);r=h instanceof bt?r.zt(c,h):r.remove(c)}}))})).next((function(){return r.forEach((function(t,n){ee(e,n)||(r=r.remove(t))})),r}))},t.prototype.sc=function(t,e,n){for(var r=nn(),i=0,o=e;i<o.length;i++)for(var u=0,s=o[i].mutations;u<s.length;u++){var a=s[u];a instanceof xe&&null===n.get(a.key)&&(r=r.add(a.key))}var c=n;return this.fo.getEntries(t,r).next((function(t){return t.forEach((function(t,e){null!==e&&e instanceof bt&&(c=c.zt(t,e))})),c}))},t}(),Ui=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.ic=n,this.rc=r}return t.oc=function(e,n){for(var r=nn(),i=nn(),o=0,u=n.docChanges;o<u.length;o++){var s=u[o];switch(s.type){case 0:r=r.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}}return new t(e,n.fromCache,r,i)},t}(),Mi=function(){function t(){}return t.prototype.cc=function(t){this.ac=t},t.prototype.Kr=function(t,e,n,i){var o=this;return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.xt.length||1===t.xt.length&&t.xt[0].field.ut())}(e)||n.isEqual(C.min())?this.uc(t,e):this.ac.Xo(t,i).next((function(u){var s=o.hc(e,u);return(Bt(e)||Qt(e))&&o.lc(e.limitType,s,i,n)?o.uc(t,e):(h()<=r.a.DEBUG&&f("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),te(e)),o.ac.Kr(t,e,n).next((function(t){return s.forEach((function(e){t=t.zt(e.key,e)})),t})))}))},t.prototype.hc=function(t,e){var n=new Ye(ne(t));return e.forEach((function(e,r){r instanceof bt&&ee(t,r)&&(n=n.add(r))})),n},t.prototype.lc=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version._(r)>0)},t.prototype.uc=function(t,e){return h()<=r.a.DEBUG&&f("QueryEngine","Using full collection scan to execute query:",te(e)),this.ac.Kr(t,e,C.min())},t}(),qi=function(){function t(t,e,n,r){this.persistence=t,this._c=e,this.Qt=r,this.fc=new Ge(w),this.dc=new ii((function(t){return Et(t)}),Ot),this.wc=C.min(),this.zo=t.Qo(n),this.Ec=t.$r(),this._o=t.Sr(),this.Tc=new Ri(this.Ec,this.zo,this.persistence.Ko()),this.wo=t.Wo(),this._c.cc(this.Tc)}return t.prototype.Ir=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.Vr(n,e.fc)}))},t}();function Fi(t,e,n,r){return new qi(t,e,n,r)}function zi(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o;return Object(u.d)(this,(function(u){switch(u.label){case 0:return n=m(t),r=n.zo,i=n.Tc,[4,n.persistence.runTransaction("Handle user change","readonly",(function(t){var o;return n.zo.pi(t).next((function(u){return o=u,r=n.persistence.Qo(e),i=new Ri(n.Ec,r,n.persistence.Ko()),r.pi(t)})).next((function(e){for(var n=[],r=[],u=nn(),s=0,a=o;s<a.length;s++){var c=a[s];n.push(c.batchId);for(var h=0,f=c.mutations;h<f.length;h++){var l=f[h];u=u.add(l.key)}}for(var p=0,d=e;p<d.length;p++){var v=d[p];r.push(v.batchId);for(var y=0,m=v.mutations;y<m.length;y++){var b=m[y];u=u.add(b.key)}}return i.Xo(t,u).next((function(t){return{Ic:t,mc:n,Ac:r}}))}))}))];case 1:return o=u.sent(),[2,(n.zo=r,n.Tc=i,n._c.cc(n.Tc),o)]}}))}))}function Gi(t,e){var n=m(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(t){var r=e.batch.keys(),i=n.Ec.Nr({Wr:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),u=Jn.resolve();return o.forEach((function(t){u=u.next((function(){return r._i(e,t)})).next((function(e){var o=e,u=n.$s.get(t);y(null!==u),(!o||o.version._(u)<0)&&(o=i.Ss(t,o,n))&&r.ai(o,n.Ns)}))})),u.next((function(){return t.zo.Ci(e,i)}))}(n,t,e,i).next((function(){return i.apply(t)})).next((function(){return n.zo.$i(t)})).next((function(){return n.Tc.Xo(t,r)}))}))}function Bi(t){var e=m(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(function(t){return e._o.Qi(t)}))}function Qi(t,e){var n=m(t),r=e.Ot,i=n.fc;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(function(t){var o=n.Ec.Nr({Wr:!0});i=n.fc;var u=[];e.$e.forEach((function(e,o){var s=i.get(o);if(s){u.push(n._o.sr(t,e.Qe,o).next((function(){return n._o.er(t,e.qe,o)})));var a=e.resumeToken;if(a.l()>0){var c=s.Mt(a,r).kt(t.bs);i=i.zt(o,c),function(t,e,n){return y(e.resumeToken.l()>0),0===t.resumeToken.l()||e.Ot.W()-t.Ot.W()>=3e8||n.qe.size+n.Ue.size+n.Qe.size>0}(s,c,e)&&u.push(n._o.Hi(t,c))}}}));var s=Xe();if(e.Oe.forEach((function(r,i){e.ke.has(r)&&u.push(n.persistence.Ti.Fr
1(t,r))})),u.push(Yi(t,o,e.Oe,r,void 0).next((function(t){s=t}))),!r.isEqual(C.min())){var a=n._o.Qi(t).next((function(e){return n._o.Wi(t,t.bs,r)}));u.push(a)}return Jn.Mn(u).next((function(){return o.apply(t)})).next((function(){return n.Tc.Zo(t,s)}))})).then((function(t){return n.fc=i,t}))}function Yi(t,e,n,r,i){var o=nn();return n.forEach((function(t){return o=o.add(t)})),e.getEntries(t,o).next((function(t){var o=Xe();return n.forEach((function(n,u){var s=t.get(n),a=(null==i?void 0:i.get(n))||r;u instanceof gt&&u.version.isEqual(C.min())?(e.li(n,a),o=o.zt(n,u)):null==s||u.version._(s.version)>0||0===u.version._(s.version)&&s.hasPendingWrites?(e.ai(u,a),o=o.zt(n,u)):f("LocalStore","Ignoring outdated watch update for ",n,". Current version:",s.version," Watch version:",u.version)})),o}))}function Hi(t,e){var n=m(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(function(t){return void 0===e&&(e=-1),n.zo.gi(t,e)}))}function Ki(t,e){var n=m(t);return n.persistence.runTransaction("Allocate target","readwrite",(function(t){var r;return n._o.tr(t,e).next((function(i){return i?(r=i,Jn.resolve(r)):n._o.Bi(t).next((function(i){return r=new ie(e,i,0,t.bs),n._o.ji(t,r).next((function(){return r}))}))}))})).then((function(t){var r=n.fc.get(t.targetId);return(null===r||t.Ot._(r.Ot)>0)&&(n.fc=n.fc.zt(t.targetId,t),n.dc.set(e,t.targetId)),t}))}function Xi(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s;return Object(u.d)(this,(function(u){switch(u.label){case 0:r=m(t),i=r.fc.get(e),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(t){return r.persistence.Ti.removeTarget(t,i)}))];case 2:u.sent(),u.label=3;case 3:return[3,5];case 4:if(!rr(s=u.sent()))throw s;return f("LocalStore","Failed to update sequence numbers for target "+e+": "+s),[3,5];case 5:return r.fc=r.fc.remove(e),r.dc.delete(i.target),[2]}}))}))}function Wi(t,e,n){var r=m(t),i=C.min(),o=nn();return r.persistence.runTransaction("Execute query","readonly",(function(t){return function(t,e,n){var r=m(t),i=r.dc.get(n);return void 0!==i?Jn.resolve(r.fc.get(i)):r._o.tr(e,n)}(r,t,Wt(e)).next((function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r._o.rr(t,e.targetId).next((function(t){o=t}))})).next((function(){return r._c.Kr(t,e,n?i:C.min(),n?o:nn())})).next((function(t){return{documents:t,Rc:o}}))}))}function Zi(t,e){var n=m(t),r=m(n._o),i=n.fc.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(function(t){return r.Sn(t,e).next((function(t){return t?t.target:null}))}))}function Ji(t){var e=m(t);return e.persistence.runTransaction("Get new document changes","readonly",(function(t){return function(t,e,n){var r=m(t),i=Xe(),o=qr(n),u=ji(e),s=IDBKeyRange.lowerBound(o,!0);return u.hs({index:Er.readTimeIndex,range:s},(function(t,e){var n=Ur(r.Qt,e);i=i.zt(n.key,n),o=e.readTime})).next((function(){return{Go:i,readTime:Fr(o)}}))}(e.Ec,t,e.wc)})).then((function(t){var n=t.Go,r=t.readTime;return e.wc=r,n}))}function $i(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){return[2,(e=m(t)).persistence.runTransaction("Synchronize last document change read time","readonly",(function(t){return function(t){var e=ji(t),n=C.min();return e.hs({index:Er.readTimeIndex,reverse:!0},(function(t,e,r){e.readTime&&(n=Fr(e.readTime)),r.done()})).next((function(){return n}))}(t)})).then((function(t){e.wc=t}))]}))}))}function to(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o,s,a,c,h,f,l,p,d;return Object(u.d)(this,(function(u){switch(u.label){case 0:for(i=m(t),o=nn(),s=Xe(),a=tn(),c=0,h=n;c<h.length;c++)f=h[c],l=e.Pc(f.metadata.name),f.document&&(o=o.add(l)),s=s.zt(l,e.yc(f)),a=a.zt(l,e.gc(f.metadata.readTime));return p=i.Ec.Nr({Wr:!0}),[4,Ki(i,function(t){return Wt(Gt(R.ot("__bundle__/docs/"+t)))}(r))];case 1:return d=u.sent(),[2,i.persistence.runTransaction("Apply bundle documents","readwrite",(function(t){return Yi(t,p,s,C.min(),a).next((function(e){return p.apply(t),e})).next((function(e){return i._o.Yi(t,d.targetId).next((function(){return i._o.er(t,o,d.targetId)})).next((function(){return i.Tc.Zo(t,e)}))}
1))}))]}}))}))}function eo(t,e,n){return void 0===n&&(n=nn()),Object(u.b)(this,void 0,void 0,(function(){var r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return[4,Ki(t,Wt(Hr(e.bundledQuery)))];case 1:return r=o.sent(),[2,(i=m(t)).persistence.runTransaction("Save named query","readwrite",(function(t){var o=On(e.readTime);if(r.Ot._(o)>=0)return i.wo.Ls(t,e);var u=r.Mt(E.T,o);return i.fc=i.fc.zt(u.targetId,u),i._o.Hi(t,u).next((function(){return i._o.Yi(t,r.targetId)})).next((function(){return i._o.er(t,n,r.targetId)})).next((function(){return i.wo.Ls(t,e)}))}))]}}))}))}var no=function(){function t(t){this.Qt=t,this.Vc=new Map,this.bc=new Map}return t.prototype.Os=function(t,e){return Jn.resolve(this.Vc.get(e))},t.prototype.ks=function(t,e){var n;return this.Vc.set(e.id,{id:(n=e).id,version:n.version,createTime:On(n.createTime)}),Jn.resolve()},t.prototype.Ms=function(t,e){return Jn.resolve(this.bc.get(e))},t.prototype.Ls=function(t,e){return this.bc.set(e.name,function(t){return{name:t.name,query:Hr(t.bundledQuery),readTime:On(t.readTime)}}(e)),Jn.resolve()},t}(),ro=function(){function t(){this.vc=new Ye(io.Sc),this.Dc=new Ye(io.Cc)}return t.prototype.et=function(){return this.vc.et()},t.prototype.nr=function(t,e){var n=new io(t,e);this.vc=this.vc.add(n),this.Dc=this.Dc.add(n)},t.prototype.xc=function(t,e){var n=this;t.forEach((function(t){return n.nr(t,e)}))},t.prototype.ir=function(t,e){this.Nc(new io(t,e))},t.prototype.$c=function(t,e){var n=this;t.forEach((function(t){return n.ir(t,e)}))},t.prototype.Fc=function(t){var e=this,n=new q(new R([])),r=new io(n,t),i=new io(n,t+1),o=[];return this.Dc.me([r,i],(function(t){e.Nc(t),o.push(t.key)})),o},t.prototype.Oc=function(){var t=this;this.vc.forEach((function(e){return t.Nc(e)}))},t.prototype.Nc=function(t){this.vc=this.vc.delete(t),this.Dc=this.Dc.delete(t)},t.prototype.kc=function(t){var e=new q(new R([])),n=new io(e,t),r=new io(e,t+1),i=nn();return this.Dc.me([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.Fi=function(t){var e=new io(t,0),n=this.vc.Re(e);return null!==n&&t.isEqual(n.key)},t}(),io=function(){function t(t,e){this.key=t,this.Mc=e}return t.Sc=function(t,e){return q.H(t.key,e.key)||w(t.Mc,e.Mc)},t.Cc=function(t,e){return w(t.Mc,e.Mc)||q.H(t.key,e.key)},t}(),oo=function(){function t(t,e){this.Ei=t,this.Ti=e,this.zo=[],this.Lc=1,this.Bc=new Ye(io.Sc)}return t.prototype.Ai=function(t){return Jn.resolve(0===this.zo.length)},t.prototype.Ri=function(t,e,n,r){var i=this.Lc;this.Lc++,this.zo.length>0&&this.zo[this.zo.length-1];var o=new Cr(i,e,n,r);this.zo.push(o);for(var u=0,s=r;u<s.length;u++){var a=s[u];this.Bc=this.Bc.add(new io(a.key,i)),this.Ei.qs(t,a.key.path.X())}return Jn.resolve(o)},t.prototype.Pi=function(t,e){return Jn.resolve(this.qc(e))},t.prototype.gi=function(t,e){var n=e+1,r=this.Uc(n),i=r<0?0:r;return Jn.resolve(this.zo.length>i?this.zo[i]:null)},t.prototype.Vi=function(){return Jn.resolve(0===this.zo.length?-1:this.Lc-1)},t.prototype.pi=function(t){return Jn.resolve(this.zo.slice())},t.prototype.bi=function(t,e){var n=this,r=new io(e,0),i=new io(e,Number.POSITIVE_INFINITY),o=[];return this.Bc.me([r,i],(function(t){var e=n.qc(t.Mc);o.push(e)})),Jn.resolve(o)},t.prototype.vi=function(t,e){var n=this,r=new Ye(w);return e.forEach((function(t){var e=new io(t,0),i=new io(t,Number.POSITIVE_INFINITY);n.Bc.me([e,i],(function(t){r=r.add(t.Mc)}))})),Jn.resolve(this.Qc(r))},t.prototype.Di=function(t,e){var n=e.path,r=n.length+1,i=n;q.wt(i)||(i=i.child(""));var o=new io(new q(i),0),u=new Ye(w);return this.Bc.Ae((function(t){var e=t.key.path;return!!n.nt(e)&&(e.length===r&&(u=u.add(t.Mc)),!0)}),o),Jn.resolve(this.Qc(u))},t.prototype.Qc=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.qc(t);null!==r&&n.push(r)})),n},t.prototype.Ci=function(t,e){var n=this;y(0===this.Kc(e.batchId,"removed")),this.zo.shift();var r=this.Bc;return Jn.forEach(e.mutations,(function(i){var o=new io(i.key,e.batchId);return r=r.delete(o),n.Ti.Ni(t,i.key)})).next((function(){n.Bc=r}))},t.prototype.xi=function(t){},t.prototype.Fi=function(t,e){var n=new io(e,0),r=this.Bc.Re(n);return Jn.resolve(e.isEqual(r&&r.key))},t.prototype.$i=function(t){return this.zo.length,Jn.resolve()},t.prototype.Kc=function(t,e){return this.Uc(t)},t.prototype.Uc=function(t){return 0===this.zo.length?0:t-this.zo[0].batchId},t.prototype.qc=function(t){var e=this.Uc(t);return e<0||e>=this.zo.length?null:this.zo[e]},t}(),uo=function(){function t(t,e){this.Ei=t,this.Wc=e,this.docs=new Ge(q.H),this.size=0}return t.prototype.ai=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,u=this.Wc(e);return this.docs=this.docs.zt(r,{hi:e,size:u,readTime:n}
1),this.size+=u-o,this.Ei.qs(t,r.path.X())},t.prototype.li=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype._i=function(t,e){var n=this.docs.get(e);return Jn.resolve(n?n.hi:null)},t.prototype.getEntries=function(t,e){var n=this,r=We();return e.forEach((function(t){var e=n.docs.get(t);r=r.zt(t,e?e.hi:null)})),Jn.resolve(r)},t.prototype.Kr=function(t,e,n){for(var r=Je(),i=new q(e.path.child("")),o=this.docs.ee(i);o.ce();){var u=o.oe(),s=u.key,a=u.value,c=a.hi,h=a.readTime;if(!e.path.nt(s.path))break;h._(n)<=0||c instanceof bt&&ee(e,c)&&(r=r.zt(c.key,c))}return Jn.resolve(r)},t.prototype.jc=function(t,e){return Jn.forEach(this.docs,(function(t){return e(t)}))},t.prototype.Nr=function(t){return new so(this)},t.prototype.Or=function(t){return Jn.resolve(this.size)},t}(),so=function(t){function e(e){var n=this;return(n=t.call(this)||this).jr=e,n}return Object(u.c)(e,t),e.prototype.wi=function(t){var e=this,n=[];return this.ri.forEach((function(r,i){i&&i.hi?n.push(e.jr.ai(t,i.hi,e.ci(r))):e.jr.li(r)})),Jn.Mn(n)},e.prototype.fi=function(t,e){return this.jr._i(t,e)},e.prototype.di=function(t,e){return this.jr.getEntries(t,e)},e}(oi),ao=function(){function t(t){this.persistence=t,this.Gc=new ii((function(t){return Et(t)}),Ot),this.lastRemoteSnapshotVersion=C.min(),this.highestTargetId=0,this.zc=0,this.Hc=new ro,this.targetCount=0,this.Jc=pi.Mi()}return t.prototype.In=function(t,e){return this.Gc.forEach((function(t,n){return e(n)})),Jn.resolve()},t.prototype.Qi=function(t){return Jn.resolve(this.lastRemoteSnapshotVersion)},t.prototype.Ki=function(t){return Jn.resolve(this.zc)},t.prototype.Bi=function(t){return this.highestTargetId=this.Jc.next(),Jn.resolve(this.highestTargetId)},t.prototype.Wi=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.zc&&(this.zc=e),Jn.resolve()},t.prototype.Gi=function(t){this.Gc.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.Jc=new pi(e),this.highestTargetId=e),t.sequenceNumber>this.zc&&(this.zc=t.sequenceNumber)},t.prototype.ji=function(t,e){return this.Gi(e),this.targetCount+=1,Jn.resolve()},t.prototype.Hi=function(t,e){return this.Gi(e),Jn.resolve()},t.prototype.Ji=function(t,e){return this.Gc.delete(e.target),this.Hc.Fc(e.targetId),this.targetCount-=1,Jn.resolve()},t.prototype.Xi=function(t,e,n){var r=this,i=0,o=[];return this.Gc.forEach((function(u,s){s.sequenceNumber<=e&&null===n.get(s.targetId)&&(r.Gc.delete(u),o.push(r.Yi(t,s.targetId)),i++)})),Jn.Mn(o).next((function(){return i}))},t.prototype.Zi=function(t){return Jn.resolve(this.targetCount)},t.prototype.tr=function(t,e){var n=this.Gc.get(e)||null;return Jn.resolve(n)},t.prototype.er=function(t,e,n){return this.Hc.xc(e,n),Jn.resolve()},t.prototype.sr=function(t,e,n){this.Hc.$c(e,n);var r=this.persistence.Ti,i=[];return r&&e.forEach((function(e){i.push(r.Ni(t,e))})),Jn.Mn(i)},t.prototype.Yi=function(t,e){return this.Hc.Fc(e),Jn.resolve()},t.prototype.rr=function(t,e){var n=this.Hc.kc(e);return Jn.resolve(n)},t.prototype.Fi=function(t,e){return Jn.resolve(this.Hc.Fi(e))},t}(),co=function(){function t(t,e){var n=this;this.Yc={},this.so=new P(0),this.io=!1,this.io=!0,this.Ti=t(this),this._o=new ao(this),this.Ei=new Zr,this.fo=function(t,e){return new uo(t,(function(t){return n.Ti.Xc(t)}))}(this.Ei),this.Qt=new Rr(e),this.wo=new no(this.Qt)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.ko=function(){return this.io=!1,Promise.resolve()},Object.defineProperty(t.prototype,"Er",{get:function(){return this.io},enumerable:!1,configurable:!0}),t.prototype.Po=function(){},t.prototype.yo=function(){},t.prototype.Ko=function(){return this.Ei},t.prototype.Qo=function(t){var e=this.Yc[t.A()];return e||(e=new oo(this.Ei,this.Ti),this.Yc[t.A()]=e),e},t.prototype.Sr=function(){return this._o},t.prototype.$r=function(){return this.fo},t.prototype.Wo=function(){return this.wo},t.prototype.runTransaction=function(t,e,n){var r=this;f("MemoryPersistence","Starting transaction:",t);var i=new ho(this.so.next());return this.Ti.Zc(),n(i).next((function(t){return r.Ti.ta(i).next((function(){return t}))})).On().then((function(t){return i.Vs(),t}))},t.prototype.ea=function(t,e){return Jn.Ln(Object.values(this.Yc).map((function(n){return function(){return n.Fi(t,e)}})))},t}(),ho=function(t){function e(e){var n=this;return(n=t.call(this)||this).bs=e,n}return Object(u.c)(e,t),e}(fr),fo=function(){function t(t){this.persistence=t,this.na=new ro,this.sa=null}return t.ia=function(e){return new t(e)},Object.defineProperty(t.prototype,"ra",{get:function(){if(this.sa)return this.sa;
1throw v()},enumerable:!1,configurable:!0}),t.prototype.nr=function(t,e,n){return this.na.nr(n,e),this.ra.delete(n.toString()),Jn.resolve()},t.prototype.ir=function(t,e,n){return this.na.ir(n,e),this.ra.add(n.toString()),Jn.resolve()},t.prototype.Ni=function(t,e){return this.ra.add(e.toString()),Jn.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.na.Fc(e.targetId).forEach((function(t){return n.ra.add(t.toString())}));var r=this.persistence.Sr();return r.rr(t,e.targetId).next((function(t){t.forEach((function(t){return n.ra.add(t.toString())}))})).next((function(){return r.Ji(t,e)}))},t.prototype.Zc=function(){this.sa=new Set},t.prototype.ta=function(t){var e=this,n=this.persistence.$r().Nr();return Jn.forEach(this.ra,(function(r){var i=q._t(r);return e.oa(t,i).next((function(t){t||n.li(i)}))})).next((function(){return e.sa=null,n.apply(t)}))},t.prototype.Fr=function(t,e){var n=this;return this.oa(t,e).next((function(t){t?n.ra.delete(e.toString()):n.ra.add(e.toString())}))},t.prototype.Xc=function(t){return 0},t.prototype.oa=function(t,e){var n=this;return Jn.Ln([function(){return Jn.resolve(n.na.Fi(e))},function(){return n.persistence.Sr().Fi(t,e)},function(){return n.persistence.ea(t,e)}])},t}();function lo(t,e){return"firestore_clients_"+t+"_"+e}function po(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.m()&&(r+="_"+e.uid),r}function vo(t,e){return"firestore_targets_"+t+"_"+e}var yo=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.ca=function(e,n,r){var i,o=JSON.parse(r),u="object"==typeof o&&-1!==["pending","acknowledged","rejected"].indexOf(o.state)&&(void 0===o.error||"object"==typeof o.error);return u&&o.error&&(u="string"==typeof o.error.message&&"string"==typeof o.error.code)&&(i=new T(o.error.code,o.error.message)),u?new t(e,n,o.state,i):(l("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.aa=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)},t}(),mo=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.ca=function(e,n){var r,i=JSON.parse(n),o="object"==typeof i&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error);return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new T(i.error.code,i.error.message)),o?new t(e,i.state,r):(l("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.aa=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)},t}(),bo=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.ca=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=on(),u=0;i&&u<r.activeTargetIds.length;++u)i=tt(r.activeTargetIds[u]),o=o.add(r.activeTargetIds[u]);return i?new t(e,o):(l("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),go=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.ca=function(e){var n=JSON.parse(e);return"object"==typeof n&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new t(n.clientId,n.onlineState):(l("SharedClientState","Failed to parse online state: "+e),null)},t}(),wo=function(){function t(){this.activeTargetIds=on()}return t.prototype.ua=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.ha=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.aa=function(){var t={activeTargetIds:this.activeTargetIds.it(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),_o=function(){function t(t,e,n,r,i){this.window=t,this.Zr=e,this.persistenceKey=n,this.la=r,this._a=null,this.fa=null,this.k=null,this.da=this.wa.bind(this),this.Ea=new Ge(w),this.Er=!1,this.Ta=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Ia=lo(this.persistenceKey,this.la),this.ma=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.Ea=this.Ea.zt(this.la,new wo),this.Aa=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Ra=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.Pa=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.ya=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.ga=function(t){return"firestore_bundle_loaded_"+t}(this.persistenceKey),this.window.addEventListener("storage",this.da)}return t.Kn=function(t){return!(!t||!t.localStorage)},t.prototype.start=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e,n,r,i,o,s,a,c,h,f,l=this;return Object(u.d)(this,(function(u){switch(u.label){case 0:return[4,this._a.Uo()];case 1:for(t=u.sent(),e=0,n=t;e<n.length;e++)(r=n[e])!==this.la&&(i=this.getItem(lo(this.persistenceKey,r)))&&(o=bo.ca(r,i))&&(this.Ea=this.Ea.zt(o.clientId,o));
1for(this.Va(),(s=this.storage.getItem(this.ya))&&(a=this.pa(s))&&this.ba(a),c=0,h=this.Ta;c<h.length;c++)f=h[c],this.wa(f);return this.Ta=[],this.window.addEventListener("unload",(function(){return l.ko()})),this.Er=!0,[2]}}))}))},t.prototype.B=function(t){this.setItem(this.ma,JSON.stringify(t))},t.prototype.va=function(){return this.Sa(this.Ea)},t.prototype.Da=function(t){var e=!1;return this.Ea.forEach((function(n,r){r.activeTargetIds.has(t)&&(e=!0)})),e},t.prototype.Ca=function(t){this.xa(t,"pending")},t.prototype.Na=function(t,e,n){this.xa(t,e,n),this.$a(t)},t.prototype.Fa=function(t){var e="not-current";if(this.Da(t)){var n=this.storage.getItem(vo(this.persistenceKey,t));if(n){var r=mo.ca(t,n);r&&(e=r.state)}}return this.Oa.ua(t),this.Va(),e},t.prototype.ka=function(t){this.Oa.ha(t),this.Va()},t.prototype.Ma=function(t){return this.Oa.activeTargetIds.has(t)},t.prototype.La=function(t){this.removeItem(vo(this.persistenceKey,t))},t.prototype.Ba=function(t,e,n){this.qa(t,e,n)},t.prototype.Ua=function(t,e,n){var r=this;e.forEach((function(t){r.$a(t)})),this.currentUser=t,n.forEach((function(t){r.Ca(t)}))},t.prototype.Qa=function(t){this.Ka(t)},t.prototype.Wa=function(){this.ja()},t.prototype.ko=function(){this.Er&&(this.window.removeEventListener("storage",this.da),this.removeItem(this.Ia),this.Er=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return f("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){f("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){f("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.wa=function(t){var e=this,n=t;if(n.storageArea===this.storage){if(f("SharedClientState","EVENT",n.key,n.newValue),n.key===this.Ia)return void l("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Zr.po((function(){return Object(u.b)(e,void 0,void 0,(function(){var t,e,r,i,o,s;return Object(u.d)(this,(function(u){if(this.Er){if(null!==n.key)if(this.Aa.test(n.key)){if(null==n.newValue)return t=this.Ga(n.key),[2,this.za(t,null)];if(e=this.Ha(n.key,n.newValue))return[2,this.za(e.clientId,e)]}else if(this.Ra.test(n.key)){if(null!==n.newValue&&(r=this.Ja(n.key,n.newValue)))return[2,this.Ya(r)]}else if(this.Pa.test(n.key)){if(null!==n.newValue&&(i=this.Xa(n.key,n.newValue)))return[2,this.Za(i)]}else if(n.key===this.ya){if(null!==n.newValue&&(o=this.pa(n.newValue)))return[2,this.ba(o)]}else if(n.key===this.ma)(s=function(t){var e=P.q;if(null!=t)try{var n=JSON.parse(t);y("number"==typeof n),e=n}catch(t){l("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(n.newValue))!==P.q&&this.k(s);else if(n.key===this.ga)return[2,this._a.tu()]}else this.Ta.push(n);return[2]}))}))}))}},Object.defineProperty(t.prototype,"Oa",{get:function(){return this.Ea.get(this.la)},enumerable:!1,configurable:!0}),t.prototype.Va=function(){this.setItem(this.Ia,this.Oa.aa())},t.prototype.xa=function(t,e,n){var r=new yo(this.currentUser,t,e,n),i=po(this.persistenceKey,this.currentUser,t);this.setItem(i,r.aa())},t.prototype.$a=function(t){var e=po(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.Ka=function(t){var e={clientId:this.la,onlineState:t};this.storage.setItem(this.ya,JSON.stringify(e))},t.prototype.qa=function(t,e,n){var r=vo(this.persistenceKey,t),i=new mo(t,e,n);this.setItem(r,i.aa())},t.prototype.ja=function(){this.setItem(this.ga,"value-not-used")},t.prototype.Ga=function(t){var e=this.Aa.exec(t);return e?e[1]:null},t.prototype.Ha=function(t,e){var n=this.Ga(t);return bo.ca(n,e)},t.prototype.Ja=function(t,e){var n=this.Ra.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return yo.ca(new j(i),r,e)},t.prototype.Xa=function(t,e){var n=this.Pa.exec(t),r=Number(n[1]);return mo.ca(r,e)},t.prototype.pa=function(t){return go.ca(t)},t.prototype.Ya=function(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){return t.user.uid===this.currentUser.uid?[2,this._a.eu(t.batchId,t.state,t.error)]:(f("SharedClientState","Ignoring mutation for non-active user "+t.user.uid),[2])}))}))},t.prototype.Za=function(t){return this._a.nu(t.targetId,t.state,t.error)},t.prototype.za=function(t,e){var n=this,r=e?this.Ea.zt(t,e):this.Ea.remove(t),i=this.Sa(this.Ea),o=this.Sa(r),u=[],s=[];return o.forEach((function(t){i.has(t)||u.push(t)}
1)),i.forEach((function(t){o.has(t)||s.push(t)})),this._a.su(u,s).then((function(){n.Ea=r}))},t.prototype.ba=function(t){this.Ea.get(t.clientId)&&this.fa(t.onlineState)},t.prototype.Sa=function(t){var e=on();return t.forEach((function(t,n){e=e.Pe(n.activeTargetIds)})),e},t}(),Io=function(){function t(){this.iu=new wo,this.ru={},this.fa=null,this.k=null}return t.prototype.Ca=function(t){},t.prototype.Na=function(t,e,n){},t.prototype.Fa=function(t){return this.iu.ua(t),this.ru[t]||"not-current"},t.prototype.Ba=function(t,e,n){this.ru[t]=e},t.prototype.ka=function(t){this.iu.ha(t)},t.prototype.Ma=function(t){return this.iu.activeTargetIds.has(t)},t.prototype.La=function(t){delete this.ru[t]},t.prototype.va=function(){return this.iu.activeTargetIds},t.prototype.Da=function(t){return this.iu.activeTargetIds.has(t)},t.prototype.start=function(){return this.iu=new wo,Promise.resolve()},t.prototype.Ua=function(t,e,n){},t.prototype.Qa=function(t){},t.prototype.ko=function(){},t.prototype.B=function(t){},t.prototype.Wa=function(){},t}(),Eo=function(){function t(){}return t.prototype.ou=function(t){},t.prototype.ko=function(){},t}(),Oo=function(){function t(){var t=this;this.cu=function(){return t.au()},this.uu=function(){return t.hu()},this.lu=[],this._u()}return t.prototype.ou=function(t){this.lu.push(t)},t.prototype.ko=function(){window.removeEventListener("online",this.cu),window.removeEventListener("offline",this.uu)},t.prototype._u=function(){window.addEventListener("online",this.cu),window.addEventListener("offline",this.uu)},t.prototype.au=function(){f("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.lu;t<e.length;t++)(0,e[t])(0)},t.prototype.hu=function(){f("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.lu;t<e.length;t++)(0,e[t])(1)},t.Kn=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),To={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},No=function(){function t(t){this.fu=t.fu,this.du=t.du}return t.prototype.wu=function(t){this.Eu=t},t.prototype.Tu=function(t){this.Iu=t},t.prototype.onMessage=function(t){this.mu=t},t.prototype.close=function(){this.du()},t.prototype.send=function(t){this.fu(t)},t.prototype.Au=function(){this.Eu()},t.prototype.Ru=function(t){this.Iu(t)},t.prototype.Pu=function(t){this.mu(t)},t}(),jo=function(t){function e(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n.i=e.i,n}return Object(u.c)(e,t),e.prototype.Su=function(t,e,n,r){return new Promise((function(i,u){var s=new o.f;s.listenOnce(o.c.COMPLETE,(function(){try{switch(s.getLastErrorCode()){case o.a.NO_ERROR:var e=s.getResponseJson();f("Connection","XHR received:",JSON.stringify(e)),i(e);break;case o.a.TIMEOUT:f("Connection",'RPC "'+t+'" timed out'),u(new T(O.DEADLINE_EXCEEDED,"Request time out"));break;case o.a.HTTP_ERROR:var n=s.getStatus();if(f("Connection",'RPC "'+t+'" failed with status:',n,"response text:",s.getResponseText()),n>0){var r=s.getResponseJson().error;if(r&&r.status&&r.message){var a=function(t){var e=t.toLowerCase().replace(/_/g,"-");return Object.values(O).indexOf(e)>=0?e:O.UNKNOWN}(r.status);u(new T(a,r.message))}else u(new T(O.UNKNOWN,"Server responded with status "+s.getStatus()))}else u(new T(O.UNAVAILABLE,"Connection failed."));break;default:v()}}finally{f("Connection",'RPC "'+t+'" completed.')}}));var a=JSON.stringify(r);s.send(e,"POST",a,n,15)}))},e.prototype.Cu=function(t,e){var n=[this.gu,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=Object(o.g)(),u=Object(o.h)(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.t.projectId+"/databases/"+this.t.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.i};this.vu(s.initMessageHeaders,e),Object(i.u)()||Object(i.x)()||Object(i.r)()||Object(i.t)()||Object(i.y)()||Object(i.q)()||(s.httpHeadersOverwriteParam="$httpHeaders");var a=n.join("");f("Connection","Creating WebChannel: "+a,s);var c=r.createWebChannel(a,s),h=!1,l=!1,d=new No({fu:function(t){l?f("Connection","Not sending because WebChannel is closed:",t):(h||(f("Connection","Opening WebChannel transport."),c.open(),h=!0),f("Connection","WebChannel sending:",t),c.send(t))},du:function(){return c.close()}}),v=function(t,e,n){t.listen(e,(function(t){try{n(t)}catch(t){setTimeout((function(){throw t}),0)}}))};return v(c,o.e.EventType.OPEN,(function(){l||f("Connection","WebChannel transport opened.")})),v(c,o.e.EventType.CLOSE,(function(){l||(l=!0,f("Connection","WebChannel transport closed"),d.Ru())}
1)),v(c,o.e.EventType.ERROR,(function(t){l||(l=!0,p("Connection","WebChannel transport errored:",t),d.Ru(new T(O.UNAVAILABLE,"The operation could not be completed")))})),v(c,o.e.EventType.MESSAGE,(function(t){var e;if(!l){var n=t.data[0];y(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){f("Connection","WebChannel received error:",i);var o=i.status,u=function(t){var e=Le[t];if(void 0!==e)return ze(e)}(o),s=i.message;void 0===u&&(u=O.INTERNAL,s="Unknown error status: "+o+" with message "+i.message),l=!0,d.Ru(new T(u,s)),c.close()}else f("Connection","WebChannel received:",n),d.Pu(n)}})),v(u,o.b.STAT_EVENT,(function(t){t.stat===o.d.PROXY?f("Connection","Detected buffering proxy"):t.stat===o.d.NOPROXY&&f("Connection","Detected no buffering proxy")})),setTimeout((function(){d.Au()}),0),d},e}(function(){function t(t){this.yu=t,this.t=t.t;var e=t.ssl?"https":"http";this.gu=e+"://"+t.host,this.Vu="projects/"+this.t.projectId+"/databases/"+this.t.database+"/documents"}return t.prototype.pu=function(t,e,n,r){var i=this.bu(t,e);f("RestConnection","Sending: ",i,n);var o={};return this.vu(o,r),this.Su(t,i,o,n).then((function(t){return f("RestConnection","Received: ",t),t}),(function(e){throw p("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e}))},t.prototype.Du=function(t,e,n,r){return this.pu(t,e,n,r)},t.prototype.vu=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.2.9",t["Content-Type"]="text/plain",e)for(var n in e.g)e.g.hasOwnProperty(n)&&(t[n]=e.g[n])},t.prototype.bu=function(t,e){var n=To[t];return this.gu+"/v1/"+e+":"+n},t}());function Ao(){return"undefined"!=typeof window?window:null}function Do(){return"undefined"!=typeof document?document:null}function So(t){return new wn(t,!0)}var xo=function(){function t(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Zr=t,this.fs=e,this.xu=n,this.Nu=r,this.$u=i,this.Fu=0,this.Ou=null,this.ku=Date.now(),this.reset()}return t.prototype.reset=function(){this.Fu=0},t.prototype.Mu=function(){this.Fu=this.$u},t.prototype.Lu=function(t){var e=this;this.cancel();var n=Math.floor(this.Fu+this.Bu()),r=Math.max(0,Date.now()-this.ku),i=Math.max(0,n-r);i>0&&f("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Fu+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ou=this.Zr.Tr(this.fs,i,(function(){return e.ku=Date.now(),t()})),this.Fu*=this.Nu,this.Fu<this.xu&&(this.Fu=this.xu),this.Fu>this.$u&&(this.Fu=this.$u)},t.prototype.qu=function(){null!==this.Ou&&(this.Ou.Rs(),this.Ou=null)},t.prototype.cancel=function(){null!==this.Ou&&(this.Ou.cancel(),this.Ou=null)},t.prototype.Bu=function(){return(Math.random()-.5)*this.Fu},t}(),ko=function(){function t(t,e,n,r,i,o){this.Zr=t,this.Uu=n,this.Qu=r,this.Ku=i,this.listener=o,this.state=0,this.Wu=0,this.ju=null,this.stream=null,this.Gu=new xo(t,e)}return t.prototype.zu=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.Hu=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.Ju()},t.prototype.stop=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return this.zu()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
1))}))},t.prototype.Yu=function(){this.state=0,this.Gu.reset()},t.prototype.Xu=function(){var t=this;this.Hu()&&null===this.ju&&(this.ju=this.Zr.Tr(this.Uu,6e4,(function(){return t.Zu()})))},t.prototype.th=function(t){this.eh(),this.stream.send(t)},t.prototype.Zu=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){return this.Hu()?[2,this.close(0)]:[2]}))}))},t.prototype.eh=function(){this.ju&&(this.ju.cancel(),this.ju=null)},t.prototype.close=function(t,e){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(n){switch(n.label){case 0:return this.eh(),this.Gu.cancel(),this.Wu++,3!==t?this.Gu.reset():e&&e.code===O.RESOURCE_EXHAUSTED?(l(e.toString()),l("Using maximum backoff delay to prevent overloading the backend."),this.Gu.Mu()):e&&e.code===O.UNAUTHENTICATED&&this.Ku.p(),null!==this.stream&&(this.nh(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Tu(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.nh=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.sh(this.Wu),n=this.Wu;this.Ku.getToken().then((function(e){t.Wu===n&&t.ih(e)}),(function(n){e((function(){var e=new T(O.UNKNOWN,"Fetching auth token failed: "+n.message);return t.rh(e)}))}))},t.prototype.ih=function(t){var e=this,n=this.sh(this.Wu);this.stream=this.oh(t),this.stream.wu((function(){n((function(){return e.state=2,e.listener.wu()}))})),this.stream.Tu((function(t){n((function(){return e.rh(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.Ju=function(){var t=this;this.state=4,this.Gu.Lu((function(){return Object(u.b)(t,void 0,void 0,(function(){return Object(u.d)(this,(function(t){return this.state=0,this.start(),[2]}))}))}))},t.prototype.rh=function(t){return f("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.sh=function(t){var e=this;return function(n){e.Zr.Ps((function(){return e.Wu===t?n():(f("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),Po=function(t){function e(e,n,r,i,o){var u=this;return(u=t.call(this,e,"listen_stream_connection_backoff","listen_stream_idle",n,r,o)||this).Qt=i,u}return Object(u.c)(e,t),e.prototype.oh=function(t){return this.Qu.Cu("Listen",t)},e.prototype.onMessage=function(t){this.Gu.reset();var e=function(t,e){var n;if("targetChange"in e){e.targetChange;var r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:v()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],o=function(t,e){return t.Bt?(y(void 0===e||"string"==typeof e),E.fromBase64String(e||"")):(y(void 0===e||e instanceof Uint8Array),E.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),u=(s=e.targetChange.cause)&&function(t){var e=void 0===t.code?O.UNKNOWN:ze(t.code);return new T(e,t.message||"")}(s);n=new pn(r,i,o,u||null)}else if("documentChange"in e){e.documentChange,(r=e.documentChange).document,r.document.name,r.document.updateTime,i=An(t,r.document.name),o=On(r.document.updateTime);var s=new dt({mapValue:{fields:r.document.fields}}),a=(u=new bt(i,o,s,{}),r.targetIds||[]),c=r.removedTargetIds||[];n=new fn(a,c,u.key,u)}else if("documentDelete"in e)e.documentDelete,(r=e.documentDelete).document,i=An(t,r.document),o=r.readTime?On(r.readTime):C.min(),s=new gt(i,o),u=r.removedTargetIds||[],n=new fn([],u,s.key,s);else if("documentRemove"in e)e.documentRemove,(r=e.documentRemove).document,i=An(t,r.document),o=r.removedTargetIds||[],n=new fn([],o,i,null);else{if(!("filter"in e))return v();e.filter;var h=e.filter;h.targetId,r=h.count||0,i=new qe(r),o=h.targetId,n=new ln(o,i)}return n}(this.Qt,t),n=function(t){if(!("targetChange"in t))return C.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?C.min():e.readTime?On(e.readTime):C.min()}(t);return this.listener.ah(e,n)},e.prototype.uh=function(t){var e={};e.database=xn(this.Qt),e.addTarget=function(t,e){var n,r=e.target;return(n=Tt(r)?{documents:Rn(t,r)}:{query:Un(t,r)}).targetId=e.targetId,e.resumeToken.l()>0?n.resumeToken=In(t,e.resumeToken):e.Ot._(C.min())>0&&(n.readTime=_n(t,e.Ot.j())),n}(this.Qt,t);var n=function(t,e){var n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return v()}}(0,e.Ft);return null==n?null:{"goog-listen-tags":n}}(this.Qt,t);n&&(e.labels=n),this.th(e)},e.prototype.hh=function(t){var e={};e.database=xn(this.Qt),e.removeTarget=t,this.th(e)},e}(ko),Vo=function(t){function e(e,n,r,i,o){var u=this;return(u=t.call(this,e,"write_stream_connection_backoff","write_stream_idle",n,r,o)||this).Qt=i,u.lh=!1,u}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"_h",{get:function(){return this.lh}
1,enumerable:!1,configurable:!0}),e.prototype.start=function(){this.lh=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},e.prototype.nh=function(){this.lh&&this.fh([])},e.prototype.oh=function(t){return this.Qu.Cu("Write",t)},e.prototype.onMessage=function(t){if(y(!!t.streamToken),this.lastStreamToken=t.streamToken,this.lh){this.Gu.reset();var e=function(t,e){return t&&t.length>0?(y(void 0!==e),t.map((function(t){return function(t,e){var n=t.updateTime?On(t.updateTime):On(e);n.isEqual(C.min())&&(n=On(e));var r=null;return t.transformResults&&t.transformResults.length>0&&(r=t.transformResults),new _e(n,r)}(t,e)}))):[]}(t.writeResults,t.commitTime),n=On(t.commitTime);return this.listener.dh(n,e)}return y(!t.writeResults||0===t.writeResults.length),this.lh=!0,this.listener.wh()},e.prototype.Eh=function(){var t={};t.database=xn(this.Qt),this.th(t)},e.prototype.fh=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map((function(t){return Cn(e.Qt,t)}))};this.th(n)},e}(ko),Co=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.Qu=n,i.Qt=r,i.Th=!1,i}return Object(u.c)(e,t),e.prototype.Ih=function(){if(this.Th)throw new T(O.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.pu=function(t,e,n){var r=this;return this.Ih(),this.credentials.getToken().then((function(i){return r.Qu.pu(t,e,n,i)})).catch((function(t){throw t.code===O.UNAUTHENTICATED&&r.credentials.p(),t}))},e.prototype.Du=function(t,e,n){var r=this;return this.Ih(),this.credentials.getToken().then((function(i){return r.Qu.Du(t,e,n,i)})).catch((function(t){throw t.code===O.UNAUTHENTICATED&&r.credentials.p(),t}))},e.prototype.terminate=function(){this.Th=!1},e}((function(){})),Lo=function(){function t(t,e){this._s=t,this.fa=e,this.state="Unknown",this.mh=0,this.Ah=null,this.Rh=!0}return t.prototype.Ph=function(){var t=this;0===this.mh&&(this.yh("Unknown"),this.Ah=this._s.Tr("online_state_timeout",1e4,(function(){return t.Ah=null,t.gh("Backend didn't respond within 10 seconds."),t.yh("Offline"),Promise.resolve()})))},t.prototype.Vh=function(t){"Online"===this.state?this.yh("Unknown"):(this.mh++,this.mh>=1&&(this.ph(),this.gh("Connection failed 1 times. Most recent error: "+t.toString()),this.yh("Offline")))},t.prototype.set=function(t){this.ph(),this.mh=0,"Online"===t&&(this.Rh=!1),this.yh(t)},t.prototype.yh=function(t){t!==this.state&&(this.state=t,this.fa(t))},t.prototype.gh=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis 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.Rh?(l(e),this.Rh=!1):f("OnlineStateTracker",e)},t.prototype.ph=function(){null!==this.Ah&&(this.Ah.cancel(),this.Ah=null)},t}(),Ro=function(t,e,n,r,i){var o=this;this.bh=t,this.Sh=e,this._s=n,this.Dh={},this.Ch=[],this.xh=new Map,this.Nh=new Set,this.$h=[],this.Fh=i,this.Fh.ou((function(t){n.Ps((function(){return Object(u.b)(o,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return Yo(this)?(f("RemoteStore","Restarting streams for network reachability change."),[4,function(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return(e=m(t)).Nh.add(4),[4,Mo(e)];case 1:return n.sent(),e.Oh.set("Unknown"),e.Nh.delete(4),[4,Uo(e)];case 2:return n.sent(),[2]}}))}))}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
1))}))}))})),this.Oh=new Lo(n,r)};function Uo(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:if(!Yo(t))return[3,4];e=0,n=t.$h,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!0)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function Mo(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:e=0,n=t.$h,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!1)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function qo(t,e){var n=m(t);n.xh.has(e.targetId)||(n.xh.set(e.targetId,e),Qo(n)?Bo(n):su(n).Hu()&&zo(n,e))}function Fo(t,e){var n=m(t),r=su(n);n.xh.delete(e),r.Hu()&&Go(n,e),0===n.xh.size&&(r.Hu()?r.Xu():Yo(n)&&n.Oh.set("Unknown"))}function zo(t,e){t.kh.on(e.targetId),su(t).uh(e)}function Go(t,e){t.kh.on(e),su(t).hh(e)}function Bo(t){t.kh=new vn({vn:function(e){return t.Dh.vn(e)},Sn:function(e){return t.xh.get(e)||null}}),su(t).start(),t.Oh.Ph()}function Qo(t){return Yo(t)&&!su(t).zu()&&t.xh.size>0}function Yo(t){return 0===m(t).Nh.size}function Ho(t){t.kh=void 0}function Ko(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){return t.xh.forEach((function(e,n){zo(t,e)})),[2]}))}))}function Xo(t,e){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(n){return Ho(t),Qo(t)?(t.Oh.Vh(e),Bo(t)):t.Oh.set("Unknown"),[2]}))}))}function Wo(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o;return Object(u.d)(this,(function(s){switch(s.label){case 0:if(t.Oh.set("Online"),!(e instanceof pn&&2===e.state&&e.cause))return[3,6];s.label=1;case 1:return s.trys.push([1,3,,5]),[4,function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o;return Object(u.d)(this,(function(u){switch(u.label){case 0:n=e.cause,r=0,i=e.targetIds,u.label=1;case 1:return r<i.length?(o=i[r],t.xh.has(o)?[4,t.Dh.Mh(o,n)]:[3,3]):[3,5];case 2:u.sent(),t.xh.delete(o),t.kh.removeTarget(o),u.label=3;case 3:u.label=4;case 4:return r++,[3,1];case 5:return[2]}}
1))}))}(t,e)];case 2:return s.sent(),[3,5];case 3:return r=s.sent(),f("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),[4,Zo(t,r)];case 4:return s.sent(),[3,5];case 5:return[3,13];case 6:if(e instanceof fn?t.kh.dn(e):e instanceof ln?t.kh.Pn(e):t.kh.Tn(e),n.isEqual(C.min()))return[3,13];s.label=7;case 7:return s.trys.push([7,11,,13]),[4,Bi(t.bh)];case 8:return i=s.sent(),n._(i)>=0?[4,function(t,e){var n=t.kh.Vn(e);return n.$e.forEach((function(n,r){if(n.resumeToken.l()>0){var i=t.xh.get(r);i&&t.xh.set(r,i.Mt(n.resumeToken,e))}})),n.Fe.forEach((function(e){var n=t.xh.get(e);if(n){t.xh.set(e,n.Mt(E.T,n.Ot)),Go(t,e);var r=new ie(n.target,e,1,n.sequenceNumber);zo(t,r)}})),t.Dh.Lh(n)}(t,n)]:[3,10];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return f("RemoteStore","Failed to raise snapshot:",o=s.sent()),[4,Zo(t,o)];case 12:return s.sent(),[3,13];case 13:return[2]}}))}))}function Zo(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r=this;return Object(u.d)(this,(function(i){switch(i.label){case 0:if(!rr(e))throw e;return t.Nh.add(1),[4,Mo(t)];case 1:return i.sent(),t.Oh.set("Offline"),n||(n=function(){return Bi(t.bh)}),t._s.po((function(){return Object(u.b)(r,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return f("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return e.sent(),t.Nh.delete(1),[4,Uo(t)];case 2:return e.sent(),[2]}}))}))})),[2]}}))}))}function Jo(t,e){return e().catch((function(n){return Zo(t,n,e)}))}function $o(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n,r,i,o;return Object(u.d)(this,(function(u){switch(u.label){case 0:e=m(t),n=au(e),r=e.Ch.length>0?e.Ch[e.Ch.length-1].batchId:-1,u.label=1;case 1:if(!function(t){return Yo(t)&&t.Ch.length<10}(e))return[3,7];u.label=2;case 2:return u.trys.push([2,4,,6]),[4,Hi(e.bh,r)];case 3:return null===(i=u.sent())?(0===e.Ch.length&&n.Xu(),[3,7]):(r=i.batchId,function(t,e){t.Ch.push(e);var n=au(t);n.Hu()&&n._h&&n.fh(e.mutations)}(e,i),[3,6]);case 4:return o=u.sent(),[4,Zo(e,o)];case 5:return u.sent(),[3,6];case 6:return[3,1];case 7:return tu(e)&&eu(e),[2]}}))}))}function tu(t){return Yo(t)&&!au(t).zu()&&t.Ch.length>0}function eu(t){au(t).start()}function nu(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){return au(t).Eh(),[2]}))}
1))}function ru(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n,r,i;return Object(u.d)(this,(function(o){for(e=au(t),n=0,r=t.Ch;n<r.length;n++)i=r[n],e.fh(i.mutations);return[2]}))}))}function iu(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return r=t.Ch.shift(),i=Lr.from(r,e,n),[4,Jo(t,(function(){return t.Dh.Bh(i)}))];case 1:return o.sent(),[4,$o(t)];case 2:return o.sent(),[2]}}))}))}function ou(t,e){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(n){switch(n.label){case 0:return e&&au(t)._h?[4,function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:return Fe(r=e.code)&&r!==O.ABORTED?(n=t.Ch.shift(),au(t).Yu(),[4,Jo(t,(function(){return t.Dh.qh(n.batchId,e)}))]):[3,3];case 1:return i.sent(),[4,$o(t)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return tu(t)&&eu(t),[2]}}))}))}function uu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n;return Object(u.d)(this,(function(r){switch(r.label){case 0:return n=m(t),e?(n.Nh.delete(2),[4,Uo(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.Nh.add(2),[4,Mo(n)]);case 3:r.sent(),n.Oh.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}}
1))}))}function su(t){var e=this;return t.Uh||(t.Uh=function(t,e,n){var r=m(t);return r.Ih(),new Po(e,r.Qu,r.credentials,r.Qt,n)}(t.Sh,t._s,{wu:Ko.bind(null,t),Tu:Xo.bind(null,t),ah:Wo.bind(null,t)}),t.$h.push((function(n){return Object(u.b)(e,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return n?(t.Uh.Yu(),Qo(t)?Bo(t):t.Oh.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.Uh.stop()];case 2:e.sent(),Ho(t),e.label=3;case 3:return[2]}}))}))}))),t.Uh}function au(t){var e=this;return t.Qh||(t.Qh=function(t,e,n){var r=m(t);return r.Ih(),new Vo(e,r.Qu,r.credentials,r.Qt,n)}(t.Sh,t._s,{wu:nu.bind(null,t),Tu:ou.bind(null,t),wh:ru.bind(null,t),dh:iu.bind(null,t)}),t.$h.push((function(n){return Object(u.b)(e,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return n?(t.Qh.Yu(),[4,$o(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.Qh.stop()];case 3:e.sent(),t.Ch.length>0&&(f("RemoteStore","Stopping write stream with "+t.Ch.length+" pending writes"),t.Ch=[]),e.label=4;case 4:return[2]}}
1))}))}))),t.Qh}var cu=function(){this.Kh=void 0,this.listeners=[]},hu=function(){this.queries=new ii((function(t){return $t(t)}),Jt),this.onlineState="Unknown",this.Wh=new Set};function fu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a,c;return Object(u.d)(this,(function(u){switch(u.label){case 0:if(n=m(t),r=e.query,i=!1,(o=n.queries.get(r))||(i=!0,o=new cu),!i)return[3,4];u.label=1;case 1:return u.trys.push([1,3,,4]),s=o,[4,n.jh(r)];case 2:return s.Kh=u.sent(),[3,4];case 3:return a=u.sent(),c=cr(a,"Initialization of query '"+te(e.query)+"' failed"),[2,void e.onError(c)];case 4:return n.queries.set(r,o),o.listeners.push(e),e.Gh(n.onlineState),o.Kh&&e.zh(o.Kh)&&vu(n),[2]}}))}))}function lu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s;return Object(u.d)(this,(function(u){return n=m(t),r=e.query,i=!1,(o=n.queries.get(r))&&(s=o.listeners.indexOf(e))>=0&&(o.listeners.splice(s,1),i=0===o.listeners.length),i?[2,(n.queries.delete(r),n.Hh(r))]:[2]}))}))}function pu(t,e){for(var n=m(t),r=!1,i=0,o=e;i<o.length;i++){var u=o[i],s=u.query,a=n.queries.get(s);if(a){for(var c=0,h=a.listeners;c<h.length;c++)h[c].zh(u)&&(r=!0);a.Kh=u}}r&&vu(n)}function du(t,e,n){var r=m(t),i=r.queries.get(e);if(i)for(var o=0,u=i.listeners;o<u.length;o++)u[o].onError(n);r.queries.delete(e)}function vu(t){t.Wh.forEach((function(t){t.next()}))}var yu=function(){function t(t,e,n){this.query=t,this.Jh=e,this.Yh=!1,this.Xh=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.zh=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new an(t.query,t.docs,t.Se,e,t.De,t.fromCache,t.Ce,!0)}var o=!1;return this.Yh?this.Zh(t)&&(this.Jh.next(t),o=!0):this.tl(t,this.onlineState)&&(this.el(t),o=!0),this.Xh=t,o},t.prototype.onError=function(t){this.Jh.error(t)},t.prototype.Gh=function(t){this.onlineState=t;var e=!1;return this.Xh&&!this.Yh&&this.tl(this.Xh,t)&&(this.el(this.Xh),e=!0),e},t.prototype.tl=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.nl&&n||t.docs.et()&&"Offline"!==e)},t.prototype.Zh=function(t){if(t.docChanges.length>0)return!0;var e=this.Xh&&this.Xh.hasPendingWrites!==t.hasPendingWrites;return!(!t.Ce&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.el=function(t){t=an.Ne(t.query,t.docs,t.De,t.fromCache),this.Yh=!0,this.Jh.next(t)},t}(),mu=function(){function t(t,e){this.payload=t,this.byteLength=e}return t.prototype.sl=function(){return"metadata"in this.payload},t}(),bu=function(){function t(t){this.Qt=t}return t.prototype.Pc=function(t){return An(this.Qt,t)},t.prototype.yc=function(t){return t.metadata.exists?Vn(this.Qt,t.document,!1):new gt(this.Pc(t.metadata.name),this.gc(t.metadata.readTime))},t.prototype.gc=function(t){return On(t)},t}();!function(){function t(t,e,n){this.il=t,this.bh=e,this.Qt=n,this.queries=[],this.documents=[],this.progress=gu(t)}t.prototype.rl=function(t){this.progress.bytesLoaded+=t.byteLength;var e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null},t.prototype.ol=function(t){for(var e=new Map,n=new bu(this.Qt),r=0,i=t;r<i.length;r++){var o=i[r];if(o.metadata.queries)for(var u=n.Pc(o.metadata.name),s=0,a=o.metadata.queries;s<a.length;s++){var c=a[s],h=(e.get(c)||nn()).add(u);e.set(c,h)}}return e},t.prototype.complete=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e,n,r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return[4,to(this.bh,new bu(this.Qt),this.documents,this.il.id)];case 1:t=o.sent(),e=this.ol(this.documents),n=0,r=this.queries,o.label=2;case 2:return n<r.length?(i=r[n],[4,eo(this.bh,i,e.get(i.name))]):[3,5];case 3:o.sent(),o.label=4;case 4:return n++,[3,2];case 5:return[2,(this.progress.taskState="Success",new Li(Object.assign({},this.progress),t))]}}))}))}}();function gu(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}var wu=function(t){this.key=t},_u=function(t){this.key=t}
1,Iu=function(){function t(t,e){this.query=t,this.cl=e,this.al=null,this.Be=!1,this.ul=nn(),this.De=nn(),this.hl=ne(t),this.ll=new un(this.hl)}return Object.defineProperty(t.prototype,"_l",{get:function(){return this.cl},enumerable:!1,configurable:!0}),t.prototype.fl=function(t,e){var n=this,r=e?e.dl:new sn,i=e?e.ll:this.ll,o=e?e.De:this.De,u=i,s=!1,a=Bt(this.query)&&i.size===this.query.limit?i.last():null,c=Qt(this.query)&&i.size===this.query.limit?i.first():null;if(t.Xt((function(t,e){var h=i.get(t),f=e instanceof bt?e:null;f&&(f=ee(n.query,f)?f:null);var l=!!h&&n.De.has(h.key),p=!!f&&(f.Vt||n.De.has(f.key)&&f.hasCommittedMutations),d=!1;h&&f?h.data().isEqual(f.data())?l!==p&&(r.track({type:3,doc:f}),d=!0):n.wl(h,f)||(r.track({type:2,doc:f}),d=!0,(a&&n.hl(f,a)>0||c&&n.hl(f,c)<0)&&(s=!0)):!h&&f?(r.track({type:0,doc:f}),d=!0):h&&!f&&(r.track({type:1,doc:h}),d=!0,(a||c)&&(s=!0)),d&&(f?(u=u.add(f),o=p?o.add(t):o.delete(t)):(u=u.delete(t),o=o.delete(t)))})),Bt(this.query)||Qt(this.query))for(;u.size>this.query.limit;){var h=Bt(this.query)?u.last():u.first();u=u.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{ll:u,dl:r,lc:s,De:o}},t.prototype.wl=function(t,e){return t.Vt&&e.hasCommittedMutations&&!e.Vt},t.prototype.wi=function(t,e,n){var r=this,i=this.ll;this.ll=t.ll,this.De=t.De;var o=t.dl.ve();o.sort((function(t,e){return function(t,e){var n=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return v()}};return n(t)-n(e)}(t.type,e.type)||r.hl(t.doc,e.doc)})),this.El(n);var u=e?this.Tl():[],s=0===this.ul.size&&this.Be?1:0,a=s!==this.al;return this.al=s,0!==o.length||a?{snapshot:new an(this.query,t.ll,i,o,t.De,0===s,a,!1),Il:u}:{Il:u}},t.prototype.Gh=function(t){return this.Be&&"Offline"===t?(this.Be=!1,this.wi({ll:this.ll,dl:new sn,De:this.De,lc:!1},!1)):{Il:[]}},t.prototype.ml=function(t){return!this.cl.has(t)&&!!this.ll.has(t)&&!this.ll.get(t).Vt},t.prototype.El=function(t){var e=this;t&&(t.qe.forEach((function(t){return e.cl=e.cl.add(t)})),t.Ue.forEach((function(t){})),t.Qe.forEach((function(t){return e.cl=e.cl.delete(t)})),this.Be=t.Be)},t.prototype.Tl=function(){var t=this;if(!this.Be)return[];var e=this.ul;this.ul=nn(),this.ll.forEach((function(e){t.ml(e.key)&&(t.ul=t.ul.add(e.key))}));var n=[];return e.forEach((function(e){t.ul.has(e)||n.push(new _u(e))})),this.ul.forEach((function(t){e.has(t)||n.push(new wu(t))})),n},t.prototype.Al=function(t){this.cl=t.Rc,this.ul=nn();var e=this.fl(t.documents);return this.wi(e,!0)},t.prototype.Rl=function(){return an.Ne(this.query,this.ll,this.De,0===this.al)},t}(),Eu=function(t,e,n){this.query=t,this.targetId=e,this.view=n},Ou=function(t){this.key=t,this.Pl=!1},Tu=function(){function t(t,e,n,r,i,o){this.bh=t,this.yl=e,this.gl=n,this.Vl=r,this.currentUser=i,this.pl=o,this.bl={},this.vl=new ii((function(t){return $t(t)}),Jt),this.Sl=new Map,this.Dl=new Set,this.Cl=new Ge(q.H),this.xl=new Map,this.Nl=new ro,this.$l={},this.Fl=new Map,this.Ol=pi.Li(),this.onlineState="Unknown",this.kl=void 0}return Object.defineProperty(t.prototype,"Ml",{get:function(){return!0===this.kl},enumerable:!1,configurable:!0}),t}();function Nu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a;return Object(u.d)(this,(function(u){switch(u.label){case 0:return n=es(t),(o=n.vl.get(e))?(r=o.targetId,n.Vl.Fa(r),i=o.view.Rl(),[3,4]):[3,1];case 1:return[4,Ki(n.bh,Wt(e))];case 2:return s=u.sent(),a=n.Vl.Fa(s.targetId),r=s.targetId,[4,ju(n,e,r,"current"===a)];case 3:i=u.sent(),n.Ml&&qo(n.yl,s),u.label=4;case 4:return[2,i]}}))}))}function ju(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o,s,a,c,h;return Object(u.d)(this,(function(f){switch(f.label){case 0:return t.Ll=function(e,n,r){return function(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o,s;return Object(u.d)(this,(function(u){switch(u.label){case 0:return(i=e.view.fl(n)).lc?[4,Wi(t.bh,e.query,!1).then((function(t){var n=t.documents;return e.view.fl(n,i)}))]:[3,2];case 1:i=u.sent(),u.label=2;case 2:return o=r&&r.$e.get(e.targetId),s=e.view.wi(i,t.Ml,o),[2,(qu(t,e.targetId,s.Il),s.snapshot)]}}))}))}(t,e,n,r)},[4,Wi(t.bh,e,!0)];case 1:return i=f.sent(),o=new Iu(e,i.Rc),s=o.fl(i.documents),a=hn.Le(n,r&&"Offline"!==t.onlineState),c=o.wi(s,t.Ml,a),qu(t,n,c.Il),h=new Eu(e,n,o),[2,(t.vl.set(e,h),t.Sl.has(n)?t.Sl.get(n).push(e):t.Sl.set(n,[e]),c.snapshot)]}}))}))}function Au(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return n=m(t),r=n.vl.get(e),(i=n.Sl.get(r.targetId)).length>1?[2,(n.Sl.set(r.targetId,i.filter((function(t){return!Jt(t,e)}
1))),void n.vl.delete(e))]:n.Ml?(n.Vl.ka(r.targetId),n.Vl.Da(r.targetId)?[3,2]:[4,Xi(n.bh,r.targetId,!1).then((function(){n.Vl.La(r.targetId),Fo(n.yl,r.targetId),Uu(n,r.targetId)})).catch(ri)]):[3,3];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return Uu(n,r.targetId),[4,Xi(n.bh,r.targetId,!0)];case 4:o.sent(),o.label=5;case 5:return[2]}}))}))}function Du(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s;return Object(u.d)(this,(function(u){switch(u.label){case 0:r=ns(t),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,function(t,e){var n,r=m(t),i=V.now(),o=e.reduce((function(t,e){return t.add(e.key)}),nn());return r.persistence.runTransaction("Locally write mutations","readwrite",(function(t){return r.Tc.Xo(t,o).next((function(o){n=o;for(var u=[],s=0,a=e;s<a.length;s++){var c=a[s],h=je(c,n.get(c.key));null!=h&&u.push(new xe(c.key,h,yt(h.proto.mapValue),Ie.exists(!0)))}return r.zo.Ri(t,i,u,e)}))})).then((function(t){var e=t.xs(n);return{batchId:t.batchId,ri:e}}))}(r.bh,e)];case 2:return i=u.sent(),r.Vl.Ca(i.batchId),function(t,e,n){var r=t.$l[t.currentUser.A()];r||(r=new Ge(w)),r=r.zt(e,n),t.$l[t.currentUser.A()]=r}(r,i.batchId,n),[4,Gu(r,i.ri)];case 3:return u.sent(),[4,$o(r.yl)];case 4:return u.sent(),[3,6];case 5:return o=u.sent(),s=cr(o,"Failed to persist write"),n.reject(s),[3,6];case 6:return[2]}}
1))}))}function Su(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:n=m(t),i.label=1;case 1:return i.trys.push([1,4,,6]),[4,Qi(n.bh,e)];case 2:return r=i.sent(),e.$e.forEach((function(t,e){var r=n.xl.get(e);r&&(y(t.qe.size+t.Ue.size+t.Qe.size<=1),t.qe.size>0?r.Pl=!0:t.Ue.size>0?y(r.Pl):t.Qe.size>0&&(y(r.Pl),r.Pl=!1))})),[4,Gu(n,r,e)];case 3:return i.sent(),[3,6];case 4:return[4,ri(i.sent())];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))}function xu(t,e,n){var r=m(t);if(r.Ml&&0===n||!r.Ml&&1===n){var i=[];r.vl.forEach((function(t,n){var r=n.view.Gh(e);r.snapshot&&i.push(r.snapshot)})),function(t,e){var n=m(t);n.onlineState=e;var r=!1;n.queries.forEach((function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].Gh(e)&&(r=!0)})),r&&vu(n)}(r.gl,e),i.length&&r.bl.ah(i),r.onlineState=e,r.Ml&&r.Vl.Qa(e)}}function ku(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s,a,c;return Object(u.d)(this,(function(u){switch(u.label){case 0:return(r=m(t)).Vl.Ba(e,"rejected",n),i=r.xl.get(e),(o=i&&i.key)?(s=(s=new Ge(q.H)).zt(o,new gt(o,C.min())),a=nn().add(o),c=new cn(C.min(),new Map,new Ye(w),s,a),[4,Su(r,c)]):[3,2];case 1:return u.sent(),r.Cl=r.Cl.remove(o),r.xl.delete(e),zu(r),[3,4];case 2:return[4,Xi(r.bh,e,!1).then((function(){return Uu(r,e,n)})).catch(ri)];case 3:u.sent(),u.label=4;case 4:return[2]}}
1))}))}function Pu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:n=m(t),r=e.batch.batchId,o.label=1;case 1:return o.trys.push([1,4,,6]),[4,Gi(n.bh,e)];case 2:return i=o.sent(),Ru(n,r,null),Lu(n,r),n.Vl.Na(r,"acknowledged"),[4,Gu(n,i)];case 3:return o.sent(),[3,6];case 4:return[4,ri(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}}))}))}function Vu(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:r=m(t),o.label=1;case 1:return o.trys.push([1,4,,6]),[4,function(t,e){var n=m(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(function(t){var r;return n.zo.Pi(t,e).next((function(e){return y(null!==e),r=e.keys(),n.zo.Ci(t,e)})).next((function(){return n.zo.$i(t)})).next((function(){return n.Tc.Xo(t,r)}))}))}(r.bh,e)];case 2:return i=o.sent(),Ru(r,e,n),Lu(r,e),r.Vl.Na(e,"rejected",n),[4,Gu(r,i)];case 3:return o.sent(),[3,6];case 4:return[4,ri(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}}
1))}))}function Cu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s;return Object(u.d)(this,(function(u){switch(u.label){case 0:Yo((n=m(t)).yl)||f("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,function(t){var e=m(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(t){return e.zo.Vi(t)}))}(n.bh)];case 2:return-1===(r=u.sent())?[2,void e.resolve()]:((i=n.Fl.get(r)||[]).push(e),n.Fl.set(r,i),[3,4]);case 3:return o=u.sent(),s=cr(o,"Initialization of waitForPendingWrites() operation failed"),e.reject(s),[3,4];case 4:return[2]}}))}))}function Lu(t,e){(t.Fl.get(e)||[]).forEach((function(t){t.resolve()})),t.Fl.delete(e)}function Ru(t,e,n){var r=m(t),i=r.$l[r.currentUser.A()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.$l[r.currentUser.A()]=i}}function Uu(t,e,n){void 0===n&&(n=null),t.Vl.ka(e);for(var r=0,i=t.Sl.get(e);r<i.length;r++){var o=i[r];t.vl.delete(o),n&&t.bl.Bl(o,n)}t.Sl.delete(e),t.Ml&&t.Nl.Fc(e).forEach((function(e){t.Nl.Fi(e)||Mu(t,e)}))}function Mu(t,e){t.Dl.delete(e.path.rt());var n=t.Cl.get(e);null!==n&&(Fo(t.yl,n),t.Cl=t.Cl.remove(e),t.xl.delete(n),zu(t))}function qu(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof wu?(t.Nl.nr(o.key,e),Fu(t,o)):o instanceof _u?(f("SyncEngine","Document no longer in limbo: "+o.key),t.Nl.ir(o.key,e),t.Nl.Fi(o.key)||Mu(t,o.key)):v()}}function Fu(t,e){var n=e.key,r=n.path.rt();t.Cl.get(n)||t.Dl.has(r)||(f("SyncEngine","New document in limbo: "+n),t.Dl.add(r),zu(t))}function zu(t){for(;t.Dl.size>0&&t.Cl.size<t.pl;){var e=t.Dl.values().next().value;t.Dl.delete(e);var n=new q(R.ot(e)),r=t.Ol.next();t.xl.set(r,new Ou(n)),t.Cl=t.Cl.zt(n,r),qo(t.yl,new ie(Wt(Gt(n.path)),r,2,P.q))}}function Gu(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s;return Object(u.d)(this,(function(a){switch(a.label){case 0:return r=m(t),i=[],o=[],s=[],r.vl.et()?[3,3]:(r.vl.forEach((function(t,u){s.push(r.Ll(u,e,n).then((function(t){if(t){r.Ml&&r.Vl.Ba(u.targetId,t.fromCache?"not-current":"current"),i.push(t);var e=Ui.oc(u.targetId,t);o.push(e)}})))})),[4,Promise.all(s)]);case 1:return a.sent(),r.bl.ah(i),[4,function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,h,l;return Object(u.d)(this,(function(u){switch(u.label){case 0:n=m(t),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(t){return Jn.forEach(e,(function(e){return Jn.forEach(e.ic,(function(r){return n.persistence.Ti.nr(t,e.targetId,r)})).next((function(){return Jn.forEach(e.rc,(function(r){return n.persistence.Ti.ir(t,e.targetId,r)}))}))}))}))];case 2:return u.sent(),[3,4];case 3:if(!rr(r=u.sent()))throw r;return f("LocalStore","Failed to update sequence numbers: "+r),[3,4];case 4:for(i=0,o=e;i<o.length;i++)s=o[i],a=s.targetId,s.fromCache||(c=n.fc.get(a),h=c.Ot,l=c.Lt(h),n.fc=n.fc.zt(a,l));return[2]}}))}))}(r.bh,o)];case 2:a.sent(),a.label=3;case 3:return[2]}}
1))}))}function Bu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:return(n=m(t)).currentUser.isEqual(e)?[3,3]:(f("SyncEngine","User change. New user:",e.A()),[4,zi(n.bh,e)]);case 1:return r=i.sent(),n.currentUser=e,function(t,e){t.Fl.forEach((function(t){t.forEach((function(t){t.reject(new T(O.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.Fl.clear()}(n),n.Vl.Ua(e,r.mc,r.Ac),[4,Gu(n,r.Ic)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}function Qu(t,e){var n=m(t),r=n.xl.get(e);if(r&&r.Pl)return nn().add(r.key);var i=nn(),o=n.Sl.get(e);if(!o)return i;for(var u=0,s=o;u<s.length;u++){var a=s[u],c=n.vl.get(a);i=i.Pe(c.view._l)}return i}function Yu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return[4,Wi((n=m(t)).bh,e.query,!0)];case 1:return r=o.sent(),i=e.view.Al(r),[2,(n.Ml&&qu(n,e.targetId,i.Il),i)]}}))}))}function Hu(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){return[2,Ji((e=m(t)).bh).then((function(t){return Gu(e,t)}))]}))}))}function Ku(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o;return Object(u.d)(this,(function(u){switch(u.label){case 0:return[4,function(t,e){var n=m(t),r=m(n.zo);return n.persistence.runTransaction("Lookup mutation documents","readonly",(function(t){return r.yi(t,e).next((function(e){return e?n.Tc.Xo(t,e):Jn.resolve(null)}))}))}((i=m(t)).bh,e)];case 1:return null===(o=u.sent())?[3,6]:"pending"!==n?[3,3]:[4,$o(i.yl)];case 2:return u.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(Ru(i,e,r||null),Lu(i,e),function(t,e){m(m(t).zo).xi(e)}(i.bh,e)):v(),u.label=4;case 4:return[4,Gu(i,o)];case 5:return u.sent(),[3,7];case 6:f("SyncEngine","Cannot apply mutation batch with id: "+e),u.label=7;case 7:return[2]}}
1))}))}function Xu(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,h;return Object(u.d)(this,(function(u){switch(u.label){case 0:return es(n=m(t)),ns(n),!0!==e||!0===n.kl?[3,3]:(r=n.Vl.va(),[4,Wu(n,r.it())]);case 1:return i=u.sent(),n.kl=!0,[4,uu(n.yl,!0)];case 2:for(u.sent(),o=0,s=i;o<s.length;o++)a=s[o],qo(n.yl,a);return[3,7];case 3:return!1!==e||!1===n.kl?[3,7]:(c=[],h=Promise.resolve(),n.Sl.forEach((function(t,e){n.Vl.Ma(e)?c.push(e):h=h.then((function(){return Uu(n,e),Xi(n.bh,e,!0)})),Fo(n.yl,e)})),[4,h]);case 4:return u.sent(),[4,Wu(n,c)];case 5:return u.sent(),function(t){var e=m(t);e.xl.forEach((function(t,n){Fo(e.yl,n)})),e.Nl.Oc(),e.xl=new Map,e.Cl=new Ge(q.H)}(n),n.kl=!1,[4,uu(n.yl,!1)];case 6:u.sent(),u.label=7;case 7:return[2]}}))}))}function Wu(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a,c,h,f,l,p,d,v,y;return Object(u.d)(this,(function(u){switch(u.label){case 0:n=m(t),r=[],i=[],o=0,s=e,u.label=1;case 1:return o<s.length?(a=s[o],c=void 0,(h=n.Sl.get(a))&&0!==h.length?[4,Ki(n.bh,Wt(h[0]))]:[3,7]):[3,13];case 2:c=u.sent(),f=0,l=h,u.label=3;case 3:return f<l.length?(p=l[f],d=n.vl.get(p),[4,Yu(n,d)]):[3,6];case 4:(v=u.sent()).snapshot&&i.push(v.snapshot),u.label=5;case 5:return f++,[3,3];case 6:return[3,11];case 7:return[4,Zi(n.bh,a)];case 8:return y=u.sent(),[4,Ki(n.bh,y)];case 9:return c=u.sent(),[4,ju(n,Zu(y),a,!1)];case 10:u.sent(),u.label=11;case 11:r.push(c),u.label=12;case 12:return o++,[3,1];case 13:return[2,(n.bl.ah(i),r)]}}))}))}function Zu(t){return zt(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function Ju(t){var e=m(t);return m(m(e.bh).persistence).Uo()}function $u(t,e,n,r){return Object(u.b)(this,void 0,void 0,(function(){var i,o,s;return Object(u.d)(this,(function(u){switch(u.label){case 0:return(i=m(t)).kl?(f("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!i.Sl.has(e))return[3,8];switch(n){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Ji(i.bh)];case 3:return o=u.sent(),s=cn.Me(e,"current"===n),[4,Gu(i,o,s)];case 4:return u.sent(),[3,8];case 5:return[4,Xi(i.bh,e,!0)];case 6:return u.sent(),Uu(i,e,r),[3,8];case 7:v(),u.label=8;case 8:return[2]}}
1))}))}function ts(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s,a,c,h,l,p,d;return Object(u.d)(this,(function(v){switch(v.label){case 0:if(!(r=es(t)).kl)return[3,10];i=0,o=e,v.label=1;case 1:return i<o.length?(s=o[i],r.Sl.has(s)?(f("SyncEngine","Adding an already active target "+s),[3,5]):[4,Zi(r.bh,s)]):[3,6];case 2:return a=v.sent(),[4,Ki(r.bh,a)];case 3:return c=v.sent(),[4,ju(r,Zu(a),c.targetId,!1)];case 4:v.sent(),qo(r.yl,c),v.label=5;case 5:return i++,[3,1];case 6:h=function(t){return Object(u.d)(this,(function(e){switch(e.label){case 0:return r.Sl.has(t)?[4,Xi(r.bh,t,!1).then((function(){Fo(r.yl,t),Uu(r,t)})).catch(ri)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))},l=0,p=n,v.label=7;case 7:return l<p.length?(d=p[l],[5,h(d)]):[3,10];case 8:v.sent(),v.label=9;case 9:return l++,[3,7];case 10:return[2]}}))}))}function es(t){var e=m(t);return e.yl.Dh.Lh=Su.bind(null,e),e.yl.Dh.vn=Qu.bind(null,e),e.yl.Dh.Mh=ku.bind(null,e),e.bl.ah=pu.bind(null,e.gl),e.bl.Bl=du.bind(null,e.gl),e}function ns(t){var e=m(t);return e.yl.Dh.Bh=Pu.bind(null,e),e.yl.Dh.qh=Vu.bind(null,e),e}var rs=function(){function t(){this.synchronizeTabs=!1}return t.prototype.initialize=function(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return this.Qt=So(t.yu.t),this.Vl=this.Wl(t),this.persistence=this.jl(t),[4,this.persistence.start()];case 1:return e.sent(),this.Gl=this.zl(t),this.bh=this.Hl(t),[2]}}))}))},t.prototype.zl=function(t){return null},t.prototype.Hl=function(t){return Fi(this.persistence,new Mi,t.Jl,this.Qt)},t.prototype.jl=function(t){return new co(fo.ia,this.Qt)},t.prototype.Wl=function(t){return new Io},t.prototype.terminate=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return this.Gl&&this.Gl.stop(),[4,this.Vl.ko()];case 1:return t.sent(),[4,this.persistence.ko()];case 2:return t.sent(),[2]}}))}))},t}(),is=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).Yl=e,i.cacheSizeBytes=n,i.forceOwnership=r,i.synchronizeTabs=!1,i}return Object(u.c)(e,t),e.prototype.initialize=function(e){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(n){switch(n.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return n.sent(),[4,$i(this.bh)];case 2:return n.sent(),[4,this.Yl.initialize(this,e)];case 3:return n.sent(),[4,ns(this.Yl._a)];case 4:return n.sent(),[4,$o(this.Yl.yl)];case 5:return n.sent(),[2]}}))}))},e.prototype.Hl=function(t){return Fi(this.persistence,new Mi,t.Jl,this.Qt)},e.prototype.zl=function(t){var e=this.persistence.Ti.lr;return new wi(e,t._s)},e.prototype.jl=function(t){var e=Ci(t.yu.t,t.yu.persistenceKey),n=void 0!==this.cacheSizeBytes?ni.Ys(this.cacheSizeBytes):ni.ti;return new ki(this.synchronizeTabs,e,t.clientId,n,t._s,Ao(),Do(),this.Qt,this.Vl,!!this.forceOwnership)},e.prototype.Wl=function(t){return new Io},e}(rs),os=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n,!1)||this).Yl=e,r.cacheSizeBytes=n,r.synchronizeTabs=!0,r}return Object(u.c)(e,t),e.prototype.initialize=function(e){return Object(u.b)(this,void 0,void 0,(function(){var n,r=this;return Object(u.d)(this,(function(i){switch(i.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return i.sent(),n=this.Yl._a,this.Vl instanceof _o?(this.Vl._a={eu:Ku.bind(null,n),nu:$u.bind(null,n),su:ts.bind(null,n),Uo:Ju.bind(null,n),tu:Hu.bind(null,n)},[4,this.Vl.start()]):[3,3];case 2:i.sent(),i.label=3;case 3:return[4,this.persistence.Ro((function(t){return Object(u.b)(r,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return[4,Xu(this.Yl._a,t)];case 1:return e.sent(),this.Gl&&(t&&!this.Gl.Er?this.Gl.start(this.bh):t||this.Gl.stop()),[2]}}))}))}))];case 4:return i.sent(),[2]}}))}))},e.prototype.Wl=function(t){var e=Ao();if(!_o.Kn(e))throw new T(O.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=Ci(t.yu.t,t.yu.persistenceKey);return new _o(e,t._s,n,t.clientId,t.Jl)},e}(is),us=function(){function t(){}return t.prototype.initialize=function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n=this;return Object(u.d)(this,(function(r){switch(r.label){case 0:return this.bh?[3,2]:(this.bh=t.bh,this.Vl=t.Vl,this.Sh=this.Xl(e),this.yl=this.Zl(e),this.gl=this.t_(e),this._a=this.e_(e,!t.synchronizeTabs),this.Vl.fa=function(t){return xu(n._a,t,1)},this.yl.Dh.n_=Bu.bind(null,this._a),[4,uu(this.yl,this._a.Ml)]);case 1:r.sent(),r.label=2;case 2:return[2]}}
1))}))},t.prototype.t_=function(t){return new hu},t.prototype.Xl=function(t){var e,n=So(t.yu.t),r=(e=t.yu,new jo(e));return function(t,e,n){return new Co(t,e,n)}(t.credentials,r,n)},t.prototype.Zl=function(t){var e,n,r,i,o,u=this;return e=this.bh,n=this.Sh,r=t._s,i=function(t){return xu(u._a,t,0)},o=Oo.Kn()?new Oo:new Eo,new Ro(e,n,r,i,o)},t.prototype.e_=function(t,e){return function(t,e,n,r,i,o,u){var s=new Tu(t,e,n,r,i,o);return u&&(s.kl=!0),s}(this.bh,this.yl,this.gl,this.Vl,t.Jl,t.pl,e)},t.prototype.terminate=function(){return function(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return e=m(t),f("RemoteStore","RemoteStore shutting down."),e.Nh.add(5),[4,Mo(e)];case 1:return n.sent(),e.Fh.ko(),e.Oh.set("Unknown"),[2]}}))}))}(this.yl)},t}();var ss=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.s_(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.s_(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.i_=function(){this.muted=!0},t.prototype.s_=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),as=(function(){function t(t,e){var n=this;this.r_=t,this.Qt=e,this.metadata=new Zn,this.buffer=new Uint8Array,this.o_=new TextDecoder("utf-8"),this.c_().then((function(t){t&&t.sl()?n.metadata.resolve(t.payload.metadata):n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n             "+JSON.stringify(null==t?void 0:t.payload)))}),(function(t){return n.metadata.reject(t)}))}t.prototype.close=function(){return this.r_.cancel()},t.prototype.getMetadata=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){return[2,this.metadata.promise]}))}))},t.prototype.Ql=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return[4,this.getMetadata()];case 1:return[2,(t.sent(),this.c_())]}}))}))},t.prototype.c_=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e,n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:return[4,this.a_()];case 1:return null===(t=i.sent())?[2,null]:(e=this.o_.decode(t),n=Number(e),isNaN(n)&&this.u_("length string ("+e+") is not valid number"),[4,this.h_(n)]);case 2:return r=i.sent(),[2,new mu(JSON.parse(r),t.length+n)]}}))}))},t.prototype.l_=function(){return this.buffer.findIndex((function(t){return t==="{".charCodeAt(0)}))},t.prototype.a_=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return this.l_()<0?[4,this.__()]:[3,3];case 1:if(n.sent())return[3,3];n.label=2;case 2:return[3,0];case 3:return 0===this.buffer.length?[2,null]:((t=this.l_())<0&&this.u_("Reached the end of bundle when a length string is expected."),e=this.buffer.slice(0,t),[2,(this.buffer=this.buffer.slice(t),e)])}}))}))},t.prototype.h_=function(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return this.buffer.length<t?[4,this.__()]:[3,3];case 1:n.sent()&&this.u_("Reached the end of bundle when more is expected."),n.label=2;case 2:return[3,0];case 3:return e=this.o_.decode(this.buffer.slice(0,t)),[2,(this.buffer=this.buffer.slice(t),e)]}}))}))},t.prototype.u_=function(t){throw this.r_.cancel(),new Error("Invalid bundle format: "+t)},t.prototype.__=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return[4,this.r_.read()];case 1:return(t=n.sent()).done||((e=new Uint8Array(this.buffer.length+t.value.length)).set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e),[2,t.done]}}))}))}}(),function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;++n)if(0===t[n].length)throw new T(O.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.f_=new M(t)}return t.prototype.isEqual=function(t){return this.f_.isEqual(t.f_)},t}()),cs=function(t){this._methodName=t},hs=function(t){this.d_=t};function fs(t,e,n){if(!n)throw new T(O.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function ls(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new T(O.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function ps(t,e,n,r){if(!0===e&&!0===r)throw new T(O.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function ds(t){if(!q.wt(t))throw new T(O.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function vs(t){if(q.wt(t))throw new T(O.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function ys(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":v()}function ms(t,e){if("_delegate"in t&&(t=t.d_),!(t instanceof e)){if(e.name===t.constructor.name)throw new T(O.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=ys(t);throw new T(O.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+n)}return t}function bs(t,e){if(e<=0)throw new T(O.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}var gs=function(){function t(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new T(O.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=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new T(O.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,ps("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return t.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},t}(),ws=new Map,_s=function(){function t(t,e){this.w_="(lite)",this.E_=new gs({}),this.T_=!1,t instanceof a?(this.I_=t,this.m_=new D):(this.A_=t,this.I_=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new T(O.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new a(t.options.projectId)}(t),this.m_=new S(e))}return Object.defineProperty(t.prototype,"app",{get:function(){if(!this.A_)throw new T(O.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.A_}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"R_",{get:function(){return this.T_},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"P_",{get:function(){return void 0!==this.y_},enumerable:!1,configurable:!0}),t.prototype.g_=function(t){if(this.T_)throw new T(O.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this.E_=new gs(t),void 0!==t.credentials&&(this.m_=function(t){if(!t)return new D;switch(t.type){case"gapi":var e=t.client;return y(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new k(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new T(O.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},t.prototype.V_=function(){return this.E_},t.prototype.p_=function(){return this.T_=!0,this.E_},t.prototype._delete=function(){return this.y_||(this.y_=this.b_()),this.y_},t.prototype.toJSON=function(){return{app:this.A_,t:this.I_,settings:this.E_}},t.prototype.b_=function(){return this,(t=ws.get(this))&&(f("ComponentProvider","Removing Datastore"),ws.delete(this),t.terminate()),Promise.resolve();var t},t}(),Is=function(){function t(t,e,n){this.v_=e,this.S_=n,this.type="document",this.firestore=t}return Object.defineProperty(t.prototype,"D_",{get:function(){return this.S_.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this.S_.path.tt()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this.S_.path.rt()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new Os(this.firestore,this.v_,this.S_.path.X())},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(e){return new t(this.firestore,e,this.S_)},t}(),Es=function(){function t(t,e,n){this.v_=e,this.C_=n,this.type="query",this.firestore=t}return t.prototype.withConverter=function(e){return new t(this.firestore,e,this.C_)},t}(),Os=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,Gt(r))||this).firestore=e,i.D_=r,i.type="collection",i}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.C_.path.tt()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.C_.path.rt()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this.D_.X();return t.et()?null:new Is(this.firestore,null,new q(t))},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this.D_)},e}(Es);function Ts(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t instanceof hs&&(t=t.d_),fs("collection","path",e),t instanceof _s)return vs(n=R.ot.apply(R,Object(u.g)([e],r))),new Os(t,null,n);if(!(t instanceof Is||t instanceof Os))throw new T(O.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return vs(n=R.ot.apply(R,Object(u.g)([t.path],r)).child(R.ot(e))),new Os(t.firestore,null,n)}function Ns(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t instanceof hs&&(t=t.d_),1===arguments.length&&(e=g.u()),fs("doc","path",e),t instanceof _s)return ds(n=R.ot.apply(R,Object(u.g)([e],r))),new Is(t,null,new q(n));if(!(t instanceof Is||t instanceof Os))throw new T(O.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return ds(n=t.D_.child(R.ot.apply(R,Object(u.g)([e],r)))),new Is(t.firestore,t instanceof Os?t.v_:null,new q(n))}function js(t,e){return t instanceof hs&&(t=t.d_),e instanceof hs&&(e=e.d_),(t instanceof Is||t instanceof Os)&&(e instanceof Is||e instanceof Os)&&t.firestore===e.firestore&&t.path===e.path&&t.v_===e.v_}function As(t,e){return t instanceof hs&&(t=t.d_),e instanceof hs&&(e=e.d_),t instanceof Es&&e instanceof Es&&t.firestore===e.firestore&&Jt(t.C_,e.C_)&&t.v_===e.v_}var Ds=function(){function t(t,e){if(!isFinite(t)||t<-90||t>90)throw new T(O.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new T(O.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.x_=t,this.N_=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this.x_}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this.N_},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.x_===t.x_&&this.N_===t.N_},t.prototype.toJSON=function(){return{latitude:this.x_,longitude:this.N_}},t.prototype.U=function(t){return w(this.x_,t.x_)||w(this.N_,t.N_)},t}(),Ss=/^__.*__$/,xs=function(){function t(t,e,n){this.data=t,this.Gt=e,this.fieldTransforms=n}return t.prototype.F_=function(t,e){return null!==this.Gt?new xe(t,this.data,this.Gt,e,this.fieldTransforms):new Se(t,this.data,e,this.fieldTransforms)},t}(),ks=function(){function t(t,e,n){this.data=t,this.Gt=e,this.fieldTransforms=n}return t.prototype.F_=function(t,e){return new xe(t,this.data,this.Gt,e,this.fieldTransforms)},t}();function Ps(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw v()}}var Vs=function(){function t(t,e,n,r,i,o){this.settings=t,this.t=e,this.Qt=n,this.ignoreUndefinedProperties=r,void 0===i&&this.O_(),this.fieldTransforms=i||[],this.Gt=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"k_",{get:function(){return this.settings.k_},enumerable:!1,configurable:!0}),t.prototype.M_=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.t,this.Qt,this.ignoreUndefinedProperties,this.fieldTransforms,this.Gt)},t.prototype.L_=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.M_({path:n,B_:!1});return r.q_(t),r},t.prototype.U_=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.M_({path:n,B_:!1});return r.O_(),r},t.prototype.Q_=function(t){return this.M_({path:void 0,B_:!0})},t.prototype.K_=function(t){return ta(t,this.settings.methodName,this.settings.W_||!1,this.path,this.settings.j_)},t.prototype.contains=function(t){return void 0!==this.Gt.find((function(e){return t.nt(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.nt(e.field)}))},t.prototype.O_=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.q_(this.path.get(t))},t.prototype.q_=function(t){if(0===t.length)throw this.K_("Document fields must not be empty");if(Ps(this.k_)&&Ss.test(t))throw this.K_('Document fields cannot begin and end with "__"')},t}(),Cs=function(){function t(t,e,n){this.t=t,this.ignoreUndefinedProperties=e,this.Qt=n||So(t)}return t.prototype.G_=function(t,e,n,r){return void 0===r&&(r=!1),new Vs({k_:t,methodName:e,j_:n,path:M.ct(),B_:!1,W_:r},this.t,this.Qt,this.ignoreUndefinedProperties)},t}();function Ls(t){var e=t.p_(),n=So(t.I_);return new Cs(t.I_,!!e.ignoreUndefinedProperties,n)}function Rs(t,e,n,r,i,o){void 0===o&&(o={});var u=t.G_(o.merge||o.mergeFields?2:0,e,n,i);Ws("Data must be an object, but it was:",u,r);var s,a,c=Ks(r,u);if(o.merge)s=new B(u.Gt),a=u.fieldTransforms;else if(o.mergeFields){for(var h=[],f=0,l=o.mergeFields;f<l.length;f++){var p=Zs(e,l[f],n);if(!u.contains(p))throw new T(O.INVALID_ARGUMENT,"Field '"+p+"' is specified in your field mask but missing from your input data.");ea(h,p)||h.push(p)}s=new B(h),a=u.fieldTransforms.filter((function(t){return s.Tt(t.field)}))}else s=null,a=u.fieldTransforms;return new xs(new dt(c),s,a)}var Us=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.z_=function(t){if(2!==t.k_)throw 1===t.k_?t.K_(this._methodName+"() can only appear at the top level of your update data"):t.K_(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return t.Gt.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(cs);function Ms(t,e,n){return new Vs({k_:3,j_:e.settings.j_,methodName:t._methodName,B_:n},e.t,e.Qt,e.ignoreUndefinedProperties)}var qs=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.z_=function(t){return new we(t.path,new le)},e.prototype.isEqual=function(t){return t instanceof e},e}(cs),Fs=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).H_=n,r}return Object(u.c)(e,t),e.prototype.z_=function(t){var e=Ms(this,t,!0),n=this.H_.map((function(t){return Hs(t,e)})),r=new pe(n);return new we(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(cs),zs=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).H_=n,r}return Object(u.c)(e,t),e.prototype.z_=function(t){var e=Ms(this,t,!0),n=this.H_.map((function(t){return Hs(t,e)})),r=new ve(n);return new we(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(cs),Gs=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).J_=n,r}return Object(u.c)(e,t),e.prototype.z_=function(t){var e=new me(t.Qt,se(t.Qt,this.J_));return new we(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(cs);function Bs(t,e,n,r){var i=t.G_(1,e,n);Ws("Data must be an object, but it was:",i,r);var o=[],u=new vt;
1z(r,(function(t,r){var s=$s(e,t,n);r instanceof hs&&(r=r.d_);var a=i.U_(s);if(r instanceof Us)o.push(s);else{var c=Hs(r,a);null!=c&&(o.push(s),u.set(s,c))}}));var s=new B(o);return new ks(u.Pt(),s,i.fieldTransforms)}function Qs(t,e,n,r,i,o){var u=t.G_(1,e,n),s=[Zs(e,r,n)],a=[i];if(o.length%2!=0)throw new T(O.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var c=0;c<o.length;c+=2)s.push(Zs(e,o[c])),a.push(o[c+1]);for(var h=[],f=new vt,l=s.length-1;l>=0;--l)if(!ea(h,s[l])){var p=s[l],d=a[l];d instanceof hs&&(d=d.d_);var v=u.U_(p);if(d instanceof Us)h.push(p);else{var y=Hs(d,v);null!=y&&(h.push(p),f.set(p,y))}}var m=new B(h);return new ks(f.Pt(),m,u.fieldTransforms)}function Ys(t,e,n,r){return void 0===r&&(r=!1),Hs(n,t.G_(r?4:3,e))}function Hs(t,e){if(t instanceof hs&&(t=t.d_),Xs(t))return Ws("Unsupported field value:",e,t),Ks(t,e);if(t instanceof cs)return function(t,e){if(!Ps(e.k_))throw e.K_(t._methodName+"() can only be used with update() and set()");if(!e.path)throw e.K_(t._methodName+"() is not currently supported inside arrays");var n=t.z_(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.Gt.push(e.path),t instanceof Array){if(e.settings.B_&&4!==e.k_)throw e.K_("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var u=Hs(o[i],e.Q_(r));null==u&&(u={nullValue:"NULL_VALUE"}),n.push(u),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(t instanceof hs&&(t=t.d_),null===t)return{nullValue:"NULL_VALUE"};if("number"==typeof t)return se(e.Qt,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=V.fromDate(t);return{timestampValue:_n(e.Qt,n)}}if(t instanceof V)return n=new V(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:_n(e.Qt,n)};if(t instanceof Ds)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof N)return{bytesValue:In(e.Qt,t.I)};if(t instanceof Is){n=e.t;var r=t.firestore.I_;if(!r.isEqual(n))throw e.K_("Document reference is for database "+r.projectId+"/"+r.database+" but should be for database "+n.projectId+"/"+n.database);return{referenceValue:Tn(t.firestore.I_||e.t,t.S_.path)}}throw e.K_("Unsupported field value: "+ys(t))}(t,e)}function Ks(t,e){var n={};return G(t)?e.path&&e.path.length>0&&e.Gt.push(e.path):z(t,(function(t,r){var i=Hs(r,e.L_(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Xs(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof V||t instanceof Ds||t instanceof N||t instanceof Is||t instanceof cs)}function Ws(t,e,n){if(!Xs(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){var r=ys(n);throw"an object"===r?e.K_(t+" a custom object"):e.K_(t+" "+r)}}function Zs(t,e,n){if(e instanceof hs&&(e=e.d_),e instanceof as)return e.f_;if("string"==typeof e)return $s(t,e);throw ta("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}var Js=new RegExp("[~\\*/\\[\\]]");function $s(t,e,n){if(e.search(Js)>=0)throw ta("Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'",t,!1,void 0,n);try{return(new(as.bind.apply(as,Object(u.g)([void 0],e.split("."))))).f_}catch(r){throw ta("Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",t,!1,void 0,n)}}function ta(t,e,n,r,i){var o=r&&!r.et(),u=void 0!==i,s="Function "+e+"() called with invalid data";n&&(s+=" (via `toFirestore()`)");var a="";return(o||u)&&(a+=" (found",o&&(a+=" in field "+r),u&&(a+=" in document "+i),a+=")"),new T(O.INVALID_ARGUMENT,(s+=". ")+t+a)}function ea(t,e){return t.some((function(t){return t.isEqual(e)}))}var na=function(){function t(t){this.Sh=t,this.Y_=new Map,this.mutations=[],this.X_=!1,this.Z_=null,this.tf=new Set}return t.prototype.ef=function(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n=this;return Object(u.d)(this,(function(r){switch(r.label){case 0:if(this.nf(),this.mutations.length>0)throw new T(O.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i,o,s,a;return Object(u.d)(this,(function(u){switch(u.label){case 0:return n=m(t),r=xn(n.Qt)+"/documents",i={documents:e.map((function(t){return jn(n.Qt,t)}))},[4,n.Du("BatchGetDocuments",r,i)];case 1:return o=u.sent(),s=new Map,o.forEach((function(t){var e=function(t,e){return"found"in e?function(t,e){y(!!e.found),e.found.name,e.found.updateTime;var n=An(t,e.found.name),r=On(e.found.updateTime),i=new dt({mapValue:{fields:e.found.fields}});return new bt(n,r,i,{})}(t,e):"missing"in e?function(t,e){y(!!e.missing),y(!!e.readTime);var n=An(t,e.missing),r=On(e.readTime);return new gt(n,r)}(t,e):v()}(n.Qt,t);s.set(e.key.toString(),e)})),a=[],[2,(e.forEach((function(t){var e=s.get(t.toString());y(!!e),a.push(e)})),a)]}}))}))}(this.Sh,t)];
1case 1:return[2,((e=r.sent()).forEach((function(t){t instanceof gt||t instanceof bt?n.sf(t):v()})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.F_(t,this.jt(t))),this.tf.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.F_(t,this.rf(t)))}catch(t){this.Z_=t}this.tf.add(t.toString())},t.prototype.delete=function(t){this.write(new Ue(t,this.jt(t))),this.tf.add(t.toString())},t.prototype.commit=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e=this;return Object(u.d)(this,(function(n){switch(n.label){case 0:if(this.nf(),this.Z_)throw this.Z_;return t=this.Y_,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=q._t(n);e.mutations.push(new Me(r,e.jt(r)))})),[4,function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return n=m(t),r=xn(n.Qt)+"/documents",i={writes:e.map((function(t){return Cn(n.Qt,t)}))},[4,n.pu("Commit",r,i)];case 1:return o.sent(),[2]}}))}))}(this.Sh,this.mutations)];case 1:return n.sent(),this.X_=!0,[2]}}))}))},t.prototype.sf=function(t){var e;if(t instanceof bt)e=t.version;else{if(!(t instanceof gt))throw v();e=C.min()}var n=this.Y_.get(t.key.toString());if(n){if(!e.isEqual(n))throw new T(O.ABORTED,"Document version changed between two reads.")}else this.Y_.set(t.key.toString(),e)},t.prototype.jt=function(t){var e=this.Y_.get(t.toString());return!this.tf.has(t.toString())&&e?Ie.updateTime(e):Ie.Kt()},t.prototype.rf=function(t){var e=this.Y_.get(t.toString());if(!this.tf.has(t.toString())&&e){if(e.isEqual(C.min()))throw new T(O.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ie.updateTime(e)}return Ie.exists(!0)},t.prototype.write=function(t){this.nf(),this.mutations.push(t)},t.prototype.nf=function(){},t}(),ra=function(){function t(t,e,n,r){this._s=t,this.Sh=e,this.updateFunction=n,this.Es=r,this.cf=5,this.Gu=new xo(this._s,"transaction_retry")}return t.prototype.run=function(){this.af()},t.prototype.af=function(){var t=this;this.Gu.Lu((function(){return Object(u.b)(t,void 0,void 0,(function(){var t,e,n=this;return Object(u.d)(this,(function(r){return t=new na(this.Sh),(e=this.uf(t))&&e.then((function(e){n._s.Ps((function(){return t.commit().then((function(){n.Es.resolve(e)})).catch((function(t){n.hf(t)}))}))})).catch((function(t){n.hf(t)})),[2]}))}))}))},t.prototype.uf=function(t){try{var e=this.updateFunction(t);return!J(e)&&e.catch&&e.then?e:(this.Es.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Es.reject(t),null}},t.prototype.hf=function(t){var e=this;this.cf>0&&this.lf(t)?(this.cf-=1,this._s.Ps((function(){return e.af(),Promise.resolve()}))):this.Es.reject(t)},t.prototype.lf=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!Fe(e)}return!1},t}(),ia=function(){function t(t,e,n){var r=this;this.credentials=t,this._s=e,this.yu=n,this.user=j.UNAUTHENTICATED,this.clientId=g.u(),this._f=function(){},this.C=new Zn,this.credentials.v((function(t){f("FirestoreClient","Received user=",t.uid),r.user=t,r._f(t),r.C.resolve()}))}return t.prototype.getConfiguration=function(){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return[4,this.C.promise];case 1:return[2,(t.sent(),{_s:this._s,yu:this.yu,clientId:this.clientId,credentials:this.credentials,Jl:this.user,pl:100})]}}))}))},t.prototype.ff=function(t){var e=this;this._f=t,this.C.promise.then((function(){return e._f(e.user)}))},t.prototype.df=function(){if(this._s.wf)throw new T(O.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.terminate=function(){var t=this;this._s.Ef();var e=new Zn;return this._s.Tf((function(){return Object(u.b)(t,void 0,void 0,(function(){var t,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),this.If?[4,this.If.terminate()]:[3,2];case 1:r.sent(),r.label=2;case 2:return this.mf?[4,this.mf.terminate()]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.credentials.S(),e.resolve(),[3,6];case 5:return t=r.sent(),n=cr(t,"Failed to shutdown persistence"),e.reject(n),[3,6];case 6:return[2]}}
1))}))})),e.promise},t}();function oa(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r,i=this;return Object(u.d)(this,(function(o){switch(o.label){case 0:return t._s.Af(),f("FirestoreClient","Initializing OfflineComponentProvider"),[4,t.getConfiguration()];case 1:return n=o.sent(),[4,e.initialize(n)];case 2:return o.sent(),r=n.Jl,t.ff((function(n){r.isEqual(n)||(r=n,t._s.po((function(){return Object(u.b)(i,void 0,void 0,(function(){return Object(u.d)(this,(function(t){switch(t.label){case 0:return[4,zi(e.bh,n)];case 1:return t.sent(),[2]}}))}))})))})),e.persistence.Po((function(){return t.terminate()})),t.mf=e,[2]}}))}))}function ua(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:return t._s.Af(),[4,sa(t)];case 1:return n=i.sent(),f("FirestoreClient","Initializing OnlineComponentProvider"),[4,t.getConfiguration()];case 2:return r=i.sent(),[4,e.initialize(n,r)];case 3:return i.sent(),t.ff((function(n){return t._s.po((function(){return function(t,e){return Object(u.b)(this,void 0,void 0,(function(){var n,r;return Object(u.d)(this,(function(i){switch(i.label){case 0:return(n=m(t))._s.Af(),f("RemoteStore","RemoteStore received new credentials"),r=Yo(n),n.Nh.add(3),[4,Mo(n)];case 1:return i.sent(),r&&n.Oh.set("Unknown"),[4,n.Dh.n_(e)];case 2:return i.sent(),n.Nh.delete(3),[4,Uo(n)];case 3:return i.sent(),[2]}}))}))}(e.yl,n)}))})),t.If=e,[2]}}))}))}function sa(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return t.mf?[3,2]:(f("FirestoreClient","Using default OfflineComponentProvider"),[4,oa(t,new rs)]);case 1:e.sent(),e.label=2;case 2:return[2,t.mf]}}))}))}function aa(t){return Object(u.b)(this,void 0,void 0,(function(){return Object(u.d)(this,(function(e){switch(e.label){case 0:return t.If?[3,2]:(f("FirestoreClient","Using default OnlineComponentProvider"),[4,ua(t,new us)]);case 1:e.sent(),e.label=2;case 2:return[2,t.If]}}))}))}function ca(t){return sa(t).then((function(t){return t.persistence}))}function ha(t){return sa(t).then((function(t){return t.bh}))}function fa(t){return aa(t).then((function(t){return t.yl}))}function la(t){return aa(t).then((function(t){return t._a}))}function pa(t){return Object(u.b)(this,void 0,void 0,(function(){var e,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:return[4,aa(t)];case 1:return e=r.sent(),[2,((n=e.gl).jh=Nu.bind(null,e._a),n.Hh=Au.bind(null,e._a),n)]}}))}))}function da(t,e,n){var r=this;void 0===n&&(n={});var i=new Zn;return t._s.Ps((function(){return Object(u.b)(r,void 0,void 0,(function(){var r;return Object(u.d)(this,(function(o){switch(o.label){case 0:return r=function(t,e,n,r,i){var o=new ss({next:function(o){e.Ps((function(){return lu(t,u)}));var s=o.docs.has(n);!s&&o.fromCache?i.reject(new T(O.UNAVAILABLE,"Failed to get document because the client is offline.")):s&&o.fromCache&&r&&"server"===r.source?i.reject(new T(O.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(o)},error:function(t){return i.reject(t)}}),u=new yu(Gt(n.path),o,{includeMetadataChanges:!0,nl:!0});return fu(t,u)},[4,pa(t)];case 1:return[2,r.apply(void 0,[o.sent(),t._s,e,n,i])]}}))}))})),i.promise}function va(t,e,n){var r=this;void 0===n&&(n={});var i=new Zn;return t._s.Ps((function(){return Object(u.b)(r,void 0,void 0,(function(){var r;return Object(u.d)(this,(function(o){switch(o.label){case 0:return r=function(t,e,n,r,i){var o=new ss({next:function(n){e.Ps((function(){return lu(t,u)})),n.fromCache&&"server"===r.source?i.reject(new T(O.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:function(t){return i.reject(t)}}),u=new yu(n,o,{includeMetadataChanges:!0,nl:!0});return fu(t,u)},[4,pa(t)];case 1:return[2,r.apply(void 0,[o.sent(),t._s,e,n,i])]}}))}))})),i.promise}var ya=function(){function t(){var t=this;this.Rf=Promise.resolve(),this.Pf=[],this.yf=!1,this.gf=[],this.Vf=null,this.pf=!1,this.bf=[],this.Gu=new xo(this,"async_queue_retry"),this.vf=function(){var e=Do();e&&f("AsyncQueue","Visibility state changed to "+e.visibilityState),t.Gu.qu()};var e=Do();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.vf)}return Object.defineProperty(t.prototype,"wf",{get:function(){return this.yf}
1,enumerable:!1,configurable:!0}),t.prototype.Ps=function(t){this.enqueue(t)},t.prototype.Tf=function(t){this.Sf(),this.Df(t)},t.prototype.Ef=function(){if(!this.yf){this.yf=!0;var t=Do();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.vf)}},t.prototype.enqueue=function(t){return this.Sf(),this.yf?new Promise((function(t){})):this.Df(t)},t.prototype.po=function(t){var e=this;this.Ps((function(){return e.Pf.push(t),e.Cf()}))},t.prototype.Cf=function(){return Object(u.b)(this,void 0,void 0,(function(){var t,e=this;return Object(u.d)(this,(function(n){switch(n.label){case 0:if(0===this.Pf.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.Pf[0]()];case 2:return n.sent(),this.Pf.shift(),this.Gu.reset(),[3,4];case 3:if(!rr(t=n.sent()))throw t;return f("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.Pf.length>0&&this.Gu.Lu((function(){return e.Cf()})),n.label=5;case 5:return[2]}}))}))},t.prototype.Df=function(t){var e=this,n=this.Rf.then((function(){return e.pf=!0,t().catch((function(t){throw e.Vf=t,e.pf=!1,l("INTERNAL UNHANDLED ERROR: ",function(t){var e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t)),t})).then((function(t){return e.pf=!1,t}))}));return this.Rf=n,n},t.prototype.Tr=function(t,e,n){var r=this;this.Sf(),this.bf.indexOf(t)>-1&&(e=0);var i=ar.Ts(this,t,e,n,(function(t){return r.xf(t)}));return this.gf.push(i),i},t.prototype.Sf=function(){this.Vf&&v()},t.prototype.Af=function(){},t.prototype.Nf=function(){return Object(u.b)(this,void 0,void 0,(function(){var t;return Object(u.d)(this,(function(e){switch(e.label){case 0:return[4,t=this.Rf];case 1:e.sent(),e.label=2;case 2:if(t!==this.Rf)return[3,0];e.label=3;case 3:return[2]}}
1))}))},t.prototype.$f=function(t){for(var e=0,n=this.gf;e<n.length;e++)if(n[e].fs===t)return!0;return!1},t.prototype.Ff=function(t){var e=this;return this.Nf().then((function(){e.gf.sort((function(t,e){return t.ds-e.ds}));for(var n=0,r=e.gf;n<r.length;n++){var i=r[n];if(i.Rs(),"all"!==t&&i.fs===t)break}return e.Nf()}))},t.prototype.Of=function(t){this.bf.push(t)},t.prototype.xf=function(t){var e=this.gf.indexOf(t);this.gf.splice(e,1)},t}();function ma(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=t,r=0,i=["next","error","complete"];r<i.length;r++){var o=i[r];if(o in n&&"function"==typeof n[o])return!0}return!1}(t)}!function(){function t(){this.kf={},this.Mf=new Zn,this.Lf={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}t.prototype.onProgress=function(t,e,n){this.kf={next:t,error:e,complete:n}},t.prototype.catch=function(t){return this.Mf.promise.catch(t)},t.prototype.then=function(t,e){return this.Mf.promise.then(t,e)},t.prototype.ql=function(t){this.Ul(t),this.kf.complete&&this.kf.complete(),this.Mf.resolve(t)},t.prototype.Kl=function(t){this.Lf.taskState="Error",this.kf.next&&this.kf.next(this.Lf),this.kf.error&&this.kf.error(t),this.Mf.reject(t)},t.prototype.Ul=function(t){this.Lf=t,this.kf.next&&this.kf.next(t)}}();var ba=-1,ga=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).Bf=new ya,r.w_="name"in e?e.name:"[DEFAULT]",r}return Object(u.c)(e,t),e.prototype.b_=function(){return this.qf||_a(this),this.qf.terminate()},e}(_s);function wa(t){return t.qf||_a(t),t.qf.df(),t.qf}function _a(t){var e=t.p_(),n=function(t,e,n){return new s(t,e,n.host,n.ssl,n.experimentalForceLongPolling,n.experimentalAutoDetectLongPolling)}(t.I_,t.w_,e);t.qf=new ia(t.m_,t.Bf,n)}function Ia(t,e,n){var r=this,i=new Zn;return t._s.enqueue((function(){return Object(u.b)(r,void 0,void 0,(function(){var r;return Object(u.d)(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,oa(t,n)];case 1:return o.sent(),[4,ua(t,e)];case 2:return o.sent(),i.resolve(),[3,4];case 3:if(!function(t){return"FirebaseError"===t.name?t.code===O.FAILED_PRECONDITION||t.code===O.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(r=o.sent()))throw r;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+r),i.reject(r),[3,4];case 4:return[2]}}
1))}))})).then((function(){return i.promise}))}function Ea(t){if(t.R_||t.P_)throw new T(O.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}var Oa=function(){function t(){}return t.prototype.Uf=function(t,e){switch(void 0===e&&(e="none"),et(t)){case 0:return null;case 1:return t.booleanValue;case 2:return H(t.integerValue||t.doubleValue);case 3:return this.Qf(t.timestampValue);case 4:return this.Kf(t,e);case 5:return t.stringValue;case 6:return this.Wf(K(t.bytesValue));case 7:return this.jf(t.referenceValue);case 8:return this.Gf(t.geoPointValue);case 9:return this.zf(t.arrayValue,e);case 10:return this.Hf(t.mapValue,e);default:throw v()}},t.prototype.Hf=function(t,e){var n=this,r={};return z(t.fields||{},(function(t,i){r[t]=n.Uf(i,e)})),r},t.prototype.Gf=function(t){return new Ds(H(t.latitude),H(t.longitude))},t.prototype.zf=function(t,e){var n=this;return(t.values||[]).map((function(t){return n.Uf(t,e)}))},t.prototype.Kf=function(t,e){switch(e){case"previous":var n=W(t);return null==n?null:this.Uf(n,e);case"estimate":return this.Qf(Z(t));default:return null}},t.prototype.Qf=function(t){var e=Y(t);return new V(e.seconds,e.nanos)},t.prototype.Jf=function(t,e){var n=R.ot(t);y(Wn(n));var r=new a(n.get(1),n.get(3)),i=new q(n.Y(5));return r.isEqual(e)||l("Document "+i+" contains a document reference within a different database ("+r.projectId+"/"+r.database+") which is not supported. It will be treated as a reference in the current database ("+e.projectId+"/"+e.database+") instead."),i},t}(),Ta=function(){function t(t,e,n,r,i){this.Yf=t,this.Xf=e,this.S_=n,this.Zf=r,this.v_=i}return Object.defineProperty(t.prototype,"id",{get:function(){return this.S_.path.tt()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Is(this.Yf,this.v_,this.S_)},enumerable:!1,configurable:!0}),t.prototype.exists=function(){return null!==this.Zf},t.prototype.data=function(){if(this.Zf){if(this.v_){var t=new Na(this.Yf,this.Xf,this.S_,this.Zf,null);return this.v_.fromFirestore(t)}return this.Xf.Uf(this.Zf.bt())}},t.prototype.get=function(t){if(this.Zf){var e=this.Zf.data().field(ja("DocumentSnapshot.get",t));if(null!==e)return this.Xf.Uf(e)}},t}(),Na=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.data=function(){return t.prototype.data.call(this)},e}(Ta);function ja(t,e){return"string"==typeof e?$s(t,e):e instanceof hs?e.d_.f_:e.f_}function Aa(t){if(Qt(t)&&0===t.xt.length)throw new T(O.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Da=function(){};function Sa(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];t=o.td(t)}return t}var xa=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).ed=e,i.nd=n,i.sd=r,i.type="where",i}return Object(u.c)(e,t),e.prototype.td=function(t){var e=Ls(t.firestore),n=function(t,e,n,r,i,o,u){var s;if(i.ut()){if("array-contains"===o||"array-contains-any"===o)throw new T(O.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){Ua(u,o);for(var a=[],c=0,h=u;c<h.length;c++){var f=h[c];a.push(Ra(r,t,f))}s={arrayValue:{values:a}}}else s=Ra(r,t,u)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||Ua(u,o),s=Ys(n,"where",u,"in"===o||"not-in"===o);var l=Nt.create(i,o,s);return function(t,e){if(e.Ct()){var n=Ht(t);if(null!==n&&!n.isEqual(e.field))throw new T(O.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=Yt(t);null!==r&&Ma(t,e.field,r)}var i=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(e.indexOf(i.op)>=0)return i.op}return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","
1not-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[]}}(e.op));if(null!==i)throw i===e.op?new T(O.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new T(O.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,l),l}(t.C_,0,e,t.firestore.I_,this.ed,this.nd,this.sd);return new Es(t.firestore,t.v_,function(t,e){var n=t.filters.concat([e]);return new Ft(t.path,t.collectionGroup,t.xt.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t.C_,n))},e}(Da),ka=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).ed=e,r.rd=n,r.type="orderBy",r}return Object(u.c)(e,t),e.prototype.td=function(t){var e=function(t,e,n){if(null!==t.startAt)throw new T(O.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new T(O.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new Rt(e,n);return function(t,e){if(null===Yt(t)){var n=Ht(t);null!==n&&Ma(t,n,e.field)}}(t,r),r}(t.C_,this.ed,this.rd);return new Es(t.firestore,t.v_,function(t,e){var n=t.xt.concat([e]);return new Ft(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t.C_,e))},e}(Da),Pa=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.od=n,i.ad=r,i}return Object(u.c)(e,t),e.prototype.td=function(t){return new Es(t.firestore,t.v_,Zt(t.C_,this.od,this.ad))},e}(Da),Va=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.ud=n,i.hd=r,i}return Object(u.c)(e,t),e.prototype.td=function(t){var e=La(t,this.type,this.ud,this.hd);return new Es(t.firestore,t.v_,function(t,e){return new Ft(t.path,t.collectionGroup,t.xt.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t.C_,e))},e}(Da),Ca=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.ud=n,i.hd=r,i}return Object(u.c)(e,t),e.prototype.td=function(t){var e=La(t,this.type,this.ud,this.hd);return new Es(t.firestore,t.v_,function(t,e){return new Ft(t.path,t.collectionGroup,t.xt.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t.C_,e))},e}(Da);function La(t,e,n,r){if(n[0]instanceof hs&&(n[0]=n[0].d_),n[0]instanceof Ta)return function(t,e,n,r,i){if(!r)throw new T(O.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],u=0,s=Xt(t);u<s.length;u++){var a=s[u];if(a.field.ut())o.push(at(e,r.key));else{var c=r.field(a.field);if(X(c))throw new T(O.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===c){var h=a.field.rt();throw new T(O.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+h+"' (used as the orderBy) does not exist.")}o.push(c)}}return new Ct(o,i)}(t.C_,t.firestore.I_,e,n[0].Zf,r);var i=Ls(t.firestore);return function(t,e,n,r,i,o){var u=t.xt;if(i.length>u.length)throw new T(O.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var s=[],a=0;a<i.length;a++){var c=i[a];if(u[a].field.ut()){if("string"!=typeof c)throw new T(O.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof c);if(!Kt(t)&&-1!==c.indexOf("/"))throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+r+"() must be a plain document ID, but '"+c+"' contains a slash.");var h=t.path.child(R.ot(c));if(!q.wt(h))throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+r+"() must result in a valid document path, but '"+h+"' is not because it c
1ontains an odd number of segments.");var f=new q(h);s.push(at(e,f))}else{var l=Ys(n,r,c);s.push(l)}}return new Ct(s,o)}(t.C_,t.firestore.I_,i,e,n,r)}function Ra(t,e,n){if(n instanceof hs&&(n=n.d_),"string"==typeof n){if(""===n)throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!Kt(e)&&-1!==n.indexOf("/"))throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");var r=e.path.child(R.ot(n));if(!q.wt(r))throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+r+"' is not because it has an odd number of segments ("+r.length+").");return at(t,new q(r))}if(n instanceof Is)return at(t,n.S_);throw new T(O.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+ys(n)+".")}function Ua(t,e){if(!Array.isArray(t)||0===t.length)throw new T(O.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new T(O.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function Ma(t,e,n){if(!n.isEqual(e))throw new T(O.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}function qa(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var Fa=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return Object(u.c)(e,t),e.prototype.Wf=function(t){return new N(t)},e.prototype.jf=function(t){var e=this.Jf(t,this.firestore.I_);return new Is(this.firestore,null,e)},e}(Oa),za=function(){function t(t,e){this.hasPendingWrites=t,this.fromCache=e}return t.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},t}(),Ga=function(t){function e(e,n,r,i,o,u){var s=this;return(s=t.call(this,e,n,r,i,u)||this).Yf=e,s.ld=e,s.metadata=o,s}return Object(u.c)(e,t),e.prototype.exists=function(){return t.prototype.exists.call(this)},e.prototype.data=function(t){if(void 0===t&&(t={}),this.Zf){if(this.v_){var e=new Ba(this.Yf,this.Xf,this.S_,this.Zf,this.metadata,null);return this.v_.fromFirestore(e,t)}return this.Xf.Uf(this.Zf.bt(),t.serverTimestamps)}},e.prototype.get=function(t,e){if(void 0===e&&(e={}),this.Zf){var n=this.Zf.data().field(ja("DocumentSnapshot.get",t));if(null!==n)return this.Xf.Uf(n,e.serverTimestamps)}},e}(Ta),Ba=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.data=function(e){return void 0===e&&(e={}),t.prototype.data.call(this,e)},e}(Ga),Qa=function(){function t(t,e,n,r){this.Yf=t,this.Xf=e,this._d=r,this.metadata=new za(r.hasPendingWrites,r.fromCache),this.query=n}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach((function(e){return t.push(e)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._d.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;this._d.docs.forEach((function(r){t.call(e,new Ba(n.Yf,n.Xf,r.key,r,new za(n._d.De.has(r.key),n._d.fromCache),n.query.v_))}))},t.prototype.docChanges=function(t){void 0===t&&(t={});var e=!!t.includeMetadataChanges;if(e&&this._d.xe)throw new T(O.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.fd&&this.dd===e||(this.fd=function(t,e){if(t._d.Se.et()){var n=0;return t._d.docChanges.map((function(e){var r=new Ba(t.Yf,t.Xf,e.doc.key,e.doc,new za(t._d.De.has(e.doc.key),t._d.fromCache),t.query.v_);return e.doc,{type:"added",doc:r,oldIndex:-1,newIndex:n++}}))}var r=t._d.Se;return t._d.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var n=new Ba(t.Yf,t.Xf,e.doc.key,e.doc,new za(t._d.De.has(e.doc.key),t._d.fromCache),t.query.v_),i=-1,o=-1;return 0!==e.type&&(i=r.indexOf(e.doc.key),r=r.delete(e.doc.key)),1!==e.type&&(o=(r=r.add(e.doc)).indexOf(e.doc.key)),{type:Ya(e.type),doc:n,oldIndex:i,newIndex:o}}))}(this,e),this.dd=e),this.fd},t}();function Ya(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return v()}}function Ha(t,e){return t instanceof Ga&&e instanceof Ga?t.Yf===e.Yf&&t.S_.isEqual(e.S_)&&(null===t.Zf?null===e.Zf:t.Zf.isEqual(e.Zf))&&t.v_===e.v_:t instanceof Qa&&e instanceof Qa&&t.Yf===e.Yf&&As(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._d.isEqual(e._d)}var Ka=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return Object(u.c)(e,t),e.prototype.Wf=function(t){return new N(t)},e.prototype.jf=function(t){var e=this.Jf(t,this.firestore.I_);
1return new Is(this.firestore,null,e)},e}(Oa);function Xa(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];t=ms(t,Is);var o=ms(t.firestore,ga),u=Ls(o);return e instanceof hs&&(e=e.d_),Za(o,[("string"==typeof e||e instanceof as?Qs(u,"updateDoc",t.S_,e,n,r):Bs(u,"updateDoc",t.S_,e)).F_(t.S_,Ie.exists(!0))])}function Wa(t){for(var e,n,r,i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];t instanceof hs&&(t=t.d_);var s={includeMetadataChanges:!1},a=0;"object"!=typeof i[a]||ma(i[a])||(s=i[a],a++);var c,h,f,l={includeMetadataChanges:s.includeMetadataChanges};if(ma(i[a])){var p=i[a];i[a]=null===(e=p.next)||void 0===e?void 0:e.bind(p),i[a+1]=null===(n=p.error)||void 0===n?void 0:n.bind(p),i[a+2]=null===(r=p.complete)||void 0===r?void 0:r.bind(p)}if(t instanceof Is)h=ms(t.firestore,ga),f=Gt(t.S_.path),c={next:function(e){i[a]&&i[a](Ja(h,t,e))},error:i[a+1],complete:i[a+2]};else{var d=ms(t,Es);h=ms(d.firestore,ga),f=d.C_;var v=new Ka(h);c={next:function(t){i[a]&&i[a](new Qa(h,v,d,t))},error:i[a+1],complete:i[a+2]},Aa(t.C_)}return function(t,e,n,r){var i=this,o=new ss(r),s=new yu(e,o,n);return t._s.Ps((function(){return Object(u.b)(i,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return e=fu,[4,pa(t)];case 1:return[2,e.apply(void 0,[n.sent(),s])]}}))}))})),function(){o.i_(),t._s.Ps((function(){return Object(u.b)(i,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return e=lu,[4,pa(t)];case 1:return[2,e.apply(void 0,[n.sent(),s])]}}))}))}))}}(wa(h),f,l,c)}function Za(t,e){return function(t,e){var n=this,r=new Zn;return t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var n;return Object(u.d)(this,(function(i){switch(i.label){case 0:return n=Du,[4,la(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(wa(t),e)}function Ja(t,e,n){var r=n.docs.get(e.S_),i=new Ka(t);return new Ga(t,i,e.S_,r,new za(n.hasPendingWrites,n.fromCache),e.v_)}var $a=function(){function t(t,e){this.Yf=t,this.wd=e,this.Ed=[],this.Td=!1,this.Id=Ls(t)}return t.prototype.set=function(t,e,n){this.md();var r=tc(t,this.Yf),i=qa(r.v_,e,n),o=Rs(this.Id,"WriteBatch.set",r.S_,i,null!==r.v_,n);return this.Ed.push(o.F_(r.S_,Ie.Kt())),this},t.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];this.md();var o,u=tc(t,this.Yf);return e instanceof hs&&(e=e.d_),o="string"==typeof e||e instanceof as?Qs(this.Id,"WriteBatch.update",u.S_,e,n,r):Bs(this.Id,"WriteBatch.update",u.S_,e),this.Ed.push(o.F_(u.S_,Ie.exists(!0))),this},t.prototype.delete=function(t){this.md();var e=tc(t,this.Yf);return this.Ed=this.Ed.concat(new Ue(e.S_,Ie.Kt())),this},t.prototype.commit=function(){return this.md(),this.Td=!0,this.Ed.length>0?this.wd(this.Ed):Promise.resolve()},t.prototype.md=function(){if(this.Td)throw new T(O.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}();function tc(t,e){if(t instanceof hs&&(t=t.d_),t.firestore!==e)throw new T(O.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}var ec=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).Yf=e,r}return Object(u.c)(e,t),e.prototype.get=function(e){var n=this,r=tc(e,this.Yf),i=new Ka(this.Yf);return t.prototype.get.call(this,e).then((function(t){return new Ga(n.Yf,i,r.S_,t.Zf,new za(!1,!1),r.v_)}))},e}(function(){function t(t,e){this.Yf=t,this.Ad=e,this.Id=Ls(t)}return t.prototype.get=function(t){var e=this,n=tc(t,this.Yf),r=new Fa(this.Yf);return this.Ad.ef([n.S_]).then((function(t){if(!t||1!==t.length)return v();var i=t[0];if(i instanceof gt)return new Ta(e.Yf,r,n.S_,null,n.v_);if(i instanceof bt)return new Ta(e.Yf,r,i.key,i,n.v_);throw v()}))},t.prototype.set=function(t,e,n){var r=tc(t,this.Yf),i=qa(r.v_,e,n),o=Rs(this.Id,"Transaction.set",r.S_,i,null!==r.v_,n);return this.Ad.set(r.S_,o),this},t.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];var o,u=tc(t,this.Yf);return e instanceof hs&&(e=e.d_),o="string"==typeof e||e instanceof as?Qs(this.Id,"Transaction.update",u.S_,e,n,r):Bs(this.Id,"Transaction.update",u.S_,e),this.Ad.update(u.S_,o),this},t.prototype.delete=function(t){var e=tc(t,this.Yf);return this.Ad.delete(e.S_),this},t}());function nc(){if("undefined"==typeof Uint8Array)throw new T(O.UNIMPLEMENT
1ED,"Uint8Arrays are not available in this environment.")}function rc(){if("undefined"==typeof atob)throw new T(O.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var ic=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.fromBase64String=function(t){return rc(),new e(N.fromBase64String(t))},e.fromUint8Array=function(t){return nc(),new e(N.fromUint8Array(t))},e.prototype.toBase64=function(){return rc(),this.d_.toBase64()},e.prototype.toUint8Array=function(){return nc(),this.d_.toUint8Array()},e.prototype.isEqual=function(t){return this.d_.isEqual(t.d_)},e.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},e}(hs),oc=function(){function t(){}return t.prototype.enableIndexedDbPersistence=function(t,e){return function(t,e){Ea(t=ms(t,ga));var n=wa(t),r=t.p_(),i=new us;return Ia(n,i,new is(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}(t.d_,{forceOwnership:e})},t.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(t){Ea(t=ms(t,ga));var e=wa(t),n=t.p_(),r=new us;return Ia(e,r,new os(r,n.cacheSizeBytes))}(t.d_)},t.prototype.clearIndexedDbPersistence=function(t){return function(t){var e=this;if(t.R_&&!t.P_)throw new T(O.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var n=new Zn;return t.Bf.Tf((function(){return Object(u.b)(e,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,function(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return tr.Kn()?(e=t+"main",[4,tr.delete(e)]):[2,Promise.resolve()];case 1:return n.sent(),[2]}}))}))}(Ci(t.I_,t.w_))];case 1:return r.sent(),n.resolve(),[3,3];case 2:return e=r.sent(),n.reject(e),[3,3];case 3:return[2]}}
1))}))})),n.promise}(t.d_)},t}(),uc=function(t){function e(e,n,r){var i=this;return(i=t.call(this,n)||this).Rd=r,i.INTERNAL={delete:function(){return i.terminate()}},e instanceof a||(i.Pd=e),i}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"I_",{get:function(){return this.d_.I_},enumerable:!1,configurable:!0}),e.prototype.settings=function(t){t.merge&&delete(t=Object.assign(Object.assign({},this.d_.V_()),t)).merge,this.d_.g_(t)},e.prototype.useEmulator=function(t,e){!function(t,e,n){var r=(t=ms(t,_s)).V_();"firestore.googleapis.com"!==r.host&&r.host!==e&&p("Host has been set in both settings() and useEmulator(), emulator host will be used"),t.g_(Object.assign(Object.assign({},r),{host:e+":"+n,ssl:!1}))}(this.d_,t,e)},e.prototype.enableNetwork=function(){return function(t){var e=this;return t._s.enqueue((function(){return Object(u.b)(e,void 0,void 0,(function(){var e,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:return[4,ca(t)];case 1:return e=r.sent(),[4,fa(t)];case 2:return n=r.sent(),[2,(e.yo(!0),function(t){var e=m(t);return e.Nh.delete(0),Uo(e)}(n))]}}))}))}))}(wa(ms(this.d_,ga)))},e.prototype.disableNetwork=function(){return function(t){var e=this;return t._s.enqueue((function(){return Object(u.b)(e,void 0,void 0,(function(){var e,n;return Object(u.d)(this,(function(r){switch(r.label){case 0:return[4,ca(t)];case 1:return e=r.sent(),[4,fa(t)];case 2:return n=r.sent(),[2,(e.yo(!1),function(t){return Object(u.b)(this,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return(e=m(t)).Nh.add(0),[4,Mo(e)];case 1:return n.sent(),e.Oh.set("Offline"),[2]}}))}))}(n))]}}))}))}))}(wa(ms(this.d_,ga)))},e.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&ps("synchronizeTabs",e=!!t.synchronizeTabs,"experimentalForceOwningTab",n=!!t.experimentalForceOwningTab),e?this.Rd.enableMultiTabIndexedDbPersistence(this):this.Rd.enableIndexedDbPersistence(this,n)},e.prototype.clearPersistence=function(){return this.Rd.clearIndexedDbPersistence(this)},e.prototype.terminate=function(){return this.Pd&&(this.Pd._removeServiceInstance("firestore"),this.Pd._removeServiceInstance("firestore-exp")),this.d_._delete()},e.prototype.waitForPendingWrites=function(){return function(t){var e=this,n=new Zn;return t._s.Ps((function(){return Object(u.b)(e,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(r){switch(r.label){case 0:return e=Cu,[4,la(t)];case 1:return[2,e.apply(void 0,[r.sent(),n])]}}))}))})),n.promise}(wa(ms(this.d_,ga)))},e.prototype.onSnapshotsInSync=function(t){return function(t,e){return function(t,e){var n=this,r=new ss(e);return t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return e=function(t,e){m(t).Wh.add(e),e.next()},[4,pa(t)];case 1:return[2,e.apply(void 0,[n.sent(),r])]}}))}))})),function(){r.i_(),t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var e;return Object(u.d)(this,(function(n){switch(n.label){case 0:return e=function(t,e){m(t).Wh.delete(e)},[4,pa(t)];case 1:return[2,e.apply(void 0,[n.sent(),r])]}}))}))}))}}(wa(t=ms(t,ga)),ma(e)?e:{next:e})}(this.d_,t)},Object.defineProperty(e.prototype,"app",{get:function(){if(!this.Pd)throw new T(O.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Pd},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){try{return new _c(this,Ts(this.d_,t))}catch(t){throw pc(t,"collection()","Firestore.collection()")}},e.prototype.doc=function(t){try{return new lc(this,Ns(this.d_,t))}catch(t){throw pc(t,"doc()","Firestore.doc()")}},e.prototype.collectionGroup=function(t){try{return new bc(this,function(t,e){if(t=ms(t,_s),fs("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new T(O.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Es(t,null,function(t){return new Ft(R.ct(),t)}(e))}(this.d_,t))}catch(t){throw pc(t,"collectionGroup()","Firestore.collectionGroup()")}},e.prototype.runTransaction=function(t){var e=this;return function(t,e){return function(t,e){var n=this,r=new Zn;return t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var n;return Object(u.d)(this,(function(i){switch(i.label){case 0:return[4,function(t){return aa(t).then((function(t){return t.Sh}))}(t)];case 1:return n=i.sent(),new ra(t._s,n,e,r).run(),[2]}}))}))})),r.promise}(wa(t),(function(n){return e(new ec(t,n))}
1))}(this.d_,(function(n){return t(new cc(e,n))}))},e.prototype.batch=function(){var t=this;return wa(this.d_),new hc(new $a(this.d_,(function(e){return Za(t.d_,e)})))},e.prototype.loadBundle=function(t){throw new T(O.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},e.prototype.namedQuery=function(t){throw new T(O.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},e}(hs),sc=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return Object(u.c)(e,t),e.prototype.Wf=function(t){return new ic(new N(t))},e.prototype.jf=function(t){var e=this.Jf(t,this.firestore.I_);return lc.yd(e,this.firestore,null)},e}(Oa);function ac(t){var e;e=t,c.setLogLevel(e)}var cc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).Yf=e,r.Xf=new sc(e),r}return Object(u.c)(e,t),e.prototype.get=function(t){var e=this,n=Ic(t);return this.d_.get(n).then((function(t){return new yc(e.Yf,new Ga(e.Yf.d_,e.Xf,t.S_,t.Zf,t.metadata,n.v_))}))},e.prototype.set=function(t,e,n){var r=Ic(t);return n?(ls("Transaction.set",n),this.d_.set(r,e,n)):this.d_.set(r,e),this},e.prototype.update=function(t,e,n){for(var r,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var s=Ic(t);return 2===arguments.length?this.d_.update(s,e):(r=this.d_).update.apply(r,Object(u.g)([s,e,n],i)),this},e.prototype.delete=function(t){var e=Ic(t);return this.d_.delete(e),this},e}(hs),hc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.set=function(t,e,n){var r=Ic(t);return n?(ls("WriteBatch.set",n),this.d_.set(r,e,n)):this.d_.set(r,e),this},e.prototype.update=function(t,e,n){for(var r,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var s=Ic(t);return 2===arguments.length?this.d_.update(s,e):(r=this.d_).update.apply(r,Object(u.g)([s,e,n],i)),this},e.prototype.delete=function(t){var e=Ic(t);return this.d_.delete(e),this},e.prototype.commit=function(){return this.d_.commit()},e}(hs),fc=function(t){function e(e,n,r){var i=this;return(i=t.call(this,r)||this).Yf=e,i.Xf=n,i}return Object(u.c)(e,t),e.prototype.fromFirestore=function(t,e){var n=new Ba(this.Yf.d_,this.Xf,t.S_,t.Zf,t.metadata,null);return this.d_.fromFirestore(new mc(this.Yf,n),null!=e?e:{})},e.prototype.toFirestore=function(t,e){return e?this.d_.toFirestore(t,e):this.d_.toFirestore(t)},e.gd=function(t,n){var r=e.Vd,i=r.get(t);i||(i=new WeakMap,r.set(t,i));var o=i.get(n);return o||(o=new e(t,new sc(t),n),i.set(n,o)),o},e}(hs);fc.Vd=new WeakMap;var lc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).firestore=e,r.Xf=new sc(e),r}return Object(u.c)(e,t),e.pd=function(t,n,r){if(t.length%2!=0)throw new T(O.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.rt()+" has "+t.length);return new e(n,new Is(n.d_,r,new q(t)))},e.yd=function(t,n,r){return new e(n,new Is(n.d_,r,t))},Object.defineProperty(e.prototype,"id",{get:function(){return this.d_.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new _c(this.firestore,this.d_.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.d_.path},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){try{return new _c(this.firestore,Ts(this.d_,t))}catch(t){throw pc(t,"collection()","DocumentReference.collection()")}},e.prototype.isEqual=function(t){return t instanceof hs&&(t=t.d_),t instanceof Is&&js(this.d_,t)},e.prototype.set=function(t,e){e=ls("DocumentReference.set",e);try{return function(t,e,n){t=ms(t,Is);var r=ms(t.firestore,ga),i=qa(t.v_,e,n);return Za(r,[Rs(Ls(r),"setDoc",t.S_,i,null!==t.v_,n).F_(t.S_,Ie.Kt())])}(this.d_,t,e)}catch(t){throw pc(t,"setDoc()","DocumentReference.set()")}},e.prototype.update=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{return 1===arguments.length?Xa(this.d_,t):Xa.apply(void 0,Object(u.g)([this.d_,t,e],n))}
1catch(t){throw pc(t,"updateDoc()","DocumentReference.update()")}},e.prototype.delete=function(){return Za(ms((t=this.d_).firestore,ga),[new Ue(t.S_,Ie.Kt())]);var t},e.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=dc(e),i=vc(e,(function(e){return new yc(t.firestore,new Ga(t.firestore.d_,t.Xf,e.S_,e.Zf,e.metadata,t.d_.v_))}));return Wa(this.d_,r,i)},e.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(t){t=ms(t,Is);var e=ms(t.firestore,ga),n=wa(e),r=new Ka(e);return function(t,e){var n=this,r=new Zn;return t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var n;return Object(u.d)(this,(function(i){switch(i.label){case 0:return n=function(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i;return Object(u.d)(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,function(t,e){var n=m(t);return n.persistence.runTransaction("read document","readonly",(function(t){return n.Tc.Ho(t,e)}))}(t,e)];case 1:return(i=o.sent())instanceof bt?n.resolve(i):i instanceof gt?n.resolve(null):n.reject(new T(O.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),[3,3];case 2:return r=o.sent(),i=cr(r,"Failed to get document '"+e+" from cache"),n.reject(i),[3,3];case 3:return[2]}}
1))}))},[4,ha(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(n,t.S_).then((function(n){return new Ga(e,r,t.S_,n,new za(n instanceof bt&&n.Vt,!0),t.v_)}))}(this.d_):"server"===(null==t?void 0:t.source)?function(t){t=ms(t,Is);var e=ms(t.firestore,ga);return da(wa(e),t.S_,{source:"server"}).then((function(n){return Ja(e,t,n)}))}(this.d_):function(t){t=ms(t,Is);var e=ms(t.firestore,ga);return da(wa(e),t.S_).then((function(n){return Ja(e,t,n)}))}(this.d_)).then((function(t){return new yc(e.firestore,new Ga(e.firestore.d_,e.Xf,t.S_,t.Zf,t.metadata,e.d_.v_))}))},e.prototype.withConverter=function(t){return new e(this.firestore,this.d_.withConverter(fc.gd(this.firestore,t)))},e}(hs);function pc(t,e,n){return t.message=t.message.replace(e,n),t}function dc(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if("object"==typeof r&&!ma(r))return r}return{}}function vc(t,e){var n,r,i;return{next:function(t){i.next&&i.next(e(t))},error:null===(n=(i=ma(t[0])?t[0]:ma(t[1])?t[1]:"function"==typeof t[0]?{next:t[0],error:t[1],complete:t[2]}:{next:t[1],error:t[2],complete:t[3]}).error)||void 0===n?void 0:n.bind(i),complete:null===(r=i.complete)||void 0===r?void 0:r.bind(i)}}var yc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).Yf=e,r}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"ref",{get:function(){return new lc(this.Yf,this.d_.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.d_.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this.d_.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exists",{get:function(){return this.d_.exists()},enumerable:!1,configurable:!0}),e.prototype.data=function(t){return this.d_.data(t)},e.prototype.get=function(t,e){return this.d_.get(t,e)},e.prototype.isEqual=function(t){return Ha(this.d_,t.d_)},e}(hs),mc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.prototype.data=function(t){return this.d_.data(t)},e}(yc),bc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).firestore=e,r.Xf=new sc(e),r}return Object(u.c)(e,t),e.prototype.where=function(t,n,r){try{return new e(this.firestore,Sa(this.d_,function(t,e,n){var r=e,i=ja("where",t);return new xa(i,r,n)}(t,n,r)))}catch(t){throw pc(t,/(orderBy|where)\(\)/,"Query.$1()")}},e.prototype.orderBy=function(t,n){try{return new e(this.firestore,Sa(this.d_,function(t,e){void 0===e&&(e="asc");var n=e,r=ja("orderBy",t);return new ka(r,n)}(t,n)))}catch(t){throw pc(t,/(orderBy|where)\(\)/,"Query.$1()")}},e.prototype.limit=function(t){try{return new e(this.firestore,Sa(this.d_,function(t){return bs("limit",t),new Pa("limit",t,"F")}(t)))}catch(t){throw pc(t,"limit()","Query.limit()")}},e.prototype.limitToLast=function(t){try{return new e(this.firestore,Sa(this.d_,function(t){return bs("limitToLast",t),new Pa("limitToLast",t,"L")}(t)))}catch(t){throw pc(t,"limitToLast()","Query.limitToLast()")}},e.prototype.startAt=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Sa(this.d_,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Va("startAt",t,!0)}.apply(void 0,t)))}catch(t){throw pc(t,"startAt()","Query.startAt()")}},e.prototype.startAfter=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Sa(this.d_,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Va("startAfter",t,!1)}.apply(void 0,t)))}catch(t){throw pc(t,"startAfter()","Query.startAfter()")}},e.prototype.endBefore=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Sa(this.d_,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Ca("endBefore",t,!0)}.apply(void 0,t)))}catch(t){throw pc(t,"endBefore()","Query.endBefore()")}},e.prototype.endAt=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Sa(this.d_,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Ca("endAt",t,!1)}.apply(void 0,t)))}catch(t){throw pc(t,"endAt()","Query.endAt()")}},e.prototype.isEqual=function(t){return As(this.d_,t.d_)},e.prototype.get=function(t){var e=this;
1return("cache"===(null==t?void 0:t.source)?function(t){t=ms(t,Es);var e=ms(t.firestore,ga),n=wa(e),r=new Ka(e);return function(t,e){var n=this,r=new Zn;return t._s.Ps((function(){return Object(u.b)(n,void 0,void 0,(function(){var n;return Object(u.d)(this,(function(i){switch(i.label){case 0:return n=function(t,e,n){return Object(u.b)(this,void 0,void 0,(function(){var r,i,o,s,a;return Object(u.d)(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,Wi(t,e,!0)];case 1:return a=u.sent(),r=new Iu(e,a.Rc),i=r.fl(a.documents),o=r.wi(i,!1),n.resolve(o.snapshot),[3,3];case 2:return s=u.sent(),a=cr(s,"Failed to execute query '"+e+" against cache"),n.reject(a),[3,3];case 3:return[2]}}))}))},[4,ha(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(n,t.C_).then((function(n){return new Qa(e,r,t,n)}))}(this.d_):"server"===(null==t?void 0:t.source)?function(t){t=ms(t,Es);var e=ms(t.firestore,ga),n=wa(e),r=new Ka(e);return va(n,t.C_,{source:"server"}).then((function(n){return new Qa(e,r,t,n)}))}(this.d_):function(t){t=ms(t,Es);var e=ms(t.firestore,ga),n=wa(e),r=new Ka(e);return Aa(t.C_),va(n,t.C_).then((function(n){return new Qa(e,r,t,n)}))}(this.d_)).then((function(t){return new wc(e.firestore,new Qa(e.firestore.d_,e.Xf,e.d_,t._d))}))},e.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=dc(e),i=vc(e,(function(e){return new wc(t.firestore,new Qa(t.firestore.d_,t.Xf,t.d_,e._d))}));return Wa(this.d_,r,i)},e.prototype.withConverter=function(t){return new e(this.firestore,this.d_.withConverter(fc.gd(this.firestore,t)))},e}(hs),gc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).Yf=e,r}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return this.d_.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doc",{get:function(){return new mc(this.Yf,this.d_.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldIndex",{get:function(){return this.d_.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newIndex",{get:function(){return this.d_.newIndex},enumerable:!1,configurable:!0}),e}(hs),wc=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).Yf=e,r}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"query",{get:function(){return new bc(this.Yf,this.d_.query)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this.d_.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.d_.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"empty",{get:function(){return this.d_.empty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"docs",{get:function(){var t=this;return this.d_.docs.map((function(e){return new mc(t.Yf,e)}))},enumerable:!1,configurable:!0}),e.prototype.docChanges=function(t){var e=this;return this.d_.docChanges(t).map((function(t){return new gc(e.Yf,t)}))},e.prototype.forEach=function(t,e){var n=this;this.d_.forEach((function(r){t.call(e,new mc(n.Yf,r))}))},e.prototype.isEqual=function(t){return Ha(this.d_,t.d_)},e}(hs),_c=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).firestore=e,r.d_=n,r}return Object(u.c)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.d_.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.d_.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this.d_.parent;return t?new lc(this.firestore,t):null},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){try{return new lc(this.firestore,void 0===t?Ns(this.d_):Ns(this.d_,t))}catch(t){throw pc(t,"doc()","CollectionReference.doc()")}},e.prototype.add=function(t){var e=this;return function(t,e){var n=ms(t.firestore,ga),r=Ns(t),i=qa(t.v_,e);return Za(n,[Rs(Ls(t.firestore),"addDoc",r.S_,i,null!==t.v_,{}).F_(r.S_,Ie.exists(!1))]).then((function(){return r}))}(this.d_,t).then((function(t){return new lc(e.firestore,t)}))},e.prototype.isEqual=function(t){return js(this.d_,t.d_)},e.prototype.withConverter=function(t){return new e(this.firestore,this.d_.withConverter(fc.gd(this.firestore,t)))},e}(bc);function Ic(t){return t instanceof hs&&(t=t.d_),ms(t,Is)}var Ec=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.call(this,new(as.bind.apply(as,Object(u.g)([void 0],e))))||this}return Object(u.c)(e,t),e.documentId=function(){return new e(M.ht().rt())},e.prototype.isEqual=function(t){return t instanceof hs&&(t=t.d_),t instanceof as&&this.d_.f_.isEqual(t.f_)},e}(hs),Oc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(u.c)(e,t),e.serverTimestamp=function(){var t=new qs("serverTimestamp");return t._methodName="FieldValue.serverTimestamp",new e(t)},e.delete=function(){var t=new Us("deleteField");return t._methodName="FieldValue.delete",new e(t)},e.arrayUnion=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Fs("arrayUnion",t)}.apply(void 0,t);return r._methodName="FieldValue.arrayUnion",new e(r)},e.arrayRemove=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new zs("arrayRemove",t)}.apply(void 0,t);return r._methodName="FieldValue.arrayRemove",new e(r)},e.increment=function(t){var n=function(t){return new Gs("increment",t)}(t);return n._methodName="FieldValue.increment",new e(n)},e.prototype.isEqual=function(t){return this.d_.isEqual(t.d_)},e}(hs)}).call(this,n("5IsQ"))}}]);

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