1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00
musix-oss/node_modules/firebase/firebase-firestore.min.js
2020-03-03 22:30:50 +02:00

3 lines
310 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t=t||self).firebase)}(this,function(Bd){"use strict";try{(function(){Bd=Bd&&Bd.hasOwnProperty("default")?Bd.default:Bd;var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function t(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o,e,f=function(){return(f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function p(o,s,a,u){return new(a=a||Promise)(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(n,r)}i((u=u.apply(o,s||[])).next())})}function y(n,r){var i,o,s,t,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,o=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=r.call(n,a)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function s(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function a(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(e=o=o||{})[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT";function n(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var i=(new Date).toISOString();switch(e){case o.DEBUG:case o.VERBOSE:console.log.apply(console,a(["["+i+"] "+t.name+":"],n));break;case o.INFO:console.info.apply(console,a(["["+i+"] "+t.name+":"],n));break;case o.WARN:console.warn.apply(console,a(["["+i+"] "+t.name+":"],n));break;case o.ERROR:console.error.apply(console,a(["["+i+"] "+t.name+":"],n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}}var i=o.INFO,u=(Object.defineProperty(h.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in o))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!0,configurable:!0}),h.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,a([this,o.DEBUG],t))},h.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,a([this,o.VERBOSE],t))},h.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,a([this,o.INFO],t))},h.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,a([this,o.WARN],t))},h.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,a([this,o.ERROR],t))},h);function h(t){this.name=t,this._logLevel=i,this._logHandler=n}function l(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var c,d=(t(v,c=Error),v);function v(t,e){var n=c.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,v.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,m.prototype.create),n}var m=(g.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=e[0]||{},i=this.service+"/"+t,o=this.errors[t],s=o?function(t,r){return t.replace(w,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})}(o,r):"Error",a=this.serviceName+": "+s+" ("+i+").",u=new d(i,a),h=0,c=Object.keys(r);h<c.length;h++){var f=c[h];"_"!==f.slice(-1)&&(f in u&&console.warn('Overwriting FirebaseError base field "'+f+'" can cause unexpected behavior.'),u[f]=r[f])}return u},g);function g(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var w=/\{\$([^}]+)}/g,b=(E.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},E.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},E.prototype.setServiceProps=function(t){return this.serviceProps=t,this},E);function E(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var I,T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A=A||{},N=T;function S(t){return"string"==typeof t}function D(t){return"number"==typeof t}function k(t,e){t=t.split("."),e=e||N;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function R(){}function _(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function C(t){return"array"==_(t)}function x(t){var e=_(t);return"array"==e||"object"==e&&"number"==typeof t.length}function P(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var O="closure_uid_"+(1e9*Math.random()>>>0),L=0;function q(t,e,n){return t.call.apply(t.bind,arguments)}function M(e,n,t){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,r),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function U(t,e,n){return(U=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?q:M).apply(null,arguments)}function V(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}var j=Date.now||function(){return+new Date};function F(t,o){function e(){}e.prototype=o.prototype,t.N=o.prototype,t.prototype=new e,(t.prototype.constructor=t).xb=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function G(){this.j=this.j,this.i=this.i}G.prototype.j=!1,G.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[O]||(this[O]=++L)},G.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var B=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(S(t))return S(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},z=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=S(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function X(t){return Array.prototype.concat.apply([],arguments)}function W(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function H(t){return/^[\s\xa0]*$/.test(t)}var Y,K=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function Q(t,e){return-1!=t.indexOf(e)}function J(t,e){return t<e?-1:e<t?1:0}t:{var $=N.navigator;if($){var Z=$.userAgent;if(Z){Y=Z;break t}}Y=""}function tt(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function et(t){var e,n={};for(e in t)n[e]=t[e];return n}var nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function rt(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<nt.length;o++)n=nt[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function it(t){return it[" "](t),t}it[" "]=R;var ot,st,at=Q(Y,"Opera"),ut=Q(Y,"Trident")||Q(Y,"MSIE"),ht=Q(Y,"Edge"),ct=ht||ut,ft=Q(Y,"Gecko")&&!(Q(Y.toLowerCase(),"webkit")&&!Q(Y,"Edge"))&&!(Q(Y,"Trident")||Q(Y,"MSIE"))&&!Q(Y,"Edge"),lt=Q(Y.toLowerCase(),"webkit")&&!Q(Y,"Edge");function pt(){var t=N.document;return t?t.documentMode:void 0}t:{var dt="",yt=(st=Y,ft?/rv:([^\);]+)(\)|;)/.exec(st):ht?/Edge\/([\d\.]+)/.exec(st):ut?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(st):lt?/WebKit\/(\S+)/.exec(st):at?/(?:Version)[ \/]?(\S+)/.exec(st):void 0);if(yt&&(dt=yt?yt[1]:""),ut){var vt=pt();if(null!=vt&&vt>parseFloat(dt)){ot=String(vt);break t}}ot=dt}var mt,gt={};function wt(a){return function(t,e){var n=gt;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(a,function(){for(var t=0,e=K(String(ot)).split("."),n=K(String(a)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var o=e[i]||"",s=n[i]||"";do{if(o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==o[0].length&&0==s[0].length)break;t=J(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||J(0==o[2].length,0==s[2].length)||J(o[2],s[2]),o=o[3],s=s[3]}while(0==t)}return 0<=t})}var bt=N.document;mt=bt&&ut?pt()||("CSS1Compat"==bt.compatMode?parseInt(ot,10):5):void 0;var Et=!ut||9<=Number(mt),It=ut&&!wt("9"),Tt=function(){if(!N.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{N.addEventListener("test",R,e),N.removeEventListener("test",R,e)}catch(t){}return t}();function At(t,e){this.type=t,this.a=this.target=e,this.Ia=!0}function Nt(t,e){if(At.call(this,t?t.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.a=e,e=t.relatedTarget){if(ft){t:{try{it(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=S(t.pointerType)?t.pointerType:St[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}At.prototype.b=function(){this.Ia=!1},F(Nt,At);var St={2:"touch",3:"pen",4:"mouse"};Nt.prototype.b=function(){Nt.N.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,It)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var Dt="closure_listenable_"+(1e6*Math.random()|0),kt=0;function Rt(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.da=i,this.key=++kt,this.X=this.Z=!1}function _t(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function Ct(t){this.src=t,this.a={},this.b=0}function xt(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=B(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(_t(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function Pt(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.X&&o.listener==e&&o.capture==!!n&&o.da==r)return i}return-1}Ct.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Pt(t,e,r,i);return-1<s?(e=t[s],n||(e.Z=!1)):((e=new Rt(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var Ot="closure_lm_"+(1e6*Math.random()|0),Lt={};function qt(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(C(n)){for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);return null}r=zt(r);return e&&e[Dt]?e.Aa(n,r,P(i)?!!i.capture:!!i,o):Mt(e,n,r,!0,i,o)}(t,e,n,r,i);if(C(e)){for(var o=0;o<e.length;o++)qt(t,e[o],n,r,i);return null}return n=zt(n),t&&t[Dt]?t.za(e,n,P(r)?!!r.capture:!!r,i):Mt(t,e,n,!1,r,i)}function Mt(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=P(i)?!!i.capture:!!i;if(s&&!Et)return null;var a=Gt(t);if(a||(t[Ot]=a=new Ct(t)),(n=a.add(e,n,r,s,o)).proxy)return n;if(r=function(){var e=Ft,n=Et?function(t){return e.call(n.src,n.listener,t)}:function(t){if(!(t=e.call(n.src,n.listener,t)))return t};return n}(),(n.proxy=r).src=t,r.listener=n,t.addEventListener)Tt||(i=s),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Vt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Ut(t){if(!D(t)&&t&&!t.X){var e=t.src;if(e&&e[Dt])xt(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Vt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Gt(e))?(xt(n,t),0==n.b&&(n.src=null,e[Ot]=null)):_t(t)}}}function Vt(t){return t in Lt?Lt[t]:Lt[t]="on"+t}function jt(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&Ut(t),n.call(r,e)}function Ft(t,e){return!!t.X||(Et?jt(t,new Nt(e,this)):jt(t,e=new Nt(e||k("window.event"),this)))}function Gt(t){return(t=t[Ot])instanceof Ct?t:null}var Bt="__closure_events_fn_"+(1e9*Math.random()>>>0);function zt(e){return"function"==_(e)?e:(e[Bt]||(e[Bt]=function(t){return e.handleEvent(t)}),e[Bt])}function Xt(){G.call(this),this.c=new Ct(this),(this.J=this).B=null}function Wt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var s=e[o];if(s&&!s.X&&s.capture==n){var a=s.listener,u=s.da||s.src;s.Z&&xt(t.c,s),i=!1!==a.call(u,r)&&i}}return i&&0!=r.Ia}F(Xt,G),Xt.prototype[Dt]=!0,(I=Xt.prototype).addEventListener=function(t,e,n,r){qt(this,t,e,n,r)},I.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(C(n))for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);else i=P(i)?!!i.capture:!!i,r=zt(r),e&&e[Dt]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Pt(s=e.a[n],r,i,o))&&(_t(s[r]),Array.prototype.splice.call(s,r,1),0==s.length&&(delete e.a[n],e.b--))):(e=e&&Gt(e))&&(n=e.a[n.toString()],e=-1,n&&(e=Pt(n,r,i,o)),(r=-1<e?n[e]:null)&&Ut(r))}(this,t,e,n,r)},I.dispatchEvent=function(t){var e,n=this.B;if(n)for(e=[];n;n=n.B)e.push(n);n=this.J;var r=t.type||t;if(S(t))t=new At(t,n);else if(t instanceof At)t.target=t.target||n;else{var i=t;rt(t=new At(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var s=t.a=e[o];i=Wt(s,r,!0,t)&&i}if(i=Wt(s=t.a=n,r,!0,t)&&i,i=Wt(s,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Wt(s=t.a=e[o],r,!1,t)&&i;return i},I.G=function(){if(Xt.N.G.call(this),this.c){var t,e=this.c;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)_t(n[r]);delete e.a[t],e.b--}}this.B=null},I.za=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},I.Aa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var Ht=N.JSON.stringify;function Yt(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function Kt(){this.b=this.a=null}Yt.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var Qt,Jt=new Yt(function(){return new $t},function(t){t.reset()});function $t(){this.next=this.b=this.a=null}function Zt(t){N.setTimeout(function(){throw t},0)}function te(t,e){Qt||function(){var t=N.Promise.resolve(void 0);Qt=function(){t.then(re)}}(),ee||(Qt(),ee=!0),ne.add(t,e)}Kt.prototype.add=function(t,e){var n=Jt.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},$t.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var ee=!($t.prototype.reset=function(){this.next=this.b=this.a=null}),ne=new Kt;function re(){for(var t;r=n=void 0,r=null,(n=ne).a&&(r=n.a,n.a=n.a.next,n.a||(n.b=null),r.next=null),t=r;){try{t.a.call(t.b)}catch(t){Zt(t)}var e=Jt;e.f(t),e.b<100&&(e.b++,t.next=e.a,e.a=t)}var n,r;ee=!1}function ie(t,e){Xt.call(this),this.b=t||1,this.a=e||N,this.f=U(this.fb,this),this.g=j()}function oe(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function se(t,e,n){if("function"==_(t))n&&(t=U(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=U(t.handleEvent,t)}return 2147483647<Number(e)?-1:N.setTimeout(t,e||0)}function ae(t,e,n){G.call(this),this.f=null!=n?U(t,n):t,this.c=e,this.b=U(this.$a,this),this.a=[]}function ue(t){t.U=se(t.b,t.c),t.f.apply(null,t.a)}function he(t){G.call(this),this.b=t,this.a={}}F(ie,Xt),(I=ie.prototype).ba=!1,I.L=null,I.fb=function(){if(this.ba){var t=j()-this.g;0<t&&t<.8*this.b?this.L=this.a.setTimeout(this.f,this.b-t):(this.L&&(this.a.clearTimeout(this.L),this.L=null),this.dispatchEvent("tick"),this.ba&&(oe(this),this.start()))}},I.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=j())},I.G=function(){ie.N.G.call(this),oe(this),delete this.a},F(ae,G),(I=ae.prototype).ea=!1,I.U=null,I.Ta=function(t){this.a=arguments,this.U?this.ea=!0:ue(this)},I.G=function(){ae.N.G.call(this),this.U&&(N.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},I.$a=function(){this.U=null,this.ea&&(this.ea=!1,ue(this))},F(he,G);var ce=[];function fe(t,e,n,r){C(n)||(n&&(ce[0]=n.toString()),n=ce);for(var i=0;i<n.length;i++){var o=qt(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function le(t){tt(t.a,function(t,e){this.a.hasOwnProperty(e)&&Ut(t)},t),t.a={}}function pe(){}he.prototype.G=function(){he.N.G.call(this),le(this)},he.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var de=new Xt;function ye(t){At.call(this,"serverreachability",t)}function ve(t){de.dispatchEvent(new ye(de,t))}function me(t){At.call(this,"statevent",t)}function ge(t){de.dispatchEvent(new me(de,t))}function we(t){At.call(this,"timingevent",t)}function be(t,e){if("function"!=_(t))throw Error("Fn must not be null and must be a function");return N.setTimeout(function(){t()},e)}F(ye,At),F(me,At),F(we,At);var Ee={NO_ERROR:0,gb:1,nb:2,mb:3,jb:4,lb:5,ob:6,La:7,TIMEOUT:8,rb:9},Ie={ib:"complete",vb:"success",Ma:"error",La:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",kb:"downloadprogress",wb:"uploadprogress"};function Te(){}function Ae(t){var e;return(e=t.a)||(e=t.a={}),e}function Ne(){}Te.prototype.a=null;var Se,De={OPEN:"a",hb:"b",Ma:"c",qb:"d"};function ke(){At.call(this,"d")}function Re(){At.call(this,"c")}function _e(){}function Ce(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new he(this),this.O=xe,t=ct?125:void 0,this.P=new ie(t),this.h=null,this.b=!1,this.l=this.D=this.f=this.F=this.v=this.R=this.i=null,this.j=[],this.a=null,this.A=0,this.c=this.w=null,this.o=-1,this.m=!1,this.J=0,this.B=null,this.s=this.S=this.H=!1}F(ke,At),F(Re,At),F(_e,Te),Se=new _e;var xe=45e3,Pe={},Oe={};function Le(t,e,n){t.F=1,t.f=an(Ze(e)),t.l=n,t.H=!0,Me(t,null)}function qe(t,e,n,r){t.F=1,t.f=an(Ze(e)),t.l=null,t.H=n,Me(t,r)}function Me(t,e){t.v=j(),je(t),t.D=Ze(t.f),sn(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new ae(U(t.Ja,t,t.a),t.J)),fe(t.I,t.a,"readystatechange",t.cb),e=t.h?et(t.h):{},t.l?(t.w||(t.w="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.ca(t.D,t.w,t.l,e)):(t.w="GET",t.a.ca(t.D,t.w,null,e)),ve(1)}function Ue(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=Ve(t,n);if(i==Oe){4==e&&(t.c=4,ge(14),r=!1);break}if(i==Pe){t.c=4,ge(15),r=!1;break}Xe(t,i)}4==e&&0==n.length&&(t.c=1,ge(16),r=!1),t.b=t.b&&r,r||(ze(t),Be(t))}function Ve(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?Oe:(n=Number(e.substring(n,r)),isNaN(n)?Pe:(r+=1)+n>e.length?Oe:(e=e.substr(r,n),t.A=r+n,e))}function je(t){t.R=j()+t.O,Fe(t,t.O)}function Fe(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=be(U(t.ab,t),e)}function Ge(t){t.i&&(N.clearTimeout(t.i),t.i=null)}function Be(t){t.g.Ca()||t.m||t.g.na(t)}function ze(t){Ge(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,oe(t.P),le(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function Xe(t,e){try{t.g.Fa(t,e),ve(4)}catch(t){}}function We(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(x(t)||S(t))z(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(x(t)||S(t)){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;i=(r=function(t){if(t.C&&"function"==typeof t.C)return t.C();if(S(t))return t.split("");if(x(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function He(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof He)for(n=t.K(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Ye(t,e){Qe(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Ke(t))}function Ke(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Qe(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){var i={};for(n=e=0;e<t.a.length;)Qe(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function Qe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(I=Ce.prototype).setTimeout=function(t){this.O=t},I.cb=function(t){t=t.target;var e=this.B;e&&3==Zn(t)?e.Ta():this.Ja(t)},I.Ja=function(t){try{if(t==this.a)t:{var e=Zn(this.a),n=this.a.ya(),r=this.a.T();if(!(e<3||3==e&&!ct&&!this.a.aa())){this.m||4!=e||7==n||ve(8==n||r<=0?3:2),Ge(this);var i=this.a.T();this.o=i;var o=this.a.aa();if(this.b=200==i){if(this.S&&!this.s){e:{if(this.a){var s=tr(this.a,"X-HTTP-Initial-Response");if(s&&!H(s)){var a=s;break e}}a=null}if(!a){this.b=!1,this.c=3,ge(12),ze(this),Be(this);break t}this.s=!0,Xe(this,a)}this.H?(Ue(this,e,o),ct&&this.b&&3==e&&(fe(this.I,this.P,"tick",this.bb),this.P.start())):Xe(this,o),4==e&&ze(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,je(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,ge(12)):(this.c=0,ge(13)),ze(this),Be(this)}}}catch(t){}},I.bb=function(){if(this.a){var t=Zn(this.a),e=this.a.aa();this.A<e.length&&(Ge(this),Ue(this,t,e),this.b&&4!=t&&je(this))}},I.cancel=function(){this.m=!0,ze(this)},I.ab=function(){this.i=null;var t=j();0<=t-this.R?(2!=this.F&&(ve(3),ge(17)),ze(this),this.c=2,Be(this)):Fe(this,this.R-t)},(I=He.prototype).C=function(){Ke(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},I.K=function(){return Ke(this),this.a.concat()},I.get=function(t,e){return Qe(this.b,t)?this.b[t]:e},I.set=function(t,e){Qe(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},I.forEach=function(t,e){for(var n=this.K(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var Je=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function $e(t,e){var n;this.b=this.j=this.f="",this.i=null,this.g=this.a="",this.h=!1,t instanceof $e?(this.h=void 0!==e?e:t.h,tn(this,t.f),this.j=t.j,en(this,t.b),nn(this,t.i),this.a=t.a,rn(this,En(t.c)),this.g=t.g):t&&(n=String(t).match(Je))?(this.h=!!e,tn(this,n[1]||"",!0),this.j=un(n[2]||""),en(this,n[3]||"",!0),nn(this,n[4]),this.a=un(n[5]||"",!0),rn(this,n[6]||"",!0),this.g=un(n[7]||"")):(this.h=!!e,this.c=new vn(null,this.h))}function Ze(t){return new $e(t)}function tn(t,e,n){t.f=n?un(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function en(t,e,n){t.b=n?un(e,!0):e}function nn(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.i=e}else t.i=null}function rn(t,e,n){e instanceof vn?(t.c=e,function(t,e){e&&!t.f&&(mn(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(gn(this,e),bn(this,n,t))},t)),t.f=e}(t.c,t.h)):(n||(e=hn(e,dn)),t.c=new vn(e,t.h))}function on(t,e,n){t.c.set(e,n)}function sn(t,e,n){C(n)||(n=[String(n)]),bn(t.c,e,n)}function an(t){return on(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^j()).toString(36)),t}function un(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function hn(t,e,n){return S(t)?(t=encodeURI(t).replace(e,cn),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function cn(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}$e.prototype.toString=function(){var t=[],e=this.f;e&&t.push(hn(e,fn,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(hn(e,fn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(hn(n,"/"==n.charAt(0)?pn:ln,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",hn(n,yn)),t.join("")},$e.prototype.resolve=function(t){var e=Ze(this),n=!!t.f;n?tn(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?en(e,t.b):n=null!=t.i;var r=t.a;if(n)nn(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(Q(i,"./")||Q(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],s=0;s<i.length;){var a=i[s++];"."==a?r&&s==i.length&&o.push(""):".."==a?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&s==i.length&&o.push("")):(o.push(a),r=!0)}r=o.join("/")}else r=i}return n?e.a=r:n=""!==t.c.toString(),n?rn(e,En(t.c)):n=!!t.g,n&&(e.g=t.g),e};var fn=/[#\/\?@]/g,ln=/[#\?:]/g,pn=/[#\?]/g,dn=/[#\?@]/g,yn=/#/g;function vn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function mn(n){n.a||(n.a=new He,n.b=0,n.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(n.c,function(t,e){n.add(decodeURIComponent(t.replace(/\+/g," ")),e)}))}function gn(t,e){mn(t),e=In(t,e),Qe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Ye(t.a,e))}function wn(t,e){return mn(t),e=In(t,e),Qe(t.a.b,e)}function bn(t,e,n){gn(t,e),0<n.length&&(t.c=null,t.a.set(In(t,e),W(n)),t.b+=n.length)}function En(t){var e=new vn;return e.c=t.c,t.a&&(e.a=new He(t.a),e.b=t.b),e}function In(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function Tn(t){this.a=t,this.b=this.h=null,this.g=!1,this.i=null,this.c=-1,this.l=this.f=null}function An(t){var e=t.a.F.a;if(null!=e)ge(4),e?(ge(10),lr(t.a,t,!1)):(ge(11),lr(t.a,t,!0));else{t.b=new Ce(t,void 0,void 0),t.b.h=t.h,e=mr(e=t.a,e.Y()?t.f:null,t.i),ge(4),sn(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&on(e,n,r),qe(t.b,e,!1,t.f)}}function Nn(){this.a=this.b=null}function Sn(){this.a=new He}function Dn(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[O]||(t[O]=++L)):e.charAt(0)+t}function kn(t,e){this.b=t,this.a=e}function Rn(t){this.g=t||_n,t=N.PerformanceNavigationTiming?0<(t=N.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(N.ka&&N.ka.Da&&N.ka.Da()&&N.ka.Da().yb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Sn),this.b=null,this.c=[]}(I=vn.prototype).add=function(t,e){mn(this),this.c=null,t=In(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},I.forEach=function(n,r){mn(this),this.a.forEach(function(t,e){z(t,function(t){n.call(r,t,e,this)},this)},this)},I.K=function(){mn(this);for(var t=this.a.C(),e=this.a.K(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},I.C=function(t){mn(this);var e=[];if(S(t))wn(this,t)&&(e=X(e,this.a.get(In(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=X(e,t[n])}return e},I.set=function(t,e){return mn(this),this.c=null,wn(this,t=In(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},I.get=function(t,e){return t&&0<(t=this.C(t)).length?String(t[0]):e},I.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.K(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.C(r);for(var o=0;o<r.length;o++){var s=i;""!==r[o]&&(s+="="+encodeURIComponent(String(r[o]))),t.push(s)}}return this.c=t.join("&")},F(function(){},function(){}),(I=Tn.prototype).M=null,I.$=function(t){return this.a.$(t)},I.abort=function(){this.b&&(this.b.cancel(),this.b=null),this.c=-1},I.Ca=function(){return!1},I.Fa=function(t,e){if(this.c=t.o,0==this.M){if(!this.a.o&&(t=t.a)){var n=tr(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=tr(t,"X-HTTP-Session-Id"))&&(this.a.I=t)}if(e){try{var r=this.a.ja.a.parse(e)}catch(t){return(e=this.a).m=this.c,void yr(e,2)}this.f=r[0]}else(e=this.a).m=this.c,yr(e,2)}else 1==this.M&&(this.g?ge(6):"11111"==e?(ge(5),this.g=!0,(!ut||10<=Number(mt))&&(this.c=200,this.b.cancel(),ge(11),lr(this.a,this,!0))):(ge(7),this.g=!1))},I.na=function(){if(this.c=this.b.o,this.b.b)0==this.M?(this.M=1,An(this)):1==this.M&&(this.g?(ge(11),lr(this.a,this,!0)):(ge(10),lr(this.a,this,!1)));else{0==this.M?ge(8):1==this.M&&ge(9);var t=this.a;t.m=this.c,yr(t,2)}},I.Y=function(){return this.a.Y()},I.ma=function(){return this.a.ma()},Sn.prototype.add=function(t){this.a.set(Dn(t),t)},Sn.prototype.C=function(){return this.a.C()};var _n=10;function Cn(t,e){!t.a&&(Q(e,"spdy")||Q(e,"quic")||Q(e,"h2"))&&(t.f=t.g,t.a=new Sn,t.b&&(Ln(t,t.b),t.b=null))}function xn(t){return!!t.b||!!t.a&&t.a.a.c>=t.f}function Pn(t){return t.b?1:t.a?t.a.a.c:0}function On(t,e){return t=t.b?t.b==e:!!t.a&&(e=Dn(e),Qe(t.a.a.b,e))}function Ln(t,e){t.a?t.a.add(e):t.b=e}function qn(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=Dn(e),n=Qe(t.a.a.b,n)),n&&Ye(t.a.a,Dn(e)))}function Mn(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return W(t.c);var e=t.c;return z(t.a.C(),function(t){e=e.concat(t.j)}),e}function Un(){}function Vn(){this.a=new Un}function jn(t,r,e){var i=e||"";try{We(t,function(t,e){var n=t;P(t)&&(n=Ht(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Fn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}Rn.prototype.cancel=function(){this.c=Mn(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(z(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},Un.prototype.stringify=function(t){return N.JSON.stringify(t,void 0)},Un.prototype.parse=function(t){return N.JSON.parse(t,void 0)};var Gn=N.JSON.parse;function Bn(t){Xt.call(this),this.headers=new He,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=zn,this.D=this.F=!1}F(Bn,Xt);var zn="",Xn=/^https?$/i,Wn=["POST","PUT"];function Hn(t){return"content-type"==t.toLowerCase()}function Yn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Kn(t),Jn(t)}function Kn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Qn(t){if(t.b&&void 0!==A&&(!t.s[1]||4!=Zn(t)||2!=t.T()))if(t.l&&4==Zn(t))se(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==Zn(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.A).match(Je)[1]||null;if(!o&&N.self&&N.self.location){var s=N.self.location.protocol;o=s.substr(0,s.length-1)}i=!Xn.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var a=2<Zn(t)?t.a.statusText:""}catch(t){a=""}t.f=a+" ["+t.T()+"]",Kn(t)}}finally{Jn(t)}}}function Jn(t,e){if(t.a){$n(t);var n=t.a,r=t.s[0]?R:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function $n(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(N.clearTimeout(t.m),t.m=null)}function Zn(t){return t.a?t.a.readyState:0}function tr(t,e){return t.a?t.a.getResponseHeader(e):null}function er(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;if(n=function(t){var n="";return tt(t,function(t,e){n+=e,n+=":",n+=t,n+="\r\n"}),n}(n),S(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if((n=t.indexOf("#"))<0&&(n=t.length),(r=t.indexOf("?"))<0||n<r){r=n;var i=""}else i=t.substring(r+1,n);n=(t=[t.substr(0,r),i,t.substr(n)])[1],t[1]=e?n?n+"&"+e:e:n,t=t[0]+(t[1]?"?"+t[1]:"")+t[2]}return t}return on(t,e,n),t}function nr(t){this.f=[],this.F=new Nn,this.ga=this.pa=this.B=this.ha=this.a=this.I=this.j=this.V=this.g=this.J=this.i=null,this.Qa=this.P=0,this.Oa=!!k("internalChannelParams.failFast",t),this.ia=this.w=this.s=this.l=this.h=this.c=null,this.oa=!0,this.m=this.ra=this.O=-1,this.S=this.v=this.A=0,this.Na=k("internalChannelParams.baseRetryDelayMs",t)||5e3,this.Ra=k("internalChannelParams.retryDelaySeedMs",t)||1e4,this.Pa=k("internalChannelParams.forwardChannelMaxRetries",t)||2,this.qa=k("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.Ka=t&&t.zb||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new Rn(t&&t.concurrentRequestLimit),this.ja=new Vn,this.o=!t||void 0===t.backgroundChannelTest||t.backgroundChannelTest,(this.W=t&&t.fastHandshake||!1)&&!this.o&&(this.o=!0),t&&t.forceLongPolling&&(this.oa=!1),this.fa=void 0}function rr(t){if(ir(t),3==t.u){var e=t.P++,n=Ze(t.B);on(n,"SID",t.H),on(n,"RID",e),on(n,"TYPE","terminate"),ur(t,n),(e=new Ce(t,e,void 0)).F=2,e.f=an(Ze(n)),n=!1,N.navigator&&N.navigator.sendBeacon&&(n=N.navigator.sendBeacon(e.f.toString(),"")),!n&&N.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=j(),je(e)}vr(t)}function ir(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(N.clearTimeout(t.l),t.l=null),pr(t),t.b.cancel(),t.h&&(D(t.h)&&N.clearTimeout(t.h),t.h=null)}function or(t,e){t.f.push(new kn(t.Qa++,e)),3==t.u&&sr(t)}function sr(t){xn(t.b)||t.h||(t.h=!0,te(t.Ha,t),t.A=0)}function ar(t,e){var n;n=e?e.W:t.P++;var r=Ze(t.B);on(r,"SID",t.H),on(r,"RID",n),on(r,"AID",t.O),ur(t,r),t.g&&t.i&&er(r,t.g,t.i),n=new Ce(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=hr(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),Ln(t.b,n),Le(n,r,e)}function ur(t,n){t.c&&We({},function(t,e){on(n,e,t)})}function hr(t,e,n){n=Math.min(t.f.length,n);var r=t.c?U(t.c.Sa,t.c,t):null;t:for(var i=t.f,o=-1;;){var s=["count="+n];-1==o?0<n?(o=i[0].b,s.push("ofs="+o)):o=0:s.push("ofs="+o);for(var a=!0,u=0;u<n;u++){var h=i[u].b,c=i[u].a;if((h-=o)<0)o=Math.max(0,i[u].b-100),a=!1;else try{jn(c,s,"req"+h+"_")}catch(t){r&&r(c)}}if(a){r=s.join("&");break t}}return t=t.f.splice(0,n),e.j=t,r}function cr(t){t.a||t.l||(t.S=1,te(t.Ga,t),t.v=0)}function fr(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=be(U(t.Ga,t),dr(t,t.v)),t.v++,!0)}function lr(t,e,n){var r=e.l;r&&Cn(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=mr(t,null,t.ha),sr(t)}function pr(t){null!=t.s&&(N.clearTimeout(t.s),t.s=null)}function dr(t,e){var n=t.Na+Math.floor(Math.random()*t.Ra);return t.ma()||(n*=2),n*e}function yr(t,e){if(2==e){var n=null;t.c&&(n=null);var r=U(t.eb,t);n||(n=new $e("//www.google.com/images/cleardot.gif"),N.location&&"http"==N.location.protocol||tn(n,"https"),an(n)),function(t,e){var n=new pe;if(N.Image){var r=new Image;r.onload=V(Fn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=V(Fn,n,r,"TestLoadImage: error",!1,e),r.onabort=V(Fn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=V(Fn,n,r,"TestLoadImage: timeout",!1,e),N.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}else e(!1)}(n.toString(),r)}else ge(2);t.u=0,t.c&&t.c.ta(e),vr(t),ir(t)}function vr(t){t.u=0,t.m=-1,t.c&&(0==Mn(t.b).length&&0==t.f.length||(t.b.c.length=0,W(t.f),t.f.length=0),t.c.sa())}function mr(t,e,n){var r=function(t){return t instanceof $e?Ze(t):new $e(t,void 0)}(n);if(""!=r.b)e&&en(r,e+"."+r.b),nn(r,r.i);else{var i,o=N.location;i=e?e+"."+o.hostname:o.hostname,r=function(t,e,n,r){var i=new $e(null,void 0);return t&&tn(i,t),e&&en(i,e),n&&nn(i,n),r&&(i.a=r),i}(o.protocol,i,+o.port,n)}return t.V&&tt(t.V,function(t,e){on(r,e,t)}),e=t.j,n=t.I,e&&n&&on(r,e,n),on(r,"VER",t.wa),ur(t,r),r}function gr(){}function wr(){if(ut&&!(10<=Number(mt)))throw Error("Environmental error: no available transport.")}function br(t,e){Xt.call(this),this.a=new nr(e),this.g=t,this.m=e&&e.testUrl?e.testUrl:function(t){for(var e=t,n=1;n<arguments.length;n++){var r,i=arguments[n];if(0==i.lastIndexOf("/",0))e=i;else(r=""==e)||(r=0<=(r=e.length-1)&&e.indexOf("/",r)==r),e+=r?i:"/"+i}return e}(this.g,"test"),this.b=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.a.i=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.xa&&(t?t["X-WebChannel-Client-Profile"]=e.xa:t={"X-WebChannel-Client-Profile":e.xa}),this.a.J=t,(t=e&&e.httpHeadersOverwriteParam)&&!H(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!H(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new Tr(this)}function Er(t){ke.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.c=t)?(t=this.c,this.data=null!==e&&t in e?e[t]:void 0):this.data=e}else this.data=t}function Ir(){Re.call(this),this.status=1}function Tr(t){this.a=t}(I=Bn.prototype).ca=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.A+"; newUri="+t);e=e?e.toUpperCase():"GET",this.A=t,this.f="",this.h=0,this.v=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?Ae(this.H):Ae(Se),this.a.onreadystatechange=U(this.Ea,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void Yn(this,t)}t=n||"";var i=new He(this.headers);r&&We(r,function(t,e){i.set(e,t)}),r=function(t){t:{for(var e=Hn,n=t.length,r=S(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return e<0?null:S(t)?t.charAt(e):t[e]}(i.K()),n=N.FormData&&t instanceof N.FormData,0<=B(Wn,e)&&!r&&!n&&i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(t,e){this.a.setRequestHeader(e,t)},this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{$n(this),0<this.o&&((this.D=function(t){return ut&&wt(9)&&D(t.timeout)&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=U(this.Ba,this)):this.m=se(this.Ba,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){Yn(this,t)}},I.Ba=function(){void 0!==A&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},I.abort=function(t){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=t||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),Jn(this))},I.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Jn(this,!0)),Bn.N.G.call(this)},I.Ea=function(){this.j||(this.w||this.l||this.g?Qn(this):this.Za())},I.Za=function(){Qn(this)},I.T=function(){try{return 2<Zn(this)?this.a.status:-1}catch(t){return-1}},I.aa=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},I.Ua=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Gn(e)}},I.ya=function(){return this.h},I.Xa=function(){return S(this.f)?this.f:String(this.f)},(I=nr.prototype).wa=8,I.u=1,I.Ca=function(){return 0==this.u},I.Ha=function(t){if(this.h)if(this.h=null,1==this.u){if(!t){this.P=Math.floor(1e5*Math.random()),t=this.P++;var e,n=new Ce(this,t,void 0),r=this.i;if(this.J&&(r?rt(r=et(r),this.J):r=this.J),null===this.g&&(n.h=r),this.W)t:{for(var i=e=0;i<this.f.length;i++){var o=this.f[i];if(void 0===(o="__data__"in o.a&&S(o=o.a.__data__)?o.length:void 0))break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.f.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=hr(this,n,e),on(i=Ze(this.B),"RID",t),on(i,"CVER",22),this.o&&this.j&&on(i,"X-HTTP-Session-Id",this.j),ur(this,i),this.g&&r&&er(i,this.g,r),Ln(this.b,n),this.W?(on(i,"$req",e),on(i,"SID","null"),n.S=!0,Le(n,i,null)):Le(n,i,e),this.u=2}}else 3==this.u&&(t?ar(this,t):0==this.f.length||xn(this.b)||ar(this))},I.Ga=function(){this.l=null,this.a=new Ce(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=Ze(this.pa);on(t,"RID","rpc"),on(t,"SID",this.H),on(t,"CI",this.ia?"0":"1"),on(t,"AID",this.O),ur(this,t),on(t,"TYPE","xmlhttp"),this.g&&this.i&&er(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),qe(this.a,t,!0,this.ga)},I.Fa=function(t,e){if(0!=this.u&&(this.a==t||On(this.b,t)))if(this.m=t.o,!t.s&&On(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(t){n=null}if(C(n)&&3==n.length){if(0==(e=n)[0]){t:if(!this.l){if(this.a){if(!(this.a.v+3e3<t.v))break t;pr(this),this.a.cancel(),this.a=null}fr(this),ge(18)}}else this.ra=e[1],0<this.ra-this.O&&e[2]<37500&&this.ia&&0==this.v&&!this.s&&(this.s=be(U(this.Ya,this),6e3));if(Pn(this.b)<=1&&this.fa){try{this.fa()}catch(t){}this.fa=void 0}}else yr(this,11)}else if(!t.s&&this.a!=t||pr(this),!H(e))for(e=n=this.ja.a.parse(e),n=0;n<e.length;n++){var r=e[n];if(this.O=r[0],r=r[1],2==this.u)if("c"==r[0]){this.H=r[1],this.ga=r[2];var i=r[3];null!=i&&(this.wa=i),null!=(r=r[5])&&D(r)&&0<r&&(this.D=1.5*r),this.o&&(r=t.a)&&((i=tr(r,"X-Client-Wire-Protocol"))&&Cn(this.b,i),this.j&&(r=tr(r,"X-HTTP-Session-Id")))&&(this.I=r,on(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=mr(this,this.Y()?this.ga:null,this.ha),r.s?(qn(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(Ge(r),je(r)),this.a=r):cr(this),0<this.f.length&&sr(this)}else"stop"!=r[0]&&"close"!=r[0]||yr(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?yr(this,7):rr(this):"noop"!=r[0]&&this.c&&this.c.ua(r),this.v=0)}},I.Ya=function(){null!=this.s&&(this.s=null,this.a.cancel(),this.a=null,fr(this),ge(19))},I.na=function(t){var e=null;if(this.a==t){pr(this),this.a=null;var n=2}else{if(!On(this.b,t))return;e=t.j,qn(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=j()-t.v,de.dispatchEvent(new we(de,t.l?t.l.length:0,e,this.A)),sr(this)):cr(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){return!(Pn(t.b)>=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa))&&(t.h=be(U(t.Ha,t,e),dr(t,t.A)),t.A++,!0))}(this,t)||2==n&&fr(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:yr(this,5);break;case 4:yr(this,10);break;case 3:yr(this,6);break;default:yr(this,2)}}},I.eb=function(t){ge(t?2:1)},I.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new Bn(this.Ka)).F=this.R,t},I.ma=function(){return!!this.c&&!0},I.Y=function(){return this.R},(I=gr.prototype).va=function(){},I.ua=function(){},I.ta=function(){},I.sa=function(){},I.Sa=function(){},wr.prototype.a=function(t,e){return new br(t,e)},F(br,Xt),(I=br.prototype).addEventListener=function(t,e,n,r){br.N.addEventListener.call(this,t,e,n,r)},I.removeEventListener=function(t,e,n,r){br.N.removeEventListener.call(this,t,e,n,r)},I.Va=function(){this.a.c=this.f,this.l&&(this.a.R=!0);var t=this.a,e=this.m,n=this.g,r=this.b||void 0;ge(0),t.ha=n,t.V=r||{},t.o&&(t.F.b=[],t.F.a=!1),t.w=new Tn(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=er(e,t.g,t.i)),(t=t.w).i=n,e=mr(t.a,null,t.i),ge(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,An(t)):(sn(e,"MODE","init"),!t.a.o&&t.a.j&&sn(e,"X-HTTP-Session-Id",t.a.j),t.b=new Ce(t,void 0,void 0),t.b.h=t.h,qe(t.b,e,!1,null),t.M=0)},I.close=function(){rr(this.a)},I.Wa=function(t){if(S(t)){var e={};e.__data__=t,or(this.a,e)}else this.h?((e={}).__data__=Ht(t),or(this.a,e)):or(this.a,t)},I.G=function(){this.a.c=null,delete this.f,rr(this.a),delete this.a,br.N.G.call(this)},F(Er,ke),F(Ir,Re),F(Tr,gr),Tr.prototype.va=function(){this.a.dispatchEvent("a")},Tr.prototype.ua=function(t){this.a.dispatchEvent(new Er(t))},Tr.prototype.ta=function(t){this.a.dispatchEvent(new Ir(t))},Tr.prototype.sa=function(){this.a.dispatchEvent("b")};var Ar=V(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},wr);wr.prototype.createWebChannel=wr.prototype.a,br.prototype.send=br.prototype.Wa,br.prototype.open=br.prototype.Va,br.prototype.close=br.prototype.close,Ee.NO_ERROR=0,Ee.TIMEOUT=8,Ee.HTTP_ERROR=6,Ie.COMPLETE="complete",(Ne.EventType=De).OPEN="a",De.CLOSE="b",De.ERROR="c",De.MESSAGE="d",Xt.prototype.listen=Xt.prototype.za,Bn.prototype.listenOnce=Bn.prototype.Aa,Bn.prototype.getLastError=Bn.prototype.Xa,Bn.prototype.getLastErrorCode=Bn.prototype.ya,Bn.prototype.getStatus=Bn.prototype.T,Bn.prototype.getResponseJson=Bn.prototype.Ua,Bn.prototype.getResponseText=Bn.prototype.aa,Bn.prototype.send=Bn.prototype.ca;var Nr,Sr,Dr={createWebChannelTransport:Ar,ErrorCode:Ee,EventType:Ie,WebChannel:Ne,XhrIo:Bn},kr=Dr.createWebChannelTransport,Rr=Dr.ErrorCode,_r=Dr.EventType,Cr=Dr.WebChannel,xr=Dr.XhrIo,Pr=Bd.SDK_VERSION,Or=new u("@firebase/firestore");function Lr(){return Or.logLevel===o.DEBUG?Nr.DEBUG:Or.logLevel===o.SILENT?Nr.SILENT:Nr.ERROR}function qr(t){switch(t){case Nr.DEBUG:Or.logLevel=o.DEBUG;break;case Nr.ERROR:Or.logLevel=o.ERROR;break;case Nr.SILENT:Or.logLevel=o.SILENT;break;default:Or.error("Firestore ("+Pr+"): Invalid value passed to `setLogLevel`")}}function Mr(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(Or.logLevel<=o.DEBUG){var i=n.map(Vr);Or.debug.apply(Or,s(["Firestore ("+Pr+") ["+t+"]: "+e],i))}}function Ur(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Or.logLevel<=o.ERROR){var r=e.map(Vr);Or.error.apply(Or,s(["Firestore ("+Pr+"): "+t],r))}}function Vr(t){if("string"==typeof t)return t;var e=Fu.t();try{return e.i(t)}catch(e){return t}}function jr(t){var e="FIRESTORE ("+Pr+") INTERNAL ASSERTION FAILED: "+t;throw Ur(e),new Error(e)}function Fr(t,e){t||jr(e)}(Sr=Nr=Nr||{})[Sr.DEBUG=0]="DEBUG",Sr[Sr.ERROR=1]="ERROR",Sr[Sr.SILENT=2]="SILENT";var Gr=(Br.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return Fr(20===e.length,"Invalid auto ID: "+e),e},Br);function Br(){}function zr(t,e){return t<e?-1:e<t?1:0}function Xr(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].isEqual(e[n]))return!1;return!0}function Wr(t){return t+"\0"}function Hr(t,e,n,r,i){this.s=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i}var Yr,Kr,Qr,Jr,$r="(default)",Zr=(Object.defineProperty(ti.prototype,"o",{get:function(){return this.database===$r},enumerable:!0,configurable:!0}),ti.prototype.isEqual=function(t){return t instanceof ti&&t.projectId===this.projectId&&t.database===this.database},ti.prototype.h=function(t){return zr(this.projectId,t.projectId)||zr(this.database,t.database)},ti);function ti(t,e){this.projectId=t,this.database=e||$r}(Kr=Yr=Yr||{})[Kr.l=0]="__PRIVATE_Unknown",Kr[Kr.v=1]="__PRIVATE_Online",Kr[Kr.m=2]="__PRIVATE_Offline",(Jr=Qr=Qr||{})[Jr.p=0]="__PRIVATE_RemoteStore",Jr[Jr.g=1]="__PRIVATE_SharedClientState";function ei(t,e){this.user=e,this.type="OAuth",this.A={},this.A.Authorization="Bearer "+t}var ni,ri=(yi.prototype._=function(){return null!=this.uid},yi.prototype.I=function(){return this._()?"uid:"+this.uid:"anonymous-user"},yi.prototype.isEqual=function(t){return t.uid===this.uid},yi.UNAUTHENTICATED=new yi(null),yi.T=new yi("google-credentials-uid"),yi.R=new yi("first-party-uid"),yi),ii={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"},oi=(t(di,ni=Error),di),si=(pi.prototype.getToken=function(){return Promise.resolve(null)},pi.prototype.P=function(){},pi.prototype.S=function(t){Fr(!this.D,"Can only call setChangeListener() once."),(this.D=t)(ri.UNAUTHENTICATED)},pi.prototype.C=function(){Fr(null!==this.D,"removeChangeListener() when no listener registered"),this.D=null},pi),ai=(li.prototype.getToken=function(){var e=this;Fr(null!=this.V,"getToken cannot be called after listener removed.");var n=this.N,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.N!==n)throw new oi(ii.ABORTED,"getToken aborted due to token change.");return t?(Fr("string"==typeof t.accessToken,"Invalid tokenData returned from getToken():"+t),new ei(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},li.prototype.P=function(){this.forceRefresh=!0},li.prototype.S=function(t){Fr(!this.D,"Can only call setChangeListener() once."),this.D=t,this.k&&t(this.currentUser)},li.prototype.C=function(){Fr(null!=this.V,"removeChangeListener() called twice"),Fr(null!==this.D,"removeChangeListener() called when no listener registered"),this.auth&&this.auth.removeAuthTokenListener(this.V),this.V=null,this.D=null},li.prototype.O=function(){var t=this.auth&&this.auth.getUid();return Fr(null===t||"string"==typeof t,"Received invalid UID: "+t),new ri(t)},li),ui=(Object.defineProperty(fi.prototype,"A",{get:function(){var t={"X-Goog-AuthUser":this.j},e=this.F.auth.U([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),fi),hi=(ci.prototype.getToken=function(){return Promise.resolve(new ui(this.F,this.j))},ci.prototype.S=function(t){t(ri.R)},ci.prototype.C=function(){},ci.prototype.P=function(){},ci);function ci(t,e){this.F=t,this.j=e}function fi(t,e){this.F=t,this.j=e,this.type="FirstParty",this.user=ri.R}function li(t){var e=this;this.V=null,this.currentUser=ri.UNAUTHENTICATED,this.k=!1,this.N=0,this.D=null,this.forceRefresh=!1,this.V=function(){e.N++,e.currentUser=e.O(),e.k=!0,e.D&&e.D(e.currentUser)},this.N=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.V):(this.V(null),t.get().then(function(t){e.auth=t,e.V&&e.auth.addAuthTokenListener(e.V)},function(){}))}function pi(){this.D=null}function di(t,e){var n=ni.call(this,e)||this;return n.code=t,n.message=e,n.name="FirebaseError",n.toString=function(){return n.name+": [code="+n.code+"]: "+n.message},n}function yi(t){this.uid=t}function vi(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function mi(t,e){return void 0!==t?t:e}function gi(t,e){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Number(n);isNaN(r)||e(r,t[n])}}function wi(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function bi(t){for(var e in Fr(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Ei(t,e){if(0!==e.length)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Ui(e.length,"argument")+".")}function Ii(t,e,n){if(e.length!==n)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires "+Ui(n,"argument")+", but was called with "+Ui(e.length,"argument")+".")}function Ti(t,e,n){if(e.length<n)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Ui(n,"argument")+", but was called with "+Ui(e.length,"argument")+".")}function Ai(t,e,n,r){if(e.length<n||e.length>r)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Ui(e.length,"argument")+".")}function Ni(t,e,n,r){_i(t,e,Mi(n)+" argument",r)}function Si(t,e,n,r){void 0!==r&&Ni(t,e,n,r)}function Di(t,e,n,r){_i(t,e,n+" option",r)}function ki(t,e,n,r){void 0!==r&&Di(t,e,n,r)}function Ri(t,e,n,r,h){void 0!==r&&function(t,e,n,r){for(var i=[],o=0,s=h;o<s.length;o++){var a=s[o];if(a===r)return;i.push(xi(a))}var u=xi(r);throw new oi(ii.INVALID_ARGUMENT,"Invalid value "+u+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+i.join(", "))}(t,0,n,r)}function _i(t,e,n,r){if(!("object"===e?Ci(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=xi(r);throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function Ci(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function xi(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return 20<t.length&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"!=typeof t)return"function"==typeof t?"a function":jr("Unknown wrong type: "+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&&1<e.length)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}function Pi(t,e,n){if(void 0===n)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+Mi(e)+" argument, but it was undefined.")}function Oi(n,t,r){wi(t,function(t,e){if(r.indexOf(t)<0)throw new oi(ii.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function Li(t,e,n,r){var i=xi(r);return new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires its "+Mi(n)+" argument to be a "+e+", but it was: "+i)}function qi(t,e,n){if(n<=0)throw new oi(ii.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+Mi(e)+" argument to be a positive number, but it was: "+n+".")}function Mi(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Ui(t,e){return t+" "+e+(1===t?"":"s")}var Vi,ji,Fi=(Object.defineProperty(ho.prototype,"latitude",{get:function(){return this.B},enumerable:!0,configurable:!0}),Object.defineProperty(ho.prototype,"longitude",{get:function(){return this.M},enumerable:!0,configurable:!0}),ho.prototype.isEqual=function(t){return this.B===t.B&&this.M===t.M},ho.prototype.q=function(t){return zr(this.B,t.B)||zr(this.M,t.M)},ho),Gi=(uo.now=function(){return uo.fromMillis(Date.now())},uo.fromDate=function(t){return uo.fromMillis(t.getTime())},uo.fromMillis=function(t){var e=Math.floor(t/1e3);return new uo(e,1e6*(t-1e3*e))},uo.prototype.toDate=function(){return new Date(this.toMillis())},uo.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},uo.prototype.q=function(t){return this.seconds===t.seconds?zr(this.nanoseconds,t.nanoseconds):zr(this.seconds,t.seconds)},uo.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},uo.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},uo),Bi=(ao.G=function(t){var e=Math.floor(t/1e6);return new ao(new Gi(e,t%1e6*1e3))},ao.W=function(t){return new ao(t)},ao.K=function(){return ao.MIN},ao.prototype.h=function(t){return this.timestamp.q(t.timestamp)},ao.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},ao.prototype.H=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},ao.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},ao.prototype.J=function(){return this.timestamp},ao.MIN=new ao(new Gi(0,0)),ao),zi=(Object.defineProperty(so.prototype,"length",{get:function(){return this.Y},enumerable:!0,configurable:!0}),so.prototype.isEqual=function(t){return 0===so.X(this,t)},so.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof so?t.forEach(function(t){e.push(t)}):e.push(t),this.$(e)},so.prototype.limit=function(){return this.offset+this.length},so.prototype.Z=function(t){return t=void 0===t?1:t,Fr(this.length>=t,"Can't call popFirst() with less segments"),this.$(this.segments,this.offset+t,this.length-t)},so.prototype.tt=function(){return Fr(!this.nt(),"Can't call popLast() on empty path"),this.$(this.segments,this.offset,this.length-1)},so.prototype.it=function(){return Fr(!this.nt(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},so.prototype.et=function(){return this.get(this.length-1)},so.prototype.get=function(t){return Fr(t<this.length,"Index out of range"),this.segments[this.offset+t]},so.prototype.nt=function(){return 0===this.length},so.prototype.rt=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},so.prototype.ut=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},so.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},so.prototype.st=function(){return this.segments.slice(this.offset,this.limit())},so.X=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(o<i)return 1}return t.length<e.length?-1:t.length>e.length?1:0},so),Xi=(t(oo,ji=zi),oo.prototype.$=function(t,e,n){return new oo(t,e,n)},oo.prototype.ot=function(){return this.st().join("/")},oo.prototype.toString=function(){return this.ot()},oo.ht=function(t){if(0<=t.indexOf("//"))throw new oi(ii.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new oo(t.split("/").filter(function(t){return 0<t.length}))},oo.ct=new oo([]),oo),Wi=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Hi=(t(io,Vi=zi),io.prototype.$=function(t,e,n){return new io(t,e,n)},io.at=function(t){return Wi.test(t)},io.prototype.ot=function(){return this.st().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),io.at(t)||(t="`"+t+"`"),t}).join(".")},io.prototype.toString=function(){return this.ot()},io.prototype.ft=function(){return 1===this.length&&"__name__"===this.get(0)},io.lt=function(){return new io(["__name__"])},io.dt=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new oi(ii.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");e.push(n),n=""},o=!1;r<t.length;){var s=t[r];if("\\"===s){if(r+1===t.length)throw new oi(ii.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[r+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new oi(ii.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=a,r+=2}else"`"===s?o=!o:"."!==s||o?n+=s:i(),r++}if(i(),o)throw new oi(ii.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new io(e)},io.ct=new io([]),io),Yi=(ro.prototype.wt=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},ro.prototype.isEqual=function(t){return null!==t&&0===Xi.X(this.path,t.path)},ro.prototype.toString=function(){return this.path.toString()},ro.X=function(t,e){return Xi.X(t.path,e.path)},ro.vt=function(t){return t.length%2==0},ro.pt=function(t){return new ro(new Xi(t.slice()))},ro.gt=function(t){return new ro(Xi.ht(t))},ro.EMPTY=new ro(new Xi([])),ro),Ki=(no.prototype.bt=function(t,e){return new no(this.X,this.root.bt(t,e,this.X).yt(null,null,Ji._t,null,null))},no.prototype.remove=function(t){return new no(this.X,this.root.remove(t,this.X).yt(null,null,Ji._t,null,null))},no.prototype.get=function(t){for(var e=this.root;!e.nt();){var n=this.X(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},no.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.nt();){var r=this.X(t,n.key);if(0===r)return e+n.left.size;n=r<0?n.left:(e+=n.left.size+1,n.right)}return-1},no.prototype.nt=function(){return this.root.nt()},Object.defineProperty(no.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),no.prototype.It=function(){return this.root.It()},no.prototype.Tt=function(){return this.root.Tt()},no.prototype.Et=function(t){return this.root.Et(t)},no.prototype.forEach=function(n){this.Et(function(t,e){return n(t,e),!1})},no.prototype.toString=function(){var n=[];return this.Et(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},no.prototype.Rt=function(t){return this.root.Rt(t)},no.prototype.At=function(){return new Qi(this.root,null,this.X,!1)},no.prototype.Dt=function(t){return new Qi(this.root,t,this.X,!1)},no.prototype.Pt=function(){return new Qi(this.root,null,this.X,!0)},no.prototype.St=function(t){return new Qi(this.root,t,this.X,!0)},no),Qi=(eo.prototype.kt=function(){Fr(0<this.Vt.length,"getNext() called on iterator when hasNext() is false.");var t=this.Vt.pop(),e={key:t.key,value:t.value};if(this.Ct)for(t=t.left;!t.nt();)this.Vt.push(t),t=t.right;else for(t=t.right;!t.nt();)this.Vt.push(t),t=t.left;return e},eo.prototype.Nt=function(){return 0<this.Vt.length},eo.prototype.Ot=function(){if(0===this.Vt.length)return null;var t=this.Vt[this.Vt.length-1];return{key:t.key,value:t.value}},eo),Ji=(to.prototype.yt=function(t,e,n,r,i){return new to(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)},to.prototype.nt=function(){return!1},to.prototype.Et=function(t){return this.left.Et(t)||t(this.key,this.value)||this.right.Et(t)},to.prototype.Rt=function(t){return this.right.Rt(t)||t(this.key,this.value)||this.left.Rt(t)},to.prototype.min=function(){return this.left.nt()?this:this.left.min()},to.prototype.It=function(){return this.min().key},to.prototype.Tt=function(){return this.right.nt()?this.key:this.right.Tt()},to.prototype.bt=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.yt(null,null,null,r.left.bt(t,e,n),null):0===i?r.yt(null,e,null,null,null):r.yt(null,null,null,null,r.right.bt(t,e,n))).Ft()},to.prototype.xt=function(){if(this.left.nt())return to.EMPTY;var t=this;return t.left.jt()||t.left.left.jt()||(t=t.Ut()),(t=t.yt(null,null,null,t.left.xt(),null)).Ft()},to.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.nt()||r.left.jt()||r.left.left.jt()||(r=r.Ut()),r=r.yt(null,null,null,r.left.remove(t,e),null);else{if(r.left.jt()&&(r=r.Lt()),r.right.nt()||r.right.jt()||r.right.left.jt()||(r=r.Bt()),0===e(t,r.key)){if(r.right.nt())return to.EMPTY;n=r.right.min(),r=r.yt(n.key,n.value,null,null,r.right.xt())}r=r.yt(null,null,null,null,r.right.remove(t,e))}return r.Ft()},to.prototype.jt=function(){return this.color},to.prototype.Ft=function(){var t=this;return t.right.jt()&&!t.left.jt()&&(t=t.Mt()),t.left.jt()&&t.left.left.jt()&&(t=t.Lt()),t.left.jt()&&t.right.jt()&&(t=t.qt()),t},to.prototype.Ut=function(){var t=this.qt();return t.right.left.jt()&&(t=(t=(t=t.yt(null,null,null,null,t.right.Lt())).Mt()).qt()),t},to.prototype.Bt=function(){var t=this.qt();return t.left.left.jt()&&(t=(t=t.Lt()).qt()),t},to.prototype.Mt=function(){var t=this.yt(null,null,to.RED,null,this.right.left);return this.right.yt(null,null,this.color,t,null)},to.prototype.Lt=function(){var t=this.yt(null,null,to.RED,this.left.right,null);return this.left.yt(null,null,this.color,null,t)},to.prototype.qt=function(){var t=this.left.yt(null,null,!this.left.color,null,null),e=this.right.yt(null,null,!this.right.color,null,null);return this.yt(null,null,!this.color,t,e)},to.prototype.Qt=function(){var t=this.Gt();return Math.pow(2,t)<=this.size+1},to.prototype.Gt=function(){if(this.jt()&&this.left.jt())throw jr("Red node has red child("+this.key+","+this.value+")");if(this.right.jt())throw jr("Right child of ("+this.key+","+this.value+") is red");var t=this.left.Gt();if(t!==this.right.Gt())throw jr("Black depths differ");return t+(this.jt()?0:1)},to.EMPTY=null,to.RED=!0,to._t=!1,to),$i=(Object.defineProperty(Zi.prototype,"key",{get:function(){throw jr("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(Zi.prototype,"value",{get:function(){throw jr("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(Zi.prototype,"color",{get:function(){throw jr("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(Zi.prototype,"left",{get:function(){throw jr("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(Zi.prototype,"right",{get:function(){throw jr("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),Zi.prototype.yt=function(t,e,n,r,i){return this},Zi.prototype.bt=function(t,e,n){return new Ji(t,e)},Zi.prototype.remove=function(t,e){return this},Zi.prototype.nt=function(){return!0},Zi.prototype.Et=function(t){return!1},Zi.prototype.Rt=function(t){return!1},Zi.prototype.It=function(){return null},Zi.prototype.Tt=function(){return null},Zi.prototype.jt=function(){return!1},Zi.prototype.Qt=function(){return!0},Zi.prototype.Gt=function(){return 0},Zi);function Zi(){this.size=0}function to(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:to.RED,this.left=null!=r?r:to.EMPTY,this.right=null!=i?i:to.EMPTY,this.size=this.left.size+1+this.right.size}function eo(t,e,n,r){this.Ct=r,this.Vt=[];for(var i=1;!t.nt();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.Ct?t.left:t.right;else{if(0===i){this.Vt.push(t);break}this.Vt.push(t),t=this.Ct?t.right:t.left}}function no(t,e){this.X=t,this.root=e||Ji.EMPTY}function ro(t){this.path=t,Fr(ro.vt(t),"Invalid DocumentKey with an odd number of segments: "+t.st().join("/"))}function io(){return null!==Vi&&Vi.apply(this,arguments)||this}function oo(){return null!==ji&&ji.apply(this,arguments)||this}function so(t,e,n){void 0===e?e=0:e>t.length&&jr("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&jr("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.Y=n}function ao(t){this.timestamp=t}function uo(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new oi(ii.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new oi(ii.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new oi(ii.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new oi(ii.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function ho(t,e){if(Ii("GeoPoint",arguments,2),Ni("GeoPoint","number",1,t),Ni("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new oi(ii.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new oi(ii.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.B=t,this.M=e}Ji.EMPTY=new $i;var co=(Io.Wt=function(t){var e=new Io(t.X);return t.forEach(function(t){e=e.add(t)}),e},Io.prototype.has=function(t){return null!==this.data.get(t)},Io.prototype.first=function(){return this.data.It()},Io.prototype.last=function(){return this.data.Tt()},Object.defineProperty(Io.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),Io.prototype.indexOf=function(t){return this.data.indexOf(t)},Io.prototype.forEach=function(n){this.data.Et(function(t,e){return n(t),!1})},Io.prototype.zt=function(t,e){for(var n=this.data.Dt(t[0]);n.Nt();){var r=n.kt();if(0<=this.X(r.key,t[1]))return;e(r.key)}},Io.prototype.Kt=function(t,e){var n;for(n=void 0!==e?this.data.Dt(e):this.data.At();n.Nt();)if(!t(n.kt().key))return},Io.prototype.Ht=function(t){var e=this.data.Dt(t);return e.Nt()?e.kt().key:null},Io.prototype.At=function(){return new fo(this.data.At())},Io.prototype.Dt=function(t){return new fo(this.data.Dt(t))},Io.prototype.add=function(t){return this.yt(this.data.remove(t).bt(t,!0))},Io.prototype.delete=function(t){return this.has(t)?this.yt(this.data.remove(t)):this},Io.prototype.nt=function(){return this.data.nt()},Io.prototype.Jt=function(t){var e=this;return t.forEach(function(t){e=e.add(t)}),e},Io.prototype.isEqual=function(t){if(!(t instanceof Io))return!1;if(this.size!==t.size)return!1;for(var e=this.data.At(),n=t.data.At();e.Nt();){var r=e.kt().key,i=n.kt().key;if(0!==this.X(r,i))return!1}return!0},Io.prototype.st=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},Io.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},Io.prototype.yt=function(t){var e=new Io(this.X);return e.data=t,e},Io),fo=(Eo.prototype.kt=function(){return this.Yt.kt().key},Eo.prototype.Nt=function(){return this.Yt.Nt()},Eo),lo=(bo.prototype.Xt=function(t,e){return new Cs(e,t)},bo.prototype.$t=function(t,e){return e},bo.prototype.Zt=function(t){return null},bo.prototype.isEqual=function(t){return t instanceof bo},bo.instance=new bo,bo),po=(wo.prototype.Xt=function(t,e){return this.apply(t)},wo.prototype.$t=function(t,e){return this.apply(t)},wo.prototype.apply=function(t){for(var n=To(t),e=function(e){n.find(function(t){return t.isEqual(e)})||n.push(e)},r=0,i=this.elements;r<i.length;r++)e(i[r]);return new qs(n)},wo.prototype.Zt=function(t){return null},wo.prototype.isEqual=function(t){return t instanceof wo&&Xr(t.elements,this.elements)},wo),yo=(go.prototype.Xt=function(t,e){return this.apply(t)},go.prototype.$t=function(t,e){return this.apply(t)},go.prototype.apply=function(t){for(var n=To(t),e=function(e){n=n.filter(function(t){return!t.isEqual(e)})},r=0,i=this.elements;r<i.length;r++)e(i[r]);return new qs(n)},go.prototype.Zt=function(t){return null},go.prototype.isEqual=function(t){return t instanceof go&&Xr(t.elements,this.elements)},go),vo=(mo.prototype.Xt=function(t,e){var n=this.Zt(t);if(n instanceof Ds&&this.tn instanceof Ds){var r=n.nn+this.tn.nn;return new Ds(r)}return r=n.nn+this.tn.nn,new ks(r)},mo.prototype.$t=function(t,e){return Fr(null!==e,"Didn't receive transformResult for NUMERIC_ADD transform"),e},mo.prototype.Zt=function(t){return t instanceof as?t:new Ds(0)},mo.prototype.isEqual=function(t){return t instanceof mo&&this.tn.isEqual(t.tn)},mo);function mo(t){this.tn=t}function go(t){this.elements=t}function wo(t){this.elements=t}function bo(){}function Eo(t){this.Yt=t}function Io(t){this.X=t,this.data=new Ki(this.X)}function To(t){return t instanceof qs?t.nn.slice():[]}function Ao(t,e){this.version=t,this.transformResults=e}var No,So,Do=(_o.in=function(t){return new _o(t)},_o.en=function(t){var e=new co(Hi.X);return t.forEach(function(t){return e=e.add(t)}),new _o(e)},_o.prototype.rn=function(e){var n=!1;return this.fields.forEach(function(t){t.rt(e)&&(n=!0)}),n},_o.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},_o),ko=(Ro.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},Ro);function Ro(t,e){this.field=t,this.transform=e}function _o(t){this.fields=t}(So=No=No||{})[So.Set=0]="Set",So[So.un=1]="__PRIVATE_Patch",So[So.sn=2]="__PRIVATE_Transform",So[So.on=3]="__PRIVATE_Delete",So[So.hn=4]="__PRIVATE_Verify";var Co,xo,Po,Oo,Lo,qo,Mo,Uo,Vo,jo=(Zo.exists=function(t){return new Zo(void 0,t)},Zo.updateTime=function(t){return new Zo(t)},Object.defineProperty(Zo.prototype,"cn",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),Zo.prototype.an=function(t){return void 0!==this.updateTime?t instanceof Us&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof Us:(Fr(this.cn,"Precondition should be empty"),!0)},Zo.prototype.isEqual=function(t){return e=this.updateTime,n=t.updateTime,(null!=e?!(!n||!e.isEqual(n)):e===n)&&this.exists===t.exists;var e,n},Zo.NONE=new Zo,Zo),Fo=($o.prototype.fn=function(t){null!=t&&Fr(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},$o.ln=function(t){return t instanceof Us?t.version:Bi.MIN},$o),Go=(t(Jo,Vo=Fo),Jo.prototype.$t=function(t,e){this.fn(t),Fr(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new Us(this.key,n,{hasCommittedMutations:!0},this.value)},Jo.prototype.Xt=function(t,e,n){if(this.fn(t),!this.dn.an(t))return t;var r=Fo.ln(t);return new Us(this.key,r,{vn:!0},this.value)},Jo.prototype.wn=function(t){return null},Jo.prototype.isEqual=function(t){return t instanceof Jo&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.dn.isEqual(t.dn)},Jo),Bo=(t(Qo,Uo=Fo),Qo.prototype.$t=function(t,e){if(this.fn(t),Fr(null==e.transformResults,"Transform results received by PatchMutation."),!this.dn.an(t))return new js(this.key,e.version);var n=this.pn(t);return new Us(this.key,e.version,{hasCommittedMutations:!0},n)},Qo.prototype.Xt=function(t,e,n){if(this.fn(t),!this.dn.an(t))return t;var r=Fo.ln(t),i=this.pn(t);return new Us(this.key,r,{vn:!0},i)},Qo.prototype.wn=function(t){return null},Qo.prototype.isEqual=function(t){return t instanceof Qo&&this.key.isEqual(t.key)&&this.mn.isEqual(t.mn)&&this.dn.isEqual(t.dn)},Qo.prototype.pn=function(t){var e;return e=t instanceof Us?t.data():Ls.EMPTY,this.gn(e)},Qo.prototype.gn=function(n){var r=this;return this.mn.fields.forEach(function(t){if(!t.nt()){var e=r.data.field(t);n=null!==e?n.set(t,e):n.delete(t)}}),n},Qo),zo=(t(Ko,Mo=Fo),Ko.prototype.$t=function(t,e){if(this.fn(t),Fr(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.dn.an(t))return new js(this.key,e.version);var n=this.bn(t),r=this.yn(t,e.transformResults),i=e.version,o=this._n(n.data(),r);return new Us(this.key,i,{hasCommittedMutations:!0},o)},Ko.prototype.Xt=function(t,e,n){if(this.fn(t),!this.dn.an(t))return t;var r=this.bn(t),i=this.In(n,t,e),o=this._n(r.data(),i);return new Us(this.key,r.version,{vn:!0},o)},Ko.prototype.wn=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Us?t.field(i.field):void 0,s=i.transform.Zt(o||null);null!=s&&(e=null==e?Ls.EMPTY.set(i.field,s):e.set(i.field,s))}return e},Ko.prototype.isEqual=function(t){return t instanceof Ko&&this.key.isEqual(t.key)&&Xr(this.fieldTransforms,t.fieldTransforms)&&this.dn.isEqual(t.dn)},Ko.prototype.bn=function(t){return Fr(t instanceof Us,"Unknown MaybeDocument type "+t),Fr(t.key.isEqual(this.key),"Can only transform a document with the same key"),t},Ko.prototype.yn=function(t,e){var n=[];Fr(this.fieldTransforms.length===e.length,"server transform result count ("+e.length+") should match field transform count ("+this.fieldTransforms.length+")");for(var r=0;r<e.length;r++){var i=this.fieldTransforms[r],o=i.transform,s=null;t instanceof Us&&(s=t.field(i.field)),n.push(o.$t(s,e[r]))}return n},Ko.prototype.In=function(t,e,n){for(var r=[],i=0,o=this.fieldTransforms;i<o.length;i++){var s=o[i],a=s.transform,u=null;e instanceof Us&&(u=e.field(s.field)),null===u&&n instanceof Us&&(u=n.field(s.field)),r.push(a.Xt(u,t))}return r},Ko.prototype._n=function(t,e){Fr(e.length===this.fieldTransforms.length,"TransformResults length mismatch.");for(var n=0;n<this.fieldTransforms.length;n++){var r=this.fieldTransforms[n].field;t=t.set(r,e[n])}return t},Ko),Xo=(t(Yo,qo=Fo),Yo.prototype.$t=function(t,e){return this.fn(t),Fr(null==e.transformResults,"Transform results received by DeleteMutation."),new Vs(this.key,e.version,{hasCommittedMutations:!0})},Yo.prototype.Xt=function(t,e,n){return this.fn(t),this.dn.an(t)?(t&&Fr(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new Vs(this.key,Bi.K())):t},Yo.prototype.wn=function(t){return null},Yo.prototype.isEqual=function(t){return t instanceof Yo&&this.key.isEqual(t.key)&&this.dn.isEqual(t.dn)},Yo),Wo=(t(Ho,Lo=Fo),Ho.prototype.$t=function(t,e){jr("VerifyMutation should only be used in Transactions.")},Ho.prototype.Xt=function(t,e,n){jr("VerifyMutation should only be used in Transactions.")},Ho.prototype.wn=function(t){jr("VerifyMutation should only be used in Transactions.")},Ho.prototype.isEqual=function(t){return t instanceof Ho&&this.key.isEqual(t.key)&&this.dn.isEqual(t.dn)},Ho);function Ho(t,e){var n=Lo.call(this)||this;return n.key=t,n.dn=e,n.type=No.hn,n}function Yo(t,e){var n=qo.call(this)||this;return n.key=t,n.dn=e,n.type=No.on,n}function Ko(t,e){var n=Mo.call(this)||this;return n.key=t,n.fieldTransforms=e,n.type=No.sn,n.dn=jo.exists(!0),n}function Qo(t,e,n,r){var i=Uo.call(this)||this;return i.key=t,i.data=e,i.mn=n,i.dn=r,i.type=No.un,i}function Jo(t,e,n){var r=Vo.call(this)||this;return r.key=t,r.value=e,r.dn=n,r.type=No.Set,r}function $o(){}function Zo(t,e){this.updateTime=t,this.exists=e,Fr(void 0===t||void 0===e,'Precondition can specify "exists" or "updateTime" but not both')}(xo=Co=Co||{})[xo.Tn=0]="__PRIVATE_NullValue",xo[xo.En=1]="__PRIVATE_BooleanValue",xo[xo.Rn=2]="__PRIVATE_NumberValue",xo[xo.An=3]="__PRIVATE_TimestampValue",xo[xo.Dn=4]="__PRIVATE_StringValue",xo[xo.Pn=5]="__PRIVATE_BlobValue",xo[xo.Sn=6]="__PRIVATE_RefValue",xo[xo.Cn=7]="__PRIVATE_GeoPointValue",xo[xo.ArrayValue=8]="ArrayValue",xo[xo.Vn=9]="__PRIVATE_ObjectValue",(Oo=Po=Po||{})[Oo.kn=0]="__PRIVATE_Default",Oo[Oo.Nn=1]="__PRIVATE_Estimate",Oo[Oo.On=2]="__PRIVATE_Previous";var ts,es,ns,rs=(ls.xn=function(t,e){switch(t.serverTimestamps){case"estimate":return new ls(Po.Nn,e);case"previous":return new ls(Po.On,e);case"none":case void 0:return new ls(Po.kn,e);default:return jr("fromSnapshotOptions() called with invalid options.")}},ls),is=(fs.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},fs.prototype.jn=function(t){return Fr(this.Un!==t.Un,"Default compareTo should not be used for values of same type."),zr(this.Un,t.Un)},fs),os=(t(cs,ns=is),cs.prototype.value=function(t){return null},cs.prototype.isEqual=function(t){return t instanceof cs},cs.prototype.h=function(t){return t instanceof cs?0:this.jn(t)},cs.prototype.Ln=function(){return 4},cs.Bn=new cs,cs),ss=(t(hs,es=is),hs.prototype.value=function(t){return this.nn},hs.prototype.isEqual=function(t){return t instanceof hs&&this.nn===t.nn},hs.prototype.h=function(t){return t instanceof hs?zr(this,t):this.jn(t)},hs.prototype.Ln=function(){return 4},hs.of=function(t){return t?hs.Mn:hs.qn},hs.Mn=new hs(!0),hs.qn=new hs(!1),hs),as=(t(us,ts=is),us.prototype.value=function(t){return this.nn},us.prototype.h=function(t){return t instanceof us?(e=this.nn)<(n=t.nn)?-1:n<e?1:e===n?0:isNaN(e)?isNaN(n)?0:-1:1:this.jn(t);var e,n},us.prototype.Ln=function(){return 8},us);function us(t){var e=ts.call(this)||this;return e.nn=t,e.Un=Co.Rn,e}function hs(t){var e=es.call(this)||this;return e.nn=t,e.Un=Co.En,e}function cs(){var t=ns.call(this)||this;return t.Un=Co.Tn,t.nn=null,t}function fs(){}function ls(t,e){this.Fn=t,this.timestampsInSnapshots=e}function ps(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var ds,ys,vs,ms,gs,ws,bs,Es,Is,Ts,As,Ns,Ss,Ds=(t(ia,Ss=as),ia.prototype.isEqual=function(t){return t instanceof ia&&ps(this.nn,t.nn)},ia),ks=(t(ra,Ns=as),ra.prototype.isEqual=function(t){return t instanceof ra&&ps(this.nn,t.nn)},ra.Qn=new ra(NaN),ra.POSITIVE_INFINITY=new ra(1/0),ra.NEGATIVE_INFINITY=new ra(-1/0),ra),Rs=(t(na,As=is),na.prototype.value=function(t){return this.nn},na.prototype.isEqual=function(t){return t instanceof na&&this.nn===t.nn},na.prototype.h=function(t){return t instanceof na?zr(this.nn,t.nn):this.jn(t)},na.prototype.Ln=function(){return 2*this.nn.length},na),_s=(t(ea,Ts=is),ea.prototype.value=function(t){return!t||t.timestampsInSnapshots?this.nn:this.nn.toDate()},ea.prototype.isEqual=function(t){return t instanceof ea&&this.nn.isEqual(t.nn)},ea.prototype.h=function(t){return t instanceof ea?this.nn.q(t.nn):t instanceof Cs?-1:this.jn(t)},ea.prototype.Ln=function(){return 16},ea),Cs=(t(ta,Is=is),ta.prototype.value=function(t){return t&&t.Fn===Po.Nn?new _s(this.Gn).value(t):t&&t.Fn===Po.On&&this.previousValue?this.previousValue.value(t):null},ta.prototype.isEqual=function(t){return t instanceof ta&&this.Gn.isEqual(t.Gn)},ta.prototype.h=function(t){return t instanceof ta?this.Gn.q(t.Gn):t instanceof _s?1:this.jn(t)},ta.prototype.toString=function(){return"<ServerTimestamp localTime="+this.Gn.toString()+">"},ta.prototype.Ln=function(){return 16+(this.previousValue?this.previousValue.Ln():0)},ta),xs=(t(Zs,Es=is),Zs.prototype.value=function(t){return this.nn},Zs.prototype.isEqual=function(t){return t instanceof Zs&&this.nn.isEqual(t.nn)},Zs.prototype.h=function(t){return t instanceof Zs?this.nn.q(t.nn):this.jn(t)},Zs.prototype.Ln=function(){return this.nn.Wn()},Zs),Ps=(t($s,bs=is),$s.prototype.value=function(t){return this.key},$s.prototype.isEqual=function(t){return t instanceof $s&&this.key.isEqual(t.key)&&this.s.isEqual(t.s)},$s.prototype.h=function(t){if(t instanceof $s){var e=this.s.h(t.s);return 0!==e?e:Yi.X(this.key,t.key)}return this.jn(t)},$s.prototype.Ln=function(){return this.s.projectId.length+this.s.database.length+this.key.toString().length},$s),Os=(t(Js,ws=is),Js.prototype.value=function(t){return this.nn},Js.prototype.isEqual=function(t){return t instanceof Js&&this.nn.isEqual(t.nn)},Js.prototype.h=function(t){return t instanceof Js?this.nn.q(t.nn):this.jn(t)},Js.prototype.Ln=function(){return 16},Js),Ls=(t(Qs,gs=is),Qs.prototype.value=function(n){var r={};return this.nn.Et(function(t,e){r[t]=e.value(n)}),r},Qs.prototype.forEach=function(t){this.nn.Et(t)},Qs.prototype.isEqual=function(t){if(t instanceof Qs){for(var e=this.nn.At(),n=t.nn.At();e.Nt()&&n.Nt();){var r=e.kt(),i=n.kt();if(r.key!==i.key||!r.value.isEqual(i.value))return!1}return!e.Nt()&&!n.Nt()}return!1},Qs.prototype.h=function(t){if(t instanceof Qs){for(var e=this.nn.At(),n=t.nn.At();e.Nt()&&n.Nt();){var r=e.kt(),i=n.kt(),o=zr(r.key,i.key)||r.value.h(i.value);if(o)return o}return zr(e.Nt(),n.Nt())}return this.jn(t)},Qs.prototype.set=function(t,e){if(Fr(!t.nt(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.zn(t.it(),e);var n=this.child(t.it());n instanceof Qs||(n=Qs.EMPTY);var r=n.set(t.Z(),e);return this.zn(t.it(),r)},Qs.prototype.delete=function(t){if(Fr(!t.nt(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new Qs(this.nn.remove(t.it()));var e=this.child(t.it());if(e instanceof Qs){var n=e.delete(t.Z());return new Qs(this.nn.bt(t.it(),n))}return this},Qs.prototype.contains=function(t){return null!==this.field(t)},Qs.prototype.field=function(t){Fr(!t.nt(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof Qs?e.nn.get(t):null}),e},Qs.prototype.mn=function(){var i=new co(Hi.X);return this.nn.forEach(function(t,e){var n=new Hi([t]);if(e instanceof Qs){var r=e.mn().fields;r.nt()?i=i.add(n):r.forEach(function(t){i=i.add(n.child(t))})}else i=i.add(n)}),Do.in(i)},Qs.prototype.Ln=function(){var n=0;return this.nn.Et(function(t,e){n+=t.length+e.Ln()}),n},Qs.prototype.toString=function(){return this.nn.toString()},Qs.prototype.child=function(t){return this.nn.get(t)||void 0},Qs.prototype.zn=function(t,e){return new Qs(this.nn.bt(t,e))},Qs.EMPTY=new Qs(new Ki(zr)),Qs),qs=(t(Ks,ms=is),Ks.prototype.value=function(e){return this.nn.map(function(t){return t.value(e)})},Ks.prototype.contains=function(t){for(var e=0,n=this.nn;e<n.length;e++)if(n[e].isEqual(t))return!0;return!1},Ks.prototype.forEach=function(t){this.nn.forEach(t)},Ks.prototype.isEqual=function(t){if(t instanceof Ks){if(this.nn.length!==t.nn.length)return!1;for(var e=0;e<this.nn.length;e++)if(!this.nn[e].isEqual(t.nn[e]))return!1;return!0}return!1},Ks.prototype.h=function(t){if(t instanceof Ks){for(var e=Math.min(this.nn.length,t.nn.length),n=0;n<e;n++){var r=this.nn[n].h(t.nn[n]);if(r)return r}return zr(this.nn.length,t.nn.length)}return this.jn(t)},Ks.prototype.Ln=function(){return this.nn.reduce(function(t,e){return t+e.Ln()},0)},Ks.prototype.toString=function(){return"["+this.nn.map(function(t){return t.toString()}).join(",")+"]"},Ks),Ms=(Ys.Kn=function(t,e){return Yi.X(t.key,e.key)},Ys),Us=(t(Hs,vs=Ms),Hs.prototype.field=function(t){if(this.Hn)return this.Hn.field(t);this.Jn||(this.Jn=new Map);var e=t.ot(),n=this.Jn.get(e);if(void 0===n){var r=this.Yn(t);n=void 0===r?null:this.converter(r),this.Jn.set(e,n)}return n},Hs.prototype.data=function(){var n=this;if(!this.Hn){var r=Ls.EMPTY;wi(this.proto.fields||{},function(t,e){r=r.set(new Hi([t]),n.converter(e))}),this.Hn=r,this.Jn=void 0}return this.Hn},Hs.prototype.value=function(){return this.data().value()},Hs.prototype.isEqual=function(t){return t instanceof Hs&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.vn===t.vn&&this.hasCommittedMutations===t.hasCommittedMutations&&this.data().isEqual(t.data())},Hs.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.data().toString()+", {hasLocalMutations: "+this.vn+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(Hs.prototype,"hasPendingWrites",{get:function(){return this.vn||this.hasCommittedMutations},enumerable:!0,configurable:!0}),Hs.prototype.Yn=function(t){Fr(void 0!==this.proto,"Can only call getProtoField() when proto is defined");for(var e=this.proto.fields?this.proto.fields[t.it()]:void 0,n=1;n<t.length;++n){if(!e||!e.mapValue||!e.mapValue.fields)return;e=e.mapValue.fields[t.get(n)]}return e},Hs.Xn=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?r.h(i):jr("Trying to compare documents on fields that don't exist")},Hs),Vs=(t(Ws,ys=Ms),Ws.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(Ws.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),Ws.prototype.isEqual=function(t){return t instanceof Ws&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Ws),js=(t(Xs,ds=Ms),Xs.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Xs.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),Xs.prototype.isEqual=function(t){return t instanceof Xs&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Xs),Fs=Number,Gs=Fs.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),Bs=Fs.MAX_SAFE_INTEGER||Math.pow(2,53)-1,zs=Fs.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function Xs(){return null!==ds&&ds.apply(this,arguments)||this}function Ws(t,e,n){var r=ys.call(this,t,e)||this;return r.hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}function Hs(t,e,n,r,i,o){var s=vs.call(this,t,e)||this;return s.Hn=r,s.proto=i,s.converter=o,Fr(void 0!==s.Hn||void 0!==s.proto&&void 0!==s.converter,"If objectValue is not defined, proto and converter need to be set."),s.vn=!!n.vn,s.hasCommittedMutations=!!n.hasCommittedMutations,s}function Ys(t,e){this.key=t,this.version=e}function Ks(t){var e=ms.call(this)||this;return e.nn=t,e.Un=Co.ArrayValue,e}function Qs(t){var e=gs.call(this)||this;return e.nn=t,e.Un=Co.Vn,e}function Js(t){var e=ws.call(this)||this;return e.nn=t,e.Un=Co.Cn,e}function $s(t,e){var n=bs.call(this)||this;return n.s=t,n.key=e,n.Un=Co.Sn,n}function Zs(t){var e=Es.call(this)||this;return e.nn=t,e.Un=Co.Pn,e}function ta(t,e){var n=Is.call(this)||this;return n.Gn=t,n.previousValue=e,n.Un=Co.An,n}function ea(t){var e=Ts.call(this)||this;return e.nn=t,e.Un=Co.An,e}function na(t){var e=As.call(this)||this;return e.nn=t,e.Un=Co.Dn,e}function ra(){return null!==Ns&&Ns.apply(this,arguments)||this}function ia(){return null!==Ss&&Ss.apply(this,arguments)||this}function oa(t){return null==t}function sa(t){return zs(t)&&t<=Bs&&Gs<=t}var aa,ua,ha=(ca.prototype.canonicalId=function(){if(null===this.$n){var t=this.path.ot();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:";for(var e=0,n=this.filters;e<n.length;e++)t+=n[e].canonicalId(),t+=",";t+="|ob:";for(var r=0,i=this.orderBy;r<i.length;r++)t+=i[r].canonicalId(),t+=",";oa(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.$n=t}return this.$n},ca.prototype.toString=function(){var t=this.path.ot();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),oa(this.limit)||(t+=", limit: "+this.limit),0<this.orderBy.length&&(t+=", orderBy: ["+this.orderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),"Target("+t+")"},ca.prototype.isEqual=function(t){if(this.limit!==t.limit)return!1;if(this.orderBy.length!==t.orderBy.length)return!1;for(var e=0;e<this.orderBy.length;e++)if(!this.orderBy[e].isEqual(t.orderBy[e]))return!1;if(this.filters.length!==t.filters.length)return!1;for(e=0;e<this.filters.length;e++)if(!this.filters[e].isEqual(t.filters[e]))return!1;return this.collectionGroup===t.collectionGroup&&!!this.path.isEqual(t.path)&&!(null!==this.startAt?!this.startAt.isEqual(t.startAt):null!==t.startAt)&&(null!==this.endAt?this.endAt.isEqual(t.endAt):null===t.endAt)},ca.prototype.Zn=function(){return Yi.vt(this.path)&&null===this.collectionGroup&&0===this.filters.length},ca);function ca(t,e,n,r,i,o,s){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===s&&(s=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.$n=null}(ua=aa=aa||{}).ti="F",ua.ni="L";var fa,la,pa,da,ya,va,ma,ga,wa=(Ga.oi=function(t){return new Ga(t)},Object.defineProperty(Ga.prototype,"orderBy",{get:function(){if(null===this.ri){var t=this.hi(),e=this.ci();if(null!==t&&null===e)t.ft()?this.ri=[_a]:this.ri=[new Ra(t),_a];else{Fr(null===t||null!==e&&t.isEqual(e),"First orderBy should match inequality field.");for(var n=!(this.ri=[]),r=0,i=this.ii;r<i.length;r++){var o=i[r];this.ri.push(o),o.field.ft()&&(n=!0)}if(!n){var s=0<this.ii.length?this.ii[this.ii.length-1].dir:Da.ASCENDING;this.ri.push(s===Da.ASCENDING?_a:Ca)}}}return this.ri},enumerable:!0,configurable:!0}),Ga.prototype.ai=function(t){Fr(null==this.hi()||!(t instanceof Ea)||!t.fi()||t.field.isEqual(this.hi()),"Query must only have one inequality field."),Fr(!this.Zn(),"No filtering allowed for document query");var e=this.filters.concat([t]);return new Ga(this.path,this.collectionGroup,this.ii.slice(),e,this.limit,this.ei,this.startAt,this.endAt)},Ga.prototype.li=function(t){Fr(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var e=this.ii.concat([t]);return new Ga(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.ei,this.startAt,this.endAt)},Ga.prototype.di=function(t){return new Ga(this.path,this.collectionGroup,this.ii.slice(),this.filters.slice(),t,aa.ti,this.startAt,this.endAt)},Ga.prototype.vi=function(t){return new Ga(this.path,this.collectionGroup,this.ii.slice(),this.filters.slice(),t,aa.ni,this.startAt,this.endAt)},Ga.prototype.wi=function(t){return new Ga(this.path,this.collectionGroup,this.ii.slice(),this.filters.slice(),this.limit,this.ei,t,this.endAt)},Ga.prototype.mi=function(t){return new Ga(this.path,this.collectionGroup,this.ii.slice(),this.filters.slice(),this.limit,this.ei,this.startAt,t)},Ga.prototype.pi=function(t){return new Ga(t,null,this.ii.slice(),this.filters.slice(),this.limit,this.ei,this.startAt,this.endAt)},Ga.prototype.gi=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.ii.length||1===this.ii.length&&this.ii[0].field.ft())},Ga.prototype.canonicalId=function(){return this.bi().canonicalId()+"|lt:"+this.ei},Ga.prototype.toString=function(){return"Query(target="+this.bi().toString()+"; limitType="+this.ei+")"},Ga.prototype.isEqual=function(t){return this.bi().isEqual(t.bi())&&this.ei===t.ei},Ga.prototype.yi=function(t,e){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],s=o.compare(t,e);if(0!==s)return s;n=n||o.field.ft()}return Fr(n,"orderBy used that doesn't compare on key field"),0},Ga.prototype.matches=function(t){return this._i(t)&&this.Ii(t)&&this.Ti(t)&&this.Ei(t)},Ga.prototype.Ri=function(){return!oa(this.limit)&&this.ei===aa.ti},Ga.prototype.Ai=function(){return!oa(this.limit)&&this.ei===aa.ni},Ga.prototype.ci=function(){return 0<this.ii.length?this.ii[0].field:null},Ga.prototype.hi=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof Ea&&n.fi())return n.field}return null},Ga.prototype.Di=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof Ea&&0<=t.indexOf(r.op))return r.op}return null},Ga.prototype.Zn=function(){return this.bi().Zn()},Ga.prototype.Pi=function(){return null!==this.collectionGroup},Ga.prototype.bi=function(){if(!this.ui)if(this.ei===aa.ti)this.ui=new ha(this.path,this.collectionGroup,this.orderBy,this.filters,this.limit,this.startAt,this.endAt);else{for(var t=[],e=0,n=this.orderBy;e<n.length;e++){var r=n[e],i=r.dir===Da.DESCENDING?Da.ASCENDING:Da.DESCENDING;t.push(new Ra(r.field,i))}var o=this.endAt?new ka(this.endAt.position,!this.endAt.before):null,s=this.startAt?new ka(this.startAt.position,!this.startAt.before):null;this.ui=new ha(this.path,this.collectionGroup,t,this.filters,this.limit,o,s)}return this.ui},Ga.prototype._i=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.wt(this.collectionGroup)&&this.path.rt(e):Yi.vt(this.path)?this.path.isEqual(e):this.path.ut(e)},Ga.prototype.Ii=function(t){for(var e=0,n=this.ii;e<n.length;e++){var r=n[e];if(!r.field.ft()&&null===t.field(r.field))return!1}return!0},Ga.prototype.Ti=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},Ga.prototype.Ei=function(t){return!(this.startAt&&!this.startAt.Si(this.orderBy,t)||this.endAt&&this.endAt.Si(this.orderBy,t))},Ga.prototype.si=function(t){Fr(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},Ga),ba=(Fa.ht=function(t){switch(t){case"<":return Fa.LESS_THAN;case"<=":return Fa.LESS_THAN_OR_EQUAL;case"==":return Fa.EQUAL;case">=":return Fa.GREATER_THAN_OR_EQUAL;case">":return Fa.GREATER_THAN;case"array-contains":return Fa.ARRAY_CONTAINS;case"in":return Fa.IN;case"array-contains-any":return Fa.ARRAY_CONTAINS_ANY;default:return jr("Unknown FieldFilter operator: "+t)}},Fa.prototype.toString=function(){return this.name},Fa.prototype.isEqual=function(t){return this.name===t.name},Fa.LESS_THAN=new Fa("<"),Fa.LESS_THAN_OR_EQUAL=new Fa("<="),Fa.EQUAL=new Fa("=="),Fa.GREATER_THAN=new Fa(">"),Fa.GREATER_THAN_OR_EQUAL=new Fa(">="),Fa.ARRAY_CONTAINS=new Fa("array-contains"),Fa.IN=new Fa("in"),Fa.ARRAY_CONTAINS_ANY=new Fa("array-contains-any"),Fa),Ea=(t(ja,ga=function(){}),ja.create=function(t,e,n){if(t.ft())return e===ba.IN?(Fr(n instanceof qs,"Comparing on key with IN, but filter value not an ArrayValue"),Fr(n.nn.every(function(t){return t instanceof Ps}),"Comparing on key with IN, but an array value was not a RefValue"),new Ta(t,n)):(Fr(n instanceof Ps,"Comparing on key, but filter value not a RefValue"),Fr(e!==ba.ARRAY_CONTAINS&&e!==ba.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new Ia(t,e,n));if(n.isEqual(os.Bn)){if(e!==ba.EQUAL)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new ja(t,e,n)}if(n.isEqual(ks.Qn)){if(e!==ba.EQUAL)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new ja(t,e,n)}return e===ba.ARRAY_CONTAINS?new Aa(t,n):e===ba.IN?(Fr(n instanceof qs,"IN filter has invalid value: "+n.toString()),new Na(t,n)):e===ba.ARRAY_CONTAINS_ANY?(Fr(n instanceof qs,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new Sa(t,n)):new ja(t,e,n)},ja.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.Un===e.Un&&this.Ci(e.h(this.value))},ja.prototype.Ci=function(t){switch(this.op){case ba.LESS_THAN:return t<0;case ba.LESS_THAN_OR_EQUAL:return t<=0;case ba.EQUAL:return 0===t;case ba.GREATER_THAN:return 0<t;case ba.GREATER_THAN_OR_EQUAL:return 0<=t;default:return jr("Unknown FieldFilter operator: "+this.op)}},ja.prototype.fi=function(){return 0<=[ba.LESS_THAN,ba.LESS_THAN_OR_EQUAL,ba.GREATER_THAN,ba.GREATER_THAN_OR_EQUAL].indexOf(this.op)},ja.prototype.canonicalId=function(){return this.field.ot()+this.op.toString()+this.value.toString()},ja.prototype.isEqual=function(t){return t instanceof ja&&this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&this.value.isEqual(t.value)},ja.prototype.toString=function(){return this.field.ot()+" "+this.op+" "+this.value.value()},ja),Ia=(t(Va,ma=Ea),Va.prototype.matches=function(t){var e=this.value,n=Yi.X(t.key,e.key);return this.Ci(n)},Va),Ta=(t(Ua,va=Ea),Ua.prototype.matches=function(e){return this.value.nn.some(function(t){return e.key.isEqual(t.key)})},Ua),Aa=(t(Ma,ya=Ea),Ma.prototype.matches=function(t){var e=t.field(this.field);return e instanceof qs&&e.contains(this.value)},Ma),Na=(t(qa,da=Ea),qa.prototype.matches=function(t){var e=this.value,n=t.field(this.field);return null!==n&&e.contains(n)},qa),Sa=(t(La,pa=Ea),La.prototype.matches=function(t){var e=this,n=t.field(this.field);return n instanceof qs&&n.nn.some(function(t){return e.value.contains(t)})},La),Da=(Oa.prototype.toString=function(){return this.name},Oa.ASCENDING=new Oa("asc"),Oa.DESCENDING=new Oa("desc"),Oa),ka=(Pa.prototype.canonicalId=function(){for(var t=this.before?"b:":"a:",e=0,n=this.position;e<n.length;e++)t+=n[e].toString();return t},Pa.prototype.Si=function(t,e){Fr(this.position.length<=t.length,"Bound has more components than query's orderBy");for(var n=0,r=0;r<this.position.length;r++){var i=t[r],o=this.position[r];if(i.field.ft())Fr(o instanceof Ps,"Bound has a non-key value where the key path is being used."),n=Yi.X(o.key,e.key);else{var s=e.field(i.field);Fr(null!==s,"Field should exist since document matched the orderBy already."),n=o.h(s)}if(i.dir===Da.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},Pa.prototype.isEqual=function(t){if(null===t)return!1;if(this.before!==t.before||this.position.length!==t.position.length)return!1;for(var e=0;e<this.position.length;e++){var n=this.position[e],r=t.position[e];if(!n.isEqual(r))return!1}return!0},Pa),Ra=(xa.prototype.compare=function(t,e){var n=this.Vi?Us.Kn(t,e):Us.Xn(this.field,t,e);switch(this.dir){case Da.ASCENDING:return n;case Da.DESCENDING:return-1*n;default:return jr("Unknown direction: "+this.dir)}},xa.prototype.canonicalId=function(){return this.field.ot()+this.dir.toString()},xa.prototype.toString=function(){return this.field.ot()+" ("+this.dir+")"},xa.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},xa),_a=new Ra(Hi.lt(),Da.ASCENDING),Ca=new Ra(Hi.lt(),Da.DESCENDING);function xa(t,e){this.field=t,void 0===e&&(e=Da.ASCENDING),this.dir=e,this.Vi=t.ft()}function Pa(t,e){this.position=t,this.before=e}function Oa(t){this.name=t}function La(t,e){var n=pa.call(this,t,ba.ARRAY_CONTAINS_ANY,e)||this;return n.value=e,n}function qa(t,e){var n=da.call(this,t,ba.IN,e)||this;return n.value=e,n}function Ma(t,e){return ya.call(this,t,ba.ARRAY_CONTAINS,e)||this}function Ua(t,e){var n=va.call(this,t,ba.IN,e)||this;return n.value=e,n}function Va(){return null!==ma&&ma.apply(this,arguments)||this}function ja(t,e,n){var r=ga.call(this)||this;return r.field=t,r.op=e,r.value=n,r}function Fa(t){this.name=t}function Ga(t,e,n,r,i,o,s,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=aa.ti),void 0===s&&(s=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.ii=n,this.filters=r,this.limit=i,this.ei=o,this.startAt=s,this.endAt=a,this.ri=null,this.ui=null,this.startAt&&this.si(this.startAt),this.endAt&&this.si(this.endAt)}(la=fa=fa||{})[la.ki=0]="__PRIVATE_Listen",la[la.Ni=1]="__PRIVATE_ExistenceFilterMismatch",la[la.Oi=2]="__PRIVATE_LimboResolution";var Ba,za,Xa=(Ya.prototype.ji=function(t){return new Ya(this.target,this.targetId,this.Fi,t,this.xi,this.lastLimboFreeSnapshotVersion,this.resumeToken)},Ya.prototype.Ui=function(t,e){return new Ya(this.target,this.targetId,this.Fi,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},Ya.prototype.Li=function(t){return new Ya(this.target,this.targetId,this.Fi,this.sequenceNumber,this.xi,t,this.resumeToken)},Ya.prototype.isEqual=function(t){return this.targetId===t.targetId&&this.Fi===t.Fi&&this.sequenceNumber===t.sequenceNumber&&this.xi.isEqual(t.xi)&&this.lastLimboFreeSnapshotVersion.isEqual(t.lastLimboFreeSnapshotVersion)&&this.resumeToken===t.resumeToken&&this.target.isEqual(t.target)},Ya),Wa=(Ha.prototype.isEqual=function(t){return t&&t.count===this.count},Ha);function Ha(t){this.count=t}function Ya(t,e,n,r,i,o,s){void 0===i&&(i=Bi.MIN),void 0===o&&(o=Bi.MIN),void 0===s&&(s=zu()),this.target=t,this.targetId=e,this.Fi=n,this.sequenceNumber=r,this.xi=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}function Ka(t){switch(t){case ii.OK:return jr("Treated status OK as error");case ii.CANCELLED:case ii.UNKNOWN:case ii.DEADLINE_EXCEEDED:case ii.RESOURCE_EXHAUSTED:case ii.INTERNAL:case ii.UNAVAILABLE:case ii.UNAUTHENTICATED:return!1;case ii.INVALID_ARGUMENT:case ii.NOT_FOUND:case ii.ALREADY_EXISTS:case ii.PERMISSION_DENIED:case ii.FAILED_PRECONDITION:case ii.ABORTED:case ii.OUT_OF_RANGE:case ii.UNIMPLEMENTED:case ii.DATA_LOSS:return!0;default:return jr("Unknown status code: "+t)}}function Qa(t){if(void 0===t)return Ur("GRPC error has no .code"),ii.UNKNOWN;switch(t){case Ba.OK:return ii.OK;case Ba.CANCELLED:return ii.CANCELLED;case Ba.UNKNOWN:return ii.UNKNOWN;case Ba.DEADLINE_EXCEEDED:return ii.DEADLINE_EXCEEDED;case Ba.RESOURCE_EXHAUSTED:return ii.RESOURCE_EXHAUSTED;case Ba.INTERNAL:return ii.INTERNAL;case Ba.UNAVAILABLE:return ii.UNAVAILABLE;case Ba.UNAUTHENTICATED:return ii.UNAUTHENTICATED;case Ba.INVALID_ARGUMENT:return ii.INVALID_ARGUMENT;case Ba.NOT_FOUND:return ii.NOT_FOUND;case Ba.ALREADY_EXISTS:return ii.ALREADY_EXISTS;case Ba.PERMISSION_DENIED:return ii.PERMISSION_DENIED;case Ba.FAILED_PRECONDITION:return ii.FAILED_PRECONDITION;case Ba.ABORTED:return ii.ABORTED;case Ba.OUT_OF_RANGE:return ii.OUT_OF_RANGE;case Ba.UNIMPLEMENTED:return ii.UNIMPLEMENTED;case Ba.DATA_LOSS:return ii.DATA_LOSS;default:return jr("Unknown status code: "+t)}}(za=Ba=Ba||{})[za.OK=0]="OK",za[za.CANCELLED=1]="CANCELLED",za[za.UNKNOWN=2]="UNKNOWN",za[za.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",za[za.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",za[za.NOT_FOUND=5]="NOT_FOUND",za[za.ALREADY_EXISTS=6]="ALREADY_EXISTS",za[za.PERMISSION_DENIED=7]="PERMISSION_DENIED",za[za.UNAUTHENTICATED=16]="UNAUTHENTICATED",za[za.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",za[za.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",za[za.ABORTED=10]="ABORTED",za[za.OUT_OF_RANGE=11]="OUT_OF_RANGE",za[za.UNIMPLEMENTED=12]="UNIMPLEMENTED",za[za.INTERNAL=13]="INTERNAL",za[za.UNAVAILABLE=14]="UNAVAILABLE",za[za.DATA_LOSS=15]="DATA_LOSS";var Ja=new Ki(Yi.X);function $a(){return Ja}function Za(){return $a()}var tu=new Ki(Yi.X);function eu(){return tu}var nu=new Ki(Yi.X);function ru(){return nu}var iu=new co(Yi.X);function ou(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=iu,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var su=new co(zr);function au(){return su}var uu,hu,cu,fu,lu=(pu.qi=function(t){return new pu(t.X)},pu.prototype.has=function(t){return null!=this.Bi.get(t)},pu.prototype.get=function(t){return this.Bi.get(t)},pu.prototype.first=function(){return this.Mi.It()},pu.prototype.last=function(){return this.Mi.Tt()},pu.prototype.nt=function(){return this.Mi.nt()},pu.prototype.indexOf=function(t){var e=this.Bi.get(t);return e?this.Mi.indexOf(e):-1},Object.defineProperty(pu.prototype,"size",{get:function(){return this.Mi.size},enumerable:!0,configurable:!0}),pu.prototype.forEach=function(n){this.Mi.Et(function(t,e){return n(t),!1})},pu.prototype.add=function(t){var e=this.delete(t.key);return e.yt(e.Bi.bt(t.key,t),e.Mi.bt(t,null))},pu.prototype.delete=function(t){var e=this.get(t);return e?this.yt(this.Bi.remove(t),this.Mi.remove(e)):this},pu.prototype.isEqual=function(t){if(!(t instanceof pu))return!1;if(this.size!==t.size)return!1;for(var e=this.Mi.At(),n=t.Mi.At();e.Nt();){var r=e.kt().key,i=n.kt().key;if(!r.isEqual(i))return!1}return!0},pu.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"},pu.prototype.yt=function(t,e){var n=new pu;return n.X=this.X,n.Bi=t,n.Mi=e,n},pu);function pu(n){this.X=n?function(t,e){return n(t,e)||Yi.X(t.key,e.key)}:function(t,e){return Yi.X(t.key,e.key)},this.Bi=eu(),this.Mi=new Ki(this.X)}(hu=uu=uu||{})[hu.Qi=0]="__PRIVATE_Added",hu[hu.Gi=1]="__PRIVATE_Removed",hu[hu.Wi=2]="__PRIVATE_Modified",hu[hu.zi=3]="__PRIVATE_Metadata",(fu=cu=cu||{})[fu.Ki=0]="__PRIVATE_Local",fu[fu.Hi=1]="__PRIVATE_Synced";function du(t,e,n,r){this.le=t,this.removedTargetIds=e,this.key=n,this.de=r}function yu(t,e){this.targetId=t,this.ve=e}var vu,mu,gu=(Nu.prototype.track=function(t){var e=t.doc.key,n=this.Ji.get(e);n?t.type!==uu.Qi&&n.type===uu.zi?this.Ji=this.Ji.bt(e,t):t.type===uu.zi&&n.type!==uu.Gi?this.Ji=this.Ji.bt(e,{type:n.type,doc:t.doc}):t.type===uu.Wi&&n.type===uu.Wi?this.Ji=this.Ji.bt(e,{type:uu.Wi,doc:t.doc}):t.type===uu.Wi&&n.type===uu.Qi?this.Ji=this.Ji.bt(e,{type:uu.Qi,doc:t.doc}):t.type===uu.Gi&&n.type===uu.Qi?this.Ji=this.Ji.remove(e):t.type===uu.Gi&&n.type===uu.Wi?this.Ji=this.Ji.bt(e,{type:uu.Gi,doc:n.doc}):t.type===uu.Qi&&n.type===uu.Gi?this.Ji=this.Ji.bt(e,{type:uu.Wi,doc:t.doc}):jr("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n)):this.Ji=this.Ji.bt(e,t)},Nu.prototype.Yi=function(){var n=[];return this.Ji.Et(function(t,e){n.push(e)}),n},Nu),wu=(Au.ne=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:uu.Qi,doc:t})}),new Au(t,e,lu.qi(e),i,n,r,!0,!1)},Object.defineProperty(Au.prototype,"hasPendingWrites",{get:function(){return!this.$i.nt()},enumerable:!0,configurable:!0}),Au.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.Zi===t.Zi&&this.$i.isEqual(t.$i)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.Xi.isEqual(t.Xi)))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},Au),bu=(Tu.se=function(t,e){var n,r=((n={})[t]=Eu.oe(t,e),n);return new Tu(Bi.MIN,r,au(),$a(),ou())},Tu),Eu=(Iu.oe=function(t,e){return new Iu(zu(),e,ou(),ou(),ou())},Iu);function Iu(t,e,n,r,i){this.resumeToken=t,this.he=e,this.ce=n,this.ae=r,this.fe=i}function Tu(t,e,n,r,i){this.xi=t,this.ie=e,this.ee=n,this.re=r,this.ue=i}function Au(t,e,n,r,i,o,s,a){this.query=t,this.docs=e,this.Xi=n,this.docChanges=r,this.$i=i,this.fromCache=o,this.Zi=s,this.te=a}function Nu(){this.Ji=new Ki(Yi.X)}(mu=vu=vu||{})[mu.we=0]="__PRIVATE_NoChange",mu[mu.Qi=1]="__PRIVATE_Added",mu[mu.Gi=2]="__PRIVATE_Removed",mu[mu.me=3]="__PRIVATE_Current",mu[mu.pe=4]="__PRIVATE_Reset";function Su(t,e,n,r){void 0===n&&(n=zu()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}var Du=(Object.defineProperty(_u.prototype,"he",{get:function(){return this._e},enumerable:!0,configurable:!0}),Object.defineProperty(_u.prototype,"resumeToken",{get:function(){return this.ye},enumerable:!0,configurable:!0}),Object.defineProperty(_u.prototype,"Te",{get:function(){return 0!==this.ge},enumerable:!0,configurable:!0}),Object.defineProperty(_u.prototype,"Ee",{get:function(){return this.Ie},enumerable:!0,configurable:!0}),_u.prototype.Re=function(t){0<t.length&&(this.Ie=!0,this.ye=t)},_u.prototype.Ae=function(){var n=ou(),r=ou(),i=ou();return this.be.forEach(function(t,e){switch(e){case uu.Qi:n=n.add(t);break;case uu.Wi:r=r.add(t);break;case uu.Gi:i=i.add(t);break;default:jr("Encountered invalid change type: "+e)}}),new Eu(this.ye,this._e,n,r,i)},_u.prototype.De=function(){this.Ie=!1,this.be=xu()},_u.prototype.Pe=function(t,e){this.Ie=!0,this.be=this.be.bt(t,e)},_u.prototype.Se=function(t){this.Ie=!0,this.be=this.be.remove(t)},_u.prototype.Ce=function(){this.ge+=1},_u.prototype.Ve=function(){this.ge-=1},_u.prototype.ke=function(){this.Ie=!0,this._e=!0},_u),ku=(Ru.prototype.Ue=function(t){for(var e=0,n=t.le;e<n.length;e++){var r=n[e];t.de instanceof Us?this.Le(r,t.de):t.de instanceof Vs&&this.Be(r,t.key,t.de)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.Be(r,t.key,t.de)},Ru.prototype.Me=function(n){var r=this;this.qe(n,function(t){var e=r.Qe(t);switch(n.state){case vu.we:r.Ge(t)&&e.Re(n.resumeToken);break;case vu.Qi:e.Ve(),e.Te||e.De(),e.Re(n.resumeToken);break;case vu.Gi:e.Ve(),e.Te||r.removeTarget(t),Fr(!n.cause,"WatchChangeAggregator does not handle errored targets");break;case vu.me:r.Ge(t)&&(e.ke(),e.Re(n.resumeToken));break;case vu.pe:r.Ge(t)&&(r.We(t),e.Re(n.resumeToken));break;default:jr("Unknown target watch change state: "+n.state)}})},Ru.prototype.qe=function(t,e){0<t.targetIds.length?t.targetIds.forEach(e):gi(this.Oe,e)},Ru.prototype.ze=function(t){var e=t.targetId,n=t.ve.count,r=this.Ke(e);if(r){var i=r.target;if(i.Zn())if(0===n){var o=new Yi(i.path);this.Be(e,o,new Vs(o,Bi.K()))}else Fr(1===n,"Single document existence filter with count: "+n);else this.He(e)!==n&&(this.We(e),this.je=this.je.add(e))}},Ru.prototype.Je=function(i){var o=this,s={};gi(this.Oe,function(t,e){var n=o.Ke(t);if(n){if(e.he&&n.target.Zn()){var r=new Yi(n.target.path);null!==o.Fe.get(r)||o.Ye(t,r)||o.Be(t,r,new Vs(r,i))}e.Ee&&(s[t]=e.Ae(),e.De())}});var r=ou();this.xe.forEach(function(t,e){var n=!0;e.Kt(function(t){var e=o.Ke(t);return!e||e.Fi===fa.Oi||(n=!1)}),n&&(r=r.add(t))});var t=new bu(i,s,this.je,this.Fe,r);return this.Fe=$a(),this.xe=Cu(),this.je=new co(zr),t},Ru.prototype.Le=function(t,e){if(this.Ge(t)){var n=this.Ye(t,e.key)?uu.Wi:uu.Qi;this.Qe(t).Pe(e.key,n),this.Fe=this.Fe.bt(e.key,e),this.xe=this.xe.bt(e.key,this.Xe(e.key).add(t))}},Ru.prototype.Be=function(t,e,n){if(this.Ge(t)){var r=this.Qe(t);this.Ye(t,e)?r.Pe(e,uu.Gi):r.Se(e),this.xe=this.xe.bt(e,this.Xe(e).delete(t)),n&&(this.Fe=this.Fe.bt(e,n))}},Ru.prototype.removeTarget=function(t){delete this.Oe[t]},Ru.prototype.He=function(t){var e=this.Qe(t).Ae();return this.Ne.$e(t).size+e.ce.size-e.fe.size},Ru.prototype.Ce=function(t){this.Qe(t).Ce()},Ru.prototype.Qe=function(t){return this.Oe[t]||(this.Oe[t]=new Du),this.Oe[t]},Ru.prototype.Xe=function(t){var e=this.xe.get(t);return e||(e=new co(zr),this.xe=this.xe.bt(t,e)),e},Ru.prototype.Ge=function(t){var e=null!==this.Ke(t);return e||Mr("WatchChangeAggregator","Detected inactive target",t),e},Ru.prototype.Ke=function(t){var e=this.Oe[t];return e&&e.Te?null:this.Ne.Ze(t)},Ru.prototype.We=function(e){var n=this;Fr(!this.Oe[e].Te,"Should only reset active targets"),this.Oe[e]=new Du,this.Ne.$e(e).forEach(function(t){n.Be(e,t,null)})},Ru.prototype.Ye=function(t,e){return this.Ne.$e(t).has(e)},Ru);function Ru(t){this.Ne=t,this.Oe={},this.Fe=$a(),this.xe=Cu(),this.je=new co(zr)}function _u(){this.ge=0,this.be=xu(),this.ye=zu(),this._e=!1,this.Ie=!0}function Cu(){return new Ki(Yi.X)}function xu(){return new Ki(Yi.X)}var Pu,Ou,Lu=((Pu={})[Da.ASCENDING.name]="ASCENDING",Pu[Da.DESCENDING.name]="DESCENDING",Pu),qu=((Ou={})[ba.LESS_THAN.name]="LESS_THAN",Ou[ba.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",Ou[ba.GREATER_THAN.name]="GREATER_THAN",Ou[ba.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",Ou[ba.EQUAL.name]="EQUAL",Ou[ba.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",Ou[ba.IN.name]="IN",Ou[ba.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",Ou),Mu=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Uu(t,e){Fr(!oa(t),e+" is missing")}function Vu(t){return"number"==typeof t?t:"string"==typeof t?Number(t):jr("can't parse "+t)}var ju=(Bu.prototype.tr=function(){return this.options.nr?"":new Uint8Array(0)},Bu.prototype.ir=function(t){return t},Bu.prototype.er=function(t){var e=void 0===t.code?ii.UNKNOWN:Qa(t.code);return new oi(e,t.message||"")},Bu.prototype.rr=function(t){return this.options.nr||oa(t)?t:{value:t}},Bu.prototype.ur=function(t){var e;return oa(e="object"==typeof t?t.value:t)?null:e},Bu.prototype.J=function(t){return this.options.nr?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},Bu.prototype.W=function(t){if("string"==typeof t)return this.sr(t);Fr(!!t,"Cannot deserialize null or undefined timestamp.");var e=Vu(t.seconds||"0"),n=t.nanos||0;return new Gi(e,n)},Bu.prototype.sr=function(t){var e=0,n=Mu.exec(t);if(Fr(!!n,"invalid timestamp: "+t),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t),o=Math.floor(i.getTime()/1e3);return new Gi(o,e)},Bu.prototype.or=function(t){return this.options.nr?t.toBase64():this.ir(t.toUint8Array())},Bu.prototype.hr=function(t){return"string"==typeof t?(Fr(this.options.nr,"Expected bytes to be passed in as Uint8Array, but got a string instead."),Ju.fromBase64String(t)):(Fr(!this.options.nr,"Expected bytes to be passed in as Uint8Array, but got a string instead."),Ju.fromUint8Array(t))},Bu.prototype.toVersion=function(t){return this.J(t.J())},Bu.prototype.fromVersion=function(t){return Fr(!!t,"Trying to deserialize version that isn't set"),Bi.W(this.W(t))},Bu.prototype.cr=function(t,e){return this.ar(t).child("documents").child(e).ot()},Bu.prototype.lr=function(t){var e=Xi.ht(t);return Fr(this.dr(e),"Tried to deserialize invalid key "+e.toString()),e},Bu.prototype.vr=function(t){return this.cr(this.s,t.path)},Bu.prototype.wr=function(t){var e=this.lr(t);return Fr(e.get(1)===this.s.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.s.projectId),Fr(!e.get(3)&&!this.s.database||e.get(3)===this.s.database,"Tried to deserialize key from different database: "+e.get(3)+" vs "+this.s.database),new Yi(this.mr(e))},Bu.prototype.pr=function(t){return this.cr(this.s,t)},Bu.prototype.gr=function(t){var e=this.lr(t);return 4===e.length?Xi.ct:this.mr(e)},Object.defineProperty(Bu.prototype,"br",{get:function(){return new Xi(["projects",this.s.projectId,"databases",this.s.database]).ot()},enumerable:!0,configurable:!0}),Bu.prototype.ar=function(t){return new Xi(["projects",t.projectId,"databases",t.database])},Bu.prototype.mr=function(t){return Fr(4<t.length&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.Z(5)},Bu.prototype.dr=function(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)},Bu.prototype.yr=function(t){if(t instanceof os)return{nullValue:"NULL_VALUE"};if(t instanceof ss)return{booleanValue:t.value()};if(t instanceof Ds)return{integerValue:""+t.value()};if(t instanceof ks){var e=t.value();if(this.options.nr){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:t.value()}}return t instanceof Rs?{stringValue:t.value()}:t instanceof Ls?{mapValue:this._r(t)}:t instanceof qs?{arrayValue:this.Ir(t)}:t instanceof _s?{timestampValue:this.J(t.nn)}:t instanceof Os?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof xs?{bytesValue:this.or(t.value())}:t instanceof Ps?{referenceValue:this.cr(t.s,t.key.path)}:jr("Unknown FieldValue "+JSON.stringify(t))},Bu.prototype.Tr=function(t){var e=this;if("nullValue"in t)return os.Bn;if("booleanValue"in t)return ss.of(t.booleanValue);if("integerValue"in t)return new Ds(Vu(t.integerValue));if("doubleValue"in t){if(this.options.nr){if("NaN"===t.doubleValue)return ks.Qn;if("Infinity"===t.doubleValue)return ks.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return ks.NEGATIVE_INFINITY}return new ks(t.doubleValue)}if("stringValue"in t)return new Rs(t.stringValue);if("mapValue"in t)return this.Er(t.mapValue.fields||{});if("arrayValue"in t){Uu(t.arrayValue,"arrayValue");var n=t.arrayValue.values||[];return new qs(n.map(function(t){return e.Tr(t)}))}if("timestampValue"in t)return Uu(t.timestampValue,"timestampValue"),new _s(this.W(t.timestampValue));if("geoPointValue"in t){Uu(t.geoPointValue,"geoPointValue");var r=t.geoPointValue.latitude||0,i=t.geoPointValue.longitude||0;return new Os(new Fi(r,i))}if("bytesValue"in t){Uu(t.bytesValue,"bytesValue");var o=this.hr(t.bytesValue);return new xs(o)}if("referenceValue"in t){Uu(t.referenceValue,"referenceValue");var s=this.lr(t.referenceValue),a=new Zr(s.get(1),s.get(3)),u=new Yi(this.mr(s));return new Ps(a,u)}return jr("Unknown Value proto "+JSON.stringify(t))},Bu.prototype.Rr=function(t,e){return{name:this.vr(t),fields:this.Ar(e)}},Bu.prototype.Dr=function(t){return Fr(!t.vn,"Can't serialize documents with mutations."),{name:this.vr(t.key),fields:this.Ar(t.data()),updateTime:this.J(t.version.J())}},Bu.prototype.Pr=function(t,e){var n=this,r=this.wr(t.name),i=this.fromVersion(t.updateTime);return new Us(r,i,{hasCommittedMutations:!!e},void 0,t,function(t){return n.Tr(t)})},Bu.prototype.Ar=function(t){var n=this,r={};return t.forEach(function(t,e){r[t]=n.yr(e)}),r},Bu.prototype.Er=function(t){var n=this,e=t,r=Ls.EMPTY;return wi(e,function(t,e){r=r.set(new Hi([t]),n.Tr(e))}),r},Bu.prototype._r=function(t){return{fields:this.Ar(t)}},Bu.prototype.Ir=function(t){var e=this,n=[];return t.forEach(function(t){n.push(e.yr(t))}),{values:n}},Bu.prototype.Sr=function(t){var e=this;Fr(!!t.found,"Tried to deserialize a found document from a missing document."),Uu(t.found.name,"doc.found.name"),Uu(t.found.updateTime,"doc.found.updateTime");var n=this.wr(t.found.name),r=this.fromVersion(t.found.updateTime);return new Us(n,r,{},void 0,t.found,function(t){return e.Tr(t)})},Bu.prototype.Cr=function(t){Fr(!!t.missing,"Tried to deserialize a missing document from a found document."),Fr(!!t.readTime,"Tried to deserialize a missing document without a read time.");var e=this.wr(t.missing),n=this.fromVersion(t.readTime);return new Vs(e,n)},Bu.prototype.Vr=function(t){return"found"in t?this.Sr(t):"missing"in t?this.Cr(t):jr("invalid batch get response: "+JSON.stringify(t))},Bu.prototype.kr=function(t){switch(t){case vu.Qi:return"ADD";case vu.me:return"CURRENT";case vu.we:return"NO_CHANGE";case vu.Gi:return"REMOVE";case vu.pe:return"RESET";default:return jr("Unknown WatchTargetChangeState: "+t)}},Bu.prototype.Nr=function(t){if(t instanceof yu)return{filter:{count:t.ve.count,targetId:t.targetId}};if(t instanceof du){if(t.de instanceof Us){var e=t.de;return{documentChange:{document:{name:this.vr(e.key),fields:this.Ar(e.data()),updateTime:this.toVersion(e.version)},targetIds:t.le,removedTargetIds:t.removedTargetIds}}}if(t.de instanceof Vs)return e=t.de,{documentDelete:{document:this.vr(e.key),readTime:this.toVersion(e.version),removedTargetIds:t.removedTargetIds}};if(null===t.de)return{documentRemove:{document:this.vr(t.key),removedTargetIds:t.removedTargetIds}}}if(t instanceof Su){var n=void 0;return t.cause&&(n={code:function(t){if(void 0===t)return Ba.OK;switch(t){case ii.OK:return Ba.OK;case ii.CANCELLED:return Ba.CANCELLED;case ii.UNKNOWN:return Ba.UNKNOWN;case ii.DEADLINE_EXCEEDED:return Ba.DEADLINE_EXCEEDED;case ii.RESOURCE_EXHAUSTED:return Ba.RESOURCE_EXHAUSTED;case ii.INTERNAL:return Ba.INTERNAL;case ii.UNAVAILABLE:return Ba.UNAVAILABLE;case ii.UNAUTHENTICATED:return Ba.UNAUTHENTICATED;case ii.INVALID_ARGUMENT:return Ba.INVALID_ARGUMENT;case ii.NOT_FOUND:return Ba.NOT_FOUND;case ii.ALREADY_EXISTS:return Ba.ALREADY_EXISTS;case ii.PERMISSION_DENIED:return Ba.PERMISSION_DENIED;case ii.FAILED_PRECONDITION:return Ba.FAILED_PRECONDITION;case ii.ABORTED:return Ba.ABORTED;case ii.OUT_OF_RANGE:return Ba.OUT_OF_RANGE;case ii.UNIMPLEMENTED:return Ba.UNIMPLEMENTED;case ii.DATA_LOSS:return Ba.DATA_LOSS;default:return jr("Unknown status code: "+t)}}(t.cause.code),message:t.cause.message}),{targetChange:{targetChangeType:this.kr(t.state),targetIds:t.targetIds,resumeToken:this.ir(t.resumeToken),cause:n}}}return jr("Unrecognized watch change: "+JSON.stringify(t))},Bu.prototype.Or=function(t){var e,n=this;if("targetChange"in t){Uu(t.targetChange,"targetChange");var r=this.Fr(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],o=t.targetChange.resumeToken||this.tr(),s=t.targetChange.cause,a=s&&this.er(s);e=new Su(r,i,o,a||null)}else if("documentChange"in t){Uu(t.documentChange,"documentChange");var u=t.documentChange;Uu(u.document,"documentChange.name"),Uu(u.document.name,"documentChange.document.name"),Uu(u.document.updateTime,"documentChange.document.updateTime");var h=this.wr(u.document.name),c=this.fromVersion(u.document.updateTime),f=new Us(h,c,{},void 0,u.document,function(t){return n.Tr(t)}),l=u.targetIds||[],p=u.removedTargetIds||[];e=new du(l,p,f.key,f)}else if("documentDelete"in t){Uu(t.documentDelete,"documentDelete");var d=t.documentDelete;Uu(d.document,"documentDelete.document"),h=this.wr(d.document),c=d.readTime?this.fromVersion(d.readTime):Bi.K(),f=new Vs(h,c),p=d.removedTargetIds||[],e=new du([],p,f.key,f)}else if("documentRemove"in t){Uu(t.documentRemove,"documentRemove");var y=t.documentRemove;Uu(y.document,"documentRemove"),h=this.wr(y.document),p=y.removedTargetIds||[],e=new du([],p,h,null)}else{if(!("filter"in t))return jr("Unknown change type "+JSON.stringify(t));Uu(t.filter,"filter");var v=t.filter;Uu(v.targetId,"filter.targetId");var m=v.count||0,g=new Wa(m),w=v.targetId;e=new yu(w,g)}return e},Bu.prototype.Fr=function(t){return"NO_CHANGE"===t?vu.we:"ADD"===t?vu.Qi:"REMOVE"===t?vu.Gi:"CURRENT"===t?vu.me:"RESET"===t?vu.pe:jr("Got unexpected TargetChange.state: "+t)},Bu.prototype.xr=function(t){if(!("targetChange"in t))return Bi.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length?Bi.MIN:e.readTime?this.fromVersion(e.readTime):Bi.MIN},Bu.prototype.jr=function(t){var e,n=this;if(t instanceof Go)e={update:this.Rr(t.key,t.value)};else if(t instanceof Xo)e={delete:this.vr(t.key)};else if(t instanceof Bo)e={update:this.Rr(t.key,t.data),updateMask:this.Ur(t.mn)};else if(t instanceof zo)e={transform:{document:this.vr(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.Lr(t)})}};else{if(!(t instanceof Wo))return jr("Unknown mutation type "+t.type);e={verify:this.vr(t.key)}}return t.dn.cn||(e.currentDocument=this.Br(t.dn)),e},Bu.prototype.Mr=function(t){var e=this,n=t.currentDocument?this.qr(t.currentDocument):jo.NONE;if(t.update){Uu(t.update.name,"name");var r=this.wr(t.update.name),i=this.Er(t.update.fields||{});if(t.updateMask){var o=this.Qr(t.updateMask);return new Bo(r,i,o,n)}return new Go(r,i,n)}if(t.delete)return r=this.wr(t.delete),new Xo(r,n);if(t.transform){r=this.wr(t.transform.document);var s=t.transform.fieldTransforms.map(function(t){return e.Gr(t)});return Fr(!0===n.exists,'Transforms only support precondition "exists == true"'),new zo(r,s)}return t.verify?(r=this.wr(t.verify),new Wo(r,n)):jr("unknown mutation proto: "+JSON.stringify(t))},Bu.prototype.Br=function(t){return Fr(!t.cn,"Can't serialize an empty precondition"),void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:jr("Unknown precondition")},Bu.prototype.qr=function(t){return void 0!==t.updateTime?jo.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?jo.exists(t.exists):jo.NONE},Bu.prototype.Wr=function(t,e){var n=this,r=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);r.isEqual(Bi.MIN)&&(r=this.fromVersion(e));var i=null;return t.transformResults&&0<t.transformResults.length&&(i=t.transformResults.map(function(t){return n.Tr(t)})),new Ao(r,i)},Bu.prototype.zr=function(t,e){var n=this;return t&&0<t.length?(Fr(void 0!==e,"Received a write result without a commit time"),t.map(function(t){return n.Wr(t,e)})):[]},Bu.prototype.Lr=function(t){var e=this,n=t.transform;if(n instanceof lo)return{fieldPath:t.field.ot(),setToServerValue:"REQUEST_TIME"};if(n instanceof po)return{fieldPath:t.field.ot(),appendMissingElements:{values:n.elements.map(function(t){return e.yr(t)})}};if(n instanceof yo)return{fieldPath:t.field.ot(),removeAllFromArray:{values:n.elements.map(function(t){return e.yr(t)})}};if(n instanceof vo)return{fieldPath:t.field.ot(),increment:this.yr(n.tn)};throw jr("Unknown transform: "+t.transform)},Bu.prototype.Gr=function(t){var e=this,n=null;if("setToServerValue"in t)Fr("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),n=lo.instance;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new po(r.map(function(t){return e.Tr(t)}))}else if("removeAllFromArray"in t)r=t.removeAllFromArray.values||[],n=new yo(r.map(function(t){return e.Tr(t)}));else if("increment"in t){var i=this.Tr(t.increment);Fr(i instanceof as,"NUMERIC_ADD transform requires a NumberValue"),n=new vo(i)}else jr("Unknown transform proto: "+JSON.stringify(t));var o=Hi.dt(t.fieldPath);return new ko(o,n)},Bu.prototype.Kr=function(t){return{documents:[this.pr(t.path)]}},Bu.prototype.Hr=function(t){var e=t.documents.length;Fr(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return wa.oi(this.gr(n)).bi()},Bu.prototype.Jr=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(Fr(n.length%2==0,"Collection Group queries should be within a document path or root."),e.parent=this.pr(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(Fr(n.length%2!=0,"Document queries with filters are not supported."),e.parent=this.pr(n.tt()),e.structuredQuery.from=[{collectionId:n.et()}]);var r=this.Yr(t.filters);r&&(e.structuredQuery.where=r);var i=this.Xr(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.rr(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.$r(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.$r(t.endAt)),e},Bu.prototype.Zr=function(t){var e=this.gr(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(0<r){Fr(1===r,"StructuredQuery.from with more than one collection is not supported.");var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var s=[];n.where&&(s=this.tu(n.where));var a=[];n.orderBy&&(a=this.nu(n.orderBy));var u=null;n.limit&&(u=this.ur(n.limit));var h=null;n.startAt&&(h=this.iu(n.startAt));var c=null;return n.endAt&&(c=this.iu(n.endAt)),new wa(e,i,a,s,u,aa.ti,h,c).bi()},Bu.prototype.eu=function(t){var e=this.ru(t.Fi);return null==e?null:{"goog-listen-tags":e}},Bu.prototype.ru=function(t){switch(t){case fa.ki:return null;case fa.Ni:return"existence-filter-mismatch";case fa.Oi:return"limbo-document";default:return jr("Unrecognized query purpose: "+t)}},Bu.prototype.bi=function(t){var e,n=t.target;return(e=n.Zn()?{documents:this.Kr(n)}:{query:this.Jr(n)}).targetId=t.targetId,0<t.resumeToken.length&&(e.resumeToken=this.ir(t.resumeToken)),e},Bu.prototype.Yr=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof Ea?e.uu(t):jr("Unrecognized filter: "+JSON.stringify(t))});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},Bu.prototype.tu=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.su(t)]:void 0!==t.fieldFilter?[this.ou(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return e.tu(t)}).reduce(function(t,e){return t.concat(e)}):jr("Unknown filter: "+JSON.stringify(t)):[]},Bu.prototype.Xr=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.hu(t)})},Bu.prototype.nu=function(t){var e=this;return t.map(function(t){return e.cu(t)})},Bu.prototype.$r=function(t){var e=this;return{before:t.before,values:t.position.map(function(t){return e.yr(t)})}},Bu.prototype.iu=function(t){var e=this,n=!!t.before,r=t.values.map(function(t){return e.Tr(t)});return new ka(r,n)},Bu.prototype.au=function(t){return Lu[t.name]},Bu.prototype.fu=function(t){switch(t){case"ASCENDING":return Da.ASCENDING;case"DESCENDING":return Da.DESCENDING;default:return}},Bu.prototype.lu=function(t){return qu[t.name]},Bu.prototype.du=function(t){switch(t){case"EQUAL":return ba.EQUAL;case"GREATER_THAN":return ba.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return ba.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return ba.LESS_THAN;case"LESS_THAN_OR_EQUAL":return ba.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return ba.ARRAY_CONTAINS;case"IN":return ba.IN;case"ARRAY_CONTAINS_ANY":return ba.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return jr("Unspecified operator");default:return jr("Unknown operator")}},Bu.prototype.vu=function(t){return{fieldPath:t.ot()}},Bu.prototype.wu=function(t){return Hi.dt(t.fieldPath)},Bu.prototype.hu=function(t){return{field:this.vu(t.field),direction:this.au(t.dir)}},Bu.prototype.cu=function(t){return new Ra(this.wu(t.field),this.fu(t.direction))},Bu.prototype.ou=function(t){return Ea.create(this.wu(t.fieldFilter.field),this.du(t.fieldFilter.op),this.Tr(t.fieldFilter.value))},Bu.prototype.uu=function(t){if(t.op===ba.EQUAL){if(t.value.isEqual(ks.Qn))return{unaryFilter:{field:this.vu(t.field),op:"IS_NAN"}};if(t.value.isEqual(os.Bn))return{unaryFilter:{field:this.vu(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.vu(t.field),op:this.lu(t.op),value:this.yr(t.value)}}},Bu.prototype.su=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.wu(t.unaryFilter.field);return Ea.create(e,ba.EQUAL,ks.Qn);case"IS_NULL":var n=this.wu(t.unaryFilter.field);return Ea.create(n,ba.EQUAL,os.Bn);case"OPERATOR_UNSPECIFIED":return jr("Unspecified filter");default:return jr("Unknown filter")}},Bu.prototype.Ur=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.ot())}),{fieldPaths:e}},Bu.prototype.Qr=function(t){var e=(t.fieldPaths||[]).map(function(t){return Hi.dt(t)});return Do.en(e)},Bu),Fu=(Gu.mu=function(t){Gu.platform&&jr("Platform already defined"),Gu.platform=t},Gu.t=function(){return Gu.platform||jr("Platform not set"),Gu.platform},Gu);function Gu(){}function Bu(t,e){this.s=t,this.options=e}function zu(){return Fu.t().tr}function Xu(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new oi(ii.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function Wu(){if("undefined"==typeof Uint8Array)throw new oi(ii.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Hu(){if(!Fu.t().pu)throw new oi(ii.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}function Yu(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}var Ku,Qu,Ju=(Ih.fromBase64String=function(t){Ii("Blob.fromBase64String",arguments,1),Ni("Blob.fromBase64String","string",1,t),Hu();try{return new Ih(Fu.t().atob(t))}catch(t){throw new oi(ii.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Ih.fromUint8Array=function(t){if(Ii("Blob.fromUint8Array",arguments,1),Wu(),!(t instanceof Uint8Array))throw Li("Blob.fromUint8Array","Uint8Array",1,t);return new Ih(Array.prototype.map.call(t,function(t){return String.fromCharCode(t)}).join(""))},Ih.prototype.toBase64=function(){return Ii("Blob.toBase64",arguments,0),Hu(),Fu.t().btoa(this.gu)},Ih.prototype.toUint8Array=function(){Ii("Blob.toUint8Array",arguments,0),Wu();for(var t=new Uint8Array(this.gu.length),e=0;e<this.gu.length;e++)t[e]=this.gu.charCodeAt(e);return t},Ih.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Ih.prototype.isEqual=function(t){return this.gu===t.gu},Ih.prototype.Wn=function(){return 2*this.gu.length},Ih.prototype.q=function(t){return zr(this.gu,t.gu)},Ih),$u=Xu(Ju,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Zu=(Eh.prototype.get=function(t){var e=this.bu(t),n=this.yu[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],a=o[1];if(s.isEqual(t))return a}},Eh.prototype.has=function(t){return void 0!==this.get(t)},Eh.prototype.set=function(t,e){var n=this.bu(t),r=this.yu[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(r[i][0].isEqual(t))return void(r[i]=[t,e]);r.push([t,e])}else this.yu[n]=[[t,e]]},Eh.prototype.delete=function(t){var e=this.bu(t),n=this.yu[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(n[r][0].isEqual(t))return 1===n.length?delete this.yu[e]:n.splice(r,1),!0;return!1},Eh.prototype.forEach=function(a){wi(this.yu,function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],s=i[1];a(o,s)}})},Eh.prototype.nt=function(){return bi(this.yu)},Eh),th=(bh.prototype.$t=function(t,e,n){e&&Fr(e.key.isEqual(t),"applyToRemoteDocument: key "+t+" should match maybeDoc key\n "+e.key);var r=n._u;Fr(r.length===this.mutations.length,"Mismatch between mutations length\n ("+this.mutations.length+") and mutation results length\n ("+r.length+").");for(var i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var s=r[i];e=o.$t(e,s)}}return e},bh.prototype.Xt=function(t,e){e&&Fr(e.key.isEqual(t),"applyToLocalDocument: key "+t+" should match maybeDoc key\n "+e.key);for(var n=0,r=this.baseMutations;n<r.length;n++)(a=r[n]).key.isEqual(t)&&(e=a.Xt(e,e,this.Gn));for(var i=e,o=0,s=this.mutations;o<s.length;o++){var a;(a=s[o]).key.isEqual(t)&&(e=a.Xt(e,i,this.Gn))}return e},bh.prototype.Iu=function(n){var r=this,i=n;return this.mutations.forEach(function(t){var e=r.Xt(t.key,n.get(t.key));e&&(i=i.bt(t.key,e))}),i},bh.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},ou())},bh.prototype.isEqual=function(t){return this.batchId===t.batchId&&Xr(this.mutations,t.mutations)&&Xr(this.baseMutations,t.baseMutations)},bh),eh=(wh.from=function(t,e,n,r){Fr(t.mutations.length===n.length,"Mutations sent "+t.mutations.length+" must equal results received "+n.length);for(var i=ru(),o=t.mutations,s=0;s<o.length;s++)i=i.bt(o[s].key,n[s].version);return new wh(t,e,n,r,i)},wh),nh=(gh.prototype.nt=function(){return this.Ru.nt()},gh.prototype.Pu=function(t,e){var n=new rh(t,e);this.Ru=this.Ru.add(n),this.Au=this.Au.add(n)},gh.prototype.Su=function(t,e){var n=this;t.forEach(function(t){return n.Pu(t,e)})},gh.prototype.Cu=function(t,e){this.Vu(new rh(t,e))},gh.prototype.ku=function(t,e){var n=this;t.forEach(function(t){return n.Cu(t,e)})},gh.prototype.Nu=function(t){var e=this,n=Yi.EMPTY,r=new rh(n,t),i=new rh(n,t+1),o=[];return this.Au.zt([r,i],function(t){e.Vu(t),o.push(t.key)}),o},gh.prototype.Ou=function(){var e=this;this.Ru.forEach(function(t){return e.Vu(t)})},gh.prototype.Vu=function(t){this.Ru=this.Ru.delete(t),this.Au=this.Au.delete(t)},gh.prototype.Fu=function(t){var e=Yi.EMPTY,n=new rh(e,t),r=new rh(e,t+1),i=ou();return this.Au.zt([n,r],function(t){i=i.add(t.key)}),i},gh.prototype.xu=function(t){var e=new rh(t,0),n=this.Ru.Ht(e);return null!==n&&t.isEqual(n.key)},gh),rh=(mh.Kn=function(t,e){return Yi.X(t.key,e.key)||zr(t.ju,e.ju)},mh.Du=function(t,e){return zr(t.ju,e.ju)||Yi.X(t.key,e.key)},mh),ih=(vh.prototype.catch=function(t){return this.next(void 0,t)},vh.prototype.next=function(r,i){var o=this;return this.Mu&&jr("Called next() or catch() twice for PersistencePromise"),this.Mu=!0,this.Bu?this.error?this.qu(i,this.error):this.Qu(r,this.result):new vh(function(e,n){o.Uu=function(t){o.Qu(r,t).next(e,n)},o.Lu=function(t){o.qu(i,t).next(e,n)}})},vh.prototype.Gu=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},vh.prototype.Wu=function(t){try{var e=t();return e instanceof vh?e:vh.resolve(e)}catch(t){return vh.reject(t)}},vh.prototype.Qu=function(t,e){return t?this.Wu(function(){return t(e)}):vh.resolve(e)},vh.prototype.qu=function(t,e){return t?this.Wu(function(){return t(e)}):vh.reject(e)},vh.resolve=function(n){return new vh(function(t,e){t(n)})},vh.reject=function(n){return new vh(function(t,e){e(n)})},vh.zu=function(t){return new vh(function(e,n){var r=0,i=0,o=!1;t.forEach(function(t){++r,t.next(function(){++i,o&&i===r&&e()},function(t){return n(t)})}),o=!0,i===r&&e()})},vh.Ku=function(t){for(var n=vh.resolve(!1),e=function(e){n=n.next(function(t){return t?vh.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},vh.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.zu(i)},vh),oh=(Object.defineProperty(yh.prototype,"readTime",{get:function(){return Fr(void 0!==this.Yu,"Read time is not set. All removeEntry() calls must include a readTime if `trackRemovals` is used."),this.Yu},set:function(t){Fr(void 0===this.Yu||this.Yu.isEqual(t),"All changes in a RemoteDocumentChangeBuffer must have the same read time"),this.Yu=t},enumerable:!0,configurable:!0}),yh.prototype.Xu=function(t,e){this.$u(),this.readTime=e,this.Hu.set(t.key,t)},yh.prototype.Zu=function(t,e){this.$u(),e&&(this.readTime=e),this.Hu.set(t,null)},yh.prototype.ts=function(t,e){this.$u();var n=this.Hu.get(e);return void 0!==n?ih.resolve(n):this.ns(t,e)},yh.prototype.getEntries=function(t,e){return this.es(t,e)},yh.prototype.apply=function(t){return this.$u(),this.Ju=!0,this.rs(t)},yh.prototype.$u=function(){Fr(!this.Ju,"Changes have already been applied.")},yh),sh="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",ah=(dh.prototype.ss=function(t){this.us.push(t)},dh.prototype.os=function(){this.us.forEach(function(t){return t()})},dh),uh=(ph.prototype.fs=function(e,n){var r=this;return this.cs.ls(e,n).next(function(t){return r.ds(e,n,t)})},ph.prototype.ds=function(t,r,i){return this.hs.ts(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].Xt(r,t);return t})},ph.prototype.vs=function(t,e,i){var o=Za();return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].Xt(t,e);o=o.bt(t,e)}),o},ph.prototype.ws=function(e,t){var n=this;return this.hs.getEntries(e,t).next(function(t){return n.ms(e,t)})},ph.prototype.ms=function(r,i){var o=this;return this.cs.ps(r,i).next(function(t){var e=o.vs(r,i,t),n=$a();return e.forEach(function(t,e){e=e||new Vs(t,Bi.K()),n=n.bt(t,e)}),n})},ph.prototype.gs=function(t,e,n){return e.Zn()?this.bs(t,e.path):e.Pi()?this.ys(t,e,n):this._s(t,e,n)},ph.prototype.bs=function(t,e){return this.fs(t,new Yi(e)).next(function(t){var e=eu();return t instanceof Us&&(e=e.bt(t.key,t)),e})},ph.prototype.ys=function(n,r,i){var o=this;Fr(r.path.nt(),"Currently we only support collection group queries at the root.");var s=r.collectionGroup,a=eu();return this.as.Is(n,s).next(function(t){return ih.forEach(t,function(t){var e=r.pi(t.child(s));return o._s(n,e,i).next(function(t){t.forEach(function(t,e){a=a.bt(t,e)})})}).next(function(){return a})})},ph.prototype._s=function(e,n,t){var c,f,r=this;return this.hs.gs(e,n,t).next(function(t){return c=t,r.cs.Ts(e,n)}).next(function(t){return f=t,r.Es(e,f,c).next(function(t){c=t;for(var e=0,n=f;e<n.length;e++)for(var r=n[e],i=0,o=r.mutations;i<o.length;i++){var s=o[i],a=s.key,u=c.get(a),h=s.Xt(u,u,r.Gn);c=h instanceof Us?c.bt(a,h):c.remove(a)}})}).next(function(){return c.forEach(function(t,e){n.matches(e)||(c=c.remove(t))}),c})},ph.prototype.Es=function(t,e,n){for(var r=ou(),i=0,o=e;i<o.length;i++)for(var s=0,a=o[i].mutations;s<a.length;s++){var u=a[s];u instanceof Bo&&null===n.get(u.key)&&(r=r.add(u.key))}var h=n;return this.hs.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof Us&&(h=h.bt(t,e))}),h})},ph),hh=(lh.Ds=function(t,e){for(var n=ou(),r=ou(),i=0,o=e.docChanges;i<o.length;i++){var s=o[i];switch(s.type){case uu.Qi:n=n.add(s.doc.key);break;case uu.Gi:r=r.add(s.doc.key)}}return new lh(t,e.fromCache,n,r)},lh),ch=(fh.prototype.Ss=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},fh.prototype.next=function(){var t=++this.previousValue;return this.Cs&&this.Cs(t),t},fh.ks=-1,fh);function fh(t,e){var n=this;this.previousValue=t,e&&(e.Ps=function(t){return n.Ss(t)},this.Cs=function(t){return e.Vs(t)})}function lh(t,e,n,r){this.targetId=t,this.fromCache=e,this.Rs=n,this.As=r}function ph(t,e,n){this.hs=t,this.cs=e,this.as=n}function dh(){this.us=[]}function yh(){this.Hu=new Zu(function(t){return t.toString()}),this.Ju=!1}function vh(t){var e=this;this.Uu=null,this.Lu=null,this.result=void 0,this.error=void 0,this.Bu=!1,this.Mu=!1,t(function(t){e.Bu=!0,e.result=t,e.Uu&&e.Uu(t)},function(t){e.Bu=!0,e.error=t,e.Lu&&e.Lu(t)})}function mh(t,e){this.key=t,this.ju=e}function gh(){this.Ru=new co(rh.Kn),this.Au=new co(rh.Du)}function wh(t,e,n,r,i){this.batch=t,this.Tu=e,this._u=n,this.streamToken=r,this.Eu=i}function bh(t,e,n,r){this.batchId=t,this.Gn=e,this.baseMutations=n,Fr(0<(this.mutations=r).length,"Cannot create an empty mutation batch")}function Eh(t){this.bu=t,this.yu={}}function Ih(t){Hu(),this.gu=t}(Qu=Ku=Ku||{}).Ns="all",Qu.Os="listen_stream_idle",Qu.Fs="listen_stream_connection_backoff",Qu.xs="write_stream_idle",Qu.js="write_stream_connection_backoff",Qu.Us="online_state_timeout",Qu.Ls="client_metadata_refresh",Qu.Bs="lru_garbage_collection",Qu.Ms="retry_transaction";var Th=(Sh.Ks=function(t,e,n,r,i){var o=new Sh(t,e,Date.now()+n,r,i);return o.start(n),o},Sh.prototype.start=function(t){var e=this;this.Hs=setTimeout(function(){return e.Js()},t)},Sh.prototype.Ys=function(){return this.Js()},Sh.prototype.cancel=function(t){null!==this.Hs&&(this.clearTimeout(),this.zs.reject(new oi(ii.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},Sh.prototype.Js=function(){var e=this;this.qs.Xs(function(){return null!==e.Hs?(e.clearTimeout(),e.op().then(function(t){return e.zs.resolve(t)})):Promise.resolve()})},Sh.prototype.clearTimeout=function(){null!==this.Hs&&(this.Ws(this),clearTimeout(this.Hs),this.Hs=null)},Sh),Ah=(Object.defineProperty(Nh.prototype,"ro",{get:function(){return this.Zs},enumerable:!0,configurable:!0}),Nh.prototype.Xs=function(t){this.enqueue(t)},Nh.prototype.uo=function(t){this.so(),this.oo(t)},Nh.prototype.ho=function(t){return this.so(),this.oo(t)},Nh.prototype.co=function(e){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.so(),this.Zs?[3,2]:(this.Zs=!0,[4,this.ho(e)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},Nh.prototype.enqueue=function(t){return this.so(),this.Zs?new Promise(function(t){}):this.oo(t)},Nh.prototype.oo=function(t){var n=this,e=this.$s.then(function(){return n.io=!0,t().catch(function(t){n.no=t,n.io=!1;var e=t.stack||t.message||"";throw Ur("INTERNAL UNHANDLED ERROR: ",e),e.indexOf("Firestore Test Simulated Error")<0&&setTimeout(function(){throw t},0),t}).then(function(t){return n.io=!1,t})});return this.$s=e},Nh.prototype.ao=function(t,e,n){var r=this;this.so(),Fr(0<=e,"Attempted to schedule an operation with a negative delay of "+e),-1<this.eo.indexOf(t)&&(e=0);var i=Th.Ks(this,t,e,n,function(t){return r.fo(t)});return this.to.push(i),i},Nh.prototype.so=function(){this.no&&jr("AsyncQueue is already failed: "+(this.no.stack||this.no.message))},Nh.prototype.lo=function(){Fr(this.io,"verifyOpInProgress() called when no op in progress on this queue.")},Nh.prototype.do=function(){return this.ho(function(){return Promise.resolve()})},Nh.prototype.vo=function(t){for(var e=0,n=this.to;e<n.length;e++)if(n[e].Qs===t)return!0;return!1},Nh.prototype.wo=function(r){var i=this;return this.do().then(function(){Fr(r===Ku.Ns||i.vo(r),"Attempted to drain to missing operation "+r),i.to.sort(function(t,e){return t.Gs-e.Gs});for(var t=0,e=i.to;t<e.length;t++){var n=e[t];if(n.Ys(),r!==Ku.Ns&&n.Qs===r)break}return i.do()})},Nh.prototype.mo=function(t){this.eo.push(t)},Nh.prototype.fo=function(t){var e=this.to.indexOf(t);Fr(0<=e,"Delayed operation not found."),this.to.splice(e,1)},Nh);function Nh(){this.$s=Promise.resolve(),this.Zs=!1,this.to=[],this.no=null,this.io=!1,this.eo=[]}function Sh(t,e,n,r,i){this.qs=t,this.Qs=e,this.Gs=n,this.op=r,this.Ws=i,this.zs=new Yu,this.then=this.zs.promise.then.bind(this.zs.promise),this.catch=this.zs.promise.catch.bind(this.zs.promise),this.zs.promise.catch(function(t){})}function Dh(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=zr(n,i);return 0===s?zr(r,o):s}var kh=(Vh.prototype.yo=function(){return++this.bo},Vh.prototype._o=function(t){var e=[t,this.yo()];if(this.buffer.size<this.po)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();Dh(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(Vh.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),Vh),Rh={Io:!1,To:0,Eo:0,Ro:0},_h=(Uh.So=function(t){return new Uh(t,Uh.Co,Uh.Vo)},Uh.ko=-1,Uh.No=1048576,Uh.Fo=new Uh(Uh.Oo=41943040,Uh.Co=10,Uh.Vo=1e3),Uh.DISABLED=new Uh(Uh.ko,0,0),Uh),Ch=(Mh.prototype.start=function(){Fr(null===this.Lo,"Cannot start an already started LruScheduler"),this.xo.Bo.Ao!==_h.ko&&this.Mo()},Mh.prototype.stop=function(){this.Lo&&(this.Lo.cancel(),this.Lo=null)},Object.defineProperty(Mh.prototype,"qo",{get:function(){return null!==this.Lo},enumerable:!0,configurable:!0}),Mh.prototype.Mo=function(){var t=this;Fr(null===this.Lo,"Cannot schedule GC while a task is pending");var e=this.Uo?3e5:6e4;Mr("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.Lo=this.qs.ao(Ku.Bs,e,function(){return t.Lo=null,t.Uo=!0,t.jo.Qo(t.xo).then(function(){return t.Mo()}).catch(jh)})},Mh),xh=(qh.prototype.Wo=function(t,e){return this.Go.zo(t).next(function(t){return Math.floor(e/100*t)})},qh.prototype.Ko=function(t,e){var n=this;if(0===e)return ih.resolve(ch.ks);var r=new kh(e);return this.Go.qe(t,function(t){return r._o(t.sequenceNumber)}).next(function(){return n.Go.Ho(t,function(t){return r._o(t)})}).next(function(){return r.maxValue})},qh.prototype.Jo=function(t,e,n){return this.Go.Jo(t,e,n)},qh.prototype.Yo=function(t,e){return this.Go.Yo(t,e)},qh.prototype.Xo=function(e,n){var r=this;return this.Bo.Ao===_h.ko?(Mr("LruGarbageCollector","Garbage collection skipped; disabled"),ih.resolve(Rh)):this.$o(e).next(function(t){return t<r.Bo.Ao?(Mr("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.Bo.Ao),Rh):r.Zo(e,n)})},qh.prototype.$o=function(t){return this.Go.$o(t)},qh.prototype.Zo=function(e,n){var r,i,o,s,a,u,h,c=this,f=Date.now();return this.Wo(e,this.Bo.Do).next(function(t){return i=t>c.Bo.Po?(Mr("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+c.Bo.Po+" from "+t),c.Bo.Po):t,s=Date.now(),c.Ko(e,i)}).next(function(t){return r=t,a=Date.now(),c.Jo(e,r,n)}).next(function(t){return o=t,u=Date.now(),c.Yo(e,r)}).next(function(t){return h=Date.now(),Lr()<=Nr.DEBUG&&Mr("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-f)+"ms\n\tDetermined least recently used "+i+" in "+(a-s)+"ms\n\tRemoved "+o+" targets in "+(u-a)+"ms\n\tRemoved "+t+" documents in "+(h-u)+"ms\nTotal Duration: "+(h-f)+"ms"),ih.resolve({Io:!0,To:i,Eo:o,Ro:t})})},qh),Ph="LocalStore",Oh=(Lh.prototype.start=function(){return this.mh()},Lh.prototype.ph=function(i){return p(this,void 0,void 0,function(){var e,v,n,r=this;return y(this,function(t){switch(t.label){case 0:return e=this.cs,v=this.dh,[4,this.persistence.runTransaction("Handle user change","readonly-idempotent",function(d){var y;return r.cs.gh(d).next(function(t){return y=t,e=r.persistence.oh(i),v=new uh(r.hh,e,r.persistence.vh()),e.gh(d)}).next(function(t){for(var e=[],n=[],r=ou(),i=0,o=y;i<o.length;i++){var s=o[i];e.push(s.batchId);for(var a=0,u=s.mutations;a<u.length;a++){var h=u[a];r=r.add(h.key)}}for(var c=0,f=t;c<f.length;c++){s=f[c],n.push(s.batchId);for(var l=0,p=s.mutations;l<p.length;l++)h=p[l],r=r.add(h.key)}return v.ws(d,r).next(function(t){return{bh:t,yh:e,_h:n}})})})];case 1:return n=t.sent(),this.cs=e,this.dh=v,this.th.wh(this.dh),[2,n]}})})},Lh.prototype.Ih=function(a){var u,h=this,c=Gi.now(),t=a.reduce(function(t,e){return t.add(e.key)},ou());return this.persistence.runTransaction("Locally write mutations","readwrite-idempotent",function(s){return h.dh.ws(s,t).next(function(t){u=t;for(var e=[],n=0,r=a;n<r.length;n++){var i=r[n],o=i.wn(u.get(i.key));null!=o&&e.push(new Bo(i.key,o,o.mn(),jo.exists(!0)))}return h.cs.Th(s,c,e,a)})}).then(function(t){var e=t.Iu(u);return{batchId:t.batchId,Hu:e}})},Lh.prototype.Eh=function(t){var n=this;return this.persistence.runTransaction("Lookup mutation documents","readonly-idempotent",function(e){return n.cs.Rh(e,t).next(function(t){return t?n.dh.ws(e,t):ih.resolve(null)})})},Lh.prototype.Ah=function(r){var i=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary-idempotent",function(t){var e=r.batch.keys(),n=i.hh.Dh({Ph:!0});return i.cs.Ah(t,r.batch,r.streamToken).next(function(){return i.Sh(t,r,n)}).next(function(){return n.apply(t)}).next(function(){return i.cs.Ch(t)}).next(function(){return i.dh.ws(t,e)})})},Lh.prototype.Vh=function(t){var r=this;return this.persistence.runTransaction("Reject batch","readwrite-primary-idempotent",function(e){var n;return r.cs.kh(e,t).next(function(t){return Fr(null!==t,"Attempt to reject nonexistent batch!"),n=t.keys(),r.cs.Nh(e,t)}).next(function(){return r.cs.Ch(e)}).next(function(){return r.dh.ws(e,n)})})},Lh.prototype.Oh=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly-idempotent",function(t){return e.cs.Oh(t)})},Lh.prototype.Fh=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly-idempotent",function(t){return e.cs.Fh(t)})},Lh.prototype.xh=function(e){var n=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary-idempotent",function(t){return n.cs.xh(t,e)})},Lh.prototype.jh=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly-idempotent",function(t){return e.fh.jh(t)})},Lh.prototype.Uh=function(u){var h=this,c=u.xi,f=this.ih;return this.persistence.runTransaction("Apply remote event","readwrite-primary-idempotent",function(o){var i=h.hh.Dh({Ph:!0});f=h.ih;var s=[];gi(u.ie,function(t,e){var n=f.get(t);if(n){s.push(h.fh.Lh(o,e.fe,t).next(function(){return h.fh.Bh(o,e.ce,t)}));var r=e.resumeToken;if(0<r.length){var i=n.Ui(r,c).ji(o.Mh);f=f.bt(t,i),Lh.qh(n,i,e)&&s.push(h.fh.Qh(o,i))}}});var a=$a(),n=ou();if(u.re.forEach(function(t,e){n=n.add(t)}),s.push(i.getEntries(o,n).next(function(r){u.re.forEach(function(t,e){var n=r.get(t);e instanceof Vs&&e.version.isEqual(Bi.MIN)?(i.Zu(t,c),a=a.bt(t,e)):null==n||0<e.version.h(n.version)||0===e.version.h(n.version)&&n.hasPendingWrites?(Fr(!Bi.MIN.isEqual(c),"Cannot add a document when the remote version is zero"),i.Xu(e,c),a=a.bt(t,e)):Mr(Ph,"Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),u.ue.has(t)&&s.push(h.persistence.sh.Gh(o,t))})})),!c.isEqual(Bi.MIN)){var t=h.fh.jh(o).next(function(t){return Fr(0<=c.h(t),"Watch stream reverted to previous snapshot?? "+c+" < "+t),h.fh.Wh(o,o.Mh,c)});s.push(t)}return ih.zu(s).next(function(){return i.apply(o)}).next(function(){return h.dh.ms(o,a)})}).then(function(t){return h.ih=f,t})},Lh.qh=function(t,e,n){return Fr(0<e.resumeToken.length,"Attempted to persist target data with no resume token"),0===t.resumeToken.length||e.xi.H()-t.xi.H()>=this.zh||0<n.ce.size+n.ae.size+n.fe.size},Lh.prototype.Kh=function(t){for(var n=this,e=0,r=t;e<r.length;e++){var i=r[e],o=i.targetId;if(this.nh.Su(i.Rs,o),this.nh.ku(i.As,o),!i.fromCache){var s=this.ih.get(o);Fr(null!==s,"Can't set limbo-free snapshot version for unknown target: "+o);var a=s.xi,u=s.Li(a);this.ih=this.ih.bt(o,u)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite-idempotent",function(e){return ih.forEach(t,function(t){return ih.forEach(t.As,function(t){return n.persistence.sh.Cu(e,t)})})})},Lh.prototype.Hh=function(e){var n=this;return this.persistence.runTransaction("Get next mutation batch","readonly-idempotent",function(t){return void 0===e&&(e=-1),n.cs.Jh(t,e)})},Lh.prototype.Yh=function(e){var n=this;return this.persistence.runTransaction("read document","readonly-idempotent",function(t){return n.dh.fs(t,e)})},Lh.prototype.Xh=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite-idempotent",function(e){var n;return i.fh.$h(e,r).next(function(t){return t?(n=t,ih.resolve(n)):i.fh.Zh(e).next(function(t){return n=new Xa(r,t,fa.ki,e.Mh),i.fh.tc(e,n).next(function(){return n})})})}).then(function(t){return null===i.ih.get(t.targetId)&&(i.ih=i.ih.bt(t.targetId,t),i.eh.set(r,t.targetId)),t})},Lh.prototype.$h=function(t,e){var n=this.eh.get(e);return void 0!==n?ih.resolve(this.ih.get(n)):this.fh.$h(t,e)},Lh.prototype.nc=function(n,r){var i=this,o=this.ih.get(n);Fr(null!==o,"Tried to release nonexistent target: "+n);var t=r?"readwrite-idempotent":"readwrite-primary-idempotent";return this.persistence.runTransaction("Release target",t,function(e){var t=i.nh.Nu(n);return r?ih.resolve():ih.forEach(t,function(t){return i.persistence.sh.Cu(e,t)}).next(function(){i.persistence.sh.removeTarget(e,o)})}).then(function(){i.ih=i.ih.remove(n),i.eh.delete(o.target)})},Lh.prototype.ic=function(t,n){var r=this,i=Bi.MIN,o=ou();return this.persistence.runTransaction("Execute query","readonly-idempotent",function(e){return r.$h(e,t.bi()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.fh.ec(e,t.targetId).next(function(t){o=t})}).next(function(){return r.th.gs(e,t,n?i:Bi.MIN,n?o:ou())}).next(function(t){return{documents:t,rc:o}})})},Lh.prototype.uc=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly-idempotent",function(t){return n.fh.ec(t,e)})},Lh.prototype.sc=function(){return this.persistence.sc()},Lh.prototype.oc=function(t){this.cs.hc(t)},Lh.prototype.cc=function(t){this.persistence.cc(t)},Lh.prototype.Sh=function(t,i,o){var e=this,s=i.batch,n=s.keys(),a=ih.resolve();return n.forEach(function(r){a=a.next(function(){return o.ts(t,r)}).next(function(t){var e=t,n=i.Eu.get(r);Fr(null!==n,"ackVersions should contain every doc in the write."),(!e||e.version.h(n)<0)&&((e=s.$t(r,e,i))?o.Xu(e,i.Tu):Fr(!t,"Mutation batch "+s+" applied to document "+t+" resulted in null"))})}),a.next(function(){return e.cs.Nh(t,s)})},Lh.prototype.Qo=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary-idempotent",function(t){return e.Xo(t,n.ih)})},Lh.prototype.ac=function(e){var n=this,t=this.ih.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly-idempotent",function(t){return n.fh.Ze(t,e).next(function(t){return t?t.target:null})})},Lh.prototype.fc=function(){var r=this;return this.persistence.runTransaction("Get new document changes","readonly-idempotent",function(t){return r.hh.fc(t,r.rh)}).then(function(t){var e=t.lc,n=t.readTime;return r.rh=n,e})},Lh.prototype.mh=function(){return p(this,void 0,void 0,function(){var e,n=this;return y(this,function(t){switch(t.label){case 0:return[4,(e=this).persistence.runTransaction("Synchronize last document change read time","readonly-idempotent",function(t){return n.hh.dc(t)})];case 1:return e.rh=t.sent(),[2]}})})},Lh.zh=3e8,Lh);function Lh(t,e,n){this.persistence=t,this.th=e,this.nh=new nh,this.ih=new Ki(zr),this.eh=new Zu(function(t){return t.canonicalId()}),this.rh=Bi.MIN,Fr(t.qo,"LocalStore was passed an unstarted persistence implementation"),this.persistence.sh.uh(this.nh),this.cs=t.oh(n),this.hh=t.ah(),this.fh=t.lh(),this.dh=new uh(this.hh,this.cs,this.persistence.vh()),this.th.wh(this.dh)}function qh(t,e){this.Go=t,this.Bo=e}function Mh(t,e,n){this.xo=t,this.qs=e,this.jo=n,this.Uo=!1,this.Lo=null}function Uh(t,e,n){this.Ao=t,this.Do=e,this.Po=n}function Vh(t){this.po=t,this.buffer=new co(Dh),this.bo=0}function jh(e){return p(this,void 0,void 0,function(){return y(this,function(t){if(e.code!==ii.FAILED_PRECONDITION||e.message!==sh)throw e;return Mr(Ph,"Unexpectedly lost primary lease"),[2]})})}var Fh=(Bh.documentId=function(){return Bh.wc},Bh.prototype.isEqual=function(t){if(!(t instanceof Bh))throw Li("isEqual","FieldPath",1,t);return this.vc.isEqual(t.vc)},Bh.wc=new Bh(Hi.lt().ot()),Bh),Gh=new RegExp("[~\\*/\\[\\]]");function Bh(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(){if(!(t instanceof Array)||t.length<1)throw new oi(ii.INVALID_ARGUMENT,"Function FieldPath() requires its fieldNames argument to be an array with at least "+Ui(1,"element")+".")}();for(var n=0;n<t.length;++n)if(Ni("FieldPath","string",n,t[n]),0===t[n].length)throw new oi(ii.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.vc=new Hi(t)}var zh,Xh,Wh,Hh,Yh,Kh,Qh,Jh=(dc.delete=function(){return Ei("FieldValue.delete",arguments),$h.instance},dc.serverTimestamp=function(){return Ei("FieldValue.serverTimestamp",arguments),Zh.instance},dc.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ti("FieldValue.arrayUnion",arguments,1),new tc(t)},dc.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ti("FieldValue.arrayRemove",arguments,1),new ec(t)},dc.increment=function(t){return Ni("FieldValue.increment","number",1,t),Ii("FieldValue.increment",arguments,1),new nc(t)},dc.prototype.isEqual=function(t){return this===t},dc),$h=(t(pc,Qh=Jh),pc.instance=new pc,pc),Zh=(t(lc,Kh=Jh),lc.instance=new lc,lc),tc=(t(fc,Yh=Jh),fc),ec=(t(cc,Hh=Jh),cc),nc=(t(hc,Wh=Jh),hc),rc=Xu(Jh,"Use FieldValue.<field>() instead."),ic=/^__.*__$/,oc=(uc.prototype.bc=function(t,e){var n=[];return null!==this.mn?n.push(new Bo(t,this.data,this.mn,e)):n.push(new Go(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new zo(t,this.fieldTransforms)),n},uc),sc=(ac.prototype.bc=function(t,e){var n=[new Bo(t,this.data,this.mn,e)];return 0<this.fieldTransforms.length&&n.push(new zo(t,this.fieldTransforms)),n},ac);function ac(t,e,n){this.data=t,this.mn=e,this.fieldTransforms=n}function uc(t,e,n){this.data=t,this.mn=e,this.fieldTransforms=n}function hc(t){var e=Wh.call(this,"FieldValue.increment")||this;return e.gc=t,e}function cc(t){var e=Hh.call(this,"FieldValue.arrayRemove")||this;return e.pc=t,e}function fc(t){var e=Yh.call(this,"FieldValue.arrayUnion")||this;return e.pc=t,e}function lc(){return Kh.call(this,"FieldValue.serverTimestamp")||this}function pc(){return Qh.call(this,"FieldValue.delete")||this}function dc(t){this.mc=t}function yc(t){switch(t){case zh.Set:case zh.yc:case zh._c:return!0;case zh.Ic:case zh.Tc:return!1;default:throw jr("Unexpected case for UserDataSource: "+t)}}(Xh=zh=zh||{})[Xh.Set=0]="Set",Xh[Xh._c=1]="__PRIVATE_Update",Xh[Xh.yc=2]="__PRIVATE_MergeSet",Xh[Xh.Ic=3]="__PRIVATE_Argument",Xh[Xh.Tc=4]="__PRIVATE_ArrayArgument";var vc=(bc.prototype.Dc=function(t){var e=null==this.path?null:this.path.child(t),n=new bc(this.Ec,this.methodName,e,!1,this.fieldTransforms,this.mn);return n.Pc(t),n},bc.prototype.Sc=function(t){var e=null==this.path?null:this.path.child(t),n=new bc(this.Ec,this.methodName,e,!1,this.fieldTransforms,this.mn);return n.Ac(),n},bc.prototype.Cc=function(t){return new bc(this.Ec,this.methodName,null,!0,this.fieldTransforms,this.mn)},bc.prototype.Vc=function(t){var e=null===this.path||this.path.nt()?"":" (found in field "+this.path.toString()+")";return new oi(ii.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},bc.prototype.contains=function(e){return void 0!==this.mn.find(function(t){return e.rt(t)})||void 0!==this.fieldTransforms.find(function(t){return e.rt(t.field)})},bc.prototype.Ac=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.Pc(this.path.get(t))},bc.prototype.Pc=function(t){if(0===t.length)throw this.Vc("Document fields must not be empty");if(yc(this.Ec)&&ic.test(t))throw this.Vc('Document fields cannot begin and end with "__"')},bc),mc=function(t,e){this.s=t,this.key=e},gc=(wc.prototype.Nc=function(t,e){var n=new vc(zh.Set,t,Hi.ct);Ic("Data must be an object, but it was:",n,e);var r=this.Oc(e,n);return new oc(r,null,n.fieldTransforms)},wc.prototype.Fc=function(t,e,n){var r=new vc(zh.yc,t,Hi.ct);Ic("Data must be an object, but it was:",r,e);var i,o,s=this.Oc(e,r);if(n){for(var a=new co(Hi.X),u=0,h=n;u<h.length;u++){var c=h[u],f=void 0;if(c instanceof Fh)f=c.vc;else{if("string"!=typeof c)throw jr("Expected stringOrFieldPath to be a string or a FieldPath");f=Ac(t,c)}if(!r.contains(f))throw new oi(ii.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");a=a.add(f)}i=Do.in(a),o=r.fieldTransforms.filter(function(t){return i.rn(t.field)})}else i=Do.en(r.mn),o=r.fieldTransforms;return new oc(s,i,o)},wc.prototype.xc=function(o,t){var s=this,a=new vc(zh._c,o,Hi.ct);Ic("Data must be an object, but it was:",a,t);var u=new co(Hi.X),h=Ls.EMPTY;wi(t,function(t,e){var n=Ac(o,t),r=a.Sc(n);if((e=s.jc(e,r))instanceof $h)u=u.add(n);else{var i=s.Oc(e,r);null!=i&&(u=u.add(n),h=h.set(n,i))}});var e=Do.in(u);return new sc(h,e,a.fieldTransforms)},wc.prototype.Uc=function(t,e,n,r){var i=new vc(zh._c,t,Hi.ct),o=[Tc(t,e)],s=[n];if(r.length%2!=0)throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var a=0;a<r.length;a+=2)o.push(Tc(t,r[a])),s.push(r[a+1]);var u=new co(Hi.X),h=Ls.EMPTY;for(a=0;a<o.length;++a){var c=o[a],f=i.Sc(c),l=this.jc(s[a],f);if(l instanceof $h)u=u.add(c);else{var p=this.Oc(l,f);null!=p&&(u=u.add(c),h=h.set(c,p))}}var d=Do.in(u);return new sc(h,d,i.fieldTransforms)},wc.prototype.Lc=function(t,e,n){void 0===n&&(n=!1);var r=new vc(n?zh.Tc:zh.Ic,t,Hi.ct),i=this.Oc(e,r);return Fr(null!=i,"Parsed data should not be null."),Fr(0===r.fieldTransforms.length,"Field transforms should have been disallowed."),i},wc.prototype.jc=function(t,e){try{return this.kc(t)}catch(t){var n=Nc(t);throw e.Vc(n)}},wc.prototype.Oc=function(t,e){if(Ec(t=this.jc(t,e)))return Ic("Unsupported field value:",e,t),this.Bc(t,e);if(t instanceof Jh)return this.Mc(t,e),null;if(e.path&&e.mn.push(e.path),t instanceof Array){if(e.Rc&&e.Ec!==zh.Tc)throw e.Vc("Nested arrays are not supported");return this.qc(t,e)}return this.Qc(t,e)},wc.prototype.Bc=function(t,r){var i=this,o=new Ki(zr);return bi(t)?r.path&&0<r.path.length&&r.mn.push(r.path):wi(t,function(t,e){var n=i.Oc(e,r.Dc(t));null!=n&&(o=o.bt(t,n))}),new Ls(o)},wc.prototype.qc=function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=o[i],a=this.Oc(s,e.Cc(r));null==a&&(a=os.Bn),n.push(a),r++}return new qs(n)},wc.prototype.Mc=function(t,e){if(!yc(e.Ec))throw e.Vc(t.mc+"() can only be used with update() and set()");if(null===e.path)throw e.Vc(t.mc+"() is not currently supported inside arrays");if(t instanceof $h){if(e.Ec!==zh.yc)throw e.Ec===zh._c?(Fr(0<e.path.length,"FieldValue.delete() at the top level should have already been handled."),e.Vc("FieldValue.delete() can only appear at the top level of your update data")):e.Vc("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");e.mn.push(e.path)}else if(t instanceof Zh)e.fieldTransforms.push(new ko(e.path,lo.instance));else if(t instanceof tc){var n=this.Gc(t.mc,t.pc),r=new po(n);e.fieldTransforms.push(new ko(e.path,r))}else if(t instanceof ec){n=this.Gc(t.mc,t.pc);var i=new yo(n);e.fieldTransforms.push(new ko(e.path,i))}else if(t instanceof nc){var o=this.Lc("FieldValue.increment",t.gc),s=new vo(o);e.fieldTransforms.push(new ko(e.path,s))}else jr("Unknown FieldValue type: "+t)},wc.prototype.Qc=function(t,e){if(null===t)return os.Bn;if("number"==typeof t)return sa(t)?new Ds(t):new ks(t);if("boolean"==typeof t)return ss.of(t);if("string"==typeof t)return new Rs(t);if(t instanceof Date)return new _s(Gi.fromDate(t));if(t instanceof Gi)return new _s(new Gi(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)));if(t instanceof Fi)return new Os(t);if(t instanceof Ju)return new xs(t);if(t instanceof mc)return new Ps(t.s,t.key);throw e.Vc("Unsupported field value: "+xi(t))},wc.prototype.Gc=function(r,t){var i=this;return t.map(function(t,e){var n=new vc(zh.Ic,r,Hi.ct);return i.Oc(t,n.Cc(e))})},wc);function wc(t){this.kc=t}function bc(t,e,n,r,i,o){this.Ec=t,this.methodName=e,this.path=n,this.Rc=r,void 0===i&&this.Ac(),this.Rc=void 0!==r&&r,this.fieldTransforms=i||[],this.mn=o||[]}function Ec(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Gi||t instanceof Fi||t instanceof Ju||t instanceof mc||t instanceof Jh)}function Ic(t,e,n){if(!Ec(n)||!Ci(n)){var r=xi(n);throw"an object"===r?e.Vc(t+" a custom object"):e.Vc(t+" "+r)}}function Tc(t,e){if(e instanceof Fh)return e.vc;if("string"==typeof e)return Ac(t,e);throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Ac(e,t){try{return function(e){if(0<=e.search(Gh))throw new oi(ii.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(Fh.bind.apply(Fh,s([void 0],e.split("."))))}catch(t){throw new oi(ii.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(t).vc}catch(t){var n=Nc(t);throw new oi(ii.INVALID_ARGUMENT,"Function "+e+"() called with invalid data. "+n)}}function Nc(t){return t instanceof Error?t.message:t.toString()}var Sc,Dc,kc=(Rc.prototype.reset=function(){this.Jc=0},Rc.prototype.$c=function(){this.Jc=this.Hc},Rc.prototype.Zc=function(t){var e=this;this.cancel();var n=Math.floor(this.Jc+this.ta()),r=Math.max(0,Date.now()-this.Xc),i=Math.max(0,n-r);0<this.Jc&&Mr("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Jc+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Yc=this.Wc.ao(this.Qs,i,function(){return e.Xc=Date.now(),t()}),this.Jc*=this.Kc,this.Jc<this.zc&&(this.Jc=this.zc),this.Jc>this.Hc&&(this.Jc=this.Hc)},Rc.prototype.cancel=function(){null!==this.Yc&&(this.Yc.cancel(),this.Yc=null)},Rc.prototype.ta=function(){return(Math.random()-.5)*this.Jc},Rc);function Rc(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Wc=t,this.Qs=e,this.zc=n,this.Kc=r,this.Hc=i,this.Jc=0,this.Yc=null,this.Xc=Date.now(),this.reset()}(Dc=Sc=Sc||{})[Dc.na=0]="__PRIVATE_Initial",Dc[Dc.ia=1]="__PRIVATE_Starting",Dc[Dc.ea=2]="__PRIVATE_Open",Dc[Dc.Error=3]="Error",Dc[Dc.ra=4]="__PRIVATE_Backoff";var _c,Cc,xc=(Hc.prototype.fa=function(){return this.state===Sc.ia||this.state===Sc.ea||this.state===Sc.ra},Hc.prototype.la=function(){return this.state===Sc.ea},Hc.prototype.start=function(){this.state!==Sc.Error?(Fr(this.state===Sc.na,"Already started"),this.auth()):this.da()},Hc.prototype.stop=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.fa()?[4,this.close(Sc.na)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Hc.prototype.va=function(){Fr(!this.fa(),"Can only inhibit backoff in a stopped state"),this.state=Sc.na,this.aa.reset()},Hc.prototype.wa=function(){var t=this;this.la()&&null===this.ca&&(this.ca=this.Wc.ao(this.ua,6e4,function(){return t.ma()}))},Hc.prototype.pa=function(t){this.ga(),this.stream.send(t)},Hc.prototype.ma=function(){return p(this,void 0,void 0,function(){return y(this,function(t){return this.la()?[2,this.close(Sc.na)]:[2]})})},Hc.prototype.ga=function(){this.ca&&(this.ca.cancel(),this.ca=null)},Hc.prototype.close=function(e,n){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return Fr(this.fa(),"Only started streams should be closed."),Fr(e===Sc.Error||oa(n),"Can't provide an error when not in an error state."),this.ga(),this.aa.cancel(),this.ha++,e!==Sc.Error?this.aa.reset():n&&n.code===ii.RESOURCE_EXHAUSTED?(Ur(n.toString()),Ur("Using maximum backoff delay to prevent overloading the backend."),this.aa.$c()):n&&n.code===ii.UNAUTHENTICATED&&this.oa.P(),null!==this.stream&&(this.ba(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.ya(n)];case 1:return t.sent(),[2]}})})},Hc.prototype.ba=function(){},Hc.prototype.auth=function(){var n=this;Fr(this.state===Sc.na,"Must be in initial state to auth"),this.state=Sc.ia;var t=this._a(this.ha),e=this.ha;this.oa.getToken().then(function(t){n.ha===e&&n.Ia(t)},function(e){t(function(){var t=new oi(ii.UNKNOWN,"Fetching auth token failed: "+e.message);return n.Ta(t)})})},Hc.prototype.Ia=function(t){var e=this;Fr(this.state===Sc.ia,"Trying to start stream in a non-starting state");var n=this._a(this.ha);this.stream=this.Ea(t),this.stream.Ra(function(){n(function(){return Fr(e.state===Sc.ia,"Expected stream to be in state Starting, but was "+e.state),e.state=Sc.ea,e.listener.Ra()})}),this.stream.ya(function(t){n(function(){return e.Ta(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Hc.prototype.da=function(){var t=this;Fr(this.state===Sc.Error,"Should only perform backoff when in Error state"),this.state=Sc.ra,this.aa.Zc(function(){return p(t,void 0,void 0,function(){return y(this,function(t){return Fr(this.state===Sc.ra,"Backoff elapsed but state is now: "+this.state),this.state=Sc.na,this.start(),Fr(this.fa(),"PersistentStream should have started"),[2]})})})},Hc.prototype.Ta=function(t){return Fr(this.fa(),"Can't handle server close on non-started stream"),Mr("PersistentStream","close with error: "+t),this.stream=null,this.close(Sc.Error,t)},Hc.prototype._a=function(e){var n=this;return function(t){n.Wc.Xs(function(){return n.ha===e?t():(Mr("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Hc),Pc=(t(Wc,Cc=xc),Wc.prototype.Ea=function(t){return this.sa.Aa("Listen",t)},Wc.prototype.onMessage=function(t){this.aa.reset();var e=this.serializer.Or(t),n=this.serializer.xr(t);return this.listener.Da(e,n)},Wc.prototype.Pa=function(t){var e={};e.database=this.serializer.br,e.addTarget=this.serializer.bi(t);var n=this.serializer.eu(t);n&&(e.labels=n),this.pa(e)},Wc.prototype.Sa=function(t){var e={};e.database=this.serializer.br,e.removeTarget=t,this.pa(e)},Wc),Oc=(t(Xc,_c=xc),Object.defineProperty(Xc.prototype,"Va",{get:function(){return this.Ca},enumerable:!0,configurable:!0}),Xc.prototype.start=function(){this.Ca=!1,_c.prototype.start.call(this)},Xc.prototype.ba=function(){this.Ca&&this.ka([])},Xc.prototype.Ea=function(t){return this.sa.Aa("Write",t)},Xc.prototype.onMessage=function(t){if(Fr(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.Ca){this.aa.reset();var e=this.serializer.zr(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.Na(n,e)}return Fr(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.Ca=!0,this.listener.Oa()},Xc.prototype.Fa=function(){Fr(this.la(),"Writing handshake requires an opened stream"),Fr(!this.Ca,"Handshake already completed");var t={};t.database=this.serializer.br,this.pa(t)},Xc.prototype.ka=function(t){var e=this;Fr(this.la(),"Writing mutations requires an opened stream"),Fr(this.Ca,"Handshake must be complete before writing mutations"),Fr(0<this.lastStreamToken.length,"Trying to write mutation without a token");var n={streamToken:this.lastStreamToken,writes:t.map(function(t){return e.serializer.jr(t)})};this.pa(n)},Xc),Lc=(zc.prototype.xa=function(t){return new Oc(this.Wc,this.sa,this.credentials,this.serializer,t)},zc.prototype.ja=function(t){return new Pc(this.Wc,this.sa,this.credentials,this.serializer,t)},zc.prototype.commit=function(t){var e=this,n={database:this.serializer.br,writes:t.map(function(t){return e.serializer.jr(t)})};return this.Ua("Commit",n).then(function(t){return e.serializer.zr(t.writeResults,t.commitTime)})},zc.prototype.La=function(e){var i=this,t={database:this.serializer.br,documents:e.map(function(t){return i.serializer.vr(t)})};return this.Ba("BatchGetDocuments",t).then(function(t){var n=$a();t.forEach(function(t){var e=i.serializer.Vr(t);n=n.bt(e.key,e)});var r=[];return e.forEach(function(t){var e=n.get(t);Fr(!!e,"Missing entity in write response for "+t),r.push(e)}),r})},zc.prototype.Ua=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.sa.Ua(e,n,t)}).catch(function(t){throw t.code===ii.UNAUTHENTICATED&&r.credentials.P(),t})},zc.prototype.Ba=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.sa.Ba(e,n,t)}).catch(function(t){throw t.code===ii.UNAUTHENTICATED&&r.credentials.P(),t})},zc),qc=(Bc.prototype.La=function(r){return p(this,void 0,void 0,function(){var e,n=this;return y(this,function(t){switch(t.label){case 0:if(this.za(),0<this.mutations.length)throw new oi(ii.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,this.Ma.La(r)];case 1:return(e=t.sent()).forEach(function(t){t instanceof Vs||t instanceof Us?n.Ka(t):jr("Document in a transaction was a "+t.constructor.name)}),[2,e]}})})},Bc.prototype.set=function(t,e){this.write(e.bc(t,this.dn(t))),this.Wa.add(t)},Bc.prototype.update=function(t,e){try{this.write(e.bc(t,this.Ha(t)))}catch(t){this.Ga=t}this.Wa.add(t)},Bc.prototype.delete=function(t){this.write([new Xo(t,this.dn(t))]),this.Wa.add(t)},Bc.prototype.commit=function(){return p(this,void 0,void 0,function(){var e,n=this;return y(this,function(t){switch(t.label){case 0:if(this.za(),this.Ga)throw this.Ga;return e=this.qa,this.mutations.forEach(function(t){e=e.remove(t.key)}),e.forEach(function(t,e){n.mutations.push(new Wo(t,n.dn(t)))}),[4,this.Ma.commit(this.mutations)];case 1:return t.sent(),this.Qa=!0,[2]}})})},Bc.prototype.Ka=function(t){var e;if(t instanceof Us)e=t.version;else{if(!(t instanceof Vs))throw jr("Document in a transaction was a "+t.constructor.name);e=Bi.K()}var n=this.qa.get(t.key);if(null!==n){if(!e.isEqual(n))throw new oi(ii.ABORTED,"Document version changed between two reads.")}else this.qa=this.qa.bt(t.key,e)},Bc.prototype.dn=function(t){var e=this.qa.get(t);return!this.Wa.has(t)&&e?jo.updateTime(e):jo.NONE},Bc.prototype.Ha=function(t){var e=this.qa.get(t);if(this.Wa.has(t)||!e)return jo.exists(!0);if(e.isEqual(Bi.K()))throw new oi(ii.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return jo.updateTime(e)},Bc.prototype.write=function(t){this.za(),this.mutations=this.mutations.concat(t)},Bc.prototype.za=function(){Fr(!this.Qa,"A transaction object cannot be used after its update callback has been invoked.")},Bc),Mc=(Gc.prototype.Za=function(){var t=this;0===this.Ya&&(this.tf(Yr.l),Fr(null===this.Xa,"onlineStateTimer shouldn't be started yet"),this.Xa=this.qs.ao(Ku.Us,1e4,function(){return t.Xa=null,Fr(t.state===Yr.l,"Timer should be canceled if we transitioned to a different state."),t.nf("Backend didn't respond within 10 seconds."),t.tf(Yr.m),Promise.resolve()}))},Gc.prototype.if=function(t){this.state===Yr.v?(this.tf(Yr.l),Fr(0===this.Ya,"watchStreamFailures must be 0"),Fr(null===this.Xa,"onlineStateTimer must be null")):(this.Ya++,1<=this.Ya&&(this.ef(),this.nf("Connection failed 1 times. Most recent error: "+t.toString()),this.tf(Yr.m)))},Gc.prototype.set=function(t){this.ef(),this.Ya=0,t===Yr.v&&(this.$a=!1),this.tf(t)},Gc.prototype.tf=function(t){t!==this.state&&(this.state=t,this.Ja(t))},Gc.prototype.nf=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.$a?(Ur(e),this.$a=!1):Mr("OnlineStateTracker",e)},Gc.prototype.ef=function(){null!==this.Xa&&(this.Xa.cancel(),this.Xa=null)},Gc),Uc="RemoteStore",Vc=(Fc.prototype.start=function(){return this.enableNetwork()},Fc.prototype.enableNetwork=function(){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!0,this.af()?(e=this.pf,[4,this.jo.Fh()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this._f()?this.If():this.lf.set(Yr.l),[4,this.Tf()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},Fc.prototype.disableNetwork=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.Ef()];case 1:return t.sent(),this.lf.set(Yr.m),[2]}})})},Fc.prototype.Ef=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.pf.stop()];case 1:return t.sent(),[4,this.df.stop()];case 2:return t.sent(),0<this.rf.length&&(Mr(Uc,"Stopping write stream with "+this.rf.length+" pending writes"),this.rf=[]),this.Rf(),[2]}})})},Fc.prototype.Af=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return Mr(Uc,"RemoteStore shutting down."),this.networkEnabled=!1,[4,this.Ef()];case 1:return t.sent(),this.hf.Af(),this.lf.set(Yr.l),[2]}})})},Fc.prototype.listen=function(t){vi(this.uf,t.targetId)||(this.uf[t.targetId]=t,this._f()?this.If():this.df.la()&&this.Df(t))},Fc.prototype.Pf=function(t){Fr(vi(this.uf,t),"unlisten called on target no currently watched: "+t),delete this.uf[t],this.df.la()&&this.Sf(t),bi(this.uf)&&(this.df.la()?this.df.wa():this.af()&&this.lf.set(Yr.l))},Fc.prototype.Ze=function(t){return this.uf[t]||null},Fc.prototype.$e=function(t){return this.Cf.$e(t)},Fc.prototype.Df=function(t){this.sf.Ce(t.targetId),this.df.Pa(t)},Fc.prototype.Sf=function(t){this.sf.Ce(t),this.df.Sa(t)},Fc.prototype.If=function(){Fr(this._f(),"startWatchStream() called when shouldStartWatchStream() is false."),this.sf=new ku(this),this.df.start(),this.lf.Za()},Fc.prototype._f=function(){return this.af()&&!this.df.fa()&&!bi(this.uf)},Fc.prototype.af=function(){return this.isPrimary&&this.networkEnabled},Fc.prototype.Rf=function(){this.sf=null},Fc.prototype.vf=function(){return p(this,void 0,void 0,function(){var n=this;return y(this,function(t){return gi(this.uf,function(t,e){n.Df(e)}),[2]})})},Fc.prototype.wf=function(e){return p(this,void 0,void 0,function(){return y(this,function(t){return void 0===e&&Fr(!this._f(),"Watch stream was stopped gracefully while still needed."),this.Rf(),this._f()?(this.lf.if(e),this.If()):this.lf.set(Yr.l),[2]})})},Fc.prototype.mf=function(n,r){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.lf.set(Yr.v),n instanceof Su&&n.state===vu.Gi&&n.cause?[2,this.Vf(n)]:(n instanceof du?this.sf.Ue(n):n instanceof yu?this.sf.ze(n):(Fr(n instanceof Su,"Expected watchChange to be an instance of WatchTargetChange"),this.sf.Me(n)),r.isEqual(Bi.MIN)?[3,3]:[4,this.jo.jh()]);case 1:return e=t.sent(),0<=r.h(e)?[4,this.kf(r)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})},Fc.prototype.kf=function(r){var i=this;Fr(!r.isEqual(Bi.MIN),"Can't raise event for unknown SnapshotVersion");var t=this.sf.Je(r);return gi(t.ie,function(t,e){if(0<e.resumeToken.length){var n=i.uf[t];n&&(i.uf[t]=n.Ui(e.resumeToken,r))}}),t.ee.forEach(function(t){var e=i.uf[t];if(e){i.uf[t]=e.Ui(zu(),e.xi),i.Sf(t);var n=new Xa(e.target,t,fa.Ni,e.sequenceNumber);i.Df(n)}}),this.Cf.Uh(t)},Fc.prototype.Vf=function(t){var n=this;Fr(!!t.cause,"Handling target error without a cause");var r=t.cause,i=Promise.resolve();return t.targetIds.forEach(function(e){i=i.then(function(){return p(n,void 0,void 0,function(){return y(this,function(t){return vi(this.uf,e)?(delete this.uf[e],this.sf.removeTarget(e),[2,this.Cf.Nf(e,r)]):[2]})})})}),i},Fc.prototype.Tf=function(){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return this.Of()?(e=0<this.rf.length?this.rf[this.rf.length-1].batchId:-1,[4,this.jo.Hh(e)]):[3,4];case 1:return null!==(n=t.sent())?[3,2]:(0===this.rf.length&&this.pf.wa(),[3,4]);case 2:return this.Ff(n),[4,this.Tf()];case 3:t.sent(),t.label=4;case 4:return this.xf()&&this.jf(),[2]}})})},Fc.prototype.Of=function(){return this.af()&&this.rf.length<10},Fc.prototype.Uf=function(){return this.rf.length},Fc.prototype.Ff=function(t){Fr(this.Of(),"addToWritePipeline called when pipeline is full"),this.rf.push(t),this.pf.la()&&this.pf.Va&&this.pf.ka(t.mutations)},Fc.prototype.xf=function(){return this.af()&&!this.pf.fa()&&0<this.rf.length},Fc.prototype.jf=function(){Fr(this.xf(),"startWriteStream() called when shouldStartWriteStream() is false."),this.pf.start()},Fc.prototype.gf=function(){return p(this,void 0,void 0,function(){return y(this,function(t){return this.pf.Fa(),[2]})})},Fc.prototype.yf=function(){var r=this;return this.jo.xh(this.pf.lastStreamToken).then(function(){for(var t=0,e=r.rf;t<e.length;t++){var n=e[t];r.pf.ka(n.mutations)}}).catch(jh)},Fc.prototype.Na=function(t,e){var n=this;Fr(0<this.rf.length,"Got result for empty write pipeline");var r=this.rf.shift(),i=eh.from(r,t,e,this.pf.lastStreamToken);return this.Cf.Lf(i).then(function(){return n.Tf()})},Fc.prototype.bf=function(n){return p(this,void 0,void 0,function(){var e=this;return y(this,function(t){return void 0===n&&Fr(!this.xf(),"Write stream was stopped gracefully while still needed."),n&&0<this.rf.length?[2,(this.pf.Va?this.Bf(n):this.Mf(n)).then(function(){e.xf()&&e.jf()})]:[2]})})},Fc.prototype.Mf=function(e){return p(this,void 0,void 0,function(){return y(this,function(t){return Ka(e.code)?(Mr(Uc,"RemoteStore error before completed handshake; resetting stream token: ",this.pf.lastStreamToken),this.pf.lastStreamToken=zu(),[2,this.jo.xh(zu()).catch(jh)]):[2]})})},Fc.prototype.Bf=function(i){return p(this,void 0,void 0,function(){var n,r=this;return y(this,function(t){return Ka(e=i.code)&&e!==ii.ABORTED?(n=this.rf.shift(),this.pf.va(),[2,this.Cf.qf(n.batchId,i).then(function(){return r.Tf()})]):[2];var e})})},Fc.prototype.Qf=function(){return new qc(this.Ma)},Fc.prototype.ff=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.Ef()];case 1:return t.sent(),this.lf.set(Yr.l),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},Fc.prototype.Gf=function(){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.af()?(Mr(Uc,"RemoteStore restarting streams for new credential"),[4,this.ff()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Fc.prototype.Wf=function(e){return p(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return(this.isPrimary=e)&&this.networkEnabled?[4,this.enableNetwork()]:[3,2];case 1:return t.sent(),[3,4];case 2:return e?[3,4]:[4,this.Ef()];case 3:t.sent(),this.lf.set(Yr.l),t.label=4;case 4:return[2]}})})},Fc),jc="firestore_clients";function Fc(t,e,n,r,i){var o=this;this.jo=t,this.Ma=e,this.rf=[],this.uf={},this.sf=null,this.networkEnabled=!1,this.isPrimary=!1,this.hf=i,this.hf.cf(function(t){n.Xs(function(){return p(o,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.af()?(Mr(Uc,"Restarting streams for network reachability change."),[4,this.ff()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.lf=new Mc(n,r),this.df=this.Ma.ja({Ra:this.vf.bind(this),ya:this.wf.bind(this),Da:this.mf.bind(this)}),this.pf=this.Ma.xa({Ra:this.gf.bind(this),ya:this.bf.bind(this),Oa:this.yf.bind(this),Na:this.Na.bind(this)})}function Gc(t,e){this.qs=t,this.Ja=e,this.state=Yr.l,this.Ya=0,this.Xa=null,this.$a=!0}function Bc(t){this.Ma=t,this.qa=ru(),this.mutations=[],this.Qa=!1,this.Ga=null,this.Wa=new Set}function zc(t,e,n,r){this.Wc=t,this.sa=e,this.credentials=n,this.serializer=r}function Xc(t,e,n,r,i){var o=_c.call(this,t,Ku.js,Ku.xs,e,n,i)||this;return o.serializer=r,o.Ca=!1,o.lastStreamToken=zu(),o}function Wc(t,e,n,r,i){var o=Cc.call(this,t,Ku.Fs,Ku.Os,e,n,i)||this;return o.serializer=r,o}function Hc(t,e,n,r,i,o){this.Wc=t,this.ua=n,this.sa=r,this.oa=i,this.listener=o,this.state=Sc.na,this.ha=0,this.ca=null,this.stream=null,this.aa=new kc(t,e)}function Yc(t,e){return Fr(-1===e.indexOf("_"),"Client key cannot contain '_', but was '"+e+"'"),jc+"_"+t+"_"+e}var Kc="firestore_mutations";function Qc(t,e,n){var r=Kc+"_"+t+"_"+n;return e._()&&(r+="_"+e.uid),r}var Jc="firestore_targets";function $c(t,e){return Jc+"_"+t+"_"+e}var Zc="SharedClientState",tf=(lf.zf=function(t,e,n){var r=JSON.parse(n),i="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error),o=void 0;return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(o=new oi(r.error.code,r.error.message)),i?new lf(t,e,r.state,o):(Ur(Zc,"Failed to parse mutation state for ID '"+e+"': "+n),null)},lf.prototype.Kf=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)},lf),ef=(ff.zf=function(t,e){var n=JSON.parse(e),r="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error),i=void 0;return r&&n.error&&(r="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(i=new oi(n.error.code,n.error.message)),r?new ff(t,n.state,i):(Ur(Zc,"Failed to parse target state for ID '"+t+"': "+e),null)},ff.prototype.Kf=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)},ff),nf=(cf.zf=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=au(),o=0;r&&o<n.activeTargetIds.length;++o)r=sa(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new cf(t,i):(Ur(Zc,"Failed to parse client data for instance '"+t+"': "+e),null)},cf),rf=(hf.zf=function(t){var e=JSON.parse(t);return"object"==typeof e&&e.onlineState in Yr&&"string"==typeof e.clientId?new hf(e.clientId,Yr[e.onlineState]):(Ur(Zc,"Failed to parse online state: "+t),null)},hf),of=(uf.prototype.Hf=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},uf.prototype.Jf=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},uf.prototype.Kf=function(){var t={activeTargetIds:this.activeTargetIds.st(),updateTimeMs:Date.now()};return JSON.stringify(t)},uf),sf=(af.nl=function(t){return!(!t.window||null==t.window.localStorage)},af.prototype.start=function(){return p(this,void 0,void 0,function(){var e,n,r,i,o,s,a,u,h,c,f,l=this;return y(this,function(t){switch(t.label){case 0:return Fr(!this.qo,"WebStorageSharedClientState already started"),Fr(null!==this.Cf,"syncEngine property must be set before calling start()"),Fr(null!==this.Ja,"onlineStateHandler property must be set before calling start()"),[4,this.Cf.sc()];case 1:for(e=t.sent(),n=0,r=e;n<r.length;n++)(i=r[n])!==this.Yf&&(o=this.getItem(Yc(this.persistenceKey,i)))&&(s=nf.zf(i,o))&&(this.Xf[s.clientId]=s);for(this.hl(),(a=this.storage.getItem(this.ol))&&(u=this.cl(a))&&this.al(u),h=0,c=this.tl;h<c.length;h++)f=c[h],this.Zf(f);return this.tl=[],this.platform.window.addEventListener("unload",function(){return l.Af()}),this.qo=!0,[2]}})})},af.prototype.Vs=function(t){this.setItem(this.el,JSON.stringify(t))},af.prototype.fl=function(){var n=au();return wi(this.Xf,function(t,e){n=n.Jt(e.activeTargetIds)}),n},af.prototype.ll=function(t){for(var e in this.Xf)if(this.Xf.hasOwnProperty(e)&&this.Xf[e].activeTargetIds.has(t))return!0;return!1},af.prototype.dl=function(t){this.vl(t,"pending")},af.prototype.wl=function(t,e,n){this.vl(t,e,n),this.ml(t)},af.prototype.pl=function(t){var e="not-current";if(this.ll(t)){var n=this.storage.getItem($c(this.persistenceKey,t));if(n){var r=ef.zf(t,n);r&&(e=r.state)}}return this.gl.Hf(t),this.hl(),e},af.prototype.bl=function(t){this.gl.Jf(t),this.hl()},af.prototype.yl=function(t){return this.gl.activeTargetIds.has(t)},af.prototype._l=function(t){this.removeItem($c(this.persistenceKey,t))},af.prototype.Il=function(t,e,n){this.Tl(t,e,n)},af.prototype.ph=function(t,e,n){var r=this;e.forEach(function(t){r.ml(t)}),this.currentUser=t,n.forEach(function(t){r.dl(t)})},af.prototype.El=function(t){this.Rl(t)},af.prototype.Af=function(){this.qo&&(this.platform.window.removeEventListener("storage",this.$f),this.removeItem(this.il),this.qo=!1)},af.prototype.getItem=function(t){var e=this.storage.getItem(t);return Mr(Zc,"READ",t,e),e},af.prototype.setItem=function(t,e){Mr(Zc,"SET",t,e),this.storage.setItem(t,e)},af.prototype.removeItem=function(t){Mr(Zc,"REMOVE",t),this.storage.removeItem(t)},af.prototype.Zf=function(a){var t=this;if(a.storageArea===this.storage){if(Mr(Zc,"EVENT",a.key,a.newValue),a.key===this.il)return void Ur("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Wc.Xs(function(){return p(t,void 0,void 0,function(){var e,n,r,i,o,s;return y(this,function(t){if(!this.qo)return this.tl.push(a),[2];if(null===a.key)return[2];if(this.rl.test(a.key)){if(null==a.newValue)return n=this.Al(a.key),[2,this.Dl(n,null)];if(e=this.Pl(a.key,a.newValue))return[2,this.Dl(e.clientId,e)]}else if(this.ul.test(a.key)){if(null!==a.newValue&&(r=this.Sl(a.key,a.newValue)))return[2,this.Cl(r)]}else if(this.sl.test(a.key)){if(null!==a.newValue&&(i=this.Vl(a.key,a.newValue)))return[2,this.kl(i)]}else if(a.key===this.ol){if(null!==a.newValue&&(o=this.cl(a.newValue)))return[2,this.al(o)]}else a.key===this.el&&(Fr(!!this.Ps,"Missing sequenceNumberHandler"),(s=function(t){var e=ch.ks;if(null!=t)try{var n=JSON.parse(t);Fr("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(t){Ur(Zc,"Failed to read sequence number from WebStorage",t)}return e}(a.newValue))!==ch.ks&&this.Ps(s));return[2]})})})}},Object.defineProperty(af.prototype,"gl",{get:function(){return this.Xf[this.Yf]},enumerable:!0,configurable:!0}),af.prototype.hl=function(){this.setItem(this.il,this.gl.Kf())},af.prototype.vl=function(t,e,n){var r=new tf(this.currentUser,t,e,n),i=Qc(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Kf())},af.prototype.ml=function(t){var e=Qc(this.persistenceKey,this.currentUser,t);this.removeItem(e)},af.prototype.Rl=function(t){var e={clientId:this.Yf,onlineState:Yr[t]};this.storage.setItem(this.ol,JSON.stringify(e))},af.prototype.Tl=function(t,e,n){var r=$c(this.persistenceKey,t),i=new ef(t,e,n);this.setItem(r,i.Kf())},af.prototype.Al=function(t){var e=this.rl.exec(t);return e?e[1]:null},af.prototype.Pl=function(t,e){var n=this.Al(t);return Fr(null!==n,"Cannot parse client state key '"+t+"'"),nf.zf(n,e)},af.prototype.Sl=function(t,e){var n=this.ul.exec(t);Fr(null!==n,"Cannot parse mutation batch key '"+t+"'");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return tf.zf(new ri(i),r,e)},af.prototype.Vl=function(t,e){var n=this.sl.exec(t);Fr(null!==n,"Cannot parse query target key '"+t+"'");var r=Number(n[1]);return ef.zf(r,e)},af.prototype.cl=function(t){return rf.zf(t)},af.prototype.Cl=function(e){return p(this,void 0,void 0,function(){return y(this,function(t){return e.user.uid!==this.currentUser.uid?(Mr(Zc,"Ignoring mutation for non-active user "+e.user.uid),[2]):[2,this.Cf.Nl(e.batchId,e.state,e.error)]})})},af.prototype.kl=function(t){return this.Cf.Ol(t.targetId,t.state,t.error)},af.prototype.Dl=function(t,e){var n=this,r=this.fl();e?this.Xf[t]=e:delete this.Xf[t];var i=this.fl(),o=[],s=[];return i.forEach(function(e){return p(n,void 0,void 0,function(){return y(this,function(t){return r.has(e)||o.push(e),[2]})})}),r.forEach(function(e){return p(n,void 0,void 0,function(){return y(this,function(t){return i.has(e)||s.push(e),[2]})})}),this.Cf.Fl(o,s)},af.prototype.al=function(t){this.Xf[t.clientId]&&this.Ja(t.onlineState)},af);function af(t,e,n,r,i){if(this.Wc=t,this.platform=e,this.persistenceKey=n,this.Yf=r,this.Cf=null,this.Ja=null,this.Ps=null,this.Xf={},this.$f=this.Zf.bind(this),this.qo=!1,this.tl=[],!af.nl(this.platform))throw new oi(ii.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.il=Yc(this.persistenceKey,this.Yf),this.el="firestore_sequence_number_"+this.persistenceKey,this.Xf[this.Yf]=new of,this.rl=new RegExp("^"+jc+"_"+o+"_([^_]*)$"),this.ul=new RegExp("^"+Kc+"_"+o+"_(\\d+)(?:_(.*))?$"),this.sl=new RegExp("^"+Jc+"_"+o+"_(\\d+)$"),this.ol="firestore_online_state_"+this.persistenceKey,this.platform.window.addEventListener("storage",this.$f)}function uf(){this.activeTargetIds=au()}function hf(t,e){this.clientId=t,this.onlineState=e}function cf(t,e){this.clientId=t,this.activeTargetIds=e}function ff(t,e,n){this.targetId=t,this.state=e,Fr(void 0!==(this.error=n)==("rejected"===e),"QueryTargetMetadata must contain an error iff state is 'rejected'")}function lf(t,e,n,r){this.user=t,this.batchId=e,this.state=n,Fr(void 0!==(this.error=r)==("rejected"===n),"MutationMetadata must contain an error iff state is 'rejected'")}var pf,df,yf=(vf.prototype.dl=function(t){},vf.prototype.wl=function(t,e,n){},vf.prototype.pl=function(t){return this.xl.Hf(t),this.jl[t]||"not-current"},vf.prototype.Il=function(t,e,n){this.jl[t]=e},vf.prototype.bl=function(t){this.xl.Jf(t)},vf.prototype.yl=function(t){return this.xl.activeTargetIds.has(t)},vf.prototype._l=function(t){delete this.jl[t]},vf.prototype.fl=function(){return this.xl.activeTargetIds},vf.prototype.ll=function(t){return this.xl.activeTargetIds.has(t)},vf.prototype.start=function(){return this.xl=new of,Promise.resolve()},vf.prototype.ph=function(t,e,n){},vf.prototype.El=function(t){},vf.prototype.Af=function(){},vf.prototype.Vs=function(t){},vf);function vf(){this.xl=new of,this.jl={},this.Cf=null,this.Ja=null,this.Ps=null}(df=pf=pf||{})[df.Ul=0]="__PRIVATE_QueryCache",df[df.Ll=1]="__PRIVATE_SyncEngine";function mf(t){this.key=t}function gf(t){this.key=t}var wf=(If.prototype.next=function(){var t=this.ql;return this.ql+=2,t},If.prototype.after=function(t){return this.Ml(t+2),this.next()},If.prototype.Ml=function(t){Fr((1&t)===this.Bl,"Cannot supply target ID from different generator ID"),this.ql=t},If.Ql=function(){return new If(pf.Ul,2)},If.Gl=function(){return new If(pf.Ll)},If),bf=(Object.defineProperty(Ef.prototype,"Jl",{get:function(){return this.Wl},enumerable:!0,configurable:!0}),Ef.prototype.Yl=function(t,e){var a=this,u=e?e.Xl:new gu,h=e?e.Hl:this.Hl,c=e?e.$i:this.$i,f=h,l=!1,p=this.query.Ri()&&h.size===this.query.limit?h.last():null,d=this.query.Ai()&&h.size===this.query.limit?h.first():null;if(t.Et(function(t,e){var n=h.get(t),r=e instanceof Us?e:null;r&&(Fr(t.isEqual(r.key),"Mismatching keys found in document changes: "+t+" != "+r.key),r=a.query.matches(r)?r:null);var i=!!n&&a.$i.has(n.key),o=!!r&&(r.vn||a.$i.has(r.key)&&r.hasCommittedMutations),s=!1;n&&r?n.data().isEqual(r.data())?i!==o&&(u.track({type:uu.zi,doc:r}),s=!0):a.$l(n,r)||(u.track({type:uu.Wi,doc:r}),s=!0,(p&&0<a.query.yi(r,p)||d&&a.query.yi(r,d)<0)&&(l=!0)):!n&&r?(u.track({type:uu.Qi,doc:r}),s=!0):n&&!r&&(u.track({type:uu.Gi,doc:n}),s=!0,(p||d)&&(l=!0)),s&&(c=r?(f=f.add(r),o?c.add(t):c.delete(t)):(f=f.delete(t),c.delete(t)))}),this.query.Ri()||this.query.Ai())for(;f.size>this.query.limit;){var n=this.query.Ri()?f.last():f.first();f=f.delete(n.key),c=c.delete(n.key),u.track({type:uu.Gi,doc:n})}return Fr(!l||!e,"View was refilled using docs that themselves needed refilling."),{Hl:f,Xl:u,Zl:l,$i:c}},Ef.prototype.$l=function(t,e){return t.vn&&e.hasCommittedMutations&&!e.vn},Ef.prototype.rs=function(t,e,n){var o=this;Fr(!t.Zl,"Cannot apply changes that need a refill");var r=this.Hl;this.Hl=t.Hl,this.$i=t.$i;var i=t.Xl.Yi();i.sort(function(t,e){return r=t.type,i=e.type,n(r)-n(i)||o.query.yi(t.doc,e.doc);function n(t){switch(t){case uu.Qi:return 1;case uu.Wi:case uu.zi:return 2;case uu.Gi:return 0;default:return jr("Unknown ChangeType: "+t)}}var r,i}),this.td(n);var s=e?this.nd():[],a=0===this.Kl.size&&this.he?cu.Hi:cu.Ki,u=a!==this.zl;return this.zl=a,0!==i.length||u?{snapshot:new wu(this.query,t.Hl,r,i,t.$i,a===cu.Ki,u,!1),ed:s}:{ed:s}},Ef.prototype.rd=function(t){return this.he&&t===Yr.m?(this.he=!1,this.rs({Hl:this.Hl,Xl:new gu,$i:this.$i,Zl:!1},!1)):{ed:[]}},Ef.prototype.ud=function(t){return!this.Wl.has(t)&&!!this.Hl.has(t)&&!this.Hl.get(t).vn},Ef.prototype.td=function(t){var e=this;t&&(t.ce.forEach(function(t){return e.Wl=e.Wl.add(t)}),t.ae.forEach(function(t){return Fr(e.Wl.has(t),"Modified document "+t+" not found in view.")}),t.fe.forEach(function(t){return e.Wl=e.Wl.delete(t)}),this.he=t.he)},Ef.prototype.nd=function(){var e=this;if(!this.he)return[];var n=this.Kl;this.Kl=ou(),this.Hl.forEach(function(t){e.ud(t.key)&&(e.Kl=e.Kl.add(t.key))});var r=[];return n.forEach(function(t){e.Kl.has(t)||r.push(new gf(t))}),this.Kl.forEach(function(t){n.has(t)||r.push(new mf(t))}),r},Ef.prototype.sd=function(t){this.Wl=t.rc,this.Kl=ou();var e=this.Yl(t.documents);return this.rs(e,!0)},Ef.prototype.od=function(){return wu.ne(this.query,this.Hl,this.$i,this.zl===cu.Ki)},Ef);function Ef(t,e){this.query=t,this.Wl=e,this.zl=null,this.he=!1,this.Kl=ou(),this.$i=ou(),this.Hl=new lu(t.yi.bind(t))}function If(t,e){Fr((1&(this.Bl=t))===t,"Generator ID "+t+" contains more than 1 reserved bits"),this.Ml(void 0!==e?e:this.Bl)}function Tf(t,e,n){this.query=t,this.targetId=e,this.view=n}function Af(t){this.key=t,this.md=!1}function Nf(){this.Kd=null,this.targetId=0,this.Hd=[]}var Sf=(Mf.prototype.fd=function(){this.ld()},Mf.prototype.ld=function(){var t=this;this.aa.Zc(function(){return p(t,void 0,void 0,function(){var e,n,r=this;return y(this,function(t){return e=this.hd.Qf(),(n=this.dd(e))&&n.then(function(t){r.qs.Xs(function(){return e.commit().then(function(){r.zs.resolve(t)}).catch(function(t){r.vd(t)})})}).catch(function(t){r.vd(t)}),[2]})})})},Mf.prototype.dd=function(t){try{var e=this.updateFunction(t);return!oa(e)&&e.catch&&e.then?e:(this.zs.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.zs.reject(t),null}},Mf.prototype.vd=function(t){var e=this;0<this.ad&&this.wd(t)?(this.ad-=1,this.qs.Xs(function(){return e.ld(),Promise.resolve()})):this.zs.reject(t)},Mf.prototype.wd=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!Ka(e)},Mf),Df=(Object.defineProperty(qf.prototype,"Dd",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),qf.prototype.subscribe=function(t){Fr(null!==t,"SyncEngine listener cannot be null"),Fr(null===this.gd,"SyncEngine already has a subscriber."),this.gd=t},qf.prototype.listen=function(s){return p(this,void 0,void 0,function(){var e,n,r,i,o;return y(this,function(t){switch(t.label){case 0:return this.Pd("listen()"),(r=this.bd.get(s))?(e=r.targetId,this.pd.pl(e),n=r.view.od(),[3,4]):[3,1];case 1:return[4,this.jo.Xh(s.bi())];case 2:return i=t.sent(),o=this.pd.pl(i.targetId),e=i.targetId,[4,this.Sd(s,e,"current"===o)];case 3:n=t.sent(),this.isPrimary&&this.hd.listen(i),t.label=4;case 4:return this.gd.Da([n]),[2,e]}})})},qf.prototype.Sd=function(a,u,h){return p(this,void 0,void 0,function(){var e,n,r,i,o,s;return y(this,function(t){switch(t.label){case 0:return[4,this.jo.ic(a,!0)];case 1:return e=t.sent(),n=new bf(a,e.rc),r=n.Yl(e.documents),i=Eu.oe(u,h&&this.onlineState!==Yr.m),Fr(0===(o=n.rs(r,!0===this.isPrimary,i)).ed.length,"View returned limbo docs before target ack from the server."),Fr(!!o.snapshot,"applyChanges for new view should always return a snapshot"),s=new Tf(a,u,n),this.bd.set(a,s),this.yd[u]||(this.yd[u]=[]),this.yd[u].push(a),[2,o.snapshot]}})})},qf.prototype.Cd=function(r){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return[4,this.jo.ic(r.query,!0)];case 1:return e=t.sent(),n=r.view.sd(e),this.isPrimary&&this.Vd(r.targetId,n.ed),[2,n]}})})},qf.prototype.Pf=function(i){return p(this,void 0,void 0,function(){var e,n,r=this;return y(this,function(t){switch(t.label){case 0:return this.Pd("unlisten()"),Fr(!!(e=this.bd.get(i)),"Trying to unlisten on query not found:"+i),1<(n=this.yd[e.targetId]).length?(this.yd[e.targetId]=n.filter(function(t){return!t.isEqual(i)}),this.bd.delete(i),[2]):this.isPrimary?(this.pd.bl(e.targetId),this.pd.ll(e.targetId)?[3,2]:[4,this.jo.nc(e.targetId,!1).then(function(){r.pd._l(e.targetId),r.hd.Pf(e.targetId),r.kd(e.targetId)}).catch(jh)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.kd(e.targetId),[4,this.jo.nc(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},qf.prototype.write=function(n,r){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.Pd("write()"),[4,this.jo.Ih(n)];case 1:return e=t.sent(),this.pd.dl(e.batchId),this.Nd(e.batchId,r),[4,this.Od(e.Hu)];case 2:return t.sent(),[4,this.hd.Tf()];case 3:return t.sent(),[2]}})})},qf.prototype.runTransaction=function(t,e,n){new Sf(t,this.hd,e,n).fd()},qf.prototype.Uh=function(n){return p(this,void 0,void 0,function(){var e,r=this;return y(this,function(t){switch(t.label){case 0:this.Pd("applyRemoteEvent()"),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.jo.Uh(n)];case 2:return e=t.sent(),wi(n.ie,function(t,e){var n=r.Id[Number(t)];n&&(Fr(e.ce.size+e.ae.size+e.fe.size<=1,"Limbo resolution for single document contains multiple changes."),0<e.ce.size?n.md=!0:0<e.ae.size?Fr(n.md,"Received change for limbo target document without add."):0<e.fe.size&&(Fr(n.md,"Received remove for limbo target document without add."),n.md=!1))}),[4,this.Od(e,n)];case 3:return t.sent(),[3,6];case 4:return[4,jh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},qf.prototype.rd=function(r,t){if(this.isPrimary&&t===Qr.p||!this.isPrimary&&t===Qr.g){this.Pd("applyOnlineStateChange()");var i=[];this.bd.forEach(function(t,e){var n=e.view.rd(r);Fr(0===n.ed.length,"OnlineState should not affect limbo documents."),n.snapshot&&i.push(n.snapshot)}),this.gd.Fd(r),this.gd.Da(i),this.onlineState=r,this.isPrimary&&this.pd.El(r)}},qf.prototype.Nf=function(a,u){return p(this,void 0,void 0,function(){var e,n,r,i,o,s=this;return y(this,function(t){switch(t.label){case 0:return this.Pd("rejectListens()"),this.pd.Il(a,"rejected",u),e=this.Id[a],(n=e&&e.key)?(this._d=this._d.remove(n),delete this.Id[a],r=(r=new Ki(Yi.X)).bt(n,new Vs(n,Bi.K())),i=ou().add(n),o=new bu(Bi.MIN,{},new co(zr),r,i),[2,this.Uh(o)]):[3,1];case 1:return[4,this.jo.nc(a,!1).then(function(){return s.kd(a,u)}).catch(jh)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},qf.prototype.Nl=function(n,r,i){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.Pd("applyBatchState()"),[4,this.jo.Eh(n)];case 1:return null===(e=t.sent())?(Mr("SyncEngine","Cannot apply mutation batch with id: "+n),[2]):"pending"!==r?[3,3]:[4,this.hd.Tf()];case 2:return t.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(this.xd(n,i||null),this.jo.oc(n)):jr("Unknown batchState: "+r),t.label=4;case 4:return[4,this.Od(e)];case 5:return t.sent(),[2]}})})},qf.prototype.Lf=function(r){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:this.Pd("applySuccessfulWrite()"),e=r.batch.batchId,this.xd(e,null),this.jd(e),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.jo.Ah(r)];case 2:return n=t.sent(),this.pd.wl(e,"acknowledged"),[4,this.Od(n)];case 3:return t.sent(),[3,6];case 4:return[4,jh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},qf.prototype.qf=function(n,r){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:this.Pd("rejectFailedWrite()"),this.xd(n,r),this.jd(n),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.jo.Vh(n)];case 2:return e=t.sent(),this.pd.wl(n,"rejected",r),[4,this.Od(e)];case 3:return t.sent(),[3,6];case 4:return[4,jh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},qf.prototype.Ud=function(r){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return this.hd.af()||Mr("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),[4,this.jo.Oh()];case 1:return-1===(e=t.sent())?r.resolve():((n=this.Rd.get(e)||[]).push(r),this.Rd.set(e,n)),[2]}})})},qf.prototype.jd=function(t){(this.Rd.get(t)||[]).forEach(function(t){t.resolve()}),this.Rd.delete(t)},qf.prototype.Ld=function(e){this.Rd.forEach(function(t){t.forEach(function(t){t.reject(new oi(ii.CANCELLED,e))})}),this.Rd.clear()},qf.prototype.Nd=function(t,e){var n=this.Ed[this.currentUser.I()];n=(n=n||new Ki(zr)).bt(t,e),this.Ed[this.currentUser.I()]=n},qf.prototype.xd=function(t,e){var n=this.Ed[this.currentUser.I()];if(n){var r=n.get(t);r&&(Fr(t===n.It(),"Mutation callbacks processed out-of-order?"),e?r.reject(e):r.resolve(),n=n.remove(t)),this.Ed[this.currentUser.I()]=n}},qf.prototype.kd=function(t,e){var n=this;void 0===e&&(e=null),this.pd.bl(t),Fr(this.yd[t]&&0!==this.yd[t].length,"There are no queries mapped to target id "+t);for(var r=0,i=this.yd[t];r<i.length;r++){var o=i[r];this.bd.delete(o),e&&this.gd.Bd(o,e)}if(delete this.yd[t],this.isPrimary){var s=this.Td.Fu(t);this.Td.Nu(t),s.forEach(function(t){n.Td.xu(t)||n.Md(t)})}},qf.prototype.Md=function(t){var e=this._d.get(t);null!==e&&(this.hd.Pf(e),this._d=this._d.remove(t),delete this.Id[e])},qf.prototype.Vd=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof mf?(this.Td.Pu(i.key,t),this.qd(i)):i instanceof gf?(Mr("SyncEngine","Document no longer in limbo: "+i.key),this.Td.Cu(i.key,t),this.Td.xu(i.key)||this.Md(i.key)):jr("Unknown limbo change: "+JSON.stringify(i))}},qf.prototype.qd=function(t){var e=t.key;if(!this._d.get(e)){Mr("SyncEngine","New document in limbo: "+e);var n=this.Ad.next(),r=wa.oi(e.path);this.Id[n]=new Af(e),this.hd.listen(new Xa(r.bi(),n,fa.Oi,ch.ks)),this._d=this._d.bt(e,n)}},qf.prototype.Qd=function(){return this._d},qf.prototype.Od=function(r,u){return p(this,void 0,void 0,function(){var o,s,e,a=this;return y(this,function(t){switch(t.label){case 0:return o=[],s=[],e=[],this.bd.forEach(function(t,i){e.push(Promise.resolve().then(function(){var n=i.view.Yl(r);return n.Zl?a.jo.ic(i.query,!1).then(function(t){var e=t.documents;return i.view.Yl(e,n)}):n}).then(function(t){var e=u&&u.ie[i.targetId],n=i.view.rs(t,!0===a.isPrimary,e);if(a.Vd(i.targetId,n.ed),n.snapshot){a.isPrimary&&a.pd.Il(i.targetId,n.snapshot.fromCache?"not-current":"current"),o.push(n.snapshot);var r=hh.Ds(i.targetId,n.snapshot);s.push(r)}}))}),[4,Promise.all(e)];case 1:return t.sent(),this.gd.Da(o),[4,this.jo.Kh(s)];case 2:return t.sent(),[2]}})})},qf.prototype.Pd=function(t){Fr(null!==this.gd,"Trying to call "+t+" before calling subscribe().")},qf.prototype.Gf=function(r){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return e=!this.currentUser.isEqual(r),this.currentUser=r,e?(this.Ld("'waitForPendingWrites' promise is rejected due to a user change."),[4,this.jo.ph(r)]):[3,3];case 1:return n=t.sent(),this.pd.ph(r,n.yh,n._h),[4,this.Od(n.bh)];case 2:t.sent(),t.label=3;case 3:return[4,this.hd.Gf()];case 4:return t.sent(),[2]}})})},qf.prototype.Wf=function(u){return p(this,void 0,void 0,function(){var e,n,r,i,o,s,a=this;return y(this,function(t){switch(t.label){case 0:return!0!==u||!0===this.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.hd.Wf(!0)]);case 1:return t.sent(),o=this.pd.fl(),[4,this.Gd(o.st())];case 2:for(e=t.sent(),n=0,r=e;n<r.length;n++)i=r[n],this.hd.listen(i);return[3,7];case 3:return!1!==u||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,o=[],s=Promise.resolve(),gi(this.yd,function(t,e){a.pd.yl(t)?o.push(t):s=s.then(function(){return a.kd(t),a.jo.nc(t,!0)}),a.hd.Pf(t)}),[4,s]);case 4:return t.sent(),[4,this.Gd(o)];case 5:return t.sent(),this.Wd(),[4,this.hd.Wf(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},qf.prototype.Wd=function(){var e=this;gi(this.Id,function(t){e.hd.Pf(t)}),this.Td.Ou(),this.Id=[],this._d=new Ki(Yi.X)},qf.prototype.Gd=function(d){return p(this,void 0,void 0,function(){var e,n,r,i,o,s,a,u,h,c,f,l,p;return y(this,function(t){switch(t.label){case 0:e=[],n=[],r=0,i=d,t.label=1;case 1:return r<i.length?(o=i[r],s=void 0,(a=this.yd[o])&&0!==a.length?[4,this.jo.nc(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.jo.Xh(a[0].bi())];case 3:s=t.sent(),u=0,h=a,t.label=4;case 4:return u<h.length?(c=h[u],Fr(!!(f=this.bd.get(c)),"No query view found for "+c),[4,this.Cd(f)]):[3,7];case 5:(l=t.sent()).snapshot&&n.push(l.snapshot),t.label=6;case 6:return u++,[3,4];case 7:return[3,12];case 8:return Fr(!0===this.isPrimary,"A secondary tab should never have an active target without an active query."),[4,this.jo.ac(o)];case 9:return Fr(!!(p=t.sent()),"Target for id "+o+" not found"),[4,this.jo.Xh(p)];case 10:return s=t.sent(),[4,this.Sd(this.zd(p),o,!1)];case 11:t.sent(),t.label=12;case 12:e.push(s),t.label=13;case 13:return r++,[3,1];case 14:return this.gd.Da(n),[2,e]}})})},qf.prototype.zd=function(t){return new wa(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,aa.ti,t.startAt,t.endAt)},qf.prototype.sc=function(){return this.jo.sc()},qf.prototype.Ol=function(r,i,o){return p(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:if(this.isPrimary)return Mr("SyncEngine","Ignoring unexpected query state notification."),[2];if(!this.yd[r])return[3,7];switch(i){case"current":case"not-current":return[3,1];case"rejected":return[3,4]}return[3,6];case 1:return[4,this.jo.fc()];case 2:return e=t.sent(),n=bu.se(r,"current"===i),[4,this.Od(e,n)];case 3:return t.sent(),[3,7];case 4:return[4,this.jo.nc(r,!0)];case 5:return t.sent(),this.kd(r,o),[3,7];case 6:jr("Unexpected target state: "+i),t.label=7;case 7:return[2]}})})},qf.prototype.Fl=function(f,l){return p(this,void 0,void 0,function(){var e,n,r,i,o,s,a,u,h,c=this;return y(this,function(t){switch(t.label){case 0:if(!this.isPrimary)return[2];e=0,n=f,t.label=1;case 1:return e<n.length?(h=n[e],Fr(!this.yd[h],"Trying to add an already active target"),[4,this.jo.ac(h)]):[3,6];case 2:return Fr(!!(r=t.sent()),"Query data for active target "+h+" not found"),[4,this.jo.Xh(r)];case 3:return i=t.sent(),[4,this.Sd(this.zd(r),i.targetId,!1)];case 4:t.sent(),this.hd.listen(i),t.label=5;case 5:return e++,[3,1];case 6:o=function(e){return y(this,function(t){switch(t.label){case 0:return s.yd[e]?[4,s.jo.nc(e,!1).then(function(){c.hd.Pf(e),c.kd(e)}).catch(jh)]:[2,"continue"];case 1:return t.sent(),[2]}})},s=this,a=0,u=l,t.label=7;case 7:return a<u.length?(h=u[a],[5,o(h)]):[3,10];case 8:t.sent(),t.label=9;case 9:return a++,[3,7];case 10:return[2]}})})},qf.prototype.enableNetwork=function(){return this.jo.cc(!0),this.hd.enableNetwork()},qf.prototype.disableNetwork=function(){return this.jo.cc(!1),this.hd.disableNetwork()},qf.prototype.$e=function(t){var e=this.Id[t];if(e&&e.md)return ou().add(e.key);var n=ou(),r=this.yd[t];if(!r)return n;for(var i=0,o=r;i<o.length;i++){var s=o[i],a=this.bd.get(s);Fr(!!a,"No query view found for "+s),n=n.Jt(a.view.Jl)}return n},qf),kf=(Lf.prototype.listen=function(t){var e=t.query,n=!1,r=this.Jd.get(e);return r||(n=!0,r=new Nf,this.Jd.set(e,r)),r.Hd.push(t),Fr(!t.rd(this.onlineState),"applyOnlineStateChange() shouldn't raise an event for brand-new listeners."),r.Kd&&t.Xd(r.Kd)&&this.$d(),n?this.Cf.listen(e).then(function(t){return r.targetId=t}):Promise.resolve(r.targetId)},Lf.prototype.Pf=function(o){return p(this,void 0,void 0,function(){var e,n,r,i;return y(this,function(t){return e=o.query,n=!1,(r=this.Jd.get(e))&&0<=(i=r.Hd.indexOf(o))&&(r.Hd.splice(i,1),n=0===r.Hd.length),n?(this.Jd.delete(e),[2,this.Cf.Pf(e)]):[2]})})},Lf.prototype.Da=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,s=this.Jd.get(o);if(s){for(var a=0,u=s.Hd;a<u.length;a++)u[a].Xd(i)&&(e=!0);s.Kd=i}}e&&this.$d()},Lf.prototype.Bd=function(t,e){var n=this.Jd.get(t);if(n)for(var r=0,i=n.Hd;r<i.length;r++)i[r].onError(e);this.Jd.delete(t)},Lf.prototype.Fd=function(i){this.onlineState=i;var o=!1;this.Jd.forEach(function(t,e){for(var n=0,r=e.Hd;n<r.length;n++)r[n].rd(i)&&(o=!0)}),o&&this.$d()},Lf.prototype.Zd=function(t){this.Yd.add(t),t.next()},Lf.prototype.tv=function(t){this.Yd.delete(t)},Lf.prototype.$d=function(){this.Yd.forEach(function(t){t.next()})},Lf),Rf=(Of.prototype.Xd=function(t){if(Fr(0<t.docChanges.length||t.Zi,"We got a new snapshot with no changes?"),!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];i.type!==uu.zi&&e.push(i)}t=new wu(t.query,t.docs,t.Xi,e,t.$i,t.fromCache,t.Zi,!0)}var o=!1;return this.iv?this.rv(t)&&(this.nv.next(t),o=!0):this.uv(t,this.onlineState)&&(this.sv(t),o=!0),this.ev=t,o},Of.prototype.onError=function(t){this.nv.error(t)},Of.prototype.rd=function(t){this.onlineState=t;var e=!1;return this.ev&&!this.iv&&this.uv(this.ev,t)&&(this.sv(this.ev),e=!0),e},Of.prototype.uv=function(t,e){if(Fr(!this.iv,"Determining whether to raise first event but already had first event"),!t.fromCache)return!0;var n=e!==Yr.m;return this.options.ov&&n?(Fr(t.fromCache,"Waiting for sync, but snapshot is not from cache"),!1):!t.docs.nt()||e===Yr.m},Of.prototype.rv=function(t){if(0<t.docChanges.length)return!0;var e=this.ev&&this.ev.hasPendingWrites!==t.hasPendingWrites;return!(!t.Zi&&!e)&&!0===this.options.includeMetadataChanges},Of.prototype.sv=function(t){Fr(!this.iv,"Trying to raise initial events for second time"),t=wu.ne(t.query,t.docs,t.$i,t.fromCache),this.iv=!0,this.nv.next(t)},Of),_f="",Cf="",xf="",Pf="";function Of(t,e,n){this.query=t,this.nv=e,this.iv=!1,this.ev=null,this.onlineState=Yr.l,this.options=n||{}}function Lf(t){this.Cf=t,this.Jd=new Zu(function(t){return t.canonicalId()}),this.onlineState=Yr.l,this.Yd=new Set,this.Cf.subscribe(this)}function qf(t,e,n,r){this.jo=t,this.hd=e,this.pd=n,this.currentUser=r,this.gd=null,this.bd=new Zu(function(t){return t.canonicalId()}),this.yd={},this._d=new Ki(Yi.X),this.Id={},this.Td=new nh,this.Ed={},this.Rd=new Map,this.Ad=wf.Gl(),this.isPrimary=void 0,this.onlineState=Yr.l}function Mf(t,e,n,r){this.qs=t,this.hd=e,this.updateFunction=n,this.zs=r,this.ad=5,this.aa=new kc(this.qs,Ku.Ms)}function Uf(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=jf(e)),e=Vf(t.get(n),e);return jf(e)}function Vf(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+=_f+xf;break;case _f:n+=_f+Pf;break;default:n+=o}}return n}function jf(t){return t+_f+Cf}function Ff(t){var e=t.length;if(Fr(2<=e,"Invalid path "+t),2===e)return Fr(t.charAt(0)===_f&&t.charAt(1)===Cf,"Non-empty path "+t+" had length 2"),Xi.ct;for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf(_f,o);switch((s<0||n<s)&&jr('Invalid encoded resource path: "'+t+'"'),t.charAt(s+1)){case Cf:var a=t.substring(o,s),u=void 0;0===i.length?u=a:(u=i+=a,i=""),r.push(u);break;case xf:i+=t.substring(o,s),i+="\0";break;case Pf:i+=t.substring(o,s+1);break;default:jr('Invalid encoded resource path: "'+t+'"')}o=s+2}return new Xi(r)}var Gf=(Kf.cv=function(o,t,s){return Fr(Kf.nl(),"IndexedDB not supported in current environment."),Mr("SimpleDb","Opening database:",o),new ih(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new Kf(e))},i.onblocked=function(){r(new oi(ii.FAILED_PRECONDITION,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(t){var e=t.target.error;"VersionError"===e.name?r(new oi(ii.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(e)},i.onupgradeneeded=function(t){Mr("SimpleDb",'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;s.createOrUpgrade(e,i.transaction,t.oldVersion,Tl).next(function(){Mr("SimpleDb","Database upgrade to version "+Tl+" complete")})}}).Gu()},Kf.delete=function(t){return Mr("SimpleDb","Removing database:",t),Qf(window.indexedDB.deleteDatabase(t)).Gu()},Kf.nl=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(Kf.av())return!0;if(void 0===window.navigator)return!1;var t=l(),e=Kf.hv(t),n=0<e&&e<10,r=Kf.fv(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},Kf.av=function(){var t;return"undefined"!=typeof __PRIVATE_process&&"YES"===(null===(t=__PRIVATE_process.__PRIVATE_env)||void 0===t?void 0:t.lv)},Kf.dv=function(t,e){return t.store(e)},Kf.hv=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)},Kf.fv=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},Kf.prototype.vv=function(e){this.db.onversionchange=function(t){return e(t)}},Kf.prototype.runTransaction=function(r,h,c){return p(this,void 0,void 0,function(){var o,s,a,e,u,n;return y(this,function(t){switch(t.label){case 0:o=r.startsWith("readonly"),s=r.endsWith("idempotent"),a=0,e=function(){var e,n,r,i;return y(this,function(t){switch(t.label){case 0:++a,e=zf.open(u.db,o?"readonly":"readwrite",h),t.label=1;case 1:return t.trys.push([1,3,,4]),(n=c(e).catch(function(t){return e.abort(t),ih.reject(t)}).Gu()).catch(function(){}),[4,e.wv];case 2:return t.sent(),[2,{value:n}];case 3:return r=t.sent(),i=s&&"FirebaseError"!==r.name&&a<3,Mr("SimpleDb","Transaction failed with error: %s. Retrying: %s.",r.message,i),i?[3,4]:[2,{value:Promise.reject(r)}];case 4:return[2]}})},u=this,t.label=1;case 1:return[5,e()];case 2:return"object"==typeof(n=t.sent())?[2,n.value]:[3,1];case 3:return[2]}})})},Kf.prototype.close=function(){this.db.close()},Kf),Bf=(Object.defineProperty(Yf.prototype,"Bu",{get:function(){return this.pv},enumerable:!0,configurable:!0}),Object.defineProperty(Yf.prototype,"bv",{get:function(){return this.gv},enumerable:!0,configurable:!0}),Object.defineProperty(Yf.prototype,"cursor",{set:function(t){this.mv=t},enumerable:!0,configurable:!0}),Yf.prototype.done=function(){this.pv=!0},Yf.prototype.yv=function(t){this.gv=t},Yf.prototype.delete=function(){return Qf(this.mv.delete())},Yf),zf=(Hf.open=function(t,e,n){return new Hf(t.transaction(n,e))},Object.defineProperty(Hf.prototype,"wv",{get:function(){return this._v.promise},enumerable:!0,configurable:!0}),Hf.prototype.abort=function(t){t&&this._v.reject(t),this.aborted||(Mr("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},Hf.prototype.store=function(t){var e=this.transaction.objectStore(t);return Fr(!!e,"Object store not part of transaction: "+t),new Xf(e)},Hf),Xf=(Wf.prototype.put=function(t,e){return Qf(void 0!==e?(Mr("SimpleDb","PUT",this.store.name,t,e),this.store.put(e,t)):(Mr("SimpleDb","PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},Wf.prototype.add=function(t){return Mr("SimpleDb","ADD",this.store.name,t,t),Qf(this.store.add(t))},Wf.prototype.get=function(e){var n=this;return Qf(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Mr("SimpleDb","GET",n.store.name,e,t),t})},Wf.prototype.delete=function(t){return Mr("SimpleDb","DELETE",this.store.name,t),Qf(this.store.delete(t))},Wf.prototype.count=function(){return Mr("SimpleDb","COUNT",this.store.name),Qf(this.store.count())},Wf.prototype.Iv=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.Tv(n,function(t,e){r.push(e)}).next(function(){return r})},Wf.prototype.Ev=function(t,e){Mr("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Rv=!1;var r=this.cursor(n);return this.Tv(r,function(t,e,n){return n.delete()})},Wf.prototype.Av=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.Tv(r,e)},Wf.prototype.Dv=function(i){var t=this.cursor({});return new ih(function(n,r){t.onerror=function(t){var e=$f(t.target.error);r(e)},t.onsuccess=function(t){var e=t.target.result;e?i(e.primaryKey,e.value).next(function(t){t?e.continue():n()}):n()}})},Wf.prototype.Tv=function(t,s){var a=[];return new ih(function(o,e){t.onerror=function(t){e(t.target.error)},t.onsuccess=function(t){var e=t.target.result;if(e){var n=new Bf(e),r=s(e.primaryKey,e.value,n);if(r instanceof ih){var i=r.catch(function(t){return n.done(),ih.reject(t)});a.push(i)}n.Bu?o():null===n.bv?e.continue():e.continue(n.bv)}else o()}}).next(function(){return ih.zu(a)})},Wf.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(Fr(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},Wf.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Rv?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},Wf);function Wf(t){this.store=t}function Hf(t){var n=this;this.transaction=t,this.aborted=!1,this._v=new Yu,this.transaction.oncomplete=function(){n._v.resolve()},this.transaction.onabort=function(){t.error?n._v.reject(t.error):n._v.resolve()},this.transaction.onerror=function(t){var e=$f(t.target.error);n._v.reject(e)}}function Yf(t){this.mv=t,this.pv=!1,this.gv=null}function Kf(t){this.db=t,12.2===Kf.hv(l())&&Ur("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}function Qf(t){return new ih(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=$f(t.target.error);r(e)}})}var Jf=!1;function $f(t){var e=Gf.hv(l());if(12.2<=e&&e<13){var n="An internal error was encountered in the Indexed Database server";if(0<=t.message.indexOf(n)){var r=new oi("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return Jf||(Jf=!0,setTimeout(function(){throw r},0)),r}}return t}var Zf=(tl.Sv=function(t,e,n,r){return Fr(""!==t.uid,"UserID must not be an empty string."),new tl(t._()?t.uid:"",e,n,r)},tl.prototype.Cv=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return il(t).Av({index:xl.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},tl.prototype.Ah=function(e,t,n){return this.Vv(e).next(function(t){return t.lastStreamToken=rl(n),sl(e).put(t)})},tl.prototype.Fh=function(t){return this.Vv(t).next(function(t){return t.lastStreamToken})},tl.prototype.xh=function(e,n){return this.Vv(e).next(function(t){return t.lastStreamToken=rl(n),sl(e).put(t)})},tl.prototype.Th=function(h,c,f,l){var p=this,d=ol(h),y=il(h);return y.add({}).next(function(t){Fr("number"==typeof t,"Auto-generated key is not a number");for(var e=new th(t,c,f,l),n=p.serializer.kv(p.userId,e),r=[],i=new co(function(t,e){return zr(t.ot(),e.ot())}),o=0,s=l;o<s.length;o++){var a=s[o],u=Ll.key(p.userId,a.key.path,t);i=i.add(a.key.path.tt()),r.push(y.put(n)),r.push(d.put(u,Ll.PLACEHOLDER))}return i.forEach(function(t){r.push(p.as.Nv(h,t))}),h.ss(function(){p.Pv[t]=e.keys()}),ih.zu(r).next(function(){return e})})},tl.prototype.kh=function(t,e){var n=this;return il(t).get(e).next(function(t){return t?(Fr(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.Ov(t)):null})},tl.prototype.Rh=function(t,n){var r=this;return this.Pv[n]?ih.resolve(this.Pv[n]):this.kh(t,n).next(function(t){if(t){var e=t.keys();return r.Pv[n]=e}return null})},tl.prototype.Jh=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return il(t).Av({index:xl.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(Fr(e.batchId>=i,"Should have found mutation after "+i),o=r.serializer.Ov(e)),n.done()}).next(function(){return o})},tl.prototype.Oh=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return il(t).Av({index:xl.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},tl.prototype.gh=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return il(t).Iv(xl.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.Ov(t)})})},tl.prototype.ls=function(a,u){var h=this,t=Ll.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),c=[];return ol(a).Av({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],s=Ff(i);if(r===h.userId&&u.path.isEqual(s))return il(a).get(o).next(function(t){if(!t)throw jr("Dangling document-mutation reference found: "+e+" which points to "+o);Fr(t.userId===h.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),c.push(h.serializer.Ov(t))});n.done()}).next(function(){return c})},tl.prototype.ps=function(r,t){var u=this,h=new co(zr),i=[];return t.forEach(function(a){var t=Ll.prefixForPath(u.userId,a.path),e=IDBKeyRange.lowerBound(t),n=ol(r).Av({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Ff(i);r===u.userId&&a.path.isEqual(s)?h=h.add(o):n.done()});i.push(n)}),ih.zu(i).next(function(){return u.Fv(r,h)})},tl.prototype.Ts=function(t,e){var a=this;Fr(!e.Zn(),"Document queries shouldn't go down this path"),Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");var u=e.path,h=u.length+1,n=Ll.prefixForPath(this.userId,u),r=IDBKeyRange.lowerBound(n),c=new co(zr);return ol(t).Av({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Ff(i);r===a.userId&&u.rt(s)?s.length===h&&(c=c.add(o)):n.done()}).next(function(){return a.Fv(t,c)})},tl.prototype.Fv=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(il(t).get(e).next(function(t){if(null===t)throw jr("Dangling document-mutation reference found, which points to "+e);Fr(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.Ov(t))}))}),ih.zu(i).next(function(){return r})},tl.prototype.Nh=function(e,n){var r=this;return nl(e.xv,this.userId,n).next(function(t){return e.ss(function(){r.hc(n.batchId)}),ih.forEach(t,function(t){return r.sh.jv(e,t)})})},tl.prototype.hc=function(t){delete this.Pv[t]},tl.prototype.Ch=function(n){var o=this;return this.Cv(n).next(function(t){if(!t)return ih.resolve();var e=IDBKeyRange.lowerBound(Ll.prefixForUser(o.userId)),i=[];return ol(n).Av({range:e},function(t,e,n){if(t[0]===o.userId){var r=Ff(t[1]);i.push(r)}else n.done()}).next(function(){Fr(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.ot()}))})})},tl.prototype.xu=function(t,e){return el(t,this.userId,e)},tl.prototype.Vv=function(t){var e=this;return sl(t).get(this.userId).next(function(t){return t||new Cl(e.userId,-1,"")})},tl);function tl(t,e,n,r){this.userId=t,this.serializer=e,this.as=n,this.sh=r,this.Pv={}}function el(t,o,e){var n=Ll.prefixForPath(o,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),a=!1;return ol(t).Av({range:r,Rv:!0},function(t,e,n){var r=t[0],i=t[1];t[2],r===o&&i===s&&(a=!0),n.done()}).next(function(){return a})}function nl(t,e,n){var r=t.store(xl.store),i=t.store(Ll.store),o=[],s=IDBKeyRange.only(n.batchId),a=0,u=r.Av({range:s},function(t,e,n){return a++,n.delete()});o.push(u.next(function(){Fr(1===a,"Dangling document-mutation reference found: Missing batch "+n.batchId)}));for(var h=[],c=0,f=n.mutations;c<f.length;c++){var l=f[c],p=Ll.key(e,l.key.path,n.batchId);o.push(i.delete(p)),h.push(l.key)}return ih.zu(o).next(function(){return h})}function rl(t){return t instanceof Uint8Array?(Fr(Gf.av(),"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function il(t){return hp.dv(t,xl.store)}function ol(t){return hp.dv(t,Ll.store)}function sl(t){return hp.dv(t,Cl.store)}var al=(ul.prototype.Zh=function(e){var n=this;return this.Lv(e).next(function(t){return t.highestTargetId=n.Uv.after(t.highestTargetId),n.Bv(e,t).next(function(){return t.highestTargetId})})},ul.prototype.jh=function(t){return this.Lv(t).next(function(t){return Bi.W(new Gi(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},ul.prototype.Mv=function(t){return fl(t.xv)},ul.prototype.Wh=function(e,n,r){var i=this;return this.Lv(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.J()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.Bv(e,t)})},ul.prototype.tc=function(e,n){var r=this;return this.qv(e,n).next(function(){return r.Lv(e).next(function(t){return t.targetCount+=1,r.Qv(n,t),r.Bv(e,t)})})},ul.prototype.Qh=function(t,e){return this.qv(t,e)},ul.prototype.Gv=function(e,t){var n=this;return this.Wv(e,t.targetId).next(function(){return hl(e).delete(t.targetId)}).next(function(){return n.Lv(e)}).next(function(t){return Fr(0<t.targetCount,"Removing from an empty target cache"),t.targetCount-=1,n.Bv(e,t)})},ul.prototype.Jo=function(r,i,o){var s=this,a=0,u=[];return hl(r).Av(function(t,e){var n=s.serializer.zv(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(a++,u.push(s.Gv(r,n)))}).next(function(){return ih.zu(u)}).next(function(){return a})},ul.prototype.qe=function(t,r){var i=this;return hl(t).Av(function(t,e){var n=i.serializer.zv(e);r(n)})},ul.prototype.Lv=function(t){return cl(t.xv)},ul.prototype.Bv=function(t,e){return(n=t,hp.dv(n,Xl.store)).put(Xl.key,e);var n},ul.prototype.qv=function(t,e){return hl(t).put(this.serializer.Kv(e))},ul.prototype.Qv=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},ul.prototype.Hv=function(t){return this.Lv(t).next(function(t){return t.targetCount})},ul.prototype.$h=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),s=null;return hl(t).Av({range:n,index:Bl.queryTargetsIndexName},function(t,e,n){var r=o.serializer.zv(e);i.isEqual(r.target)&&(s=r,n.done())}).next(function(){return s})},ul.prototype.Bh=function(n,t,r){var i=this,o=[],s=ll(n);return t.forEach(function(t){var e=Uf(t.path);o.push(s.put(new zl(r,e))),o.push(i.sh.Pu(n,t))}),ih.zu(o)},ul.prototype.Lh=function(n,t,r){var i=this,o=ll(n);return ih.forEach(t,function(t){var e=Uf(t.path);return ih.zu([o.delete([r,e]),i.sh.Cu(n,t)])})},ul.prototype.Wv=function(t,e){var n=ll(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},ul.prototype.ec=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=ll(t),o=ou();return r.Av({range:n,Rv:!0},function(t,e,n){var r=Ff(t[1]),i=new Yi(r);o=o.add(i)}).next(function(){return o})},ul.prototype.xu=function(t,e){var n=Uf(e.path),r=IDBKeyRange.bound([n],[Wr(n)],!1,!0),i=0;return ll(t).Av({index:zl.documentTargetsIndex,Rv:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},ul.prototype.Ze=function(t,e){var n=this;return hl(t).get(e).next(function(t){return t?n.serializer.zv(t):null})},ul);function ul(t,e){this.sh=t,this.serializer=e,this.Uv=wf.Ql()}function hl(t){return hp.dv(t,Bl.store)}function cl(t){return Gf.dv(t,Xl.store).get(Xl.key).next(function(t){return Fr(null!==t,"Missing metadata row."),t})}function fl(t){return cl(t).next(function(t){return t.highestListenSequenceNumber})}function ll(t){return hp.dv(t,zl.store)}var pl,dl=(yl.prototype.Xu=function(t,e,n){return gl(t).put(wl(e),n)},yl.prototype.Zu=function(t,e){var n=gl(t),r=wl(e);return n.delete(r)},yl.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.Jv(e,t)})},yl.prototype.ts=function(t,e){var n=this;return gl(t).get(wl(e)).next(function(t){return n.Yv(t)})},yl.prototype.Xv=function(t,e){var n=this;return gl(t).get(wl(e)).next(function(t){var e=n.Yv(t);return e?{$v:e,size:bl(t)}:null})},yl.prototype.getEntries=function(t,e){var r=this,i=Za();return this.Zv(t,e,function(t,e){var n=r.Yv(e);i=i.bt(t,n)}).next(function(){return i})},yl.prototype.tw=function(t,e){var r=this,i=Za(),o=new Ki(Yi.X);return this.Zv(t,e,function(t,e){var n=r.Yv(e);o=n?(i=i.bt(t,n),o.bt(t,bl(e))):(i=i.bt(t,null),o.bt(t,0))}).next(function(){return{nw:i,iw:o}})},yl.prototype.Zv=function(t,e,i){if(e.nt())return ih.resolve();var n=IDBKeyRange.bound(e.first().path.st(),e.last().path.st()),o=e.At(),s=o.kt();return gl(t).Av({range:n},function(t,e,n){for(var r=Yi.pt(t);s&&Yi.X(s,r)<0;)i(s,null),s=o.kt();s&&s.isEqual(r)&&(i(s,e),s=o.Nt()?o.kt():null),s?n.yv(s.path.st()):n.done()}).next(function(){for(;s;)i(s,null),s=o.Nt()?o.kt():null})},yl.prototype.gs=function(t,i,e){var o=this;Fr(!i.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");var s=eu(),a=i.path.length+1,n={};if(e.isEqual(Bi.MIN)){var r=i.path.st();n.range=IDBKeyRange.lowerBound(r)}else{var u=i.path.st(),h=this.serializer.ew(e);n.range=IDBKeyRange.lowerBound([u,h],!0),n.index=Vl.collectionReadTimeIndex}return gl(t).Av(n,function(t,e,n){if(t.length===a){var r=o.serializer.rw(e);i.path.rt(r.key.path)?r instanceof Us&&i.matches(r)&&(s=s.bt(r.key,r)):n.done()}}).next(function(){return s})},yl.prototype.fc=function(t,e){var r=this,i=$a(),o=this.serializer.ew(e),n=gl(t),s=IDBKeyRange.lowerBound(o,!0);return n.Av({index:Vl.readTimeIndex,range:s},function(t,e){var n=r.serializer.rw(e);i=i.bt(n.key,n),o=e.readTime}).next(function(){return{lc:i,readTime:r.serializer.uw(o)}})},yl.prototype.dc=function(t){var r=this,e=gl(t),i=Bi.MIN;return e.Av({index:Vl.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(i=r.serializer.uw(e.readTime)),n.done()}).next(function(){return i})},yl.prototype.Dh=function(t){return new yl.sw(this,!!t&&t.Ph)},yl.prototype.ow=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},yl.prototype.getMetadata=function(t){return ml(t).get(jl.key).next(function(t){return Fr(!!t,"Missing document cache metadata"),t})},yl.prototype.Jv=function(t,e){return ml(t).put(jl.key,e)},yl.prototype.Yv=function(t){if(t){var e=this.serializer.rw(t);return e instanceof Vs&&e.version.isEqual(Bi.K())?null:e}return null},yl.sw=(t(vl,pl=oh),vl.prototype.rs=function(s){var a=this,u=[],h=0,c=new co(function(t,e){return zr(t.ot(),e.ot())});return this.Hu.forEach(function(t,e){var n=a.cw.get(t);if(Fr(void 0!==n,"Cannot modify a document that wasn't read (for "+t+")"),e){Fr(!a.readTime.isEqual(Bi.MIN),"Cannot add a document with a read time of zero");var r=a.hw.serializer.aw(e,a.readTime);c=c.add(t.path.tt());var i=bl(r);h+=i-n,u.push(a.hw.Xu(s,t,r))}else if(h-=n,a.Ph){var o=a.hw.serializer.aw(new Vs(t,Bi.K()),a.readTime);u.push(a.hw.Xu(s,t,o))}else u.push(a.hw.Zu(s,t))}),c.forEach(function(t){u.push(a.hw.as.Nv(s,t))}),u.push(this.hw.updateMetadata(s,h)),ih.zu(u)},vl.prototype.ns=function(t,e){var n=this;return this.hw.Xv(t,e).next(function(t){return null===t?(n.cw.set(e,0),null):(n.cw.set(e,t.size),t.$v)})},vl.prototype.es=function(t,e){var n=this;return this.hw.tw(t,e).next(function(t){var e=t.nw;return t.iw.forEach(function(t,e){n.cw.set(t,e)}),e})},vl),yl);function yl(t,e){this.serializer=t,this.as=e}function vl(t,e){var n=pl.call(this)||this;return n.hw=t,n.Ph=e,n.cw=new Zu(function(t){return t.toString()}),n}function ml(t){return hp.dv(t,jl.store)}function gl(t){return hp.dv(t,Vl.store)}function wl(t){return t.path.st()}function bl(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw jr("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}var El=(Dl.prototype.Nv=function(t,e){return this.fw.add(e),ih.resolve()},Dl.prototype.Is=function(t,e){return ih.resolve(this.fw.getEntries(e))},Dl),Il=(Sl.prototype.add=function(t){Fr(t.length%2==1,"Expected a collection path.");var e=t.et(),n=t.tt(),r=this.index[e]||new co(Xi.X),i=!r.has(n);return this.index[e]=r.add(n),i},Sl.prototype.has=function(t){var e=t.et(),n=t.tt(),r=this.index[e];return r&&r.has(n)},Sl.prototype.getEntries=function(t){return(this.index[t]||new co(Xi.X)).st()},Sl),Tl=9,Al=(Nl.prototype.createOrUpgrade=function(n,r,t,e){var i=this;Fr(t<e&&0<=t&&e<=Tl,"Unexpected schema upgrade from v"+t+" to v{toVersion}.");var o,s=new zf(r);t<1&&1<=e&&(n.createObjectStore(Rl.store),(o=n).createObjectStore(Cl.store,{keyPath:Cl.keyPath}),o.createObjectStore(xl.store,{keyPath:xl.keyPath,autoIncrement:!0}).createIndex(xl.userMutationsIndex,xl.userMutationsKeyPath,{unique:!0}),o.createObjectStore(Ll.store),Jl(n),n.createObjectStore(Vl.store));var a,u=ih.resolve();return t<3&&3<=e&&(0!==t&&((a=n).deleteObjectStore(zl.store),a.deleteObjectStore(Bl.store),a.deleteObjectStore(Xl.store),Jl(n)),u=u.next(function(){return t=s.store(Xl.store),e=new Xl(0,0,Bi.MIN.J(),0),t.put(Xl.key,e);var t,e})),t<4&&4<=e&&(0!==t&&(u=u.next(function(){return r=n,(i=s).store(xl.store).Iv().next(function(t){r.deleteObjectStore(xl.store),r.createObjectStore(xl.store,{keyPath:xl.keyPath,autoIncrement:!0}).createIndex(xl.userMutationsIndex,xl.userMutationsKeyPath,{unique:!0});var e=i.store(xl.store),n=t.map(function(t){return e.put(t)});return ih.zu(n)});var r,i})),u=u.next(function(){n.createObjectStore($l.store,{keyPath:$l.keyPath})})),t<5&&5<=e&&(u=u.next(function(){return i.removeAcknowledgedMutations(s)})),t<6&&6<=e&&(u=u.next(function(){return n.createObjectStore(jl.store),i.addDocumentGlobal(s)})),t<7&&7<=e&&(u=u.next(function(){return i.ensureSequenceNumbers(s)})),t<8&&8<=e&&(u=u.next(function(){return i.createCollectionParentIndex(n,s)})),t<9&&9<=e&&(u=u.next(function(){var t,e;(e=n).objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges"),(t=r.objectStore(Vl.store)).createIndex(Vl.readTimeIndex,Vl.readTimeIndexPath,{unique:!1}),t.createIndex(Vl.collectionReadTimeIndex,Vl.collectionReadTimeIndexPath,{unique:!1})})),u},Nl.prototype.addDocumentGlobal=function(e){var n=0;return e.store(Vl.store).Av(function(t,e){n+=bl(e)}).next(function(){var t=new jl(n);return e.store(jl.store).put(jl.key,t)})},Nl.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(Cl.store),e=r.store(xl.store);return t.Iv().next(function(t){return ih.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.Iv(xl.userMutationsIndex,t).next(function(t){return ih.forEach(t,function(t){Fr(t.userId===n.userId,"Cannot process batch "+t.batchId+" from unexpected user");var e=i.serializer.Ov(t);return nl(r,n.userId,e).next(function(){})})})})})},Nl.prototype.ensureSequenceNumbers=function(t){var s=t.store(zl.store),e=t.store(Vl.store);return fl(t).next(function(i){var o=[];return e.Av(function(t,e){var n=new Xi(t),r=[0,Uf(n)];o.push(s.get(r).next(function(t){return t?ih.resolve():(e=n,s.put(new zl(0,Uf(e),i)));var e}))}).next(function(){return ih.zu(o)})})},Nl.prototype.createCollectionParentIndex=function(t,e){function i(t){if(o.add(t)){var e=t.et(),n=t.tt();return r.put({collectionId:e,parent:Uf(n)})}}t.createObjectStore(Wl.store,{keyPath:Wl.keyPath});var r=e.store(Wl.store),o=new Il;return e.store(Vl.store).Av({Rv:!0},function(t,e){var n=new Xi(t);return i(n.tt())}).next(function(){return e.store(Ll.store).Av({Rv:!0},function(t,e){t[0];var n=t[1],r=(t[2],Ff(n));return i(r.tt())})})},Nl);function Nl(t){this.serializer=t}function Sl(){this.index={}}function Dl(){this.fw=new Il}function kl(t,e){this.seconds=t,this.nanoseconds=e}var Rl=(_l.store="owner",_l.key="owner",_l);function _l(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}var Cl=(Ol.store="mutationQueues",Ol.keyPath="userId",Ol),xl=(Pl.store="mutations",Pl.keyPath="batchId",Pl.userMutationsIndex="userMutationsIndex",Pl.userMutationsKeyPath=["userId","batchId"],Pl);function Pl(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}function Ol(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}var Ll=(ql.prefixForUser=function(t){return[t]},ql.prefixForPath=function(t,e){return[t,Uf(e)]},ql.key=function(t,e,n){return[t,Uf(e),n]},ql.store="documentMutations",ql.PLACEHOLDER=new ql,ql);function ql(){}function Ml(t,e){this.path=t,this.readTime=e}function Ul(t,e){this.path=t,this.version=e}var Vl=(Gl.store="remoteDocuments",Gl.readTimeIndex="readTimeIndex",Gl.readTimeIndexPath="readTime",Gl.collectionReadTimeIndex="collectionReadTimeIndex",Gl.collectionReadTimeIndexPath=["parentPath","readTime"],Gl),jl=(Fl.store="remoteDocumentGlobal",Fl.key="remoteDocumentGlobalKey",Fl);function Fl(t){this.byteSize=t}function Gl(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o}var Bl=(Ql.store="targets",Ql.keyPath="targetId",Ql.queryTargetsIndexName="queryTargetsIndex",Ql.queryTargetsKeyPath=["canonicalId","targetId"],Ql),zl=(Kl.store="targetDocuments",Kl.keyPath=["targetId","path"],Kl.documentTargetsIndex="documentTargetsIndex",Kl.documentTargetsKeyPath=["path","targetId"],Kl),Xl=(Yl.key="targetGlobalKey",Yl.store="targetGlobal",Yl),Wl=(Hl.store="collectionParents",Hl.keyPath=["collectionId","parent"],Hl);function Hl(t,e){this.collectionId=t,this.parent=e}function Yl(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}function Kl(t,e,n){this.targetId=t,this.path=e,Fr(0===t==(void 0!==(this.sequenceNumber=n)),"A target-document row must either have targetId == 0 and a defined sequence number, or a non-zero targetId and no sequence number")}function Ql(t,e,n,r,i,o,s){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s}function Jl(t){t.createObjectStore(zl.store,{keyPath:zl.keyPath}).createIndex(zl.documentTargetsIndex,zl.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Bl.store,{keyPath:Bl.keyPath}).createIndex(Bl.queryTargetsIndexName,Bl.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Xl.store)}var $l=(Zl.store="clientMetadata",Zl.keyPath="clientId",Zl);function Zl(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}var tp=s(s(s([Cl.store,xl.store,Ll.store,Vl.store,Bl.store,Rl.store,Xl.store,zl.store],[$l.store]),[jl.store]),[Wl.store]),ep=(np.prototype.Nv=function(t,e){var n=this;if(Fr(e.length%2==1,"Expected a collection path."),this.lw.has(e))return ih.resolve();var r=e.et(),i=e.tt();t.ss(function(){n.lw.add(e)});var o={collectionId:r,parent:Uf(i)};return rp(t).put(o)},np.prototype.Is=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[Wr(i),""],!1,!0);return rp(t).Iv(e).next(function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if(r.collectionId!==i)break;o.push(Ff(r.parent))}return o})},np);function np(){this.lw=new Il}function rp(t){return hp.dv(t,Wl.store)}var ip=(op.prototype.rw=function(t){if(t.document)return this.dw.Pr(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=Yi.pt(t.noDocument.path),n=this.vw(t.noDocument.readTime);return new Vs(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}return t.unknownDocument?(e=Yi.pt(t.unknownDocument.path),n=this.vw(t.unknownDocument.version),new js(e,n)):jr("Unexpected DbRemoteDocument")},op.prototype.aw=function(t,e){var n=this.ew(e),r=t.key.path.tt().st();if(t instanceof Us){var i=t.proto?t.proto:this.dw.Dr(t),o=t.hasCommittedMutations;return new Vl(null,null,i,o,n,r)}if(t instanceof Vs){var s=t.key.path.st(),a=this.ww(t.version);return o=t.hasCommittedMutations,new Vl(null,new Ml(s,a),null,o,n,r)}if(t instanceof js){s=t.key.path.st();var u=this.ww(t.version);return new Vl(new Ul(s,u),null,null,!0,n,r)}return jr("Unexpected MaybeDocument")},op.prototype.ew=function(t){var e=t.J();return[e.seconds,e.nanoseconds]},op.prototype.uw=function(t){var e=new Gi(t[0],t[1]);return Bi.W(e)},op.prototype.ww=function(t){var e=t.J();return new kl(e.seconds,e.nanoseconds)},op.prototype.vw=function(t){var e=new Gi(t.seconds,t.nanoseconds);return Bi.W(e)},op.prototype.kv=function(t,e){var n=this,r=e.baseMutations.map(function(t){return n.dw.jr(t)}),i=e.mutations.map(function(t){return n.dw.jr(t)});return new xl(t,e.batchId,e.Gn.toMillis(),r,i)},op.prototype.Ov=function(t){var e=this,n=(t.baseMutations||[]).map(function(t){return e.dw.Mr(t)}),r=t.mutations.map(function(t){return e.dw.Mr(t)}),i=Gi.fromMillis(t.localWriteTimeMs);return new th(t.batchId,i,n,r)},op.prototype.mw=function(t){var e=[];return t.forEach(function(t){e.push(Uf(t.path))}),e},op.prototype.pw=function(t){for(var e=ou(),n=0,r=t;n<r.length;n++){var i=r[n];e=e.add(new Yi(Ff(i)))}return e},op.prototype.zv=function(t){var e,n=this.vw(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.vw(t.lastLimboFreeSnapshotVersion):Bi.MIN,i=t.resumeToken;return e=void 0!==t.query.documents?this.dw.Hr(t.query):this.dw.Zr(t.query),new Xa(e,t.targetId,fa.ki,t.lastListenSequenceNumber,n,r,i)},op.prototype.Kv=function(t){Fr(fa.ki===t.Fi,"Only queries with purpose "+fa.ki+" may be stored, got "+t.Fi);var e,n,r=this.ww(t.xi),i=this.ww(t.lastLimboFreeSnapshotVersion);return e=t.target.Zn()?this.dw.Kr(t.target):this.dw.Jr(t.target),n=t.resumeToken instanceof Uint8Array?(Fr(Gf.av(),"Persisting non-string stream tokens is only supported with mock persistence ."),t.resumeToken.toString()):t.resumeToken,new Bl(t.targetId,t.target.canonicalId(),r,n,t.sequenceNumber,i,e)},op);function op(t){this.dw=t}var sp,ap="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",up=(t(fp,sp=ah),fp),hp=(cp.dv=function(t,e){if(t instanceof up)return Gf.dv(t.xv,e);throw jr("IndexedDbPersistence must use instances of IndexedDbTransaction")},cp.Pw=function(n){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:if(!cp.nl())throw new oi(ii.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(e=new cp(n.allowTabSynchronization,n.persistenceKey,n.clientId,n.platform,n.Sw,n.Wc,n.serializer,n.gw)).start()];case 1:return t.sent(),[2,e]}})})},cp.prototype.start=function(){var e=this;return Fr(!this.qo,"IndexedDbPersistence double-started!"),Fr(null!==this.window,"Expected 'window' to be defined"),Gf.cv(this.Rw,Tl,new Al(this.serializer)).then(function(t){return e.Cw=t,e.Vw()}).then(function(){return e.kw(),e.Nw(),e.Ow(),e.Cw.runTransaction("readonly-idempotent",[Xl.store],function(t){return fl(t)})}).then(function(t){e.Fw=new ch(t,e.gw)}).then(function(){e.bw=!0}).catch(function(t){return e.Cw&&e.Cw.close(),Promise.reject(t)})},cp.prototype.xw=function(n){var t=this;return this.Ew=function(e){return p(t,void 0,void 0,function(){return y(this,function(t){return this.qo?[2,n(e)]:[2]})})},n(this.isPrimary)},cp.prototype.jw=function(n){var t=this;this.Cw.vv(function(e){return p(t,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return null!==e.newVersion?[3,2]:[4,n()];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},cp.prototype.cc=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Wc.Xs(function(){return p(e,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.qo?[4,this.Vw()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},cp.prototype.Vw=function(){var n=this;return this.Cw.runTransaction("readwrite-idempotent",tp,function(e){return pp(e).put(new $l(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.Uw(e).next(function(t){t||(n.isPrimary=!1,n.Wc.Xs(function(){return n.Ew(!1)}))})}).next(function(){return n.Lw(e)}).next(function(t){return n.isPrimary&&!t?n.Bw(e).next(function(){return!1}):!!t&&n.Mw(e).next(function(){return!0})})}).catch(function(t){if(!n.allowTabSynchronization)throw t;return Mr("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.Wc.Xs(function(){return n.Ew(t)}),n.isPrimary=t})},cp.prototype.Uw=function(t){var e=this;return lp(t).get(Rl.key).next(function(t){return ih.resolve(e.qw(t))})},cp.prototype.Qw=function(t){return pp(t).delete(this.clientId)},cp.prototype.Gw=function(){return p(this,void 0,void 0,function(){var i=this;return y(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.Ww(this.Tw,18e5)?[3,2]:(this.Tw=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary-idempotent",function(t){var r=cp.dv(t,$l.store);return r.Iv().next(function(t){var e=i.zw(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return ih.forEach(n,function(t){return r.delete(t.clientId)}).next(function(){return n})})})]);case 1:t.sent().forEach(function(t){i.window.localStorage.removeItem(i.Kw(t.clientId))}),t.label=2;case 2:return[2]}})})},cp.prototype.Ow=function(){var t=this;this.Iw=this.Wc.ao(Ku.Ls,4e3,function(){return t.Vw().then(function(){return t.Gw()}).then(function(){return t.Ow()})})},cp.prototype.qw=function(t){return!!t&&t.ownerId===this.clientId},cp.prototype.Lw=function(e){var i=this;return lp(e).get(Rl.key).next(function(t){if(null!==t&&i.Ww(t.leaseTimestampMs,5e3)&&!i.Hw(t.ownerId)){if(i.qw(t)&&i.networkEnabled)return!0;if(!i.qw(t)){if(!t.allowTabSynchronization)throw new oi(ii.FAILED_PRECONDITION,ap);return!1}}return!(!i.networkEnabled||!i.inForeground)||pp(e).Iv().next(function(t){return void 0===i.zw(t,5e3).find(function(t){if(i.clientId!==t.clientId){var e=!i.networkEnabled&&t.networkEnabled,n=!i.inForeground&&t.inForeground,r=i.networkEnabled===t.networkEnabled;if(e||n&&r)return!0}return!1})})}).next(function(t){return i.isPrimary!==t&&Mr("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},cp.prototype.Af=function(){return p(this,void 0,void 0,function(){var e=this;return y(this,function(t){switch(t.label){case 0:return this.bw=!1,this.Jw(),this.Iw&&(this.Iw.cancel(),this.Iw=null),this.Yw(),this.Xw(),[4,this.Cw.runTransaction("readwrite-idempotent",[Rl.store,$l.store],function(t){return e.Bw(t).next(function(){return e.Qw(t)})})];case 1:return t.sent(),this.Cw.close(),this.$w(),[2]}})})},cp.prototype.zw=function(t,e){var n=this;return t.filter(function(t){return n.Ww(t.updateTimeMs,e)&&!n.Hw(t.clientId)})},cp.prototype.sc=function(){var e=this;return this.Cw.runTransaction("readonly-idempotent",[$l.store],function(t){return pp(t).Iv().next(function(t){return e.zw(t,18e5).map(function(t){return t.clientId})})})},cp.clearPersistence=function(n){return p(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return cp.nl()?(e=n+cp.Aw,[4,Gf.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(cp.prototype,"qo",{get:function(){return this.bw},enumerable:!0,configurable:!0}),cp.prototype.oh=function(t){return Fr(this.qo,"Cannot initialize MutationQueue before persistence is started."),Zf.Sv(t,this.serializer,this.as,this.sh)},cp.prototype.lh=function(){return Fr(this.qo,"Cannot initialize TargetCache before persistence is started."),this.fh},cp.prototype.ah=function(){return Fr(this.qo,"Cannot initialize RemoteDocumentCache before persistence is started."),this.hs},cp.prototype.vh=function(){return Fr(this.qo,"Cannot initialize IndexManager before persistence is started."),this.as},cp.prototype.runTransaction=function(n,t,r){var i=this;Mr("IndexedDbPersistence","Starting transaction:",n);var o,e=t.endsWith("idempotent"),s=t.startsWith("readonly")?e?"readonly-idempotent":"readonly":e?"readwrite-idempotent":"readwrite";return this.Cw.runTransaction(s,tp,function(e){return o=new up(e,i.Fw.next()),"readwrite-primary"===t||"readwrite-primary-idempotent"===t?i.Uw(e).next(function(t){return!!t||i.Lw(e)}).next(function(t){if(!t)throw Ur("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.Wc.Xs(function(){return i.Ew(!1)}),new oi(ii.FAILED_PRECONDITION,sh);return r(o)}).next(function(t){return i.Mw(e).next(function(){return t})}):i.Zw(e).next(function(){return r(o)})}).then(function(t){return o.os(),t})},cp.prototype.Zw=function(t){var e=this;return lp(t).get(Rl.key).next(function(t){if(null!==t&&e.Ww(t.leaseTimestampMs,5e3)&&!e.Hw(t.ownerId)&&!e.qw(t)&&!t.allowTabSynchronization)throw new oi(ii.FAILED_PRECONDITION,ap)})},cp.prototype.Mw=function(t){var e=new Rl(this.clientId,this.allowTabSynchronization,Date.now());return lp(t).put(Rl.key,e)},cp.nl=function(){return Gf.nl()},cp.tm=function(t){var e=t.s.projectId;return t.s.o||(e+="."+t.s.database),"firestore/"+t.persistenceKey+"/"+e+"/"},cp.prototype.Bw=function(t){var e=this,n=lp(t);return n.get(Rl.key).next(function(t){return e.qw(t)?(Mr("IndexedDbPersistence","Releasing primary lease."),n.delete(Rl.key)):ih.resolve()})},cp.prototype.Ww=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(Ur("Detected an update time that is in the future: "+t+" > "+n),1))},cp.prototype.kw=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this._w=function(){t.Wc.Xs(function(){return t.inForeground="visible"===t.document.visibilityState,t.Vw()})},this.document.addEventListener("visibilitychange",this._w),this.inForeground="visible"===this.document.visibilityState)},cp.prototype.Yw=function(){this._w&&(Fr(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this._w),this._w=null)},cp.prototype.Nw=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.yw=function(){t.Jw(),t.Wc.Xs(function(){return t.Af()})},this.window.addEventListener("unload",this.yw))},cp.prototype.Xw=function(){this.yw&&(Fr("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.yw),this.yw=null)},cp.prototype.Hw=function(t){try{var e=null!==this.Dw.getItem(this.Kw(t));return Mr("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Ur("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},cp.prototype.Jw=function(){try{this.Dw.setItem(this.Kw(this.clientId),String(Date.now()))}catch(t){Ur("Failed to set zombie client id.",t)}},cp.prototype.$w=function(){try{this.Dw.removeItem(this.Kw(this.clientId))}catch(t){}},cp.prototype.Kw=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},cp.Aw="main",cp);function cp(t,e,n,r,i,o,s,a){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Wc=o,this.gw=a,this.bw=!1,this.isPrimary=!1,this.networkEnabled=!0,this.yw=null,this.inForeground=!1,this._w=null,this.Iw=null,this.Tw=Number.NEGATIVE_INFINITY,this.Ew=function(t){return Promise.resolve()},this.sh=new dp(this,i),this.Rw=e+cp.Aw,this.serializer=new ip(s),this.document=r.document,this.fh=new al(this.sh,this.serializer),this.as=new ep,this.hs=new dl(this.serializer,this.as),!r.window||!r.window.localStorage)throw new oi(ii.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.Dw=this.window.localStorage}function fp(t,e){var n=sp.call(this)||this;return n.xv=t,n.Mh=e,n}function lp(t){return t.store(Rl.store)}function pp(t){return t.store($l.store)}var dp=(yp.prototype.zo=function(t){var n=this.im(t);return this.db.lh().Hv(t).next(function(e){return n.next(function(t){return e+t})})},yp.prototype.im=function(t){var e=0;return this.Ho(t,function(t){e++}).next(function(){return e})},yp.prototype.qe=function(t,e){return this.db.lh().qe(t,e)},yp.prototype.Ho=function(t,n){return this.em(t,function(t,e){return n(e)})},yp.prototype.uh=function(t){this.nm=t},yp.prototype.Pu=function(t,e){return vp(t,e)},yp.prototype.Cu=function(t,e){return vp(t,e)},yp.prototype.Jo=function(t,e,n){return this.db.lh().Jo(t,e,n)},yp.prototype.jv=function(t,e){return vp(t,e)},yp.prototype.rm=function(t,e){return this.nm.xu(e)?ih.resolve(!0):(r=e,i=!1,sl(n=t).Dv(function(t){return el(n,t,r).next(function(t){return t&&(i=!0),ih.resolve(!t)})}).next(function(){return i}));var n,r,i},yp.prototype.Yo=function(r,i){var o=this,s=this.db.ah().Dh(),a=[],u=0;return this.em(r,function(e,t){if(t<=i){var n=o.rm(r,e).next(function(t){if(!t)return u++,s.ts(r,e).next(function(){return s.Zu(e),ll(r).delete([0,Uf(e.path)])})});a.push(n)}}).next(function(){return ih.zu(a)}).next(function(){return s.apply(r)}).next(function(){return u})},yp.prototype.removeTarget=function(t,e){var n=e.ji(t.Mh);return this.db.lh().Qh(t,n)},yp.prototype.Gh=function(t,e){return vp(t,e)},yp.prototype.em=function(t,o){var s,e=ll(t),a=ch.ks;return e.Av({index:zl.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(a!==ch.ks&&o(new Yi(Ff(s)),a),a=i,s=r):a=ch.ks}).next(function(){a!==ch.ks&&o(new Yi(Ff(s)),a)})},yp.prototype.$o=function(t){return this.db.ah().ow(t)},yp);function yp(t,e){this.db=t,this.nm=null,this.xo=new xh(this,e)}function vp(t,e){return ll(t).put((n=e,r=t.Mh,new zl(0,Uf(n.path),r)));var n,r}var mp=(bp.prototype.wh=function(t){this.um=t},bp.prototype.gs=function(e,r,i,o){var s=this;return Fr(void 0!==this.um,"setLocalDocumentsView() not called"),r.gi()?this.sm(e,r):i.isEqual(Bi.MIN)?this.sm(e,r):this.um.ws(e,o).next(function(t){var n=s.om(r,t);return(r.Ri()||r.Ai())&&s.Zl(r.ei,n,o,i)?s.sm(e,r):(Lr()<=Nr.DEBUG&&Mr("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),s.um.gs(e,r,i).next(function(e){return n.forEach(function(t){e=e.bt(t.key,t)}),e}))})},bp.prototype.om=function(n,t){var r=new co(function(t,e){return n.yi(t,e)});return t.forEach(function(t,e){e instanceof Us&&n.matches(e)&&(r=r.add(e))}),r},bp.prototype.Zl=function(t,e,n,r){if(n.size!==e.size)return!0;var i=t===aa.ti?e.last():e.first();return!!i&&(i.hasPendingWrites||0<i.version.h(r))},bp.prototype.sm=function(t,e){return Lr()<=Nr.DEBUG&&Mr("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.um.gs(t,e,Bi.MIN)},bp),gp=(wp.prototype.Cv=function(t){return ih.resolve(0===this.cs.length)},wp.prototype.Ah=function(t,e,n){var r=e.batchId,i=this.am(r,"acknowledged");Fr(0===i,"Can only acknowledge the first batch in the mutation queue");var o=this.cs[i];return Fr(r===o.batchId,"Queue ordering failure: expected batch "+r+", got batch "+o.batchId),this.lastStreamToken=n,ih.resolve()},wp.prototype.Fh=function(t){return ih.resolve(this.lastStreamToken)},wp.prototype.xh=function(t,e){return this.lastStreamToken=e,ih.resolve()},wp.prototype.Th=function(t,e,n,r){Fr(0!==r.length,"Mutation batches should not be empty");var i=this.hm;this.hm++,0<this.cs.length&&Fr(this.cs[this.cs.length-1].batchId<i,"Mutation batchIDs must be monotonically increasing order");var o=new th(i,e,n,r);this.cs.push(o);for(var s=0,a=r;s<a.length;s++){var u=a[s];this.cm=this.cm.add(new rh(u.key,i)),this.as.Nv(t,u.key.path.tt())}return ih.resolve(o)},wp.prototype.kh=function(t,e){return ih.resolve(this.fm(e))},wp.prototype.Rh=function(t,e){var n=this.fm(e);return Fr(null!=n,"Failed to find local mutation batch."),ih.resolve(n.keys())},wp.prototype.Jh=function(t,e){var n=e+1,r=this.lm(n),i=r<0?0:r;return ih.resolve(this.cs.length>i?this.cs[i]:null)},wp.prototype.Oh=function(){return ih.resolve(0===this.cs.length?-1:this.hm-1)},wp.prototype.gh=function(t){return ih.resolve(this.cs.slice())},wp.prototype.ls=function(t,n){var r=this,e=new rh(n,0),i=new rh(n,Number.POSITIVE_INFINITY),o=[];return this.cm.zt([e,i],function(t){Fr(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.fm(t.ju);Fr(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),ih.resolve(o)},wp.prototype.ps=function(t,e){var r=this,i=new co(zr);return e.forEach(function(e){var t=new rh(e,0),n=new rh(e,Number.POSITIVE_INFINITY);r.cm.zt([t,n],function(t){Fr(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.ju)})}),ih.resolve(this.dm(i))},wp.prototype.Ts=function(t,e){Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;Yi.vt(i)||(i=i.child(""));var o=new rh(new Yi(i),0),s=new co(zr);return this.cm.Kt(function(t){var e=t.key.path;return!!n.rt(e)&&(e.length===r&&(s=s.add(t.ju)),!0)},o),ih.resolve(this.dm(s))},wp.prototype.dm=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.fm(t);null!==e&&r.push(e)}),r},wp.prototype.Nh=function(n,r){var i=this;Fr(0===this.am(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.cs.shift();var o=this.cm;return ih.forEach(r.mutations,function(t){var e=new rh(t.key,r.batchId);return o=o.delete(e),i.sh.jv(n,t.key)}).next(function(){i.cm=o})},wp.prototype.hc=function(t){},wp.prototype.xu=function(t,e){var n=new rh(e,0),r=this.cm.Ht(n);return ih.resolve(e.isEqual(r&&r.key))},wp.prototype.Ch=function(t){return 0===this.cs.length&&Fr(this.cm.nt(),"Document leak -- detected dangling mutation references when queue is empty."),ih.resolve()},wp.prototype.am=function(t,e){var n=this.lm(t);return Fr(0<=n&&n<this.cs.length,"Batches must exist to be "+e),n},wp.prototype.lm=function(t){return 0===this.cs.length?0:t-this.cs[0].batchId},wp.prototype.fm=function(t){var e=this.lm(t);if(e<0||e>=this.cs.length)return null;var n=this.cs[e];return Fr(n.batchId===t,"If found batch must match"),n},wp);function wp(t,e){this.as=t,this.sh=e,this.cs=[],this.hm=1,this.lastStreamToken=zu(),this.cm=new co(rh.Kn)}function bp(){}function Ep(){}var Ip,Tp,Ap=(Fp.prototype.Xu=function(t,e,n){Fr(!n.isEqual(Bi.MIN),"Cannot add a document with a read time of zero");var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.vm(e);return this.docs=this.docs.bt(r,{$v:e,size:s,readTime:n}),this.size+=s-o,this.as.Nv(t,r.path.tt())},Fp.prototype.Zu=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Fp.prototype.ts=function(t,e){var n=this.docs.get(e);return ih.resolve(n?n.$v:null)},Fp.prototype.getEntries=function(t,e){var n=this,r=Za();return e.forEach(function(t){var e=n.docs.get(t);r=r.bt(t,e?e.$v:null)}),ih.resolve(r)},Fp.prototype.gs=function(t,e,n){Fr(!e.Pi(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=eu(),i=new Yi(e.path.child("")),o=this.docs.Dt(i);o.Nt();){var s=o.kt(),a=s.key,u=s.value,h=u.$v,c=u.readTime;if(!e.path.rt(a.path))break;c.h(n)<=0||h instanceof Us&&e.matches(h)&&(r=r.bt(h.key,h))}return ih.resolve(r)},Fp.prototype.wm=function(t,e){return ih.forEach(this.docs,function(t){return e(t)})},Fp.prototype.fc=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},Fp.prototype.dc=function(t){return ih.resolve(Bi.MIN)},Fp.prototype.Dh=function(t){return new Fp.sw(this)},Fp.prototype.ow=function(t){return ih.resolve(this.size)},Fp.sw=(t(Gp,Tp=oh),Gp.prototype.rs=function(n){var r=this,i=[];return this.Hu.forEach(function(t,e){e?i.push(r.hw.Xu(n,e,r.readTime)):r.hw.Zu(t)}),ih.zu(i)},Gp.prototype.ns=function(t,e){return this.hw.ts(t,e)},Gp.prototype.es=function(t,e){return this.hw.getEntries(t,e)},Gp),Fp),Np=(jp.prototype.qe=function(t,n){return this.mm.forEach(function(t,e){return n(e)}),ih.resolve()},jp.prototype.jh=function(t){return ih.resolve(this.lastRemoteSnapshotVersion)},jp.prototype.Mv=function(t){return ih.resolve(this.pm)},jp.prototype.Zh=function(t){var e=this.Uv.after(this.highestTargetId);return this.highestTargetId=e,ih.resolve(e)},jp.prototype.Wh=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.pm&&(this.pm=e),ih.resolve()},jp.prototype.qv=function(t){this.mm.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.pm&&(this.pm=t.sequenceNumber)},jp.prototype.tc=function(t,e){return Fr(!this.mm.has(e.target),"Adding a target that already exists"),this.qv(e),this.targetCount+=1,ih.resolve()},jp.prototype.Qh=function(t,e){return Fr(this.mm.has(e.target),"Updating a non-existent target"),this.qv(e),ih.resolve()},jp.prototype.Gv=function(t,e){return Fr(0<this.targetCount,"Removing a target from an empty cache"),Fr(this.mm.has(e.target),"Removing a non-existent target from the cache"),this.mm.delete(e.target),this.gm.Nu(e.targetId),this.targetCount-=1,ih.resolve()},jp.prototype.Jo=function(n,r,i){var o=this,s=0,a=[];return this.mm.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.mm.delete(t),a.push(o.Wv(n,e.targetId)),s++)}),ih.zu(a).next(function(){return s})},jp.prototype.Hv=function(t){return ih.resolve(this.targetCount)},jp.prototype.$h=function(t,e){var n=this.mm.get(e)||null;return ih.resolve(n)},jp.prototype.Ze=function(t,e){return jr("Not yet implemented.")},jp.prototype.Bh=function(e,t,n){this.gm.Su(t,n);var r=this.persistence.sh,i=[];return r&&t.forEach(function(t){i.push(r.Pu(e,t))}),ih.zu(i)},jp.prototype.Lh=function(e,t,n){this.gm.ku(t,n);var r=this.persistence.sh,i=[];return r&&t.forEach(function(t){i.push(r.Cu(e,t))}),ih.zu(i)},jp.prototype.Wv=function(t,e){return this.gm.Nu(e),ih.resolve()},jp.prototype.ec=function(t,e){var n=this.gm.Fu(e);return ih.resolve(n)},jp.prototype.xu=function(t,e){return ih.resolve(this.gm.xu(e))},jp),Sp=(Vp._m=function(t,e){return new Vp(t,function(t){return new Rp(t,e)})},Vp.Im=function(t){return new Vp(t,function(t){return new kp(t)})},Vp.prototype.Af=function(){return this.bw=!1,Promise.resolve()},Object.defineProperty(Vp.prototype,"qo",{get:function(){return this.bw},enumerable:!0,configurable:!0}),Vp.prototype.sc=function(){return p(this,void 0,void 0,function(){return y(this,function(t){return[2,[this.clientId]]})})},Vp.prototype.xw=function(t){return t(!0)},Vp.prototype.jw=function(){},Vp.prototype.cc=function(t){},Vp.prototype.vh=function(){return this.as},Vp.prototype.oh=function(t){var e=this.bm[t.I()];return e||(e=new gp(this.as,this.sh),this.bm[t.I()]=e),e},Vp.prototype.lh=function(){return this.fh},Vp.prototype.ah=function(){return this.hs},Vp.prototype.runTransaction=function(t,e,n){var r=this;Mr("MemoryPersistence","Starting transaction:",t);var i=new Dp(this.Fw.next());return this.sh.Tm(),n(i).next(function(t){return r.sh.Em(i).next(function(){return t})}).Gu().then(function(t){return i.os(),t})},Vp.prototype.Rm=function(e,n){return ih.Ku((t=this.bm,r=[],wi(t,function(t,e){return r.push(e)}),r).map(function(t){return function(){return t.xu(e,n)}}));var t,r},Vp),Dp=(t(Up,Ip=ah),Up),kp=(Object.defineProperty(Mp.prototype,"Dm",{get:function(){if(this.Am)return this.Am;throw jr("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),Mp.prototype.uh=function(t){this.nm=t},Mp.prototype.Pu=function(t,e){return this.Dm.delete(e),ih.resolve()},Mp.prototype.Cu=function(t,e){return this.Dm.add(e),ih.resolve()},Mp.prototype.jv=function(t,e){return this.Dm.add(e),ih.resolve()},Mp.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.lh();return r.ec(t,e.targetId).next(function(t){t.forEach(function(t){return n.Dm.add(t)})}).next(function(){return r.Gv(t,e)})},Mp.prototype.Tm=function(){this.Am=new Set},Mp.prototype.Em=function(t){var n=this,r=this.persistence.ah().Dh();return ih.forEach(this.Dm,function(e){return n.Pm(t,e).next(function(t){t||r.Zu(e)})}).next(function(){return n.Am=null,r.apply(t)})},Mp.prototype.Gh=function(t,e){var n=this;return this.Pm(t,e).next(function(t){t?n.Dm.delete(e):n.Dm.add(e)})},Mp.prototype.ym=function(t){return 0},Mp.prototype.Pm=function(t,e){var n=this;return ih.Ku([function(){return n.persistence.lh().xu(t,e)},function(){return n.persistence.Rm(t,e)},function(){return ih.resolve(n.nm.xu(e))}])},Mp),Rp=(qp.prototype.Tm=function(){},qp.prototype.Em=function(t){return ih.resolve()},qp.prototype.qe=function(t,e){return this.persistence.lh().qe(t,e)},qp.prototype.zo=function(t){var n=this.Cm(t);return this.persistence.lh().Hv(t).next(function(e){return n.next(function(t){return e+t})})},qp.prototype.Cm=function(t){var e=0;return this.Ho(t,function(t){e++}).next(function(){return e})},qp.prototype.Ho=function(n,r){var i=this;return ih.forEach(this.Sm,function(t,e){return i.rm(n,t,e).next(function(t){return t?ih.resolve():r(e)})})},qp.prototype.uh=function(t){this.nm=t},qp.prototype.Jo=function(t,e,n){return this.persistence.lh().Jo(t,e,n)},qp.prototype.Yo=function(t,n){var r=this,i=0,e=this.persistence.ah(),o=e.Dh();return e.wm(t,function(e){return r.rm(t,e,n).next(function(t){t||(i++,o.Zu(e))})}).next(function(){return o.apply(t)}).next(function(){return i})},qp.prototype.jv=function(t,e){return this.Sm.set(e,t.Mh),ih.resolve()},qp.prototype.removeTarget=function(t,e){var n=e.ji(t.Mh);return this.persistence.lh().Qh(t,n)},qp.prototype.Pu=function(t,e){return this.Sm.set(e,t.Mh),ih.resolve()},qp.prototype.Cu=function(t,e){return this.Sm.set(e,t.Mh),ih.resolve()},qp.prototype.Gh=function(t,e){return this.Sm.set(e,t.Mh),ih.resolve()},qp.prototype.ym=function(t){var e=t.key.toString().length;return t instanceof Us&&(e+=t.data().Ln()),e},qp.prototype.rm=function(t,e,n){var r=this;return ih.Ku([function(){return r.persistence.Rm(t,e)},function(){return ih.resolve(r.nm.xu(e))},function(){return r.persistence.lh().xu(t,e)},function(){var t=r.Sm.get(e);return ih.resolve(void 0!==t&&n<t)}])},qp.prototype.$o=function(t){return this.persistence.ah().ow(t)},qp),_p=(Lp.prototype.Sw=function(){return _h.So(this.cacheSizeBytes)},Lp),Cp=(Op.prototype.start=function(t){var n=this;this.km();var r=new Yu,i=new Yu,o=!1;return this.credentials.S(function(e){o?n.qs.Xs(function(){return n.Gf(e)}):(o=!0,n.Nm(t,i,e).then(function(t){return n.Om(e,t)}).then(r.resolve,r.reject))}),this.qs.Xs(function(){return r.promise}),i.promise},Op.prototype.enableNetwork=function(){var t=this;return this.km(),this.qs.enqueue(function(){return t.Cf.enableNetwork()})},Op.prototype.Nm=function(t,e,n){var r=this;return t instanceof _p?this.Fm(n,t).then(function(t){return e.resolve(),t}).catch(function(t){if(e.reject(t),!r.xm(t))throw t;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.jm()}):(e.resolve(),this.jm())},Op.prototype.xm=function(t){return t instanceof oi?t.code===ii.FAILED_PRECONDITION||t.code===ii.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},Op.prototype.km=function(){if(this.qs.ro)throw new oi(ii.FAILED_PRECONDITION,"The client has already been terminated.")},Op.prototype.Fm=function(r,i){var t=this,o=hp.tm(this.Vm),s=new ju(this.Vm.s,{nr:!0});return Promise.resolve().then(function(){return p(t,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:if(i.synchronizeTabs&&!sf.nl(this.platform))throw new oi(ii.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");return e=i.Sw(),this.pd=i.synchronizeTabs?new sf(this.qs,this.platform,o,this.clientId,r):new yf,[4,hp.Pw({allowTabSynchronization:i.synchronizeTabs,persistenceKey:o,clientId:this.clientId,platform:this.platform,Wc:this.qs,serializer:s,Sw:e,gw:this.pd})];case 1:return n=t.sent(),[2,(this.persistence=n).sh.xo]}})})})},Op.prototype.jm=function(){return this.persistence=Sp.Im(this.clientId),this.pd=new yf,Promise.resolve(null)},Op.prototype.Om=function(h,c){var t=this;return Mr("FirestoreClient","Initializing. user=",h.uid),this.platform.Um(this.Vm).then(function(u){return p(t,void 0,void 0,function(){var e,n,r,i,o,s,a=this;return y(this,function(t){switch(t.label){case 0:return e=new mp,this.jo=new Oh(this.persistence,e,h),[4,this.jo.start()];case 1:return t.sent(),c&&(this.Lm=new Ch(c,this.qs,this.jo)),n=this.platform.Bm(),r=this.platform.Mm(this.Vm.s),i=new Lc(this.qs,u,this.credentials,r),o=function(t){return a.Cf.rd(t,Qr.p)},s=function(t){return a.Cf.rd(t,Qr.g)},this.hd=new Vc(this.jo,i,this.qs,o,n),this.Cf=new Df(this.jo,this.hd,this.pd,h),this.pd.Ja=s,this.hd.Cf=this.Cf,this.pd.Cf=this.Cf,this.qm=new kf(this.Cf),[4,this.pd.start()];case 2:return t.sent(),[4,this.hd.start()];case 3:return t.sent(),[4,this.persistence.xw(function(e){return p(a,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.Cf.Wf(e)];case 1:return t.sent(),this.Lm&&(e&&!this.Lm.qo?this.Lm.start():e||this.Lm.stop()),[2]}})})})];case 4:return t.sent(),[4,this.persistence.jw(function(){return p(a,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})})];case 5:return t.sent(),[2]}})})})},Op.prototype.Gf=function(t){return this.qs.lo(),Mr("FirestoreClient","Credential Changed. Current user: "+t.uid),this.Cf.Gf(t)},Op.prototype.disableNetwork=function(){var t=this;return this.km(),this.qs.enqueue(function(){return t.Cf.disableNetwork()})},Op.prototype.terminate=function(){var t=this;return this.qs.co(function(){return p(t,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Lm&&this.Lm.stop(),[4,this.hd.Af()];case 1:return t.sent(),[4,this.pd.Af()];case 2:return t.sent(),[4,this.persistence.Af()];case 3:return t.sent(),this.credentials.C(),[2]}})})})},Op.prototype.waitForPendingWrites=function(){var t=this;this.km();var e=new Yu;return this.qs.Xs(function(){return t.Cf.Ud(e)}),e.promise},Op.prototype.listen=function(t,e,n){var r=this;this.km();var i=new Rf(t,e,n);return this.qs.Xs(function(){return r.qm.listen(i)}),i},Op.prototype.Pf=function(t){var e=this;this.Qm||this.qs.Xs(function(){return e.qm.Pf(t)})},Op.prototype.Gm=function(t){var e=this;return this.km(),this.qs.enqueue(function(){return e.jo.Yh(t)}).then(function(t){if(t instanceof Us)return t;if(t instanceof Vs)return null;throw new oi(ii.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.)")})},Op.prototype.Wm=function(i){var t=this;return this.km(),this.qs.enqueue(function(){return p(t,void 0,void 0,function(){var e,n,r;return y(this,function(t){switch(t.label){case 0:return[4,this.jo.ic(i,!0)];case 1:return e=t.sent(),n=new bf(i,e.rc),r=n.Yl(e.documents),[2,n.rs(r,!1).snapshot]}})})})},Op.prototype.write=function(t){var e=this;this.km();var n=new Yu;return this.qs.Xs(function(){return e.Cf.write(t,n)}),n.promise},Op.prototype.s=function(){return this.Vm.s},Op.prototype.Zd=function(t){var e=this;this.km(),this.qs.Xs(function(){return e.qm.Zd(t),Promise.resolve()})},Op.prototype.tv=function(t){this.Qm||this.qm.tv(t)},Object.defineProperty(Op.prototype,"Qm",{get:function(){return this.qs.ro},enumerable:!0,configurable:!0}),Op.prototype.transaction=function(t){var e=this;this.km();var n=new Yu;return this.qs.Xs(function(){return e.Cf.runTransaction(e.qs,t,n),Promise.resolve()}),n.promise},Op),xp=(Pp.prototype.next=function(t){this.zm(this.observer.next,t)},Pp.prototype.error=function(t){this.zm(this.observer.error,t)},Pp.prototype.Km=function(){this.muted=!0},Pp.prototype.zm=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},Pp);function Pp(t){this.observer=t,this.muted=!1}function Op(t,e,n,r){this.platform=t,this.Vm=e,this.credentials=n,this.qs=r,this.clientId=Gr.u()}function Lp(t,e){this.cacheSizeBytes=t,this.synchronizeTabs=e}function qp(t,e){this.persistence=t,this.nm=null,this.Sm=new Zu(function(t){return Uf(t.path)}),this.xo=new xh(this,e)}function Mp(t){this.persistence=t,this.nm=null,this.Am=null}function Up(t){var e=Ip.call(this)||this;return e.Mh=t,e}function Vp(t,e){var n=this;this.clientId=t,this.bm={},this.Fw=new ch(0),this.bw=!1,this.bw=!0,this.sh=e(this),this.fh=new Np(this),this.as=new El,this.hs=new Ap(this.as,function(t){return n.sh.ym(t)})}function jp(t){this.persistence=t,this.mm=new Zu(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Bi.MIN,this.highestTargetId=0,this.pm=0,this.gm=new nh,this.targetCount=0,this.Uv=wf.Ql()}function Fp(t,e){this.as=t,this.vm=e,this.docs=new Ki(Yi.X),this.size=0}function Gp(t){var e=Tp.call(this)||this;return e.hw=t,e}function Bp(i){return function(){if("object"!=typeof i||null===i)return!1;for(var t=i,e=0,n=["next","error","complete"];e<n.length;e++){var r=n[e];if(r in t&&"function"==typeof t[r])return!0}return!1}()}var zp,Xp=_h.ko,Wp=(fd.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.timestampsInSnapshots===t.timestampsInSnapshots&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.forceLongPolling===t.forceLongPolling},fd),Hp=(cd.prototype.settings=function(t){if(Ii("Firestore.settings",arguments,1),Ni("Firestore.settings","object",1,t),vi(t,"persistence"))throw new oi(ii.INVALID_ARGUMENT,'"persistence" is now specified with a separate call to firestore.enablePersistence().');var e=new Wp(t);if(this.Xm&&!this.ip.isEqual(e))throw new oi(ii.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.");void 0!==(this.ip=e).credentials&&(this.np=function(t){if(!t)return new si;switch(t.type){case"gapi":var e=t.L;return Fr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new hi(e,t.j||"0");case"provider":return t.L;default:throw new oi(ii.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},cd.prototype.enableNetwork=function(){return this.Ym(),this.Xm.enableNetwork()},cd.prototype.disableNetwork=function(){return this.Ym(),this.Xm.disableNetwork()},cd.prototype.enablePersistence=function(t){if(this.Xm)throw new oi(ii.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.");var e=!1;return t&&(void 0!==t.experimentalTabSynchronization&&Ur("The 'experimentalTabSynchronization' setting has been renamed to 'synchronizeTabs'. In a future release, the setting will be removed and it is recommended that you update your firestore.enablePersistence() call to use 'synchronizeTabs'."),e=mi(void 0!==t.synchronizeTabs?t.synchronizeTabs:t.experimentalTabSynchronization,!1)),this.up(new _p(this.ip.cacheSizeBytes,e))},cd.prototype.clearPersistence=function(){var t=this,n=hp.tm(this.sp()),r=new Yu;return this.Jm.uo(function(){return p(t,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:if(t.trys.push([0,2,,3]),void 0!==this.Xm&&!this.Xm.Qm)throw new oi(ii.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return[4,hp.clearPersistence(n)];case 1:return t.sent(),r.resolve(),[3,3];case 2:return e=t.sent(),r.reject(e),[3,3];case 3:return[2]}})})}),r.promise},cd.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(cd.prototype,"hp",{get:function(){return this.Ym(),this.Xm.Qm},enumerable:!0,configurable:!0}),cd.prototype.waitForPendingWrites=function(){return this.Ym(),this.Xm.waitForPendingWrites()},cd.prototype.onSnapshotsInSync=function(t){if(this.Ym(),Bp(t))return this.cp(t);Ni("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.cp(e)},cd.prototype.cp=function(t){var e=this,n=new xp({next:function(){t.next&&t.next()},error:function(t){throw jr("Uncaught Error in onSnapshotsInSync")}});return this.Xm.Zd(n),function(){n.Km(),e.Xm.tv(n)}},cd.prototype.Ym=function(){return this.Xm||this.up(new Ep),this.Xm},cd.prototype.sp=function(){return new Hr(this.$m,this.tp,this.ip.host,this.ip.ssl,this.ip.forceLongPolling)},cd.prototype.up=function(t){Fr(!!this.ip.host,"FirestoreSettings.host is not set"),Fr(!this.Xm,"configureClient() called multiple times");var e=this.sp();return this.Xm=new Cp(Fu.t(),e,this.np,this.Jm),this.Xm.start(t)},cd.prototype.rp=function(r){return new gc(function(t){if(t instanceof Qp){var e=r,n=t.firestore.$m;if(!n.isEqual(e))throw new oi(ii.INVALID_ARGUMENT,"Document reference is for database "+n.projectId+"/"+n.database+" but should be for database "+e.projectId+"/"+e.database);return new mc(r,t.ap)}return t})},cd.Zm=function(t){var e=t.options;if(!vi(e,"projectId"))throw new oi(ii.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var n=e.projectId;if(!n||"string"!=typeof n)throw new oi(ii.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Zr(n)},Object.defineProperty(cd.prototype,"app",{get:function(){if(!this.Hm)throw new oi(ii.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Hm},enumerable:!0,configurable:!0}),cd.prototype.collection=function(t){return Ii("Firestore.collection",arguments,1),Ni("Firestore.collection","non-empty string",1,t),this.Ym(),new pd(Xi.ht(t),this)},cd.prototype.doc=function(t){return Ii("Firestore.doc",arguments,1),Ni("Firestore.doc","non-empty string",1,t),this.Ym(),Qp.fp(Xi.ht(t),this)},cd.prototype.collectionGroup=function(t){if(Ii("Firestore.collectionGroup",arguments,1),Ni("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new oi(ii.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.Ym(),new td(new wa(Xi.ct,t),this)},cd.prototype.runTransaction=function(e){var n=this;return Ii("Firestore.runTransaction",arguments,1),Ni("Firestore.runTransaction","function",1,e),this.Ym().transaction(function(t){return e(new Yp(n,t))})},cd.prototype.batch=function(){return this.Ym(),new Kp(this)},Object.defineProperty(cd,"logLevel",{get:function(){switch(Lr()){case Nr.DEBUG:return"debug";case Nr.ERROR:return"error";case Nr.SILENT:return"silent";default:return jr("Unknown log level: "+Lr())}},enumerable:!0,configurable:!0}),cd.setLogLevel=function(t){switch(Ii("Firestore.setLogLevel",arguments,1),Ni("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":qr(Nr.DEBUG);break;case"error":qr(Nr.ERROR);break;case"silent":qr(Nr.SILENT);break;default:throw new oi(ii.INVALID_ARGUMENT,"Invalid log level: "+t)}},cd.prototype.lp=function(){return this.ip.timestampsInSnapshots},cd),Yp=(hd.prototype.get=function(t){var n=this;Ii("Transaction.get",arguments,1);var r=gd("Transaction.get",t,this.dp);return this.vp.La([r.ap]).then(function(t){if(!t||1!==t.length)return jr("Mismatch in docs returned from document lookup.");var e=t[0];if(e instanceof Vs)return new $p(n.dp,r.ap,null,!1,!1,r.wp);if(e instanceof Us)return new $p(n.dp,r.ap,e,!1,!1,r.wp);throw jr("BatchGetDocumentsRequest returned unexpected document type: "+e.constructor.name)})},hd.prototype.set=function(t,e,n){Ai("Transaction.set",arguments,2,3);var r=gd("Transaction.set",t,this.dp);n=yd("Transaction.set",n);var i=wd(r.wp,e,"Transaction.set"),o=i[0],s=i[1],a=n.merge||n.mergeFields?this.dp.ep.Fc(s,o,n.mergeFields):this.dp.ep.Nc(s,o);return this.vp.set(r.ap,a),this},hd.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return i="string"==typeof e||e instanceof Fh?(Ti("Transaction.update",arguments,3),r=gd("Transaction.update",t,this.dp),this.dp.ep.Uc("Transaction.update",e,n,o)):(Ii("Transaction.update",arguments,2),r=gd("Transaction.update",t,this.dp),this.dp.ep.xc("Transaction.update",e)),this.vp.update(r.ap,i),this},hd.prototype.delete=function(t){Ii("Transaction.delete",arguments,1);var e=gd("Transaction.delete",t,this.dp);return this.vp.delete(e.ap),this},hd),Kp=(ud.prototype.set=function(t,e,n){Ai("WriteBatch.set",arguments,2,3),this.gp();var r=gd("WriteBatch.set",t,this.dp);n=yd("WriteBatch.set",n);var i=wd(r.wp,e,"WriteBatch.set"),o=i[0],s=i[1],a=n.merge||n.mergeFields?this.dp.ep.Fc(s,o,n.mergeFields):this.dp.ep.Nc(s,o);return this.mp=this.mp.concat(a.bc(r.ap,jo.NONE)),this},ud.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return this.gp(),i="string"==typeof e||e instanceof Fh?(Ti("WriteBatch.update",arguments,3),r=gd("WriteBatch.update",t,this.dp),this.dp.ep.Uc("WriteBatch.update",e,n,o)):(Ii("WriteBatch.update",arguments,2),r=gd("WriteBatch.update",t,this.dp),this.dp.ep.xc("WriteBatch.update",e)),this.mp=this.mp.concat(i.bc(r.ap,jo.exists(!0))),this},ud.prototype.delete=function(t){Ii("WriteBatch.delete",arguments,1),this.gp();var e=gd("WriteBatch.delete",t,this.dp);return this.mp=this.mp.concat(new Xo(e.ap,jo.NONE)),this},ud.prototype.commit=function(){return p(this,void 0,void 0,function(){return y(this,function(t){return this.gp(),this.pp=!0,0<this.mp.length?[2,this.dp.Ym().write(this.mp)]:[2]})})},ud.prototype.gp=function(){if(this.pp)throw new oi(ii.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},ud),Qp=(ad.fp=function(t,e,n){if(t.length%2!=0)throw new oi(ii.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.ot()+" has "+t.length);return new ad(new Yi(t),e,n)},Object.defineProperty(ad.prototype,"id",{get:function(){return this.ap.path.et()},enumerable:!0,configurable:!0}),Object.defineProperty(ad.prototype,"parent",{get:function(){return new pd(this.ap.path.tt(),this.firestore,this.wp)},enumerable:!0,configurable:!0}),Object.defineProperty(ad.prototype,"path",{get:function(){return this.ap.path.ot()},enumerable:!0,configurable:!0}),ad.prototype.collection=function(t){if(Ii("DocumentReference.collection",arguments,1),Ni("DocumentReference.collection","non-empty string",1,t),!t)throw new oi(ii.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Xi.ht(t);return new pd(this.ap.path.child(e),this.firestore)},ad.prototype.isEqual=function(t){if(!(t instanceof ad))throw Li("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.ap.isEqual(t.ap)&&this.wp===t.wp},ad.prototype.set=function(t,e){Ai("DocumentReference.set",arguments,1,2),e=yd("DocumentReference.set",e);var n=wd(this.wp,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore.ep.Fc(i,r,e.mergeFields):this.firestore.ep.Nc(i,r);return this.Xm.write(o.bc(this.ap,jo.NONE))},ad.prototype.update=function(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return n="string"==typeof t||t instanceof Fh?(Ti("DocumentReference.update",arguments,2),this.firestore.ep.Uc("DocumentReference.update",t,e,r)):(Ii("DocumentReference.update",arguments,1),this.firestore.ep.xc("DocumentReference.update",t)),this.Xm.write(n.bc(this.ap,jo.exists(!0)))},ad.prototype.delete=function(){return Ii("DocumentReference.delete",arguments,0),this.Xm.write([new Xo(this.ap,jo.NONE)])},ad.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Ai("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||Bp(t[i])||(Oi("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),ki("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=Bp(t[i])?t[i]:(Ni("DocumentReference.onSnapshot","function",i,t[i]),Si("DocumentReference.onSnapshot","function",i+1,t[i+1]),Si("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.bp(o,n)},ad.prototype.bp=function(t,n){var r=this,e=function(t){console.error("Uncaught Error in onSnapshot:",t)};n.error&&(e=n.error.bind(n));var i=new xp({next:function(t){if(n.next){Fr(t.docs.size<=1,"Too many documents returned on a document query");var e=t.docs.get(r.ap);n.next(new $p(r.firestore,r.ap,e,t.fromCache,t.hasPendingWrites,r.wp))}},error:e}),o=this.Xm.listen(wa.oi(this.ap.path),i,t);return function(){i.Km(),r.Xm.Pf(o)}},ad.prototype.get=function(n){var r=this;return Ai("DocumentReference.get",arguments,0,1),md("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.Ym().Gm(r.ap).then(function(t){e(new $p(r.firestore,r.ap,t,!0,t instanceof Us&&t.vn,r.wp))},t):r.yp(e,t,n)})},ad.prototype.yp=function(e,n,r){var i=this.bp({includeMetadataChanges:!0,ov:!0},{next:function(t){i(),!t.exists&&t.metadata.fromCache?n(new oi(ii.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new oi(ii.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.)')):e(t)},error:n})},ad.prototype.withConverter=function(t){return new ad(this.ap,this.firestore,t)},ad),Jp=(sd.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},sd),$p=(od.prototype.data=function(t){if(Ai("DocumentSnapshot.data",arguments,0,1),t=vd("DocumentSnapshot.data",t),this._p){if(this.wp){var e=new Zp(this.dp,this.ap,this._p,this.Ip,this.Tp);return this.wp.fromFirestore(e,t)}return this.Ep(this._p.data(),rs.xn(t,this.dp.lp()))}},od.prototype.get=function(t,e){if(Ai("DocumentSnapshot.get",arguments,1,2),e=vd("DocumentSnapshot.get",e),this._p){var n=this._p.data().field(Tc("DocumentSnapshot.get",t));if(null!==n)return this.Rp(n,rs.xn(e,this.dp.lp()))}},Object.defineProperty(od.prototype,"id",{get:function(){return this.ap.path.et()},enumerable:!0,configurable:!0}),Object.defineProperty(od.prototype,"ref",{get:function(){return new Qp(this.ap,this.dp,this.wp)},enumerable:!0,configurable:!0}),Object.defineProperty(od.prototype,"exists",{get:function(){return null!==this._p},enumerable:!0,configurable:!0}),Object.defineProperty(od.prototype,"metadata",{get:function(){return new Jp(this.Tp,this.Ip)},enumerable:!0,configurable:!0}),od.prototype.isEqual=function(t){if(!(t instanceof od))throw Li("isEqual","DocumentSnapshot",1,t);return this.dp===t.dp&&this.Ip===t.Ip&&this.ap.isEqual(t.ap)&&(null===this._p?null===t._p:this._p.isEqual(t._p))&&this.wp===t.wp},od.prototype.Ep=function(t,n){var r=this,i={};return t.forEach(function(t,e){i[t]=r.Rp(e,n)}),i},od.prototype.Rp=function(t,e){if(t instanceof Ls)return this.Ep(t,e);if(t instanceof qs)return this.Ap(t,e);if(t instanceof Ps){var n=t.value(e),r=this.dp.Ym().s();return t.s.isEqual(r)||Ur("Document "+this.ap.path+" contains a document reference within a different database ("+t.s.projectId+"/"+t.s.database+") which is not supported. It will be treated as a reference in the current database ("+r.projectId+"/"+r.database+") instead."),new Qp(n,this.dp,this.wp)}return t.value(e)},od.prototype.Ap=function(t,e){var n=this;return t.nn.map(function(t){return n.Rp(t,e)})},od),Zp=(t(id,zp=$p),id.prototype.data=function(t){var e=zp.prototype.data.call(this,t);return Fr(void 0!==e,"Document in a QueryDocumentSnapshot should exist"),e},id),td=(rd.prototype.where=function(t,e,n){var r;Ii("Query.where",arguments,3),Pi("Query.where",3,n),function(t,e,n,r){if(!e.some(function(t){return t===r}))throw new oi(ii.INVALID_ARGUMENT,"Invalid value "+xi(r)+" provided to function "+t+"() for its "+Mi(n)+" argument. Acceptable values: "+e.join(", "))}("Query.where",["<","<=","==",">=",">","array-contains","in","array-contains-any"],2,e);var i=Tc("Query.where",t),o=ba.ht(e);if(i.ft()){if(o===ba.ARRAY_CONTAINS||o===ba.ARRAY_CONTAINS_ANY)throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===ba.IN){this.Pp(n,o);for(var s=[],a=0,u=n;a<u.length;a++){var h=u[a];s.push(this.Sp(h))}r=new qs(s)}else r=this.Sp(n)}else o!==ba.IN&&o!==ba.ARRAY_CONTAINS_ANY||this.Pp(n,o),r=this.firestore.ep.Lc("Query.where",n,o===ba.IN);var c=Ea.create(i,o,r);return this.Cp(c),new rd(this.Dp.ai(c),this.firestore,this.wp)},rd.prototype.orderBy=function(t,e){var n;if(Ai("Query.orderBy",arguments,1,2),Si("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=Da.ASCENDING;else{if("desc"!==e)throw new oi(ii.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=Da.DESCENDING}if(null!==this.Dp.startAt)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this.Dp.endAt)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=Tc("Query.orderBy",t),i=new Ra(r,n);return this.Vp(i),new rd(this.Dp.li(i),this.firestore,this.wp)},rd.prototype.limit=function(t){return Ii("Query.limit",arguments,1),Ni("Query.limit","number",1,t),qi("Query.limit",1,t),new rd(this.Dp.di(t),this.firestore,this.wp)},rd.prototype.limitToLast=function(t){return Ii("Query.limitToLast",arguments,1),Ni("Query.limitToLast","number",1,t),qi("Query.limitToLast",1,t),new rd(this.Dp.vi(t),this.firestore,this.wp)},rd.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ti("Query.startAt",arguments,1);var r=this.kp("Query.startAt",t,e,!0);return new rd(this.Dp.wi(r),this.firestore,this.wp)},rd.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ti("Query.startAfter",arguments,1);var r=this.kp("Query.startAfter",t,e,!1);return new rd(this.Dp.wi(r),this.firestore,this.wp)},rd.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ti("Query.endBefore",arguments,1);var r=this.kp("Query.endBefore",t,e,!0);return new rd(this.Dp.mi(r),this.firestore,this.wp)},rd.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Ti("Query.endAt",arguments,1);var r=this.kp("Query.endAt",t,e,!1);return new rd(this.Dp.mi(r),this.firestore,this.wp)},rd.prototype.isEqual=function(t){if(!(t instanceof rd))throw Li("isEqual","Query",1,t);return this.firestore===t.firestore&&this.Dp.isEqual(t.Dp)},rd.prototype.withConverter=function(t){return new rd(this.Dp,this.firestore,t)},rd.prototype.kp=function(t,e,n,r){if(Pi(t,1,e),e instanceof $p){if(0<n.length)throw new oi(ii.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new oi(ii.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");return this.Np(t,i._p,r)}var o=[e].concat(n);return this.Op(t,o,r)},rd.prototype.Np=function(t,e,n){for(var r=[],i=0,o=this.Dp.orderBy;i<o.length;i++){var s=o[i];if(s.field.ft())r.push(new Ps(this.firestore.$m,e.key));else{var a=e.field(s.field);if(a instanceof Cs)throw new oi(ii.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+s.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===a){var u=s.field.ot();throw new oi(ii.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+u+"' (used as the orderBy) does not exist.")}r.push(a)}}return new ka(r,n)},rd.prototype.Op=function(t,e,n){var r=this.Dp.ii;if(e.length>r.length)throw new oi(ii.INVALID_ARGUMENT,"Too many arguments provided to "+t+"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses");for(var i=[],o=0;o<e.length;o++){var s=e[o];if(r[o].field.ft()){if("string"!=typeof s)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof s);if(!this.Dp.Pi()&&-1!==s.indexOf("/"))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+t+"() must be a plain document ID, but '"+s+"' contains a slash.");var a=this.Dp.path.child(Xi.ht(s));if(!Yi.vt(a))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+t+"() must result in a valid document path, but '"+a+"' is not because it contains an odd number of segments.");var u=new Yi(a);i.push(new Ps(this.firestore.$m,u))}else{var h=this.firestore.ep.Lc(t,s);i.push(h)}}return new ka(i,n)},rd.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Ai("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||Bp(t[i])||(Oi("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),ki("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=Bp(t[i])?t[i]:(Ni("Query.onSnapshot","function",i,t[i]),Si("Query.onSnapshot","function",i+1,t[i+1]),Si("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.Fp(this.Dp),this.bp(r,n)},rd.prototype.bp=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new xp({next:function(t){e.next&&e.next(new ed(n.firestore,n.Dp,t,n.wp))},error:r}),o=this.firestore.Ym(),s=o.listen(this.Dp,i,t);return function(){i.Km(),o.Pf(s)}},rd.prototype.Fp=function(t){if(t.Ai()&&0===t.ii.length)throw new oi(ii.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},rd.prototype.get=function(n){var r=this;return Ai("Query.get",arguments,0,1),md("Query.get",n),this.Fp(this.Dp),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.Ym().Wm(r.Dp).then(function(t){e(new ed(r.firestore,r.Dp,t,r.wp))},t):r.yp(e,t,n)})},rd.prototype.yp=function(e,n,r){var i=this.bp({includeMetadataChanges:!0,ov:!0},{next:function(t){i(),t.metadata.fromCache&&r&&"server"===r.source?n(new oi(ii.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.)')):e(t)},error:n})},rd.prototype.Sp=function(t){if("string"==typeof t){if(""===t)throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this.Dp.Pi()&&-1!==t.indexOf("/"))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+t+"' contains a '/' character.");var e=this.Dp.path.child(Xi.ht(t));if(!Yi.vt(e))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+e+"' is not because it has an odd number of segments ("+e.length+").");return new Ps(this.firestore.$m,new Yi(e))}if(t instanceof Qp){var n=t;return new Ps(this.firestore.$m,n.ap)}throw new oi(ii.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+xi(t)+".")},rd.prototype.Pp=function(t,e){if(!Array.isArray(t)||0===t.length)throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'null' in the value array.");if(0<t.filter(function(t){return Number.isNaN(t)}).length)throw new oi(ii.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},rd.prototype.Cp=function(t){if(t instanceof Ea){var e=[ba.ARRAY_CONTAINS,ba.ARRAY_CONTAINS_ANY],n=[ba.IN,ba.ARRAY_CONTAINS_ANY],r=0<=e.indexOf(t.op),i=0<=n.indexOf(t.op);if(t.fi()){var o=this.Dp.hi();if(null!==o&&!o.isEqual(t.field))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var s=this.Dp.ci();null!==s&&this.xp(t.field,s)}else if(i||r){var a=null;if(i&&(a=this.Dp.Di(n)),null===a&&r&&(a=this.Dp.Di(e)),null!=a)throw a===t.op?new oi(ii.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new oi(ii.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+a.toString()+"' filters.")}}},rd.prototype.Vp=function(t){if(null===this.Dp.ci()){var e=this.Dp.hi();null!==e&&this.xp(e,t.field)}},rd.prototype.xp=function(t,e){if(!e.isEqual(t))throw new oi(ii.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first Query.orderBy(), but your first Query.orderBy() is on field '"+e.toString()+"' instead.")},rd),ed=(Object.defineProperty(nd.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(nd.prototype,"empty",{get:function(){return this.Up.docs.nt()},enumerable:!0,configurable:!0}),Object.defineProperty(nd.prototype,"size",{get:function(){return this.Up.docs.size},enumerable:!0,configurable:!0}),nd.prototype.forEach=function(e,n){var r=this;Ai("QuerySnapshot.forEach",arguments,1,2),Ni("QuerySnapshot.forEach","function",1,e),this.Up.docs.forEach(function(t){e.call(n,r.Mp(t))})},Object.defineProperty(nd.prototype,"query",{get:function(){return new td(this.jp,this.dp,this.wp)},enumerable:!0,configurable:!0}),nd.prototype.docChanges=function(t){t&&(Oi("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),ki("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.Up.te)throw new oi(ii.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.Lp&&this.Bp===e||(this.Lp=function(i,e,o,s){if(o.Xi.nt()){var n,r=0;return o.docChanges.map(function(t){var e=new Zp(i,t.doc.key,t.doc,o.fromCache,o.$i.has(t.doc.key),s);return Fr(t.type===uu.Qi,"Invalid event type for first snapshot"),Fr(!n||o.query.yi(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var a=o.Xi;return o.docChanges.filter(function(t){return e||t.type!==uu.zi}).map(function(t){var e=new Zp(i,t.doc.key,t.doc,o.fromCache,o.$i.has(t.doc.key),s),n=-1,r=-1;return t.type!==uu.Qi&&(Fr(0<=(n=a.indexOf(t.doc.key)),"Index for document not found"),a=a.delete(t.doc.key)),t.type!==uu.Gi&&(r=(a=a.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case uu.Qi:return"added";case uu.Wi:case uu.zi:return"modified";case uu.Gi:return"removed";default:return jr("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this.dp,e,this.Up,this.wp),this.Bp=e),this.Lp},nd.prototype.isEqual=function(t){if(!(t instanceof nd))throw Li("isEqual","QuerySnapshot",1,t);return this.dp===t.dp&&this.jp.isEqual(t.jp)&&this.Up.isEqual(t.Up)&&this.wp===t.wp},nd.prototype.Mp=function(t){return new Zp(this.dp,t.key,t,this.metadata.fromCache,this.Up.$i.has(t.key),this.wp)},nd);function nd(t,e,n,r){this.dp=t,this.jp=e,this.Up=n,this.wp=r,this.Lp=null,this.Bp=null,this.metadata=new Jp(n.hasPendingWrites,n.fromCache)}function rd(t,e,n){this.Dp=t,this.firestore=e,this.wp=n}function id(){return null!==zp&&zp.apply(this,arguments)||this}function od(t,e,n,r,i,o){this.dp=t,this.ap=e,this._p=n,this.Ip=r,this.Tp=i,this.wp=o}function sd(t,e){this.hasPendingWrites=t,this.fromCache=e}function ad(t,e,n){this.ap=t,this.firestore=e,this.wp=n,this.Xm=this.firestore.Ym()}function ud(t){this.dp=t,this.mp=[],this.pp=!1}function hd(t,e){this.dp=t,this.vp=e}function cd(t,e){var n=this;if(this.Hm=null,this.Jm=new Ah,this.INTERNAL={delete:function(){return p(n,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Ym(),[4,this.Xm.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var r=t;this.Hm=r,this.$m=cd.Zm(r),this.tp=r.name,this.np=new ai(e)}else{var i=t;if(!i.projectId)throw new oi(ii.INVALID_ARGUMENT,"Must provide projectId");this.$m=new Zr(i.projectId,i.database),this.tp="[DEFAULT]",this.np=new si}this.ip=new Wp({}),this.ep=this.rp(this.$m)}function fd(t){if(void 0===t.host){if(void 0!==t.ssl)throw new oi(ii.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Di("settings","non-empty string","host",t.host),this.host=t.host,ki("settings","boolean","ssl",t.ssl),this.ssl=mi(t.ssl,!0);if(Oi("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),ki("settings","object","credentials",t.credentials),this.credentials=t.credentials,ki("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?Ur("\n The timestampsInSnapshots setting now defaults to true and you no\n longer need to explicitly set it. In a future release, the setting\n will be removed entirely and so it is recommended that you remove it\n from your firestore.settings() call now."):!1===t.timestampsInSnapshots&&Ur("\n The timestampsInSnapshots setting will soon be removed. YOU MUST UPDATE\n YOUR CODE.\n\n To hide this warning, stop using the timestampsInSnapshots setting in your\n firestore.settings({ ... }) call.\n\n Once you remove the setting, Timestamps stored in Cloud Firestore will be\n read back as Firebase Timestamp objects instead of as system Date objects.\n So you will also need to update code expecting a Date to instead expect a\n Timestamp. For example:\n\n // Old:\n const date = snapshot.get('created_at');\n // New:\n const timestamp = snapshot.get('created_at'); const date =\n timestamp.toDate();\n\n Please audit all existing usages of Date when you enable the new\n behavior."),this.timestampsInSnapshots=mi(t.timestampsInSnapshots,!0),ki("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=_h.Oo;else{if(t.cacheSizeBytes!==Xp&&t.cacheSizeBytes<_h.No)throw new oi(ii.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+_h.No);this.cacheSizeBytes=t.cacheSizeBytes}ki("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}s(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(ed.prototype.docChanges,t,{get:function(){return function(){throw new oi(ii.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(t){}});var ld,pd=(t(dd,ld=td),Object.defineProperty(dd.prototype,"id",{get:function(){return this.Dp.path.et()},enumerable:!0,configurable:!0}),Object.defineProperty(dd.prototype,"parent",{get:function(){var t=this.Dp.path.tt();return t.nt()?null:new Qp(new Yi(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(dd.prototype,"path",{get:function(){return this.Dp.path.ot()},enumerable:!0,configurable:!0}),dd.prototype.doc=function(t){if(Ai("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Gr.u()),Ni("CollectionReference.doc","non-empty string",1,t),""===t)throw new oi(ii.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Xi.ht(t);return Qp.fp(this.Dp.path.child(e),this.firestore,this.wp)},dd.prototype.add=function(t){Ii("CollectionReference.add",arguments,1),Ni("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},dd.prototype.withConverter=function(t){return new dd(this.qp,this.firestore,t)},dd);function dd(t,e,n){var r=ld.call(this,wa.oi(t),e,n)||this;if((r.qp=t).length%2!=1)throw new oi(ii.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.ot()+" has "+t.length);return r}function yd(t,e){if(void 0===e)return{merge:!1};if(Oi(t,e,["merge","mergeFields"]),ki(t,"boolean","merge",e.merge),function(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+xi(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new oi(ii.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+xi(r[o]))}(t,e,n,r,i)}(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof Fh}),void 0!==e.mergeFields&&void 0!==e.merge)throw new oi(ii.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function vd(t,e){return void 0===e?{}:(Oi(t,e,["serverTimestamps"]),Ri(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function md(t,e){Si(t,"object",1,e),e&&(Oi(t,e,["source"]),Ri(t,0,"source",e.source,["default","server","cache"]))}function gd(t,e,n){if(e instanceof Qp){if(e.firestore!==n)throw new oi(ii.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Li(t,"DocumentReference",1,e)}function wd(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}var bd=Xu(Hp,"Use firebase.firestore() instead."),Ed=Xu(Yp,"Use firebase.firestore().runTransaction() instead."),Id=Xu(Kp,"Use firebase.firestore().batch() instead."),Td=Xu(Qp,"Use firebase.firestore().doc() instead."),Ad=Xu($p),Nd=Xu(Zp),Sd=Xu(td),Dd=Xu(ed),kd=Xu(pd,"Use firebase.firestore().collection() instead."),Rd={Firestore:bd,GeoPoint:Fi,Timestamp:Gi,Blob:$u,Transaction:Ed,WriteBatch:Id,DocumentReference:Td,DocumentSnapshot:Ad,Query:Sd,QueryDocumentSnapshot:Nd,QuerySnapshot:Dd,CollectionReference:kd,FieldPath:Fh,FieldValue:rc,setLogLevel:Hp.setLogLevel,CACHE_SIZE_UNLIMITED:Xp};var _d=(Fd.prototype.cf=function(t){},Fd.prototype.Af=function(){},Fd),Cd=(jd.prototype.cf=function(t){this.Kp.push(t)},jd.prototype.Af=function(){window.removeEventListener("online",this.Qp),window.removeEventListener("offline",this.Wp)},jd.prototype.Hp=function(){window.addEventListener("online",this.Qp),window.addEventListener("offline",this.Wp)},jd.prototype.Gp=function(){Mr("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.Kp;t<e.length;t++)(0,e[t])(0)},jd.prototype.zp=function(){Mr("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.Kp;t<e.length;t++)(0,e[t])(1)},jd.nl=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},jd),xd=(Vd.prototype.Ra=function(t){Fr(!this.Xp,"Called onOpen on stream twice!"),this.Xp=t},Vd.prototype.ya=function(t){Fr(!this.$p,"Called onClose on stream twice!"),this.$p=t},Vd.prototype.onMessage=function(t){Fr(!this.Zp,"Called onMessage on stream twice!"),this.Zp=t},Vd.prototype.close=function(){this.Yp()},Vd.prototype.send=function(t){this.Jp(t)},Vd.prototype.tg=function(){Fr(void 0!==this.Xp,"Cannot call onOpen because no callback was set"),this.Xp()},Vd.prototype.ng=function(t){Fr(void 0!==this.$p,"Cannot call onClose because no callback was set"),this.$p(t)},Vd.prototype.ig=function(t){Fr(void 0!==this.Zp,"Cannot call onMessage because no callback was set"),this.Zp(t)},Vd),Pd={BatchGetDocuments:"batchGet",Commit:"commit"},Od="gl-js/ fire/"+Pr,Ld=(Ud.prototype.rg=function(t,e){if(e)for(var n in e.A)e.A.hasOwnProperty(n)&&(t[n]=e.A[n]);t["X-Goog-Api-Client"]=Od},Ud.prototype.Ua=function(u,r,i){var h=this,c=this.ug(u);return new Promise(function(o,s){var a=new xr;a.listenOnce(_r.COMPLETE,function(){try{switch(a.getLastErrorCode()){case Rr.NO_ERROR:var t=a.getResponseJson();Mr("Connection","XHR received:",JSON.stringify(t)),o(t);break;case Rr.TIMEOUT:Mr("Connection",'RPC "'+u+'" timed out'),s(new oi(ii.DEADLINE_EXCEEDED,"Request time out"));break;case Rr.HTTP_ERROR:var e=a.getStatus();if(Mr("Connection",'RPC "'+u+'" failed with status:',e,"response text:",a.getResponseText()),0<e){var n=a.getResponseJson().error;if(n&&n.status&&n.message){var r=(i=n.status.toLowerCase().replace("_","-"),0<=Object.values(ii).indexOf(i)?i:ii.UNKNOWN);s(new oi(r,n.message))}else s(new oi(ii.UNKNOWN,"Server responded with status "+a.getStatus()))}else Mr("Connection",'RPC "'+u+'" failed'),s(new oi(ii.UNAVAILABLE,"Connection failed."));break;default:jr('RPC "'+u+'" failed with unanticipated webchannel error '+a.getLastErrorCode()+": "+a.getLastError()+", giving up.")}}finally{Mr("Connection",'RPC "'+u+'" completed.')}var i});var t=f({},r);delete t.database;var e=JSON.stringify(t);Mr("Connection","XHR sending: ",c+" "+e);var n={"Content-Type":"text/plain"};h.rg(n,i),a.send(c,"POST",e,n,15)})},Ud.prototype.Ba=function(t,e,n){return this.Ua(t,e,n)},Ud.prototype.Aa=function(t,e){var n=[this.eg,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=kr(),i={backgroundChannelTest:!0,httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.s.projectId+"/databases/"+this.s.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.rg(i.initMessageHeaders,e),"object"==typeof navigator&&"ReactNative"===navigator.product||0<=l().indexOf("Electron/")||function(){var t=l();return 0<=t.indexOf("MSIE ")||0<=t.indexOf("Trident/")}()||0<=l().indexOf("MSAppHost/")||function(){var t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");function s(t,e){u.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}Mr("Connection","Creating WebChannel: "+o+" "+i);var u=r.createWebChannel(o,i),a=!1,h=!1,c=new xd({Jp:function(t){h?Mr("Connection","Not sending because WebChannel is closed:",t):(a||(Mr("Connection","Opening WebChannel transport."),u.open(),a=!0),Mr("Connection","WebChannel sending:",t),u.send(t))},Yp:function(){return u.close()}});return s(Cr.EventType.OPEN,function(){h||Mr("Connection","WebChannel transport opened.")}),s(Cr.EventType.CLOSE,function(){h||(h=!0,Mr("Connection","WebChannel transport closed"),c.ng())}),s(Cr.EventType.ERROR,function(t){h||(h=!0,Mr("Connection","WebChannel transport errored:",t),c.ng(new oi(ii.UNAVAILABLE,"The operation could not be completed")))}),s(Cr.EventType.MESSAGE,function(t){var e;if(!h){var n=t.data[0];Fr(!!n,"Got a webchannel message without data.");var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){Mr("Connection","WebChannel received error:",i);var o=i.status,s=function(){var t=Ba[o];if(void 0!==t)return Qa(t)}(),a=i.message;void 0===s&&(s=ii.INTERNAL,a="Unknown error status: "+o+" with message "+i.message),h=!0,c.ng(new oi(s,a)),u.close()}else Mr("Connection","WebChannel received:",n),c.ig(n)}}),setTimeout(function(){c.tg()},0),c},Ud.prototype.ug=function(t){var e=Pd[t];return Fr(void 0!==e,"Unknown REST mapping for: "+t),this.eg+"/v1/projects/"+this.s.projectId+"/databases/"+this.s.database+"/documents:"+e},Ud),qd=(Object.defineProperty(Md.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(Md.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),Md.prototype.Um=function(t){return Promise.resolve(new Ld(t))},Md.prototype.Bm=function(){return Cd.nl()?new Cd:new _d},Md.prototype.Mm=function(t){return new ju(t,{nr:!0})},Md.prototype.i=function(t){return JSON.stringify(t)},Md.prototype.atob=function(t){return atob(t)},Md.prototype.btoa=function(t){return btoa(t)},Md);function Md(){this.tr="",this.pu="undefined"!=typeof atob}function Ud(t){this.s=t.s;var e=t.ssl?"https":"http";this.eg=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}function Vd(t){this.Jp=t.Jp,this.Yp=t.Yp}function jd(){var t=this;this.Qp=function(){return t.Gp()},this.Wp=function(){return t.zp()},this.Kp=[],this.Hp()}function Fd(){}Fu.mu(new qd);var Gd;(Gd=Bd).INTERNAL.registerComponent(new b("firestore",function(t){var e=t.getProvider("app").getImmediate();return new Hp(e,t.getProvider("auth-internal"))},"PUBLIC").setServiceProps(function(t){Fr(t&&"object"==typeof t,"shallowCopy() expects object parameter.");var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}(Rd))),Gd.registerVersion("@firebase/firestore","1.10.0")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-firestore.min.js - be sure to load firebase-app.js first.")}});
//# sourceMappingURL=firebase-firestore.min.js.map