Files
watchparty/app/public/firebase-firestore.js
T
ayushya 906880ab14 v1.6.7/version bump
- remove remote code link
2020-09-01 23:53:42 -04:00

3 lines
287 KiB
JavaScript

!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(mp){"use strict";try{(function(){mp=mp&&Object.prototype.hasOwnProperty.call(mp,"default")?mp.default:mp;var t,l,e,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 n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function f(t,s,u,a){return new(u=u||Promise)(function(n,e){function r(t){try{o(a.next(t))}catch(t){e(t)}}function i(t){try{o(a.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(r,i)}o((a=a.apply(t,s||[])).next())})}function y(n,r){var i,o,s,t,u={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(;u;)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 u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){u.label=e[1];break}if(6===e[0]&&u.label<s[1]){u.label=s[1],s=e;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(e);break}s[2]&&u.ops.pop(),u.trys.pop();continue}e=r.call(n,u)}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 i(){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,u=o.length;s<u;s++,i++)r[i]=o[s];return r}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,u=o.length;s<u;s++,i++)r[i]=o[s];return r}(e=l=l||{})[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";l.DEBUG,l.VERBOSE,l.INFO,l.WARN,l.ERROR,l.SILENT;function o(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(),o=a[e];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[o].apply(console,s(["["+i+"] "+t.name+":"],n))}}var u=l.INFO,a=((t={})[l.DEBUG]="log",t[l.VERBOSE]="log",t[l.INFO]="info",t[l.WARN]="warn",t[l.ERROR]="error",t),h=(Object.defineProperty(c.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in l))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(c.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}),Object.defineProperty(c.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!0,configurable:!0}),c.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,l.DEBUG],t)),this._logHandler.apply(this,s([this,l.DEBUG],t))},c.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,l.VERBOSE],t)),this._logHandler.apply(this,s([this,l.VERBOSE],t))},c.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,l.INFO],t)),this._logHandler.apply(this,s([this,l.INFO],t))},c.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,l.WARN],t)),this._logHandler.apply(this,s([this,l.WARN],t))},c.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,l.ERROR],t)),this._logHandler.apply(this,s([this,l.ERROR],t))},c);function c(t){this.name=t,this._logLevel=u,this._logHandler=o,this._userLogHandler=null}function p(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var d,v=(n(m,d=Error),m);function m(t,e){var n=d.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,m.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,g.prototype.create),n}var g=(w.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r,i=e[0]||{},o=this.service+"/"+t,s=this.errors[t],u=s?(r=i,s.replace(b,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})):"Error",a=this.serviceName+": "+u+" ("+o+").",h=new v(o,a),c=0,f=Object.keys(i);c<f.length;c++){var l=f[c];"_"!==l.slice(-1)&&(l in h&&console.warn('Overwriting FirebaseError base field "'+l+'" can cause unexpected behavior.'),h[l]=i[l])}return h},w);function w(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var b=/\{\$([^}]+)}/g,E=(T.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},T.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},T.prototype.setServiceProps=function(t){return this.serviceProps=t,this},T);function T(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var I,N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A=A||{},_=N;function S(t){return"string"==typeof t}function D(t){return"number"==typeof t}function k(t,e){t=t.split("."),e=e||_;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function x(){}function R(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 L(t){return"array"==R(t)}function O(t){var e=R(t);return"array"==e||"object"==e&&"number"==typeof t.length}function V(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var P="closure_uid_"+(1e9*Math.random()>>>0),C=0;function U(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 F(t,e,n){return(F=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?U:M).apply(null,arguments)}function j(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 q=Date.now||function(){return+new Date};function G(t,o){function e(){}e.prototype=o.prototype,t.N=o.prototype,t.prototype=new e,(t.prototype.constructor=t).yb=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 B(){this.j=this.j,this.i=this.i}B.prototype.j=!1,B.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[P]||(this[P]=++C)},B.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var z=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},K=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 W(t){return Array.prototype.concat.apply([],arguments)}function H(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 Y(t){return/^[\s\xa0]*$/.test(t)}var X,J=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 Z(t,e){return t<e?-1:e<t?1:0}t:{var $=_.navigator;if($){var tt=$.userAgent;if(tt){X=tt;break t}}X=""}function et(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function nt(t){var e,n={};for(e in t)n[e]=t[e];return n}var rt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function it(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<rt.length;o++)n=rt[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ot(t){return ot[" "](t),t}ot[" "]=x;var st,ut,at=Q(X,"Opera"),ht=Q(X,"Trident")||Q(X,"MSIE"),ct=Q(X,"Edge"),ft=ct||ht,lt=Q(X,"Gecko")&&!(Q(X.toLowerCase(),"webkit")&&!Q(X,"Edge"))&&!(Q(X,"Trident")||Q(X,"MSIE"))&&!Q(X,"Edge"),pt=Q(X.toLowerCase(),"webkit")&&!Q(X,"Edge");function dt(){var t=_.document;return t?t.documentMode:void 0}t:{var yt="",vt=(ut=X,lt?/rv:([^\);]+)(\)|;)/.exec(ut):ct?/Edge\/([\d\.]+)/.exec(ut):ht?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(ut):pt?/WebKit\/(\S+)/.exec(ut):at?/(?:Version)[ \/]?(\S+)/.exec(ut):void 0);if(vt&&(yt=vt?vt[1]:""),ht){var mt=dt();if(null!=mt&&mt>parseFloat(yt)){st=String(mt);break t}}st=yt}var gt,wt={};function bt(u){return t=u,e=function(){for(var t=0,e=J(String(st)).split("."),n=J(String(u)).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=Z(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||Z(0==o[2].length,0==s[2].length)||Z(o[2],s[2]),o=o[3],s=s[3]}while(0==t)}return 0<=t},n=wt,Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t);var t,e,n}var Et=_.document;gt=Et&&ht?dt()||("CSS1Compat"==Et.compatMode?parseInt(st,10):5):void 0;var Tt=!ht||9<=Number(gt),It=ht&&!bt("9"),Nt=function(){if(!_.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{_.addEventListener("test",x,e),_.removeEventListener("test",x,e)}catch(t){}return t}();function At(t,e){this.type=t,this.a=this.target=e,this.Ia=!0}function _t(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(lt){t:{try{ot(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},G(_t,At);var St={2:"touch",3:"pen",4:"mouse"};_t.prototype.b=function(){_t.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 xt(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 Rt(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function Lt(t){this.src=t,this.a={},this.b=0}function Ot(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=z(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(Rt(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function Vt(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}Lt.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Vt(t,e,r,i);return-1<s?(e=t[s],n||(e.Z=!1)):((e=new xt(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var Pt="closure_lm_"+(1e6*Math.random()|0),Ct={};function Ut(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(L(n)){for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);return null}r=Kt(r);return e&&e[Dt]?e.Aa(n,r,V(i)?!!i.capture:!!i,o):Mt(e,n,r,!0,i,o)}(t,e,n,r,i);if(L(e)){for(var o=0;o<e.length;o++)Ut(t,e[o],n,r,i);return null}return n=Kt(n),t&&t[Dt]?t.za(e,n,V(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=V(i)?!!i.capture:!!i;if(s&&!Tt)return null;var u,a,h=Bt(t);if(h||(t[Pt]=h=new Lt(t)),(n=h.add(e,n,r,s,o)).proxy)return n;if(u=Gt,r=a=Tt?function(t){return u.call(a.src,a.listener,t)}:function(t){if(!(t=u.call(a.src,a.listener,t)))return t},(n.proxy=r).src=t,r.listener=n,t.addEventListener)Nt||(i=s),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(jt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Ft(t){if(!D(t)&&t&&!t.X){var e=t.src;if(e&&e[Dt])Ot(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(jt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Bt(e))?(Ot(n,t),0==n.b&&(n.src=null,e[Pt]=null)):Rt(t)}}}function jt(t){return t in Ct?Ct[t]:Ct[t]="on"+t}function qt(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&Ft(t),n.call(r,e)}function Gt(t,e){return!!t.X||(Tt?qt(t,new _t(e,this)):qt(t,e=new _t(e||k("window.event"),this)))}function Bt(t){return(t=t[Pt])instanceof Lt?t:null}var zt="__closure_events_fn_"+(1e9*Math.random()>>>0);function Kt(e){return"function"==R(e)?e:(e[zt]||(e[zt]=function(t){return e.handleEvent(t)}),e[zt])}function Wt(){B.call(this),this.c=new Lt(this),(this.J=this).B=null}function Ht(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 u=s.listener,a=s.da||s.src;s.Z&&Ot(t.c,s),i=!1!==u.call(a,r)&&i}}return i&&0!=r.Ia}G(Wt,B),Wt.prototype[Dt]=!0,(I=Wt.prototype).addEventListener=function(t,e,n,r){Ut(this,t,e,n,r)},I.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(L(n))for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);else i=V(i)?!!i.capture:!!i,r=Kt(r),e&&e[Dt]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Vt(s=e.a[n],r,i,o))&&(Rt(s[r]),Array.prototype.splice.call(s,r,1),0==s.length&&(delete e.a[n],e.b--))):(e=e&&Bt(e))&&(n=e.a[n.toString()],e=-1,n&&(e=Vt(n,r,i,o)),(r=-1<e?n[e]:null)&&Ft(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;it(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=Ht(s,r,!0,t)&&i}if(i=Ht(s=t.a=n,r,!0,t)&&i,i=Ht(s,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Ht(s=t.a=e[o],r,!1,t)&&i;return i},I.G=function(){if(Wt.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++)Rt(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 Yt=_.JSON.stringify;function Xt(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function Jt(){this.b=this.a=null}Xt.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,Zt=new Xt(function(){return new $t},function(t){t.reset()});function $t(){this.next=this.b=this.a=null}function te(t){_.setTimeout(function(){throw t},0)}function ee(t,e){var n;Qt||(n=_.Promise.resolve(void 0),Qt=function(){n.then(ie)}),ne||(Qt(),ne=!0),re.add(t,e)}Jt.prototype.add=function(t,e){var n=Zt.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 ne=!($t.prototype.reset=function(){this.next=this.b=this.a=null}),re=new Jt;function ie(){for(var t;r=n=void 0,r=null,(n=re).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){te(t)}var e=Zt;e.f(t),e.b<100&&(e.b++,t.next=e.a,e.a=t)}var n,r;ne=!1}function oe(t,e){Wt.call(this),this.b=t||1,this.a=e||_,this.f=F(this.gb,this),this.g=q()}function se(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function ue(t,e,n){if("function"==R(t))n&&(t=F(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=F(t.handleEvent,t)}return 2147483647<Number(e)?-1:_.setTimeout(t,e||0)}function ae(t,e,n){B.call(this),this.f=null!=n?F(t,n):t,this.c=e,this.b=F(this.$a,this),this.a=[]}function he(t){t.U=ue(t.b,t.c),t.f.apply(null,t.a)}function ce(t){B.call(this),this.b=t,this.a={}}G(oe,Wt),(I=oe.prototype).ba=!1,I.L=null,I.gb=function(){if(this.ba){var t=q()-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&&(se(this),this.start()))}},I.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=q())},I.G=function(){oe.N.G.call(this),se(this),delete this.a},G(ae,B),(I=ae.prototype).ea=!1,I.U=null,I.Ta=function(t){this.a=arguments,this.U?this.ea=!0:he(this)},I.G=function(){ae.N.G.call(this),this.U&&(_.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},I.$a=function(){this.U=null,this.ea&&(this.ea=!1,he(this))},G(ce,B);var fe=[];function le(t,e,n,r){L(n)||(n&&(fe[0]=n.toString()),n=fe);for(var i=0;i<n.length;i++){var o=Ut(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function pe(t){et(t.a,function(t,e){this.a.hasOwnProperty(e)&&Ft(t)},t),t.a={}}function de(){}ce.prototype.G=function(){ce.N.G.call(this),pe(this)},ce.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ye=new Wt;function ve(t){At.call(this,"serverreachability",t)}function me(t){ye.dispatchEvent(new ve(ye))}function ge(t){At.call(this,"statevent",t)}function we(t){ye.dispatchEvent(new ge(ye))}function be(t){At.call(this,"timingevent",t)}function Ee(t,e){if("function"!=R(t))throw Error("Fn must not be null and must be a function");return _.setTimeout(function(){t()},e)}G(ve,At),G(ge,At),G(be,At);var Te={NO_ERROR:0,hb:1,ob:2,nb:3,kb:4,mb:5,pb:6,La:7,TIMEOUT:8,sb:9},Ie={jb:"complete",wb:"success",Ma:"error",La:"abort",ub:"ready",vb:"readystatechange",TIMEOUT:"timeout",qb:"incrementaldata",tb:"progress",lb:"downloadprogress",xb:"uploadprogress"};function Ne(){}function Ae(t){var e;return(e=t.a)||(e=t.a={}),e}function _e(){}Ne.prototype.a=null;var Se,De={OPEN:"a",ib:"b",Ma:"c",rb:"d"};function ke(){At.call(this,"d")}function xe(){At.call(this,"c")}function Re(){}function Le(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new ce(this),this.O=Oe,t=ft?125:void 0,this.P=new oe(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}G(ke,At),G(xe,At),G(Re,Ne),Se=new Re;var Oe=45e3,Ve={},Pe={};function Ce(t,e,n){t.F=1,t.f=an(tn(e)),t.l=n,t.H=!0,Me(t,null)}function Ue(t,e,n,r){t.F=1,t.f=an(tn(e)),t.l=null,t.H=n,Me(t,r)}function Me(t,e){t.v=q(),qe(t),t.D=tn(t.f),un(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new ae(F(t.Ja,t,t.a),t.J)),le(t.I,t.a,"readystatechange",t.cb),e=t.h?nt(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)),me(1)}function Fe(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=je(t,n);if(i==Pe){4==e&&(t.c=4,we(14),r=!1);break}if(i==Ve){t.c=4,we(15),r=!1;break}We(t,i)}4==e&&0==n.length&&(t.c=1,we(16),r=!1),t.b=t.b&&r,r||(Ke(t),ze(t))}function je(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?Pe:(n=Number(e.substring(n,r)),isNaN(n)?Ve:(r+=1)+n>e.length?Pe:(e=e.substr(r,n),t.A=r+n,e))}function qe(t){t.R=q()+t.O,Ge(t,t.O)}function Ge(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=Ee(F(t.ab,t),e)}function Be(t){t.i&&(_.clearTimeout(t.i),t.i=null)}function ze(t){t.g.Ca()||t.m||t.g.na(t)}function Ke(t){Be(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,se(t.P),pe(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function We(t,e){try{t.g.Fa(t,e),me(4)}catch(t){}}function He(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(O(t)||S(t))K(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(O(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(O(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 Ye(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 Ye)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 Xe(t,e){Qe(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Je(t))}function Je(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=Le.prototype).setTimeout=function(t){this.O=t},I.cb=function(t){t=t.target;var e=this.B;e&&3==tr(t)?e.Ta():this.Ja(t)},I.Ja=function(t){try{if(t==this.a)t:{var e=tr(this.a),n=this.a.ya(),r=this.a.T();if(!(e<3||3==e&&!ft&&!this.a.aa())){this.m||4!=e||7==n||me(8==n||r<=0?3:2),Be(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=er(this.a,"X-HTTP-Initial-Response");if(s&&!Y(s)){var u=s;break e}}u=null}if(!u){this.b=!1,this.c=3,we(12),Ke(this),ze(this);break t}this.s=!0,We(this,u)}this.H?(Fe(this,e,o),ft&&this.b&&3==e&&(le(this.I,this.P,"tick",this.bb),this.P.start())):We(this,o),4==e&&Ke(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,qe(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,we(12)):(this.c=0,we(13)),Ke(this),ze(this)}}}catch(t){}},I.bb=function(){if(this.a){var t=tr(this.a),e=this.a.aa();this.A<e.length&&(Be(this),Fe(this,t,e),this.b&&4!=t&&qe(this))}},I.cancel=function(){this.m=!0,Ke(this)},I.ab=function(){this.i=null;var t=q();0<=t-this.R?(2!=this.F&&(me(3),we(17)),Ke(this),this.c=2,ze(this)):Ge(this,this.R-t)},(I=Ye.prototype).C=function(){Je(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},I.K=function(){return Je(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 Ze=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([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,en(this,t.f),this.j=t.j,nn(this,t.b),rn(this,t.i),this.a=t.a,on(this,Tn(t.c)),this.g=t.g):t&&(n=String(t).match(Ze))?(this.h=!!e,en(this,n[1]||"",!0),this.j=hn(n[2]||""),nn(this,n[3]||"",!0),rn(this,n[4]),this.a=hn(n[5]||"",!0),on(this,n[6]||"",!0),this.g=hn(n[7]||"")):(this.h=!!e,this.c=new mn(null,this.h))}function tn(t){return new $e(t)}function en(t,e,n){t.f=n?hn(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function nn(t,e,n){t.b=n?hn(e,!0):e}function rn(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 on(t,e,n){var r,i;e instanceof mn?(t.c=e,r=t.c,(i=t.h)&&!r.f&&(gn(r),r.c=null,r.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(wn(this,e),En(this,n,t))},r)),r.f=i):(n||(e=cn(e,yn)),t.c=new mn(e,t.h))}function sn(t,e,n){t.c.set(e,n)}function un(t,e,n){L(n)||(n=[String(n)]),En(t.c,e,n)}function an(t){return sn(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^q()).toString(36)),t}function hn(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function cn(t,e,n){return S(t)?(t=encodeURI(t).replace(e,fn),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function fn(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(cn(e,ln,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(cn(e,ln,!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(cn(n,"/"==n.charAt(0)?dn:pn,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",cn(n,vn)),t.join("")},$e.prototype.resolve=function(t){var e=tn(this),n=!!t.f;n?en(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?nn(e,t.b):n=null!=t.i;var r=t.a;if(n)rn(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 u=i[s++];"."==u?r&&s==i.length&&o.push(""):".."==u?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&s==i.length&&o.push("")):(o.push(u),r=!0)}r=o.join("/")}else r=i}return n?e.a=r:n=""!==t.c.toString(),n?on(e,Tn(t.c)):n=!!t.g,n&&(e.g=t.g),e};var ln=/[#\/\?@]/g,pn=/[#\?:]/g,dn=/[#\?]/g,yn=/[#\?@]/g,vn=/#/g;function mn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function gn(n){n.a||(n.a=new Ye,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 wn(t,e){gn(t),e=In(t,e),Qe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Xe(t.a,e))}function bn(t,e){return gn(t),e=In(t,e),Qe(t.a.b,e)}function En(t,e,n){wn(t,e),0<n.length&&(t.c=null,t.a.set(In(t,e),H(n)),t.b+=n.length)}function Tn(t){var e=new mn;return e.c=t.c,t.a&&(e.a=new Ye(t.a),e.b=t.b),e}function In(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function Nn(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)we(4),e?(we(10),pr(t.a,t,!1)):(we(11),pr(t.a,t,!0));else{t.b=new Le(t,void 0,void 0),t.b.h=t.h,e=gr(e=t.a,e.Y()?t.f:null,t.i),we(4),un(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&sn(e,n,r),Ue(t.b,e,!1,t.f)}}function _n(){this.a=this.b=null}function Sn(){this.a=new Ye}function Dn(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[P]||(t[P]=++C)):e.charAt(0)+t}function kn(t,e){this.b=t,this.a=e}function xn(t){this.g=t||Rn,t=_.PerformanceNavigationTiming?0<(t=_.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(_.ka&&_.ka.Da&&_.ka.Da()&&_.ka.Da().zb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Sn),this.b=null,this.c=[]}(I=mn.prototype).add=function(t,e){gn(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){gn(this),this.a.forEach(function(t,e){K(t,function(t){n.call(r,t,e,this)},this)},this)},I.K=function(){gn(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){gn(this);var e=[];if(S(t))bn(this,t)&&(e=W(e,this.a.get(In(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=W(e,t[n])}return e},I.set=function(t,e){return gn(this),this.c=null,bn(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("&")},G(function(){},function(){}),(I=Nn.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=er(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=er(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 vr(e,2)}this.f=r[0]}else(e=this.a).m=this.c,vr(e,2)}else 1==this.M&&(this.g?we(6):"11111"==e?(we(5),this.g=!0,(!ht||10<=Number(gt))&&(this.c=200,this.b.cancel(),we(11),pr(this.a,this,!0))):(we(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?(we(11),pr(this.a,this,!0)):(we(10),pr(this.a,this,!1)));else{0==this.M?we(8):1==this.M&&we(9);var t=this.a;t.m=this.c,vr(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 Rn=10;function Ln(t,e){!t.a&&(Q(e,"spdy")||Q(e,"quic")||Q(e,"h2"))&&(t.f=t.g,t.a=new Sn,t.b&&(Cn(t,t.b),t.b=null))}function On(t){return t.b||t.a&&t.a.a.c>=t.f}function Vn(t){return t.b?1:t.a?t.a.a.c:0}function Pn(t,e){return t=t.b?t.b==e:!!t.a&&(e=Dn(e),Qe(t.a.a.b,e))}function Cn(t,e){t.a?t.a.add(e):t.b=e}function Un(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&&Xe(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 H(t.c);var e=t.c;return K(t.a.C(),function(t){e=e.concat(t.j)}),e}function Fn(){}function jn(){this.a=new Fn}function qn(t,r,e){var i=e||"";try{He(t,function(t,e){var n=t;V(t)&&(n=Yt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Gn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}xn.prototype.cancel=function(){var t;this.c=Mn(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(K(this.a.C(),function(t){t.cancel()}),(t=this.a.a).b={},t.a.length=0,t.c=0)},Fn.prototype.stringify=function(t){return _.JSON.stringify(t,void 0)},Fn.prototype.parse=function(t){return _.JSON.parse(t,void 0)};var Bn=_.JSON.parse;function zn(t){Wt.call(this),this.headers=new Ye,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=Kn,this.D=this.F=!1}G(zn,Wt);var Kn="",Wn=/^https?$/i,Hn=["POST","PUT"];function Yn(t){return"content-type"==t.toLowerCase()}function Xn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Jn(t),Zn(t)}function Jn(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!=tr(t)||2!=t.T()))if(t.l&&4==tr(t))ue(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==tr(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(Ze)[1]||null;if(!o&&_.self&&_.self.location){var s=_.self.location.protocol;o=s.substr(0,s.length-1)}i=!Wn.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var u=2<tr(t)?t.a.statusText:""}catch(t){u=""}t.f=u+" ["+t.T()+"]",Jn(t)}}finally{Zn(t)}}}function Zn(t,e){if(t.a){$n(t);var n=t.a,r=t.s[0]?x: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&&(_.clearTimeout(t.m),t.m=null)}function tr(t){return t.a?t.a.readyState:0}function er(t,e){return t.a?t.a.getResponseHeader(e):null}function nr(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;var i;if(i="",et(n,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),n=i,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 o=""}else o=t.substring(r+1,n);n=(t=[t.substr(0,r),o,t.substr(n)])[1],t[1]=e?n?n+"&"+e:e:n,t=t[0]+(t[1]?"?"+t[1]:"")+t[2]}return t}return sn(t,e,n),t}function rr(t){this.f=[],this.F=new _n,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.Ab||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new xn(t&&t.concurrentRequestLimit),this.ja=new jn,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 ir(t){if(or(t),3==t.u){var e=t.P++,n=tn(t.B);sn(n,"SID",t.H),sn(n,"RID",e),sn(n,"TYPE","terminate"),hr(t,n),(e=new Le(t,e,void 0)).F=2,e.f=an(tn(n)),n=!1,_.navigator&&_.navigator.sendBeacon&&(n=_.navigator.sendBeacon(e.f.toString(),"")),!n&&_.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=q(),qe(e)}mr(t)}function or(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(_.clearTimeout(t.l),t.l=null),dr(t),t.b.cancel(),t.h&&(D(t.h)&&_.clearTimeout(t.h),t.h=null)}function sr(t,e){t.f.push(new kn(t.Qa++,e)),3==t.u&&ur(t)}function ur(t){On(t.b)||t.h||(t.h=!0,ee(t.Ha,t),t.A=0)}function ar(t,e){var n;n=e?e.W:t.P++;var r=tn(t.B);sn(r,"SID",t.H),sn(r,"RID",n),sn(r,"AID",t.O),hr(t,r),t.g&&t.i&&nr(r,t.g,t.i),n=new Le(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=cr(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),Cn(t.b,n),Ce(n,r,e)}function hr(t,n){t.c&&He({},function(t,e){sn(n,e,t)})}function cr(t,e,n){n=Math.min(t.f.length,n);var r=t.c?F(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 u=!0,a=0;a<n;a++){var h=i[a].b,c=i[a].a;if((h-=o)<0)o=Math.max(0,i[a].b-100),u=!1;else try{qn(c,s,"req"+h+"_")}catch(t){r&&r(c)}}if(u){r=s.join("&");break t}}return t=t.f.splice(0,n),e.j=t,r}function fr(t){t.a||t.l||(t.S=1,ee(t.Ga,t),t.v=0)}function lr(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=Ee(F(t.Ga,t),yr(t,t.v)),t.v++,1)}function pr(t,e,n){var r=e.l;r&&Ln(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=gr(t,null,t.ha),ur(t)}function dr(t){null!=t.s&&(_.clearTimeout(t.s),t.s=null)}function yr(t,e){var n=t.Na+Math.floor(Math.random()*t.Ra);return t.ma()||(n*=2),n*e}function vr(t,e){if(2==e){var n=null;t.c&&(n=null);var r=F(t.eb,t);n||(n=new $e("//www.google.com/images/cleardot.gif"),_.location&&"http"==_.location.protocol||en(n,"https"),an(n)),function(t,e){var n=new de;if(_.Image){var r=new Image;r.onload=j(Gn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=j(Gn,n,r,"TestLoadImage: error",!1,e),r.onabort=j(Gn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=j(Gn,n,r,"TestLoadImage: timeout",!1,e),_.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}else e(!1)}(n.toString(),r)}else we(2);t.u=0,t.c&&t.c.ta(e),mr(t),or(t)}function mr(t){t.u=0,t.m=-1,t.c&&(0==Mn(t.b).length&&0==t.f.length||(t.b.c.length=0,H(t.f),t.f.length=0),t.c.sa())}function gr(t,e,n){var r,i,o,s,u,a,h=(r=n)instanceof $e?tn(r):new $e(r,void 0);if(""!=h.b)e&&nn(h,e+"."+h.b),rn(h,h.i);else{var c,f=_.location;c=e?e+"."+f.hostname:f.hostname,i=f.protocol,o=c,s=+f.port,u=n,a=new $e(null,void 0),i&&en(a,i),o&&nn(a,o),s&&rn(a,s),u&&(a.a=u),h=a}return t.V&&et(t.V,function(t,e){sn(h,e,t)}),e=t.j,n=t.I,e&&n&&sn(h,e,n),sn(h,"VER",t.wa),hr(t,h),h}function wr(){}function br(){if(ht&&!(10<=Number(gt)))throw Error("Environmental error: no available transport.")}function Er(t,e){Wt.call(this),this.a=new rr(e),this.g=t,this.m=e&&e.fb?e.fb: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)&&!Y(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Y(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new Nr(this)}function Tr(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(){xe.call(this),this.status=1}function Nr(t){this.a=t}(I=zn.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=F(this.Ea,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void Xn(this,t)}t=n||"";var i,o=new Ye(this.headers);r&&He(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Yn,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]}(o.K()),n=_.FormData&&t instanceof _.FormData,0<=z(Hn,e)&&!r&&!n&&o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.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=(i=this.a,ht&&bt(9)&&D(i.timeout)&&void 0!==i.ontimeout))?(this.a.timeout=this.o,this.a.ontimeout=F(this.Ba,this)):this.m=ue(this.Ba,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){Xn(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"),Zn(this))},I.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Zn(this,!0)),zn.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<tr(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)),Bn(e)}},I.ya=function(){return this.h},I.Xa=function(){return S(this.f)?this.f:String(this.f)},(I=rr.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 Le(this,t,void 0),r=this.i;if(this.J&&(r?it(r=nt(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("__data__"in o.a&&S(o=o.a.__data__)?o=o.length:o=void 0,void 0===o)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=cr(this,n,e),sn(i=tn(this.B),"RID",t),sn(i,"CVER",22),this.o&&this.j&&sn(i,"X-HTTP-Session-Id",this.j),hr(this,i),this.g&&r&&nr(i,this.g,r),Cn(this.b,n),this.W?(sn(i,"$req",e),sn(i,"SID","null"),n.S=!0,Ce(n,i,null)):Ce(n,i,e),this.u=2}}else 3==this.u&&(t?ar(this,t):0==this.f.length||On(this.b)||ar(this))},I.Ga=function(){this.l=null,this.a=new Le(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=tn(this.pa);sn(t,"RID","rpc"),sn(t,"SID",this.H),sn(t,"CI",this.ia?"0":"1"),sn(t,"AID",this.O),hr(this,t),sn(t,"TYPE","xmlhttp"),this.g&&this.i&&nr(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),Ue(this.a,t,!0,this.ga)},I.Fa=function(t,e){if(0!=this.u&&(this.a==t||Pn(this.b,t)))if(this.m=t.o,!t.s&&Pn(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(t){n=null}if(L(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;dr(this),this.a.cancel(),this.a=null}lr(this),we(18)}}else this.ra=e[1],0<this.ra-this.O&&e[2]<37500&&this.ia&&0==this.v&&!this.s&&(this.s=Ee(F(this.Ya,this),6e3));if(Vn(this.b)<=1&&this.fa){try{this.fa()}catch(t){}this.fa=void 0}}else vr(this,11)}else if(!t.s&&this.a!=t||dr(this),!Y(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=er(r,"X-Client-Wire-Protocol"))&&Ln(this.b,i),this.j&&(r=er(r,"X-HTTP-Session-Id")))&&(this.I=r,sn(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=gr(this,this.Y()?this.ga:null,this.ha),r.s?(Un(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(Be(r),qe(r)),this.a=r):fr(this),0<this.f.length&&ur(this)}else"stop"!=r[0]&&"close"!=r[0]||vr(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?vr(this,7):ir(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,lr(this),we(19))},I.na=function(t){var e=null;if(this.a==t){dr(this),this.a=null;var n=2}else{if(!Pn(this.b,t))return;e=t.j,Un(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=q()-t.v,ye.dispatchEvent(new be(ye,t.l&&t.l.length,this.A)),ur(this)):fr(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){if(!(Vn(t.b)>=t.b.f-(t.h?1:0))){if(t.h)return t.f=e.j.concat(t.f),1;if(!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa)))return t.h=Ee(F(t.Ha,t,e),yr(t,t.A)),t.A++,1}}(this,t)||2==n&&lr(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:vr(this,5);break;case 4:vr(this,10);break;case 3:vr(this,6);break;default:vr(this,2)}}},I.eb=function(t){we(t?2:1)},I.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new zn(this.Ka)).F=this.R,t},I.ma=function(){return!!this.c&&!0},I.Y=function(){return this.R},(I=wr.prototype).va=function(){},I.ua=function(){},I.ta=function(){},I.sa=function(){},I.Sa=function(){},br.prototype.a=function(t,e){return new Er(t,e)},G(Er,Wt),(I=Er.prototype).addEventListener=function(t,e,n,r){Er.N.addEventListener.call(this,t,e,n,r)},I.removeEventListener=function(t,e,n,r){Er.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;we(0),t.ha=n,t.V=r||{},t.o&&(t.F.b=[],t.F.a=!1),t.w=new Nn(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=nr(e,t.g,t.i)),(t=t.w).i=n,e=gr(t.a,null,t.i),we(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,An(t)):(un(e,"MODE","init"),!t.a.o&&t.a.j&&un(e,"X-HTTP-Session-Id",t.a.j),t.b=new Le(t,void 0,void 0),t.b.h=t.h,Ue(t.b,e,!1,null),t.M=0)},I.close=function(){ir(this.a)},I.Wa=function(t){if(S(t)){var e={};e.__data__=t,sr(this.a,e)}else this.h?((e={}).__data__=Yt(t),sr(this.a,e)):sr(this.a,t)},I.G=function(){this.a.c=null,delete this.f,ir(this.a),delete this.a,Er.N.G.call(this)},G(Tr,ke),G(Ir,xe),G(Nr,wr),Nr.prototype.va=function(){this.a.dispatchEvent("a")},Nr.prototype.ua=function(t){this.a.dispatchEvent(new Tr(t))},Nr.prototype.ta=function(t){this.a.dispatchEvent(new Ir)},Nr.prototype.sa=function(){this.a.dispatchEvent("b")};var Ar=j(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},br);br.prototype.createWebChannel=br.prototype.a,Er.prototype.send=Er.prototype.Wa,Er.prototype.open=Er.prototype.Va,Er.prototype.close=Er.prototype.close,Te.NO_ERROR=0,Te.TIMEOUT=8,Te.HTTP_ERROR=6,Ie.COMPLETE="complete",(_e.EventType=De).OPEN="a",De.CLOSE="b",De.ERROR="c",De.MESSAGE="d",Wt.prototype.listen=Wt.prototype.za,zn.prototype.listenOnce=zn.prototype.Aa,zn.prototype.getLastError=zn.prototype.Xa,zn.prototype.getLastErrorCode=zn.prototype.ya,zn.prototype.getStatus=zn.prototype.T,zn.prototype.getResponseJson=zn.prototype.Ua,zn.prototype.getResponseText=zn.prototype.aa,zn.prototype.send=zn.prototype.ca;var _r={createWebChannelTransport:Ar,ErrorCode:Te,EventType:Ie,WebChannel:_e,XhrIo:zn},Sr=_r.createWebChannelTransport,Dr=_r.ErrorCode,kr=_r.EventType,xr=_r.WebChannel,Rr=_r.XhrIo,Lr=mp.SDK_VERSION,Or=(Vr.prototype.t=function(){return null!=this.uid},Vr.prototype.s=function(){return this.t()?"uid:"+this.uid:"anonymous-user"},Vr.prototype.isEqual=function(t){return t.uid===this.uid},Vr);function Vr(t){this.uid=t}Or.UNAUTHENTICATED=new Or(null),Or.i=new Or("google-credentials-uid"),Or.o=new Or("first-party-uid");function Pr(t,e){this.user=e,this.type="OAuth",this.h={},this.h.Authorization="Bearer "+t}var Cr,Ur={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"},Mr=(n(Qr,Cr=Error),Qr),Fr=(Jr.prototype.getToken=function(){return Promise.resolve(null)},Jr.prototype._=function(){},Jr.prototype.l=function(t){(this.u=t)(Or.UNAUTHENTICATED)},Jr.prototype.T=function(){this.u=null},Jr),jr=(Xr.prototype.getToken=function(){var e=this,n=this.R,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.R!==n)throw new Mr(Ur.ABORTED,"getToken aborted due to token change.");return t?(gu("string"==typeof t.accessToken,"Invalid tokenData returned from getToken():"+t),new Pr(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},Xr.prototype._=function(){this.forceRefresh=!0},Xr.prototype.l=function(t){this.u=t,this.I&&t(this.currentUser)},Xr.prototype.T=function(){this.auth&&this.auth.removeAuthTokenListener(this.m),this.m=null,this.u=null},Xr.prototype.A=function(){var t=this.auth&&this.auth.getUid();return gu(null===t||"string"==typeof t,"Received invalid UID: "+t),new Or(t)},Xr),qr=(Object.defineProperty(Yr.prototype,"h",{get:function(){var t={"X-Goog-AuthUser":this.V},e=this.P.auth.g([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),Yr),Gr=(Hr.prototype.getToken=function(){return Promise.resolve(new qr(this.P,this.V))},Hr.prototype.l=function(t){t(Or.o)},Hr.prototype.T=function(){},Hr.prototype._=function(){},Hr),Br=(Wr.now=function(){return Wr.fromMillis(Date.now())},Wr.fromDate=function(t){return Wr.fromMillis(t.getTime())},Wr.fromMillis=function(t){var e=Math.floor(t/1e3);return new Wr(e,1e6*(t-1e3*e))},Wr.prototype.toDate=function(){return new Date(this.toMillis())},Wr.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},Wr.prototype.p=function(t){return this.seconds===t.seconds?Eu(this.nanoseconds,t.nanoseconds):Eu(this.seconds,t.seconds)},Wr.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},Wr.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},Wr.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},Wr),zr=(Kr.v=function(t){return new Kr(t)},Kr.S=function(){return Kr.MIN},Kr.prototype.D=function(t){return this.timestamp.p(t.timestamp)},Kr.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Kr.prototype.C=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Kr.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Kr.prototype.k=function(){return this.timestamp},Kr);function Kr(t){this.timestamp=t}function Wr(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new Mr(Ur.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new Mr(Ur.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Mr(Ur.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new Mr(Ur.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function Hr(t,e){this.P=t,this.V=e}function Yr(t,e){this.P=t,this.V=e,this.type="FirstParty",this.user=Or.o}function Xr(t){var e=this;this.m=null,this.currentUser=Or.UNAUTHENTICATED,this.I=!1,this.R=0,this.u=null,this.forceRefresh=!1,this.m=function(){e.R++,e.currentUser=e.A(),e.I=!0,e.u&&e.u(e.currentUser)},this.R=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.m):(this.m(null),t.get().then(function(t){e.auth=t,e.m&&e.auth.addAuthTokenListener(e.m)},function(){}))}function Jr(){this.u=null}function Qr(t,e){var n=this;return(n=Cr.call(this,e)||this).code=t,n.message=e,n.name="FirebaseError",n.toString=function(){return n.name+": [code="+n.code+"]: "+n.message},n}zr.MIN=new zr(new Br(0,0));var Zr,$r=(Object.defineProperty(ni.prototype,"length",{get:function(){return this.N},enumerable:!0,configurable:!0}),ni.prototype.isEqual=function(t){return 0===ni.F(this,t)},ni.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof ni?t.forEach(function(t){e.push(t)}):e.push(t),this.$(e)},ni.prototype.limit=function(){return this.offset+this.length},ni.prototype.M=function(t){return t=void 0===t?1:t,this.$(this.segments,this.offset+t,this.length-t)},ni.prototype.L=function(){return this.$(this.segments,this.offset,this.length-1)},ni.prototype.O=function(){return this.segments[this.offset]},ni.prototype.B=function(){return this.get(this.length-1)},ni.prototype.get=function(t){return this.segments[this.offset+t]},ni.prototype.U=function(){return 0===this.length},ni.prototype.q=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},ni.prototype.W=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},ni.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},ni.prototype.j=function(){return this.segments.slice(this.offset,this.limit())},ni.F=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},ni),ti=(n(ei,Zr=$r),ei.prototype.$=function(t,e,n){return new ei(t,e,n)},ei.prototype.K=function(){return this.j().join("/")},ei.prototype.toString=function(){return this.K()},ei.G=function(t){if(0<=t.indexOf("//"))throw new Mr(Ur.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new ei(t.split("/").filter(function(t){return 0<t.length}))},ei);function ei(){return null!==Zr&&Zr.apply(this,arguments)||this}function ni(t,e,n){void 0===e?e=0:e>t.length&&mu("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&mu("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.N=n}ti.H=new ti([]);var ri,ii=/^[_a-zA-Z][_a-zA-Z0-9]*$/,oi=(n(si,ri=$r),si.prototype.$=function(t,e,n){return new si(t,e,n)},si.J=function(t){return ii.test(t)},si.prototype.K=function(){return this.j().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),si.J(t)||(t="`"+t+"`"),t}).join(".")},si.prototype.toString=function(){return this.K()},si.prototype.Y=function(){return 1===this.length&&"__name__"===this.get(0)},si.X=function(){return new si(["__name__"])},si.Z=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new Mr(Ur.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 Mr(Ur.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[r+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new Mr(Ur.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=u,r+=2}else"`"===s?o=!o:"."!==s||o?n+=s:i(),r++}if(i(),o)throw new Mr(Ur.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new si(e)},si);function si(){return null!==ri&&ri.apply(this,arguments)||this}oi.H=new oi([]);var ui=(ai.tt=function(t){return new ai(ti.G(t).M(5))},ai.prototype.et=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},ai.prototype.isEqual=function(t){return null!==t&&0===ti.F(this.path,t.path)},ai.prototype.toString=function(){return this.path.toString()},ai.F=function(t,e){return ti.F(t.path,e.path)},ai.st=function(t){return t.length%2==0},ai.nt=function(t){return new ai(new ti(t.slice()))},ai);function ai(t){this.path=t}ui.EMPTY=new ui(new ti([]));var hi=(di.prototype.it=function(t,e){return new di(this.F,this.root.it(t,e,this.F).rt(null,null,fi.ot,null,null))},di.prototype.remove=function(t){return new di(this.F,this.root.remove(t,this.F).rt(null,null,fi.ot,null,null))},di.prototype.get=function(t){for(var e=this.root;!e.U();){var n=this.F(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},di.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.U();){var r=this.F(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},di.prototype.U=function(){return this.root.U()},Object.defineProperty(di.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),di.prototype.ht=function(){return this.root.ht()},di.prototype.at=function(){return this.root.at()},di.prototype.ut=function(t){return this.root.ut(t)},di.prototype.forEach=function(n){this.ut(function(t,e){return n(t,e),!1})},di.prototype.toString=function(){var n=[];return this.ut(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},di.prototype.ct=function(t){return this.root.ct(t)},di.prototype._t=function(){return new ci(this.root,null,this.F,!1)},di.prototype.lt=function(t){return new ci(this.root,t,this.F,!1)},di.prototype.dt=function(){return new ci(this.root,null,this.F,!0)},di.prototype.ft=function(t){return new ci(this.root,t,this.F,!0)},di),ci=(pi.prototype.wt=function(){var t=this.Et.pop(),e={key:t.key,value:t.value};if(this.Tt)for(t=t.left;!t.U();)this.Et.push(t),t=t.right;else for(t=t.right;!t.U();)this.Et.push(t),t=t.left;return e},pi.prototype.It=function(){return 0<this.Et.length},pi.prototype.Rt=function(){if(0===this.Et.length)return null;var t=this.Et[this.Et.length-1];return{key:t.key,value:t.value}},pi),fi=(li.prototype.rt=function(t,e,n,r,i){return new li(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)},li.prototype.U=function(){return!1},li.prototype.ut=function(t){return this.left.ut(t)||t(this.key,this.value)||this.right.ut(t)},li.prototype.ct=function(t){return this.right.ct(t)||t(this.key,this.value)||this.left.ct(t)},li.prototype.min=function(){return this.left.U()?this:this.left.min()},li.prototype.ht=function(){return this.min().key},li.prototype.at=function(){return this.right.U()?this.key:this.right.at()},li.prototype.it=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.rt(null,null,null,r.left.it(t,e,n),null):0===i?r.rt(null,e,null,null,null):r.rt(null,null,null,null,r.right.it(t,e,n))).At()},li.prototype.Pt=function(){if(this.left.U())return li.EMPTY;var t=this;return t.left.Vt()||t.left.left.Vt()||(t=t.gt()),(t=t.rt(null,null,null,t.left.Pt(),null)).At()},li.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.U()||r.left.Vt()||r.left.left.Vt()||(r=r.gt()),r=r.rt(null,null,null,r.left.remove(t,e),null);else{if(r.left.Vt()&&(r=r.pt()),r.right.U()||r.right.Vt()||r.right.left.Vt()||(r=r.yt()),0===e(t,r.key)){if(r.right.U())return li.EMPTY;n=r.right.min(),r=r.rt(n.key,n.value,null,null,r.right.Pt())}r=r.rt(null,null,null,null,r.right.remove(t,e))}return r.At()},li.prototype.Vt=function(){return this.color},li.prototype.At=function(){var t=this;return t.right.Vt()&&!t.left.Vt()&&(t=t.bt()),t.left.Vt()&&t.left.left.Vt()&&(t=t.pt()),t.left.Vt()&&t.right.Vt()&&(t=t.vt()),t},li.prototype.gt=function(){var t=this.vt();return t.right.left.Vt()&&(t=(t=(t=t.rt(null,null,null,null,t.right.pt())).bt()).vt()),t},li.prototype.yt=function(){var t=this.vt();return t.left.left.Vt()&&(t=(t=t.pt()).vt()),t},li.prototype.bt=function(){var t=this.rt(null,null,li.RED,null,this.right.left);return this.right.rt(null,null,this.color,t,null)},li.prototype.pt=function(){var t=this.rt(null,null,li.RED,this.left.right,null);return this.left.rt(null,null,this.color,null,t)},li.prototype.vt=function(){var t=this.left.rt(null,null,!this.left.color,null,null),e=this.right.rt(null,null,!this.right.color,null,null);return this.rt(null,null,!this.color,t,e)},li.prototype.St=function(){var t=this.Dt();return Math.pow(2,t)<=this.size+1},li.prototype.Dt=function(){if(this.Vt()&&this.left.Vt())throw mu("Red node has red child("+this.key+","+this.value+")");if(this.right.Vt())throw mu("Right child of ("+this.key+","+this.value+") is red");var t=this.left.Dt();if(t!==this.right.Dt())throw mu("Black depths differ");return t+(this.Vt()?0:1)},li);function li(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:li.RED,this.left=null!=r?r:li.EMPTY,this.right=null!=i?i:li.EMPTY,this.size=this.left.size+1+this.right.size}function pi(t,e,n,r){this.Tt=r,this.Et=[];for(var i=1;!t.U();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.Tt?t.left:t.right;else{if(0===i){this.Et.push(t);break}this.Et.push(t),t=this.Tt?t.right:t.left}}function di(t,e){this.F=t,this.root=e||fi.EMPTY}function yi(){this.size=0}fi.EMPTY=null,fi.RED=!0,fi.ot=!1,fi.EMPTY=(Object.defineProperty(yi.prototype,"key",{get:function(){throw mu("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(yi.prototype,"value",{get:function(){throw mu("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(yi.prototype,"color",{get:function(){throw mu("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(yi.prototype,"left",{get:function(){throw mu("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(yi.prototype,"right",{get:function(){throw mu("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),yi.prototype.rt=function(t,e,n,r,i){return this},yi.prototype.it=function(t,e,n){return new fi(t,e)},yi.prototype.remove=function(t,e){return this},yi.prototype.U=function(){return!0},yi.prototype.ut=function(t){return!1},yi.prototype.ct=function(t){return!1},yi.prototype.ht=function(){return null},yi.prototype.at=function(){return null},yi.prototype.Vt=function(){return!1},yi.prototype.St=function(){return!0},yi.prototype.Dt=function(){return 0},new yi);var vi=(wi.prototype.has=function(t){return null!==this.data.get(t)},wi.prototype.first=function(){return this.data.ht()},wi.prototype.last=function(){return this.data.at()},Object.defineProperty(wi.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),wi.prototype.indexOf=function(t){return this.data.indexOf(t)},wi.prototype.forEach=function(n){this.data.ut(function(t,e){return n(t),!1})},wi.prototype.Ct=function(t,e){for(var n=this.data.lt(t[0]);n.It();){var r=n.wt();if(0<=this.F(r.key,t[1]))return;e(r.key)}},wi.prototype.kt=function(t,e){var n;for(n=void 0!==e?this.data.lt(e):this.data._t();n.It();)if(!t(n.wt().key))return},wi.prototype.Nt=function(t){var e=this.data.lt(t);return e.It()?e.wt().key:null},wi.prototype._t=function(){return new mi(this.data._t())},wi.prototype.lt=function(t){return new mi(this.data.lt(t))},wi.prototype.add=function(t){return this.rt(this.data.remove(t).it(t,!0))},wi.prototype.delete=function(t){return this.has(t)?this.rt(this.data.remove(t)):this},wi.prototype.U=function(){return this.data.U()},wi.prototype.Ft=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach(function(t){e=e.add(t)}),e},wi.prototype.isEqual=function(t){if(!(t instanceof wi))return!1;if(this.size!==t.size)return!1;for(var e=this.data._t(),n=t.data._t();e.It();){var r=e.wt().key,i=n.wt().key;if(0!==this.F(r,i))return!1}return!0},wi.prototype.j=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},wi.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},wi.prototype.rt=function(t){var e=new wi(this.F);return e.data=t,e},wi),mi=(gi.prototype.wt=function(){return this.$t.wt().key},gi.prototype.It=function(){return this.$t.It()},gi);function gi(t){this.$t=t}function wi(t){this.F=t,this.data=new hi(this.F)}function bi(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Ei(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Ti(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var Ii=(Ni.fromBase64String=function(t){return new Ni(hu.Lt().atob(t))},Ni.fromUint8Array=function(t){return new Ni(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t))},Ni.prototype.toBase64=function(){return hu.Lt().btoa(this.Mt)},Ni.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.Mt)},Ni.prototype.Ot=function(){return 2*this.Mt.length},Ni.prototype.D=function(t){return Eu(this.Mt,t.Mt)},Ni.prototype.isEqual=function(t){return this.Mt===t.Mt},Ni);function Ni(t){this.Mt=t}function Ai(t){return null==t}function _i(t){return-0===t&&1/t==-1/0}function Si(t){return"number"==typeof t&&Number.isInteger(t)&&!_i(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}function Di(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function ki(t){var e=Ui(t.mapValue.fields.__local_write_time__.timestampValue);return new Br(e.seconds,e.nanos)}Ii.xt=new Ii("");var xi=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Ri(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?Di(t)?4:10:mu("Invalid value type: "+JSON.stringify(t))}function Li(i,t){var e,n,r,o=Ri(i);if(o!==Ri(t))return!1;switch(o){case 0:return!0;case 1:return i.booleanValue===t.booleanValue;case 4:return ki(i).isEqual(ki(t));case 3:return function(t){if("string"==typeof i.timestampValue&&"string"==typeof t.timestampValue&&i.timestampValue.length===t.timestampValue.length)return i.timestampValue===t.timestampValue;var e=Ui(i.timestampValue),n=Ui(t.timestampValue);return e.seconds===n.seconds&&e.nanos===n.nanos}(t);case 5:return i.stringValue===t.stringValue;case 6:return r=t,Fi(i.bytesValue).isEqual(Fi(r.bytesValue));case 7:return i.referenceValue===t.referenceValue;case 8:return n=t,Mi((e=i).geoPointValue.latitude)===Mi(n.geoPointValue.latitude)&&Mi(e.geoPointValue.longitude)===Mi(n.geoPointValue.longitude);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Mi(t.integerValue)===Mi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=Mi(t.doubleValue),r=Mi(e.doubleValue);return n===r?_i(n)===_i(r):isNaN(n)&&isNaN(r)}return!1}(i,t);case 9:return Tu(i.arrayValue.values||[],t.arrayValue.values||[],Li);case 10:return function(t){var e=i.mapValue.fields||{},n=t.mapValue.fields||{};if(bi(e)!==bi(n))return!1;for(var r in e)if(e.hasOwnProperty(r)&&(void 0===n[r]||!Li(e[r],n[r])))return!1;return!0}(t);default:return mu("Unexpected value type: "+JSON.stringify(i))}}function Oi(t,e){return void 0!==(t.values||[]).find(function(t){return Li(t,e)})}function Vi(t,e){var n,r,i,o,s,u,a,h,c,f,l=Ri(t),p=Ri(e);if(l!==p)return Eu(l,p);switch(l){case 0:return 0;case 1:return Eu(t.booleanValue,e.booleanValue);case 2:return h=e,c=Mi(t.integerValue||t.doubleValue),f=Mi(h.integerValue||h.doubleValue),c<f?-1:f<c?1:c===f?0:isNaN(c)?isNaN(f)?0:-1:1;case 3:return Pi(t.timestampValue,e.timestampValue);case 4:return Pi(ki(t),ki(e));case 5:return Eu(t.stringValue,e.stringValue);case 6:return o=t.bytesValue,s=e.bytesValue,u=Fi(o),a=Fi(s),u.D(a);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=Eu(n[i],r[i]);if(0!==o)return o}return Eu(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return n=t.geoPointValue,r=e.geoPointValue,0!==(i=Eu(Mi(n.latitude),Mi(r.latitude)))?i:Eu(Mi(n.longitude),Mi(r.longitude));case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=Vi(n[i],r[i]);if(o)return o}return Eu(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var s=0;s<r.length&&s<o.length;++s){var u=Eu(r[s],o[s]);if(0!==u)return u;var a=Vi(n[r[s]],i[o[s]]);if(0!==a)return a}return Eu(r.length,o.length)}(t.mapValue,e.mapValue);default:throw mu("Invalid value type: "+l)}}function Pi(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Eu(t,e);var n=Ui(t),r=Ui(e),i=Eu(n.seconds,r.seconds);return 0!==i?i:Eu(n.nanos,r.nanos)}function Ci(t){return function s(i){return"nullValue"in i?"null":"booleanValue"in i?""+i.booleanValue:"integerValue"in i?""+i.integerValue:"doubleValue"in i?""+i.doubleValue:"timestampValue"in i?"time("+(t=Ui(i.timestampValue)).seconds+","+t.nanos+")":"stringValue"in i?i.stringValue:"bytesValue"in i?Fi(i.bytesValue).toBase64():"referenceValue"in i?(n=i.referenceValue,ui.tt(n).toString()):"geoPointValue"in i?"geo("+(e=i.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in i?function(){for(var t="[",e=!0,n=0,r=i.arrayValue.values||[];n<r.length;n++){e?e=!1:t+=",",t+=s(r[n])}return t+"]"}():"mapValue"in i?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+s(t.fields[o])}return e+"}"}(i.mapValue):mu("Invalid value type: "+JSON.stringify(i));var t,e,n}(t)}function Ui(t){if(gu(!!t,"Cannot normalize null or undefined timestamp."),"string"!=typeof t)return{seconds:Mi(t.seconds),nanos:Mi(t.nanos)};var e=0,n=xi.exec(t);if(gu(!!n,"invalid timestamp: "+t),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}function Mi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function Fi(t){return"string"==typeof t?Ii.fromBase64String(t):Ii.fromUint8Array(t)}function ji(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.K()}}function qi(t){return t&&"integerValue"in t}function Gi(t){return!!t&&"arrayValue"in t}function Bi(t){return t&&"nullValue"in t}function zi(t){return t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Ki(t){return t&&"mapValue"in t}var Wi=(Hi.prototype.Bt=function(t,e){return n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}},t&&(n.fields.__previous_value__=t),{mapValue:n};var n},Hi.prototype.Ut=function(t,e){return e},Hi.prototype.qt=function(t){return null},Hi.prototype.isEqual=function(t){return t instanceof Hi},Hi);function Hi(){}Wi.instance=new Wi;var Yi=($i.prototype.Bt=function(t,e){return this.apply(t)},$i.prototype.Ut=function(t,e){return this.apply(t)},$i.prototype.apply=function(t){for(var n=to(t),e=function(e){n.some(function(t){return Li(t,e)})||n.push(e)},r=0,i=this.elements;r<i.length;r++)e(i[r]);return{arrayValue:{values:n}}},$i.prototype.qt=function(t){return null},$i.prototype.isEqual=function(t){return t instanceof $i&&Tu(this.elements,t.elements,Li)},$i),Xi=(Zi.prototype.Bt=function(t,e){return this.apply(t)},Zi.prototype.Ut=function(t,e){return this.apply(t)},Zi.prototype.apply=function(t){for(var n=to(t),e=function(e){n=n.filter(function(t){return!Li(t,e)})},r=0,i=this.elements;r<i.length;r++)e(i[r]);return{arrayValue:{values:n}}},Zi.prototype.qt=function(t){return null},Zi.prototype.isEqual=function(t){return t instanceof Zi&&Tu(this.elements,t.elements,Li)},Zi),Ji=(Qi.prototype.Bt=function(t,e){var n=this.qt(t),r=this.asNumber(n)+this.asNumber(this.Qt);return qi(n)&&qi(this.Qt)?this.serializer.Wt(r):this.serializer.jt(r)},Qi.prototype.Ut=function(t,e){return e},Qi.prototype.qt=function(t){return qi(e=t)||e&&"doubleValue"in e?t:{integerValue:0};var e},Qi.prototype.isEqual=function(t){return t instanceof Qi&&Li(this.Qt,t.Qt)},Qi.prototype.asNumber=function(t){return Mi(t.integerValue||t.doubleValue)},Qi);function Qi(t,e){this.serializer=t,this.Qt=e}function Zi(t){this.elements=t}function $i(t){this.elements=t}function to(t){return Gi(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function eo(t,e){this.version=t,this.transformResults=e}var no=(uo.Kt=function(t){return new uo(t)},uo.Gt=function(t){var e=new vi(oi.F);return t.forEach(function(t){return e=e.add(t)}),new uo(e)},uo.prototype.zt=function(e){var n=!1;return this.fields.forEach(function(t){t.q(e)&&(n=!0)}),n},uo.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},uo),ro=(so.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},so),io=(oo.exists=function(t){return new oo(void 0,t)},oo.updateTime=function(t){return new oo(t)},Object.defineProperty(oo.prototype,"Ht",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),oo.prototype.Jt=function(t){return void 0!==this.updateTime?t instanceof Oo&&t.version.isEqual(this.updateTime):void 0===this.exists||this.exists===t instanceof Oo},oo.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},oo);function oo(t,e){this.updateTime=t,this.exists=e}function so(t,e){this.field=t,this.transform=e}function uo(t){this.fields=t}io.NONE=new io;var ao,ho,co,fo,lo,po=(So.prototype.Yt=function(t){},So.Xt=function(t){return t instanceof Oo?t.version:zr.MIN},So),yo=(n(_o,lo=po),_o.prototype.Ut=function(t,e){this.Yt(t);var n=e.version;return new Oo(this.key,n,this.value,{hasCommittedMutations:!0})},_o.prototype.Bt=function(t,e,n){if(this.Yt(t),!this.Zt.Jt(t))return t;var r=po.Xt(t);return new Oo(this.key,r,this.value,{te:!0})},_o.prototype.ee=function(t){return null},_o.prototype.isEqual=function(t){return t instanceof _o&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.Zt.isEqual(t.Zt)},_o),vo=(n(Ao,fo=po),Ao.prototype.Ut=function(t,e){if(this.Yt(t),!this.Zt.Jt(t))return new Po(this.key,e.version);var n=this.ne(t);return new Oo(this.key,e.version,n,{hasCommittedMutations:!0})},Ao.prototype.Bt=function(t,e,n){if(this.Yt(t),!this.Zt.Jt(t))return t;var r=po.Xt(t),i=this.ne(t);return new Oo(this.key,r,i,{te:!0})},Ao.prototype.ee=function(t){return null},Ao.prototype.isEqual=function(t){return t instanceof Ao&&this.key.isEqual(t.key)&&this.se.isEqual(t.se)&&this.Zt.isEqual(t.Zt)},Ao.prototype.ne=function(t){var e;return e=t instanceof Oo?t.data():bo.EMPTY,this.ie(e)},Ao.prototype.ie=function(t){var n=this,r=t.re();return this.se.fields.forEach(function(t){if(!t.U()){var e=n.data.field(t);null!==e?r.set(t,e):r.delete(t)}}),r.oe()},Ao),mo=(n(No,co=po),No.prototype.Ut=function(t,e){if(this.Yt(t),gu(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.Zt.Jt(t))return new Po(this.key,e.version);var n=this.he(t),r=this.ae(t,e.transformResults),i=e.version,o=this.ue(n.data(),r);return new Oo(this.key,i,o,{hasCommittedMutations:!0})},No.prototype.Bt=function(t,e,n){if(this.Yt(t),!this.Zt.Jt(t))return t;var r=this.he(t),i=this.ce(n,t,e),o=this.ue(r.data(),i);return new Oo(this.key,r.version,o,{te:!0})},No.prototype.ee=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Oo?t.field(i.field):void 0,s=i.transform.qt(o||null);null!=s&&(e=null==e?bo._e().set(i.field,s):e.set(i.field,s))}return e?e.oe():null},No.prototype.isEqual=function(t){return t instanceof No&&this.key.isEqual(t.key)&&Tu(this.fieldTransforms,t.fieldTransforms,function(t,e){return t.isEqual(e)})&&this.Zt.isEqual(t.Zt)},No.prototype.he=function(t){return t},No.prototype.ae=function(t,e){var n=[];gu(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 Oo&&(s=t.field(i.field)),n.push(o.Ut(s,e[r]))}return n},No.prototype.ce=function(t,e,n){for(var r=[],i=0,o=this.fieldTransforms;i<o.length;i++){var s=o[i],u=s.transform,a=null;e instanceof Oo&&(a=e.field(s.field)),null===a&&n instanceof Oo&&(a=n.field(s.field)),r.push(u.Bt(a,t))}return r},No.prototype.ue=function(t,e){for(var n=t.re(),r=0;r<this.fieldTransforms.length;r++){var i=this.fieldTransforms[r].field;n.set(i,e[r])}return n.oe()},No),go=(n(Io,ho=po),Io.prototype.Ut=function(t,e){return this.Yt(t),new Vo(this.key,e.version,{hasCommittedMutations:!0})},Io.prototype.Bt=function(t,e,n){return this.Yt(t),this.Zt.Jt(t)?new Vo(this.key,zr.S()):t},Io.prototype.ee=function(t){return null},Io.prototype.isEqual=function(t){return t instanceof Io&&this.key.isEqual(t.key)&&this.Zt.isEqual(t.Zt)},Io),wo=(n(To,ao=po),To.prototype.Ut=function(t,e){mu("VerifyMutation should only be used in Transactions.")},To.prototype.Bt=function(t,e,n){mu("VerifyMutation should only be used in Transactions.")},To.prototype.ee=function(t){mu("VerifyMutation should only be used in Transactions.")},To.prototype.isEqual=function(t){return t instanceof To&&this.key.isEqual(t.key)&&this.Zt.isEqual(t.Zt)},To),bo=(Eo._e=function(){return Eo.EMPTY.re()},Eo.prototype.field=function(t){if(t.U())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!Ki(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t.B()])||null},Eo.prototype.se=function(){return this.le(this.proto.mapValue)},Eo.prototype.le=function(t){var i=this,o=new vi(oi.F);return Ei(t.fields||{},function(t,e){var n=new oi([t]);if(10===Ri(e)){var r=i.le(e.mapValue).fields;r.U()?o=o.add(n):r.forEach(function(t){o=o.add(n.child(t))})}else o=o.add(n)}),no.Kt(o)},Eo.prototype.isEqual=function(t){return Li(this.proto,t.proto)},Eo.prototype.re=function(){return new Ro(this)},Eo);function Eo(t){this.proto=t}function To(t,e){var n=this;return(n=ao.call(this)||this).key=t,n.Zt=e,n.type=4,n}function Io(t,e){var n=this;return(n=ho.call(this)||this).key=t,n.Zt=e,n.type=3,n}function No(t,e){var n=this;return(n=co.call(this)||this).key=t,n.fieldTransforms=e,n.type=2,n.Zt=io.exists(!0),n}function Ao(t,e,n,r){var i=this;return(i=fo.call(this)||this).key=t,i.data=e,i.se=n,i.Zt=r,i.type=1,i}function _o(t,e,n){var r=this;return(r=lo.call(this)||this).key=t,r.value=e,r.Zt=n,r.type=0,r}function So(){}bo.EMPTY=new bo({mapValue:{}});var Do,ko,xo,Ro=(Wo.prototype.set=function(t,e){return this.Te(t,e),this},Wo.prototype.delete=function(t){return this.Te(t,null),this},Wo.prototype.Te=function(t,e){for(var n=this.fe,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map||(o=o&&10===Ri(o)?new Map(Object.entries(o.mapValue.fields||{})):new Map,n.set(i,o)),n=o}n.set(t.B(),e)},Wo.prototype.oe=function(){var t=this.me(oi.H,this.fe);return null!=t?new bo(t):this.de},Wo.prototype.me=function(r,t){var i=this,o=!1,e=this.de.field(r),s=Ki(e)?Object.assign({},e.mapValue.fields):{};return t.forEach(function(t,e){if(t instanceof Map){var n=i.me(r.child(e),t);null!=n&&(s[e]=n,o=!0)}else null!==t?(s[e]=t,o=!0):s.hasOwnProperty(e)&&(delete s[e],o=!0)}),o?{mapValue:{fields:s}}:null},Wo),Lo=(Ko.Ee=function(t,e){return ui.F(t.key,e.key)},Ko),Oo=(n(zo,xo=Lo),zo.prototype.field=function(t){return this.we.field(t)},zo.prototype.data=function(){return this.we},zo.prototype.Ie=function(){return this.we.proto},zo.prototype.isEqual=function(t){return t instanceof zo&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.te===t.te&&this.hasCommittedMutations===t.hasCommittedMutations&&this.we.isEqual(t.we)},zo.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.we.toString()+", {hasLocalMutations: "+this.te+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(zo.prototype,"hasPendingWrites",{get:function(){return this.te||this.hasCommittedMutations},enumerable:!0,configurable:!0}),zo.Re=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?Vi(r,i):mu("Trying to compare documents on fields that don't exist")},zo),Vo=(n(Bo,ko=Lo),Bo.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(Bo.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),Bo.prototype.isEqual=function(t){return t instanceof Bo&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Bo),Po=(n(Go,Do=Lo),Go.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Go.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),Go.prototype.isEqual=function(t){return t instanceof Go&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Go),Co=(qo.prototype.canonicalId=function(){if(null===this.Ae){var t=this.path.K();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:",t+=this.filters.map(function(t){return t.canonicalId()}).join(","),t+="|ob:",t+=this.orderBy.map(function(t){return t.canonicalId()}).join(","),Ai(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.Ae=t}return this.Ae},qo.prototype.toString=function(){var t=this.path.K();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),Ai(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+")"},qo.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(var n=0;n<this.filters.length;n++)if(!this.filters[n].isEqual(t.filters[n]))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)},qo.prototype.Pe=function(){return ui.st(this.path)&&null===this.collectionGroup&&0===this.filters.length},qo),Uo=(jo.ve=function(t){return new jo(t)},Object.defineProperty(jo.prototype,"orderBy",{get:function(){if(null===this.pe){var t=this.Se(),e=this.De();if(null!==t&&null===e)t.Y()?this.pe=[gs]:this.pe=[new ms(t),gs];else{for(var n=!(this.pe=[]),r=0,i=this.Ve;r<i.length;r++){var o=i[r];this.pe.push(o),o.field.Y()&&(n=!0)}if(!n){var s=0<this.Ve.length?this.Ve[this.Ve.length-1].dir:os.ASCENDING;this.pe.push(s===os.ASCENDING?gs:ws)}}}return this.pe},enumerable:!0,configurable:!0}),jo.prototype.Ce=function(t){var e=this.filters.concat([t]);return new jo(this.path,this.collectionGroup,this.Ve.slice(),e,this.limit,this.ge,this.startAt,this.endAt)},jo.prototype.ke=function(t){var e=this.Ve.concat([t]);return new jo(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.ge,this.startAt,this.endAt)},jo.prototype.Ne=function(t){return new jo(this.path,this.collectionGroup,this.Ve.slice(),this.filters.slice(),t,"F",this.startAt,this.endAt)},jo.prototype.Fe=function(t){return new jo(this.path,this.collectionGroup,this.Ve.slice(),this.filters.slice(),t,"L",this.startAt,this.endAt)},jo.prototype.$e=function(t){return new jo(this.path,this.collectionGroup,this.Ve.slice(),this.filters.slice(),this.limit,this.ge,t,this.endAt)},jo.prototype.Me=function(t){return new jo(this.path,this.collectionGroup,this.Ve.slice(),this.filters.slice(),this.limit,this.ge,this.startAt,t)},jo.prototype.Le=function(t){return new jo(t,null,this.Ve.slice(),this.filters.slice(),this.limit,this.ge,this.startAt,this.endAt)},jo.prototype.Oe=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.Ve.length||1===this.Ve.length&&this.Ve[0].field.Y())},jo.prototype.canonicalId=function(){return this.xe().canonicalId()+"|lt:"+this.ge},jo.prototype.toString=function(){return"Query(target="+this.xe().toString()+"; limitType="+this.ge+")"},jo.prototype.isEqual=function(t){return this.xe().isEqual(t.xe())&&this.ge===t.ge},jo.prototype.Be=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.Y()}return 0},jo.prototype.matches=function(t){return this.Ue(t)&&this.qe(t)&&this.Qe(t)&&this.We(t)},jo.prototype.je=function(){return!Ai(this.limit)&&"F"===this.ge},jo.prototype.Ke=function(){return!Ai(this.limit)&&"L"===this.ge},jo.prototype.De=function(){return 0<this.Ve.length?this.Ve[0].field:null},jo.prototype.Se=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof $o&&n.Ge())return n.field}return null},jo.prototype.ze=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof $o&&0<=t.indexOf(r.op))return r.op}return null},jo.prototype.Pe=function(){return this.xe().Pe()},jo.prototype.He=function(){return null!==this.collectionGroup},jo.prototype.xe=function(){if(!this.ye)if("F"===this.ge)this.ye=new Co(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===os.DESCENDING?os.ASCENDING:os.DESCENDING;t.push(new ms(r.field,i))}var o=this.endAt?new vs(this.endAt.position,!this.endAt.before):null,s=this.startAt?new vs(this.startAt.position,!this.startAt.before):null;this.ye=new Co(this.path,this.collectionGroup,t,this.filters,this.limit,o,s)}return this.ye},jo.prototype.Ue=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.et(this.collectionGroup)&&this.path.q(e):ui.st(this.path)?this.path.isEqual(e):this.path.W(e)},jo.prototype.qe=function(t){for(var e=0,n=this.Ve;e<n.length;e++){var r=n[e];if(!r.field.Y()&&null===t.field(r.field))return!1}return!0},jo.prototype.Qe=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},jo.prototype.We=function(t){return!(this.startAt&&!this.startAt.Je(this.orderBy,t)||this.endAt&&this.endAt.Je(this.orderBy,t))},jo.prototype.be=function(t){},jo),Mo=(Fo.G=function(t){switch(t){case"<":return Fo.LESS_THAN;case"<=":return Fo.LESS_THAN_OR_EQUAL;case"==":return Fo.EQUAL;case">=":return Fo.GREATER_THAN_OR_EQUAL;case">":return Fo.GREATER_THAN;case"array-contains":return Fo.ARRAY_CONTAINS;case"in":return Fo.IN;case"array-contains-any":return Fo.ARRAY_CONTAINS_ANY;default:return mu("Unknown FieldFilter operator: "+t)}},Fo.prototype.toString=function(){return this.name},Fo.prototype.isEqual=function(t){return this.name===t.name},Fo);function Fo(t){this.name=t}function jo(t,e,n,r,i,o,s,u){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===s&&(s=null),void 0===u&&(u=null),this.path=t,this.collectionGroup=e,this.Ve=n,this.filters=r,this.limit=i,this.ge=o,this.startAt=s,this.endAt=u,this.pe=null,this.ye=null,this.startAt&&this.be(this.startAt),this.endAt&&this.be(this.endAt)}function qo(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.Ae=null}function Go(){return null!==Do&&Do.apply(this,arguments)||this}function Bo(t,e,n){var r=this;return(r=ko.call(this,t,e)||this).hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}function zo(t,e,n,r){var i=this;return(i=xo.call(this,t,e)||this).we=n,i.te=!!r.te,i.hasCommittedMutations=!!r.hasCommittedMutations,i}function Ko(t,e){this.key=t,this.version=e}function Wo(t){this.de=t,this.fe=new Map}Mo.LESS_THAN=new Mo("<"),Mo.LESS_THAN_OR_EQUAL=new Mo("<="),Mo.EQUAL=new Mo("=="),Mo.GREATER_THAN=new Mo(">"),Mo.GREATER_THAN_OR_EQUAL=new Mo(">="),Mo.ARRAY_CONTAINS=new Mo("array-contains"),Mo.IN=new Mo("in"),Mo.ARRAY_CONTAINS_ANY=new Mo("array-contains-any");var Ho,Yo,Xo,Jo,Qo,Zo,$o=(n(ls,Zo=function(){}),ls.create=function(t,e,n){if(t.Y())return e===Mo.IN?new es(t,n):new ts(t,e,n);if(Bi(n)){if(e!==Mo.EQUAL)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new ls(t,e,n)}if(zi(n)){if(e!==Mo.EQUAL)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new ls(t,e,n)}return e===Mo.ARRAY_CONTAINS?new ns(t,n):e===Mo.IN?new rs(t,n):e===Mo.ARRAY_CONTAINS_ANY?new is(t,n):new ls(t,e,n)},ls.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&Ri(this.value)===Ri(e)&&this.Ye(Vi(e,this.value))},ls.prototype.Ye=function(t){switch(this.op){case Mo.LESS_THAN:return t<0;case Mo.LESS_THAN_OR_EQUAL:return t<=0;case Mo.EQUAL:return 0===t;case Mo.GREATER_THAN:return 0<t;case Mo.GREATER_THAN_OR_EQUAL:return 0<=t;default:return mu("Unknown FieldFilter operator: "+this.op)}},ls.prototype.Ge=function(){return 0<=[Mo.LESS_THAN,Mo.LESS_THAN_OR_EQUAL,Mo.GREATER_THAN,Mo.GREATER_THAN_OR_EQUAL].indexOf(this.op)},ls.prototype.canonicalId=function(){return this.field.K()+this.op.toString()+Ci(this.value)},ls.prototype.isEqual=function(t){return t instanceof ls&&this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&Li(this.value,t.value)},ls.prototype.toString=function(){return this.field.K()+" "+this.op+" "+Ci(this.value)},ls),ts=(n(fs,Qo=$o),fs.prototype.matches=function(t){var e=ui.F(t.key,this.key);return this.Ye(e)},fs),es=(n(cs,Jo=$o),cs.prototype.matches=function(e){return this.keys.some(function(t){return t.isEqual(e.key)})},cs),ns=(n(hs,Xo=$o),hs.prototype.matches=function(t){var e=t.field(this.field);return Gi(e)&&Oi(e.arrayValue,this.value)},hs),rs=(n(as,Yo=$o),as.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&Oi(this.value.arrayValue,e)},as),is=(n(us,Ho=$o),us.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!Gi(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(t){return Oi(e.value.arrayValue,t)})},us),os=(ss.prototype.toString=function(){return this.name},ss);function ss(t){this.name=t}function us(t,e){return Ho.call(this,t,Mo.ARRAY_CONTAINS_ANY,e)||this}function as(t,e){return Yo.call(this,t,Mo.IN,e)||this}function hs(t,e){return Xo.call(this,t,Mo.ARRAY_CONTAINS,e)||this}function cs(t,e){var n=this;return(n=Jo.call(this,t,Mo.IN,e)||this).keys=(e.arrayValue.values||[]).map(function(t){return ui.tt(t.referenceValue)}),n}function fs(t,e,n){var r=this;return(r=Qo.call(this,t,e,n)||this).key=ui.tt(n.referenceValue),r}function ls(t,e,n){var r=this;return(r=Zo.call(this)||this).field=t,r.op=e,r.value=n,r}os.ASCENDING=new os("asc"),os.DESCENDING=new os("desc");function ps(t){this.count=t}var ds,ys,vs=(Is.prototype.canonicalId=function(){return(this.before?"b":"a")+":"+this.position.map(function(t){return Ci(t)}).join(",")},Is.prototype.Je=function(t,e){for(var n=0,r=0;r<this.position.length;r++){var i=t[r],o=this.position[r];if(n=i.field.Y()?ui.F(ui.tt(o.referenceValue),e.key):Vi(o,e.field(i.field)),i.dir===os.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},Is.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++)if(!Li(this.position[e],t.position[e]))return!1;return!0},Is),ms=(Ts.prototype.compare=function(t,e){var n=this.Xe?Oo.Ee(t,e):Oo.Re(this.field,t,e);switch(this.dir){case os.ASCENDING:return n;case os.DESCENDING:return-1*n;default:return mu("Unknown direction: "+this.dir)}},Ts.prototype.canonicalId=function(){return this.field.K()+this.dir.toString()},Ts.prototype.toString=function(){return this.field.K()+" ("+this.dir+")"},Ts.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},Ts),gs=new ms(oi.X(),os.ASCENDING),ws=new ms(oi.X(),os.DESCENDING),bs=(Es.prototype.es=function(t){return new Es(this.target,this.targetId,this.Ze,t,this.ts,this.lastLimboFreeSnapshotVersion,this.resumeToken)},Es.prototype.ss=function(t,e){return new Es(this.target,this.targetId,this.Ze,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},Es.prototype.ns=function(t){return new Es(this.target,this.targetId,this.Ze,this.sequenceNumber,this.ts,t,this.resumeToken)},Es);function Es(t,e,n,r,i,o,s){void 0===i&&(i=zr.MIN),void 0===o&&(o=zr.MIN),void 0===s&&(s=Ii.xt),this.target=t,this.targetId=e,this.Ze=n,this.sequenceNumber=r,this.ts=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}function Ts(t,e){this.field=t,void 0===e&&(e=os.ASCENDING),this.dir=e,this.Xe=t.Y()}function Is(t,e){this.position=t,this.before=e}function Ns(t){switch(t){case Ur.OK:return mu("Treated status OK as error");case Ur.CANCELLED:case Ur.UNKNOWN:case Ur.DEADLINE_EXCEEDED:case Ur.RESOURCE_EXHAUSTED:case Ur.INTERNAL:case Ur.UNAVAILABLE:case Ur.UNAUTHENTICATED:return;case Ur.INVALID_ARGUMENT:case Ur.NOT_FOUND:case Ur.ALREADY_EXISTS:case Ur.PERMISSION_DENIED:case Ur.FAILED_PRECONDITION:case Ur.ABORTED:case Ur.OUT_OF_RANGE:case Ur.UNIMPLEMENTED:case Ur.DATA_LOSS:return 1;default:return mu("Unknown status code: "+t)}}function As(t){if(void 0===t)return yu("GRPC error has no .code"),Ur.UNKNOWN;switch(t){case ds.OK:return Ur.OK;case ds.CANCELLED:return Ur.CANCELLED;case ds.UNKNOWN:return Ur.UNKNOWN;case ds.DEADLINE_EXCEEDED:return Ur.DEADLINE_EXCEEDED;case ds.RESOURCE_EXHAUSTED:return Ur.RESOURCE_EXHAUSTED;case ds.INTERNAL:return Ur.INTERNAL;case ds.UNAVAILABLE:return Ur.UNAVAILABLE;case ds.UNAUTHENTICATED:return Ur.UNAUTHENTICATED;case ds.INVALID_ARGUMENT:return Ur.INVALID_ARGUMENT;case ds.NOT_FOUND:return Ur.NOT_FOUND;case ds.ALREADY_EXISTS:return Ur.ALREADY_EXISTS;case ds.PERMISSION_DENIED:return Ur.PERMISSION_DENIED;case ds.FAILED_PRECONDITION:return Ur.FAILED_PRECONDITION;case ds.ABORTED:return Ur.ABORTED;case ds.OUT_OF_RANGE:return Ur.OUT_OF_RANGE;case ds.UNIMPLEMENTED:return Ur.UNIMPLEMENTED;case ds.DATA_LOSS:return Ur.DATA_LOSS;default:return mu("Unknown status code: "+t)}}(ys=ds=ds||{})[ys.OK=0]="OK",ys[ys.CANCELLED=1]="CANCELLED",ys[ys.UNKNOWN=2]="UNKNOWN",ys[ys.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",ys[ys.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",ys[ys.NOT_FOUND=5]="NOT_FOUND",ys[ys.ALREADY_EXISTS=6]="ALREADY_EXISTS",ys[ys.PERMISSION_DENIED=7]="PERMISSION_DENIED",ys[ys.UNAUTHENTICATED=16]="UNAUTHENTICATED",ys[ys.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",ys[ys.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",ys[ys.ABORTED=10]="ABORTED",ys[ys.OUT_OF_RANGE=11]="OUT_OF_RANGE",ys[ys.UNIMPLEMENTED=12]="UNIMPLEMENTED",ys[ys.INTERNAL=13]="INTERNAL",ys[ys.UNAVAILABLE=14]="UNAVAILABLE",ys[ys.DATA_LOSS=15]="DATA_LOSS";var _s=new hi(ui.F);function Ss(){return _s}function Ds(){return Ss()}var ks=new hi(ui.F);function xs(){return ks}var Rs=new hi(ui.F);function Ls(){return Rs}var Os=new vi(ui.F);function Vs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Os,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Ps=new vi(Eu);function Cs(){return Ps}function Us(t,e,n,r){this.ps=t,this.removedTargetIds=e,this.key=n,this.ys=r}function Ms(t,e){this.targetId=t,this.bs=e}function Fs(t,e,n,r){void 0===n&&(n=Ii.xt),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}var js=($s.hs=function(t){return new $s(t.F)},$s.prototype.has=function(t){return null!=this.rs.get(t)},$s.prototype.get=function(t){return this.rs.get(t)},$s.prototype.first=function(){return this.os.ht()},$s.prototype.last=function(){return this.os.at()},$s.prototype.U=function(){return this.os.U()},$s.prototype.indexOf=function(t){var e=this.rs.get(t);return e?this.os.indexOf(e):-1},Object.defineProperty($s.prototype,"size",{get:function(){return this.os.size},enumerable:!0,configurable:!0}),$s.prototype.forEach=function(n){this.os.ut(function(t,e){return n(t),!1})},$s.prototype.add=function(t){var e=this.delete(t.key);return e.rt(e.rs.it(t.key,t),e.os.it(t,null))},$s.prototype.delete=function(t){var e=this.get(t);return e?this.rt(this.rs.remove(t),this.os.remove(e)):this},$s.prototype.isEqual=function(t){if(!(t instanceof $s))return!1;if(this.size!==t.size)return!1;for(var e=this.os._t(),n=t.os._t();e.It();){var r=e.wt().key,i=n.wt().key;if(!r.isEqual(i))return!1}return!0},$s.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"},$s.prototype.rt=function(t,e){var n=new $s;return n.F=this.F,n.rs=t,n.os=e,n},$s),qs=(Zs.prototype.track=function(t){var e=t.doc.key,n=this.as.get(e);!n||0!==t.type&&3===n.type?this.as=this.as.it(e,t):3===t.type&&1!==n.type?this.as=this.as.it(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.as=this.as.it(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.as=this.as.it(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.as=this.as.remove(e):1===t.type&&2===n.type?this.as=this.as.it(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.as=this.as.it(e,{type:2,doc:t.doc}):mu("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n))},Zs.prototype.us=function(){var n=[];return this.as.ut(function(t,e){n.push(e)}),n},Zs),Gs=(Qs.fs=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:0,doc:t})}),new Qs(t,e,js.hs(e),i,n,r,!0,!1)},Object.defineProperty(Qs.prototype,"hasPendingWrites",{get:function(){return!this._s.U()},enumerable:!0,configurable:!0}),Qs.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.ls===t.ls&&this._s.isEqual(t._s)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.cs.isEqual(t.cs)))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},Qs),Bs=(Js.Is=function(t,e){var n=new Map;return n.set(t,zs.Rs(t,e)),new Js(zr.MIN,n,Cs(),Ss(),Vs())},Js),zs=(Xs.Rs=function(t,e){return new Xs(Ii.xt,e,Vs(),Vs(),Vs())},Xs),Ks=(Object.defineProperty(Ys.prototype,"As",{get:function(){return this.Cs},enumerable:!0,configurable:!0}),Object.defineProperty(Ys.prototype,"resumeToken",{get:function(){return this.Ds},enumerable:!0,configurable:!0}),Object.defineProperty(Ys.prototype,"Ns",{get:function(){return 0!==this.vs},enumerable:!0,configurable:!0}),Object.defineProperty(Ys.prototype,"Fs",{get:function(){return this.ks},enumerable:!0,configurable:!0}),Ys.prototype.$s=function(t){0<t.Ot()&&(this.ks=!0,this.Ds=t)},Ys.prototype.Ms=function(){var n=Vs(),r=Vs(),i=Vs();return this.Ss.forEach(function(t,e){switch(e){case 0:n=n.add(t);break;case 2:r=r.add(t);break;case 1:i=i.add(t);break;default:mu("Encountered invalid change type: "+e)}}),new zs(this.Ds,this.Cs,n,r,i)},Ys.prototype.Ls=function(){this.ks=!1,this.Ss=eu()},Ys.prototype.Os=function(t,e){this.ks=!0,this.Ss=this.Ss.it(t,e)},Ys.prototype.xs=function(t){this.ks=!0,this.Ss=this.Ss.remove(t)},Ys.prototype.Bs=function(){this.vs+=1},Ys.prototype.Us=function(){--this.vs},Ys.prototype.qs=function(){this.ks=!0,this.Cs=!0},Ys),Ws=(Hs.prototype.zs=function(t){for(var e=0,n=t.ps;e<n.length;e++){var r=n[e];t.ys instanceof Oo?this.Hs(r,t.ys):t.ys instanceof Vo&&this.Js(r,t.key,t.ys)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.Js(s,t.key,t.ys)}},Hs.prototype.Ys=function(n){var r=this;this.Xs(n,function(t){var e=r.Zs(t);switch(n.state){case 0:r.tn(t)&&e.$s(n.resumeToken);break;case 1:e.Us(),e.Ns||e.Ls(),e.$s(n.resumeToken);break;case 2:e.Us(),e.Ns||r.removeTarget(t);break;case 3:r.tn(t)&&(e.qs(),e.$s(n.resumeToken));break;case 4:r.tn(t)&&(r.en(t),e.$s(n.resumeToken));break;default:mu("Unknown target watch change state: "+n.state)}})},Hs.prototype.Xs=function(t,n){var r=this;0<t.targetIds.length?t.targetIds.forEach(n):this.Ws.forEach(function(t,e){r.tn(e)&&n(e)})},Hs.prototype.sn=function(t){var e=t.targetId,n=t.bs.count,r=this.nn(e);if(r){var i=r.target;if(i.Pe())if(0===n){var o=new ui(i.path);this.Js(e,o,new Vo(o,zr.S()))}else gu(1===n,"Single document existence filter with count: "+n);else this.in(e)!==n&&(this.en(e),this.Gs=this.Gs.add(e))}},Hs.prototype.rn=function(i){var o=this,s=new Map;this.Ws.forEach(function(t,e){var n=o.nn(e);if(n){if(t.As&&n.target.Pe()){var r=new ui(n.target.path);null!==o.js.get(r)||o.on(e,r)||o.Js(e,r,new Vo(r,i))}t.Fs&&(s.set(e,t.Ms()),t.Ls())}});var r=Vs();this.Ks.forEach(function(t,e){var n=!0;e.kt(function(t){var e=o.nn(t);return!e||2===e.Ze||(n=!1)}),n&&(r=r.add(t))});var t=new Bs(i,s,this.Gs,this.js,r);return this.js=Ss(),this.Ks=tu(),this.Gs=new vi(Eu),t},Hs.prototype.Hs=function(t,e){if(this.tn(t)){var n=this.on(t,e.key)?2:0;this.Zs(t).Os(e.key,n),this.js=this.js.it(e.key,e),this.Ks=this.Ks.it(e.key,this.hn(e.key).add(t))}},Hs.prototype.Js=function(t,e,n){if(this.tn(t)){var r=this.Zs(t);this.on(t,e)?r.Os(e,1):r.xs(e),this.Ks=this.Ks.it(e,this.hn(e).delete(t)),n&&(this.js=this.js.it(e,n))}},Hs.prototype.removeTarget=function(t){this.Ws.delete(t)},Hs.prototype.in=function(t){var e=this.Zs(t).Ms();return this.Qs.an(t).size+e.Ps.size-e.gs.size},Hs.prototype.Bs=function(t){this.Zs(t).Bs()},Hs.prototype.Zs=function(t){var e=this.Ws.get(t);return e||(e=new Ks,this.Ws.set(t,e)),e},Hs.prototype.hn=function(t){var e=this.Ks.get(t);return e||(e=new vi(Eu),this.Ks=this.Ks.it(t,e)),e},Hs.prototype.tn=function(t){var e=null!==this.nn(t);return e||du("WatchChangeAggregator","Detected inactive target",t),e},Hs.prototype.nn=function(t){var e=this.Ws.get(t);return e&&e.Ns?null:this.Qs.un(t)},Hs.prototype.en=function(e){var n=this;this.Ws.set(e,new Ks),this.Qs.an(e).forEach(function(t){n.Js(e,t,null)})},Hs.prototype.on=function(t,e){return this.Qs.an(t).has(e)},Hs);function Hs(t){this.Qs=t,this.Ws=new Map,this.js=Ss(),this.Ks=tu(),this.Gs=new vi(Eu)}function Ys(){this.vs=0,this.Ss=eu(),this.Ds=Ii.xt,this.Cs=!1,this.ks=!0}function Xs(t,e,n,r,i){this.resumeToken=t,this.As=e,this.Ps=n,this.Vs=r,this.gs=i}function Js(t,e,n,r,i){this.ts=t,this.Ts=e,this.ms=n,this.Es=r,this.ws=i}function Qs(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.cs=n,this.docChanges=r,this._s=i,this.fromCache=o,this.ls=s,this.ds=u}function Zs(){this.as=new hi(ui.F)}function $s(n){this.F=n?function(t,e){return n(t,e)||ui.F(t.key,e.key)}:function(t,e){return ui.F(t.key,e.key)},this.rs=xs(),this.os=new hi(this.F)}function tu(){return new hi(ui.F)}function eu(){return new hi(ui.F)}var nu,ru,iu=((ru={})[os.ASCENDING.name]="ASCENDING",ru[os.DESCENDING.name]="DESCENDING",ru),ou=((nu={})[Mo.LESS_THAN.name]="LESS_THAN",nu[Mo.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",nu[Mo.GREATER_THAN.name]="GREATER_THAN",nu[Mo.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",nu[Mo.EQUAL.name]="EQUAL",nu[Mo.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",nu[Mo.IN.name]="IN",nu[Mo.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",nu),su=(uu.prototype._n=function(t){var e=void 0===t.code?Ur.UNKNOWN:As(t.code);return new Mr(e,t.message||"")},uu.prototype.ln=function(t){return this.options.dn||Ai(t)?t:{value:t}},uu.prototype.fn=function(t){var e;return Ai(e="object"==typeof t?t.value:t)?null:e},uu.prototype.Wt=function(t){return{integerValue:""+t}},uu.prototype.jt=function(t){if(this.options.dn){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:_i(t)?"-0":t}},uu.prototype.Tn=function(t){return Si(t)?this.Wt(t):this.jt(t)},uu.prototype.k=function(t){return this.options.dn?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},uu.prototype.v=function(t){var e=Ui(t);return new Br(e.seconds,e.nanos)},uu.prototype.mn=function(t){return this.options.dn?t.toBase64():t.toUint8Array()},uu.prototype.En=function(t){return this.options.dn?(gu(void 0===t||"string"==typeof t,"value must be undefined or a string when using proto3 Json"),Ii.fromBase64String(t||"")):(gu(void 0===t||t instanceof Uint8Array,"value must be undefined or Uint8Array"),Ii.fromUint8Array(t||new Uint8Array))},uu.prototype.toVersion=function(t){return this.k(t.k())},uu.prototype.fromVersion=function(t){return gu(!!t,"Trying to deserialize version that isn't set"),zr.v(this.v(t))},uu.prototype.wn=function(t,e){return this.In(e||this.cn).child("documents").child(t).K()},uu.prototype.Rn=function(t){var e=ti.G(t);return gu(au(e),"Tried to deserialize invalid key "+e.toString()),e},uu.prototype.An=function(t){return this.wn(t.path)},uu.prototype.tt=function(t){var e=this.Rn(t);return gu(e.get(1)===this.cn.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.cn.projectId),gu(!e.get(3)&&!this.cn.database||e.get(3)===this.cn.database,"Tried to deserialize key from different database: "+e.get(3)+" vs "+this.cn.database),new ui(this.Pn(e))},uu.prototype.Vn=function(t){return this.wn(t)},uu.prototype.gn=function(t){var e=this.Rn(t);return 4===e.length?ti.H:this.Pn(e)},Object.defineProperty(uu.prototype,"pn",{get:function(){return new ti(["projects",this.cn.projectId,"databases",this.cn.database]).K()},enumerable:!0,configurable:!0}),uu.prototype.In=function(t){return new ti(["projects",t.projectId,"databases",t.database])},uu.prototype.Pn=function(t){return gu(4<t.length&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.M(5)},uu.prototype.yn=function(t,e){return{name:this.An(t),fields:e.proto.mapValue.fields}},uu.prototype.bn=function(t){return{name:this.An(t.key),fields:t.Ie().mapValue.fields,updateTime:this.k(t.version.k())}},uu.prototype.vn=function(t,e){var n=this.tt(t.name),r=this.fromVersion(t.updateTime),i=new bo({mapValue:{fields:t.fields}});return new Oo(n,r,i,{hasCommittedMutations:!!e})},uu.prototype.Sn=function(t){gu(!!t.found,"Tried to deserialize a found document from a missing document."),t.found.name,t.found.updateTime;var e=this.tt(t.found.name),n=this.fromVersion(t.found.updateTime),r=new bo({mapValue:{fields:t.found.fields}});return new Oo(e,n,r,{})},uu.prototype.Dn=function(t){gu(!!t.missing,"Tried to deserialize a missing document from a found document."),gu(!!t.readTime,"Tried to deserialize a missing document without a read time.");var e=this.tt(t.missing),n=this.fromVersion(t.readTime);return new Vo(e,n)},uu.prototype.Cn=function(t){return"found"in t?this.Sn(t):"missing"in t?this.Dn(t):mu("invalid batch get response: "+JSON.stringify(t))},uu.prototype.kn=function(t){var e;if("targetChange"in t){t.targetChange;var n=this.Nn(t.targetChange.targetChangeType||"NO_CHANGE"),r=t.targetChange.targetIds||[],i=this.En(t.targetChange.resumeToken),o=t.targetChange.cause,s=o&&this._n(o);e=new Fs(n,r,i,s||null)}else if("documentChange"in t){t.documentChange;var u=t.documentChange;u.document,u.document.name,u.document.updateTime;var a=this.tt(u.document.name),h=this.fromVersion(u.document.updateTime),c=new bo({mapValue:{fields:u.document.fields}}),f=new Oo(a,h,c,{}),l=u.targetIds||[],p=u.removedTargetIds||[];e=new Us(l,p,f.key,f)}else if("documentDelete"in t){t.documentDelete;var d=t.documentDelete;d.document;var y=this.tt(d.document),v=d.readTime?this.fromVersion(d.readTime):zr.S(),m=new Vo(y,v),g=d.removedTargetIds||[];e=new Us([],g,m.key,m)}else if("documentRemove"in t){t.documentRemove;var w=t.documentRemove;w.document;var b=this.tt(w.document),E=w.removedTargetIds||[];e=new Us([],E,b,null)}else{if(!("filter"in t))return mu("Unknown change type "+JSON.stringify(t));t.filter;var T=t.filter;T.targetId;var I=T.count||0,N=new ps(I),A=T.targetId;e=new Ms(A,N)}return e},uu.prototype.Nn=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:mu("Got unexpected TargetChange.state: "+t)},uu.prototype.Fn=function(t){if(!("targetChange"in t))return zr.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length||!e.readTime?zr.MIN:this.fromVersion(e.readTime)},uu.prototype.$n=function(t){var e,n=this;if(t instanceof yo)e={update:this.yn(t.key,t.value)};else if(t instanceof go)e={delete:this.An(t.key)};else if(t instanceof vo)e={update:this.yn(t.key,t.data),updateMask:this.Mn(t.se)};else if(t instanceof mo)e={transform:{document:this.An(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.Ln(t)})}};else{if(!(t instanceof wo))return mu("Unknown mutation type "+t.type);e={verify:this.An(t.key)}}return t.Zt.Ht||(e.currentDocument=this.On(t.Zt)),e},uu.prototype.xn=function(t){var e=this,n=t.currentDocument?this.Bn(t.currentDocument):io.NONE;if(t.update){t.update.name;var r=this.tt(t.update.name),i=new bo({mapValue:{fields:t.update.fields}});if(t.updateMask){var o=this.Un(t.updateMask);return new vo(r,i,o,n)}return new yo(r,i,n)}if(t.delete){var s=this.tt(t.delete);return new go(s,n)}if(t.transform){var u=this.tt(t.transform.document),a=t.transform.fieldTransforms.map(function(t){return e.qn(t)});return gu(!0===n.exists,'Transforms only support precondition "exists == true"'),new mo(u,a)}if(t.verify){var h=this.tt(t.verify);return new wo(h,n)}return mu("unknown mutation proto: "+JSON.stringify(t))},uu.prototype.On=function(t){return void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:mu("Unknown precondition")},uu.prototype.Bn=function(t){return void 0!==t.updateTime?io.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?io.exists(t.exists):io.NONE},uu.prototype.Qn=function(t,e){var n=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);n.isEqual(zr.MIN)&&(n=this.fromVersion(e));var r=null;return t.transformResults&&0<t.transformResults.length&&(r=t.transformResults),new eo(n,r)},uu.prototype.Wn=function(t,e){var n=this;return t&&0<t.length?(gu(void 0!==e,"Received a write result without a commit time"),t.map(function(t){return n.Qn(t,e)})):[]},uu.prototype.Ln=function(t){var e=t.transform;if(e instanceof Wi)return{fieldPath:t.field.K(),setToServerValue:"REQUEST_TIME"};if(e instanceof Yi)return{fieldPath:t.field.K(),appendMissingElements:{values:e.elements}};if(e instanceof Xi)return{fieldPath:t.field.K(),removeAllFromArray:{values:e.elements}};if(e instanceof Ji)return{fieldPath:t.field.K(),increment:e.Qt};throw mu("Unknown transform: "+t.transform)},uu.prototype.qn=function(t){var e=null;if("setToServerValue"in t)gu("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),e=Wi.instance;else if("appendMissingElements"in t){var n=t.appendMissingElements.values||[];e=new Yi(n)}else if("removeAllFromArray"in t){var r=t.removeAllFromArray.values||[];e=new Xi(r)}else"increment"in t?e=new Ji(this,t.increment):mu("Unknown transform proto: "+JSON.stringify(t));var i=oi.Z(t.fieldPath);return new ro(i,e)},uu.prototype.jn=function(t){return{documents:[this.Vn(t.path)]}},uu.prototype.Kn=function(t){var e=t.documents.length;gu(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return Uo.ve(this.gn(n)).xe()},uu.prototype.Gn=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(e.parent=this.Vn(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(e.parent=this.Vn(n.L()),e.structuredQuery.from=[{collectionId:n.B()}]);var r=this.zn(t.filters);r&&(e.structuredQuery.where=r);var i=this.Hn(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.ln(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.Jn(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.Jn(t.endAt)),e},uu.prototype.Yn=function(t){var e=this.gn(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(0<r){gu(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.Xn(n.where));var u=[];n.orderBy&&(u=this.Zn(n.orderBy));var a=null;n.limit&&(a=this.fn(n.limit));var h=null;n.startAt&&(h=this.ti(n.startAt));var c=null;return n.endAt&&(c=this.ti(n.endAt)),new Uo(e,i,u,s,a,"F",h,c).xe()},uu.prototype.ei=function(t){var e=this.si(t.Ze);return null==e?null:{"goog-listen-tags":e}},uu.prototype.si=function(t){switch(t){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return mu("Unrecognized query purpose: "+t)}},uu.prototype.xe=function(t){var e,n=t.target;return(e=n.Pe()?{documents:this.jn(n)}:{query:this.Gn(n)}).targetId=t.targetId,0<t.resumeToken.Ot()&&(e.resumeToken=this.mn(t.resumeToken)),e},uu.prototype.zn=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof $o?e.ni(t):mu("Unrecognized filter: "+JSON.stringify(t))});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},uu.prototype.Xn=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.ii(t)]:void 0!==t.fieldFilter?[this.ri(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return e.Xn(t)}).reduce(function(t,e){return t.concat(e)}):mu("Unknown filter: "+JSON.stringify(t)):[]},uu.prototype.Hn=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.oi(t)})},uu.prototype.Zn=function(t){var e=this;return t.map(function(t){return e.hi(t)})},uu.prototype.Jn=function(t){return{before:t.before,values:t.position}},uu.prototype.ti=function(t){var e=!!t.before,n=t.values||[];return new vs(n,e)},uu.prototype.ai=function(t){return iu[t.name]},uu.prototype.ui=function(t){switch(t){case"ASCENDING":return os.ASCENDING;case"DESCENDING":return os.DESCENDING;default:return}},uu.prototype.ci=function(t){return ou[t.name]},uu.prototype._i=function(t){switch(t){case"EQUAL":return Mo.EQUAL;case"GREATER_THAN":return Mo.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return Mo.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return Mo.LESS_THAN;case"LESS_THAN_OR_EQUAL":return Mo.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return Mo.ARRAY_CONTAINS;case"IN":return Mo.IN;case"ARRAY_CONTAINS_ANY":return Mo.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return mu("Unspecified operator");default:return mu("Unknown operator")}},uu.prototype.li=function(t){return{fieldPath:t.K()}},uu.prototype.di=function(t){return oi.Z(t.fieldPath)},uu.prototype.oi=function(t){return{field:this.li(t.field),direction:this.ai(t.dir)}},uu.prototype.hi=function(t){return new ms(this.di(t.field),this.ui(t.direction))},uu.prototype.ri=function(t){return $o.create(this.di(t.fieldFilter.field),this._i(t.fieldFilter.op),t.fieldFilter.value)},uu.prototype.ni=function(t){if(t.op===Mo.EQUAL){if(zi(t.value))return{unaryFilter:{field:this.li(t.field),op:"IS_NAN"}};if(Bi(t.value))return{unaryFilter:{field:this.li(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.li(t.field),op:this.ci(t.op),value:t.value}}},uu.prototype.ii=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.di(t.unaryFilter.field);return $o.create(e,Mo.EQUAL,{doubleValue:NaN});case"IS_NULL":var n=this.di(t.unaryFilter.field);return $o.create(n,Mo.EQUAL,{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return mu("Unspecified filter");default:return mu("Unknown filter")}},uu.prototype.Mn=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.K())}),{fieldPaths:e}},uu.prototype.Un=function(t){var e=(t.fieldPaths||[]).map(function(t){return oi.Z(t)});return no.Gt(e)},uu);function uu(t,e){this.cn=t,this.options=e}function au(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)}var hu=(fu.fi=function(t){fu.platform&&mu("Platform already defined"),fu.platform=t},fu.Lt=function(){return fu.platform||mu("Platform not set"),fu.platform},fu),cu=new h("@firebase/firestore");function fu(){}function lu(){return cu.logLevel}function pu(t){cu.logLevel=t}function du(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(cu.logLevel<=l.DEBUG){var r=e.map(vu);cu.debug.apply(cu,i(["Firestore ("+Lr+"): "+t],r))}}function yu(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(cu.logLevel<=l.ERROR){var r=e.map(vu);cu.error.apply(cu,i(["Firestore ("+Lr+"): "+t],r))}}function vu(t){if("string"==typeof t)return t;var e=hu.Lt();try{return e.Ti(t)}catch(e){return t}}function mu(t){var e="FIRESTORE ("+Lr+") INTERNAL ASSERTION FAILED: "+t;throw yu(e),new Error(e)}function gu(t,e){t||mu(e)}var wu=(bu.mi=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},bu);function bu(){}function Eu(t,e){return t<e?-1:e<t?1:0}function Tu(t,n,r){return t.length===n.length&&t.every(function(t,e){return r(t,n[e])})}function Iu(t){return t+"\0"}function Nu(t,e,n,r,i){this.cn=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i}var Au=(Object.defineProperty(Xu.prototype,"Ei",{get:function(){return"(default)"===this.database},enumerable:!0,configurable:!0}),Xu.prototype.isEqual=function(t){return t instanceof Xu&&t.projectId===this.projectId&&t.database===this.database},Xu.prototype.D=function(t){return Eu(this.projectId,t.projectId)||Eu(this.database,t.database)},Xu),_u=(Yu.prototype.get=function(t){var e=this.wi(t),n=this.Ii[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],u=o[1];if(s.isEqual(t))return u}},Yu.prototype.has=function(t){return void 0!==this.get(t)},Yu.prototype.set=function(t,e){var n=this.wi(t),r=this.Ii[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.Ii[n]=[[t,e]]},Yu.prototype.delete=function(t){var e=this.wi(t),n=this.Ii[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.Ii[e]:n.splice(r,1),!0;return!1},Yu.prototype.forEach=function(u){Ei(this.Ii,function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],s=i[1];u(o,s)}})},Yu.prototype.U=function(){return Ti(this.Ii)},Yu),Su=(Hu.prototype.Ut=function(t,e,n){for(var r=n.Ai,i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var s=r[i];e=o.Ut(e,s)}}return e},Hu.prototype.Bt=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=i.Bt(e,e,this.Ri))}for(var o=e,s=0,u=this.mutations;s<u.length;s++){var a=u[s];a.key.isEqual(t)&&(e=a.Bt(e,o,this.Ri))}return e},Hu.prototype.Pi=function(n){var r=this,i=n;return this.mutations.forEach(function(t){var e=r.Bt(t.key,n.get(t.key));e&&(i=i.it(t.key,e))}),i},Hu.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},Vs())},Hu.prototype.isEqual=function(t){return this.batchId===t.batchId&&Tu(this.mutations,t.mutations,function(t,e){return t.isEqual(e)})&&Tu(this.baseMutations,t.baseMutations,function(t,e){return t.isEqual(e)})},Hu),Du=(Wu.from=function(t,e,n,r){gu(t.mutations.length===n.length,"Mutations sent "+t.mutations.length+" must equal results received "+n.length);for(var i=Ls(),o=t.mutations,s=0;s<o.length;s++)i=i.it(o[s].key,n[s].version);return new Wu(t,e,n,r,i)},Wu),ku=(Ku.prototype.U=function(){return this.pi.U()},Ku.prototype.vi=function(t,e){var n=new xu(t,e);this.pi=this.pi.add(n),this.yi=this.yi.add(n)},Ku.prototype.Si=function(t,e){var n=this;t.forEach(function(t){return n.vi(t,e)})},Ku.prototype.Di=function(t,e){this.Ci(new xu(t,e))},Ku.prototype.ki=function(t,e){var n=this;t.forEach(function(t){return n.Di(t,e)})},Ku.prototype.Ni=function(t){var e=this,n=ui.EMPTY,r=new xu(n,t),i=new xu(n,t+1),o=[];return this.yi.Ct([r,i],function(t){e.Ci(t),o.push(t.key)}),o},Ku.prototype.Fi=function(){var e=this;this.pi.forEach(function(t){return e.Ci(t)})},Ku.prototype.Ci=function(t){this.pi=this.pi.delete(t),this.yi=this.yi.delete(t)},Ku.prototype.$i=function(t){var e=ui.EMPTY,n=new xu(e,t),r=new xu(e,t+1),i=Vs();return this.yi.Ct([n,r],function(t){i=i.add(t.key)}),i},Ku.prototype.Mi=function(t){var e=new xu(t,0),n=this.pi.Nt(e);return null!==n&&t.isEqual(n.key)},Ku),xu=(zu.Ee=function(t,e){return ui.F(t.key,e.key)||Eu(t.Li,e.Li)},zu.bi=function(t,e){return Eu(t.Li,e.Li)||ui.F(t.key,e.key)},zu),Ru=(Bu.prototype.catch=function(t){return this.next(void 0,t)},Bu.prototype.next=function(r,i){var o=this;return this.Ui&&mu("Called next() or catch() twice for PersistencePromise"),this.Ui=!0,this.Bi?this.error?this.qi(i,this.error):this.Qi(r,this.result):new Bu(function(e,n){o.Oi=function(t){o.Qi(r,t).next(e,n)},o.xi=function(t){o.qi(i,t).next(e,n)}})},Bu.prototype.Wi=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},Bu.prototype.ji=function(t){try{var e=t();return e instanceof Bu?e:Bu.resolve(e)}catch(t){return Bu.reject(t)}},Bu.prototype.Qi=function(t,e){return t?this.ji(function(){return t(e)}):Bu.resolve(e)},Bu.prototype.qi=function(t,e){return t?this.ji(function(){return t(e)}):Bu.reject(e)},Bu.resolve=function(n){return new Bu(function(t,e){t(n)})},Bu.reject=function(n){return new Bu(function(t,e){e(n)})},Bu.Ki=function(t){return new Bu(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()})},Bu.Gi=function(t){for(var n=Bu.resolve(!1),e=function(e){n=n.next(function(t){return t?Bu.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},Bu.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.Ki(i)},Bu),Lu=(Object.defineProperty(Gu.prototype,"readTime",{get:function(){return this.Ji},set:function(t){this.Ji=t},enumerable:!0,configurable:!0}),Gu.prototype.Yi=function(t,e){this.Xi(),this.readTime=e,this.zi.set(t.key,t)},Gu.prototype.Zi=function(t,e){this.Xi(),e&&(this.readTime=e),this.zi.set(t,null)},Gu.prototype.tr=function(t,e){this.Xi();var n=this.zi.get(e);return void 0!==n?Ru.resolve(n):this.er(t,e)},Gu.prototype.getEntries=function(t,e){return this.sr(t,e)},Gu.prototype.apply=function(t){return this.Xi(),this.Hi=!0,this.nr(t)},Gu.prototype.Xi=function(){},Gu),Ou="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Vu=(qu.prototype.rr=function(t){this.ir.push(t)},qu.prototype.or=function(){this.ir.forEach(function(t){return t()})},qu),Pu=(ju.prototype.cr=function(e,n){var r=this;return this.ar._r(e,n).next(function(t){return r.lr(e,n,t)})},ju.prototype.lr=function(t,r,i){return this.hr.tr(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].Bt(r,t);return t})},ju.prototype.dr=function(t,e,i){var o=Ds();return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].Bt(t,e);o=o.it(t,e)}),o},ju.prototype.Tr=function(e,t){var n=this;return this.hr.getEntries(e,t).next(function(t){return n.mr(e,t)})},ju.prototype.mr=function(r,i){var o=this;return this.ar.Er(r,i).next(function(t){var e=o.dr(r,i,t),n=Ss();return e.forEach(function(t,e){e=e||new Vo(t,zr.S()),n=n.it(t,e)}),n})},ju.prototype.wr=function(t,e,n){return e.Pe()?this.Ir(t,e.path):e.He()?this.Rr(t,e,n):this.Ar(t,e,n)},ju.prototype.Ir=function(t,e){return this.cr(t,new ui(e)).next(function(t){var e=xs();return t instanceof Oo&&(e=e.it(t.key,t)),e})},ju.prototype.Rr=function(n,r,i){var o=this,s=r.collectionGroup,u=xs();return this.ur.Pr(n,s).next(function(t){return Ru.forEach(t,function(t){var e=r.Le(t.child(s));return o.Ar(n,e,i).next(function(t){t.forEach(function(t,e){u=u.it(t,e)})})}).next(function(){return u})})},ju.prototype.Ar=function(e,n,t){var c,f,r=this;return this.hr.wr(e,n,t).next(function(t){return c=t,r.ar.Vr(e,n)}).next(function(t){return f=t,r.gr(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],u=s.key,a=c.get(u),h=s.Bt(a,a,r.Ri);c=h instanceof Oo?c.it(u,h):c.remove(u)}})}).next(function(){return c.forEach(function(t,e){n.matches(e)||(c=c.remove(t))}),c})},ju.prototype.gr=function(t,e,n){for(var r=Vs(),i=0,o=e;i<o.length;i++)for(var s=0,u=o[i].mutations;s<u.length;s++){var a=u[s];a instanceof vo&&null===n.get(a.key)&&(r=r.add(a.key))}var h=n;return this.hr.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof Oo&&(h=h.it(t,e))}),h})},ju),Cu=(Fu.br=function(t,e){for(var n=Vs(),r=Vs(),i=0,o=e.docChanges;i<o.length;i++){var s=o[i];switch(s.type){case 0:n=n.add(s.doc.key);break;case 1:r=r.add(s.doc.key)}}return new Fu(t,e.fromCache,n,r)},Fu),Uu=(Mu.prototype.Sr=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},Mu.prototype.next=function(){var t=++this.previousValue;return this.Dr&&this.Dr(t),t},Mu);function Mu(t,e){var n=this;this.previousValue=t,e&&(e.vr=function(t){return n.Sr(t)},this.Dr=function(t){return e.Cr(t)})}function Fu(t,e,n,r){this.targetId=t,this.fromCache=e,this.pr=n,this.yr=r}function ju(t,e,n){this.hr=t,this.ar=e,this.ur=n}function qu(){this.ir=[]}function Gu(){this.zi=new _u(function(t){return t.toString()}),this.Hi=!1}function Bu(t){var e=this;this.Oi=null,this.xi=null,this.result=void 0,this.error=void 0,this.Bi=!1,this.Ui=!1,t(function(t){e.Bi=!0,e.result=t,e.Oi&&e.Oi(t)},function(t){e.Bi=!0,e.error=t,e.xi&&e.xi(t)})}function zu(t,e){this.key=t,this.Li=e}function Ku(){this.pi=new vi(xu.Ee),this.yi=new vi(xu.bi)}function Wu(t,e,n,r,i){this.batch=t,this.Vi=e,this.Ai=n,this.streamToken=r,this.gi=i}function Hu(t,e,n,r){this.batchId=t,this.Ri=e,this.baseMutations=n,this.mutations=r}function Yu(t){this.wi=t,this.Ii={}}function Xu(t,e){this.projectId=t,this.database=e||"(default)"}Uu.kr=-1;function Ju(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}var Qu=(ta.Or=function(t,e,n,r,i){var o=new ta(t,e,Date.now()+n,r,i);return o.start(n),o},ta.prototype.start=function(t){var e=this;this.xr=setTimeout(function(){return e.Br()},t)},ta.prototype.Ur=function(){return this.Br()},ta.prototype.cancel=function(t){null!==this.xr&&(this.clearTimeout(),this.Lr.reject(new Mr(Ur.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},ta.prototype.Br=function(){var e=this;this.Nr.qr(function(){return null!==e.xr?(e.clearTimeout(),e.op().then(function(t){return e.Lr.resolve(t)})):Promise.resolve()})},ta.prototype.clearTimeout=function(){null!==this.xr&&(this.Mr(this),clearTimeout(this.xr),this.xr=null)},ta),Zu=(Object.defineProperty($u.prototype,"Hr",{get:function(){return this.Wr},enumerable:!0,configurable:!0}),$u.prototype.qr=function(t){this.enqueue(t)},$u.prototype.Jr=function(t){this.Yr(),this.Xr(t)},$u.prototype.Zr=function(t){return this.Yr(),this.Xr(t)},$u.prototype.to=function(e){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Yr(),this.Wr?[3,2]:(this.Wr=!0,[4,this.Zr(e)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},$u.prototype.enqueue=function(t){return this.Yr(),this.Wr?new Promise(function(t){}):this.Xr(t)},$u.prototype.Xr=function(t){var e=this,n=this.Qr.then(function(){return e.Gr=!0,t().catch(function(t){throw e.Kr=t,e.Gr=!1,yu("INTERNAL UNHANDLED ERROR: ",t.stack||t.message||""),t}).then(function(t){return e.Gr=!1,t})});return this.Qr=n},$u.prototype.eo=function(t,e,n){var r=this;this.Yr(),-1<this.zr.indexOf(t)&&(e=0);var i=Qu.Or(this,t,e,n,function(t){return r.so(t)});return this.jr.push(i),i},$u.prototype.Yr=function(){this.Kr&&mu("AsyncQueue is already failed: "+(this.Kr.stack||this.Kr.message))},$u.prototype.no=function(){},$u.prototype.io=function(){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return[4,e=this.Qr];case 1:t.sent(),t.label=2;case 2:if(e!==this.Qr)return[3,0];t.label=3;case 3:return[2]}})})},$u.prototype.ro=function(t){for(var e=0,n=this.jr;e<n.length;e++)if(n[e].Fr===t)return!0;return!1},$u.prototype.oo=function(r){var i=this;return this.io().then(function(){i.jr.sort(function(t,e){return t.$r-e.$r});for(var t=0,e=i.jr;t<e.length;t++){var n=e[t];if(n.Ur(),"all"!==r&&n.Fr===r)break}return i.io()})},$u.prototype.ho=function(t){this.zr.push(t)},$u.prototype.so=function(t){var e=this.jr.indexOf(t);this.jr.splice(e,1)},$u);function $u(){this.Qr=Promise.resolve(),this.Wr=!1,this.jr=[],this.Kr=null,this.Gr=!1,this.zr=[]}function ta(t,e,n,r,i){this.Nr=t,this.Fr=e,this.$r=n,this.op=r,this.Mr=i,this.Lr=new Ju,this.then=this.Lr.promise.then.bind(this.Lr.promise),this.catch=this.Lr.promise.catch.bind(this.Lr.promise),this.Lr.promise.catch(function(t){})}function ea(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=Eu(n,i);return 0===s?Eu(r,o):s}var na=(sa.prototype.co=function(){return++this.uo},sa.prototype._o=function(t){var e=[t,this.co()];if(this.buffer.size<this.ao)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();ea(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(sa.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),sa),ra={lo:!1,do:0,fo:0,To:0},ia=(oa.Io=function(t){return new oa(t,oa.Ro,oa.Ao)},oa);function oa(t,e,n){this.mo=t,this.Eo=e,this.wo=n}function sa(t){this.ao=t,this.buffer=new vi(ea),this.uo=0}ia.Po=-1,ia.Vo=1048576,ia.po=41943040,ia.Ro=10,ia.Ao=1e3,ia.yo=new ia(ia.po,ia.Ro,ia.Ao),ia.DISABLED=new ia(ia.Po,0,0);var ua=(la.prototype.start=function(t){this.bo.Do.mo!==ia.Po&&this.Co(t)},la.prototype.stop=function(){this.So&&(this.So.cancel(),this.So=null)},Object.defineProperty(la.prototype,"ko",{get:function(){return null!==this.So},enumerable:!0,configurable:!0}),la.prototype.Co=function(t){var e=this,n=this.vo?3e5:6e4;du("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.So=this.Nr.eo("lru_garbage_collection",n,function(){return e.So=null,e.vo=!0,t.No(e.bo).then(function(){return e.Co(t)}).catch(pa)})},la),aa=(fa.prototype.$o=function(t,e){return this.Fo.Mo(t).next(function(t){return Math.floor(e/100*t)})},fa.prototype.Lo=function(t,e){var n=this;if(0===e)return Ru.resolve(Uu.kr);var r=new na(e);return this.Fo.Xs(t,function(t){return r._o(t.sequenceNumber)}).next(function(){return n.Fo.Oo(t,function(t){return r._o(t)})}).next(function(){return r.maxValue})},fa.prototype.xo=function(t,e,n){return this.Fo.xo(t,e,n)},fa.prototype.Bo=function(t,e){return this.Fo.Bo(t,e)},fa.prototype.Uo=function(e,n){var r=this;return this.Do.mo===ia.Po?(du("LruGarbageCollector","Garbage collection skipped; disabled"),Ru.resolve(ra)):this.qo(e).next(function(t){return t<r.Do.mo?(du("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.Do.mo),ra):r.Qo(e,n)})},fa.prototype.qo=function(t){return this.Fo.qo(t)},fa.prototype.Qo=function(e,n){var r,i,o,s,u,a,h,c=this,f=Date.now();return this.$o(e,this.Do.Eo).next(function(t){return i=t>c.Do.wo?(du("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+c.Do.wo+" from "+t),c.Do.wo):t,s=Date.now(),c.Lo(e,i)}).next(function(t){return r=t,u=Date.now(),c.xo(e,r,n)}).next(function(t){return o=t,a=Date.now(),c.Bo(e,r)}).next(function(t){return h=Date.now(),lu()<=l.DEBUG&&du("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-f)+"ms\n\tDetermined least recently used "+i+" in "+(u-s)+"ms\n\tRemoved "+o+" targets in "+(a-u)+"ms\n\tRemoved "+t+" documents in "+(h-a)+"ms\nTotal Duration: "+(h-f)+"ms"),Ru.resolve({lo:!0,do:i,fo:o,To:t})})},fa),ha=(ca.prototype.start=function(){return this.rh()},ca.prototype.oh=function(i){return f(this,void 0,void 0,function(){var e,g,n,r=this;return y(this,function(t){switch(t.label){case 0:return e=this.ar,g=this.sh,[4,this.persistence.runTransaction("Handle user change","readonly",function(v){var m;return r.ar.hh(v).next(function(t){return m=t,e=r.persistence.Yo(i),g=new Pu(r.Xo,e,r.persistence.nh()),e.hh(v)}).next(function(t){for(var e=[],n=[],r=Vs(),i=0,o=m;i<o.length;i++){var s=o[i];e.push(s.batchId);for(var u=0,a=s.mutations;u<a.length;u++){var h=a[u];r=r.add(h.key)}}for(var c=0,f=t;c<f.length;c++){var l=f[c];n.push(l.batchId);for(var p=0,d=l.mutations;p<d.length;p++){var y=d[p];r=r.add(y.key)}}return g.Tr(v,r).next(function(t){return{ah:t,uh:e,_h:n}})})})];case 1:return n=t.sent(),[2,(this.ar=e,this.sh=g,this.Wo.ih(this.sh),n)]}})})},ca.prototype.lh=function(u){var a,h=this,c=Br.now(),t=u.reduce(function(t,e){return t.add(e.key)},Vs());return this.persistence.runTransaction("Locally write mutations","readwrite",function(s){return h.sh.Tr(s,t).next(function(t){a=t;for(var e=[],n=0,r=u;n<r.length;n++){var i=r[n],o=i.ee(a.get(i.key));null!=o&&e.push(new vo(i.key,o,o.se(),io.exists(!0)))}return h.ar.dh(s,c,e,u)})}).then(function(t){var e=t.Pi(a);return{batchId:t.batchId,zi:e}})},ca.prototype.fh=function(t){var n=this;return this.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return n.ar.Th(e,t).next(function(t){return t?n.sh.Tr(e,t):Ru.resolve(null)})})},ca.prototype.mh=function(r){var i=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var e=r.batch.keys(),n=i.Xo.Eh({wh:!0});return i.ar.mh(t,r.batch,r.streamToken).next(function(){return i.Ih(t,r,n)}).next(function(){return n.apply(t)}).next(function(){return i.ar.Rh(t)}).next(function(){return i.sh.Tr(t,e)})})},ca.prototype.Ah=function(t){var r=this;return this.persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return r.ar.Ph(e,t).next(function(t){return gu(null!==t,"Attempt to reject nonexistent batch!"),n=t.keys(),r.ar.Vh(e,t)}).next(function(){return r.ar.Rh(e)}).next(function(){return r.sh.Tr(e,n)})})},ca.prototype.gh=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e.ar.gh(t)})},ca.prototype.ph=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly",function(t){return e.ar.ph(t)})},ca.prototype.yh=function(e){var n=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary",function(t){return n.ar.yh(t,e)})},ca.prototype.bh=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.th.bh(t)})},ca.prototype.vh=function(a){var h=this,c=a.ts,f=this.Ko;return this.persistence.runTransaction("Apply remote event","readwrite-primary",function(o){var i=h.Xo.Eh({wh:!0});f=h.Ko;var s=[];a.Ts.forEach(function(t,e){var n=f.get(e);if(n){s.push(h.th.Sh(o,t.gs,e).next(function(){return h.th.Dh(o,t.Ps,e)}));var r=t.resumeToken;if(0<r.Ot()){var i=n.ss(r,c).es(o.Ch);f=f.it(e,i),ca.kh(n,i,t)&&s.push(h.th.Nh(o,i))}}});var u=Ss(),n=Vs();if(a.Es.forEach(function(t,e){n=n.add(t)}),s.push(i.getEntries(o,n).next(function(r){a.Es.forEach(function(t,e){var n=r.get(t);e instanceof Vo&&e.version.isEqual(zr.MIN)?(i.Zi(t,c),u=u.it(t,e)):null==n||0<e.version.D(n.version)||0===e.version.D(n.version)&&n.hasPendingWrites?(i.Yi(e,c),u=u.it(t,e)):du("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),a.ws.has(t)&&s.push(h.persistence.Jo.Fh(o,t))})})),!c.isEqual(zr.MIN)){var t=h.th.bh(o).next(function(t){return h.th.$h(o,o.Ch,c)});s.push(t)}return Ru.Ki(s).next(function(){return i.apply(o)}).next(function(){return h.sh.mr(o,u)})}).then(function(t){return h.Ko=f,t})},ca.kh=function(t,e,n){return gu(0<e.resumeToken.Ot(),"Attempted to persist target data with no resume token"),0===t.resumeToken.Ot()||e.ts.C()-t.ts.C()>=this.Mh||0<n.Ps.size+n.Vs.size+n.gs.size},ca.prototype.Lh=function(t){for(var n=this,e=0,r=t;e<r.length;e++){var i=r[e],o=i.targetId;if(this.jo.Si(i.pr,o),this.jo.ki(i.yr,o),!i.fromCache){var s=this.Ko.get(o),u=s.ts,a=s.ns(u);this.Ko=this.Ko.it(o,a)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(e){return Ru.forEach(t,function(t){return Ru.forEach(t.yr,function(t){return n.persistence.Jo.Di(e,t)})})})},ca.prototype.Oh=function(e){var n=this;return this.persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===e&&(e=-1),n.ar.xh(t,e)})},ca.prototype.Bh=function(e){var n=this;return this.persistence.runTransaction("read document","readonly",function(t){return n.sh.cr(t,e)})},ca.prototype.Uh=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite",function(e){var n;return i.th.qh(e,r).next(function(t){return t?(n=t,Ru.resolve(n)):i.th.Qh(e).next(function(t){return n=new bs(r,t,0,e.Ch),i.th.Wh(e,n).next(function(){return n})})})}).then(function(t){return null===i.Ko.get(t.targetId)&&(i.Ko=i.Ko.it(t.targetId,t),i.Go.set(r,t.targetId)),t})},ca.prototype.qh=function(t,e){var n=this.Go.get(e);return void 0!==n?Ru.resolve(this.Ko.get(n)):this.th.qh(t,e)},ca.prototype.jh=function(n,r){var i=this,o=this.Ko.get(n),t=r?"readwrite":"readwrite-primary";return this.persistence.runTransaction("Release target",t,function(e){var t=i.jo.Ni(n);return r?Ru.resolve():Ru.forEach(t,function(t){return i.persistence.Jo.Di(e,t)}).next(function(){i.persistence.Jo.removeTarget(e,o)})}).then(function(){i.Ko=i.Ko.remove(n),i.Go.delete(o.target)})},ca.prototype.Kh=function(t,n){var r=this,i=zr.MIN,o=Vs();return this.persistence.runTransaction("Execute query","readonly",function(e){return r.qh(e,t.xe()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.th.Gh(e,t.targetId).next(function(t){o=t})}).next(function(){return r.Wo.wr(e,t,n?i:zr.MIN,n?o:Vs())}).next(function(t){return{documents:t,zh:o}})})},ca.prototype.Hh=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly",function(t){return n.th.Gh(t,e)})},ca.prototype.Jh=function(){return this.persistence.Jh()},ca.prototype.Yh=function(t){this.ar.Xh(t)},ca.prototype.Zh=function(t){this.persistence.Zh(t)},ca.prototype.Ih=function(t,i,o){var e=this,s=i.batch,n=s.keys(),u=Ru.resolve();return n.forEach(function(r){u=u.next(function(){return o.tr(t,r)}).next(function(t){var e=t,n=i.gi.get(r);gu(null!==n,"ackVersions should contain every doc in the write."),(!e||e.version.D(n)<0)&&(e=s.Ut(r,e,i))&&o.Yi(e,i.Vi)})}),u.next(function(){return e.ar.Vh(t,s)})},ca.prototype.No=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(t){return e.Uo(t,n.Ko)})},ca.prototype.ta=function(e){var n=this,t=this.Ko.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly",function(t){return n.th.un(t,e).next(function(t){return t?t.target:null})})},ca.prototype.ea=function(){var r=this;return this.persistence.runTransaction("Get new document changes","readonly",function(t){return r.Xo.ea(t,r.zo)}).then(function(t){var e=t.sa,n=t.readTime;return r.zo=n,e})},ca.prototype.rh=function(){return f(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",function(t){return n.Xo.na(t)})];case 1:return e.zo=t.sent(),[2]}})})},ca);function ca(t,e,n){this.persistence=t,this.Wo=e,this.jo=new ku,this.Ko=new hi(Eu),this.Go=new _u(function(t){return t.canonicalId()}),this.zo=zr.MIN,this.persistence.Jo.Ho(this.jo),this.ar=t.Yo(n),this.Xo=t.Zo(),this.th=t.eh(),this.sh=new Pu(this.Xo,this.ar,this.persistence.nh()),this.Wo.ih(this.sh)}function fa(t,e){this.Fo=t,this.Do=e}function la(t,e){this.bo=t,this.Nr=e,this.vo=!1,this.So=null}function pa(e){return f(this,void 0,void 0,function(){return y(this,function(t){if(e.code!==Ur.FAILED_PRECONDITION||e.message!==Ou)throw e;return du("LocalStore","Unexpectedly lost primary lease"),[2]})})}function da(t,e){if(0!==e.length)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Ra(e.length,"argument")+".")}function ya(t,e,n){if(e.length!==n)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires "+Ra(n,"argument")+", but was called with "+Ra(e.length,"argument")+".")}function va(t,e,n){if(e.length<n)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Ra(n,"argument")+", but was called with "+Ra(e.length,"argument")+".")}function ma(t,e,n,r){if(e.length<n||e.length>r)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Ra(e.length,"argument")+".")}function ga(t,e,n,r){Ia(t,e,xa(n)+" argument",r)}function wa(t,e,n,r){void 0!==r&&ga(t,e,n,r)}function ba(t,e,n,r){Ia(t,e,n+" option",r)}function Ea(t,e,n,r){void 0!==r&&ba(t,e,n,r)}function Ta(t,e,n,r,a){void 0!==r&&function(t,e,n){for(var r=[],i=0,o=a;i<o.length;i++){var s=o[i];if(s===n)return;r.push(Aa(s))}var u=Aa(n);throw new Mr(Ur.INVALID_ARGUMENT,"Invalid value "+u+" provided to function "+t+'() for option "'+e+'". Acceptable values: '+r.join(", "))}(t,n,r)}function Ia(t,e,n,r){if(!("object"===e?Na(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=Aa(r);throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function Na(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function Aa(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return 20<e.length&&(e=e.substring(0,20)+"..."),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"!=typeof e)return"function"==typeof e?"a function":mu("Unknown wrong type: "+typeof e);if(e instanceof Array)return"an array";var t=function(){if(e.constructor){var t=/function\s+([^\s(]+)\s*\(/.exec(e.constructor.toString());if(t&&1<t.length)return t[1]}return null}();return t?"a custom "+t+" object":"an object"}function _a(t,e,n){if(void 0===n)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+xa(e)+" argument, but it was undefined.")}function Sa(n,t,r){Ei(t,function(t,e){if(r.indexOf(t)<0)throw new Mr(Ur.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function Da(t,e,n,r){var i=Aa(r);return new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires its "+xa(n)+" argument to be a "+e+", but it was: "+i)}function ka(t,e,n){if(n<=0)throw new Mr(Ur.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+xa(e)+" argument to be a positive number, but it was: "+n+".")}function xa(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Ra(t,e){return t+" "+e+(1===t?"":"s")}function La(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new Mr(Ur.INVALID_ARGUMENT,t)}return n.prototype=t.prototype,Object.assign(n,t),n}function Oa(){if("undefined"==typeof Uint8Array)throw new Mr(Ur.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Va(){if(!hu.Lt().ia)throw new Mr(Ur.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}ha.Mh=3e8;var Pa=(Fa.fromBase64String=function(t){ya("Blob.fromBase64String",arguments,1),ga("Blob.fromBase64String","string",1,t),Va();try{return new Fa(Ii.fromBase64String(t))}catch(t){throw new Mr(Ur.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Fa.fromUint8Array=function(t){if(ya("Blob.fromUint8Array",arguments,1),Oa(),!(t instanceof Uint8Array))throw Da("Blob.fromUint8Array","Uint8Array",1,t);return new Fa(Ii.fromUint8Array(t))},Fa.prototype.toBase64=function(){return ya("Blob.toBase64",arguments,0),Va(),this.ra.toBase64()},Fa.prototype.toUint8Array=function(){return ya("Blob.toUint8Array",arguments,0),Oa(),this.ra.toUint8Array()},Fa.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Fa.prototype.isEqual=function(t){return this.ra.isEqual(t.ra)},Fa),Ca=La(Pa,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Ua=(Ma.documentId=function(){return Ma.ha},Ma.prototype.isEqual=function(t){if(!(t instanceof Ma))throw Da("isEqual","FieldPath",1,t);return this.oa.isEqual(t.oa)},Ma);function Ma(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(){if(!(t instanceof Array)||t.length<1)throw new Mr(Ur.INVALID_ARGUMENT,"Function FieldPath() requires its fieldNames argument to be an array with at least 1 element.")}();for(var n=0;n<t.length;++n)if(ga("FieldPath","string",n,t[n]),0===t[n].length)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.oa=new oi(t)}function Fa(t){Va(),this.ra=t}Ua.ha=new Ua(oi.X().K());var ja,qa=new RegExp("[~\\*/\\[\\]]"),Ga=(Ka.delete=function(){return da("FieldValue.delete",arguments),Ba.instance},Ka.serverTimestamp=function(){return da("FieldValue.serverTimestamp",arguments),Ha.instance},Ka.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return va("FieldValue.arrayUnion",arguments,1),new Za(t)},Ka.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return va("FieldValue.arrayRemove",arguments,1),new $a(t)},Ka.increment=function(t){return ga("FieldValue.increment","number",1,t),ya("FieldValue.increment",arguments,1),new th(t)},Ka.prototype.isEqual=function(t){return this===t},Ka),Ba=(n(za,ja=Ga),za);function za(){return ja.call(this,"FieldValue.delete")||this}function Ka(t){this.aa=t}Ba.instance=new Ba;var Wa,Ha=(n(Ya,Wa=Ga),Ya);function Ya(){return Wa.call(this,"FieldValue.serverTimestamp")||this}Ha.instance=new Ha;var Xa,Ja,Qa,Za=(n(fh,Qa=Ga),fh),$a=(n(ch,Ja=Ga),ch),th=(n(hh,Xa=Ga),hh),eh=La(Ga,"Use FieldValue.<field>() instead."),nh=(Object.defineProperty(ah.prototype,"latitude",{get:function(){return this._a},enumerable:!0,configurable:!0}),Object.defineProperty(ah.prototype,"longitude",{get:function(){return this.la},enumerable:!0,configurable:!0}),ah.prototype.isEqual=function(t){return this._a===t._a&&this.la===t.la},ah.prototype.p=function(t){return Eu(this._a,t._a)||Eu(this.la,t.la)},ah),rh=/^__.*__$/,ih=(uh.prototype.da=function(t,e){var n=[];return null!==this.se?n.push(new vo(t,this.data,this.se,e)):n.push(new yo(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new mo(t,this.fieldTransforms)),n},uh),oh=(sh.prototype.da=function(t,e){var n=[new vo(t,this.data,this.se,e)];return 0<this.fieldTransforms.length&&n.push(new mo(t,this.fieldTransforms)),n},sh);function sh(t,e,n){this.data=t,this.se=e,this.fieldTransforms=n}function uh(t,e,n){this.data=t,this.se=e,this.fieldTransforms=n}function ah(t,e){if(ya("GeoPoint",arguments,2),ga("GeoPoint","number",1,t),ga("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new Mr(Ur.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new Mr(Ur.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._a=t,this.la=e}function hh(t){var e=this;return(e=Xa.call(this,"FieldValue.increment")||this).ca=t,e}function ch(t){var e=this;return(e=Ja.call(this,"FieldValue.arrayRemove")||this).ua=t,e}function fh(t){var e=this;return(e=Qa.call(this,"FieldValue.arrayUnion")||this).ua=t,e}function lh(t){switch(t){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw mu("Unexpected case for UserDataSource: "+t)}}var ph=(mh.prototype.Ea=function(t){var e=null==this.path?null:this.path.child(t),n=new mh(this.fa,this.methodName,e,!1,this.fieldTransforms,this.se);return n.wa(t),n},mh.prototype.Ia=function(t){var e=null==this.path?null:this.path.child(t),n=new mh(this.fa,this.methodName,e,!1,this.fieldTransforms,this.se);return n.ma(),n},mh.prototype.Ra=function(t){return new mh(this.fa,this.methodName,null,!0,this.fieldTransforms,this.se)},mh.prototype.Aa=function(t){var e=null===this.path||this.path.U()?"":" (found in field "+this.path.toString()+")";return new Mr(Ur.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},mh.prototype.contains=function(e){return void 0!==this.se.find(function(t){return e.q(t)})||void 0!==this.fieldTransforms.find(function(t){return e.q(t.field)})},mh.prototype.ma=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.wa(this.path.get(t))},mh.prototype.wa=function(t){if(0===t.length)throw this.Aa("Document fields must not be empty");if(lh(this.fa)&&rh.test(t))throw this.Aa('Document fields cannot begin and end with "__"')},mh),dh=function(t,e){this.cn=t,this.key=e},yh=(vh.prototype.Va=function(t,e){var n=new ph(0,t,oi.H);wh("Data must be an object, but it was:",n,e);var r=this.ga(e,n);return new ih(new bo(r),null,n.fieldTransforms)},vh.prototype.pa=function(t,e,n){var r=new ph(2,t,oi.H);wh("Data must be an object, but it was:",r,e);var i,o,s=this.ga(e,r);if(n){for(var u=new vi(oi.F),a=0,h=n;a<h.length;a++){var c=h[a],f=void 0;if(c instanceof Ua)f=c.oa;else{if("string"!=typeof c)throw mu("Expected stringOrFieldPath to be a string or a FieldPath");f=Eh(t,c)}if(!r.contains(f))throw new Mr(Ur.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");u=u.add(f)}i=no.Kt(u),o=r.fieldTransforms.filter(function(t){return i.zt(t.field)})}else i=no.Gt(r.se),o=r.fieldTransforms;return new ih(new bo(s),i,o)},vh.prototype.ya=function(o,t){var s=this,u=new ph(1,o,oi.H);wh("Data must be an object, but it was:",u,t);var a=new vi(oi.F),h=bo._e();Ei(t,function(t,e){var n=Eh(o,t),r=u.Ia(n);if((e=s.ba(e,r))instanceof Ba)a=a.add(n);else{var i=s.va(e,r);null!=i&&(a=a.add(n),h.set(n,i))}});var e=no.Kt(a);return new oh(h.oe(),e,u.fieldTransforms)},vh.prototype.Sa=function(t,e,n,r){var i=new ph(1,t,oi.H),o=[bh(t,e)],s=[n];if(r.length%2!=0)throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var u=0;u<r.length;u+=2)o.push(bh(t,r[u])),s.push(r[u+1]);for(var a=new vi(oi.F),h=bo._e(),c=0;c<o.length;++c){var f=o[c],l=i.Ia(f),p=this.ba(s[c],l);if(p instanceof Ba)a=a.add(f);else{var d=this.va(p,l);null!=d&&(a=a.add(f),h.set(f,d))}}var y=no.Kt(a);return new oh(h.oe(),y,i.fieldTransforms)},vh.prototype.Da=function(t,e,n){void 0===n&&(n=!1);var r=new ph(n?4:3,t,oi.H);return this.va(e,r)},vh.prototype.ba=function(t,e){try{return this.Pa(t)}catch(t){var n=Th(t);throw e.Aa(n)}},vh.prototype.va=function(t,e){if(gh(t=this.ba(t,e)))return wh("Unsupported field value:",e,t),this.ga(t,e);if(t instanceof Ga)return this.Ca(t,e),null;if(e.path&&e.se.push(e.path),t instanceof Array){if(e.Ta&&4!==e.fa)throw e.Aa("Nested arrays are not supported");return this.ka(t,e)}return this.Na(t,e)},vh.prototype.ga=function(t,r){var i=this,o={};return Ti(t)?r.path&&0<r.path.length&&r.se.push(r.path):Ei(t,function(t,e){var n=i.va(e,r.Ea(t));null!=n&&(o[t]=n)}),{mapValue:{fields:o}}},vh.prototype.ka=function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=o[i],u=this.va(s,e.Ra(r));null==u&&(u={nullValue:"NULL_VALUE"}),n.push(u),r++}return{arrayValue:{values:n}}},vh.prototype.Ca=function(t,e){if(!lh(e.fa))throw e.Aa(t.aa+"() can only be used with update() and set()");if(null===e.path)throw e.Aa(t.aa+"() is not currently supported inside arrays");if(t instanceof Ba){if(2!==e.fa)throw 1===e.fa?e.Aa("FieldValue.delete() can only appear at the top level of your update data"):e.Aa("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");e.se.push(e.path)}else if(t instanceof Ha)e.fieldTransforms.push(new ro(e.path,Wi.instance));else if(t instanceof Za){var n=this.Fa(t.aa,t.ua),r=new Yi(n);e.fieldTransforms.push(new ro(e.path,r))}else if(t instanceof $a){var i=this.Fa(t.aa,t.ua),o=new Xi(i);e.fieldTransforms.push(new ro(e.path,o))}else if(t instanceof th){var s=this.Da("FieldValue.increment",t.ca),u=new Ji(this.serializer,s);e.fieldTransforms.push(new ro(e.path,u))}else mu("Unknown FieldValue type: "+t)},vh.prototype.Na=function(t,e){if(null===t)return{nullValue:"NULL_VALUE"};if("number"==typeof t)return this.serializer.Tn(t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=Br.fromDate(t);return{timestampValue:this.serializer.k(n)}}if(t instanceof Br){var r=new Br(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:this.serializer.k(r)}}if(t instanceof nh)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Pa)return{bytesValue:this.serializer.mn(t)};if(t instanceof dh)return{referenceValue:this.serializer.wn(t.key.path,t.cn)};throw e.Aa("Unsupported field value: "+Aa(t))},vh.prototype.Fa=function(r,t){var i=this;return t.map(function(t,e){var n=new ph(3,r,oi.H);return i.va(t,n.Ra(e))})},vh);function vh(t,e){this.serializer=t,this.Pa=e}function mh(t,e,n,r,i,o){this.fa=t,this.methodName=e,this.path=n,this.Ta=r,void 0===i&&this.ma(),this.Ta=void 0!==r&&r,this.fieldTransforms=i||[],this.se=o||[]}function gh(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Br||t instanceof nh||t instanceof Pa||t instanceof dh||t instanceof Ga)}function wh(t,e,n){if(!gh(n)||!Na(n)){var r=Aa(n);throw"an object"===r?e.Aa(t+" a custom object"):e.Aa(t+" "+r)}}function bh(t,e){if(e instanceof Ua)return e.oa;if("string"==typeof e)return Eh(t,e);throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Eh(t,e){try{return function(e){if(0<=e.search(qa))throw new Mr(Ur.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(Ua.bind.apply(Ua,i([void 0],e.split("."))))}catch(t){throw new Mr(Ur.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).oa}catch(e){var n=Th(e);throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. "+n)}}function Th(t){return t instanceof Error?t.message:t.toString()}var Ih,Nh,Ah=(jh.prototype.reset=function(){this.xa=0},jh.prototype.qa=function(){this.xa=this.Oa},jh.prototype.Qa=function(t){var e=this;this.cancel();var n=Math.floor(this.xa+this.Wa()),r=Math.max(0,Date.now()-this.Ua),i=Math.max(0,n-r);0<this.xa&&du("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.xa+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ba=this.$a.eo(this.Fr,i,function(){return e.Ua=Date.now(),t()}),this.xa*=this.La,this.xa<this.Ma&&(this.xa=this.Ma),this.xa>this.Oa&&(this.xa=this.Oa)},jh.prototype.cancel=function(){null!==this.Ba&&(this.Ba.cancel(),this.Ba=null)},jh.prototype.Wa=function(){return(Math.random()-.5)*this.xa},jh),_h=(Fh.prototype.Ya=function(){return 1===this.state||2===this.state||4===this.state},Fh.prototype.Xa=function(){return 2===this.state},Fh.prototype.start=function(){3!==this.state?this.auth():this.Za()},Fh.prototype.stop=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Ya()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Fh.prototype.tu=function(){this.state=0,this.Ja.reset()},Fh.prototype.eu=function(){var t=this;this.Xa()&&null===this.Ha&&(this.Ha=this.$a.eo(this.ja,6e4,function(){return t.su()}))},Fh.prototype.nu=function(t){this.iu(),this.stream.send(t)},Fh.prototype.su=function(){return f(this,void 0,void 0,function(){return y(this,function(t){return this.Xa()?[2,this.close(0)]:[2]})})},Fh.prototype.iu=function(){this.Ha&&(this.Ha.cancel(),this.Ha=null)},Fh.prototype.close=function(e,n){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.iu(),this.Ja.cancel(),this.za++,3!==e?this.Ja.reset():n&&n.code===Ur.RESOURCE_EXHAUSTED?(yu(n.toString()),yu("Using maximum backoff delay to prevent overloading the backend."),this.Ja.qa()):n&&n.code===Ur.UNAUTHENTICATED&&this.Ga._(),null!==this.stream&&(this.ru(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.ou(n)];case 1:return t.sent(),[2]}})})},Fh.prototype.ru=function(){},Fh.prototype.auth=function(){var n=this;this.state=1;var t=this.hu(this.za),e=this.za;this.Ga.getToken().then(function(t){n.za===e&&n.au(t)},function(e){t(function(){var t=new Mr(Ur.UNKNOWN,"Fetching auth token failed: "+e.message);return n.uu(t)})})},Fh.prototype.au=function(t){var e=this,n=this.hu(this.za);this.stream=this.cu(t),this.stream._u(function(){n(function(){return e.state=2,e.listener._u()})}),this.stream.ou(function(t){n(function(){return e.uu(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Fh.prototype.Za=function(){var t=this;this.state=4,this.Ja.Qa(function(){return f(t,void 0,void 0,function(){return y(this,function(t){return this.state=0,this.start(),[2]})})})},Fh.prototype.uu=function(t){return du("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},Fh.prototype.hu=function(e){var n=this;return function(t){n.$a.qr(function(){return n.za===e?t():(du("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Fh),Sh=(n(Mh,Nh=_h),Mh.prototype.cu=function(t){return this.Ka.lu("Listen",t)},Mh.prototype.onMessage=function(t){this.Ja.reset();var e=this.serializer.kn(t),n=this.serializer.Fn(t);return this.listener.du(e,n)},Mh.prototype.fu=function(t){var e={};e.database=this.serializer.pn,e.addTarget=this.serializer.xe(t);var n=this.serializer.ei(t);n&&(e.labels=n),this.nu(e)},Mh.prototype.Tu=function(t){var e={};e.database=this.serializer.pn,e.removeTarget=t,this.nu(e)},Mh),Dh=(n(Uh,Ih=_h),Object.defineProperty(Uh.prototype,"Eu",{get:function(){return this.mu},enumerable:!0,configurable:!0}),Uh.prototype.start=function(){this.mu=!1,Ih.prototype.start.call(this)},Uh.prototype.ru=function(){this.mu&&this.wu([])},Uh.prototype.cu=function(t){return this.Ka.lu("Write",t)},Uh.prototype.onMessage=function(t){if(gu(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=this.serializer.En(t.streamToken),this.mu){this.Ja.reset();var e=this.serializer.Wn(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.Iu(n,e)}return gu(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.mu=!0,this.listener.Ru()},Uh.prototype.Au=function(){var t={};t.database=this.serializer.pn,this.nu(t)},Uh.prototype.wu=function(t){var e=this,n={streamToken:this.serializer.mn(this.lastStreamToken),writes:t.map(function(t){return e.serializer.$n(t)})};this.nu(n)},Uh),kh=(Ch.prototype.Pu=function(t){return new Dh(this.$a,this.Ka,this.credentials,this.serializer,t)},Ch.prototype.Vu=function(t){return new Sh(this.$a,this.Ka,this.credentials,this.serializer,t)},Ch.prototype.commit=function(t){var e=this,n={database:this.serializer.pn,writes:t.map(function(t){return e.serializer.$n(t)})};return this.gu("Commit",n).then(function(t){return e.serializer.Wn(t.writeResults,t.commitTime)})},Ch.prototype.pu=function(e){var i=this,t={database:this.serializer.pn,documents:e.map(function(t){return i.serializer.An(t)})};return this.yu("BatchGetDocuments",t).then(function(t){var n=Ss();t.forEach(function(t){var e=i.serializer.Cn(t);n=n.it(e.key,e)});var r=[];return e.forEach(function(t){var e=n.get(t);gu(!!e,"Missing entity in write response for "+t),r.push(e)}),r})},Ch.prototype.gu=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Ka.gu(e,n,t)}).catch(function(t){throw t.code===Ur.UNAUTHENTICATED&&r.credentials._(),t})},Ch.prototype.yu=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Ka.yu(e,n,t)}).catch(function(t){throw t.code===Ur.UNAUTHENTICATED&&r.credentials._(),t})},Ch),xh=(Ph.prototype.pu=function(r){return f(this,void 0,void 0,function(){var e,n=this;return y(this,function(t){switch(t.label){case 0:if(this.ku(),0<this.mutations.length)throw new Mr(Ur.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,this.bu.pu(r)];case 1:return[2,((e=t.sent()).forEach(function(t){t instanceof Vo||t instanceof Oo?n.Nu(t):mu("Document in a transaction was a "+t.constructor.name)}),e)]}})})},Ph.prototype.set=function(t,e){this.write(e.da(t,this.Zt(t))),this.Cu.add(t)},Ph.prototype.update=function(t,e){try{this.write(e.da(t,this.Fu(t)))}catch(t){this.Du=t}this.Cu.add(t)},Ph.prototype.delete=function(t){this.write([new go(t,this.Zt(t))]),this.Cu.add(t)},Ph.prototype.commit=function(){return f(this,void 0,void 0,function(){var e,n=this;return y(this,function(t){switch(t.label){case 0:if(this.ku(),this.Du)throw this.Du;return e=this.vu,this.mutations.forEach(function(t){e=e.remove(t.key)}),e.forEach(function(t,e){n.mutations.push(new wo(t,n.Zt(t)))}),[4,this.bu.commit(this.mutations)];case 1:return t.sent(),this.Su=!0,[2]}})})},Ph.prototype.Nu=function(t){var e;if(t instanceof Oo)e=t.version;else{if(!(t instanceof Vo))throw mu("Document in a transaction was a "+t.constructor.name);e=zr.S()}var n=this.vu.get(t.key);if(null!==n){if(!e.isEqual(n))throw new Mr(Ur.ABORTED,"Document version changed between two reads.")}else this.vu=this.vu.it(t.key,e)},Ph.prototype.Zt=function(t){var e=this.vu.get(t);return!this.Cu.has(t)&&e?io.updateTime(e):io.NONE},Ph.prototype.Fu=function(t){var e=this.vu.get(t);if(this.Cu.has(t)||!e)return io.exists(!0);if(e.isEqual(zr.S()))throw new Mr(Ur.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return io.updateTime(e)},Ph.prototype.write=function(t){this.ku(),this.mutations=this.mutations.concat(t)},Ph.prototype.ku=function(){},Ph),Rh=(Vh.prototype.xu=function(){var t=this;0===this.Mu&&(this.Bu("Unknown"),this.Lu=this.Nr.eo("online_state_timeout",1e4,function(){return t.Lu=null,t.Uu("Backend didn't respond within 10 seconds."),t.Bu("Offline"),Promise.resolve()}))},Vh.prototype.qu=function(t){"Online"===this.state?this.Bu("Unknown"):(this.Mu++,1<=this.Mu&&(this.Qu(),this.Uu("Connection failed 1 times. Most recent error: "+t.toString()),this.Bu("Offline")))},Vh.prototype.set=function(t){this.Qu(),this.Mu=0,"Online"===t&&(this.Ou=!1),this.Bu(t)},Vh.prototype.Bu=function(t){t!==this.state&&(this.state=t,this.$u(t))},Vh.prototype.Uu=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.Ou?(yu(e),this.Ou=!1):du("OnlineStateTracker",e)},Vh.prototype.Qu=function(){null!==this.Lu&&(this.Lu.cancel(),this.Lu=null)},Vh),Lh=(Oh.prototype.start=function(){return this.enableNetwork()},Oh.prototype.enableNetwork=function(){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!0,this.Ju()?(e=this.nc,[4,this.Wu.ph()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this.hc()?this.ac():this.Xu.set("Unknown"),[4,this.uc()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},Oh.prototype.disableNetwork=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.cc()];case 1:return t.sent(),this.Xu.set("Offline"),[2]}})})},Oh.prototype.cc=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.nc.stop()];case 1:return t.sent(),[4,this.Zu.stop()];case 2:return t.sent(),0<this.ju.length&&(du("RemoteStore","Stopping write stream with "+this.ju.length+" pending writes"),this.ju=[]),this._c(),[2]}})})},Oh.prototype.lc=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return du("RemoteStore","RemoteStore shutting down."),this.networkEnabled=!1,[4,this.cc()];case 1:return t.sent(),this.zu.lc(),this.Xu.set("Unknown"),[2]}})})},Oh.prototype.listen=function(t){this.Ku.has(t.targetId)||(this.Ku.set(t.targetId,t),this.hc()?this.ac():this.Zu.Xa()&&this.dc(t))},Oh.prototype.fc=function(t){this.Ku.delete(t),this.Zu.Xa()&&this.Tc(t),0===this.Ku.size&&(this.Zu.Xa()?this.Zu.eu():this.Ju()&&this.Xu.set("Unknown"))},Oh.prototype.un=function(t){return this.Ku.get(t)||null},Oh.prototype.an=function(t){return this.mc.an(t)},Oh.prototype.dc=function(t){this.Gu.Bs(t.targetId),this.Zu.fu(t)},Oh.prototype.Tc=function(t){this.Gu.Bs(t),this.Zu.Tu(t)},Oh.prototype.ac=function(){this.Gu=new Ws(this),this.Zu.start(),this.Xu.xu()},Oh.prototype.hc=function(){return this.Ju()&&!this.Zu.Ya()&&0<this.Ku.size},Oh.prototype.Ju=function(){return this.isPrimary&&this.networkEnabled},Oh.prototype._c=function(){this.Gu=null},Oh.prototype.tc=function(){return f(this,void 0,void 0,function(){var n=this;return y(this,function(t){return this.Ku.forEach(function(t,e){n.dc(t)}),[2]})})},Oh.prototype.ec=function(e){return f(this,void 0,void 0,function(){return y(this,function(t){return this._c(),this.hc()?(this.Xu.qu(e),this.ac()):this.Xu.set("Unknown"),[2]})})},Oh.prototype.sc=function(n,r){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this.Xu.set("Online"),n instanceof Fs&&2===n.state&&n.cause?[2,this.Ec(n)]:(n instanceof Us?this.Gu.zs(n):n instanceof Ms?this.Gu.sn(n):this.Gu.Ys(n),r.isEqual(zr.MIN)?[3,4]:[4,this.Wu.bh()]);case 1:return e=t.sent(),0<=r.D(e)?[4,this.wc(r)]:[3,3];case 2:t.sent(),t.label=3;case 3:t.label=4;case 4:return[2]}})})},Oh.prototype.wc=function(r){var i=this,t=this.Gu.rn(r);return t.Ts.forEach(function(t,e){if(0<t.resumeToken.Ot()){var n=i.Ku.get(e);n&&i.Ku.set(e,n.ss(t.resumeToken,r))}}),t.ms.forEach(function(t){var e=i.Ku.get(t);if(e){i.Ku.set(t,e.ss(Ii.xt,e.ts)),i.Tc(t);var n=new bs(e.target,t,1,e.sequenceNumber);i.dc(n)}}),this.mc.vh(t)},Oh.prototype.Ec=function(t){var n=this,r=t.cause,i=Promise.resolve();return t.targetIds.forEach(function(e){i=i.then(function(){return f(n,void 0,void 0,function(){return y(this,function(t){return this.Ku.has(e)?[2,(this.Ku.delete(e),this.Gu.removeTarget(e),this.mc.Ic(e,r))]:[2]})})})}),i},Oh.prototype.uc=function(){return f(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return this.Rc()?(e=0<this.ju.length?this.ju[this.ju.length-1].batchId:-1,[4,this.Wu.Oh(e)]):[3,5];case 1:return null!==(n=t.sent())?[3,2]:(0===this.ju.length&&this.nc.eu(),[3,4]);case 2:return this.Ac(n),[4,this.uc()];case 3:t.sent(),t.label=4;case 4:t.label=5;case 5:return this.Pc()&&this.Vc(),[2]}})})},Oh.prototype.Rc=function(){return this.Ju()&&this.ju.length<10},Oh.prototype.gc=function(){return this.ju.length},Oh.prototype.Ac=function(t){this.ju.push(t),this.nc.Xa()&&this.nc.Eu&&this.nc.wu(t.mutations)},Oh.prototype.Pc=function(){return this.Ju()&&!this.nc.Ya()&&0<this.ju.length},Oh.prototype.Vc=function(){this.nc.start()},Oh.prototype.ic=function(){return f(this,void 0,void 0,function(){return y(this,function(t){return this.nc.Au(),[2]})})},Oh.prototype.oc=function(){var r=this;return this.Wu.yh(this.nc.lastStreamToken).then(function(){for(var t=0,e=r.ju;t<e.length;t++){var n=e[t];r.nc.wu(n.mutations)}}).catch(pa)},Oh.prototype.Iu=function(t,e){var n=this,r=this.ju.shift(),i=Du.from(r,t,e,this.nc.lastStreamToken);return this.mc.pc(i).then(function(){return n.uc()})},Oh.prototype.rc=function(n){return f(this,void 0,void 0,function(){var e=this;return y(this,function(t){return n&&0<this.ju.length?[2,(this.nc.Eu?this.yc(n):this.bc(n)).then(function(){e.Pc()&&e.Vc()})]:[2]})})},Oh.prototype.bc=function(e){return f(this,void 0,void 0,function(){return y(this,function(t){return Ns(e.code)?[2,(du("RemoteStore","RemoteStore error before completed handshake; resetting stream token: ",this.nc.lastStreamToken),this.nc.lastStreamToken=Ii.xt,this.Wu.yh(Ii.xt).catch(pa))]:[2]})})},Oh.prototype.yc=function(i){return f(this,void 0,void 0,function(){var e,n,r=this;return y(this,function(t){return Ns(n=i.code)&&n!==Ur.ABORTED?(e=this.ju.shift(),[2,(this.nc.tu(),this.mc.vc(e.batchId,i).then(function(){return r.uc()}))]):[2]})})},Oh.prototype.Sc=function(){return new xh(this.bu)},Oh.prototype.Yu=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.cc()];case 1:return t.sent(),this.Xu.set("Unknown"),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},Oh.prototype.Dc=function(){return f(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Ju()?(du("RemoteStore","RemoteStore restarting streams for new credential"),[4,this.Yu()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Oh.prototype.Cc=function(e){return f(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,5];case 2:return e?[3,4]:[4,this.cc()];case 3:t.sent(),this.Xu.set("Unknown"),t.label=4;case 4:t.label=5;case 5:return[2]}})})},Oh);function Oh(t,e,n,r,i){var o=this;this.Wu=t,this.bu=e,this.ju=[],this.Ku=new Map,this.Gu=null,this.networkEnabled=!1,this.isPrimary=!1,this.zu=i,this.zu.Hu(function(t){n.qr(function(){return f(o,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.Ju()?(du("RemoteStore","Restarting streams for network reachability change."),[4,this.Yu()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Xu=new Rh(n,r),this.Zu=this.bu.Vu({_u:this.tc.bind(this),ou:this.ec.bind(this),du:this.sc.bind(this)}),this.nc=this.bu.Pu({_u:this.ic.bind(this),ou:this.rc.bind(this),Ru:this.oc.bind(this),Iu:this.Iu.bind(this)})}function Vh(t,e){this.Nr=t,this.$u=e,this.state="Unknown",this.Mu=0,this.Lu=null,this.Ou=!0}function Ph(t){this.bu=t,this.vu=Ls(),this.mutations=[],this.Su=!1,this.Du=null,this.Cu=new Set}function Ch(t,e,n,r){this.$a=t,this.Ka=e,this.credentials=n,this.serializer=r}function Uh(t,e,n,r,i){var o=this;return(o=Ih.call(this,t,"write_stream_connection_backoff","write_stream_idle",e,n,i)||this).serializer=r,o.mu=!1,o.lastStreamToken=Ii.xt,o}function Mh(t,e,n,r,i){var o=this;return(o=Nh.call(this,t,"listen_stream_connection_backoff","listen_stream_idle",e,n,i)||this).serializer=r,o}function Fh(t,e,n,r,i,o){this.$a=t,this.ja=n,this.Ka=r,this.Ga=i,this.listener=o,this.state=0,this.za=0,this.Ha=null,this.stream=null,this.Ja=new Ah(t,e)}function jh(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.$a=t,this.Fr=e,this.Ma=n,this.La=r,this.Oa=i,this.xa=0,this.Ba=null,this.Ua=Date.now(),this.reset()}function qh(t,e){return"firestore_clients_"+t+"_"+e}function Gh(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.t()&&(r+="_"+e.uid),r}function Bh(t,e){return"firestore_targets_"+t+"_"+e}function zh(t){this.key=t}function Kh(t){this.key=t}function Wh(t,e,n){this.query=t,this.targetId=e,this.view=n}function Hh(t){this.key=t,this.Y_=!1}function Yh(){this.kl=null,this.targetId=0,this.Nl=[]}var Xh=(Tc.kc=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 Mr(r.error.code,r.error.message)),i?new Tc(t,e,r.state,o):(yu("SharedClientState","Failed to parse mutation state for ID '"+e+"': "+n),null)},Tc.prototype.Nc=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)},Tc),Jh=(Ec.kc=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 Mr(n.error.code,n.error.message)),r?new Ec(t,n.state,i):(yu("SharedClientState","Failed to parse target state for ID '"+t+"': "+e),null)},Ec.prototype.Nc=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)},Ec),Qh=(bc.kc=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=Cs(),o=0;r&&o<n.activeTargetIds.length;++o)r=Si(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new bc(t,i):(yu("SharedClientState","Failed to parse client data for instance '"+t+"': "+e),null)},bc),Zh=(wc.kc=function(t){var e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new wc(e.clientId,e.onlineState):(yu("SharedClientState","Failed to parse online state: "+t),null)},wc),$h=(gc.prototype.Fc=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},gc.prototype.$c=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},gc.prototype.Nc=function(){var t={activeTargetIds:this.activeTargetIds.j(),updateTimeMs:Date.now()};return JSON.stringify(t)},gc),tc=(mc.Uc=function(t){return!(!t.window||null==t.window.localStorage)},mc.prototype.start=function(){return f(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h,c,f,l=this;return y(this,function(t){switch(t.label){case 0:return[4,this.mc.Jh()];case 1:for(e=t.sent(),n=0,r=e;n<r.length;n++)(i=r[n])!==this.Mc&&(o=this.getItem(qh(this.persistenceKey,i)))&&(s=Qh.kc(i,o))&&(this.Lc[s.clientId]=s);for(this.zc(),(u=this.storage.getItem(this.Gc))&&(a=this.Hc(u))&&this.Jc(a),h=0,c=this.Bc;h<c.length;h++)f=c[h],this.xc(f);return this.Bc=[],this.platform.window.addEventListener("unload",function(){return l.lc()}),this.ko=!0,[2]}})})},mc.prototype.Cr=function(t){this.setItem(this.Qc,JSON.stringify(t))},mc.prototype.Yc=function(){var n=Cs();return Ei(this.Lc,function(t,e){n=n.Ft(e.activeTargetIds)}),n},mc.prototype.Xc=function(t){for(var e in this.Lc)if(this.Lc.hasOwnProperty(e)&&this.Lc[e].activeTargetIds.has(t))return!0;return!1},mc.prototype.Zc=function(t){this.t_(t,"pending")},mc.prototype.e_=function(t,e,n){this.t_(t,e,n),this.s_(t)},mc.prototype.n_=function(t){var e="not-current";if(this.Xc(t)){var n=this.storage.getItem(Bh(this.persistenceKey,t));if(n){var r=Jh.kc(t,n);r&&(e=r.state)}}return this.i_.Fc(t),this.zc(),e},mc.prototype.r_=function(t){this.i_.$c(t),this.zc()},mc.prototype.o_=function(t){return this.i_.activeTargetIds.has(t)},mc.prototype.h_=function(t){this.removeItem(Bh(this.persistenceKey,t))},mc.prototype.a_=function(t,e,n){this.u_(t,e,n)},mc.prototype.oh=function(t,e,n){var r=this;e.forEach(function(t){r.s_(t)}),this.currentUser=t,n.forEach(function(t){r.Zc(t)})},mc.prototype.c_=function(t){this.__(t)},mc.prototype.lc=function(){this.ko&&(this.platform.window.removeEventListener("storage",this.Oc),this.removeItem(this.qc),this.ko=!1)},mc.prototype.getItem=function(t){var e=this.storage.getItem(t);return du("SharedClientState","READ",t,e),e},mc.prototype.setItem=function(t,e){du("SharedClientState","SET",t,e),this.storage.setItem(t,e)},mc.prototype.removeItem=function(t){du("SharedClientState","REMOVE",t),this.storage.removeItem(t)},mc.prototype.xc=function(u){var t=this;if(u.storageArea===this.storage){if(du("SharedClientState","EVENT",u.key,u.newValue),u.key===this.qc)return void yu("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.$a.qr(function(){return f(t,void 0,void 0,function(){var e,n,r,i,o,s;return y(this,function(t){if(this.ko){if(null!==u.key)if(this.Wc.test(u.key)){if(null==u.newValue)return e=this.l_(u.key),[2,this.d_(e,null)];if(n=this.f_(u.key,u.newValue))return[2,this.d_(n.clientId,n)]}else if(this.jc.test(u.key)){if(null!==u.newValue&&(r=this.T_(u.key,u.newValue)))return[2,this.m_(r)]}else if(this.Kc.test(u.key)){if(null!==u.newValue&&(i=this.E_(u.key,u.newValue)))return[2,this.w_(i)]}else if(u.key===this.Gc){if(null!==u.newValue&&(o=this.Hc(u.newValue)))return[2,this.Jc(o)]}else u.key===this.Qc&&(s=function(t){var e=Uu.kr;if(null!=t)try{var n=JSON.parse(t);gu("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(t){yu("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(u.newValue))!==Uu.kr&&this.vr(s)}else this.Bc.push(u);return[2]})})})}},Object.defineProperty(mc.prototype,"i_",{get:function(){return this.Lc[this.Mc]},enumerable:!0,configurable:!0}),mc.prototype.zc=function(){this.setItem(this.qc,this.i_.Nc())},mc.prototype.t_=function(t,e,n){var r=new Xh(this.currentUser,t,e,n),i=Gh(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Nc())},mc.prototype.s_=function(t){var e=Gh(this.persistenceKey,this.currentUser,t);this.removeItem(e)},mc.prototype.__=function(t){var e={clientId:this.Mc,onlineState:t};this.storage.setItem(this.Gc,JSON.stringify(e))},mc.prototype.u_=function(t,e,n){var r=Bh(this.persistenceKey,t),i=new Jh(t,e,n);this.setItem(r,i.Nc())},mc.prototype.l_=function(t){var e=this.Wc.exec(t);return e?e[1]:null},mc.prototype.f_=function(t,e){var n=this.l_(t);return Qh.kc(n,e)},mc.prototype.T_=function(t,e){var n=this.jc.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Xh.kc(new Or(i),r,e)},mc.prototype.E_=function(t,e){var n=this.Kc.exec(t),r=Number(n[1]);return Jh.kc(r,e)},mc.prototype.Hc=function(t){return Zh.kc(t)},mc.prototype.m_=function(e){return f(this,void 0,void 0,function(){return y(this,function(t){return e.user.uid===this.currentUser.uid?[2,this.mc.I_(e.batchId,e.state,e.error)]:(du("SharedClientState","Ignoring mutation for non-active user "+e.user.uid),[2])})})},mc.prototype.w_=function(t){return this.mc.R_(t.targetId,t.state,t.error)},mc.prototype.d_=function(t,e){var n=this,r=this.Yc();e?this.Lc[t]=e:delete this.Lc[t];var i=this.Yc(),o=[],s=[];return i.forEach(function(e){return f(n,void 0,void 0,function(){return y(this,function(t){return r.has(e)||o.push(e),[2]})})}),r.forEach(function(e){return f(n,void 0,void 0,function(){return y(this,function(t){return i.has(e)||s.push(e),[2]})})}),this.mc.A_(o,s)},mc.prototype.Jc=function(t){this.Lc[t.clientId]&&this.$u(t.onlineState)},mc),ec=(vc.prototype.Zc=function(t){},vc.prototype.e_=function(t,e,n){},vc.prototype.n_=function(t){return this.P_.Fc(t),this.V_[t]||"not-current"},vc.prototype.a_=function(t,e,n){this.V_[t]=e},vc.prototype.r_=function(t){this.P_.$c(t)},vc.prototype.o_=function(t){return this.P_.activeTargetIds.has(t)},vc.prototype.h_=function(t){delete this.V_[t]},vc.prototype.Yc=function(){return this.P_.activeTargetIds},vc.prototype.Xc=function(t){return this.P_.activeTargetIds.has(t)},vc.prototype.start=function(){return this.P_=new $h,Promise.resolve()},vc.prototype.oh=function(t,e,n){},vc.prototype.c_=function(t){},vc.prototype.lc=function(){},vc.prototype.Cr=function(t){},vc),nc=(yc.prototype.next=function(){return this.g_+=2,this.g_},yc.p_=function(){return new yc(0)},yc.y_=function(){return new yc(-1)},yc),rc=(Object.defineProperty(dc.prototype,"C_",{get:function(){return this.b_},enumerable:!0,configurable:!0}),dc.prototype.k_=function(t,e){var u=this,a=e?e.N_:new qs,h=e?e.D_:this.D_,c=e?e._s:this._s,f=h,l=!1,p=this.query.je()&&h.size===this.query.limit?h.last():null,d=this.query.Ke()&&h.size===this.query.limit?h.first():null;if(t.ut(function(t,e){var n=h.get(t),r=e instanceof Oo?e:null;r=r&&(u.query.matches(r)?r:null);var i=!!n&&u._s.has(n.key),o=!!r&&(r.te||u._s.has(r.key)&&r.hasCommittedMutations),s=!1;n&&r?n.data().isEqual(r.data())?i!==o&&(a.track({type:3,doc:r}),s=!0):u.F_(n,r)||(a.track({type:2,doc:r}),s=!0,(p&&0<u.query.Be(r,p)||d&&u.query.Be(r,d)<0)&&(l=!0)):!n&&r?(a.track({type:0,doc:r}),s=!0):n&&!r&&(a.track({type:1,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.je()||this.query.Ke())for(;f.size>this.query.limit;){var n=this.query.je()?f.last():f.first();f=f.delete(n.key),c=c.delete(n.key),a.track({type:1,doc:n})}return{D_:f,N_:a,M_:l,_s:c}},dc.prototype.F_=function(t,e){return t.te&&e.hasCommittedMutations&&!e.te},dc.prototype.nr=function(t,e,n){var o=this,r=this.D_;this.D_=t.D_,this._s=t._s;var i=t.N_.us();i.sort(function(t,e){return r=t.type,i=e.type,n(r)-n(i)||o.query.Be(t.doc,e.doc);function n(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return mu("Unknown ChangeType: "+t)}}var r,i}),this.L_(n);var s=e?this.O_():[],u=0===this.S_.size&&this.As?1:0,a=u!==this.v_;return this.v_=u,0!==i.length||a?{snapshot:new Gs(this.query,t.D_,r,i,t._s,0==u,a,!1),x_:s}:{x_:s}},dc.prototype.B_=function(t){return this.As&&"Offline"===t?(this.As=!1,this.nr({D_:this.D_,N_:new qs,_s:this._s,M_:!1},!1)):{x_:[]}},dc.prototype.U_=function(t){return!this.b_.has(t)&&!!this.D_.has(t)&&!this.D_.get(t).te},dc.prototype.L_=function(t){var e=this;t&&(t.Ps.forEach(function(t){return e.b_=e.b_.add(t)}),t.Vs.forEach(function(t){}),t.gs.forEach(function(t){return e.b_=e.b_.delete(t)}),this.As=t.As)},dc.prototype.O_=function(){var e=this;if(!this.As)return[];var n=this.S_;this.S_=Vs(),this.D_.forEach(function(t){e.U_(t.key)&&(e.S_=e.S_.add(t.key))});var r=[];return n.forEach(function(t){e.S_.has(t)||r.push(new Kh(t))}),this.S_.forEach(function(t){n.has(t)||r.push(new zh(t))}),r},dc.prototype.q_=function(t){this.b_=t.zh,this.S_=Vs();var e=this.k_(t.documents);return this.nr(e,!0)},dc.prototype.Q_=function(){return Gs.fs(this.query,this.D_,this._s,0===this.v_)},dc),ic=(pc.prototype.K_=function(){this.G_()},pc.prototype.G_=function(){var t=this;this.Ja.Qa(function(){return f(t,void 0,void 0,function(){var e,n,r=this;return y(this,function(t){return e=this.W_.Sc(),(n=this.z_(e))&&n.then(function(t){r.Nr.qr(function(){return e.commit().then(function(){r.Lr.resolve(t)}).catch(function(t){r.H_(t)})})}).catch(function(t){r.H_(t)}),[2]})})})},pc.prototype.z_=function(t){try{var e=this.updateFunction(t);return!Ai(e)&&e.catch&&e.then?e:(this.Lr.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Lr.reject(t),null}},pc.prototype.H_=function(t){var e=this;0<this.j_&&this.J_(t)?(--this.j_,this.Nr.qr(function(){return e.G_(),Promise.resolve()})):this.Lr.reject(t)},pc.prototype.J_=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!Ns(e)},pc),oc=(Object.defineProperty(lc.prototype,"cl",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),lc.prototype.subscribe=function(t){this.tl=t},lc.prototype.listen=function(s){return f(this,void 0,void 0,function(){var e,n,r,i,o;return y(this,function(t){switch(t.label){case 0:return this._l("listen()"),(r=this.el.get(s))?(e=r.targetId,this.X_.n_(e),n=r.view.Q_(),[3,4]):[3,1];case 1:return[4,this.Wu.Uh(s.xe())];case 2:return i=t.sent(),o=this.X_.n_(i.targetId),e=i.targetId,[4,this.ll(s,e,"current"===o)];case 3:n=t.sent(),this.isPrimary&&this.W_.listen(i),t.label=4;case 4:return[2,(this.tl.du([n]),e)]}})})},lc.prototype.ll=function(u,a,h){return f(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.Wu.Kh(u,!0)];case 1:return e=t.sent(),n=new rc(u,e.zh),r=n.k_(e.documents),i=zs.Rs(a,h&&"Offline"!==this.onlineState),o=n.nr(r,!0===this.isPrimary,i),s=new Wh(u,a,n),[2,(this.el.set(u,s),this.sl.has(a)?this.sl.get(a).push(u):this.sl.set(a,[u]),o.snapshot)]}})})},lc.prototype.dl=function(r){return f(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return[4,this.Wu.Kh(r.query,!0)];case 1:return e=t.sent(),n=r.view.q_(e),[2,(this.isPrimary&&this.fl(r.targetId,n.x_),n)]}})})},lc.prototype.fc=function(i){return f(this,void 0,void 0,function(){var e,n,r=this;return y(this,function(t){switch(t.label){case 0:return this._l("unlisten()"),e=this.el.get(i),1<(n=this.sl.get(e.targetId)).length?[2,(this.sl.set(e.targetId,n.filter(function(t){return!t.isEqual(i)})),void this.el.delete(i))]:this.isPrimary?(this.X_.r_(e.targetId),this.X_.Xc(e.targetId)?[3,2]:[4,this.Wu.jh(e.targetId,!1).then(function(){r.X_.h_(e.targetId),r.W_.fc(e.targetId),r.Tl(e.targetId)}).catch(pa)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.Tl(e.targetId),[4,this.Wu.jh(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},lc.prototype.write=function(n,r){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this._l("write()"),[4,this.Wu.lh(n)];case 1:return e=t.sent(),this.X_.Zc(e.batchId),this.ml(e.batchId,r),[4,this.El(e.zi)];case 2:return t.sent(),[4,this.W_.uc()];case 3:return t.sent(),[2]}})})},lc.prototype.runTransaction=function(t,e,n){new ic(t,this.W_,e,n).K_()},lc.prototype.vh=function(n){return f(this,void 0,void 0,function(){var e,r=this;return y(this,function(t){switch(t.label){case 0:this._l("applyRemoteEvent()"),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.Wu.vh(n)];case 2:return e=t.sent(),n.Ts.forEach(function(t,e){var n=r.rl.get(e);n&&(gu(t.Ps.size+t.Vs.size+t.gs.size<=1,"Limbo resolution for single document contains multiple changes."),0<t.Ps.size?n.Y_=!0:0<t.Vs.size?gu(n.Y_,"Received change for limbo target document without add."):0<t.gs.size&&(gu(n.Y_,"Received remove for limbo target document without add."),n.Y_=!1))}),[4,this.El(e,n)];case 3:return t.sent(),[3,6];case 4:return[4,pa(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},lc.prototype.B_=function(r,t){if(this.isPrimary&&0===t||!this.isPrimary&&1===t){this._l("applyOnlineStateChange()");var i=[];this.el.forEach(function(t,e){var n=e.view.B_(r);n.snapshot&&i.push(n.snapshot)}),this.tl.wl(r),this.tl.du(i),this.onlineState=r,this.isPrimary&&this.X_.c_(r)}},lc.prototype.Ic=function(u,a){return f(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._l("rejectListens()"),this.X_.a_(u,"rejected",a),e=this.rl.get(u),(n=e&&e.key)?(this.il=this.il.remove(n),this.rl.delete(u),this.Il(),r=(r=new hi(ui.F)).it(n,new Vo(n,zr.S())),i=Vs().add(n),o=new Bs(zr.MIN,new Map,new vi(Eu),r,i),[2,this.vh(o)]):[4,this.Wu.jh(u,!1).then(function(){return s.Tl(u,a)}).catch(pa)];case 1:return t.sent(),[2]}})})},lc.prototype.I_=function(n,r,i){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return this._l("applyBatchState()"),[4,this.Wu.fh(n)];case 1:return null===(e=t.sent())?[3,6]:"pending"!==r?[3,3]:[4,this.W_.uc()];case 2:return t.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(this.Rl(n,i||null),this.Wu.Yh(n)):mu("Unknown batchState: "+r),t.label=4;case 4:return[4,this.El(e)];case 5:return t.sent(),[3,7];case 6:du("SyncEngine","Cannot apply mutation batch with id: "+n),t.label=7;case 7:return[2]}})})},lc.prototype.pc=function(r){return f(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:this._l("applySuccessfulWrite()"),e=r.batch.batchId,this.Rl(e,null),this.Al(e),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.Wu.mh(r)];case 2:return n=t.sent(),this.X_.e_(e,"acknowledged"),[4,this.El(n)];case 3:return t.sent(),[3,6];case 4:return[4,pa(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},lc.prototype.vc=function(n,r){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:this._l("rejectFailedWrite()"),this.Rl(n,r),this.Al(n),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.Wu.Ah(n)];case 2:return e=t.sent(),this.X_.e_(n,"rejected",r),[4,this.El(e)];case 3:return t.sent(),[3,6];case 4:return[4,pa(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},lc.prototype.Pl=function(r){return f(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return this.W_.Ju()||du("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),[4,this.Wu.gh()];case 1:return-1===(e=t.sent())?[2,void r.resolve()]:((n=this.al.get(e)||[]).push(r),this.al.set(e,n),[2])}})})},lc.prototype.Al=function(t){(this.al.get(t)||[]).forEach(function(t){t.resolve()}),this.al.delete(t)},lc.prototype.Vl=function(e){this.al.forEach(function(t){t.forEach(function(t){t.reject(new Mr(Ur.CANCELLED,e))})}),this.al.clear()},lc.prototype.ml=function(t,e){var n=this.hl[this.currentUser.s()];n=(n=n||new hi(Eu)).it(t,e),this.hl[this.currentUser.s()]=n},lc.prototype.Rl=function(t,e){var n=this.hl[this.currentUser.s()];if(n){var r=n.get(t);r&&(e?r.reject(e):r.resolve(),n=n.remove(t)),this.hl[this.currentUser.s()]=n}},lc.prototype.Tl=function(t,e){var n=this;void 0===e&&(e=null),this.X_.r_(t);for(var r=0,i=this.sl.get(t);r<i.length;r++){var o=i[r];this.el.delete(o),e&&this.tl.gl(o,e)}if(this.sl.delete(t),this.isPrimary){var s=this.ol.$i(t);this.ol.Ni(t),s.forEach(function(t){n.ol.Mi(t)||n.pl(t)})}},lc.prototype.pl=function(t){var e=this.il.get(t);null!==e&&(this.W_.fc(e),this.il=this.il.remove(t),this.rl.delete(e),this.Il())},lc.prototype.fl=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof zh?(this.ol.vi(i.key,t),this.yl(i)):i instanceof Kh?(du("SyncEngine","Document no longer in limbo: "+i.key),this.ol.Di(i.key,t),this.ol.Mi(i.key)||this.pl(i.key)):mu("Unknown limbo change: "+JSON.stringify(i))}},lc.prototype.yl=function(t){var e=t.key;this.il.get(e)||(du("SyncEngine","New document in limbo: "+e),this.nl.push(e),this.Il())},lc.prototype.Il=function(){for(;0<this.nl.length&&this.il.size<this.Z_;){var t=this.nl.shift(),e=this.ul.next();this.rl.set(e,new Hh(t)),this.il=this.il.it(t,e),this.W_.listen(new bs(Uo.ve(t.path).xe(),e,2,Uu.kr))}},lc.prototype.bl=function(){return this.il},lc.prototype.vl=function(){return this.nl},lc.prototype.El=function(r,a){return f(this,void 0,void 0,function(){var o,s,e,u=this;return y(this,function(t){switch(t.label){case 0:return o=[],s=[],e=[],this.el.forEach(function(t,i){e.push(Promise.resolve().then(function(){var n=i.view.k_(r);return n.M_?u.Wu.Kh(i.query,!1).then(function(t){var e=t.documents;return i.view.k_(e,n)}):n}).then(function(t){var e=a&&a.Ts.get(i.targetId),n=i.view.nr(t,!0===u.isPrimary,e);if(u.fl(i.targetId,n.x_),n.snapshot){u.isPrimary&&u.X_.a_(i.targetId,n.snapshot.fromCache?"not-current":"current"),o.push(n.snapshot);var r=Cu.br(i.targetId,n.snapshot);s.push(r)}}))}),[4,Promise.all(e)];case 1:return t.sent(),this.tl.du(o),[4,this.Wu.Lh(s)];case 2:return t.sent(),[2]}})})},lc.prototype._l=function(t){},lc.prototype.Dc=function(r){return f(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.Vl("'waitForPendingWrites' promise is rejected due to a user change."),[4,this.Wu.oh(r)]):[3,3];case 1:return n=t.sent(),this.X_.oh(r,n.uh,n._h),[4,this.El(n.ah)];case 2:t.sent(),t.label=3;case 3:return[4,this.W_.Dc()];case 4:return t.sent(),[2]}})})},lc.prototype.Cc=function(h){return f(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a=this;return y(this,function(t){switch(t.label){case 0:return!0!==h||!0===this.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.W_.Cc(!0)]);case 1:return t.sent(),e=this.X_.Yc(),[4,this.Sl(e.j())];case 2:for(n=t.sent(),r=0,i=n;r<i.length;r++)o=i[r],this.W_.listen(o);return[3,7];case 3:return!1!==h||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,s=[],u=Promise.resolve(),this.sl.forEach(function(t,e){a.X_.o_(e)?s.push(e):u=u.then(function(){return a.Tl(e),a.Wu.jh(e,!0)}),a.W_.fc(e)}),[4,u]);case 4:return t.sent(),[4,this.Sl(s)];case 5:return t.sent(),this.Dl(),[4,this.W_.Cc(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},lc.prototype.Dl=function(){var n=this;this.rl.forEach(function(t,e){n.W_.fc(e)}),this.ol.Fi(),this.rl=new Map,this.il=new hi(ui.F)},lc.prototype.Sl=function(d){return f(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,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,(u=this.sl.get(o))&&0!==u.length?[4,this.Wu.jh(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.Wu.Uh(u[0].xe())];case 3:s=t.sent(),a=0,h=u,t.label=4;case 4:return a<h.length?(c=h[a],f=this.el.get(c),[4,this.dl(f)]):[3,7];case 5:(l=t.sent()).snapshot&&n.push(l.snapshot),t.label=6;case 6:return a++,[3,4];case 7:return[3,12];case 8:return[4,this.Wu.ta(o)];case 9:return p=t.sent(),[4,this.Wu.Uh(p)];case 10:return s=t.sent(),[4,this.ll(this.Cl(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[2,(this.tl.du(n),e)]}})})},lc.prototype.Cl=function(t){return new Uo(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)},lc.prototype.Jh=function(){return this.Wu.Jh()},lc.prototype.R_=function(r,i,o){return f(this,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return this.isPrimary?(du("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!this.sl.has(r))return[3,8];switch(i){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,this.Wu.ea()];case 3:return e=t.sent(),n=Bs.Is(r,"current"===i),[4,this.El(e,n)];case 4:return t.sent(),[3,8];case 5:return[4,this.Wu.jh(r,!0)];case 6:return t.sent(),this.Tl(r,o),[3,8];case 7:mu("Unexpected target state: "+i),t.label=8;case 8:return[2]}})})},lc.prototype.A_=function(l,p){return f(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h,c,f=this;return y(this,function(t){switch(t.label){case 0:if(!this.isPrimary)return[3,10];e=0,n=l,t.label=1;case 1:return e<n.length?(r=n[e],[4,this.Wu.ta(r)]):[3,6];case 2:return i=t.sent(),[4,this.Wu.Uh(i)];case 3:return o=t.sent(),[4,this.ll(this.Cl(i),o.targetId,!1)];case 4:t.sent(),this.W_.listen(o),t.label=5;case 5:return e++,[3,1];case 6:s=function(e){return y(this,function(t){switch(t.label){case 0:return u.sl.has(e)?[4,u.Wu.jh(e,!1).then(function(){f.W_.fc(e),f.Tl(e)}).catch(pa)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})},u=this,a=0,h=p,t.label=7;case 7:return a<h.length?(c=h[a],[5,s(c)]):[3,10];case 8:t.sent(),t.label=9;case 9:return a++,[3,7];case 10:return[2]}})})},lc.prototype.enableNetwork=function(){return this.Wu.Zh(!0),this.W_.enableNetwork()},lc.prototype.disableNetwork=function(){return this.Wu.Zh(!1),this.W_.disableNetwork()},lc.prototype.an=function(t){var e=this.rl.get(t);if(e&&e.Y_)return Vs().add(e.key);var n=Vs(),r=this.sl.get(t);if(!r)return n;for(var i=0,o=r;i<o.length;i++){var s=o[i],u=this.el.get(s);n=n.Ft(u.view.C_)}return n},lc),sc=(fc.prototype.listen=function(t){var e=t.query,n=!1,r=this.Fl.get(e);return r||(n=!0,r=new Yh,this.Fl.set(e,r)),r.Nl.push(t),t.B_(this.onlineState),r.kl&&t.Ml(r.kl)&&this.Ll(),n?this.mc.listen(e).then(function(t){return r.targetId=t}):Promise.resolve(r.targetId)},fc.prototype.fc=function(o){return f(this,void 0,void 0,function(){var e,n,r,i;return y(this,function(t){return e=o.query,n=!1,(r=this.Fl.get(e))&&0<=(i=r.Nl.indexOf(o))&&(r.Nl.splice(i,1),n=0===r.Nl.length),n?[2,(this.Fl.delete(e),this.mc.fc(e))]:[2]})})},fc.prototype.du=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,s=this.Fl.get(o);if(s){for(var u=0,a=s.Nl;u<a.length;u++)a[u].Ml(i)&&(e=!0);s.kl=i}}e&&this.Ll()},fc.prototype.gl=function(t,e){var n=this.Fl.get(t);if(n)for(var r=0,i=n.Nl;r<i.length;r++)i[r].onError(e);this.Fl.delete(t)},fc.prototype.wl=function(i){this.onlineState=i;var o=!1;this.Fl.forEach(function(t,e){for(var n=0,r=e.Nl;n<r.length;n++)r[n].B_(i)&&(o=!0)}),o&&this.Ll()},fc.prototype.Ol=function(t){this.$l.add(t),t.next()},fc.prototype.xl=function(t){this.$l.delete(t)},fc.prototype.Ll=function(){this.$l.forEach(function(t){t.next()})},fc),uc=(cc.prototype.Ml=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new Gs(t.query,t.docs,t.cs,e,t._s,t.fromCache,t.ls,!0)}var o=!1;return this.Ul?this.Ql(t)&&(this.Bl.next(t),o=!0):this.Wl(t,this.onlineState)&&(this.jl(t),o=!0),this.ql=t,o},cc.prototype.onError=function(t){this.Bl.error(t)},cc.prototype.B_=function(t){this.onlineState=t;var e=!1;return this.ql&&!this.Ul&&this.Wl(this.ql,t)&&(this.jl(this.ql),e=!0),e},cc.prototype.Wl=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.Kl&&n||t.docs.U()&&"Offline"!==e)},cc.prototype.Ql=function(t){if(0<t.docChanges.length)return!0;var e=this.ql&&this.ql.hasPendingWrites!==t.hasPendingWrites;return!(!t.ls&&!e)&&!0===this.options.includeMetadataChanges},cc.prototype.jl=function(t){t=Gs.fs(t.query,t.docs,t._s,t.fromCache),this.Ul=!0,this.Bl.next(t)},cc),ac=(hc.prototype.ih=function(t){this.Gl=t},hc.prototype.wr=function(e,r,i,o){var s=this;return r.Oe()||i.isEqual(zr.MIN)?this.zl(e,r):this.Gl.Tr(e,o).next(function(t){var n=s.Hl(r,t);return(r.je()||r.Ke())&&s.M_(r.ge,n,o,i)?s.zl(e,r):(lu()<=l.DEBUG&&du("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),s.Gl.wr(e,r,i).next(function(e){return n.forEach(function(t){e=e.it(t.key,t)}),e}))})},hc.prototype.Hl=function(n,t){var r=new vi(function(t,e){return n.Be(t,e)});return t.forEach(function(t,e){e instanceof Oo&&n.matches(e)&&(r=r.add(e))}),r},hc.prototype.M_=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||0<i.version.D(r))},hc.prototype.zl=function(t,e){return lu()<=l.DEBUG&&du("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.Gl.wr(t,e,zr.MIN)},hc);function hc(){}function cc(t,e,n){this.query=t,this.Bl=e,this.Ul=!1,this.ql=null,this.onlineState="Unknown",this.options=n||{}}function fc(t){this.mc=t,this.Fl=new _u(function(t){return t.canonicalId()}),this.onlineState="Unknown",this.$l=new Set,this.mc.subscribe(this)}function lc(t,e,n,r,i){this.Wu=t,this.W_=e,this.X_=n,this.currentUser=r,this.Z_=i,this.tl=null,this.el=new _u(function(t){return t.canonicalId()}),this.sl=new Map,this.nl=[],this.il=new hi(ui.F),this.rl=new Map,this.ol=new ku,this.hl={},this.al=new Map,this.ul=nc.y_(),this.isPrimary=void 0,this.onlineState="Unknown"}function pc(t,e,n,r){this.Nr=t,this.W_=e,this.updateFunction=n,this.Lr=r,this.j_=5,this.Ja=new Ah(this.Nr,"retry_transaction")}function dc(t,e){this.query=t,this.b_=e,this.v_=null,this.As=!1,this.S_=Vs(),this._s=Vs(),this.D_=new js(t.Be.bind(t))}function yc(t){this.g_=t}function vc(){this.P_=new $h,this.V_={},this.mc=null,this.$u=null,this.vr=null}function mc(t,e,n,r,i){if(this.$a=t,this.platform=e,this.persistenceKey=n,this.Mc=r,this.mc=null,this.$u=null,this.vr=null,this.Lc={},this.Oc=this.xc.bind(this),this.ko=!1,this.Bc=[],!mc.Uc(this.platform))throw new Mr(Ur.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.qc=qh(this.persistenceKey,this.Mc),this.Qc="firestore_sequence_number_"+this.persistenceKey,this.Lc[this.Mc]=new $h,this.Wc=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.jc=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.Kc=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Gc="firestore_online_state_"+this.persistenceKey,this.platform.window.addEventListener("storage",this.Oc)}function gc(){this.activeTargetIds=Cs()}function wc(t,e){this.clientId=t,this.onlineState=e}function bc(t,e){this.clientId=t,this.activeTargetIds=e}function Ec(t,e,n){this.targetId=t,this.state=e,this.error=n}function Tc(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}function Ic(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Ac(e)),e=Nc(t.get(n),e);return Ac(e)}function Nc(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="";break;case"":n+="";break;default:n+=o}}return n}function Ac(t){return t+""}function _c(t){var e=t.length;if(gu(2<=e,"Invalid path "+t),2===e)return gu(""===t.charAt(0)&&""===t.charAt(1),"Non-empty path "+t+" had length 2"),ti.H;for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("",o);switch((s<0||n<s)&&mu('Invalid encoded resource path: "'+t+'"'),t.charAt(s+1)){case"":var u=t.substring(o,s),a=void 0;0===i.length?a=u:(a=i+=u,i=""),r.push(a);break;case"":i+=t.substring(o,s),i+="\0";break;case"":i+=t.substring(o,s+1);break;default:mu('Invalid encoded resource path: "'+t+'"')}o=s+2}return new ti(r)}var Sc=(Vc.Yl=function(o,t,s){return du("SimpleDb","Opening database:",o),new Ru(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new Vc(e))},i.onblocked=function(){r(new Mr(Ur.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 Mr(Ur.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){du("SimpleDb",'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;s.createOrUpgrade(e,i.transaction,t.oldVersion,hf).next(function(){du("SimpleDb","Database upgrade to version "+hf+" complete")})}}).Wi()},Vc.delete=function(t){return du("SimpleDb","Removing database:",t),Pc(window.indexedDB.deleteDatabase(t)).Wi()},Vc.Uc=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(Vc.Xl())return!0;if(void 0===window.navigator)return!1;var t=p(),e=Vc.Jl(t),n=0<e&&e<10,r=Vc.Zl(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},Vc.Xl=function(){var t;return"undefined"!=typeof __PRIVATE_process&&"YES"===(null===(t=__PRIVATE_process.__PRIVATE_env)||void 0===t?void 0:t.td)},Vc.ed=function(t,e){return t.store(e)},Vc.Jl=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)},Vc.Zl=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},Vc.prototype.sd=function(e){this.db.onversionchange=function(t){return e(t)}},Vc.prototype.runTransaction=function(r,h,c){return f(this,void 0,void 0,function(){var s,u,e,a,n;return y(this,function(t){switch(t.label){case 0:s="readonly"===r,u=0,e=function(){var e,n,r,i,o;return y(this,function(t){switch(t.label){case 0:++u,e=kc.open(a.db,s?"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),Ru.reject(t)}).Wi(),r={},n.catch(function(){}),[4,e.nd];case 2:return[2,(r.value=(t.sent(),n),r)];case 3:return i=t.sent(),o="FirebaseError"!==i.name&&u<3,du("SimpleDb","Transaction failed with error: %s. Retrying: %s.",i.message,o),o?[3,4]:[2,{value:Promise.reject(i)}];case 4:return[2]}})},a=this,t.label=1;case 1:return[5,e()];case 2:if("object"==typeof(n=t.sent()))return[2,n.value];t.label=3;case 3:return[3,1];case 4:return[2]}})})},Vc.prototype.close=function(){this.db.close()},Vc),Dc=(Object.defineProperty(Oc.prototype,"Bi",{get:function(){return this.od},enumerable:!0,configurable:!0}),Object.defineProperty(Oc.prototype,"ad",{get:function(){return this.hd},enumerable:!0,configurable:!0}),Object.defineProperty(Oc.prototype,"cursor",{set:function(t){this.rd=t},enumerable:!0,configurable:!0}),Oc.prototype.done=function(){this.od=!0},Oc.prototype.ud=function(t){this.hd=t},Oc.prototype.delete=function(){return Pc(this.rd.delete())},Oc),kc=(Lc.open=function(t,e,n){return new Lc(t.transaction(n,e))},Object.defineProperty(Lc.prototype,"nd",{get:function(){return this._d.promise},enumerable:!0,configurable:!0}),Lc.prototype.abort=function(t){t&&this._d.reject(t),this.aborted||(du("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},Lc.prototype.store=function(t){var e=this.transaction.objectStore(t);return new xc(e)},Lc),xc=(Rc.prototype.put=function(t,e){return Pc(void 0!==e?(du("SimpleDb","PUT",this.store.name,t,e),this.store.put(e,t)):(du("SimpleDb","PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},Rc.prototype.add=function(t){return du("SimpleDb","ADD",this.store.name,t,t),Pc(this.store.add(t))},Rc.prototype.get=function(e){var n=this;return Pc(this.store.get(e)).next(function(t){return void 0===t&&(t=null),du("SimpleDb","GET",n.store.name,e,t),t})},Rc.prototype.delete=function(t){return du("SimpleDb","DELETE",this.store.name,t),Pc(this.store.delete(t))},Rc.prototype.count=function(){return du("SimpleDb","COUNT",this.store.name),Pc(this.store.count())},Rc.prototype.ld=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.dd(n,function(t,e){r.push(e)}).next(function(){return r})},Rc.prototype.fd=function(t,e){du("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Td=!1;var r=this.cursor(n);return this.dd(r,function(t,e,n){return n.delete()})},Rc.prototype.md=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.dd(r,e)},Rc.prototype.Ed=function(i){var t=this.cursor({});return new Ru(function(n,r){t.onerror=function(t){var e=Uc(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()}})},Rc.prototype.dd=function(t,s){var u=[];return new Ru(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 Dc(e),r=s(e.primaryKey,e.value,n);if(r instanceof Ru){var i=r.catch(function(t){return n.done(),Ru.reject(t)});u.push(i)}n.Bi?o():null===n.ad?e.continue():e.continue(n.ad)}else o()}}).next(function(){return Ru.Ki(u)})},Rc.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},Rc.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Td?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},Rc);function Rc(t){this.store=t}function Lc(t){var n=this;this.transaction=t,this.aborted=!1,this._d=new Ju,this.transaction.oncomplete=function(){n._d.resolve()},this.transaction.onabort=function(){t.error?n._d.reject(t.error):n._d.resolve()},this.transaction.onerror=function(t){var e=Uc(t.target.error);n._d.reject(e)}}function Oc(t){this.rd=t,this.od=!1,this.hd=null}function Vc(t){this.db=t,12.2===Vc.Jl(p())&&yu("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 Pc(t){return new Ru(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=Uc(t.target.error);r(e)}})}var Cc=!1;function Uc(t){var e=Sc.Jl(p());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 Mr("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 Cc||(Cc=!0,setTimeout(function(){throw r},0)),r}}return t}var Mc=(Fc.Id=function(t,e,n,r){return gu(""!==t.uid,"UserID must not be an empty string."),new Fc(t.t()?t.uid:"",e,n,r)},Fc.prototype.Rd=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Gc(t).md({index:vf.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},Fc.prototype.mh=function(e,t,n){return this.Ad(e).next(function(t){return t.lastStreamToken=n.toBase64(),zc(e).put(t)})},Fc.prototype.ph=function(t){return this.Ad(t).next(function(t){return Ii.fromBase64String(t.lastStreamToken)})},Fc.prototype.yh=function(e,n){return this.Ad(e).next(function(t){return t.lastStreamToken=n.toBase64(),zc(e).put(t)})},Fc.prototype.dh=function(h,c,f,l){var p=this,d=Bc(h),y=Gc(h);return y.add({}).next(function(t){gu("number"==typeof t,"Auto-generated key is not a number");for(var e=new Su(t,c,f,l),n=p.serializer.Pd(p.userId,e),r=[],i=new vi(function(t,e){return Eu(t.K(),e.K())}),o=0,s=l;o<s.length;o++){var u=s[o],a=mf.key(p.userId,u.key.path,t);i=i.add(u.key.path.L()),r.push(y.put(n)),r.push(d.put(a,mf.PLACEHOLDER))}return i.forEach(function(t){r.push(p.ur.Vd(h,t))}),h.rr(function(){p.wd[t]=e.keys()}),Ru.Ki(r).next(function(){return e})})},Fc.prototype.Ph=function(t,e){var n=this;return Gc(t).get(e).next(function(t){return t?(gu(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.gd(t)):null})},Fc.prototype.Th=function(t,n){var r=this;return this.wd[n]?Ru.resolve(this.wd[n]):this.Ph(t,n).next(function(t){if(t){var e=t.keys();return r.wd[n]=e}return null})},Fc.prototype.xh=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return Gc(t).md({index:vf.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(gu(e.batchId>=i,"Should have found mutation after "+i),o=r.serializer.gd(e)),n.done()}).next(function(){return o})},Fc.prototype.gh=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return Gc(t).md({index:vf.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},Fc.prototype.hh=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Gc(t).ld(vf.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.gd(t)})})},Fc.prototype._r=function(u,a){var h=this,t=mf.prefixForPath(this.userId,a.path),e=IDBKeyRange.lowerBound(t),c=[];return Bc(u).md({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],s=_c(i);if(r===h.userId&&a.path.isEqual(s))return Gc(u).get(o).next(function(t){if(!t)throw mu("Dangling document-mutation reference found: "+e+" which points to "+o);gu(t.userId===h.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),c.push(h.serializer.gd(t))});n.done()}).next(function(){return c})},Fc.prototype.Er=function(r,t){var a=this,h=new vi(Eu),i=[];return t.forEach(function(u){var t=mf.prefixForPath(a.userId,u.path),e=IDBKeyRange.lowerBound(t),n=Bc(r).md({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=_c(i);r===a.userId&&u.path.isEqual(s)?h=h.add(o):n.done()});i.push(n)}),Ru.Ki(i).next(function(){return a.pd(r,h)})},Fc.prototype.Vr=function(t,e){var u=this,a=e.path,h=a.length+1,n=mf.prefixForPath(this.userId,a),r=IDBKeyRange.lowerBound(n),c=new vi(Eu);return Bc(t).md({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=_c(i);r===u.userId&&a.q(s)?s.length===h&&(c=c.add(o)):n.done()}).next(function(){return u.pd(t,c)})},Fc.prototype.pd=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(Gc(t).get(e).next(function(t){if(null===t)throw mu("Dangling document-mutation reference found, which points to "+e);gu(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.gd(t))}))}),Ru.Ki(i).next(function(){return r})},Fc.prototype.Vh=function(e,n){var r=this;return qc(e.yd,this.userId,n).next(function(t){return e.rr(function(){r.Xh(n.batchId)}),Ru.forEach(t,function(t){return r.Jo.bd(e,t)})})},Fc.prototype.Xh=function(t){delete this.wd[t]},Fc.prototype.Rh=function(n){var o=this;return this.Rd(n).next(function(t){if(!t)return Ru.resolve();var e=IDBKeyRange.lowerBound(mf.prefixForUser(o.userId)),i=[];return Bc(n).md({range:e},function(t,e,n){if(t[0]===o.userId){var r=_c(t[1]);i.push(r)}else n.done()}).next(function(){gu(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.K()}))})})},Fc.prototype.Mi=function(t,e){return jc(t,this.userId,e)},Fc.prototype.Ad=function(t){var e=this;return zc(t).get(this.userId).next(function(t){return t||new yf(e.userId,-1,"")})},Fc);function Fc(t,e,n,r){this.userId=t,this.serializer=e,this.ur=n,this.Jo=r,this.wd={}}function jc(t,o,e){var n=mf.prefixForPath(o,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),u=!1;return Bc(t).md({range:r,Td:!0},function(t,e,n){var r=t[0],i=t[1];t[2],r===o&&i===s&&(u=!0),n.done()}).next(function(){return u})}function qc(t,e,n){var r=t.store(vf.store),i=t.store(mf.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.md({range:s},function(t,e,n){return u++,n.delete()});o.push(a.next(function(){gu(1===u,"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=mf.key(e,l.key.path,n.batchId);o.push(i.delete(p)),h.push(l.key)}return Ru.Ki(o).next(function(){return h})}function Gc(t){return Uf.ed(t,vf.store)}function Bc(t){return Uf.ed(t,mf.store)}function zc(t){return Uf.ed(t,yf.store)}var Kc=(Wc.prototype.Qh=function(n){var r=this;return this.vd(n).next(function(t){var e=new nc(t.highestTargetId);return t.highestTargetId=e.next(),r.Sd(n,t).next(function(){return t.highestTargetId})})},Wc.prototype.bh=function(t){return this.vd(t).next(function(t){return zr.v(new Br(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},Wc.prototype.Dd=function(t){return Xc(t.yd)},Wc.prototype.$h=function(e,n,r){var i=this;return this.vd(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.k()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.Sd(e,t)})},Wc.prototype.Wh=function(e,n){var r=this;return this.Cd(e,n).next(function(){return r.vd(e).next(function(t){return t.targetCount+=1,r.kd(n,t),r.Sd(e,t)})})},Wc.prototype.Nh=function(t,e){return this.Cd(t,e)},Wc.prototype.Nd=function(e,t){var n=this;return this.Fd(e,t.targetId).next(function(){return Hc(e).delete(t.targetId)}).next(function(){return n.vd(e)}).next(function(t){return gu(0<t.targetCount,"Removing from an empty target cache"),--t.targetCount,n.Sd(e,t)})},Wc.prototype.xo=function(r,i,o){var s=this,u=0,a=[];return Hc(r).md(function(t,e){var n=s.serializer.$d(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(u++,a.push(s.Nd(r,n)))}).next(function(){return Ru.Ki(a)}).next(function(){return u})},Wc.prototype.Xs=function(t,r){var i=this;return Hc(t).md(function(t,e){var n=i.serializer.$d(e);r(n)})},Wc.prototype.vd=function(t){return Yc(t.yd)},Wc.prototype.Sd=function(t,e){return Uf.ed(t,Af.store).put(Af.key,e)},Wc.prototype.Cd=function(t,e){return Hc(t).put(this.serializer.Md(e))},Wc.prototype.kd=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},Wc.prototype.Ld=function(t){return this.vd(t).next(function(t){return t.targetCount})},Wc.prototype.qh=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),s=null;return Hc(t).md({range:n,index:If.queryTargetsIndexName},function(t,e,n){var r=o.serializer.$d(e);i.isEqual(r.target)&&(s=r,n.done())}).next(function(){return s})},Wc.prototype.Dh=function(n,t,r){var i=this,o=[],s=Jc(n);return t.forEach(function(t){var e=Ic(t.path);o.push(s.put(new Nf(r,e))),o.push(i.Jo.vi(n,t))}),Ru.Ki(o)},Wc.prototype.Sh=function(n,t,r){var i=this,o=Jc(n);return Ru.forEach(t,function(t){var e=Ic(t.path);return Ru.Ki([o.delete([r,e]),i.Jo.Di(n,t)])})},Wc.prototype.Fd=function(t,e){var n=Jc(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},Wc.prototype.Gh=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Jc(t),o=Vs();return r.md({range:n,Td:!0},function(t,e,n){var r=_c(t[1]),i=new ui(r);o=o.add(i)}).next(function(){return o})},Wc.prototype.Mi=function(t,e){var n=Ic(e.path),r=IDBKeyRange.bound([n],[Iu(n)],!1,!0),i=0;return Jc(t).md({index:Nf.documentTargetsIndex,Td:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},Wc.prototype.un=function(t,e){var n=this;return Hc(t).get(e).next(function(t){return t?n.serializer.$d(t):null})},Wc);function Wc(t,e){this.Jo=t,this.serializer=e}function Hc(t){return Uf.ed(t,If.store)}function Yc(t){return Sc.ed(t,Af.store).get(Af.key).next(function(t){return gu(null!==t,"Missing metadata row."),t})}function Xc(t){return Yc(t).next(function(t){return t.highestListenSequenceNumber})}function Jc(t){return Uf.ed(t,Nf.store)}var Qc,Zc=($c.prototype.Yi=function(t,e,n){return ef(t).put(nf(e),n)},$c.prototype.Zi=function(t,e){var n=ef(t),r=nf(e);return n.delete(r)},$c.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.Od(e,t)})},$c.prototype.tr=function(t,e){var n=this;return ef(t).get(nf(e)).next(function(t){return n.xd(t)})},$c.prototype.Bd=function(t,e){var n=this;return ef(t).get(nf(e)).next(function(t){var e=n.xd(t);return e?{Ud:e,size:rf(t)}:null})},$c.prototype.getEntries=function(t,e){var r=this,i=Ds();return this.qd(t,e,function(t,e){var n=r.xd(e);i=i.it(t,n)}).next(function(){return i})},$c.prototype.Qd=function(t,e){var r=this,i=Ds(),o=new hi(ui.F);return this.qd(t,e,function(t,e){var n=r.xd(e);o=n?(i=i.it(t,n),o.it(t,rf(e))):(i=i.it(t,null),o.it(t,0))}).next(function(){return{Wd:i,jd:o}})},$c.prototype.qd=function(t,e,i){if(e.U())return Ru.resolve();var n=IDBKeyRange.bound(e.first().path.j(),e.last().path.j()),o=e._t(),s=o.wt();return ef(t).md({range:n},function(t,e,n){for(var r=ui.nt(t);s&&ui.F(s,r)<0;)i(s,null),s=o.wt();s&&s.isEqual(r)&&(i(s,e),s=o.It()?o.wt():null),s?n.ud(s.path.j()):n.done()}).next(function(){for(;s;)i(s,null),s=o.It()?o.wt():null})},$c.prototype.wr=function(t,i,e){var o=this,s=xs(),u=i.path.length+1,n={};if(e.isEqual(zr.MIN)){var r=i.path.j();n.range=IDBKeyRange.lowerBound(r)}else{var a=i.path.j(),h=this.serializer.Kd(e);n.range=IDBKeyRange.lowerBound([a,h],!0),n.index=Ef.collectionReadTimeIndex}return ef(t).md(n,function(t,e,n){if(t.length===u){var r=o.serializer.Gd(e);i.path.q(r.key.path)?r instanceof Oo&&i.matches(r)&&(s=s.it(r.key,r)):n.done()}}).next(function(){return s})},$c.prototype.ea=function(t,e){var r=this,i=Ss(),o=this.serializer.Kd(e),n=ef(t),s=IDBKeyRange.lowerBound(o,!0);return n.md({index:Ef.readTimeIndex,range:s},function(t,e){var n=r.serializer.Gd(e);i=i.it(n.key,n),o=e.readTime}).next(function(){return{sa:i,readTime:r.serializer.zd(o)}})},$c.prototype.na=function(t){var r=this,e=ef(t),i=zr.MIN;return e.md({index:Ef.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(i=r.serializer.zd(e.readTime)),n.done()}).next(function(){return i})},$c.prototype.Eh=function(t){return new $c.Hd(this,!!t&&t.wh)},$c.prototype.Jd=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},$c.prototype.getMetadata=function(t){return tf(t).get(Tf.key).next(function(t){return gu(!!t,"Missing document cache metadata"),t})},$c.prototype.Od=function(t,e){return tf(t).put(Tf.key,e)},$c.prototype.xd=function(t){if(t){var e=this.serializer.Gd(t);return e instanceof Vo&&e.version.isEqual(zr.S())?null:e}return null},$c);function $c(t,e){this.serializer=t,this.ur=e}function tf(t){return Uf.ed(t,Tf.store)}function ef(t){return Uf.ed(t,Ef.store)}function nf(t){return t.path.j()}function rf(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw mu("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}function of(t,e){var n=this;return(n=Qc.call(this)||this).Yd=t,n.wh=e,n.Xd=new _u(function(t){return t.toString()}),n}Zc.Hd=(n(of,Qc=Lu),of.prototype.nr=function(s){var u=this,a=[],h=0,c=new vi(function(t,e){return Eu(t.K(),e.K())});return this.zi.forEach(function(t,e){var n=u.Xd.get(t);if(e){var r=u.Yd.serializer.Zd(e,u.readTime);c=c.add(t.path.L());var i=rf(r);h+=i-n,a.push(u.Yd.Yi(s,t,r))}else if(h-=n,u.wh){var o=u.Yd.serializer.Zd(new Vo(t,zr.S()),u.readTime);a.push(u.Yd.Yi(s,t,o))}else a.push(u.Yd.Zi(s,t))}),c.forEach(function(t){a.push(u.Yd.ur.Vd(s,t))}),a.push(this.Yd.updateMetadata(s,h)),Ru.Ki(a)},of.prototype.er=function(t,e){var n=this;return this.Yd.Bd(t,e).next(function(t){return null===t?(n.Xd.set(e,0),null):(n.Xd.set(e,t.size),t.Ud)})},of.prototype.sr=function(t,e){var n=this;return this.Yd.Qd(t,e).next(function(t){var e=t.Wd;return t.jd.forEach(function(t,e){n.Xd.set(t,e)}),e})},of);function sf(t,e){this.seconds=t,this.nanoseconds=e}var uf=(df.prototype.Vd=function(t,e){return this.tf.add(e),Ru.resolve()},df.prototype.Pr=function(t,e){return Ru.resolve(this.tf.getEntries(e))},df),af=(pf.prototype.add=function(t){var e=t.B(),n=t.L(),r=this.index[e]||new vi(ti.F),i=!r.has(n);return this.index[e]=r.add(n),i},pf.prototype.has=function(t){var e=t.B(),n=t.L(),r=this.index[e];return r&&r.has(n)},pf.prototype.getEntries=function(t){return(this.index[t]||new vi(ti.F)).j()},pf),hf=10,cf=(lf.prototype.createOrUpgrade=function(n,r,t,e){var i=this;gu(t<e&&0<=t&&e<=hf,"Unexpected schema upgrade from v"+t+" to v"+e+".");var o,s=new kc(r);t<1&&1<=e&&(n.createObjectStore(ff.store),(o=n).createObjectStore(yf.store,{keyPath:yf.keyPath}),o.createObjectStore(vf.store,{keyPath:vf.keyPath,autoIncrement:!0}).createIndex(vf.userMutationsIndex,vf.userMutationsKeyPath,{unique:!0}),o.createObjectStore(mf.store),Sf(n),n.createObjectStore(Ef.store));var u,a=Ru.resolve();return t<3&&3<=e&&(0!==t&&((u=n).deleteObjectStore(Nf.store),u.deleteObjectStore(If.store),u.deleteObjectStore(Af.store),Sf(n)),a=a.next(function(){return t=s.store(Af.store),e=new Af(0,0,zr.MIN.k(),0),t.put(Af.key,e);var t,e})),t<4&&4<=e&&(0!==t&&(a=a.next(function(){return r=n,(i=s).store(vf.store).ld().next(function(t){r.deleteObjectStore(vf.store),r.createObjectStore(vf.store,{keyPath:vf.keyPath,autoIncrement:!0}).createIndex(vf.userMutationsIndex,vf.userMutationsKeyPath,{unique:!0});var e=i.store(vf.store),n=t.map(function(t){return e.put(t)});return Ru.Ki(n)});var r,i})),a=a.next(function(){n.createObjectStore(Df.store,{keyPath:Df.keyPath})})),t<5&&5<=e&&(a=a.next(function(){return i.removeAcknowledgedMutations(s)})),t<6&&6<=e&&(a=a.next(function(){return n.createObjectStore(Tf.store),i.addDocumentGlobal(s)})),t<7&&7<=e&&(a=a.next(function(){return i.ensureSequenceNumbers(s)})),t<8&&8<=e&&(a=a.next(function(){return i.createCollectionParentIndex(n,s)})),t<9&&9<=e&&(a=a.next(function(){var t,e;(e=n).objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges"),(t=r.objectStore(Ef.store)).createIndex(Ef.readTimeIndex,Ef.readTimeIndexPath,{unique:!1}),t.createIndex(Ef.collectionReadTimeIndex,Ef.collectionReadTimeIndexPath,{unique:!1})})),t<10&&10<=e&&(a=a.next(function(){return i.rewriteCanonicalIds(s)})),a},lf.prototype.addDocumentGlobal=function(e){var n=0;return e.store(Ef.store).md(function(t,e){n+=rf(e)}).next(function(){var t=new Tf(n);return e.store(Tf.store).put(Tf.key,t)})},lf.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(yf.store),e=r.store(vf.store);return t.ld().next(function(t){return Ru.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.ld(vf.userMutationsIndex,t).next(function(t){return Ru.forEach(t,function(t){gu(t.userId===n.userId,"Cannot process batch "+t.batchId+" from unexpected user");var e=i.serializer.gd(t);return qc(r,n.userId,e).next(function(){})})})})})},lf.prototype.ensureSequenceNumbers=function(t){var s=t.store(Nf.store),e=t.store(Ef.store);return Xc(t).next(function(i){var o=[];return e.md(function(t,e){var n=new ti(t),r=[0,Ic(n)];o.push(s.get(r).next(function(t){return t?Ru.resolve():(e=n,s.put(new Nf(0,Ic(e),i)));var e}))}).next(function(){return Ru.Ki(o)})})},lf.prototype.createCollectionParentIndex=function(t,e){function i(t){if(o.add(t)){var e=t.B(),n=t.L();return r.put({collectionId:e,parent:Ic(n)})}}t.createObjectStore(_f.store,{keyPath:_f.keyPath});var r=e.store(_f.store),o=new af;return e.store(Ef.store).md({Td:!0},function(t,e){var n=new ti(t);return i(n.L())}).next(function(){return e.store(mf.store).md({Td:!0},function(t,e){t[0];var n=t[1],r=(t[2],_c(n));return i(r.L())})})},lf.prototype.rewriteCanonicalIds=function(t){var i=this,o=t.store(If.store);return o.md(function(t,e){var n=i.serializer.$d(e),r=i.serializer.Md(n);return o.put(r)})},lf),ff=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};function lf(t){this.serializer=t}function pf(){this.index={}}function df(){this.tf=new af}ff.store="owner",ff.key="owner";var yf=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};yf.store="mutationQueues",yf.keyPath="userId";var vf=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};vf.store="mutations",vf.keyPath="batchId",vf.userMutationsIndex="userMutationsIndex",vf.userMutationsKeyPath=["userId","batchId"];var mf=(gf.prefixForUser=function(t){return[t]},gf.prefixForPath=function(t,e){return[t,Ic(e)]},gf.key=function(t,e,n){return[t,Ic(e),n]},gf);function gf(){}mf.store="documentMutations",mf.PLACEHOLDER=new mf;function wf(t,e){this.path=t,this.readTime=e}function bf(t,e){this.path=t,this.version=e}var Ef=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Ef.store="remoteDocuments",Ef.readTimeIndex="readTimeIndex",Ef.readTimeIndexPath="readTime",Ef.collectionReadTimeIndex="collectionReadTimeIndex",Ef.collectionReadTimeIndexPath=["parentPath","readTime"];var Tf=function(t){this.byteSize=t};Tf.store="remoteDocumentGlobal",Tf.key="remoteDocumentGlobalKey";var If=function(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};If.store="targets",If.keyPath="targetId",If.queryTargetsIndexName="queryTargetsIndex",If.queryTargetsKeyPath=["canonicalId","targetId"];var Nf=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Nf.store="targetDocuments",Nf.keyPath=["targetId","path"],Nf.documentTargetsIndex="documentTargetsIndex",Nf.documentTargetsKeyPath=["path","targetId"];var Af=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Af.key="targetGlobalKey",Af.store="targetGlobal";var _f=function(t,e){this.collectionId=t,this.parent=e};function Sf(t){t.createObjectStore(Nf.store,{keyPath:Nf.keyPath}).createIndex(Nf.documentTargetsIndex,Nf.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(If.store,{keyPath:If.keyPath}).createIndex(If.queryTargetsIndexName,If.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Af.store)}_f.store="collectionParents",_f.keyPath=["collectionId","parent"];var Df=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Df.store="clientMetadata",Df.keyPath="clientId";var kf=i(i(i([yf.store,vf.store,mf.store,Ef.store,If.store,ff.store,Af.store,Nf.store],[Df.store]),[Tf.store]),[_f.store]),xf=(Rf.prototype.Vd=function(t,e){var n=this;if(this.ef.has(e))return Ru.resolve();var r=e.B(),i=e.L();t.rr(function(){n.ef.add(e)});var o={collectionId:r,parent:Ic(i)};return Lf(t).put(o)},Rf.prototype.Pr=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[Iu(i),""],!1,!0);return Lf(t).ld(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(_c(r.parent))}return o})},Rf);function Rf(){this.ef=new af}function Lf(t){return Uf.ed(t,_f.store)}var Of,Vf=(jf.prototype.Gd=function(t){if(t.document)return this.sf.vn(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=ui.nt(t.noDocument.path),n=this.nf(t.noDocument.readTime);return new Vo(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}if(t.unknownDocument){var r=ui.nt(t.unknownDocument.path),i=this.nf(t.unknownDocument.version);return new Po(r,i)}return mu("Unexpected DbRemoteDocument")},jf.prototype.Zd=function(t,e){var n=this.Kd(e),r=t.key.path.L().j();if(t instanceof Oo){var i=this.sf.bn(t),o=t.hasCommittedMutations;return new Ef(null,null,i,o,n,r)}if(t instanceof Vo){var s=t.key.path.j(),u=this.if(t.version),a=t.hasCommittedMutations;return new Ef(null,new wf(s,u),null,a,n,r)}if(t instanceof Po){var h=t.key.path.j(),c=this.if(t.version);return new Ef(new bf(h,c),null,null,!0,n,r)}return mu("Unexpected MaybeDocument")},jf.prototype.Kd=function(t){var e=t.k();return[e.seconds,e.nanoseconds]},jf.prototype.zd=function(t){var e=new Br(t[0],t[1]);return zr.v(e)},jf.prototype.if=function(t){var e=t.k();return new sf(e.seconds,e.nanoseconds)},jf.prototype.nf=function(t){var e=new Br(t.seconds,t.nanoseconds);return zr.v(e)},jf.prototype.Pd=function(t,e){var n=this,r=e.baseMutations.map(function(t){return n.sf.$n(t)}),i=e.mutations.map(function(t){return n.sf.$n(t)});return new vf(t,e.batchId,e.Ri.toMillis(),r,i)},jf.prototype.gd=function(t){var e=this,n=(t.baseMutations||[]).map(function(t){return e.sf.xn(t)}),r=t.mutations.map(function(t){return e.sf.xn(t)}),i=Br.fromMillis(t.localWriteTimeMs);return new Su(t.batchId,i,n,r)},jf.prototype.$d=function(t){var e,n=this.nf(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.nf(t.lastLimboFreeSnapshotVersion):zr.MIN;return e=void 0!==t.query.documents?this.sf.Kn(t.query):this.sf.Yn(t.query),new bs(e,t.targetId,0,t.lastListenSequenceNumber,n,r,Ii.fromBase64String(t.resumeToken))},jf.prototype.Md=function(t){var e,n=this.if(t.ts),r=this.if(t.lastLimboFreeSnapshotVersion);e=t.target.Pe()?this.sf.jn(t.target):this.sf.Gn(t.target);var i=t.resumeToken.toBase64();return new If(t.targetId,t.target.canonicalId(),n,i,t.sequenceNumber,r,e)},jf),Pf="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",Cf=(n(Ff,Of=Vu),Ff),Uf=(Mf.ed=function(t,e){if(t instanceof Cf)return Sc.ed(t.yd,e);throw mu("IndexedDbPersistence must use instances of IndexedDbTransaction")},Mf.mf=function(t){if(!Mf.Uc())throw new Mr(Ur.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return new Mf(t.allowTabSynchronization,t.persistenceKey,t.clientId,t.platform,t.Ef,t.$a,t.serializer,t.rf)},Mf.prototype.start=function(){var e=this;return Sc.Yl(this.df,hf,new cf(this.serializer)).then(function(t){return e.wf=t,e.If()}).then(function(){return e.Rf(),e.Af(),e.Pf(),e.wf.runTransaction("readonly",[Af.store],function(t){return Xc(t)})}).then(function(t){e.Vf=new Uu(t,e.rf)}).then(function(){e.hf=!0}).catch(function(t){return e.wf&&e.wf.close(),Promise.reject(t)})},Mf.prototype.gf=function(n){var t=this;return this.lf=function(e){return f(t,void 0,void 0,function(){return y(this,function(t){return this.ko?[2,n(e)]:[2]})})},n(this.isPrimary)},Mf.prototype.pf=function(n){var t=this;this.wf.sd(function(e){return f(t,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return null===e.newVersion?[4,n()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},Mf.prototype.Zh=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.$a.qr(function(){return f(e,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.ko?[4,this.If()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},Mf.prototype.If=function(){var n=this;return this.wf.runTransaction("readwrite",kf,function(e){return Gf(e).put(new Df(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.yf(e).next(function(t){t||(n.isPrimary=!1,n.$a.qr(function(){return n.lf(!1)}))})}).next(function(){return n.bf(e)}).next(function(t){return n.isPrimary&&!t?n.vf(e).next(function(){return!1}):!!t&&n.Sf(e).next(function(){return!0})})}).catch(function(t){if(!n.allowTabSynchronization)throw t;return du("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.$a.qr(function(){return n.lf(t)}),n.isPrimary=t})},Mf.prototype.yf=function(t){var e=this;return qf(t).get(ff.key).next(function(t){return Ru.resolve(e.Df(t))})},Mf.prototype.Cf=function(t){return Gf(t).delete(this.clientId)},Mf.prototype.kf=function(){return f(this,void 0,void 0,function(){var i=this;return y(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.Nf(this._f,18e5)?[3,2]:(this._f=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var r=Mf.ed(t,Df.store);return r.ld().next(function(t){var e=i.Ff(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return Ru.forEach(n,function(t){return r.delete(t.clientId)}).next(function(){return n})})}).catch(function(){return[]})]);case 1:t.sent().forEach(function(t){i.window.localStorage.removeItem(i.$f(t.clientId))}),t.label=2;case 2:return[2]}})})},Mf.prototype.Pf=function(){var t=this;this.cf=this.$a.eo("client_metadata_refresh",4e3,function(){return t.If().then(function(){return t.kf()}).then(function(){return t.Pf()})})},Mf.prototype.Df=function(t){return!!t&&t.ownerId===this.clientId},Mf.prototype.bf=function(e){var i=this;return qf(e).get(ff.key).next(function(t){if(null!==t&&i.Nf(t.leaseTimestampMs,5e3)&&!i.Mf(t.ownerId)){if(i.Df(t)&&i.networkEnabled)return!0;if(!i.Df(t)){if(!t.allowTabSynchronization)throw new Mr(Ur.FAILED_PRECONDITION,Pf);return!1}}return!(!i.networkEnabled||!i.inForeground)||Gf(e).ld().next(function(t){return void 0===i.Ff(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&&du("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},Mf.prototype.lc=function(){return f(this,void 0,void 0,function(){var e=this;return y(this,function(t){switch(t.label){case 0:return this.hf=!1,this.Lf(),this.cf&&(this.cf.cancel(),this.cf=null),this.Of(),this.xf(),[4,this.wf.runTransaction("readwrite",[ff.store,Df.store],function(t){return e.vf(t).next(function(){return e.Cf(t)})})];case 1:return t.sent(),this.wf.close(),this.Bf(),[2]}})})},Mf.prototype.Ff=function(t,e){var n=this;return t.filter(function(t){return n.Nf(t.updateTimeMs,e)&&!n.Mf(t.clientId)})},Mf.prototype.Jh=function(){var e=this;return this.wf.runTransaction("readonly",[Df.store],function(t){return Gf(t).ld().next(function(t){return e.Ff(t,18e5).map(function(t){return t.clientId})})})},Mf.clearPersistence=function(n){return f(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return Mf.Uc()?(e=n+Mf.ff,[4,Sc.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(Mf.prototype,"ko",{get:function(){return this.hf},enumerable:!0,configurable:!0}),Mf.prototype.Yo=function(t){return Mc.Id(t,this.serializer,this.ur,this.Jo)},Mf.prototype.eh=function(){return this.th},Mf.prototype.Zo=function(){return this.hr},Mf.prototype.nh=function(){return this.ur},Mf.prototype.runTransaction=function(n,t,r){var i=this;du("IndexedDbPersistence","Starting transaction:",n);var o,e="readonly"===t?"readonly":"readwrite";return this.wf.runTransaction(e,kf,function(e){return o=new Cf(e,i.Vf.next()),"readwrite-primary"===t?i.yf(e).next(function(t){return!!t||i.bf(e)}).next(function(t){if(!t)throw yu("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.$a.qr(function(){return i.lf(!1)}),new Mr(Ur.FAILED_PRECONDITION,Ou);return r(o)}).next(function(t){return i.Sf(e).next(function(){return t})}):i.Uf(e).next(function(){return r(o)})}).then(function(t){return o.or(),t})},Mf.prototype.Uf=function(t){var e=this;return qf(t).get(ff.key).next(function(t){if(null!==t&&e.Nf(t.leaseTimestampMs,5e3)&&!e.Mf(t.ownerId)&&!e.Df(t)&&!t.allowTabSynchronization)throw new Mr(Ur.FAILED_PRECONDITION,Pf)})},Mf.prototype.Sf=function(t){var e=new ff(this.clientId,this.allowTabSynchronization,Date.now());return qf(t).put(ff.key,e)},Mf.Uc=function(){return Sc.Uc()},Mf.qf=function(t){var e=t.cn.projectId;return t.cn.Ei||(e+="."+t.cn.database),"firestore/"+t.persistenceKey+"/"+e+"/"},Mf.prototype.vf=function(t){var e=this,n=qf(t);return n.get(ff.key).next(function(t){return e.Df(t)?(du("IndexedDbPersistence","Releasing primary lease."),n.delete(ff.key)):Ru.resolve()})},Mf.prototype.Nf=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(yu("Detected an update time that is in the future: "+t+" > "+n),1))},Mf.prototype.Rf=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.uf=function(){t.$a.qr(function(){return t.inForeground="visible"===t.document.visibilityState,t.If()})},this.document.addEventListener("visibilitychange",this.uf),this.inForeground="visible"===this.document.visibilityState)},Mf.prototype.Of=function(){this.uf&&(this.document.removeEventListener("visibilitychange",this.uf),this.uf=null)},Mf.prototype.Af=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.af=function(){t.Lf(),t.$a.qr(function(){return t.lc()})},this.window.addEventListener("unload",this.af))},Mf.prototype.xf=function(){this.af&&(this.window.removeEventListener("unload",this.af),this.af=null)},Mf.prototype.Mf=function(t){try{var e=null!==this.Tf.getItem(this.$f(t));return du("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return yu("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},Mf.prototype.Lf=function(){try{this.Tf.setItem(this.$f(this.clientId),String(Date.now()))}catch(t){yu("Failed to set zombie client id.",t)}},Mf.prototype.Bf=function(){try{this.Tf.removeItem(this.$f(this.clientId))}catch(t){}},Mf.prototype.$f=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},Mf);function Mf(t,e,n,r,i,o,s,u){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.$a=o,this.rf=u,this.hf=!1,this.isPrimary=!1,this.networkEnabled=!0,this.af=null,this.inForeground=!1,this.uf=null,this.cf=null,this._f=Number.NEGATIVE_INFINITY,this.lf=function(t){return Promise.resolve()},this.Jo=new Bf(this,i),this.df=e+Mf.ff,this.serializer=new Vf(s),this.document=r.document,this.th=new Kc(this.Jo,this.serializer),this.ur=new xf,this.hr=new Zc(this.serializer,this.ur),!r.window||!r.window.localStorage)throw new Mr(Ur.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.Tf=this.window.localStorage}function Ff(t,e){var n=this;return(n=Of.call(this)||this).yd=t,n.Ch=e,n}function jf(t){this.sf=t}function qf(t){return t.store(ff.store)}function Gf(t){return t.store(Df.store)}Uf.ff="main";var Bf=(zf.prototype.Mo=function(t){var n=this.Wf(t);return this.db.eh().Ld(t).next(function(e){return n.next(function(t){return e+t})})},zf.prototype.Wf=function(t){var e=0;return this.Oo(t,function(t){e++}).next(function(){return e})},zf.prototype.Xs=function(t,e){return this.db.eh().Xs(t,e)},zf.prototype.Oo=function(t,n){return this.jf(t,function(t,e){return n(e)})},zf.prototype.Ho=function(t){this.Qf=t},zf.prototype.vi=function(t,e){return Kf(t,e)},zf.prototype.Di=function(t,e){return Kf(t,e)},zf.prototype.xo=function(t,e,n){return this.db.eh().xo(t,e,n)},zf.prototype.bd=function(t,e){return Kf(t,e)},zf.prototype.Kf=function(t,e){return this.Qf.Mi(e)?Ru.resolve(!0):(r=e,i=!1,zc(n=t).Ed(function(t){return jc(n,t,r).next(function(t){return t&&(i=!0),Ru.resolve(!t)})}).next(function(){return i}));var n,r,i},zf.prototype.Bo=function(r,i){var o=this,s=this.db.Zo().Eh(),u=[],a=0;return this.jf(r,function(e,t){if(t<=i){var n=o.Kf(r,e).next(function(t){if(!t)return a++,s.tr(r,e).next(function(){return s.Zi(e),Jc(r).delete([0,Ic(e.path)])})});u.push(n)}}).next(function(){return Ru.Ki(u)}).next(function(){return s.apply(r)}).next(function(){return a})},zf.prototype.removeTarget=function(t,e){var n=e.es(t.Ch);return this.db.eh().Nh(t,n)},zf.prototype.Fh=function(t,e){return Kf(t,e)},zf.prototype.jf=function(t,o){var s,e=Jc(t),u=Uu.kr;return e.md({index:Nf.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(u!==Uu.kr&&o(new ui(_c(s)),u),u=i,s=r):u=Uu.kr}).next(function(){u!==Uu.kr&&o(new ui(_c(s)),u)})},zf.prototype.qo=function(t){return this.db.Zo().Jd(t)},zf);function zf(t,e){this.db=t,this.Qf=null,this.bo=new aa(this,e)}function Kf(t,e){return Jc(t).put((n=e,r=t.Ch,new Nf(0,Ic(n.path),r)));var n,r}var Wf,Hf=(Jf.prototype.Rd=function(t){return Ru.resolve(0===this.ar.length)},Jf.prototype.mh=function(t,e,n){var r=e.batchId,i=this.Hf(r,"acknowledged");return gu(0===i,"Can only acknowledge the first batch in the mutation queue"),this.ar[i],this.lastStreamToken=n,Ru.resolve()},Jf.prototype.ph=function(t){return Ru.resolve(this.lastStreamToken)},Jf.prototype.yh=function(t,e){return this.lastStreamToken=e,Ru.resolve()},Jf.prototype.dh=function(t,e,n,r){var i=this.Gf;this.Gf++,0<this.ar.length&&this.ar[this.ar.length-1];var o=new Su(i,e,n,r);this.ar.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.zf=this.zf.add(new xu(a.key,i)),this.ur.Vd(t,a.key.path.L())}return Ru.resolve(o)},Jf.prototype.Ph=function(t,e){return Ru.resolve(this.Jf(e))},Jf.prototype.Th=function(t,e){var n=this.Jf(e);return Ru.resolve(n.keys())},Jf.prototype.xh=function(t,e){var n=e+1,r=this.Yf(n),i=r<0?0:r;return Ru.resolve(this.ar.length>i?this.ar[i]:null)},Jf.prototype.gh=function(){return Ru.resolve(0===this.ar.length?-1:this.Gf-1)},Jf.prototype.hh=function(t){return Ru.resolve(this.ar.slice())},Jf.prototype._r=function(t,e){var n=this,r=new xu(e,0),i=new xu(e,Number.POSITIVE_INFINITY),o=[];return this.zf.Ct([r,i],function(t){var e=n.Jf(t.Li);o.push(e)}),Ru.resolve(o)},Jf.prototype.Er=function(t,e){var r=this,i=new vi(Eu);return e.forEach(function(t){var e=new xu(t,0),n=new xu(t,Number.POSITIVE_INFINITY);r.zf.Ct([e,n],function(t){i=i.add(t.Li)})}),Ru.resolve(this.Xf(i))},Jf.prototype.Vr=function(t,e){var n=e.path,r=n.length+1,i=n;ui.st(i)||(i=i.child(""));var o=new xu(new ui(i),0),s=new vi(Eu);return this.zf.kt(function(t){var e=t.key.path;return!!n.q(e)&&(e.length===r&&(s=s.add(t.Li)),!0)},o),Ru.resolve(this.Xf(s))},Jf.prototype.Xf=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.Jf(t);null!==e&&r.push(e)}),r},Jf.prototype.Vh=function(n,r){var i=this;gu(0===this.Hf(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.ar.shift();var o=this.zf;return Ru.forEach(r.mutations,function(t){var e=new xu(t.key,r.batchId);return o=o.delete(e),i.Jo.bd(n,t.key)}).next(function(){i.zf=o})},Jf.prototype.Xh=function(t){},Jf.prototype.Mi=function(t,e){var n=new xu(e,0),r=this.zf.Nt(n);return Ru.resolve(e.isEqual(r&&r.key))},Jf.prototype.Rh=function(t){return this.ar.length,Ru.resolve()},Jf.prototype.Hf=function(t,e){return this.Yf(t)},Jf.prototype.Yf=function(t){return 0===this.ar.length?0:t-this.ar[0].batchId},Jf.prototype.Jf=function(t){var e=this.Yf(t);return e<0||e>=this.ar.length?null:this.ar[e]},Jf),Yf=(Xf.prototype.Yi=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.Zf(e);return this.docs=this.docs.it(r,{Ud:e,size:s,readTime:n}),this.size+=s-o,this.ur.Vd(t,r.path.L())},Xf.prototype.Zi=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Xf.prototype.tr=function(t,e){var n=this.docs.get(e);return Ru.resolve(n?n.Ud:null)},Xf.prototype.getEntries=function(t,e){var n=this,r=Ds();return e.forEach(function(t){var e=n.docs.get(t);r=r.it(t,e?e.Ud:null)}),Ru.resolve(r)},Xf.prototype.wr=function(t,e,n){for(var r=xs(),i=new ui(e.path.child("")),o=this.docs.lt(i);o.It();){var s=o.wt(),u=s.key,a=s.value,h=a.Ud,c=a.readTime;if(!e.path.q(u.path))break;c.D(n)<=0||h instanceof Oo&&e.matches(h)&&(r=r.it(h.key,h))}return Ru.resolve(r)},Xf.prototype.tT=function(t,e){return Ru.forEach(this.docs,function(t){return e(t)})},Xf.prototype.ea=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},Xf.prototype.na=function(t){return Ru.resolve(zr.MIN)},Xf.prototype.Eh=function(t){return new Xf.Hd(this)},Xf.prototype.Jd=function(t){return Ru.resolve(this.size)},Xf);function Xf(t,e){this.ur=t,this.Zf=e,this.docs=new hi(ui.F),this.size=0}function Jf(t,e){this.ur=t,this.Jo=e,this.ar=[],this.Gf=1,this.lastStreamToken=Ii.xt,this.zf=new vi(xu.Ee)}function Qf(t){var e=this;return(e=Wf.call(this)||this).Yd=t,e}Yf.Hd=(n(Qf,Wf=Lu),Qf.prototype.nr=function(n){var r=this,i=[];return this.zi.forEach(function(t,e){e?i.push(r.Yd.Yi(n,e,r.readTime)):r.Yd.Zi(t)}),Ru.Ki(i)},Qf.prototype.er=function(t,e){return this.Yd.tr(t,e)},Qf.prototype.sr=function(t,e){return this.Yd.getEntries(t,e)},Qf);var Zf,$f,tl=(yl.prototype.Xs=function(t,n){return this.eT.forEach(function(t,e){return n(e)}),Ru.resolve()},yl.prototype.bh=function(t){return Ru.resolve(this.lastRemoteSnapshotVersion)},yl.prototype.Dd=function(t){return Ru.resolve(this.sT)},yl.prototype.Qh=function(t){return this.highestTargetId=this.iT.next(),Ru.resolve(this.highestTargetId)},yl.prototype.$h=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.sT&&(this.sT=e),Ru.resolve()},yl.prototype.Cd=function(t){this.eT.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.iT=new nc(e),this.highestTargetId=e),t.sequenceNumber>this.sT&&(this.sT=t.sequenceNumber)},yl.prototype.Wh=function(t,e){return this.Cd(e),this.targetCount+=1,Ru.resolve()},yl.prototype.Nh=function(t,e){return this.Cd(e),Ru.resolve()},yl.prototype.Nd=function(t,e){return this.eT.delete(e.target),this.nT.Ni(e.targetId),--this.targetCount,Ru.resolve()},yl.prototype.xo=function(n,r,i){var o=this,s=0,u=[];return this.eT.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.eT.delete(t),u.push(o.Fd(n,e.targetId)),s++)}),Ru.Ki(u).next(function(){return s})},yl.prototype.Ld=function(t){return Ru.resolve(this.targetCount)},yl.prototype.qh=function(t,e){var n=this.eT.get(e)||null;return Ru.resolve(n)},yl.prototype.un=function(t,e){return mu("Not yet implemented.")},yl.prototype.Dh=function(e,t,n){this.nT.Si(t,n);var r=this.persistence.Jo,i=[];return r&&t.forEach(function(t){i.push(r.vi(e,t))}),Ru.Ki(i)},yl.prototype.Sh=function(e,t,n){this.nT.ki(t,n);var r=this.persistence.Jo,i=[];return r&&t.forEach(function(t){i.push(r.Di(e,t))}),Ru.Ki(i)},yl.prototype.Fd=function(t,e){return this.nT.Ni(e),Ru.resolve()},yl.prototype.Gh=function(t,e){var n=this.nT.$i(e);return Ru.resolve(n)},yl.prototype.Mi=function(t,e){return Ru.resolve(this.nT.Mi(e))},yl),el=(dl.prototype.start=function(){return Promise.resolve()},dl.prototype.lc=function(){return this.hf=!1,Promise.resolve()},Object.defineProperty(dl.prototype,"ko",{get:function(){return this.hf},enumerable:!0,configurable:!0}),dl.prototype.Jh=function(){return f(this,void 0,void 0,function(){return y(this,function(t){return[2,[this.clientId]]})})},dl.prototype.gf=function(t){return t(!0)},dl.prototype.pf=function(){},dl.prototype.Zh=function(t){},dl.prototype.nh=function(){return this.ur},dl.prototype.Yo=function(t){var e=this.rT[t.s()];return e||(e=new Hf(this.ur,this.Jo),this.rT[t.s()]=e),e},dl.prototype.eh=function(){return this.th},dl.prototype.Zo=function(){return this.hr},dl.prototype.runTransaction=function(t,e,n){var r=this;du("MemoryPersistence","Starting transaction:",t);var i=new nl(this.Vf.next());return this.Jo.hT(),n(i).next(function(t){return r.Jo.aT(i).next(function(){return t})}).Wi().then(function(t){return i.or(),t})},dl.prototype.uT=function(e,n){return Ru.Gi(Object.values(this.rT).map(function(t){return function(){return t.Mi(e,n)}}))},dl),nl=(n(pl,$f=Vu),pl),rl=(ll._T=function(t){return new ll(t)},Object.defineProperty(ll.prototype,"lT",{get:function(){if(this.cT)return this.cT;throw mu("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),ll.prototype.Ho=function(t){this.Qf=t},ll.prototype.vi=function(t,e){return this.lT.delete(e),Ru.resolve()},ll.prototype.Di=function(t,e){return this.lT.add(e),Ru.resolve()},ll.prototype.bd=function(t,e){return this.lT.add(e),Ru.resolve()},ll.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.eh();return r.Gh(t,e.targetId).next(function(t){t.forEach(function(t){return n.lT.add(t)})}).next(function(){return r.Nd(t,e)})},ll.prototype.hT=function(){this.cT=new Set},ll.prototype.aT=function(t){var n=this,r=this.persistence.Zo().Eh();return Ru.forEach(this.lT,function(e){return n.dT(t,e).next(function(t){t||r.Zi(e)})}).next(function(){return n.cT=null,r.apply(t)})},ll.prototype.Fh=function(t,e){var n=this;return this.dT(t,e).next(function(t){t?n.lT.delete(e):n.lT.add(e)})},ll.prototype.oT=function(t){return 0},ll.prototype.dT=function(t,e){var n=this;return Ru.Gi([function(){return n.persistence.eh().Mi(t,e)},function(){return n.persistence.uT(t,e)},function(){return Ru.resolve(n.Qf.Mi(e))}])},ll),il=(fl.prototype.initialize=function(e){return f(this,void 0,void 0,function(){var n=this;return y(this,function(t){switch(t.label){case 0:return this.X_=this.fT(e),this.persistence=this.TT(e),[4,this.persistence.start()];case 1:return t.sent(),this.mT=this.ET(e),this.Wu=this.wT(e),this.W_=this.IT(e),this.mc=this.RT(e),this.AT=this.PT(e),this.X_.$u=function(t){return n.mc.B_(t,1)},this.W_.mc=this.mc,this.X_.mc=this.mc,[4,this.X_.start()];case 2:return t.sent(),[4,this.W_.start()];case 3:return t.sent(),[4,this.Wu.start()];case 4:return t.sent(),[4,this.persistence.gf(function(e){return f(n,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.mc.Cc(e)];case 1:return t.sent(),this.mT&&(e&&!this.mT.ko?this.mT.start(this.Wu):e||this.mT.stop()),[2]}})})})];case 5:return t.sent(),[2]}})})},fl.prototype.PT=function(t){return new sc(this.mc)},fl.prototype.ET=function(t){return null},fl.prototype.wT=function(t){return new ha(this.persistence,new ac,t.VT)},fl.prototype.TT=function(t){return new el(t.clientId,rl._T)},fl.prototype.IT=function(t){var e=this;return new Lh(this.Wu,t.bu,t.Nr,function(t){return e.mc.B_(t,0)},t.platform.gT())},fl.prototype.fT=function(t){return new ec},fl.prototype.RT=function(t){return new oc(this.Wu,this.W_,this.X_,t.VT,t.Z_)},fl.prototype.clearPersistence=function(t){throw new Mr(Ur.FAILED_PRECONDITION,"You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.")},fl),ol=(n(cl,Zf=il),cl.prototype.ET=function(t){var e=this.persistence.Jo.bo;return new ua(e,t.Nr)},cl.prototype.TT=function(t){var e=Uf.qf(t.pT),n=t.platform.yT(t.pT.cn);return Uf.mf({allowTabSynchronization:t.bT.synchronizeTabs,persistenceKey:e,clientId:t.clientId,platform:t.platform,$a:t.Nr,serializer:n,Ef:ia.Io(t.bT.cacheSizeBytes),rf:this.X_})},cl.prototype.fT=function(t){if(t.bT.synchronizeTabs){if(!tc.Uc(t.platform))throw new Mr(Ur.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var e=Uf.qf(t.pT);return new tc(t.Nr,t.platform,e,t.clientId,t.VT)}return new ec},cl.prototype.clearPersistence=function(t){var e=Uf.qf(t);return Uf.clearPersistence(e)},cl),sl=(hl.prototype.start=function(e,n){var r=this;this.vT();var i=new Ju,o=new Ju,s=!1;return this.credentials.l(function(t){if(!s)return s=!0,du("FirestoreClient","Initializing. user=",t.uid),r.ST(e,n,t,o).then(i.resolve,i.reject);r.Nr.qr(function(){return r.Dc(t)})}),this.Nr.qr(function(){return i.promise}),o.promise},hl.prototype.enableNetwork=function(){var t=this;return this.vT(),this.Nr.enqueue(function(){return t.mc.enableNetwork()})},hl.prototype.ST=function(s,u,a,h){return f(this,void 0,void 0,function(){var e,n,r,i,o=this;return y(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.platform.DT(this.pT)];case 1:return e=t.sent(),n=this.platform.yT(this.pT.cn),r=new kh(this.Nr,e,this.credentials,n),[4,s.initialize({Nr:this.Nr,pT:this.pT,platform:this.platform,bu:r,clientId:this.clientId,VT:a,Z_:100,bT:u})];case 2:return t.sent(),this.persistence=s.persistence,this.X_=s.X_,this.Wu=s.Wu,this.W_=s.W_,this.mc=s.mc,this.mT=s.mT,this.CT=s.AT,this.persistence.pf(function(){return f(o,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]}})})}),h.resolve(),[3,4];case 3:if(i=t.sent(),h.reject(i),!this.kT(i))throw i;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+i),this.ST(new il,{NT:!1},a,h))];case 4:return[2]}})})},hl.prototype.kT=function(t){return"FirebaseError"===t.name?t.code===Ur.FAILED_PRECONDITION||t.code===Ur.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},hl.prototype.vT=function(){if(this.Nr.Hr)throw new Mr(Ur.FAILED_PRECONDITION,"The client has already been terminated.")},hl.prototype.Dc=function(t){return this.Nr.no(),du("FirestoreClient","Credential Changed. Current user: "+t.uid),this.mc.Dc(t)},hl.prototype.disableNetwork=function(){var t=this;return this.vT(),this.Nr.enqueue(function(){return t.mc.disableNetwork()})},hl.prototype.terminate=function(){var t=this;return this.Nr.to(function(){return f(t,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.mT&&this.mT.stop(),[4,this.W_.lc()];case 1:return t.sent(),[4,this.X_.lc()];case 2:return t.sent(),[4,this.persistence.lc()];case 3:return t.sent(),this.credentials.T(),[2]}})})})},hl.prototype.waitForPendingWrites=function(){var t=this;this.vT();var e=new Ju;return this.Nr.qr(function(){return t.mc.Pl(e)}),e.promise},hl.prototype.listen=function(t,e,n){var r=this;this.vT();var i=new uc(t,e,n);return this.Nr.qr(function(){return r.CT.listen(i)}),i},hl.prototype.fc=function(t){var e=this;this.FT||this.Nr.qr(function(){return e.CT.fc(t)})},hl.prototype.$T=function(t){var e=this;return this.vT(),this.Nr.enqueue(function(){return e.Wu.Bh(t)}).then(function(t){if(t instanceof Oo)return t;if(t instanceof Vo)return null;throw new Mr(Ur.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.)")})},hl.prototype.MT=function(i){var t=this;return this.vT(),this.Nr.enqueue(function(){return f(t,void 0,void 0,function(){var e,n,r;return y(this,function(t){switch(t.label){case 0:return[4,this.Wu.Kh(i,!0)];case 1:return e=t.sent(),n=new rc(i,e.zh),r=n.k_(e.documents),[2,n.nr(r,!1).snapshot]}})})})},hl.prototype.write=function(t){var e=this;this.vT();var n=new Ju;return this.Nr.qr(function(){return e.mc.write(t,n)}),n.promise},hl.prototype.cn=function(){return this.pT.cn},hl.prototype.Ol=function(t){var e=this;this.vT(),this.Nr.qr(function(){return e.CT.Ol(t),Promise.resolve()})},hl.prototype.xl=function(t){this.FT||this.CT.xl(t)},Object.defineProperty(hl.prototype,"FT",{get:function(){return this.Nr.Hr},enumerable:!0,configurable:!0}),hl.prototype.transaction=function(t){var e=this;this.vT();var n=new Ju;return this.Nr.qr(function(){return e.mc.runTransaction(e.Nr,t,n),Promise.resolve()}),n.promise},hl),ul=(al.prototype.next=function(t){this.LT(this.observer.next,t)},al.prototype.error=function(t){this.LT(this.observer.error,t)},al.prototype.OT=function(){this.muted=!0},al.prototype.LT=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},al);function al(t){this.observer=t,this.muted=!1}function hl(t,e,n,r){this.platform=t,this.pT=e,this.credentials=n,this.Nr=r,this.clientId=wu.mi()}function cl(){return null!==Zf&&Zf.apply(this,arguments)||this}function fl(){}function ll(t){this.persistence=t,this.Qf=null,this.cT=null}function pl(t){var e=this;return(e=$f.call(this)||this).Ch=t,e}function dl(t,e){var n=this;this.clientId=t,this.rT={},this.Vf=new Uu(0),this.hf=!1,this.hf=!0,this.Jo=e(this),this.th=new tl(this),this.ur=new uf,this.hr=new Yf(this.ur,function(t){return n.Jo.oT(t)})}function yl(t){this.persistence=t,this.eT=new _u(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=zr.MIN,this.highestTargetId=0,this.sT=0,this.nT=new ku,this.targetCount=0,this.iT=nc.p_()}function vl(i){return function(){if("object"==typeof i&&null!==i)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 1}}()}var ml,gl,wl=(Bl.prototype.BT=function(t){switch(Ri(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Mi(t.integerValue||t.doubleValue);case 3:return this.UT(t.timestampValue);case 4:return this.qT(t);case 5:return t.stringValue;case 6:return new Pa(Fi(t.bytesValue));case 7:return this.QT(t.referenceValue);case 8:return new nh(t.geoPointValue.latitude,t.geoPointValue.longitude);case 9:return this.WT(t.arrayValue);case 10:return this.jT(t.mapValue);default:throw mu("Invalid value type: "+JSON.stringify(t))}},Bl.prototype.jT=function(t){var n=this,r={};return Ei(t.fields||{},function(t,e){r[t]=n.BT(e)}),r},Bl.prototype.WT=function(t){var e=this;return(t.values||[]).map(function(t){return e.BT(t)})},Bl.prototype.qT=function(t){switch(this.xT){case"previous":var e=function t(e){var n=e.mapValue.fields.__previous_value__;return Di(n)?t(n):n}(t);return null==e?null:this.BT(e);case"estimate":return this.UT(ki(t));default:return null}},Bl.prototype.UT=function(t){var e=Ui(t),n=new Br(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},Bl.prototype.QT=function(t){var e=ti.G(t);gu(au(e),"ReferenceValue is not valid "+t);var n=new Au(e.get(1),e.get(3)),r=new ui(e.M(5));return n.isEqual(this.firestore.KT)||yu("Document "+r+" contains a document reference within a different database ("+n.projectId+"/"+n.database+") which is not supported. It will be treated as a reference in the current database ("+this.firestore.KT.projectId+"/"+this.firestore.KT.database+") instead."),new Al(r,this.firestore,this.converter)},Bl),bl=ia.Po,El=(Gl.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},Gl),Tl=(ql.prototype.settings=function(t){ya("Firestore.settings",arguments,1),ga("Firestore.settings","object",1,t);var e=new El(t);if(this.JT&&!this.em.isEqual(e))throw new Mr(Ur.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.em=e).credentials&&(this.ZT=function(t){if(!t)return new Fr;switch(t.type){case"gapi":var e=t.im;return gu(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new Gr(e,t.V||"0");case"provider":return t.im;default:throw new Mr(Ur.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},ql.prototype.enableNetwork=function(){return this.HT(),this.JT.enableNetwork()},ql.prototype.disableNetwork=function(){return this.HT(),this.JT.disableNetwork()},ql.prototype.enablePersistence=function(t){var e,n;if(this.JT)throw new Mr(Ur.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 r=!1;return t&&(void 0!==t.experimentalTabSynchronization&&yu("The 'experimentalTabSynchronization' setting will be removed. Use 'synchronizeTabs' instead."),r=null!==(n=null!==(e=t.synchronizeTabs)&&void 0!==e?e:t.experimentalTabSynchronization)&&void 0!==n&&n),this.rm(this.tm,{NT:!0,cacheSizeBytes:this.em.cacheSizeBytes,synchronizeTabs:r})},ql.prototype.clearPersistence=function(){return f(this,void 0,void 0,function(){var r,e=this;return y(this,function(t){if(void 0!==this.JT&&!this.JT.FT)throw new Mr(Ur.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return r=new Ju,[2,(this.zT.Jr(function(){return f(e,void 0,void 0,function(){var e,n;return y(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=this.om(),[4,this.tm.clearPersistence(e)];case 1:return t.sent(),r.resolve(),[3,3];case 2:return n=t.sent(),r.reject(n),[3,3];case 3:return[2]}})})}),r.promise)]})})},ql.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(ql.prototype,"hm",{get:function(){return this.HT(),this.JT.FT},enumerable:!0,configurable:!0}),ql.prototype.waitForPendingWrites=function(){return this.HT(),this.JT.waitForPendingWrites()},ql.prototype.onSnapshotsInSync=function(t){if(this.HT(),vl(t))return this.am(t);ga("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.am(e)},ql.prototype.am=function(t){var e=this,n=new ul({next:function(){t.next&&t.next()},error:function(t){throw mu("Uncaught Error in onSnapshotsInSync")}});return this.JT.Ol(n),function(){n.OT(),e.JT.xl(n)}},ql.prototype.HT=function(){return this.JT||this.rm(new il,{NT:!1}),this.JT},ql.prototype.om=function(){return new Nu(this.KT,this.XT,this.em.host,this.em.ssl,this.em.forceLongPolling)},ql.prototype.rm=function(t,e){var n=this.om();return this.JT=new sl(hu.Lt(),n,this.ZT,this.zT),this.JT.start(t,e)},ql.prototype.nm=function(r){var t=new su(r,{dn:hu.Lt().dn});return new yh(t,function(t){if(t instanceof Al){var e=r,n=t.firestore.KT;if(!n.isEqual(e))throw new Mr(Ur.INVALID_ARGUMENT,"Document reference is for database "+n.projectId+"/"+n.database+" but should be for database "+e.projectId+"/"+e.database);return new dh(r,t.um)}return t})},ql.YT=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new Mr(Ur.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new Mr(Ur.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Au(n)},Object.defineProperty(ql.prototype,"app",{get:function(){if(!this.GT)throw new Mr(Ur.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.GT},enumerable:!0,configurable:!0}),ql.prototype.collection=function(t){return ya("Firestore.collection",arguments,1),ga("Firestore.collection","non-empty string",1,t),this.HT(),new Rl(ti.G(t),this)},ql.prototype.doc=function(t){return ya("Firestore.doc",arguments,1),ga("Firestore.doc","non-empty string",1,t),this.HT(),Al.cm(ti.G(t),this)},ql.prototype.collectionGroup=function(t){if(ya("Firestore.collectionGroup",arguments,1),ga("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new Mr(Ur.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.HT(),new kl(new Uo(ti.H,t),this)},ql.prototype.runTransaction=function(e){var n=this;return ya("Firestore.runTransaction",arguments,1),ga("Firestore.runTransaction","function",1,e),this.HT().transaction(function(t){return e(new Il(n,t))})},ql.prototype.batch=function(){return this.HT(),new Nl(this)},Object.defineProperty(ql,"logLevel",{get:function(){switch(lu()){case l.DEBUG:return"debug";case l.SILENT:return"silent";default:return"error"}},enumerable:!0,configurable:!0}),ql.setLogLevel=function(t){switch(ya("Firestore.setLogLevel",arguments,1),ga("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":pu(l.DEBUG);break;case"error":pu(l.ERROR);break;case"silent":pu(l.SILENT);break;default:throw new Mr(Ur.INVALID_ARGUMENT,"Invalid log level: "+t)}},ql.prototype._m=function(){return this.em.timestampsInSnapshots},ql),Il=(jl.prototype.get=function(t){var n=this;ya("Transaction.get",arguments,1);var r=Hl("Transaction.get",t,this.lm);return this.dm.pu([r.um]).then(function(t){if(!t||1!==t.length)return mu("Mismatch in docs returned from document lookup.");var e=t[0];if(e instanceof Vo)return new Sl(n.lm,r.um,null,!1,!1,r.fm);if(e instanceof Oo)return new Sl(n.lm,r.um,e,!1,!1,r.fm);throw mu("BatchGetDocumentsRequest returned unexpected document type: "+e.constructor.name)})},jl.prototype.set=function(t,e,n){ma("Transaction.set",arguments,2,3);var r=Hl("Transaction.set",t,this.lm);n=zl("Transaction.set",n);var i=Yl(r.fm,e,"Transaction.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.lm.sm.pa(s,o,n.mergeFields):this.lm.sm.Va(s,o);return this.dm.set(r.um,u),this},jl.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 Ua?(va("Transaction.update",arguments,3),r=Hl("Transaction.update",t,this.lm),this.lm.sm.Sa("Transaction.update",e,n,o)):(ya("Transaction.update",arguments,2),r=Hl("Transaction.update",t,this.lm),this.lm.sm.ya("Transaction.update",e)),this.dm.update(r.um,i),this},jl.prototype.delete=function(t){ya("Transaction.delete",arguments,1);var e=Hl("Transaction.delete",t,this.lm);return this.dm.delete(e.um),this},jl),Nl=(Fl.prototype.set=function(t,e,n){ma("WriteBatch.set",arguments,2,3),this.Em();var r=Hl("WriteBatch.set",t,this.lm);n=zl("WriteBatch.set",n);var i=Yl(r.fm,e,"WriteBatch.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.lm.sm.pa(s,o,n.mergeFields):this.lm.sm.Va(s,o);return this.Tm=this.Tm.concat(u.da(r.um,io.NONE)),this},Fl.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return this.Em(),i="string"==typeof e||e instanceof Ua?(va("WriteBatch.update",arguments,3),r=Hl("WriteBatch.update",t,this.lm),this.lm.sm.Sa("WriteBatch.update",e,n,o)):(ya("WriteBatch.update",arguments,2),r=Hl("WriteBatch.update",t,this.lm),this.lm.sm.ya("WriteBatch.update",e)),this.Tm=this.Tm.concat(i.da(r.um,io.exists(!0))),this},Fl.prototype.delete=function(t){ya("WriteBatch.delete",arguments,1),this.Em();var e=Hl("WriteBatch.delete",t,this.lm);return this.Tm=this.Tm.concat(new go(e.um,io.NONE)),this},Fl.prototype.commit=function(){return this.Em(),this.mm=!0,0<this.Tm.length?this.lm.HT().write(this.Tm):Promise.resolve()},Fl.prototype.Em=function(){if(this.mm)throw new Mr(Ur.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},Fl),Al=(Ml.cm=function(t,e,n){if(t.length%2!=0)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.K()+" has "+t.length);return new Ml(new ui(t),e,n)},Object.defineProperty(Ml.prototype,"id",{get:function(){return this.um.path.B()},enumerable:!0,configurable:!0}),Object.defineProperty(Ml.prototype,"parent",{get:function(){return new Rl(this.um.path.L(),this.firestore,this.fm)},enumerable:!0,configurable:!0}),Object.defineProperty(Ml.prototype,"path",{get:function(){return this.um.path.K()},enumerable:!0,configurable:!0}),Ml.prototype.collection=function(t){if(ya("DocumentReference.collection",arguments,1),ga("DocumentReference.collection","non-empty string",1,t),!t)throw new Mr(Ur.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=ti.G(t);return new Rl(this.um.path.child(e),this.firestore)},Ml.prototype.isEqual=function(t){if(!(t instanceof Ml))throw Da("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.um.isEqual(t.um)&&this.fm===t.fm},Ml.prototype.set=function(t,e){ma("DocumentReference.set",arguments,1,2),e=zl("DocumentReference.set",e);var n=Yl(this.fm,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore.sm.pa(i,r,e.mergeFields):this.firestore.sm.Va(i,r);return this.JT.write(o.da(this.um,io.NONE))},Ml.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 Ua?(va("DocumentReference.update",arguments,2),this.firestore.sm.Sa("DocumentReference.update",t,e,r)):(ya("DocumentReference.update",arguments,1),this.firestore.sm.ya("DocumentReference.update",t)),this.JT.write(n.da(this.um,io.exists(!0)))},Ml.prototype.delete=function(){return ya("DocumentReference.delete",arguments,0),this.JT.write([new go(this.um,io.NONE)])},Ml.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ma("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||vl(t[i])||(Sa("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),Ea("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=vl(t[i])?t[i]:(ga("DocumentReference.onSnapshot","function",i,t[i]),wa("DocumentReference.onSnapshot","function",i+1,t[i+1]),wa("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.wm(o,n)},Ml.prototype.wm=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 ul({next:function(t){if(n.next){var e=t.docs.get(r.um);n.next(new Sl(r.firestore,r.um,e,t.fromCache,t.hasPendingWrites,r.fm))}},error:e}),o=this.JT.listen(Uo.ve(this.um.path),i,t);return function(){i.OT(),r.JT.fc(o)}},Ml.prototype.get=function(n){var r=this;return ma("DocumentReference.get",arguments,0,1),Wl("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.HT().$T(r.um).then(function(t){e(new Sl(r.firestore,r.um,t,!0,t instanceof Oo&&t.te,r.fm))},t):r.Im(e,t,n)})},Ml.prototype.Im=function(e,n,r){var i=this.wm({includeMetadataChanges:!0,Kl:!0},{next:function(t){i(),!t.exists&&t.metadata.fromCache?n(new Mr(Ur.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new Mr(Ur.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})},Ml.prototype.withConverter=function(t){return new Ml(this.um,this.firestore,t)},Ml),_l=(Ul.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},Ul),Sl=(Cl.prototype.data=function(t){if(ma("DocumentSnapshot.data",arguments,0,1),t=Kl("DocumentSnapshot.data",t),this.Rm){if(this.fm){var e=new Dl(this.lm,this.um,this.Rm,this.Am,this.Pm);return this.fm.fromFirestore(e,t)}return new wl(this.lm,this.lm._m(),t.serverTimestamps,void 0).BT(this.Rm.Ie())}},Cl.prototype.get=function(t,e){if(ma("DocumentSnapshot.get",arguments,1,2),e=Kl("DocumentSnapshot.get",e),this.Rm){var n=this.Rm.data().field(bh("DocumentSnapshot.get",t));if(null!==n)return new wl(this.lm,this.lm._m(),e.serverTimestamps,this.fm).BT(n)}},Object.defineProperty(Cl.prototype,"id",{get:function(){return this.um.path.B()},enumerable:!0,configurable:!0}),Object.defineProperty(Cl.prototype,"ref",{get:function(){return new Al(this.um,this.lm,this.fm)},enumerable:!0,configurable:!0}),Object.defineProperty(Cl.prototype,"exists",{get:function(){return null!==this.Rm},enumerable:!0,configurable:!0}),Object.defineProperty(Cl.prototype,"metadata",{get:function(){return new _l(this.Pm,this.Am)},enumerable:!0,configurable:!0}),Cl.prototype.isEqual=function(t){if(!(t instanceof Cl))throw Da("isEqual","DocumentSnapshot",1,t);return this.lm===t.lm&&this.Am===t.Am&&this.um.isEqual(t.um)&&(null===this.Rm?null===t.Rm:this.Rm.isEqual(t.Rm))&&this.fm===t.fm},Cl),Dl=(n(Pl,gl=Sl),Pl.prototype.data=function(t){return gl.prototype.data.call(this,t)},Pl),kl=(Vl.prototype.where=function(t,e,n){var r;ya("Query.where",arguments,3),_a("Query.where",3,n),function(t,e){if(!t.some(function(t){return t===e}))throw new Mr(Ur.INVALID_ARGUMENT,"Invalid value "+Aa(e)+" provided to function Query.where() for its "+xa(2)+" argument. Acceptable values: "+t.join(", "))}(["<","<=","==",">=",">","array-contains","in","array-contains-any"],e);var i=bh("Query.where",t),o=Mo.G(e);if(i.Y()){if(o===Mo.ARRAY_CONTAINS||o===Mo.ARRAY_CONTAINS_ANY)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===Mo.IN){this.gm(n,o);for(var s=[],u=0,a=n;u<a.length;u++){var h=a[u];s.push(this.pm(h))}r={arrayValue:{values:s}}}else r=this.pm(n)}else o!==Mo.IN&&o!==Mo.ARRAY_CONTAINS_ANY||this.gm(n,o),r=this.firestore.sm.Da("Query.where",n,o===Mo.IN);var c=$o.create(i,o,r);return this.ym(c),new Vl(this.Vm.Ce(c),this.firestore,this.fm)},Vl.prototype.orderBy=function(t,e){var n;if(ma("Query.orderBy",arguments,1,2),wa("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=os.ASCENDING;else{if("desc"!==e)throw new Mr(Ur.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=os.DESCENDING}if(null!==this.Vm.startAt)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this.Vm.endAt)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=bh("Query.orderBy",t),i=new ms(r,n);return this.bm(i),new Vl(this.Vm.ke(i),this.firestore,this.fm)},Vl.prototype.limit=function(t){return ya("Query.limit",arguments,1),ga("Query.limit","number",1,t),ka("Query.limit",1,t),new Vl(this.Vm.Ne(t),this.firestore,this.fm)},Vl.prototype.limitToLast=function(t){return ya("Query.limitToLast",arguments,1),ga("Query.limitToLast","number",1,t),ka("Query.limitToLast",1,t),new Vl(this.Vm.Fe(t),this.firestore,this.fm)},Vl.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];va("Query.startAt",arguments,1);var r=this.vm("Query.startAt",t,e,!0);return new Vl(this.Vm.$e(r),this.firestore,this.fm)},Vl.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];va("Query.startAfter",arguments,1);var r=this.vm("Query.startAfter",t,e,!1);return new Vl(this.Vm.$e(r),this.firestore,this.fm)},Vl.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];va("Query.endBefore",arguments,1);var r=this.vm("Query.endBefore",t,e,!0);return new Vl(this.Vm.Me(r),this.firestore,this.fm)},Vl.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];va("Query.endAt",arguments,1);var r=this.vm("Query.endAt",t,e,!1);return new Vl(this.Vm.Me(r),this.firestore,this.fm)},Vl.prototype.isEqual=function(t){if(!(t instanceof Vl))throw Da("isEqual","Query",1,t);return this.firestore===t.firestore&&this.Vm.isEqual(t.Vm)},Vl.prototype.withConverter=function(t){return new Vl(this.Vm,this.firestore,t)},Vl.prototype.vm=function(t,e,n,r){if(_a(t,1,e),e instanceof Sl){if(0<n.length)throw new Mr(Ur.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new Mr(Ur.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");return this.Sm(i.Rm,r)}var o=[e].concat(n);return this.Dm(t,o,r)},Vl.prototype.Sm=function(t,e){for(var n=[],r=0,i=this.Vm.orderBy;r<i.length;r++){var o=i[r];if(o.field.Y())n.push(ji(this.firestore.KT,t.key));else{var s=t.field(o.field);if(Di(s))throw new Mr(Ur.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+o.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===s){var u=o.field.K();throw new Mr(Ur.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.")}n.push(s)}}return new vs(n,e)},Vl.prototype.Dm=function(t,e,n){var r=this.Vm.Ve;if(e.length>r.length)throw new Mr(Ur.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.Y()){if("string"!=typeof s)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof s);if(!this.Vm.He()&&-1!==s.indexOf("/"))throw new Mr(Ur.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 u=this.Vm.path.child(ti.G(s));if(!ui.st(u))throw new Mr(Ur.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 '"+u+"' is not because it contains an odd number of segments.");var a=new ui(u);i.push(ji(this.firestore.KT,a))}else{var h=this.firestore.sm.Da(t,s);i.push(h)}}return new vs(i,n)},Vl.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ma("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||vl(t[i])||(Sa("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),Ea("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=vl(t[i])?t[i]:(ga("Query.onSnapshot","function",i,t[i]),wa("Query.onSnapshot","function",i+1,t[i+1]),wa("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.Cm(this.Vm),this.wm(r,n)},Vl.prototype.wm=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 ul({next:function(t){e.next&&e.next(new xl(n.firestore,n.Vm,t,n.fm))},error:r}),o=this.firestore.HT(),s=o.listen(this.Vm,i,t);return function(){i.OT(),o.fc(s)}},Vl.prototype.Cm=function(t){if(t.Ke()&&0===t.Ve.length)throw new Mr(Ur.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},Vl.prototype.get=function(n){var r=this;return ma("Query.get",arguments,0,1),Wl("Query.get",n),this.Cm(this.Vm),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.HT().MT(r.Vm).then(function(t){e(new xl(r.firestore,r.Vm,t,r.fm))},t):r.Im(e,t,n)})},Vl.prototype.Im=function(e,n,r){var i=this.wm({includeMetadataChanges:!0,Kl:!0},{next:function(t){i(),t.metadata.fromCache&&r&&"server"===r.source?n(new Mr(Ur.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})},Vl.prototype.pm=function(t){if("string"==typeof t){if(""===t)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this.Vm.He()&&-1!==t.indexOf("/"))throw new Mr(Ur.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.Vm.path.child(ti.G(t));if(!ui.st(e))throw new Mr(Ur.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 ji(this.firestore.KT,new ui(e))}if(t instanceof Al){var n=t;return ji(this.firestore.KT,n.um)}throw new Mr(Ur.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Aa(t)+".")},Vl.prototype.gm=function(t,e){if(!Array.isArray(t)||0===t.length)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new Mr(Ur.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 Mr(Ur.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},Vl.prototype.ym=function(t){if(t instanceof $o){var e=[Mo.ARRAY_CONTAINS,Mo.ARRAY_CONTAINS_ANY],n=[Mo.IN,Mo.ARRAY_CONTAINS_ANY],r=0<=e.indexOf(t.op),i=0<=n.indexOf(t.op);if(t.Ge()){var o=this.Vm.Se();if(null!==o&&!o.isEqual(t.field))throw new Mr(Ur.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.Vm.De();null!==s&&this.km(t.field,s)}else if(i||r){var u=null;if(i&&(u=this.Vm.ze(n)),null===u&&r&&(u=this.Vm.ze(e)),null!=u)throw u===t.op?new Mr(Ur.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new Mr(Ur.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+u.toString()+"' filters.")}}},Vl.prototype.bm=function(t){if(null===this.Vm.De()){var e=this.Vm.Se();null!==e&&this.km(e,t.field)}},Vl.prototype.km=function(t,e){if(!e.isEqual(t))throw new Mr(Ur.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.")},Vl),xl=(Object.defineProperty(Ol.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(Ol.prototype,"empty",{get:function(){return this.Fm.docs.U()},enumerable:!0,configurable:!0}),Object.defineProperty(Ol.prototype,"size",{get:function(){return this.Fm.docs.size},enumerable:!0,configurable:!0}),Ol.prototype.forEach=function(e,n){var r=this;ma("QuerySnapshot.forEach",arguments,1,2),ga("QuerySnapshot.forEach","function",1,e),this.Fm.docs.forEach(function(t){e.call(n,r.Lm(t))})},Object.defineProperty(Ol.prototype,"query",{get:function(){return new kl(this.Nm,this.lm,this.fm)},enumerable:!0,configurable:!0}),Ol.prototype.docChanges=function(t){t&&(Sa("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),Ea("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.Fm.ds)throw new Mr(Ur.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.$m&&this.Mm===e||(this.$m=function(i,e,o,s){if(o.cs.U()){var n=0;return o.docChanges.map(function(t){var e=new Dl(i,t.doc.key,t.doc,o.fromCache,o._s.has(t.doc.key),s);return t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:n++}})}var u=o.cs;return o.docChanges.filter(function(t){return e||3!==t.type}).map(function(t){var e=new Dl(i,t.doc.key,t.doc,o.fromCache,o._s.has(t.doc.key),s),n=-1,r=-1;return 0!==t.type&&(n=u.indexOf(t.doc.key),u=u.delete(t.doc.key)),1!==t.type&&(r=(u=u.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return mu("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this.lm,e,this.Fm,this.fm),this.Mm=e),this.$m},Ol.prototype.isEqual=function(t){if(!(t instanceof Ol))throw Da("isEqual","QuerySnapshot",1,t);return this.lm===t.lm&&this.Nm.isEqual(t.Nm)&&this.Fm.isEqual(t.Fm)&&this.fm===t.fm},Ol.prototype.Lm=function(t){return new Dl(this.lm,t.key,t,this.metadata.fromCache,this.Fm._s.has(t.key),this.fm)},Ol),Rl=(n(Ll,ml=kl),Object.defineProperty(Ll.prototype,"id",{get:function(){return this.Vm.path.B()},enumerable:!0,configurable:!0}),Object.defineProperty(Ll.prototype,"parent",{get:function(){var t=this.Vm.path.L();return t.U()?null:new Al(new ui(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(Ll.prototype,"path",{get:function(){return this.Vm.path.K()},enumerable:!0,configurable:!0}),Ll.prototype.doc=function(t){if(ma("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=wu.mi()),ga("CollectionReference.doc","non-empty string",1,t),""===t)throw new Mr(Ur.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=ti.G(t);return Al.cm(this.Vm.path.child(e),this.firestore,this.fm)},Ll.prototype.add=function(t){ya("CollectionReference.add",arguments,1),ga("CollectionReference.add","object",1,this.fm?this.fm.toFirestore(t):t);var e=this.doc();return e.set(t).then(function(){return e})},Ll.prototype.withConverter=function(t){return new Ll(this.Om,this.firestore,t)},Ll);function Ll(t,e,n){var r=this;if(((r=ml.call(this,Uo.ve(t),e,n)||this).Om=t).length%2!=1)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.K()+" has "+t.length);return r}function Ol(t,e,n,r){this.lm=t,this.Nm=e,this.Fm=n,this.fm=r,this.$m=null,this.Mm=null,this.metadata=new _l(n.hasPendingWrites,n.fromCache)}function Vl(t,e,n){this.Vm=t,this.firestore=e,this.fm=n}function Pl(){return null!==gl&&gl.apply(this,arguments)||this}function Cl(t,e,n,r,i,o){this.lm=t,this.um=e,this.Rm=n,this.Am=r,this.Pm=i,this.fm=o}function Ul(t,e){this.hasPendingWrites=t,this.fromCache=e}function Ml(t,e,n){this.um=t,this.firestore=e,this.fm=n,this.JT=this.firestore.HT()}function Fl(t){this.lm=t,this.Tm=[],this.mm=!1}function jl(t,e){this.lm=t,this.dm=e}function ql(t,e,n){var r=this;if(void 0===n&&(n=new il),this.GT=null,this.zT=new Zu,this.INTERNAL={delete:function(){return f(r,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return this.HT(),[4,this.JT.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var i=t;this.GT=i,this.KT=ql.YT(i),this.XT=i.name,this.ZT=new jr(e)}else{var o=t;if(!o.projectId)throw new Mr(Ur.INVALID_ARGUMENT,"Must provide projectId");this.KT=new Au(o.projectId,o.database),this.XT="[DEFAULT]",this.ZT=new Fr}this.tm=n,this.em=new El({}),this.sm=this.nm(this.KT)}function Gl(t){var e,n;if(void 0===t.host){if(void 0!==t.ssl)throw new Mr(Ur.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else ba("settings","non-empty string","host",t.host),this.host=t.host,Ea("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(Sa("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),Ea("settings","object","credentials",t.credentials),this.credentials=t.credentials,Ea("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?yu("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&yu("Support for 'timestampsInSnapshots: false' will be removed soon. You must update your code to handle Timestamp objects."),this.timestampsInSnapshots=null===(n=t.timestampsInSnapshots)||void 0===n||n,Ea("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=ia.po;else{if(t.cacheSizeBytes!==bl&&t.cacheSizeBytes<ia.Vo)throw new Mr(Ur.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+ia.Vo);this.cacheSizeBytes=t.cacheSizeBytes}Ea("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}function Bl(t,e,n,r){this.firestore=t,this.timestampsInSnapshots=e,this.xT=n,this.converter=r}function zl(t,e){if(void 0===e)return{merge:!1};if(Sa(t,e,["merge","mergeFields"]),Ea(t,"boolean","merge",e.merge),n=t,void 0!==(r=e.mergeFields)&&function(t,e,n,r){if(!(n instanceof Array))throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+Aa(n));for(var i=0;i<n.length;++i)if(!r(n[i]))throw new Mr(Ur.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be a string or a FieldPath, but the value at index "+i+" was: "+Aa(n[i]))}(n,"mergeFields",r,function(t){return"string"==typeof t||t instanceof Ua}),void 0!==e.mergeFields&&void 0!==e.merge)throw new Mr(Ur.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');var n,r;return e}function Kl(t,e){return void 0===e?{}:(Sa(t,e,["serverTimestamps"]),Ta(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function Wl(t,e){wa(t,"object",1,e),e&&(Sa(t,e,["source"]),Ta(t,0,"source",e.source,["default","server","cache"]))}function Hl(t,e,n){if(e instanceof Al){if(e.firestore!==n)throw new Mr(Ur.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Da(t,"DocumentReference",1,e)}function Yl(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}var Xl,Jl=La(Tl,"Use firebase.firestore() instead."),Ql=La(Il,"Use firebase.firestore().runTransaction() instead."),Zl=La(Nl,"Use firebase.firestore().batch() instead."),$l=La(Al,"Use firebase.firestore().doc() instead."),tp=La(Sl),ep=La(Dl),np=La(kl),rp=La(xl),ip=La(Rl,"Use firebase.firestore().collection() instead."),op={Firestore:Jl,GeoPoint:nh,Timestamp:Br,Blob:Ca,Transaction:Ql,WriteBatch:Zl,DocumentReference:$l,DocumentSnapshot:tp,Query:np,QueryDocumentSnapshot:ep,QuerySnapshot:rp,CollectionReference:ip,FieldPath:Ua,FieldValue:eh,setLogLevel:Tl.setLogLevel,CACHE_SIZE_UNLIMITED:bl},sp=(yp.prototype.Hu=function(t){},yp.prototype.lc=function(){},yp),up=(dp.prototype.Hu=function(t){this.Qm.push(t)},dp.prototype.lc=function(){window.removeEventListener("online",this.xm),window.removeEventListener("offline",this.Um)},dp.prototype.Wm=function(){window.addEventListener("online",this.xm),window.addEventListener("offline",this.Um)},dp.prototype.Bm=function(){du("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.Qm;t<e.length;t++)(0,e[t])(0)},dp.prototype.qm=function(){du("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.Qm;t<e.length;t++)(0,e[t])(1)},dp.Uc=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},dp),ap=(pp.prototype._u=function(t){this.Gm=t},pp.prototype.ou=function(t){this.zm=t},pp.prototype.onMessage=function(t){this.Hm=t},pp.prototype.close=function(){this.Km()},pp.prototype.send=function(t){this.jm(t)},pp.prototype.Jm=function(){this.Gm()},pp.prototype.Ym=function(t){this.zm(t)},pp.prototype.Xm=function(t){this.Hm(t)},pp),hp={BatchGetDocuments:"batchGet",Commit:"commit"},cp="gl-js/ fire/"+Lr,fp=(lp.prototype.tE=function(t,e){if(e)for(var n in e.h)e.h.hasOwnProperty(n)&&(t[n]=e.h[n]);t["X-Goog-Api-Client"]=cp},lp.prototype.gu=function(a,r,i){var h=this,c=this.eE(a);return new Promise(function(o,s){var u=new Rr;u.listenOnce(kr.COMPLETE,function(){try{switch(u.getLastErrorCode()){case Dr.NO_ERROR:var t=u.getResponseJson();du("Connection","XHR received:",JSON.stringify(t)),o(t);break;case Dr.TIMEOUT:du("Connection",'RPC "'+a+'" timed out'),s(new Mr(Ur.DEADLINE_EXCEEDED,"Request time out"));break;case Dr.HTTP_ERROR:var e=u.getStatus();if(du("Connection",'RPC "'+a+'" failed with status:',e,"response text:",u.getResponseText()),0<e){var n=u.getResponseJson().error;if(n&&n.status&&n.message){var r=(i=n.status.toLowerCase().replace("_","-"),0<=Object.values(Ur).indexOf(i)?i:Ur.UNKNOWN);s(new Mr(r,n.message))}else s(new Mr(Ur.UNKNOWN,"Server responded with status "+u.getStatus()))}else du("Connection",'RPC "'+a+'" failed'),s(new Mr(Ur.UNAVAILABLE,"Connection failed."));break;default:mu('RPC "'+a+'" failed with unanticipated webchannel error '+u.getLastErrorCode()+": "+u.getLastError()+", giving up.")}}finally{du("Connection",'RPC "'+a+'" completed.')}var i});var t=Object.assign({},r);delete t.database;var e=JSON.stringify(t);du("Connection","XHR sending: ",c+" "+e);var n={"Content-Type":"text/plain"};h.tE(n,i),u.send(c,"POST",e,n,15)})},lp.prototype.yu=function(t,e,n){return this.gu(t,e,n)},lp.prototype.lu=function(t,e){var n,r,i=[this.Zm,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=Sr(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.cn.projectId+"/databases/"+this.cn.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.tE(s.initMessageHeaders,e),"undefined"!=typeof window&&(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(p())||"object"==typeof navigator&&"ReactNative"===navigator.product||0<=p().indexOf("Electron/")||0<=(r=p()).indexOf("MSIE ")||0<=r.indexOf("Trident/")||0<=p().indexOf("MSAppHost/")||"object"==typeof(n="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0)&&void 0!==n.id||(s.httpHeadersOverwriteParam="$httpHeaders");var u=i.join("");function a(t,e){h.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}du("Connection","Creating WebChannel: "+u+" "+s);var h=o.createWebChannel(u,s),c=!1,f=!1,l=new ap({jm:function(t){f?du("Connection","Not sending because WebChannel is closed:",t):(c||(du("Connection","Opening WebChannel transport."),h.open(),c=!0),du("Connection","WebChannel sending:",t),h.send(t))},Km:function(){return h.close()}});return a(xr.EventType.OPEN,function(){f||du("Connection","WebChannel transport opened.")}),a(xr.EventType.CLOSE,function(){f||(f=!0,du("Connection","WebChannel transport closed"),l.Ym())}),a(xr.EventType.ERROR,function(t){f||(f=!0,du("Connection","WebChannel transport errored:",t),l.Ym(new Mr(Ur.UNAVAILABLE,"The operation could not be completed")))}),a(xr.EventType.MESSAGE,function(t){var e;if(!f){var n=t.data[0];gu(!!n,"Got a webchannel message without data.");var r=n.error||(null===(e=n[0])||void 0===e?void 0:e.error);if(r){du("Connection","WebChannel received error:",r);var i=r.status,o=function(){var t=ds[i];if(void 0!==t)return As(t)}(),s=r.message;void 0===o&&(o=Ur.INTERNAL,s="Unknown error status: "+i+" with message "+r.message),f=!0,l.Ym(new Mr(o,s)),h.close()}else du("Connection","WebChannel received:",n),l.Xm(n)}}),setTimeout(function(){l.Jm()},0),l},lp.prototype.eE=function(t){var e=hp[t];return this.Zm+"/v1/projects/"+this.cn.projectId+"/databases/"+this.cn.database+"/documents:"+e},lp);function lp(t){this.cn=t.cn;var e=t.ssl?"https":"http";this.Zm=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}function pp(t){this.jm=t.jm,this.Km=t.Km}function dp(){var t=this;this.xm=function(){return t.Bm()},this.Um=function(){return t.qm()},this.Qm=[],this.Wm()}function yp(){}function vp(){this.dn=!0,this.ia="undefined"!=typeof atob}hu.fi((Object.defineProperty(vp.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(vp.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),vp.prototype.DT=function(t){return Promise.resolve(new fp(t))},vp.prototype.gT=function(){return new(up.Uc()?up:sp)},vp.prototype.yT=function(t){return new su(t,{dn:!0})},vp.prototype.Ti=function(t){return JSON.stringify(t)},vp.prototype.atob=function(t){return atob(t)},vp.prototype.btoa=function(t){return btoa(t)},new vp)),(Xl=mp).INTERNAL.registerComponent(new E("firestore",function(t){return e=t.getProvider("app").getImmediate(),n=t.getProvider("auth-internal"),new Tl(e,n,new ol);var e,n},"PUBLIC").setServiceProps(Object.assign({},op))),Xl.registerVersion("@firebase/firestore","1.14.1")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-firestore.js - be sure to load firebase-app.js first.")}});
//# sourceMappingURL=firebase-firestore.js.map