VUE_GabenParadise/node_modules/firebase/firebase-firestore.js

3 lines
283 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t=t||self).firebase)}(this,function(fp){"use strict";try{(function(){fp=fp&&Object.prototype.hasOwnProperty.call(fp,"default")?fp.default:fp;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 y(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 v(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 f,d=(n(g,f=Error),g);function g(t,e){var n=f.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,g.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,m.prototype.create),n}var m=(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 d(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"}function I(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var N,A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},_=_||{},S=A||self;function k(){}function D(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 x(t){var e=D(t);return"array"==e||"object"==e&&"number"==typeof t.length}function O(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var R="closure_uid_"+(1e9*Math.random()>>>0),P=0;function L(t,e,n){return t.call.apply(t.bind,arguments)}function V(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 C(t,e,n){return(C=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?L:V).apply(null,arguments)}function U(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}var j=Date.now||function(){return+new Date};function M(t,e){function n(){}n.prototype=e.prototype,t.M=e.prototype,t.prototype=new n,t.prototype.constructor=t}function q(){this.j=this.j,this.i=this.i}q.prototype.j=!1,q.prototype.da=function(){if(!this.j&&(this.j=!0,this.C(),0))t=this,Object.prototype.hasOwnProperty.call(t,R)&&t[R]||(t[R]=++P);var t},q.prototype.C=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var F=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},B=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i="string"==typeof t?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function G(t){return Array.prototype.concat.apply([],arguments)}function z(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 W(t){return/^[\s\xa0]*$/.test(t)}var K,Y=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 H(t,e){return t<e?-1:e<t?1:0}t:{var $=S.navigator;if($){var X=$.userAgent;if(X){K=X;break t}}K=""}function J(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function Z(t){var e={};for(var n in t)e[n]=t[n];return e}var tt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function et(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<tt.length;o++)n=tt[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function nt(t){return nt[" "](t),t}nt[" "]=k;var rt,it,ot=Q(K,"Opera"),st=Q(K,"Trident")||Q(K,"MSIE"),ut=Q(K,"Edge"),at=ut||st,ht=Q(K,"Gecko")&&!(Q(K.toLowerCase(),"webkit")&&!Q(K,"Edge"))&&!(Q(K,"Trident")||Q(K,"MSIE"))&&!Q(K,"Edge"),ct=Q(K.toLowerCase(),"webkit")&&!Q(K,"Edge");function ft(){var t=S.document;return t?t.documentMode:void 0}t:{var lt="",pt=(it=K,ht?/rv:([^\);]+)(\)|;)/.exec(it):ut?/Edge\/([\d\.]+)/.exec(it):st?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(it):ct?/WebKit\/(\S+)/.exec(it):ot?/(?:Version)[ \/]?(\S+)/.exec(it):void 0);if(pt&&(lt=pt?pt[1]:""),st){var dt=ft();if(null!=dt&&dt>parseFloat(lt)){rt=String(dt);break t}}rt=lt}var yt,vt={};function gt(u){return t=u,e=function(){for(var t=0,e=Y(String(rt)).split("."),n=Y(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=H(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||H(0==o[2].length,0==s[2].length)||H(o[2],s[2]),o=o[3],s=s[3]}while(0==t)}return 0<=t},n=vt,Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t);var t,e,n}if(S.document&&st){var mt=ft();yt=mt||(parseInt(rt,10)||void 0)}else yt=void 0;var wt=yt,bt=!st||9<=Number(wt),Et=st&&!gt("9"),Tt=function(){if(!S.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{S.addEventListener("test",k,e),S.removeEventListener("test",k,e)}catch(t){}return t}();function It(t,e){this.type=t,this.a=this.target=e,this.defaultPrevented=!1}function Nt(t,e){if(It.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(ht){t:{try{nt(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="string"==typeof t.pointerType?t.pointerType:At[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}It.prototype.b=function(){this.defaultPrevented=!0},M(Nt,It);var At={2:"touch",3:"pen",4:"mouse"};Nt.prototype.b=function(){Nt.M.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,Et)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var _t="closure_listenable_"+(1e6*Math.random()|0),St=0;function kt(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.aa=i,this.key=++St,this.V=this.X=!1}function Dt(t){t.V=!0,t.listener=null,t.proxy=null,t.src=null,t.aa=null}function xt(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=F(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(Dt(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function Rt(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.V&&o.listener==e&&o.capture==!!n&&o.aa==r)return i}return-1}xt.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Rt(t,e,r,i);return-1<s?(e=t[s],n||(e.X=!1)):((e=new kt(e,this.src,o,!!r,i)).X=n,t.push(e)),e};var Pt="closure_lm_"+(1e6*Math.random()|0),Lt={};function Vt(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(Array.isArray(n)){for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);return null}r=Gt(r);return e&&e[_t]?e.sa(n,r,O(i)?!!i.capture:!!i,o):Ct(e,n,r,!0,i,o)}(t,e,n,r,i);if(Array.isArray(e)){for(var o=0;o<e.length;o++)Vt(t,e[o],n,r,i);return null}return n=Gt(n),t&&t[_t]?t.ra(e,n,O(r)?!!r.capture:!!r,i):Ct(t,e,n,!1,r,i)}function Ct(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=O(i)?!!i.capture:!!i;if(s&&!bt)return null;var u,a,h=Ft(t);if(h||(t[Pt]=h=new xt(t)),(n=h.add(e,n,r,s,o)).proxy)return n;if(u=qt,r=a=bt?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)Tt||(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 Ut(t){if("number"!=typeof t&&t&&!t.V){var e=t.src;if(e&&e[_t])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=Ft(e))?(Ot(n,t),0==n.b&&(n.src=null,e[Pt]=null)):Dt(t)}}}function jt(t){return t in Lt?Lt[t]:Lt[t]="on"+t}function Mt(t,e){var n=t.listener,r=t.aa||t.src;return t.X&&Ut(t),n.call(r,e)}function qt(t,e){if(t.V)return!0;if(bt)return Mt(t,new Nt(e,this));if(!e)t:{e=["window","event"];for(var n=S,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}return Mt(t,e=new Nt(e,this))}function Ft(t){return(t=t[Pt])instanceof xt?t:null}var Bt="__closure_events_fn_"+(1e9*Math.random()>>>0);function Gt(e){return"function"==D(e)?e:(e[Bt]||(e[Bt]=function(t){return e.handleEvent(t)}),e[Bt])}function zt(){q.call(this),this.c=new xt(this),(this.J=this).A=null}function Wt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var s=e[o];if(s&&!s.V&&s.capture==n){var u=s.listener,a=s.aa||s.src;s.X&&Ot(t.c,s),i=!1!==u.call(a,r)&&i}}return i&&!r.defaultPrevented}M(zt,q),zt.prototype[_t]=!0,(N=zt.prototype).addEventListener=function(t,e,n,r){Vt(this,t,e,n,r)},N.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(Array.isArray(n))for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);else i=O(i)?!!i.capture:!!i,r=Gt(r),e&&e[_t]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Rt(s=e.a[n],r,i,o))&&(Dt(s[r]),Array.prototype.splice.call(s,r,1),0==s.length&&(delete e.a[n],e.b--))):(e=e&&Ft(e))&&(n=e.a[n.toString()],e=-1,n&&(e=Rt(n,r,i,o)),(r=-1<e?n[e]:null)&&Ut(r))}(this,t,e,n,r)},N.dispatchEvent=function(t){var e,n=this.A;if(n)for(e=[];n;n=n.A)e.push(n);n=this.J;var r=t.type||t;if("string"==typeof t)t=new It(t,n);else if(t instanceof It)t.target=t.target||n;else{var i=t;et(t=new It(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var s=t.a=e[o];i=Wt(s,r,!0,t)&&i}if(i=Wt(s=t.a=n,r,!0,t)&&i,i=Wt(s,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Wt(s=t.a=e[o],r,!1,t)&&i;return i},N.C=function(){if(zt.M.C.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++)Dt(n[r]);delete e.a[t],e.b--}}this.A=null},N.ra=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},N.sa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var Kt=S.JSON.stringify;function Yt(){this.b=this.a=null}var Qt,Ht=($t.prototype.get=function(){var t;return 0<this.b?(this.b--,t=this.a,this.a=t.next,t.next=null):t=this.c(),t},new $t(function(){return new Xt},function(t){t.reset()},100));function $t(t,e,n){this.f=n,this.c=t,this.g=e,this.b=0,this.a=null}function Xt(){this.next=this.b=this.a=null}function Jt(t){S.setTimeout(function(){throw t},0)}function Zt(t,e){var n;Qt||(n=S.Promise.resolve(void 0),Qt=function(){n.then(ne)}),te||(Qt(),te=!0),ee.add(t,e)}Yt.prototype.add=function(t,e){var n=Ht.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Xt.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var te=!(Xt.prototype.reset=function(){this.next=this.b=this.a=null}),ee=new Yt;function ne(){for(var t;r=n=void 0,r=null,(n=ee).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){Jt(t)}var e=Ht;e.g(t),e.b<e.f&&(e.b++,t.next=e.a,e.a=t)}var n,r;te=!1}function re(t,e){zt.call(this),this.b=t||1,this.a=e||S,this.f=C(this.Ua,this),this.g=j()}function ie(t){t.Z=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function oe(t,e,n){if("function"==D(t))n&&(t=C(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=C(t.handleEvent,t)}return 2147483647<Number(e)?-1:S.setTimeout(t,e||0)}function se(t,e,n){q.call(this),this.f=null!=n?C(t,n):t,this.c=e,this.b=C(this.Pa,this),this.a=[]}function ue(t){t.T=oe(t.b,t.c),t.f.apply(null,t.a)}function ae(t){q.call(this),this.b=t,this.a={}}M(re,zt),(N=re.prototype).Z=!1,N.L=null,N.Ua=function(){if(this.Z){var t=j()-this.g;0<t&&t<.8*this.b?this.L=this.a.setTimeout(this.f,this.b-t):(this.L&&(this.a.clearTimeout(this.L),this.L=null),this.dispatchEvent("tick"),this.Z&&(ie(this),this.start()))}},N.start=function(){this.Z=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=j())},N.C=function(){re.M.C.call(this),ie(this),delete this.a},M(se,q),(N=se.prototype).ba=!1,N.T=null,N.Ia=function(t){this.a=arguments,this.T?this.ba=!0:ue(this)},N.C=function(){se.M.C.call(this),this.T&&(S.clearTimeout(this.T),this.T=null,this.ba=!1,this.a=[])},N.Pa=function(){this.T=null,this.ba&&(this.ba=!1,ue(this))},M(ae,q);var he=[];function ce(t,e,n,r){Array.isArray(n)||(n&&(he[0]=n.toString()),n=he);for(var i=0;i<n.length;i++){var o=Vt(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function fe(t){J(t.a,function(t,e){this.a.hasOwnProperty(e)&&Ut(t)},t),t.a={}}function le(){}ae.prototype.C=function(){ae.M.C.call(this),fe(this)},ae.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var pe=null;function de(){return pe=pe||new zt}function ye(t){It.call(this,"serverreachability",t)}function ve(t){var e=de();e.dispatchEvent(new ye(e))}function ge(t){It.call(this,"statevent",t)}function me(t){var e=de();e.dispatchEvent(new ge(e))}function we(t){It.call(this,"timingevent",t)}function be(t,e){if("function"!=D(t))throw Error("Fn must not be null and must be a function");return S.setTimeout(function(){t()},e)}M(ye,It),M(ge,It),M(we,It);var Ee={NO_ERROR:0,Va:1,bb:2,ab:3,Ya:4,$a:5,cb:6,za:7,TIMEOUT:8,gb:9},Te={Xa:"complete",kb:"success",Aa:"error",za:"abort",ib:"ready",jb:"readystatechange",TIMEOUT:"timeout",eb:"incrementaldata",hb:"progress",Za:"downloadprogress",lb:"uploadprogress"};function Ie(){}function Ne(t){var e;return(e=t.a)||(e=t.a={}),e}function Ae(){}Ie.prototype.a=null;var _e,Se={OPEN:"a",Wa:"b",Aa:"c",fb:"d"};function ke(){It.call(this,"d")}function De(){It.call(this,"c")}function xe(){}function Oe(t,e,n){this.g=t,this.W=e,this.U=n||1,this.G=new ae(this),this.N=Re,t=at?125:void 0,this.O=new re(t),this.m=null,this.b=!1,this.j=this.A=this.f=this.B=this.s=this.P=this.h=null,this.i=[],this.a=null,this.w=0,this.c=this.v=null,this.H=-1,this.l=!1,this.J=0,this.D=null,this.o=this.R=this.F=!1}M(ke,It),M(De,It),M(xe,Ie),_e=new xe;var Re=45e3,Pe={},Le={};function Ve(t,e,n){t.B=1,t.f=rn(Xe(e)),t.j=n,t.F=!0,Ce(t,null)}function Ce(t,e){t.s=j(),Me(t),t.A=Xe(t.f);var n=t.A,r=t.U;Array.isArray(r)||(r=[String(r)]),gn(n.b,"t",r),t.w=0,t.a=ar(t.g,t.g.w?e:null),0<t.J&&(t.D=new se(C(t.ya,t,t.a),t.J)),ce(t.G,t.a,"readystatechange",t.Sa),e=t.m?Z(t.m):{},t.j?(t.v||(t.v="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.$(t.A,t.v,t.j,e)):(t.v="GET",t.a.$(t.A,t.v,null,e)),ve(1)}function Ue(t,e,n){for(var r=!0;!t.l&&t.w<n.length;){var i=je(t,n);if(i==Le){4==e&&(t.c=4,me(14),r=!1);break}if(i==Pe){t.c=4,me(15),r=!1;break}ze(t,i)}4==e&&0==n.length&&(t.c=1,me(16),r=!1),t.b=t.b&&r,r||(Ge(t),Be(t))}function je(t,e){var n=t.w,r=e.indexOf("\n",n);return-1==r?Le:(n=Number(e.substring(n,r)),isNaN(n)?Pe:(r+=1)+n>e.length?Le:(e=e.substr(r,n),t.w=r+n,e))}function Me(t){t.P=j()+t.N,qe(t,t.N)}function qe(t,e){if(null!=t.h)throw Error("WatchDog timer not null");t.h=be(C(t.Qa,t),e)}function Fe(t){t.h&&(S.clearTimeout(t.h),t.h=null)}function Be(t){0==t.g.u||t.l||rr(t.g,t)}function Ge(t){Fe(t);var e=t.D;e&&"function"==typeof e.da&&e.da(),t.D=null,ie(t.O),fe(t.G),t.a&&(e=t.a,t.a=null,e.abort(),e.da())}function ze(t,e){try{var n=t.g;if(0!=n.u&&(n.a==t||Nn(n.b,t)))if(n.A=t.H,!t.o&&Nn(n.b,t)&&3==n.u){try{var r=n.ja.a.parse(e)}catch(t){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.i){if(n.a){if(!(n.a.s+3e3<t.s))break t;nr(n),n.a.cancel(),n.a=null}er(n),me(18)}}else n.ia=i[1],0<n.ia-n.G&&i[2]<37500&&n.U&&0==n.m&&!n.l&&(n.l=be(C(n.Na,n),6e3));if(In(n.b)<=1&&n.O){try{n.O()}catch(t){}n.O=void 0}}else or(n,11)}else if(!t.o&&n.a!=t||nr(n),!W(e))for(e=r=n.ja.a.parse(e),r=0;r<e.length;r++)if(i=e[r],n.G=i[0],i=i[1],2==n.u)if("c"==i[0]){n.B=i[1],n.R=i[2];var o=i[3];null!=o&&(n.oa=o);var s=i[5];null!=s&&"number"==typeof s&&0<s&&(n.D=1.5*s);var u=n,a=t.a;if(a){var h=a.a?a.a.getResponseHeader("X-Client-Wire-Protocol"):null;if(h){var c=u.b;!c.a&&(Q(h,"spdy")||Q(h,"quic")||Q(h,"h2"))&&(c.f=c.g,c.a=new Set,c.b&&(An(c,c.b),c.b=null))}if(u.s){var f=a.a?a.a.getResponseHeader("X-HTTP-Session-Id"):null;f&&(u.ha=f,nn(u.v,u.s,f))}}n.u=3,n.c&&n.c.na();var l=t;if((u=n).ea=ur(u,u.w?u.R:null,u.P),l.o){_n(u.b,l);var p=l,d=u.D;d&&p.setTimeout(d),p.h&&(Fe(p),Me(p)),u.a=l}else tr(u);0<n.f.length&&$n(n)}else"stop"!=i[0]&&"close"!=i[0]||or(n,7);else 3==n.u&&("stop"==i[0]||"close"==i[0]?"stop"==i[0]?or(n,7):Yn(n):"noop"!=i[0]&&n.c&&n.c.ma(i),n.m=0);ve(4)}catch(t){}}function We(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(x(t)||"string"==typeof t)B(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.I&&"function"==typeof t.I)n=void 0;else if(x(t)||"string"==typeof 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.I&&"function"==typeof t.I)return t.I();if("string"==typeof t)return t.split("");if(x(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function Ke(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 Ke)for(n=t.K(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Ye(t){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)}(N=Oe.prototype).setTimeout=function(t){this.N=t},N.Sa=function(t){t=t.target;var e=this.D;e&&3==Gn(t)?e.Ia():this.ya(t)},N.ya=function(t){try{if(t==this.a)t:{var e=Gn(this.a),n=this.a.qa(),r=this.a.S();if(!(e<3||3==e&&!at&&!this.a.Y())){this.l||4!=e||7==n||ve(8==n||r<=0?3:2),Fe(this);var i=this.a.S();this.H=i;var o=this.a.Y();if(this.b=200==i){if(this.R&&!this.o){e:{if(this.a){var s,u=this.a;if((s=u.a?u.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!W(s)){var a=s;break e}}a=null}if(!a){this.b=!1,this.c=3,me(12),Ge(this),Be(this);break t}this.o=!0,ze(this,a)}this.F?(Ue(this,e,o),at&&this.b&&3==e&&(ce(this.G,this.O,"tick",this.Ra),this.O.start())):ze(this,o),4==e&&Ge(this),this.b&&!this.l&&(4==e?rr(this.g,this):(this.b=!1,Me(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,me(12)):(this.c=0,me(13)),Ge(this),Be(this)}}}catch(t){}},N.Ra=function(){if(this.a){var t=Gn(this.a),e=this.a.Y();this.w<e.length&&(Fe(this),Ue(this,t,e),this.b&&4!=t&&Me(this))}},N.cancel=function(){this.l=!0,Ge(this)},N.Qa=function(){this.h=null;var t=j();0<=t-this.P?(2!=this.B&&(ve(3),me(17)),Ge(this),this.c=2,Be(this)):qe(this,this.P-t)},(N=Ke.prototype).I=function(){Ye(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},N.K=function(){return Ye(this),this.a.concat()},N.get=function(t,e){return Qe(this.b,t)?this.b[t]:e},N.set=function(t,e){Qe(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},N.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 He=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function $e(t,e){if(this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,t instanceof $e){this.a=void 0!==e?e:t.a,Je(this,t.f),this.j=t.j,Ze(this,t.c),tn(this,t.h),this.g=t.g,e=t.b;var n=new pn;n.c=e.c,e.a&&(n.a=new Ke(e.a),n.b=e.b),en(this,n),this.i=t.i}else t&&(n=String(t).match(He))?(this.a=!!e,Je(this,n[1]||"",!0),this.j=on(n[2]||""),Ze(this,n[3]||"",!0),tn(this,n[4]),this.g=on(n[5]||"",!0),en(this,n[6]||"",!0),this.i=on(n[7]||"")):(this.a=!!e,this.b=new pn(null,this.a))}function Xe(t){return new $e(t)}function Je(t,e,n){t.f=n?on(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function Ze(t,e,n){t.c=n?on(e,!0):e}function tn(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.h=e}else t.h=null}function en(t,e,n){var r,i;e instanceof pn?(t.b=e,r=t.b,(i=t.a)&&!r.f&&(dn(r),r.c=null,r.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(yn(this,e),gn(this,n,t))},r)),r.f=i):(n||(e=sn(e,fn)),t.b=new pn(e,t.a))}function nn(t,e,n){t.b.set(e,n)}function rn(t){return nn(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^j()).toString(36)),t}function on(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function sn(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,un),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function un(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(sn(e,an,!0),":");var n=this.c;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(sn(e,an,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.h)&&t.push(":",String(n))),(n=this.g)&&(this.c&&"/"!=n.charAt(0)&&t.push("/"),t.push(sn(n,"/"==n.charAt(0)?cn:hn,!0))),(n=this.b.toString())&&t.push("?",n),(n=this.i)&&t.push("#",sn(n,ln)),t.join("")};var an=/[#\/\?@]/g,hn=/[#\?:]/g,cn=/[#\?]/g,fn=/[#\?@]/g,ln=/#/g;function pn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function dn(n){n.a||(n.a=new Ke,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 yn(t,e){dn(t),e=mn(t,e),Qe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Qe((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Ye(t)))}function vn(t,e){return dn(t),e=mn(t,e),Qe(t.a.b,e)}function gn(t,e,n){yn(t,e),0<n.length&&(t.c=null,t.a.set(mn(t,e),z(n)),t.b+=n.length)}function mn(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function wn(t,e){this.b=t,this.a=e}function bn(t){this.g=t||En,t=S.PerformanceNavigationTiming?0<(t=S.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(S.ca&&S.ca.ua&&S.ca.ua()&&S.ca.ua().mb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Set),this.b=null,this.c=[]}(N=pn.prototype).add=function(t,e){dn(this),this.c=null,t=mn(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},N.forEach=function(n,r){dn(this),this.a.forEach(function(t,e){B(t,function(t){n.call(r,t,e,this)},this)},this)},N.K=function(){dn(this);for(var t=this.a.I(),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},N.I=function(t){dn(this);var e=[];if("string"==typeof t)vn(this,t)&&(e=G(e,this.a.get(mn(this,t))));else{t=this.a.I();for(var n=0;n<t.length;n++)e=G(e,t[n])}return e},N.set=function(t,e){return dn(this),this.c=null,vn(this,t=mn(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},N.get=function(t,e){return t&&0<(t=this.I(t)).length?String(t[0]):e},N.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.I(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("&")};var En=10;function Tn(t){return t.b||t.a&&t.a.size>=t.f}function In(t){return t.b?1:t.a?t.a.size:0}function Nn(t,e){return t.b?t.b==e:t.a&&t.a.has(e)}function An(t,e){t.a?t.a.add(e):t.b=e}function _n(t,e){t.b&&t.b==e?t.b=null:t.a&&t.a.has(e)&&t.a.delete(e)}function Sn(t){var e,n;if(null!=t.b)return t.c.concat(t.b.i);if(null==t.a||0===t.a.size)return z(t.c);var r=t.c;try{for(var i=I(t.a.values()),o=i.next();!o.done;o=i.next()){var s=o.value;r=r.concat(s.i)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}function kn(){}function Dn(){this.a=new kn}function xn(t,r,e){var i=e||"";try{We(t,function(t,e){var n=t;O(t)&&(n=Kt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function On(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}bn.prototype.cancel=function(){var e,t;if(this.c=Sn(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&0!==this.a.size){try{for(var n=I(this.a.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.a.clear()}},kn.prototype.stringify=function(t){return S.JSON.stringify(t,void 0)},kn.prototype.parse=function(t){return S.JSON.parse(t,void 0)};var Rn=S.JSON.parse;function Pn(t){zt.call(this),this.headers=new Ke,this.G=t||null,this.b=!1,this.s=this.a=null,this.D="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.H=Ln,this.B=this.F=!1}M(Pn,zt);var Ln="",Vn=/^https?$/i,Cn=["POST","PUT"];function Un(t){return"content-type"==t.toLowerCase()}function jn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Mn(t),Fn(t)}function Mn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function qn(t){if(t.b&&void 0!==_&&(!t.s[1]||4!=Gn(t)||2!=t.S()))if(t.l&&4==Gn(t))oe(t.va,0,t);else if(t.dispatchEvent("readystatechange"),4==Gn(t)){t.b=!1;try{var e,n=t.S();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.D).match(He)[1]||null;if(!o&&S.self&&S.self.location){var s=S.self.location.protocol;o=s.substr(0,s.length-1)}i=!Vn.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var u=2<Gn(t)?t.a.statusText:""}catch(t){u=""}t.f=u+" ["+t.S()+"]",Mn(t)}}finally{Fn(t)}}}function Fn(t,e){if(t.a){Bn(t);var n=t.a,r=t.s[0]?k:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function Bn(t){t.a&&t.B&&(t.a.ontimeout=null),t.m&&(S.clearTimeout(t.m),t.m=null)}function Gn(t){return t.a?t.a.readyState:0}function zn(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}var i;r||(i="",J(n,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),n=i,"string"==typeof t?null!=n&&encodeURIComponent(String(n)):nn(t,e,n))}function Wn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Kn(t){this.f=[],this.R=this.ea=this.v=this.P=this.a=this.ha=this.s=this.N=this.h=this.F=this.j=null,this.Fa=this.H=0,this.Ca=Wn("failFast",!1,t),this.U=this.l=this.i=this.g=this.c=null,this.W=!0,this.A=this.ia=this.G=-1,this.J=this.m=this.o=0,this.Ba=Wn("baseRetryDelayMs",5e3,t),this.Ga=Wn("retryDelaySeedMs",1e4,t),this.Da=Wn("forwardChannelMaxRetries",2,t),this.ga=Wn("forwardChannelRequestTimeoutMs",2e4,t),this.Ea=t&&t.nb||void 0,this.D=void 0,this.w=t&&t.supportsCrossDomainXhr||!1,this.B="",this.b=new bn(t&&t.concurrentRequestLimit),this.ja=new Dn,this.fa=t&&t.fastHandshake||!1,t&&t.forceLongPolling&&(this.W=!1),this.O=void 0}function Yn(t){if(Qn(t),3==t.u){var e=t.H++,n=Xe(t.v);nn(n,"SID",t.B),nn(n,"RID",e),nn(n,"TYPE","terminate"),Jn(t,n),(e=new Oe(t,e,void 0)).B=2,e.f=rn(Xe(n)),n=!1,S.navigator&&S.navigator.sendBeacon&&(n=S.navigator.sendBeacon(e.f.toString(),"")),!n&&S.Image&&((new Image).src=e.f,n=!0),n||(e.a=ar(e.g,null),e.a.$(e.f)),e.s=j(),Me(e)}sr(t)}function Qn(t){t.a&&(t.a.cancel(),t.a=null),t.i&&(S.clearTimeout(t.i),t.i=null),nr(t),t.b.cancel(),t.g&&("number"==typeof t.g&&S.clearTimeout(t.g),t.g=null)}function Hn(t,e){t.f.push(new wn(t.Fa++,e)),3==t.u&&$n(t)}function $n(t){Tn(t.b)||t.g||(t.g=!0,Zt(t.xa,t),t.o=0)}function Xn(t,e){var n;n=e?e.W:t.H++;var r=Xe(t.v);nn(r,"SID",t.B),nn(r,"RID",n),nn(r,"AID",t.G),Jn(t,r),t.h&&t.j&&zn(r,t.h,t.j),n=new Oe(t,n,t.o+1),null===t.h&&(n.m=t.j),e&&(t.f=e.i.concat(t.f)),e=Zn(t,n,1e3),n.setTimeout(Math.round(.5*t.ga)+Math.round(.5*t.ga*Math.random())),An(t.b,n),Ve(n,r,e)}function Jn(t,n){t.c&&We({},function(t,e){nn(n,e,t)})}function Zn(t,e,n){n=Math.min(t.f.length,n);var r=t.c?C(t.c.Ha,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{xn(c,s,"req"+h+"_")}catch(t){r&&r(c)}}if(u){r=s.join("&");break t}}return t=t.f.splice(0,n),e.i=t,r}function tr(t){t.a||t.i||(t.J=1,Zt(t.wa,t),t.m=0)}function er(t){return!(t.a||t.i||3<=t.m)&&(t.J++,t.i=be(C(t.wa,t),ir(t,t.m)),t.m++,1)}function nr(t){null!=t.l&&(S.clearTimeout(t.l),t.l=null)}function rr(t,e){var n=null;if(t.a==e){nr(t),t.a=null;var r=2}else{if(!Nn(t.b,e))return;n=e.i,_n(t.b,e),r=1}if(t.A=e.H,0!=t.u)if(e.b)if(1==r){n=e.j?e.j.length:0,e=j()-e.s;var i=t.o;(r=de()).dispatchEvent(new we(r)),$n(t)}else tr(t);else if(3==(i=e.c)||0==i&&0<t.A||!(1==r&&function(t,e){if(!(In(t.b)>=t.b.f-(t.g?1:0))){if(t.g)return t.f=e.i.concat(t.f),1;if(!(1==t.u||2==t.u||t.o>=(t.Ca?0:t.Da)))return t.g=be(C(t.xa,t,e),ir(t,t.o)),t.o++,1}}(t,e)||2==r&&er(t)))switch(n&&0<n.length&&(e=t.b,e.c=e.c.concat(n)),i){case 1:or(t,5);break;case 4:or(t,10);break;case 3:or(t,6);break;default:or(t,2)}}function ir(t,e){var n=t.Ba+Math.floor(Math.random()*t.Ga);return t.c||(n*=2),n*e}function or(t,e){if(2==e){var n=null;t.c&&(n=null);var r=C(t.Ta,t);n||(n=new $e("//www.google.com/images/cleardot.gif"),S.location&&"http"==S.location.protocol||Je(n,"https"),rn(n)),function(t,e){var n=new le;if(S.Image){var r=new Image;r.onload=U(On,n,r,"TestLoadImage: loaded",!0,e),r.onerror=U(On,n,r,"TestLoadImage: error",!1,e),r.onabort=U(On,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=U(On,n,r,"TestLoadImage: timeout",!1,e),S.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}else e(!1)}(n.toString(),r)}else me(2);t.u=0,t.c&&t.c.la(e),sr(t),Qn(t)}function sr(t){t.u=0,t.A=-1,t.c&&(0==Sn(t.b).length&&0==t.f.length||(t.b.c.length=0,z(t.f),t.f.length=0),t.c.ka())}function ur(t,e,n){var r,i,o,s,u,a,h=(r=n)instanceof $e?Xe(r):new $e(r,void 0);if(""!=h.c)e&&Ze(h,e+"."+h.c),tn(h,h.h);else{var c=S.location;i=c.protocol,o=e?e+"."+c.hostname:c.hostname,s=+c.port,u=n,a=new $e(null,void 0),i&&Je(a,i),o&&Ze(a,o),s&&tn(a,s),u&&(a.g=u),h=a}return t.N&&J(t.N,function(t,e){nn(h,e,t)}),e=t.s,n=t.ha,e&&n&&nn(h,e,n),nn(h,"VER",t.oa),Jn(t,h),h}function ar(t,e){if(e&&!t.w)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new Pn(t.Ea)).F=t.w,e}function hr(){}function cr(){if(st&&!(10<=Number(wt)))throw Error("Environmental error: no available transport.")}function fr(t,e){zt.call(this),this.a=new Kn(e),this.l=t,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.j=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.pa&&(t?t["X-WebChannel-Client-Profile"]=e.pa:t={"X-WebChannel-Client-Profile":e.pa}),this.a.F=t,(t=e&&e.httpHeadersOverwriteParam)&&!W(t)&&(this.a.h=t),this.h=e&&e.supportsCrossDomainXhr||!1,this.g=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!W(e)&&(this.a.s=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new dr(this)}function lr(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 pr(){De.call(this),this.status=1}function dr(t){this.a=t}(N=Pn.prototype).$=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+t);e=e?e.toUpperCase():"GET",this.D=t,this.f="",this.h=0,this.v=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.G?Ne(this.G):Ne(_e),this.a.onreadystatechange=C(this.va,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void jn(this,t)}t=n||"";var i,o=new Ke(this.headers);r&&We(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Un,n=t.length,r="string"==typeof 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:"string"==typeof t?t.charAt(e):t[e]}(o.K()),n=S.FormData&&t instanceof S.FormData,0<=F(Cn,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.H&&(this.a.responseType=this.H),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{Bn(this),0<this.o&&((this.B=(i=this.a,st&&gt(9)&&"number"==typeof i.timeout&&void 0!==i.ontimeout))?(this.a.timeout=this.o,this.a.ontimeout=C(this.ta,this)):this.m=oe(this.ta,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){jn(this,t)}},N.ta=function(){void 0!==_&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},N.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"),Fn(this))},N.C=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Fn(this,!0)),Pn.M.C.call(this)},N.va=function(){this.j||(this.w||this.l||this.g?qn(this):this.Oa())},N.Oa=function(){qn(this)},N.S=function(){try{return 2<Gn(this)?this.a.status:-1}catch(t){return-1}},N.Y=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},N.Ja=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Rn(e)}},N.qa=function(){return this.h},N.Ma=function(){return"string"==typeof this.f?this.f:String(this.f)},(N=Kn.prototype).oa=8,N.u=1,N.xa=function(t){if(this.g)if(this.g=null,1==this.u){if(!t){this.H=Math.floor(1e5*Math.random()),t=this.H++;var e,n=new Oe(this,t,void 0),r=this.j;if(this.F&&(r?et(r=Z(r),this.F):r=this.F),null===this.h&&(n.m=r),this.fa)t:{for(var i=e=0;i<this.f.length;i++){var o=this.f[i];if("__data__"in o.a&&"string"==typeof(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=Zn(this,n,e),nn(i=Xe(this.v),"RID",t),nn(i,"CVER",22),this.s&&nn(i,"X-HTTP-Session-Id",this.s),Jn(this,i),this.h&&r&&zn(i,this.h,r),An(this.b,n),this.fa?(nn(i,"$req",e),nn(i,"SID","null"),n.R=!0,Ve(n,i,null)):Ve(n,i,e),this.u=2}}else 3==this.u&&(t?Xn(this,t):0==this.f.length||Tn(this.b)||Xn(this))},N.wa=function(){this.i=null,this.a=new Oe(this,"rpc",this.J),null===this.h&&(this.a.m=this.j),this.a.J=0;var t=Xe(this.ea);nn(t,"RID","rpc"),nn(t,"SID",this.B),nn(t,"CI",this.U?"0":"1"),nn(t,"AID",this.G),Jn(this,t),nn(t,"TYPE","xmlhttp"),this.h&&this.j&&zn(t,this.h,this.j),this.D&&this.a.setTimeout(this.D);var e=this.a,n=this.R;e.B=1,e.f=rn(Xe(t)),e.j=null,e.F=!0,Ce(e,n)},N.Na=function(){null!=this.l&&(this.l=null,this.a.cancel(),this.a=null,er(this),me(19))},N.Ta=function(t){me(t?2:1)},(N=hr.prototype).na=function(){},N.ma=function(){},N.la=function(){},N.ka=function(){},N.Ha=function(){},cr.prototype.a=function(t,e){return new fr(t,e)},M(fr,zt),(N=fr.prototype).addEventListener=function(t,e,n,r){fr.M.addEventListener.call(this,t,e,n,r)},N.removeEventListener=function(t,e,n,r){fr.M.removeEventListener.call(this,t,e,n,r)},N.Ka=function(){this.a.c=this.f,this.h&&(this.a.w=!0);var t=this.a,e=this.l,n=this.b||void 0;me(0),t.P=e,t.N=n||{},t.U=t.W,t.v=ur(t,null,t.P),$n(t)},N.close=function(){Yn(this.a)},N.La=function(t){if("string"==typeof t){var e={};e.__data__=t,Hn(this.a,e)}else this.g?((e={}).__data__=Kt(t),Hn(this.a,e)):Hn(this.a,t)},N.C=function(){this.a.c=null,delete this.f,Yn(this.a),delete this.a,fr.M.C.call(this)},M(lr,ke),M(pr,De),M(dr,hr),dr.prototype.na=function(){this.a.dispatchEvent("a")},dr.prototype.ma=function(t){this.a.dispatchEvent(new lr(t))},dr.prototype.la=function(t){this.a.dispatchEvent(new pr)},dr.prototype.ka=function(){this.a.dispatchEvent("b")},cr.prototype.createWebChannel=cr.prototype.a,fr.prototype.send=fr.prototype.La,fr.prototype.open=fr.prototype.Ka,fr.prototype.close=fr.prototype.close,Ee.NO_ERROR=0,Ee.TIMEOUT=8,Ee.HTTP_ERROR=6,Te.COMPLETE="complete",(Ae.EventType=Se).OPEN="a",Se.CLOSE="b",Se.ERROR="c",Se.MESSAGE="d",zt.prototype.listen=zt.prototype.ra,Pn.prototype.listenOnce=Pn.prototype.sa,Pn.prototype.getLastError=Pn.prototype.Ma,Pn.prototype.getLastErrorCode=Pn.prototype.qa,Pn.prototype.getStatus=Pn.prototype.S,Pn.prototype.getResponseJson=Pn.prototype.Ja,Pn.prototype.getResponseText=Pn.prototype.Y,Pn.prototype.send=Pn.prototype.$;var yr={createWebChannelTransport:function(){return new cr},ErrorCode:Ee,EventType:Te,WebChannel:Ae,XhrIo:Pn},vr=yr.createWebChannelTransport,gr=yr.ErrorCode,mr=yr.EventType,wr=yr.WebChannel,br=yr.XhrIo,Er=fp.SDK_VERSION,Tr=(Ir.prototype.t=function(){return null!=this.uid},Ir.prototype.s=function(){return this.t()?"uid:"+this.uid:"anonymous-user"},Ir.prototype.isEqual=function(t){return t.uid===this.uid},Ir);function Ir(t){this.uid=t}Tr.UNAUTHENTICATED=new Tr(null),Tr.i=new Tr("google-credentials-uid"),Tr.h=new Tr("first-party-uid");function Nr(t,e){this.user=e,this.type="OAuth",this.o={},this.o.Authorization="Bearer "+t}var Ar,_r,Sr={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"},kr=(n(Wr,_r=Error),Wr),Dr=(zr.prototype.getToken=function(){return Promise.resolve(null)},zr.prototype._=function(){},zr.prototype.l=function(t){(this.u=t)(Tr.UNAUTHENTICATED)},zr.prototype.T=function(){this.u=null},zr),xr=(Gr.prototype.getToken=function(){var e=this,n=this.A,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.A!==n)throw new kr(Sr.ABORTED,"getToken aborted due to token change.");return t?(Zs("string"==typeof t.accessToken),new Nr(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},Gr.prototype._=function(){this.forceRefresh=!0},Gr.prototype.l=function(t){this.u=t,this.R&&t(this.currentUser)},Gr.prototype.T=function(){this.auth&&this.auth.removeAuthTokenListener(this.I),this.I=null,this.u=null},Gr.prototype.m=function(){var t=this.auth&&this.auth.getUid();return Zs(null===t||"string"==typeof t),new Tr(t)},Gr),Or=(Object.defineProperty(Br.prototype,"o",{get:function(){var t={"X-Goog-AuthUser":this.V},e=this.P.auth.g([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),Br),Rr=(Fr.prototype.getToken=function(){return Promise.resolve(new Or(this.P,this.V))},Fr.prototype.l=function(t){t(Tr.h)},Fr.prototype.T=function(){},Fr.prototype._=function(){},Fr),Pr=(qr.now=function(){return qr.fromMillis(Date.now())},qr.fromDate=function(t){return qr.fromMillis(t.getTime())},qr.fromMillis=function(t){var e=Math.floor(t/1e3);return new qr(e,1e6*(t-1e3*e))},qr.prototype.toDate=function(){return new Date(this.toMillis())},qr.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},qr.prototype.p=function(t){return this.seconds===t.seconds?ru(this.nanoseconds,t.nanoseconds):ru(this.seconds,t.seconds)},qr.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},qr.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},qr.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},qr),Lr=(Mr.v=function(t){return new Mr(t)},Mr.min=function(){return new Mr(new Pr(0,0))},Mr.prototype.S=function(t){return this.timestamp.p(t.timestamp)},Mr.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Mr.prototype.D=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Mr.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Mr.prototype.C=function(){return this.timestamp},Mr),Vr=(Object.defineProperty(jr.prototype,"length",{get:function(){return this.F},enumerable:!0,configurable:!0}),jr.prototype.isEqual=function(t){return 0===jr.N(this,t)},jr.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof jr?t.forEach(function(t){e.push(t)}):e.push(t),this.$(e)},jr.prototype.limit=function(){return this.offset+this.length},jr.prototype.k=function(t){return t=void 0===t?1:t,this.$(this.segments,this.offset+t,this.length-t)},jr.prototype.L=function(){return this.$(this.segments,this.offset,this.length-1)},jr.prototype.M=function(){return this.segments[this.offset]},jr.prototype.O=function(){return this.get(this.length-1)},jr.prototype.get=function(t){return this.segments[this.offset+t]},jr.prototype.B=function(){return 0===this.length},jr.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},jr.prototype.U=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},jr.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},jr.prototype.W=function(){return this.segments.slice(this.offset,this.limit())},jr.N=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},jr),Cr=(n(Ur,Ar=Vr),Ur.prototype.$=function(t,e,n){return new Ur(t,e,n)},Ur.prototype.j=function(){return this.W().join("/")},Ur.prototype.toString=function(){return this.j()},Ur.K=function(t){if(0<=t.indexOf("//"))throw new kr(Sr.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new Ur(t.split("/").filter(function(t){return 0<t.length}))},Ur);function Ur(){return null!==Ar&&Ar.apply(this,arguments)||this}function jr(t,e,n){void 0===e?e=0:e>t.length&&Js(),void 0===n?n=t.length-e:n>t.length-e&&Js(),this.segments=t,this.offset=e,this.F=n}function Mr(t){this.timestamp=t}function qr(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new kr(Sr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new kr(Sr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new kr(Sr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new kr(Sr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function Fr(t,e){this.P=t,this.V=e}function Br(t,e){this.P=t,this.V=e,this.type="FirstParty",this.user=Tr.h}function Gr(t){var e=this;this.I=null,this.currentUser=Tr.UNAUTHENTICATED,this.R=!1,this.A=0,this.u=null,this.forceRefresh=!1,this.I=function(){e.A++,e.currentUser=e.m(),e.R=!0,e.u&&e.u(e.currentUser)},this.A=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.I):(this.I(null),t.get().then(function(t){e.auth=t,e.I&&e.auth.addAuthTokenListener(e.I)},function(){}))}function zr(){this.u=null}function Wr(t,e){var n=this;return(n=_r.call(this,e)||this).code=t,n.message=e,n.name="FirebaseError",n.toString=function(){return n.name+": [code="+n.code+"]: "+n.message},n}Cr.G=new Cr([]);var Kr,Yr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Qr=(n(Hr,Kr=Vr),Hr.prototype.$=function(t,e,n){return new Hr(t,e,n)},Hr.H=function(t){return Yr.test(t)},Hr.prototype.j=function(){return this.W().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),Hr.H(t)||(t="`"+t+"`"),t}).join(".")},Hr.prototype.toString=function(){return this.j()},Hr.prototype.Y=function(){return 1===this.length&&"__name__"===this.get(0)},Hr.J=function(){return new Hr(["__name__"])},Hr.X=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new kr(Sr.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 kr(Sr.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[r+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new kr(Sr.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 kr(Sr.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new Hr(e)},Hr);function Hr(){return null!==Kr&&Kr.apply(this,arguments)||this}Qr.G=new Qr([]);var $r=(Xr.Z=function(t){return new Xr(Cr.K(t).k(5))},Xr.prototype.tt=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},Xr.prototype.isEqual=function(t){return null!==t&&0===Cr.N(this.path,t.path)},Xr.prototype.toString=function(){return this.path.toString()},Xr.N=function(t,e){return Cr.N(t.path,e.path)},Xr.et=function(t){return t.length%2==0},Xr.st=function(t){return new Xr(new Cr(t.slice()))},Xr);function Xr(t){this.path=t}function Jr(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Zr(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}$r.EMPTY=new $r(new Cr([]));var ei=(ni.fromBase64String=function(t){return new ni(zs.nt().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 zs.nt().btoa(this.it)},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.it)},ni.prototype.rt=function(){return 2*this.it.length},ni.prototype.S=function(t){return ru(this.it,t.it)},ni.prototype.isEqual=function(t){return this.it===t.it},ni);function ni(t){this.it=t}function ri(t){return null==t}function ii(t){return-0===t&&1/t==-1/0}function oi(t){return"number"==typeof t&&Number.isInteger(t)&&!ii(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}function si(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 ui(t){var e=yi(t.mapValue.fields.__local_write_time__.timestampValue);return new Pr(e.seconds,e.nanos)}ei.ht=new ei("");var ai=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function hi(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?si(t)?4:10:Js()}function ci(i,t){var e,n,r,o=hi(i);if(o!==hi(t))return!1;switch(o){case 0:return!0;case 1:return i.booleanValue===t.booleanValue;case 4:return ui(i).isEqual(ui(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=yi(i.timestampValue),n=yi(t.timestampValue);return e.seconds===n.seconds&&e.nanos===n.nanos}(t);case 5:return i.stringValue===t.stringValue;case 6:return r=t,gi(i.bytesValue).isEqual(gi(r.bytesValue));case 7:return i.referenceValue===t.referenceValue;case 8:return n=t,vi((e=i).geoPointValue.latitude)===vi(n.geoPointValue.latitude)&&vi(e.geoPointValue.longitude)===vi(n.geoPointValue.longitude);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return vi(t.integerValue)===vi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=vi(t.doubleValue),r=vi(e.doubleValue);return n===r?ii(n)===ii(r):isNaN(n)&&isNaN(r)}return!1}(i,t);case 9:return iu(i.arrayValue.values||[],t.arrayValue.values||[],ci);case 10:return function(t){var e=i.mapValue.fields||{},n=t.mapValue.fields||{};if(Jr(e)!==Jr(n))return!1;for(var r in e)if(e.hasOwnProperty(r)&&(void 0===n[r]||!ci(e[r],n[r])))return!1;return!0}(t);default:return Js()}}function fi(t,e){return void 0!==(t.values||[]).find(function(t){return ci(t,e)})}function li(t,e){var n,r,i,o,s,u,a,h,c,f,l=hi(t),p=hi(e);if(l!==p)return ru(l,p);switch(l){case 0:return 0;case 1:return ru(t.booleanValue,e.booleanValue);case 2:return h=e,c=vi(t.integerValue||t.doubleValue),f=vi(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(ui(t),ui(e));case 5:return ru(t.stringValue,e.stringValue);case 6:return o=t.bytesValue,s=e.bytesValue,u=gi(o),a=gi(s),u.S(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=ru(n[i],r[i]);if(0!==o)return o}return ru(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return n=t.geoPointValue,r=e.geoPointValue,0!==(i=ru(vi(n.latitude),vi(r.latitude)))?i:ru(vi(n.longitude),vi(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=li(n[i],r[i]);if(o)return o}return ru(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=ru(r[s],o[s]);if(0!==u)return u;var a=li(n[r[s]],i[o[s]]);if(0!==a)return a}return ru(r.length,o.length)}(t.mapValue,e.mapValue);default:throw Js()}}function pi(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return ru(t,e);var n=yi(t),r=yi(e),i=ru(n.seconds,r.seconds);return 0!==i?i:ru(n.nanos,r.nanos)}function di(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=yi(i.timestampValue)).seconds+","+t.nanos+")":"stringValue"in i?i.stringValue:"bytesValue"in i?gi(i.bytesValue).toBase64():"referenceValue"in i?(n=i.referenceValue,$r.Z(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):Js();var t,e,n}(t)}function yi(t){if(Zs(!!t),"string"!=typeof t)return{seconds:vi(t.seconds),nanos:vi(t.nanos)};var e=0,n=ai.exec(t);if(Zs(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}function vi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function gi(t){return"string"==typeof t?ei.fromBase64String(t):ei.fromUint8Array(t)}function mi(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.j()}}function wi(t){return t&&"integerValue"in t}function bi(t){return!!t&&"arrayValue"in t}function Ei(t){return t&&"nullValue"in t}function Ti(t){return t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Ii(t){return t&&"mapValue"in t}var Ni=(Ai.prototype.ot=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},Ai.prototype.at=function(t,e){return e},Ai.prototype.ut=function(t){return null},Ai.prototype.isEqual=function(t){return t instanceof Ai},Ai);function Ai(){}Ni.instance=new Ni;var _i=(Oi.prototype.ot=function(t,e){return this.apply(t)},Oi.prototype.at=function(t,e){return this.apply(t)},Oi.prototype.apply=function(t){for(var n=Ri(t),e=function(e){n.some(function(t){return ci(t,e)})||n.push(e)},r=0,i=this.elements;r<i.length;r++)e(i[r]);return{arrayValue:{values:n}}},Oi.prototype.ut=function(t){return null},Oi.prototype.isEqual=function(t){return t instanceof Oi&&iu(this.elements,t.elements,ci)},Oi),Si=(xi.prototype.ot=function(t,e){return this.apply(t)},xi.prototype.at=function(t,e){return this.apply(t)},xi.prototype.apply=function(t){for(var n=Ri(t),e=function(e){n=n.filter(function(t){return!ci(t,e)})},r=0,i=this.elements;r<i.length;r++)e(i[r]);return{arrayValue:{values:n}}},xi.prototype.ut=function(t){return null},xi.prototype.isEqual=function(t){return t instanceof xi&&iu(this.elements,t.elements,ci)},xi),ki=(Di.prototype.ot=function(t,e){var n=this.ut(t),r=this.asNumber(n)+this.asNumber(this.ct);return wi(n)&&wi(this.ct)?this.serializer._t(r):this.serializer.lt(r)},Di.prototype.at=function(t,e){return e},Di.prototype.ut=function(t){return wi(e=t)||e&&"doubleValue"in e?t:{integerValue:0};var e},Di.prototype.isEqual=function(t){return t instanceof Di&&ci(this.ct,t.ct)},Di.prototype.asNumber=function(t){return vi(t.integerValue||t.doubleValue)},Di);function Di(t,e){this.serializer=t,this.ct=e}function xi(t){this.elements=t}function Oi(t){this.elements=t}function Ri(t){return bi(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function Pi(t,e){this.version=t,this.transformResults=e}var Li,Vi,Ci,Ui,ji,Mi=(so.prototype.dt=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].q(t))return!0;return!1},so.prototype.isEqual=function(t){return iu(this.fields,t.fields,function(t,e){return t.isEqual(e)})},so),qi=(oo.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},oo),Fi=(io.ft=function(){return new io},io.exists=function(t){return new io(void 0,t)},io.updateTime=function(t){return new io(t)},Object.defineProperty(io.prototype,"Tt",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),io.prototype.Et=function(t){return void 0!==this.updateTime?t instanceof To&&t.version.isEqual(this.updateTime):void 0===this.exists||this.exists===t instanceof To},io.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},io),Bi=(ro.prototype.It=function(t){},ro.wt=function(t){return t instanceof To?t.version:Lr.min()},ro),Gi=(n(no,ji=Bi),no.prototype.at=function(t,e){this.It(t);var n=e.version;return new To(this.key,n,this.value,{hasCommittedMutations:!0})},no.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=Bi.wt(t);return new To(this.key,r,this.value,{At:!0})},no.prototype.Pt=function(t){return null},no.prototype.isEqual=function(t){return t instanceof no&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.Rt.isEqual(t.Rt)},no),zi=(n(eo,Ui=Bi),eo.prototype.at=function(t,e){if(this.It(t),!this.Rt.Et(t))return new No(this.key,e.version);var n=this.gt(t);return new To(this.key,e.version,n,{hasCommittedMutations:!0})},eo.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=Bi.wt(t),i=this.gt(t);return new To(this.key,r,i,{At:!0})},eo.prototype.Pt=function(t){return null},eo.prototype.isEqual=function(t){return t instanceof eo&&this.key.isEqual(t.key)&&this.Vt.isEqual(t.Vt)&&this.Rt.isEqual(t.Rt)},eo.prototype.gt=function(t){var e;return e=t instanceof To?t.data():Qi.empty(),this.pt(e)},eo.prototype.pt=function(t){var n=this,r=new Hi(t);return this.Vt.fields.forEach(function(t){if(!t.B()){var e=n.data.field(t);null!==e?r.set(t,e):r.delete(t)}}),r.yt()},eo),Wi=(n(to,Ci=Bi),to.prototype.at=function(t,e){if(this.It(t),Zs(null!=e.transformResults),!this.Rt.Et(t))return new No(this.key,e.version);var n=this.bt(t),r=this.vt(t,e.transformResults),i=e.version,o=this.St(n.data(),r);return new To(this.key,i,o,{hasCommittedMutations:!0})},to.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=this.bt(t),i=this.Dt(n,t,e),o=this.St(r.data(),i);return new To(this.key,r.version,o,{At:!0})},to.prototype.Pt=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof To?t.field(i.field):void 0,s=i.transform.ut(o||null);null!=s&&(e=null==e?(new Hi).set(i.field,s):e.set(i.field,s))}return e?e.yt():null},to.prototype.isEqual=function(t){return t instanceof to&&this.key.isEqual(t.key)&&iu(this.fieldTransforms,t.fieldTransforms,function(t,e){return t.isEqual(e)})&&this.Rt.isEqual(t.Rt)},to.prototype.bt=function(t){return t},to.prototype.vt=function(t,e){var n=[];Zs(this.fieldTransforms.length===e.length);for(var r=0;r<e.length;r++){var i=this.fieldTransforms[r],o=i.transform,s=null;t instanceof To&&(s=t.field(i.field)),n.push(o.at(s,e[r]))}return n},to.prototype.Dt=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 To&&(a=e.field(s.field)),null===a&&n instanceof To&&(a=n.field(s.field)),r.push(u.ot(a,t))}return r},to.prototype.St=function(t,e){for(var n=new Hi(t),r=0;r<this.fieldTransforms.length;r++){var i=this.fieldTransforms[r].field;n.set(i,e[r])}return n.yt()},to),Ki=(n(Zi,Vi=Bi),Zi.prototype.at=function(t,e){return this.It(t),new Io(this.key,e.version,{hasCommittedMutations:!0})},Zi.prototype.ot=function(t,e,n){return this.It(t),this.Rt.Et(t)?new Io(this.key,Lr.min()):t},Zi.prototype.Pt=function(t){return null},Zi.prototype.isEqual=function(t){return t instanceof Zi&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},Zi),Yi=(n(Ji,Li=Bi),Ji.prototype.at=function(t,e){Js()},Ji.prototype.ot=function(t,e,n){Js()},Ji.prototype.Pt=function(t){Js()},Ji.prototype.isEqual=function(t){return t instanceof Ji&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},Ji),Qi=(Xi.empty=function(){return new Xi({mapValue:{}})},Xi.prototype.field=function(t){if(t.B())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!Ii(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t.O()])||null},Xi.prototype.isEqual=function(t){return ci(this.proto,t.proto)},Xi),Hi=($i.prototype.set=function(t,e){return this.Nt(t,e),this},$i.prototype.delete=function(t){return this.Nt(t,null),this},$i.prototype.Nt=function(t,e){for(var n=this.Ft,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map||(o=o&&10===hi(o)?new Map(Object.entries(o.mapValue.fields||{})):new Map,n.set(i,o)),n=o}n.set(t.O(),e)},$i.prototype.yt=function(){var t=this.$t(Qr.G,this.Ft);return null!=t?new Qi(t):this.Ct},$i.prototype.$t=function(r,t){var i=this,o=!1,e=this.Ct.field(r),s=Ii(e)?Object.assign({},e.mapValue.fields):{};return t.forEach(function(t,e){if(t instanceof Map){var n=i.$t(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},$i);function $i(t){void 0===t&&(t=Qi.empty()),this.Ct=t,this.Ft=new Map}function Xi(t){this.proto=t}function Ji(t,e){var n=this;return(n=Li.call(this)||this).key=t,n.Rt=e,n.type=4,n}function Zi(t,e){var n=this;return(n=Vi.call(this)||this).key=t,n.Rt=e,n.type=3,n}function to(t,e){var n=this;return(n=Ci.call(this)||this).key=t,n.fieldTransforms=e,n.type=2,n.Rt=Fi.exists(!0),n}function eo(t,e,n,r){var i=this;return(i=Ui.call(this)||this).key=t,i.data=e,i.Vt=n,i.Rt=r,i.type=1,i}function no(t,e,n){var r=this;return(r=ji.call(this)||this).key=t,r.value=e,r.Rt=n,r.type=0,r}function ro(){}function io(t,e){this.updateTime=t,this.exists=e}function oo(t,e){this.field=t,this.transform=e}function so(t){(this.fields=t).sort(Qr.N)}function uo(t){var u=[];return Zr(t.fields||{},function(t,e){var n=new Qr([t]);if(Ii(e)){var r=uo(e.mapValue).fields;if(0===r.length)u.push(n);else for(var i=0,o=r;i<o.length;i++){var s=o[i];u.push(n.child(s))}}else u.push(n)}),new Mi(u)}function ao(t,e){this.key=t,this.version=e}function ho(t){this.count=t}var co,fo,lo,po,yo,vo,go,mo,wo,bo,Eo,To=(n(Ho,Eo=ao),Ho.prototype.field=function(t){return this.kt.field(t)},Ho.prototype.data=function(){return this.kt},Ho.prototype.Lt=function(){return this.kt.proto},Ho.prototype.isEqual=function(t){return t instanceof Ho&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.At===t.At&&this.hasCommittedMutations===t.hasCommittedMutations&&this.kt.isEqual(t.kt)},Ho.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.kt.toString()+", {hasLocalMutations: "+this.At+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(Ho.prototype,"hasPendingWrites",{get:function(){return this.At||this.hasCommittedMutations},enumerable:!0,configurable:!0}),Ho),Io=(n(Qo,bo=ao),Qo.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(Qo.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),Qo.prototype.isEqual=function(t){return t instanceof Qo&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Qo),No=(n(Yo,wo=ao),Yo.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Yo.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),Yo.prototype.isEqual=function(t){return t instanceof Yo&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Yo),Ao=(Ko.prototype.canonicalId=function(){if(null===this.Mt){var t=this.path.j();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(","),ri(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.Mt=t}return this.Mt},Ko.prototype.toString=function(){var t=this.path.j();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),ri(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+")"},Ko.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)},Ko.prototype.Ot=function(){return $r.et(this.path)&&null===this.collectionGroup&&0===this.filters.length},Ko),_o=(Wo.Wt=function(t){return new Wo(t)},Object.defineProperty(Wo.prototype,"orderBy",{get:function(){if(null===this.qt){this.qt=[];var t=this.jt(),e=this.Kt();if(null!==t&&null===e)t.Y()||this.qt.push(new Lo(t)),this.qt.push(new Lo(Qr.J(),"asc"));else{for(var n=!1,r=0,i=this.xt;r<i.length;r++){var o=i[r];this.qt.push(o),o.field.Y()&&(n=!0)}if(!n){var s=0<this.xt.length?this.xt[this.xt.length-1].dir:"asc";this.qt.push(new Lo(Qr.J(),s))}}}return this.qt},enumerable:!0,configurable:!0}),Wo.prototype.Gt=function(t){var e=this.filters.concat([t]);return new Wo(this.path,this.collectionGroup,this.xt.slice(),e,this.limit,this.Bt,this.startAt,this.endAt)},Wo.prototype.zt=function(t){var e=this.xt.concat([t]);return new Wo(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},Wo.prototype.Ht=function(t){return new Wo(this.path,this.collectionGroup,this.xt.slice(),this.filters.slice(),t,"F",this.startAt,this.endAt)},Wo.prototype.Yt=function(t){return new Wo(this.path,this.collectionGroup,this.xt.slice(),this.filters.slice(),t,"L",this.startAt,this.endAt)},Wo.prototype.Jt=function(t){return new Wo(this.path,this.collectionGroup,this.xt.slice(),this.filters.slice(),this.limit,this.Bt,t,this.endAt)},Wo.prototype.Xt=function(t){return new Wo(this.path,this.collectionGroup,this.xt.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,t)},Wo.prototype.Zt=function(t){return new Wo(t,null,this.xt.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},Wo.prototype.te=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.xt.length||1===this.xt.length&&this.xt[0].field.Y())},Wo.prototype.canonicalId=function(){return this.ee().canonicalId()+"|lt:"+this.Bt},Wo.prototype.toString=function(){return"Query(target="+this.ee().toString()+"; limitType="+this.Bt+")"},Wo.prototype.isEqual=function(t){return this.ee().isEqual(t.ee())&&this.Bt===t.Bt},Wo.prototype.se=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},Wo.prototype.matches=function(t){return this.ie(t)&&this.ne(t)&&this.re(t)&&this.he(t)},Wo.prototype.oe=function(){return!ri(this.limit)&&"F"===this.Bt},Wo.prototype.ae=function(){return!ri(this.limit)&&"L"===this.Bt},Wo.prototype.Kt=function(){return 0<this.xt.length?this.xt[0].field:null},Wo.prototype.jt=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof So&&n.ue())return n.field}return null},Wo.prototype.ce=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof So&&0<=t.indexOf(r.op))return r.op}return null},Wo.prototype.Ot=function(){return this.ee().Ot()},Wo.prototype._e=function(){return null!==this.collectionGroup},Wo.prototype.ee=function(){if(!this.Ut)if("F"===this.Bt)this.Ut=new Ao(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="desc"===r.dir?"asc":"desc";t.push(new Lo(r.field,i))}var o=this.endAt?new Po(this.endAt.position,!this.endAt.before):null,s=this.startAt?new Po(this.startAt.position,!this.startAt.before):null;this.Ut=new Ao(this.path,this.collectionGroup,t,this.filters,this.limit,o,s)}return this.Ut},Wo.prototype.ie=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.tt(this.collectionGroup)&&this.path.q(e):$r.et(this.path)?this.path.isEqual(e):this.path.U(e)},Wo.prototype.ne=function(t){for(var e=0,n=this.xt;e<n.length;e++){var r=n[e];if(!r.field.Y()&&null===t.field(r.field))return!1}return!0},Wo.prototype.re=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},Wo.prototype.he=function(t){return!(this.startAt&&!this.startAt.le(this.orderBy,t)||this.endAt&&this.endAt.le(this.orderBy,t))},Wo.prototype.Qt=function(t){},Wo),So=(n(zo,mo=function(){}),zo.create=function(t,e,n){if(t.Y())return"in"===e?new Do(t,n):new ko(t,e,n);if(Ei(n)){if("=="!==e)throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new zo(t,e,n)}if(Ti(n)){if("=="!==e)throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new zo(t,e,n)}return"array-contains"===e?new xo(t,n):"in"===e?new Oo(t,n):"array-contains-any"===e?new Ro(t,n):new zo(t,e,n)},zo.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&hi(this.value)===hi(e)&&this.de(li(e,this.value))},zo.prototype.de=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case">":return 0<t;case">=":return 0<=t;default:return Js()}},zo.prototype.ue=function(){return 0<=["<","<=",">",">="].indexOf(this.op)},zo.prototype.canonicalId=function(){return this.field.j()+this.op.toString()+di(this.value)},zo.prototype.isEqual=function(t){return t instanceof zo&&this.op===t.op&&this.field.isEqual(t.field)&&ci(this.value,t.value)},zo.prototype.toString=function(){return this.field.j()+" "+this.op+" "+di(this.value)},zo),ko=(n(Go,go=So),Go.prototype.matches=function(t){var e=$r.N(t.key,this.key);return this.de(e)},Go),Do=(n(Bo,vo=So),Bo.prototype.matches=function(e){return this.keys.some(function(t){return t.isEqual(e.key)})},Bo),xo=(n(Fo,yo=So),Fo.prototype.matches=function(t){var e=t.field(this.field);return bi(e)&&fi(e.arrayValue,this.value)},Fo),Oo=(n(qo,po=So),qo.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&fi(this.value.arrayValue,e)},qo),Ro=(n(Mo,lo=So),Mo.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!bi(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(t){return fi(e.value.arrayValue,t)})},Mo),Po=(jo.prototype.canonicalId=function(){return(this.before?"b":"a")+":"+this.position.map(function(t){return di(t)}).join(",")},jo.prototype.le=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()?$r.N($r.Z(o.referenceValue),e.key):li(o,e.field(i.field)),"desc"===i.dir&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},jo.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(!ci(this.position[e],t.position[e]))return!1;return!0},jo),Lo=(Uo.prototype.compare=function(t,e){var n,r,i,o,s=this.fe?$r.N(t.key,e.key):(n=this.field,r=e,i=t.field(n),o=r.field(n),null!==i&&null!==o?li(i,o):Js());switch(this.dir){case"asc":return s;case"desc":return-1*s;default:return Js()}},Uo.prototype.canonicalId=function(){return this.field.j()+this.dir.toString()},Uo.prototype.toString=function(){return this.field.j()+" ("+this.dir+")"},Uo.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},Uo),Vo=(Co.prototype.Ie=function(t){return new Co(this.target,this.targetId,this.Te,t,this.Ee,this.lastLimboFreeSnapshotVersion,this.resumeToken)},Co.prototype.we=function(t,e){return new Co(this.target,this.targetId,this.Te,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},Co.prototype.Re=function(t){return new Co(this.target,this.targetId,this.Te,this.sequenceNumber,this.Ee,t,this.resumeToken)},Co);function Co(t,e,n,r,i,o,s){void 0===i&&(i=Lr.min()),void 0===o&&(o=Lr.min()),void 0===s&&(s=ei.ht),this.target=t,this.targetId=e,this.Te=n,this.sequenceNumber=r,this.Ee=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}function Uo(t,e){this.field=t,void 0===e&&(e="asc"),this.dir=e,this.fe=t.Y()}function jo(t,e){this.position=t,this.before=e}function Mo(t,e){return lo.call(this,t,"array-contains-any",e)||this}function qo(t,e){return po.call(this,t,"in",e)||this}function Fo(t,e){return yo.call(this,t,"array-contains",e)||this}function Bo(t,e){var n=this;return(n=vo.call(this,t,"in",e)||this).keys=(e.arrayValue.values||[]).map(function(t){return $r.Z(t.referenceValue)}),n}function Go(t,e,n){var r=this;return(r=go.call(this,t,e,n)||this).key=$r.Z(n.referenceValue),r}function zo(t,e,n){var r=this;return(r=mo.call(this)||this).field=t,r.op=e,r.value=n,r}function Wo(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.xt=n,this.filters=r,this.limit=i,this.Bt=o,this.startAt=s,this.endAt=u,this.qt=null,this.Ut=null,this.startAt&&this.Qt(this.startAt),this.endAt&&this.Qt(this.endAt)}function Ko(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.Mt=null}function Yo(){return null!==wo&&wo.apply(this,arguments)||this}function Qo(t,e,n){var r=this;return(r=bo.call(this,t,e)||this).hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}function Ho(t,e,n,r){var i=this;return(i=Eo.call(this,t,e)||this).kt=n,i.At=!!r.At,i.hasCommittedMutations=!!r.hasCommittedMutations,i}function $o(t){switch(t){case Sr.OK:return Js();case Sr.CANCELLED:case Sr.UNKNOWN:case Sr.DEADLINE_EXCEEDED:case Sr.RESOURCE_EXHAUSTED:case Sr.INTERNAL:case Sr.UNAVAILABLE:case Sr.UNAUTHENTICATED:return;case Sr.INVALID_ARGUMENT:case Sr.NOT_FOUND:case Sr.ALREADY_EXISTS:case Sr.PERMISSION_DENIED:case Sr.FAILED_PRECONDITION:case Sr.ABORTED:case Sr.OUT_OF_RANGE:case Sr.UNIMPLEMENTED:case Sr.DATA_LOSS:return 1;default:return Js()}}function Xo(t){if(void 0===t)return $s("GRPC error has no .code"),Sr.UNKNOWN;switch(t){case co.OK:return Sr.OK;case co.CANCELLED:return Sr.CANCELLED;case co.UNKNOWN:return Sr.UNKNOWN;case co.DEADLINE_EXCEEDED:return Sr.DEADLINE_EXCEEDED;case co.RESOURCE_EXHAUSTED:return Sr.RESOURCE_EXHAUSTED;case co.INTERNAL:return Sr.INTERNAL;case co.UNAVAILABLE:return Sr.UNAVAILABLE;case co.UNAUTHENTICATED:return Sr.UNAUTHENTICATED;case co.INVALID_ARGUMENT:return Sr.INVALID_ARGUMENT;case co.NOT_FOUND:return Sr.NOT_FOUND;case co.ALREADY_EXISTS:return Sr.ALREADY_EXISTS;case co.PERMISSION_DENIED:return Sr.PERMISSION_DENIED;case co.FAILED_PRECONDITION:return Sr.FAILED_PRECONDITION;case co.ABORTED:return Sr.ABORTED;case co.OUT_OF_RANGE:return Sr.OUT_OF_RANGE;case co.UNIMPLEMENTED:return Sr.UNIMPLEMENTED;case co.DATA_LOSS:return Sr.DATA_LOSS;default:return Js()}}(fo=co=co||{})[fo.OK=0]="OK",fo[fo.CANCELLED=1]="CANCELLED",fo[fo.UNKNOWN=2]="UNKNOWN",fo[fo.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",fo[fo.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",fo[fo.NOT_FOUND=5]="NOT_FOUND",fo[fo.ALREADY_EXISTS=6]="ALREADY_EXISTS",fo[fo.PERMISSION_DENIED=7]="PERMISSION_DENIED",fo[fo.UNAUTHENTICATED=16]="UNAUTHENTICATED",fo[fo.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",fo[fo.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",fo[fo.ABORTED=10]="ABORTED",fo[fo.OUT_OF_RANGE=11]="OUT_OF_RANGE",fo[fo.UNIMPLEMENTED=12]="UNIMPLEMENTED",fo[fo.INTERNAL=13]="INTERNAL",fo[fo.UNAVAILABLE=14]="UNAVAILABLE",fo[fo.DATA_LOSS=15]="DATA_LOSS";var Jo=(rs.prototype.Ae=function(t,e){return new rs(this.N,this.root.Ae(t,e,this.N).me(null,null,ts.Pe,null,null))},rs.prototype.remove=function(t){return new rs(this.N,this.root.remove(t,this.N).me(null,null,ts.Pe,null,null))},rs.prototype.get=function(t){for(var e=this.root;!e.B();){var n=this.N(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},rs.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.B();){var r=this.N(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},rs.prototype.B=function(){return this.root.B()},Object.defineProperty(rs.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),rs.prototype.Ve=function(){return this.root.Ve()},rs.prototype.ge=function(){return this.root.ge()},rs.prototype.pe=function(t){return this.root.pe(t)},rs.prototype.forEach=function(n){this.pe(function(t,e){return n(t,e),!1})},rs.prototype.toString=function(){var n=[];return this.pe(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},rs.prototype.ye=function(t){return this.root.ye(t)},rs.prototype.be=function(){return new Zo(this.root,null,this.N,!1)},rs.prototype.ve=function(t){return new Zo(this.root,t,this.N,!1)},rs.prototype.Se=function(){return new Zo(this.root,null,this.N,!0)},rs.prototype.De=function(t){return new Zo(this.root,t,this.N,!0)},rs),Zo=(ns.prototype.Ne=function(){var t=this.Fe.pop(),e={key:t.key,value:t.value};if(this.Ce)for(t=t.left;!t.B();)this.Fe.push(t),t=t.right;else for(t=t.right;!t.B();)this.Fe.push(t),t=t.left;return e},ns.prototype.$e=function(){return 0<this.Fe.length},ns.prototype.ke=function(){if(0===this.Fe.length)return null;var t=this.Fe[this.Fe.length-1];return{key:t.key,value:t.value}},ns),ts=(es.prototype.me=function(t,e,n,r,i){return new es(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)},es.prototype.B=function(){return!1},es.prototype.pe=function(t){return this.left.pe(t)||t(this.key,this.value)||this.right.pe(t)},es.prototype.ye=function(t){return this.right.ye(t)||t(this.key,this.value)||this.left.ye(t)},es.prototype.min=function(){return this.left.B()?this:this.left.min()},es.prototype.Ve=function(){return this.min().key},es.prototype.ge=function(){return this.right.B()?this.key:this.right.ge()},es.prototype.Ae=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.me(null,null,null,r.left.Ae(t,e,n),null):0===i?r.me(null,e,null,null,null):r.me(null,null,null,null,r.right.Ae(t,e,n))).Le()},es.prototype.Me=function(){if(this.left.B())return es.EMPTY;var t=this;return t.left.Oe()||t.left.left.Oe()||(t=t.xe()),(t=t.me(null,null,null,t.left.Me(),null)).Le()},es.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.B()||r.left.Oe()||r.left.left.Oe()||(r=r.xe()),r=r.me(null,null,null,r.left.remove(t,e),null);else{if(r.left.Oe()&&(r=r.Be()),r.right.B()||r.right.Oe()||r.right.left.Oe()||(r=r.qe()),0===e(t,r.key)){if(r.right.B())return es.EMPTY;n=r.right.min(),r=r.me(n.key,n.value,null,null,r.right.Me())}r=r.me(null,null,null,null,r.right.remove(t,e))}return r.Le()},es.prototype.Oe=function(){return this.color},es.prototype.Le=function(){var t=this;return t.right.Oe()&&!t.left.Oe()&&(t=t.Ue()),t.left.Oe()&&t.left.left.Oe()&&(t=t.Be()),t.left.Oe()&&t.right.Oe()&&(t=t.Qe()),t},es.prototype.xe=function(){var t=this.Qe();return t.right.left.Oe()&&(t=(t=(t=t.me(null,null,null,null,t.right.Be())).Ue()).Qe()),t},es.prototype.qe=function(){var t=this.Qe();return t.left.left.Oe()&&(t=(t=t.Be()).Qe()),t},es.prototype.Ue=function(){var t=this.me(null,null,es.RED,null,this.right.left);return this.right.me(null,null,this.color,t,null)},es.prototype.Be=function(){var t=this.me(null,null,es.RED,this.left.right,null);return this.left.me(null,null,this.color,null,t)},es.prototype.Qe=function(){var t=this.left.me(null,null,!this.left.color,null,null),e=this.right.me(null,null,!this.right.color,null,null);return this.me(null,null,!this.color,t,e)},es.prototype.We=function(){var t=this.je();return Math.pow(2,t)<=this.size+1},es.prototype.je=function(){if(this.Oe()&&this.left.Oe())throw Js();if(this.right.Oe())throw Js();var t=this.left.je();if(t!==this.right.je())throw Js();return t+(this.Oe()?0:1)},es);function es(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:es.RED,this.left=null!=r?r:es.EMPTY,this.right=null!=i?i:es.EMPTY,this.size=this.left.size+1+this.right.size}function ns(t,e,n,r){this.Ce=r,this.Fe=[];for(var i=1;!t.B();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.Ce?t.left:t.right;else{if(0===i){this.Fe.push(t);break}this.Fe.push(t),t=this.Ce?t.right:t.left}}function rs(t,e){this.N=t,this.root=e||ts.EMPTY}function is(){this.size=0}ts.EMPTY=null,ts.RED=!0,ts.Pe=!1,ts.EMPTY=(Object.defineProperty(is.prototype,"key",{get:function(){throw Js()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"value",{get:function(){throw Js()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"color",{get:function(){throw Js()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"left",{get:function(){throw Js()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"right",{get:function(){throw Js()},enumerable:!0,configurable:!0}),is.prototype.me=function(t,e,n,r,i){return this},is.prototype.Ae=function(t,e,n){return new ts(t,e)},is.prototype.remove=function(t,e){return this},is.prototype.B=function(){return!0},is.prototype.pe=function(t){return!1},is.prototype.ye=function(t){return!1},is.prototype.Ve=function(){return null},is.prototype.ge=function(){return null},is.prototype.Oe=function(){return!1},is.prototype.We=function(){return!0},is.prototype.je=function(){return 0},new is);var os=(hs.prototype.has=function(t){return null!==this.data.get(t)},hs.prototype.first=function(){return this.data.Ve()},hs.prototype.last=function(){return this.data.ge()},Object.defineProperty(hs.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),hs.prototype.indexOf=function(t){return this.data.indexOf(t)},hs.prototype.forEach=function(n){this.data.pe(function(t,e){return n(t),!1})},hs.prototype.Ke=function(t,e){for(var n=this.data.ve(t[0]);n.$e();){var r=n.Ne();if(0<=this.N(r.key,t[1]))return;e(r.key)}},hs.prototype.Ge=function(t,e){var n;for(n=void 0!==e?this.data.ve(e):this.data.be();n.$e();)if(!t(n.Ne().key))return},hs.prototype.ze=function(t){var e=this.data.ve(t);return e.$e()?e.Ne().key:null},hs.prototype.be=function(){return new ss(this.data.be())},hs.prototype.ve=function(t){return new ss(this.data.ve(t))},hs.prototype.add=function(t){return this.me(this.data.remove(t).Ae(t,!0))},hs.prototype.delete=function(t){return this.has(t)?this.me(this.data.remove(t)):this},hs.prototype.B=function(){return this.data.B()},hs.prototype.He=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach(function(t){e=e.add(t)}),e},hs.prototype.isEqual=function(t){if(!(t instanceof hs))return!1;if(this.size!==t.size)return!1;for(var e=this.data.be(),n=t.data.be();e.$e();){var r=e.Ne().key,i=n.Ne().key;if(0!==this.N(r,i))return!1}return!0},hs.prototype.W=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},hs.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},hs.prototype.me=function(t){var e=new hs(this.N);return e.data=t,e},hs),ss=(as.prototype.Ne=function(){return this.Ye.Ne().key},as.prototype.$e=function(){return this.Ye.$e()},as),us=new Jo($r.N);function as(t){this.Ye=t}function hs(t){this.N=t,this.data=new Jo(this.N)}function cs(){return us}function fs(){return cs()}var ls=new Jo($r.N);function ps(){return ls}var ds=new Jo($r.N);function ys(){return ds}var vs=new os($r.N);function gs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=vs,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var ms=new os(ru);function ws(){return ms}function bs(t,e,n,r){this.ws=t,this.removedTargetIds=e,this.key=n,this.Rs=r}function Es(t,e){this.targetId=t,this.As=e}function Ts(t,e,n,r){void 0===n&&(n=ei.ht),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}var Is=(Cs.Ze=function(t){return new Cs(t.N)},Cs.prototype.has=function(t){return null!=this.Je.get(t)},Cs.prototype.get=function(t){return this.Je.get(t)},Cs.prototype.first=function(){return this.Xe.Ve()},Cs.prototype.last=function(){return this.Xe.ge()},Cs.prototype.B=function(){return this.Xe.B()},Cs.prototype.indexOf=function(t){var e=this.Je.get(t);return e?this.Xe.indexOf(e):-1},Object.defineProperty(Cs.prototype,"size",{get:function(){return this.Xe.size},enumerable:!0,configurable:!0}),Cs.prototype.forEach=function(n){this.Xe.pe(function(t,e){return n(t),!1})},Cs.prototype.add=function(t){var e=this.delete(t.key);return e.me(e.Je.Ae(t.key,t),e.Xe.Ae(t,null))},Cs.prototype.delete=function(t){var e=this.get(t);return e?this.me(this.Je.remove(t),this.Xe.remove(e)):this},Cs.prototype.isEqual=function(t){if(!(t instanceof Cs))return!1;if(this.size!==t.size)return!1;for(var e=this.Xe.be(),n=t.Xe.be();e.$e();){var r=e.Ne().key,i=n.Ne().key;if(!r.isEqual(i))return!1}return!0},Cs.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"},Cs.prototype.me=function(t,e){var n=new Cs;return n.N=this.N,n.Je=t,n.Xe=e,n},Cs),Ns=(Vs.prototype.track=function(t){var e=t.doc.key,n=this.ts.get(e);!n||0!==t.type&&3===n.type?this.ts=this.ts.Ae(e,t):3===t.type&&1!==n.type?this.ts=this.ts.Ae(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.ts=this.ts.Ae(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.ts=this.ts.Ae(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.ts=this.ts.remove(e):1===t.type&&2===n.type?this.ts=this.ts.Ae(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.ts=this.ts.Ae(e,{type:2,doc:t.doc}):Js()},Vs.prototype.es=function(){var n=[];return this.ts.pe(function(t,e){n.push(e)}),n},Vs),As=(Ls.os=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:0,doc:t})}),new Ls(t,e,Is.Ze(e),i,n,r,!0,!1)},Object.defineProperty(Ls.prototype,"hasPendingWrites",{get:function(){return!this.ns.B()},enumerable:!0,configurable:!0}),Ls.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.rs===t.rs&&this.ns.isEqual(t.ns)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.ss.isEqual(t.ss)))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},Ls),_s=(Ps.ls=function(t,e){var n=new Map;return n.set(t,Ss.ds(t,e)),new Ps(Lr.min(),n,ws(),cs(),gs())},Ps),Ss=(Rs.ds=function(t,e){return new Rs(ei.ht,e,gs(),gs(),gs())},Rs),ks=(Object.defineProperty(Os.prototype,"fs",{get:function(){return this.gs},enumerable:!0,configurable:!0}),Object.defineProperty(Os.prototype,"resumeToken",{get:function(){return this.Vs},enumerable:!0,configurable:!0}),Object.defineProperty(Os.prototype,"ys",{get:function(){return 0!==this.ms},enumerable:!0,configurable:!0}),Object.defineProperty(Os.prototype,"bs",{get:function(){return this.ps},enumerable:!0,configurable:!0}),Os.prototype.vs=function(t){0<t.rt()&&(this.ps=!0,this.Vs=t)},Os.prototype.Ss=function(){var n=gs(),r=gs(),i=gs();return this.Ps.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:Js()}}),new Ss(this.Vs,this.gs,n,r,i)},Os.prototype.Ds=function(){this.ps=!1,this.Ps=js()},Os.prototype.Cs=function(t,e){this.ps=!0,this.Ps=this.Ps.Ae(t,e)},Os.prototype.Fs=function(t){this.ps=!0,this.Ps=this.Ps.remove(t)},Os.prototype.Ns=function(){this.ms+=1},Os.prototype.$s=function(){--this.ms},Os.prototype.ks=function(){this.ps=!0,this.gs=!0},Os),Ds=(xs.prototype.qs=function(t){for(var e=0,n=t.ws;e<n.length;e++){var r=n[e];t.Rs instanceof To?this.Us(r,t.Rs):t.Rs instanceof Io&&this.Qs(r,t.key,t.Rs)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.Qs(s,t.key,t.Rs)}},xs.prototype.Ws=function(n){var r=this;this.js(n,function(t){var e=r.Ks(t);switch(n.state){case 0:r.Gs(t)&&e.vs(n.resumeToken);break;case 1:e.$s(),e.ys||e.Ds(),e.vs(n.resumeToken);break;case 2:e.$s(),e.ys||r.removeTarget(t);break;case 3:r.Gs(t)&&(e.ks(),e.vs(n.resumeToken));break;case 4:r.Gs(t)&&(r.zs(t),e.vs(n.resumeToken));break;default:Js()}})},xs.prototype.js=function(t,n){var r=this;0<t.targetIds.length?t.targetIds.forEach(n):this.Ms.forEach(function(t,e){r.Gs(e)&&n(e)})},xs.prototype.Hs=function(t){var e=t.targetId,n=t.As.count,r=this.Ys(e);if(r){var i=r.target;if(i.Ot())if(0===n){var o=new $r(i.path);this.Qs(e,o,new Io(o,Lr.min()))}else Zs(1===n);else this.Js(e)!==n&&(this.zs(e),this.Bs=this.Bs.add(e))}},xs.prototype.Xs=function(i){var o=this,s=new Map;this.Ms.forEach(function(t,e){var n=o.Ys(e);if(n){if(t.fs&&n.target.Ot()){var r=new $r(n.target.path);null!==o.Os.get(r)||o.Zs(e,r)||o.Qs(e,r,new Io(r,i))}t.bs&&(s.set(e,t.Ss()),t.Ds())}});var r=gs();this.xs.forEach(function(t,e){var n=!0;e.Ge(function(t){var e=o.Ys(t);return!e||2===e.Te||(n=!1)}),n&&(r=r.add(t))});var t=new _s(i,s,this.Bs,this.Os,r);return this.Os=cs(),this.xs=Us(),this.Bs=new os(ru),t},xs.prototype.Us=function(t,e){if(this.Gs(t)){var n=this.Zs(t,e.key)?2:0;this.Ks(t).Cs(e.key,n),this.Os=this.Os.Ae(e.key,e),this.xs=this.xs.Ae(e.key,this.ti(e.key).add(t))}},xs.prototype.Qs=function(t,e,n){if(this.Gs(t)){var r=this.Ks(t);this.Zs(t,e)?r.Cs(e,1):r.Fs(e),this.xs=this.xs.Ae(e,this.ti(e).delete(t)),n&&(this.Os=this.Os.Ae(e,n))}},xs.prototype.removeTarget=function(t){this.Ms.delete(t)},xs.prototype.Js=function(t){var e=this.Ks(t).Ss();return this.Ls.ei(t).size+e.Ts.size-e.Is.size},xs.prototype.Ns=function(t){this.Ks(t).Ns()},xs.prototype.Ks=function(t){var e=this.Ms.get(t);return e||(e=new ks,this.Ms.set(t,e)),e},xs.prototype.ti=function(t){var e=this.xs.get(t);return e||(e=new os(ru),this.xs=this.xs.Ae(t,e)),e},xs.prototype.Gs=function(t){var e=null!==this.Ys(t);return e||Hs("WatchChangeAggregator","Detected inactive target",t),e},xs.prototype.Ys=function(t){var e=this.Ms.get(t);return e&&e.ys?null:this.Ls.si(t)},xs.prototype.zs=function(e){var n=this;this.Ms.set(e,new ks),this.Ls.ei(e).forEach(function(t){n.Qs(e,t,null)})},xs.prototype.Zs=function(t,e){return this.Ls.ei(t).has(e)},xs);function xs(t){this.Ls=t,this.Ms=new Map,this.Os=cs(),this.xs=Us(),this.Bs=new os(ru)}function Os(){this.ms=0,this.Ps=js(),this.Vs=ei.ht,this.gs=!1,this.ps=!0}function Rs(t,e,n,r,i){this.resumeToken=t,this.fs=e,this.Ts=n,this.Es=r,this.Is=i}function Ps(t,e,n,r,i){this.Ee=t,this.as=e,this.us=n,this.cs=r,this._s=i}function Ls(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.ss=n,this.docChanges=r,this.ns=i,this.fromCache=o,this.rs=s,this.hs=u}function Vs(){this.ts=new Jo($r.N)}function Cs(n){this.N=n?function(t,e){return n(t,e)||$r.N(t.key,e.key)}:function(t,e){return $r.N(t.key,e.key)},this.Je=ps(),this.Xe=new Jo(this.N)}function Us(){return new Jo($r.N)}function js(){return new Jo($r.N)}var Ms={asc:"ASCENDING",desc:"DESCENDING"},qs={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","array-contains-any":"ARRAY_CONTAINS_ANY"},Fs=(Bs.prototype.ni=function(t){var e=void 0===t.code?Sr.UNKNOWN:Xo(t.code);return new kr(e,t.message||"")},Bs.prototype.ri=function(t){return this.options.hi||ri(t)?t:{value:t}},Bs.prototype.oi=function(t){var e;return ri(e="object"==typeof t?t.value:t)?null:e},Bs.prototype._t=function(t){return{integerValue:""+t}},Bs.prototype.lt=function(t){if(this.options.hi){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ii(t)?"-0":t}},Bs.prototype.ai=function(t){return oi(t)?this._t(t):this.lt(t)},Bs.prototype.C=function(t){return this.options.hi?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},Bs.prototype.v=function(t){var e=yi(t);return new Pr(e.seconds,e.nanos)},Bs.prototype.ui=function(t){return this.options.hi?t.toBase64():t.toUint8Array()},Bs.prototype.ci=function(t){return this.options.hi?(Zs(void 0===t||"string"==typeof t),ei.fromBase64String(t||"")):(Zs(void 0===t||t instanceof Uint8Array),ei.fromUint8Array(t||new Uint8Array))},Bs.prototype.toVersion=function(t){return this.C(t.C())},Bs.prototype.fromVersion=function(t){return Zs(!!t),Lr.v(this.v(t))},Bs.prototype._i=function(t,e){return this.li(e||this.ii).child("documents").child(t).j()},Bs.prototype.di=function(t){var e=Cr.K(t);return Zs(Gs(e)),e},Bs.prototype.fi=function(t){return this._i(t.path)},Bs.prototype.Z=function(t){var e=this.di(t);return Zs(e.get(1)===this.ii.projectId),Zs(!e.get(3)&&!this.ii.database||e.get(3)===this.ii.database),new $r(this.Ti(e))},Bs.prototype.Ei=function(t){return this._i(t)},Bs.prototype.Ii=function(t){var e=this.di(t);return 4===e.length?Cr.G:this.Ti(e)},Object.defineProperty(Bs.prototype,"wi",{get:function(){return new Cr(["projects",this.ii.projectId,"databases",this.ii.database]).j()},enumerable:!0,configurable:!0}),Bs.prototype.li=function(t){return new Cr(["projects",t.projectId,"databases",t.database])},Bs.prototype.Ti=function(t){return Zs(4<t.length&&"documents"===t.get(4)),t.k(5)},Bs.prototype.Ri=function(t,e){return{name:this.fi(t),fields:e.proto.mapValue.fields}},Bs.prototype.Ai=function(t){return{name:this.fi(t.key),fields:t.Lt().mapValue.fields,updateTime:this.C(t.version.C())}},Bs.prototype.mi=function(t,e){var n=this.Z(t.name),r=this.fromVersion(t.updateTime),i=new Qi({mapValue:{fields:t.fields}});return new To(n,r,i,{hasCommittedMutations:!!e})},Bs.prototype.Pi=function(t){Zs(!!t.found),t.found.name,t.found.updateTime;var e=this.Z(t.found.name),n=this.fromVersion(t.found.updateTime),r=new Qi({mapValue:{fields:t.found.fields}});return new To(e,n,r,{})},Bs.prototype.Vi=function(t){Zs(!!t.missing),Zs(!!t.readTime);var e=this.Z(t.missing),n=this.fromVersion(t.readTime);return new Io(e,n)},Bs.prototype.gi=function(t){return"found"in t?this.Pi(t):"missing"in t?this.Vi(t):Js()},Bs.prototype.pi=function(t){var e;if("targetChange"in t){t.targetChange;var n=this.yi(t.targetChange.targetChangeType||"NO_CHANGE"),r=t.targetChange.targetIds||[],i=this.ci(t.targetChange.resumeToken),o=t.targetChange.cause,s=o&&this.ni(o);e=new Ts(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.Z(u.document.name),h=this.fromVersion(u.document.updateTime),c=new Qi({mapValue:{fields:u.document.fields}}),f=new To(a,h,c,{}),l=u.targetIds||[],p=u.removedTargetIds||[];e=new bs(l,p,f.key,f)}else if("documentDelete"in t){t.documentDelete;var d=t.documentDelete;d.document;var y=this.Z(d.document),v=d.readTime?this.fromVersion(d.readTime):Lr.min(),g=new Io(y,v),m=d.removedTargetIds||[];e=new bs([],m,g.key,g)}else if("documentRemove"in t){t.documentRemove;var w=t.documentRemove;w.document;var b=this.Z(w.document),E=w.removedTargetIds||[];e=new bs([],E,b,null)}else{if(!("filter"in t))return Js();t.filter;var T=t.filter;T.targetId;var I=T.count||0,N=new ho(I),A=T.targetId;e=new Es(A,N)}return e},Bs.prototype.yi=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Js()},Bs.prototype.bi=function(t){if(!("targetChange"in t))return Lr.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length||!e.readTime?Lr.min():this.fromVersion(e.readTime)},Bs.prototype.vi=function(t){var e,n=this;if(t instanceof Gi)e={update:this.Ri(t.key,t.value)};else if(t instanceof Ki)e={delete:this.fi(t.key)};else if(t instanceof zi)e={update:this.Ri(t.key,t.data),updateMask:this.Si(t.Vt)};else if(t instanceof Wi)e={transform:{document:this.fi(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.Di(t)})}};else{if(!(t instanceof Yi))return Js();e={verify:this.fi(t.key)}}return t.Rt.Tt||(e.currentDocument=this.Ci(t.Rt)),e},Bs.prototype.Fi=function(t){var e=this,n=t.currentDocument?this.Ni(t.currentDocument):Fi.ft();if(t.update){t.update.name;var r=this.Z(t.update.name),i=new Qi({mapValue:{fields:t.update.fields}});if(t.updateMask){var o=this.$i(t.updateMask);return new zi(r,i,o,n)}return new Gi(r,i,n)}if(t.delete){var s=this.Z(t.delete);return new Ki(s,n)}if(t.transform){var u=this.Z(t.transform.document),a=t.transform.fieldTransforms.map(function(t){return e.ki(t)});return Zs(!0===n.exists),new Wi(u,a)}if(t.verify){var h=this.Z(t.verify);return new Yi(h,n)}return Js()},Bs.prototype.Ci=function(t){return void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:Js()},Bs.prototype.Ni=function(t){return void 0!==t.updateTime?Fi.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?Fi.exists(t.exists):Fi.ft()},Bs.prototype.Li=function(t,e){var n=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);n.isEqual(Lr.min())&&(n=this.fromVersion(e));var r=null;return t.transformResults&&0<t.transformResults.length&&(r=t.transformResults),new Pi(n,r)},Bs.prototype.Mi=function(t,e){var n=this;return t&&0<t.length?(Zs(void 0!==e),t.map(function(t){return n.Li(t,e)})):[]},Bs.prototype.Di=function(t){var e=t.transform;if(e instanceof Ni)return{fieldPath:t.field.j(),setToServerValue:"REQUEST_TIME"};if(e instanceof _i)return{fieldPath:t.field.j(),appendMissingElements:{values:e.elements}};if(e instanceof Si)return{fieldPath:t.field.j(),removeAllFromArray:{values:e.elements}};if(e instanceof ki)return{fieldPath:t.field.j(),increment:e.ct};throw Js()},Bs.prototype.ki=function(t){var e=null;if("setToServerValue"in t)Zs("REQUEST_TIME"===t.setToServerValue),e=Ni.instance;else if("appendMissingElements"in t){var n=t.appendMissingElements.values||[];e=new _i(n)}else if("removeAllFromArray"in t){var r=t.removeAllFromArray.values||[];e=new Si(r)}else"increment"in t?e=new ki(this,t.increment):Js();var i=Qr.X(t.fieldPath);return new qi(i,e)},Bs.prototype.Oi=function(t){return{documents:[this.Ei(t.path)]}},Bs.prototype.xi=function(t){Zs(1===t.documents.length);var e=t.documents[0];return _o.Wt(this.Ii(e)).ee()},Bs.prototype.Bi=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(e.parent=this.Ei(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(e.parent=this.Ei(n.L()),e.structuredQuery.from=[{collectionId:n.O()}]);var r=this.qi(t.filters);r&&(e.structuredQuery.where=r);var i=this.Ui(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.ri(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.Qi(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.Qi(t.endAt)),e},Bs.prototype.Wi=function(t){var e=this.Ii(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(0<r){Zs(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var s=[];n.where&&(s=this.ji(n.where));var u=[];n.orderBy&&(u=this.Ki(n.orderBy));var a=null;n.limit&&(a=this.oi(n.limit));var h=null;n.startAt&&(h=this.Gi(n.startAt));var c=null;return n.endAt&&(c=this.Gi(n.endAt)),new _o(e,i,u,s,a,"F",h,c).ee()},Bs.prototype.zi=function(t){var e=this.Hi(t.Te);return null==e?null:{"goog-listen-tags":e}},Bs.prototype.Hi=function(t){switch(t){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Js()}},Bs.prototype.ee=function(t){var e,n=t.target;return(e=n.Ot()?{documents:this.Oi(n)}:{query:this.Bi(n)}).targetId=t.targetId,0<t.resumeToken.rt()&&(e.resumeToken=this.ui(t.resumeToken)),e},Bs.prototype.qi=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof So?e.Yi(t):Js()});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},Bs.prototype.ji=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.Ji(t)]:void 0!==t.fieldFilter?[this.Xi(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return e.ji(t)}).reduce(function(t,e){return t.concat(e)}):Js():[]},Bs.prototype.Ui=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.Zi(t)})},Bs.prototype.Ki=function(t){var e=this;return t.map(function(t){return e.tn(t)})},Bs.prototype.Qi=function(t){return{before:t.before,values:t.position}},Bs.prototype.Gi=function(t){var e=!!t.before,n=t.values||[];return new Po(n,e)},Bs.prototype.en=function(t){return Ms[t]},Bs.prototype.sn=function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}},Bs.prototype.nn=function(t){return qs[t]},Bs.prototype.rn=function(t){switch(t){case"EQUAL":return"==";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":default:return Js()}},Bs.prototype.hn=function(t){return{fieldPath:t.j()}},Bs.prototype.on=function(t){return Qr.X(t.fieldPath)},Bs.prototype.Zi=function(t){return{field:this.hn(t.field),direction:this.en(t.dir)}},Bs.prototype.tn=function(t){return new Lo(this.on(t.field),this.sn(t.direction))},Bs.prototype.Xi=function(t){return So.create(this.on(t.fieldFilter.field),this.rn(t.fieldFilter.op),t.fieldFilter.value)},Bs.prototype.Yi=function(t){if("=="===t.op){if(Ti(t.value))return{unaryFilter:{field:this.hn(t.field),op:"IS_NAN"}};if(Ei(t.value))return{unaryFilter:{field:this.hn(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.hn(t.field),op:this.nn(t.op),value:t.value}}},Bs.prototype.Ji=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.on(t.unaryFilter.field);return So.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=this.on(t.unaryFilter.field);return So.create(n,"==",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return Js()}},Bs.prototype.Si=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.j())}),{fieldPaths:e}},Bs.prototype.$i=function(t){var e=t.fieldPaths||[];return new Mi(e.map(function(t){return Qr.X(t)}))},Bs);function Bs(t,e){this.ii=t,this.options=e}function Gs(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)}var zs=(Ks.an=function(t){Ks.platform&&Js(),Ks.platform=t},Ks.nt=function(){return Ks.platform||Js(),Ks.platform},Ks),Ws=new h("@firebase/firestore");function Ks(){}function Ys(){return Ws.logLevel}function Qs(t){Ws.logLevel=t}function Hs(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Ws.logLevel<=l.DEBUG){var r=e.map(Xs);Ws.debug.apply(Ws,i(["Firestore ("+Er+"): "+t],r))}}function $s(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Ws.logLevel<=l.ERROR){var r=e.map(Xs);Ws.error.apply(Ws,i(["Firestore ("+Er+"): "+t],r))}}function Xs(t){if("string"==typeof t)return t;var e=zs.nt();try{return e.un(t)}catch(e){return t}}function Js(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE ("+Er+") INTERNAL ASSERTION FAILED: "+t;throw $s(e),new Error(e)}function Zs(t){t||Js()}function tu(t){return t}var eu=(nu.cn=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=zs.nt()._n(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},nu);function nu(){}function ru(t,e){return t<e?-1:e<t?1:0}function iu(t,n,r){return t.length===n.length&&t.every(function(t,e){return r(t,n[e])})}function ou(t){return t+"\0"}function su(t,e,n,r,i){this.ii=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i}var uu=(Object.defineProperty(Su.prototype,"ln",{get:function(){return"(default)"===this.database},enumerable:!0,configurable:!0}),Su.prototype.isEqual=function(t){return t instanceof Su&&t.projectId===this.projectId&&t.database===this.database},Su.prototype.S=function(t){return ru(this.projectId,t.projectId)||ru(this.database,t.database)},Su),au=(_u.prototype.get=function(t){var e=this.dn(t),n=this.fn[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}},_u.prototype.has=function(t){return void 0!==this.get(t)},_u.prototype.set=function(t,e){var n=this.dn(t),r=this.fn[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.fn[n]=[[t,e]]},_u.prototype.delete=function(t){var e=this.dn(t),n=this.fn[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.fn[e]:n.splice(r,1),!0;return!1},_u.prototype.forEach=function(u){Zr(this.fn,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)}})},_u.prototype.B=function(){return ti(this.fn)},_u),hu=(Au.prototype.at=function(t,e,n){for(var r=n.En,i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var s=r[i];e=o.at(e,s)}}return e},Au.prototype.ot=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=i.ot(e,e,this.Tn))}for(var o=e,s=0,u=this.mutations;s<u.length;s++){var a=u[s];a.key.isEqual(t)&&(e=a.ot(e,o,this.Tn))}return e},Au.prototype.In=function(n){var r=this,i=n;return this.mutations.forEach(function(t){var e=r.ot(t.key,n.get(t.key));e&&(i=i.Ae(t.key,e))}),i},Au.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},gs())},Au.prototype.isEqual=function(t){return this.batchId===t.batchId&&iu(this.mutations,t.mutations,function(t,e){return t.isEqual(e)})&&iu(this.baseMutations,t.baseMutations,function(t,e){return t.isEqual(e)})},Au),cu=(Nu.from=function(t,e,n,r){Zs(t.mutations.length===n.length);for(var i=ys(),o=t.mutations,s=0;s<o.length;s++)i=i.Ae(o[s].key,n[s].version);return new Nu(t,e,n,r,i)},Nu),fu=(Iu.prototype.catch=function(t){return this.next(void 0,t)},Iu.prototype.next=function(r,i){var o=this;return this.Vn&&Js(),this.Vn=!0,this.Pn?this.error?this.gn(i,this.error):this.pn(r,this.result):new Iu(function(e,n){o.An=function(t){o.pn(r,t).next(e,n)},o.mn=function(t){o.gn(i,t).next(e,n)}})},Iu.prototype.yn=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},Iu.prototype.bn=function(t){try{var e=t();return e instanceof Iu?e:Iu.resolve(e)}catch(t){return Iu.reject(t)}},Iu.prototype.pn=function(t,e){return t?this.bn(function(){return t(e)}):Iu.resolve(e)},Iu.prototype.gn=function(t,e){return t?this.bn(function(){return t(e)}):Iu.reject(e)},Iu.resolve=function(n){return new Iu(function(t,e){t(n)})},Iu.reject=function(n){return new Iu(function(t,e){e(n)})},Iu.vn=function(t){return new Iu(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()})},Iu.Sn=function(t){for(var n=Iu.resolve(!1),e=function(e){n=n.next(function(t){return t?Iu.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},Iu.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.vn(i)},Iu),lu=(Object.defineProperty(Tu.prototype,"readTime",{get:function(){return this.Fn},set:function(t){this.Fn=t},enumerable:!0,configurable:!0}),Tu.prototype.Nn=function(t,e){this.$n(),this.readTime=e,this.Dn.set(t.key,t)},Tu.prototype.kn=function(t,e){this.$n(),e&&(this.readTime=e),this.Dn.set(t,null)},Tu.prototype.Ln=function(t,e){this.$n();var n=this.Dn.get(e);return void 0!==n?fu.resolve(n):this.Mn(t,e)},Tu.prototype.getEntries=function(t,e){return this.On(t,e)},Tu.prototype.apply=function(t){return this.$n(),this.Cn=!0,this.xn(t)},Tu.prototype.$n=function(){},Tu),pu="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",du=(Eu.prototype.qn=function(t){this.Bn.push(t)},Eu.prototype.Un=function(){this.Bn.forEach(function(t){return t()})},Eu),yu=(bu.prototype.Kn=function(e,n){var r=this;return this.Wn.Gn(e,n).next(function(t){return r.zn(e,n,t)})},bu.prototype.zn=function(t,r,i){return this.Qn.Ln(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].ot(r,t);return t})},bu.prototype.Hn=function(t,e,i){var o=fs();return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].ot(t,e);o=o.Ae(t,e)}),o},bu.prototype.Yn=function(e,t){var n=this;return this.Qn.getEntries(e,t).next(function(t){return n.Jn(e,t)})},bu.prototype.Jn=function(r,i){var o=this;return this.Wn.Xn(r,i).next(function(t){var e=o.Hn(r,i,t),n=cs();return e.forEach(function(t,e){e=e||new Io(t,Lr.min()),n=n.Ae(t,e)}),n})},bu.prototype.Zn=function(t,e,n){return e.Ot()?this.tr(t,e.path):e._e()?this.er(t,e,n):this.sr(t,e,n)},bu.prototype.tr=function(t,e){return this.Kn(t,new $r(e)).next(function(t){var e=ps();return t instanceof To&&(e=e.Ae(t.key,t)),e})},bu.prototype.er=function(n,r,i){var o=this,s=r.collectionGroup,u=ps();return this.jn.ir(n,s).next(function(t){return fu.forEach(t,function(t){var e=r.Zt(t.child(s));return o.sr(n,e,i).next(function(t){t.forEach(function(t,e){u=u.Ae(t,e)})})}).next(function(){return u})})},bu.prototype.sr=function(e,n,t){var c,f,r=this;return this.Qn.Zn(e,n,t).next(function(t){return c=t,r.Wn.nr(e,n)}).next(function(t){return f=t,r.rr(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.ot(a,a,r.Tn);c=h instanceof To?c.Ae(u,h):c.remove(u)}})}).next(function(){return c.forEach(function(t,e){n.matches(e)||(c=c.remove(t))}),c})},bu.prototype.rr=function(t,e,n){for(var r=gs(),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 zi&&null===n.get(a.key)&&(r=r.add(a.key))}var h=n;return this.Qn.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof To&&(h=h.Ae(t,e))}),h})},bu),vu=(wu.ar=function(t,e){for(var n=gs(),r=gs(),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 wu(t,e.fromCache,n,r)},wu),gu=(mu.prototype.cr=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},mu.prototype.next=function(){var t=++this.previousValue;return this._r&&this._r(t),t},mu);function mu(t,e){var n=this;this.previousValue=t,e&&(e.ur=function(t){return n.cr(t)},this._r=function(t){return e.lr(t)})}function wu(t,e,n,r){this.targetId=t,this.fromCache=e,this.hr=n,this.or=r}function bu(t,e,n){this.Qn=t,this.Wn=e,this.jn=n}function Eu(){this.Bn=[]}function Tu(){this.Dn=new au(function(t){return t.toString()}),this.Cn=!1}function Iu(t){var e=this;this.An=null,this.mn=null,this.result=void 0,this.error=void 0,this.Pn=!1,this.Vn=!1,t(function(t){e.Pn=!0,e.result=t,e.An&&e.An(t)},function(t){e.Pn=!0,e.error=t,e.mn&&e.mn(t)})}function Nu(t,e,n,r,i){this.batch=t,this.wn=e,this.En=n,this.streamToken=r,this.Rn=i}function Au(t,e,n,r){this.batchId=t,this.Tn=e,this.baseMutations=n,this.mutations=r}function _u(t){this.dn=t,this.fn={}}function Su(t,e){this.projectId=t,this.database=e||"(default)"}gu.dr=-1;function ku(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}var Du=(xu.prototype.reset=function(){this.Ar=0},xu.prototype.Vr=function(){this.Ar=this.Rr},xu.prototype.gr=function(t){var e=this;this.cancel();var n=Math.floor(this.Ar+this.pr()),r=Math.max(0,Date.now()-this.Pr),i=Math.max(0,n-r);0<i&&Hs("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Ar+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.mr=this.Tr.yr(this.Er,i,function(){return e.Pr=Date.now(),t()}),this.Ar*=this.wr,this.Ar<this.Ir&&(this.Ar=this.Ir),this.Ar>this.Rr&&(this.Ar=this.Rr)},xu.prototype.br=function(){null!==this.mr&&(this.mr.vr(),this.mr=null)},xu.prototype.cancel=function(){null!==this.mr&&(this.mr.cancel(),this.mr=null)},xu.prototype.pr=function(){return(Math.random()-.5)*this.Ar},xu);function xu(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Tr=t,this.Er=e,this.Ir=n,this.wr=r,this.Rr=i,this.Ar=0,this.mr=null,this.Pr=Date.now(),this.reset()}function Ou(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Pu(e)),e=Ru(t.get(n),e);return Pu(e)}function Ru(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 Pu(t){return t+""}function Lu(t){var e=t.length;if(Zs(2<=e),2===e)return Zs(""===t.charAt(0)&&""===t.charAt(1)),Cr.G;for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("",o);switch((s<0||n<s)&&Js(),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:Js()}o=s+2}return new Cr(r)}var Vu=(qu.prototype.Dr=function(t,e){return this.Sr.add(e),fu.resolve()},qu.prototype.ir=function(t,e){return fu.resolve(this.Sr.getEntries(e))},qu),Cu=(Mu.prototype.add=function(t){var e=t.O(),n=t.L(),r=this.index[e]||new os(Cr.N),i=!r.has(n);return this.index[e]=r.add(n),i},Mu.prototype.has=function(t){var e=t.O(),n=t.L(),r=this.index[e];return r&&r.has(n)},Mu.prototype.getEntries=function(t){return(this.index[t]||new os(Cr.N)).W()},Mu),Uu=(ju.prototype.Dr=function(t,e){var n=this;if(this.Cr.has(e))return fu.resolve();var r=e.O(),i=e.L();t.qn(function(){n.Cr.add(e)});var o={collectionId:r,parent:Ou(i)};return Fu(t).put(o)},ju.prototype.ir=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[ou(i),""],!1,!0);return Fu(t).Fr(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(Lu(r.parent))}return o})},ju);function ju(){this.Cr=new Cu}function Mu(){this.index={}}function qu(){this.Sr=new Cu}function Fu(t){return ua.Nr(t,Ma.store)}var Bu,Gu=(zu.prototype.Nn=function(t,e,n){return Ku(t).put(Yu(e),n)},zu.prototype.kn=function(t,e){var n=Ku(t),r=Yu(e);return n.delete(r)},zu.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.$r(e,t)})},zu.prototype.Ln=function(t,e){var n=this;return Ku(t).get(Yu(e)).next(function(t){return n.kr(t)})},zu.prototype.Lr=function(t,e){var n=this;return Ku(t).get(Yu(e)).next(function(t){var e=n.kr(t);return e?{Mr:e,size:Qu(t)}:null})},zu.prototype.getEntries=function(t,e){var r=this,i=fs();return this.Or(t,e,function(t,e){var n=r.kr(e);i=i.Ae(t,n)}).next(function(){return i})},zu.prototype.xr=function(t,e){var r=this,i=fs(),o=new Jo($r.N);return this.Or(t,e,function(t,e){var n=r.kr(e);o=n?(i=i.Ae(t,n),o.Ae(t,Qu(e))):(i=i.Ae(t,null),o.Ae(t,0))}).next(function(){return{Br:i,qr:o}})},zu.prototype.Or=function(t,e,i){if(e.B())return fu.resolve();var n=IDBKeyRange.bound(e.first().path.W(),e.last().path.W()),o=e.be(),s=o.Ne();return Ku(t).Ur({range:n},function(t,e,n){for(var r=$r.st(t);s&&$r.N(s,r)<0;)i(s,null),s=o.Ne();s&&s.isEqual(r)&&(i(s,e),s=o.$e()?o.Ne():null),s?n.Qr(s.path.W()):n.done()}).next(function(){for(;s;)i(s,null),s=o.$e()?o.Ne():null})},zu.prototype.Zn=function(t,i,e){var o=this,s=ps(),u=i.path.length+1,n={};if(e.isEqual(Lr.min())){var r=i.path.W();n.range=IDBKeyRange.lowerBound(r)}else{var a=i.path.W(),h=this.serializer.Wr(e);n.range=IDBKeyRange.lowerBound([a,h],!0),n.index=La.collectionReadTimeIndex}return Ku(t).Ur(n,function(t,e,n){if(t.length===u){var r=o.serializer.jr(e);i.path.q(r.key.path)?r instanceof To&&i.matches(r)&&(s=s.Ae(r.key,r)):n.done()}}).next(function(){return s})},zu.prototype.Kr=function(t,e){var r=this,i=cs(),o=this.serializer.Wr(e),n=Ku(t),s=IDBKeyRange.lowerBound(o,!0);return n.Ur({index:La.readTimeIndex,range:s},function(t,e){var n=r.serializer.jr(e);i=i.Ae(n.key,n),o=e.readTime}).next(function(){return{Gr:i,readTime:r.serializer.zr(o)}})},zu.prototype.Hr=function(t){var r=this,e=Ku(t),i=Lr.min();return e.Ur({index:La.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(i=r.serializer.zr(e.readTime)),n.done()}).next(function(){return i})},zu.prototype.Yr=function(t){return new zu.Jr(this,!!t&&t.Xr)},zu.prototype.Zr=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},zu.prototype.getMetadata=function(t){return Wu(t).get(Va.key).next(function(t){return Zs(!!t),t})},zu.prototype.$r=function(t,e){return Wu(t).put(Va.key,e)},zu.prototype.kr=function(t){if(t){var e=this.serializer.jr(t);return e instanceof Io&&e.version.isEqual(Lr.min())?null:e}return null},zu);function zu(t,e){this.serializer=t,this.jn=e}function Wu(t){return ua.Nr(t,Va.store)}function Ku(t){return ua.Nr(t,La.store)}function Yu(t){return t.path.W()}function Qu(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Js();e=t.noDocument}return JSON.stringify(e).length}function Hu(t,e){var n=this;return(n=Bu.call(this)||this).th=t,n.Xr=e,n.eh=new au(function(t){return t.toString()}),n}Gu.Jr=(n(Hu,Bu=lu),Hu.prototype.xn=function(s){var u=this,a=[],h=0,c=new os(function(t,e){return ru(t.j(),e.j())});return this.Dn.forEach(function(t,e){var n=u.eh.get(t);if(e){var r=u.th.serializer.sh(e,u.readTime);c=c.add(t.path.L());var i=Qu(r);h+=i-n,a.push(u.th.Nn(s,t,r))}else if(h-=n,u.Xr){var o=u.th.serializer.sh(new Io(t,Lr.min()),u.readTime);a.push(u.th.Nn(s,t,o))}else a.push(u.th.kn(s,t))}),c.forEach(function(t){a.push(u.th.jn.Dr(s,t))}),a.push(this.th.updateMetadata(s,h)),fu.vn(a)},Hu.prototype.Mn=function(t,e){var n=this;return this.th.Lr(t,e).next(function(t){return null===t?(n.eh.set(e,0),null):(n.eh.set(e,t.size),t.Mr)})},Hu.prototype.On=function(t,e){var n=this;return this.th.xr(t,e).next(function(t){var e=t.Br;return t.qr.forEach(function(t,e){n.eh.set(t,e)}),e})},Hu);var $u=(Zu.prototype.next=function(){return this.ih+=2,this.ih},Zu.nh=function(){return new Zu(0)},Zu.rh=function(){return new Zu(-1)},Zu),Xu=(Ju.prototype.oh=function(n){var r=this;return this.ah(n).next(function(t){var e=new $u(t.highestTargetId);return t.highestTargetId=e.next(),r.uh(n,t).next(function(){return t.highestTargetId})})},Ju.prototype._h=function(t){return this.ah(t).next(function(t){return Lr.v(new Pr(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},Ju.prototype.lh=function(t){return this.ah(t).next(function(t){return t.highestListenSequenceNumber})},Ju.prototype.dh=function(e,n,r){var i=this;return this.ah(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.C()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.uh(e,t)})},Ju.prototype.fh=function(e,n){var r=this;return this.Th(e,n).next(function(){return r.ah(e).next(function(t){return t.targetCount+=1,r.Eh(n,t),r.uh(e,t)})})},Ju.prototype.Ih=function(t,e){return this.Th(t,e)},Ju.prototype.wh=function(e,t){var n=this;return this.Rh(e,t.targetId).next(function(){return ta(e).delete(t.targetId)}).next(function(){return n.ah(e)}).next(function(t){return Zs(0<t.targetCount),--t.targetCount,n.uh(e,t)})},Ju.prototype.Ah=function(r,i,o){var s=this,u=0,a=[];return ta(r).Ur(function(t,e){var n=s.serializer.mh(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(u++,a.push(s.wh(r,n)))}).next(function(){return fu.vn(a)}).next(function(){return u})},Ju.prototype.js=function(t,r){var i=this;return ta(t).Ur(function(t,e){var n=i.serializer.mh(e);r(n)})},Ju.prototype.ah=function(t){return ea(t).get(ja.key).next(function(t){return Zs(null!==t),t})},Ju.prototype.uh=function(t,e){return ea(t).put(ja.key,e)},Ju.prototype.Th=function(t,e){return ta(t).put(this.serializer.Ph(e))},Ju.prototype.Eh=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},Ju.prototype.Vh=function(t){return this.ah(t).next(function(t){return t.targetCount})},Ju.prototype.gh=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),s=null;return ta(t).Ur({range:n,index:Ca.queryTargetsIndexName},function(t,e,n){var r=o.serializer.mh(e);i.isEqual(r.target)&&(s=r,n.done())}).next(function(){return s})},Ju.prototype.ph=function(n,t,r){var i=this,o=[],s=na(n);return t.forEach(function(t){var e=Ou(t.path);o.push(s.put(new Ua(r,e))),o.push(i.hh.yh(n,r,t))}),fu.vn(o)},Ju.prototype.bh=function(n,t,r){var i=this,o=na(n);return fu.forEach(t,function(t){var e=Ou(t.path);return fu.vn([o.delete([r,e]),i.hh.vh(n,r,t)])})},Ju.prototype.Rh=function(t,e){var n=na(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},Ju.prototype.Sh=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=na(t),o=gs();return r.Ur({range:n,Dh:!0},function(t,e,n){var r=Lu(t[1]),i=new $r(r);o=o.add(i)}).next(function(){return o})},Ju.prototype.Ch=function(t,e){var n=Ou(e.path),r=IDBKeyRange.bound([n],[ou(n)],!1,!0),i=0;return na(t).Ur({index:Ua.documentTargetsIndex,Dh:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},Ju.prototype.si=function(t,e){var n=this;return ta(t).get(e).next(function(t){return t?n.serializer.mh(t):null})},Ju);function Ju(t,e){this.hh=t,this.serializer=e}function Zu(t){this.ih=t}function ta(t){return ua.Nr(t,Ca.store)}function ea(t){return ua.Nr(t,ja.store)}function na(t){return ua.Nr(t,Ua.store)}var ra,ia=(ca.prototype.jr=function(t){if(t.document)return this.Fh.mi(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=$r.st(t.noDocument.path),n=this.Nh(t.noDocument.readTime);return new Io(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}if(t.unknownDocument){var r=$r.st(t.unknownDocument.path),i=this.Nh(t.unknownDocument.version);return new No(r,i)}return Js()},ca.prototype.sh=function(t,e){var n=this.Wr(e),r=t.key.path.L().W();if(t instanceof To){var i=this.Fh.Ai(t),o=t.hasCommittedMutations;return new La(null,null,i,o,n,r)}if(t instanceof Io){var s=t.key.path.W(),u=this.$h(t.version),a=t.hasCommittedMutations;return new La(null,new Ra(s,u),null,a,n,r)}if(t instanceof No){var h=t.key.path.W(),c=this.$h(t.version);return new La(new Pa(h,c),null,null,!0,n,r)}return Js()},ca.prototype.Wr=function(t){var e=t.C();return[e.seconds,e.nanoseconds]},ca.prototype.zr=function(t){var e=new Pr(t[0],t[1]);return Lr.v(e)},ca.prototype.$h=function(t){var e=t.C();return new Aa(e.seconds,e.nanoseconds)},ca.prototype.Nh=function(t){var e=new Pr(t.seconds,t.nanoseconds);return Lr.v(e)},ca.prototype.kh=function(t,e){var n=this,r=e.baseMutations.map(function(t){return n.Fh.vi(t)}),i=e.mutations.map(function(t){return n.Fh.vi(t)});return new Da(t,e.batchId,e.Tn.toMillis(),r,i)},ca.prototype.Lh=function(t){var e=this,n=(t.baseMutations||[]).map(function(t){return e.Fh.Fi(t)}),r=t.mutations.map(function(t){return e.Fh.Fi(t)}),i=Pr.fromMillis(t.localWriteTimeMs);return new hu(t.batchId,i,n,r)},ca.prototype.mh=function(t){var e,n=this.Nh(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.Nh(t.lastLimboFreeSnapshotVersion):Lr.min();return e=void 0!==t.query.documents?this.Fh.xi(t.query):this.Fh.Wi(t.query),new Vo(e,t.targetId,0,t.lastListenSequenceNumber,n,r,ei.fromBase64String(t.resumeToken))},ca.prototype.Ph=function(t){var e,n=this.$h(t.Ee),r=this.$h(t.lastLimboFreeSnapshotVersion);e=t.target.Ot()?this.Fh.Oi(t.target):this.Fh.Bi(t.target);var i=t.resumeToken.toBase64();return new Ca(t.targetId,t.target.canonicalId(),n,i,t.sequenceNumber,r,e)},ca),oa="Failed to obtain exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",sa=(n(ha,ra=du),ha),ua=(aa.Nr=function(t,e){if(t instanceof sa)return za.Nr(t.Mh,e);throw Js()},aa.prototype.start=function(){var e=this;return za.Xh(this.zh,Ia,new Na(this.serializer)).then(function(t){return e.Zh=t,e.to()}).then(function(){if(!e.isPrimary&&!e.allowTabSynchronization)throw new kr(Sr.FAILED_PRECONDITION,oa);return e.eo(),e.so(),e.io(),e.runTransaction("getHighestListenSequenceNumber","readonly",function(t){return e.Yh.lh(t)})}).then(function(t){e.Bh=new gu(t,e.xh)}).then(function(){e.qh=!0}).catch(function(t){return e.Zh&&e.Zh.close(),Promise.reject(t)})},aa.prototype.no=function(n){var t=this;return this.Kh=function(e){return y(t,void 0,void 0,function(){return v(this,function(t){return this.ro?[2,n(e)]:[2]})})},n(this.isPrimary)},aa.prototype.ho=function(n){var t=this;this.Zh.oo(function(e){return y(t,void 0,void 0,function(){return v(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]}})})})},aa.prototype.ao=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Tr.uo(function(){return y(e,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.ro?[4,this.to()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},aa.prototype.to=function(){var n=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(e){return la(e).put(new Fa(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.co(e).next(function(t){t||(n.isPrimary=!1,n.Tr.uo(function(){return n.Kh(!1)}))})}).next(function(){return n._o(e)}).next(function(t){return n.isPrimary&&!t?n.lo(e).next(function(){return!1}):!!t&&n.do(e).next(function(){return!0})})}).catch(function(t){if(n.allowTabSynchronization)return Hs("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1;if($a(t))return Hs("IndexedDbPersistence","Failed to extend owner lease: ",t),n.isPrimary;throw t}).then(function(t){n.isPrimary!==t&&n.Tr.uo(function(){return n.Kh(t)}),n.isPrimary=t})},aa.prototype.co=function(t){var e=this;return fa(t).get(_a.key).next(function(t){return fu.resolve(e.fo(t))})},aa.prototype.To=function(t){return la(t).delete(this.clientId)},aa.prototype.Eo=function(){return y(this,void 0,void 0,function(){var i=this;return v(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.Io(this.jh,18e5)?[3,2]:(this.jh=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var r=aa.Nr(t,Fa.store);return r.Fr().next(function(t){var e=i.wo(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return fu.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.Ro(t.clientId))}),t.label=2;case 2:return[2]}})})},aa.prototype.io=function(){var t=this;this.Wh=this.Tr.yr("client_metadata_refresh",4e3,function(){return t.to().then(function(){return t.Eo()}).then(function(){return t.io()})})},aa.prototype.fo=function(t){return!!t&&t.ownerId===this.clientId},aa.prototype._o=function(e){var i=this;return fa(e).get(_a.key).next(function(t){if(null!==t&&i.Io(t.leaseTimestampMs,5e3)&&!i.Ao(t.ownerId)){if(i.fo(t)&&i.networkEnabled)return!0;if(!i.fo(t)){if(!t.allowTabSynchronization)throw new kr(Sr.FAILED_PRECONDITION,oa);return!1}}return!(!i.networkEnabled||!i.inForeground)||la(e).Fr().next(function(t){return void 0===i.wo(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&&Hs("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},aa.prototype.mo=function(){return y(this,void 0,void 0,function(){var e=this;return v(this,function(t){switch(t.label){case 0:return this.qh=!1,this.Po(),this.Wh&&(this.Wh.cancel(),this.Wh=null),this.Vo(),this.po(),[4,this.runTransaction("shutdown","readwrite",function(t){return e.lo(t).next(function(){return e.To(t)})}).catch(function(t){Hs("IndexedDbPersistence","Proceeding with shutdown despite failure: ",t)})];case 1:return t.sent(),this.Zh.close(),this.yo(),[2]}})})},aa.prototype.wo=function(t,e){var n=this;return t.filter(function(t){return n.Io(t.updateTimeMs,e)&&!n.Ao(t.clientId)})},aa.prototype.bo=function(){var e=this;return this.runTransaction("getActiveClients","readonly",function(t){return la(t).Fr().next(function(t){return e.wo(t,18e5).map(function(t){return t.clientId})})})},aa.clearPersistence=function(n){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return aa.Gh()?(e=n+aa.Hh,[4,za.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(aa.prototype,"ro",{get:function(){return this.qh},enumerable:!0,configurable:!0}),aa.prototype.vo=function(t){return va.So(t,this.serializer,this.jn,this.hh)},aa.prototype.Do=function(){return this.Yh},aa.prototype.Co=function(){return this.Qn},aa.prototype.Fo=function(){return this.jn},aa.prototype.runTransaction=function(e,n,r){var i=this;Hs("IndexedDbPersistence","Starting transaction:",e);var o,t="readonly"===n?"readonly":"readwrite";return this.Zh.runTransaction(t,Ga,function(t){return o=new sa(t,i.Bh?i.Bh.next():gu.dr),"readwrite-primary"===n?i.co(o).next(function(t){return!!t||i._o(o)}).next(function(t){if(!t)throw $s("Failed to obtain primary lease for action '"+e+"'."),i.isPrimary=!1,i.Tr.uo(function(){return i.Kh(!1)}),new kr(Sr.FAILED_PRECONDITION,pu);return r(o)}).next(function(t){return i.do(o).next(function(){return t})}):i.No(o).next(function(){return r(o)})}).then(function(t){return o.Un(),t})},aa.prototype.No=function(t){var e=this;return fa(t).get(_a.key).next(function(t){if(null!==t&&e.Io(t.leaseTimestampMs,5e3)&&!e.Ao(t.ownerId)&&!e.fo(t)&&(!e.allowTabSynchronization||!t.allowTabSynchronization))throw new kr(Sr.FAILED_PRECONDITION,oa)})},aa.prototype.do=function(t){var e=new _a(this.clientId,this.allowTabSynchronization,Date.now());return fa(t).put(_a.key,e)},aa.Gh=function(){return za.Gh()},aa.$o=function(t){var e=t.ii.projectId;return t.ii.ln||(e+="."+t.ii.database),"firestore/"+t.persistenceKey+"/"+e+"/"},aa.prototype.lo=function(t){var e=this,n=fa(t);return n.get(_a.key).next(function(t){return e.fo(t)?(Hs("IndexedDbPersistence","Releasing primary lease."),n.delete(_a.key)):fu.resolve()})},aa.prototype.Io=function(t,e){var n=Date.now();return!(t<n-e||n<t&&($s("Detected an update time that is in the future: "+t+" > "+n),1))},aa.prototype.eo=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Qh=function(){t.Tr.uo(function(){return t.inForeground="visible"===t.document.visibilityState,t.to()})},this.document.addEventListener("visibilitychange",this.Qh),this.inForeground="visible"===this.document.visibilityState)},aa.prototype.Vo=function(){this.Qh&&(this.document.removeEventListener("visibilitychange",this.Qh),this.Qh=null)},aa.prototype.so=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.Uh=function(){t.Po(),t.Tr.uo(function(){return t.mo()})},this.window.addEventListener("unload",this.Uh))},aa.prototype.po=function(){this.Uh&&(this.window.removeEventListener("unload",this.Uh),this.Uh=null)},aa.prototype.Ao=function(t){try{var e=null!==this.Jh.getItem(this.Ro(t));return Hs("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return $s("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},aa.prototype.Po=function(){try{this.Jh.setItem(this.Ro(this.clientId),String(Date.now()))}catch(t){$s("Failed to set zombie client id.",t)}},aa.prototype.yo=function(){try{this.Jh.removeItem(this.Ro(this.clientId))}catch(t){}},aa.prototype.Ro=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},aa);function aa(t,e,n,r,i,o,s,u){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Tr=o,this.xh=u,this.Bh=null,this.qh=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Uh=null,this.inForeground=!1,this.Qh=null,this.Wh=null,this.jh=Number.NEGATIVE_INFINITY,this.Kh=function(t){return Promise.resolve()},!aa.Gh())throw new kr(Sr.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");if(this.hh=new pa(this,i),this.zh=e+aa.Hh,this.serializer=new ia(s),this.document=r.document,this.Yh=new Xu(this.hh,this.serializer),this.jn=new Uu,this.Qn=new Gu(this.serializer,this.jn),!r.window||!r.window.localStorage)throw new kr(Sr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.Jh=this.window.localStorage}function ha(t,e){var n=this;return(n=ra.call(this)||this).Mh=t,n.Oh=e,n}function ca(t){this.Fh=t}function fa(t){return ua.Nr(t,_a.store)}function la(t){return ua.Nr(t,Fa.store)}ua.Hh="main";var pa=(da.prototype.Lo=function(t){var n=this.Mo(t);return this.db.Do().Vh(t).next(function(e){return n.next(function(t){return e+t})})},da.prototype.Mo=function(t){var e=0;return this.Oo(t,function(t){e++}).next(function(){return e})},da.prototype.js=function(t,e){return this.db.Do().js(t,e)},da.prototype.Oo=function(t,n){return this.xo(t,function(t,e){return n(e)})},da.prototype.yh=function(t,e,n){return ya(t,n)},da.prototype.vh=function(t,e,n){return ya(t,n)},da.prototype.Ah=function(t,e,n){return this.db.Do().Ah(t,e,n)},da.prototype.Bo=function(t,e){return ya(t,e)},da.prototype.qo=function(t,e){return r=e,i=!1,Ta(n=t).Uo(function(t){return ma(n,t,r).next(function(t){return t&&(i=!0),fu.resolve(!t)})}).next(function(){return i});var n,r,i},da.prototype.Qo=function(r,i){var o=this,s=this.db.Co().Yr(),u=[],a=0;return this.xo(r,function(e,t){if(t<=i){var n=o.qo(r,e).next(function(t){if(!t)return a++,s.Ln(r,e).next(function(){return s.kn(e),na(r).delete([0,Ou(e.path)])})});u.push(n)}}).next(function(){return fu.vn(u)}).next(function(){return s.apply(r)}).next(function(){return a})},da.prototype.removeTarget=function(t,e){var n=e.Ie(t.Oh);return this.db.Do().Ih(t,n)},da.prototype.Wo=function(t,e){return ya(t,e)},da.prototype.xo=function(t,o){var s,e=na(t),u=gu.dr;return e.Ur({index:Ua.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(u!==gu.dr&&o(new $r(Lu(s)),u),u=i,s=r):u=gu.dr}).next(function(){u!==gu.dr&&o(new $r(Lu(s)),u)})},da.prototype.jo=function(t){return this.db.Co().Zr(t)},da);function da(t,e){this.db=t,this.ko=new vh(this,e)}function ya(t,e){return na(t).put((n=e,r=t.Oh,new Ua(0,Ou(n.path),r)));var n,r}var va=(ga.So=function(t,e,n,r){return Zs(""!==t.uid),new ga(t.t()?t.uid:"",e,n,r)},ga.prototype.Go=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return ba(t).Ur({index:Da.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},ga.prototype.zo=function(e,t,n){return this.Ho(e).next(function(t){return t.lastStreamToken=n.toBase64(),Ta(e).put(t)})},ga.prototype.Yo=function(t){return this.Ho(t).next(function(t){return ei.fromBase64String(t.lastStreamToken)})},ga.prototype.Jo=function(e,n){return this.Ho(e).next(function(t){return t.lastStreamToken=n.toBase64(),Ta(e).put(t)})},ga.prototype.Xo=function(h,c,f,l){var p=this,d=Ea(h),y=ba(h);return y.add({}).next(function(t){Zs("number"==typeof t);for(var e=new hu(t,c,f,l),n=p.serializer.kh(p.userId,e),r=[],i=new os(function(t,e){return ru(t.j(),e.j())}),o=0,s=l;o<s.length;o++){var u=s[o],a=xa.key(p.userId,u.key.path,t);i=i.add(u.key.path.L()),r.push(y.put(n)),r.push(d.put(a,xa.PLACEHOLDER))}return i.forEach(function(t){r.push(p.jn.Dr(h,t))}),h.qn(function(){p.Ko[t]=e.keys()}),fu.vn(r).next(function(){return e})})},ga.prototype.Zo=function(t,e){var n=this;return ba(t).get(e).next(function(t){return t?(Zs(t.userId===n.userId),n.serializer.Lh(t)):null})},ga.prototype.ta=function(t,n){var r=this;return this.Ko[n]?fu.resolve(this.Ko[n]):this.Zo(t,n).next(function(t){if(t){var e=t.keys();return r.Ko[n]=e}return null})},ga.prototype.ea=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return ba(t).Ur({index:Da.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(Zs(e.batchId>=i),o=r.serializer.Lh(e)),n.done()}).next(function(){return o})},ga.prototype.sa=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return ba(t).Ur({index:Da.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},ga.prototype.ia=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return ba(t).Fr(Da.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.Lh(t)})})},ga.prototype.Gn=function(u,a){var h=this,t=xa.prefixForPath(this.userId,a.path),e=IDBKeyRange.lowerBound(t),c=[];return Ea(u).Ur({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Lu(i);if(r===h.userId&&a.path.isEqual(s))return ba(u).get(o).next(function(t){if(!t)throw Js();Zs(t.userId===h.userId),c.push(h.serializer.Lh(t))});n.done()}).next(function(){return c})},ga.prototype.Xn=function(r,t){var a=this,h=new os(ru),i=[];return t.forEach(function(u){var t=xa.prefixForPath(a.userId,u.path),e=IDBKeyRange.lowerBound(t),n=Ea(r).Ur({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Lu(i);r===a.userId&&u.path.isEqual(s)?h=h.add(o):n.done()});i.push(n)}),fu.vn(i).next(function(){return a.na(r,h)})},ga.prototype.nr=function(t,e){var u=this,a=e.path,h=a.length+1,n=xa.prefixForPath(this.userId,a),r=IDBKeyRange.lowerBound(n),c=new os(ru);return Ea(t).Ur({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Lu(i);r===u.userId&&a.q(s)?s.length===h&&(c=c.add(o)):n.done()}).next(function(){return u.na(t,c)})},ga.prototype.na=function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(ba(e).get(t).next(function(t){if(null===t)throw Js();Zs(t.userId===n.userId),r.push(n.serializer.Lh(t))}))}),fu.vn(i).next(function(){return r})},ga.prototype.ra=function(e,n){var r=this;return wa(e.Mh,this.userId,n).next(function(t){return e.qn(function(){r.ha(n.batchId)}),fu.forEach(t,function(t){return r.hh.Bo(e,t)})})},ga.prototype.ha=function(t){delete this.Ko[t]},ga.prototype.oa=function(n){var o=this;return this.Go(n).next(function(t){if(!t)return fu.resolve();var e=IDBKeyRange.lowerBound(xa.prefixForUser(o.userId)),i=[];return Ea(n).Ur({range:e},function(t,e,n){if(t[0]===o.userId){var r=Lu(t[1]);i.push(r)}else n.done()}).next(function(){Zs(0===i.length)})})},ga.prototype.Ch=function(t,e){return ma(t,this.userId,e)},ga.prototype.Ho=function(t){var e=this;return Ta(t).get(this.userId).next(function(t){return t||new ka(e.userId,-1,"")})},ga);function ga(t,e,n,r){this.userId=t,this.serializer=e,this.jn=n,this.hh=r,this.Ko={}}function ma(t,o,e){var n=xa.prefixForPath(o,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),u=!1;return Ea(t).Ur({range:r,Dh:!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 wa(t,e,n){var r=t.store(Da.store),i=t.store(xa.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.Ur({range:s},function(t,e,n){return u++,n.delete()});o.push(a.next(function(){Zs(1===u)}));for(var h=[],c=0,f=n.mutations;c<f.length;c++){var l=f[c],p=xa.key(e,l.key.path,n.batchId);o.push(i.delete(p)),h.push(l.key)}return fu.vn(o).next(function(){return h})}function ba(t){return ua.Nr(t,Da.store)}function Ea(t){return ua.Nr(t,xa.store)}function Ta(t){return ua.Nr(t,ka.store)}var Ia=10,Na=(Sa.prototype.createOrUpgrade=function(n,r,t,e){var i=this;Zs(t<e&&0<=t&&e<=Ia);var o,s=new Xa(r);t<1&&1<=e&&(n.createObjectStore(_a.store),(o=n).createObjectStore(ka.store,{keyPath:ka.keyPath}),o.createObjectStore(Da.store,{keyPath:Da.keyPath,autoIncrement:!0}).createIndex(Da.userMutationsIndex,Da.userMutationsKeyPath,{unique:!0}),o.createObjectStore(xa.store),qa(n),n.createObjectStore(La.store));var u,a=fu.resolve();return t<3&&3<=e&&(0!==t&&((u=n).deleteObjectStore(Ua.store),u.deleteObjectStore(Ca.store),u.deleteObjectStore(ja.store),qa(n)),a=a.next(function(){return t=s.store(ja.store),e=new ja(0,0,Lr.min().C(),0),t.put(ja.key,e);var t,e})),t<4&&4<=e&&(0!==t&&(a=a.next(function(){return r=n,(i=s).store(Da.store).Fr().next(function(t){r.deleteObjectStore(Da.store),r.createObjectStore(Da.store,{keyPath:Da.keyPath,autoIncrement:!0}).createIndex(Da.userMutationsIndex,Da.userMutationsKeyPath,{unique:!0});var e=i.store(Da.store),n=t.map(function(t){return e.put(t)});return fu.vn(n)});var r,i})),a=a.next(function(){n.createObjectStore(Fa.store,{keyPath:Fa.keyPath})})),t<5&&5<=e&&(a=a.next(function(){return i.removeAcknowledgedMutations(s)})),t<6&&6<=e&&(a=a.next(function(){return n.createObjectStore(Va.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(La.store)).createIndex(La.readTimeIndex,La.readTimeIndexPath,{unique:!1}),t.createIndex(La.collectionReadTimeIndex,La.collectionReadTimeIndexPath,{unique:!1})})),t<10&&10<=e&&(a=a.next(function(){return i.rewriteCanonicalIds(s)})),a},Sa.prototype.addDocumentGlobal=function(e){var n=0;return e.store(La.store).Ur(function(t,e){n+=Qu(e)}).next(function(){var t=new Va(n);return e.store(Va.store).put(Va.key,t)})},Sa.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(ka.store),e=r.store(Da.store);return t.Fr().next(function(t){return fu.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.Fr(Da.userMutationsIndex,t).next(function(t){return fu.forEach(t,function(t){Zs(t.userId===n.userId);var e=i.serializer.Lh(t);return wa(r,n.userId,e).next(function(){})})})})})},Sa.prototype.ensureSequenceNumbers=function(t){var s=t.store(Ua.store),e=t.store(La.store);return t.store(ja.store).get(ja.key).next(function(i){var o=[];return e.Ur(function(t,e){var n=new Cr(t),r=[0,Ou(n)];o.push(s.get(r).next(function(t){return t?fu.resolve():(e=n,s.put(new Ua(0,Ou(e),i.highestListenSequenceNumber)));var e}))}).next(function(){return fu.vn(o)})})},Sa.prototype.createCollectionParentIndex=function(t,e){function i(t){if(o.add(t)){var e=t.O(),n=t.L();return r.put({collectionId:e,parent:Ou(n)})}}t.createObjectStore(Ma.store,{keyPath:Ma.keyPath});var r=e.store(Ma.store),o=new Cu;return e.store(La.store).Ur({Dh:!0},function(t,e){var n=new Cr(t);return i(n.L())}).next(function(){return e.store(xa.store).Ur({Dh:!0},function(t,e){t[0];var n=t[1],r=(t[2],Lu(n));return i(r.L())})})},Sa.prototype.rewriteCanonicalIds=function(t){var i=this,o=t.store(Ca.store);return o.Ur(function(t,e){var n=i.serializer.mh(e),r=i.serializer.Ph(n);return o.put(r)})},Sa),Aa=function(t,e){this.seconds=t,this.nanoseconds=e},_a=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};function Sa(t){this.serializer=t}_a.store="owner",_a.key="owner";var ka=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};ka.store="mutationQueues",ka.keyPath="userId";var Da=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Da.store="mutations",Da.keyPath="batchId",Da.userMutationsIndex="userMutationsIndex",Da.userMutationsKeyPath=["userId","batchId"];var xa=(Oa.prefixForUser=function(t){return[t]},Oa.prefixForPath=function(t,e){return[t,Ou(e)]},Oa.key=function(t,e,n){return[t,Ou(e),n]},Oa);function Oa(){}xa.store="documentMutations",xa.PLACEHOLDER=new xa;var Ra=function(t,e){this.path=t,this.readTime=e},Pa=function(t,e){this.path=t,this.version=e},La=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};La.store="remoteDocuments",La.readTimeIndex="readTimeIndex",La.readTimeIndexPath="readTime",La.collectionReadTimeIndex="collectionReadTimeIndex",La.collectionReadTimeIndexPath=["parentPath","readTime"];var Va=function(t){this.byteSize=t};Va.store="remoteDocumentGlobal",Va.key="remoteDocumentGlobalKey";var Ca=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};Ca.store="targets",Ca.keyPath="targetId",Ca.queryTargetsIndexName="queryTargetsIndex",Ca.queryTargetsKeyPath=["canonicalId","targetId"];var Ua=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Ua.store="targetDocuments",Ua.keyPath=["targetId","path"],Ua.documentTargetsIndex="documentTargetsIndex",Ua.documentTargetsKeyPath=["path","targetId"];var ja=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};ja.key="targetGlobalKey",ja.store="targetGlobal";var Ma=function(t,e){this.collectionId=t,this.parent=e};function qa(t){t.createObjectStore(Ua.store,{keyPath:Ua.keyPath}).createIndex(Ua.documentTargetsIndex,Ua.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Ca.store,{keyPath:Ca.keyPath}).createIndex(Ca.queryTargetsIndexName,Ca.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(ja.store)}Ma.store="collectionParents",Ma.keyPath=["collectionId","parent"];var Fa=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Fa.store="clientMetadata",Fa.keyPath="clientId";var Ba,Ga=i(i(i([ka.store,Da.store,xa.store,La.store,Ca.store,_a.store,ja.store,Ua.store],[Fa.store]),[Va.store]),[Ma.store]),za=(Ha.Xh=function(o,t,s){return Hs("SimpleDb","Opening database:",o),new fu(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new Ha(e))},i.onblocked=function(){r(new kr(Sr.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 kr(Sr.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){Hs("SimpleDb",'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;s.createOrUpgrade(e,i.transaction,t.oldVersion,Ia).next(function(){Hs("SimpleDb","Database upgrade to version "+Ia+" complete")})}}).yn()},Ha.delete=function(t){return Hs("SimpleDb","Removing database:",t),eh(window.indexedDB.deleteDatabase(t)).yn()},Ha.Gh=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(Ha.ua())return!0;if(void 0===window.navigator)return!1;var t=p(),e=Ha.aa(t),n=0<e&&e<10,r=Ha.ca(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},Ha.ua=function(){var t;return"undefined"!=typeof __PRIVATE_process&&"YES"===(null===(t=__PRIVATE_process.__PRIVATE_env)||void 0===t?void 0:t._a)},Ha.Nr=function(t,e){return t.store(e)},Ha.aa=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)},Ha.ca=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},Ha.prototype.oo=function(e){this.db.onversionchange=function(t){return e(t)}},Ha.prototype.runTransaction=function(r,h,c){return y(this,void 0,void 0,function(){var s,u,e,a,n;return v(this,function(t){switch(t.label){case 0:s="readonly"===r,u=0,e=function(){var e,n,r,i,o;return v(this,function(t){switch(t.label){case 0:++u,e=Xa.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),fu.reject(t)}).yn(),r={},n.catch(function(){}),[4,e.la];case 2:return[2,(r.value=(t.sent(),n),r)];case 3:return i=t.sent(),o="FirebaseError"!==i.name&&u<3,Hs("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]}})})},Ha.prototype.close=function(){this.db.close()},Ha),Wa=(Object.defineProperty(Qa.prototype,"Pn",{get:function(){return this.fa},enumerable:!0,configurable:!0}),Object.defineProperty(Qa.prototype,"Ea",{get:function(){return this.Ta},enumerable:!0,configurable:!0}),Object.defineProperty(Qa.prototype,"cursor",{set:function(t){this.da=t},enumerable:!0,configurable:!0}),Qa.prototype.done=function(){this.fa=!0},Qa.prototype.Qr=function(t){this.Ta=t},Qa.prototype.delete=function(){return eh(this.da.delete())},Qa),Ka=(n(Ya,Ba=kr),Ya);function Ya(t){var e=this;return(e=Ba.call(this,Sr.UNAVAILABLE,"IndexedDB transaction failed: "+t)||this).name="IndexedDbTransactionError",e}function Qa(t){this.da=t,this.fa=!1,this.Ta=null}function Ha(t){this.db=t,12.2===Ha.aa(p())&&$s("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 $a(t){return"IndexedDbTransactionError"===t.name}var Xa=(th.open=function(t,e,n){return new th(t.transaction(n,e))},Object.defineProperty(th.prototype,"la",{get:function(){return this.Ia.promise},enumerable:!0,configurable:!0}),th.prototype.abort=function(t){t&&this.Ia.reject(t),this.aborted||(Hs("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},th.prototype.store=function(t){var e=this.transaction.objectStore(t);return new Ja(e)},th),Ja=(Za.prototype.put=function(t,e){return eh(void 0!==e?(Hs("SimpleDb","PUT",this.store.name,t,e),this.store.put(e,t)):(Hs("SimpleDb","PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},Za.prototype.add=function(t){return Hs("SimpleDb","ADD",this.store.name,t,t),eh(this.store.add(t))},Za.prototype.get=function(e){var n=this;return eh(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Hs("SimpleDb","GET",n.store.name,e,t),t})},Za.prototype.delete=function(t){return Hs("SimpleDb","DELETE",this.store.name,t),eh(this.store.delete(t))},Za.prototype.count=function(){return Hs("SimpleDb","COUNT",this.store.name),eh(this.store.count())},Za.prototype.Fr=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.wa(n,function(t,e){r.push(e)}).next(function(){return r})},Za.prototype.Ra=function(t,e){Hs("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Dh=!1;var r=this.cursor(n);return this.wa(r,function(t,e,n){return n.delete()})},Za.prototype.Ur=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.wa(r,e)},Za.prototype.Uo=function(i){var t=this.cursor({});return new fu(function(n,r){t.onerror=function(t){var e=rh(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()}})},Za.prototype.wa=function(t,s){var u=[];return new fu(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 Wa(e),r=s(e.primaryKey,e.value,n);if(r instanceof fu){var i=r.catch(function(t){return n.done(),fu.reject(t)});u.push(i)}n.Pn?o():null===n.Ea?e.continue():e.continue(n.Ea)}else o()}}).next(function(){return fu.vn(u)})},Za.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},Za.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Dh?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},Za);function Za(t){this.store=t}function th(t){var n=this;this.transaction=t,this.aborted=!1,this.Ia=new ku,this.transaction.oncomplete=function(){n.Ia.resolve()},this.transaction.onabort=function(){t.error?n.Ia.reject(new Ka(t.error)):n.Ia.resolve()},this.transaction.onerror=function(t){var e=rh(t.target.error);n.Ia.reject(new Ka(e))}}function eh(t){return new fu(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=rh(t.target.error);r(e)}})}var nh=!1;function rh(t){var e=za.aa(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 kr("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 nh||(nh=!0,setTimeout(function(){throw r},0)),r}}return t}var ih=(uh.ga=function(t,e,n,r,i){var o=new uh(t,e,Date.now()+n,r,i);return o.start(n),o},uh.prototype.start=function(t){var e=this;this.pa=setTimeout(function(){return e.ya()},t)},uh.prototype.vr=function(){return this.ya()},uh.prototype.cancel=function(t){null!==this.pa&&(this.clearTimeout(),this.Va.reject(new kr(Sr.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},uh.prototype.ya=function(){var e=this;this.Aa.uo(function(){return null!==e.pa?(e.clearTimeout(),e.op().then(function(t){return e.Va.resolve(t)})):Promise.resolve()})},uh.prototype.clearTimeout=function(){null!==this.pa&&(this.Pa(this),clearTimeout(this.pa),this.pa=null)},uh),oh=(Object.defineProperty(sh.prototype,"La",{get:function(){return this.Sa},enumerable:!0,configurable:!0}),sh.prototype.uo=function(t){this.enqueue(t)},sh.prototype.Ma=function(t){this.Oa(),this.xa(t)},sh.prototype.Ba=function(t){return this.Oa(),this.xa(t)},sh.prototype.qa=function(n){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.Oa(),this.Sa?[3,2]:(this.Sa=!0,(e=zs.nt().window)&&e.removeEventListener("visibilitychange",this.ka),[4,this.Ba(n)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},sh.prototype.enqueue=function(t){return this.Oa(),this.Sa?new Promise(function(t){}):this.xa(t)},sh.prototype.Ua=function(i){var t=this;this.Oa(),this.Sa||(this.va=this.va.then(function(){var n=new ku,r=function(){return y(t,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,i()];case 1:return t.sent(),n.resolve(),this.$a.reset(),[3,3];case 2:if(!$a(e=t.sent()))throw n.resolve(),e;return Hs("AsyncQueue","Operation failed with retryable error: "+e),this.$a.gr(r),[3,3];case 3:return[2]}})})};return t.uo(r),n.promise}))},sh.prototype.xa=function(t){var e=this,n=this.ba.then(function(){return e.Fa=!0,t().catch(function(t){throw e.Ca=t,e.Fa=!1,$s("INTERNAL UNHANDLED ERROR: ",t.stack||t.message||""),t}).then(function(t){return e.Fa=!1,t})});return this.ba=n},sh.prototype.yr=function(t,e,n){var r=this;this.Oa(),-1<this.Na.indexOf(t)&&(e=0);var i=ih.ga(this,t,e,n,function(t){return r.Qa(t)});return this.Da.push(i),i},sh.prototype.Oa=function(){this.Ca&&Js()},sh.prototype.Wa=function(){},sh.prototype.ja=function(){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return[4,e=this.ba];case 1:t.sent(),t.label=2;case 2:if(e!==this.ba)return[3,0];t.label=3;case 3:return[2]}})})},sh.prototype.Ka=function(t){for(var e=0,n=this.Da;e<n.length;e++)if(n[e].Er===t)return!0;return!1},sh.prototype.Ga=function(r){var i=this;return this.ja().then(function(){i.Da.sort(function(t,e){return t.ma-e.ma});for(var t=0,e=i.Da;t<e.length;t++){var n=e[t];if(n.vr(),"all"!==r&&n.Er===r)break}return i.ja()})},sh.prototype.za=function(t){this.Na.push(t)},sh.prototype.Qa=function(t){var e=this.Da.indexOf(t);this.Da.splice(e,1)},sh);function sh(){var t=this;this.ba=Promise.resolve(),this.va=Promise.resolve(),this.Sa=!1,this.Da=[],this.Ca=null,this.Fa=!1,this.Na=[],this.$a=new Du(this,"async_queue_retry"),this.ka=function(){return t.$a.br()};var e=zs.nt().window;e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.ka)}function uh(t,e,n,r,i){this.Aa=t,this.Er=e,this.ma=n,this.op=r,this.Pa=i,this.Va=new ku,this.then=this.Va.promise.then.bind(this.Va.promise),this.Va.promise.catch(function(t){})}function ah(t,e){if($s("AsyncQueue",e+": "+t),$a(t))return new kr(Sr.UNAVAILABLE,e+": "+t);throw t}function hh(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=ru(n,i);return 0===s?ru(r,o):s}var ch=(dh.prototype.Ja=function(){return++this.Ya},dh.prototype.Xa=function(t){var e=[t,this.Ja()];if(this.buffer.size<this.Ha)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();hh(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(dh.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),dh),fh={Za:!1,tu:0,eu:0,su:0},lh=(ph.hu=function(t){return new ph(t,ph.ou,ph.au)},ph);function ph(t,e,n){this.iu=t,this.nu=e,this.ru=n}function dh(t){this.Ha=t,this.buffer=new os(hh),this.Ya=0}lh.uu=-1,lh.cu=1048576,lh._u=41943040,lh.ou=10,lh.au=1e3,lh.lu=new lh(lh._u,lh.ou,lh.au),lh.DISABLED=new lh(lh.uu,0,0);var yh=(bh.prototype.start=function(t){this.ko.Tu.iu!==lh.uu&&this.Eu(t)},bh.prototype.stop=function(){this.fu&&(this.fu.cancel(),this.fu=null)},Object.defineProperty(bh.prototype,"ro",{get:function(){return null!==this.fu},enumerable:!0,configurable:!0}),bh.prototype.Eu=function(n){var t=this,e=this.du?3e5:6e4;Hs("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.fu=this.Aa.yr("lru_garbage_collection",e,function(){return y(t,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:this.fu=null,this.du=!0,t.label=1;case 1:return t.trys.push([1,3,,7]),[4,n.Iu(this.ko)];case 2:return t.sent(),[3,7];case 3:return $a(e=t.sent())?(Hs("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,Nh(e)];case 5:t.sent(),t.label=6;case 6:return[3,7];case 7:return[4,this.Eu(n)];case 8:return t.sent(),[2]}})})})},bh),vh=(wh.prototype.Ru=function(t,e){return this.wu.Lo(t).next(function(t){return Math.floor(e/100*t)})},wh.prototype.Au=function(t,e){var n=this;if(0===e)return fu.resolve(gu.dr);var r=new ch(e);return this.wu.js(t,function(t){return r.Xa(t.sequenceNumber)}).next(function(){return n.wu.Oo(t,function(t){return r.Xa(t)})}).next(function(){return r.maxValue})},wh.prototype.Ah=function(t,e,n){return this.wu.Ah(t,e,n)},wh.prototype.Qo=function(t,e){return this.wu.Qo(t,e)},wh.prototype.mu=function(e,n){var r=this;return this.Tu.iu===lh.uu?(Hs("LruGarbageCollector","Garbage collection skipped; disabled"),fu.resolve(fh)):this.jo(e).next(function(t){return t<r.Tu.iu?(Hs("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.Tu.iu),fh):r.Pu(e,n)})},wh.prototype.jo=function(t){return this.wu.jo(t)},wh.prototype.Pu=function(e,n){var r,i,o,s,u,a,h,c=this,f=Date.now();return this.Ru(e,this.Tu.nu).next(function(t){return i=t>c.Tu.ru?(Hs("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+c.Tu.ru+" from "+t),c.Tu.ru):t,s=Date.now(),c.Au(e,i)}).next(function(t){return r=t,u=Date.now(),c.Ah(e,r,n)}).next(function(t){return o=t,a=Date.now(),c.Qo(e,r)}).next(function(t){return h=Date.now(),Ys()<=l.DEBUG&&Hs("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"),fu.resolve({Za:!0,tu:i,eu:o,su:t})})},wh),gh=(mh.prototype.start=function(){return Promise.resolve()},mh.prototype.Du=function(i){return y(this,void 0,void 0,function(){var e,m,n,r=this;return v(this,function(t){switch(t.label){case 0:return e=this.Wn,m=this.vu,[4,this.persistence.runTransaction("Handle user change","readonly",function(v){var g;return r.Wn.ia(v).next(function(t){return g=t,e=r.persistence.vo(i),m=new yu(r.bu,e,r.persistence.Fo()),e.ia(v)}).next(function(t){for(var e=[],n=[],r=gs(),i=0,o=g;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 m.Yn(v,r).next(function(t){return{Cu:t,Fu:e,Nu:n}})})})];case 1:return n=t.sent(),[2,(this.Wn=e,this.vu=m,this.Vu.Su(this.vu),n)]}})})},mh.prototype.$u=function(u){var a,h=this,c=Pr.now(),t=u.reduce(function(t,e){return t.add(e.key)},gs());return this.persistence.runTransaction("Locally write mutations","readwrite",function(s){return h.vu.Yn(s,t).next(function(t){a=t;for(var e=[],n=0,r=u;n<r.length;n++){var i=r[n],o=i.Pt(a.get(i.key));null!=o&&e.push(new zi(i.key,o,uo(o.proto.mapValue),Fi.exists(!0)))}return h.Wn.Xo(s,c,e,u)})}).then(function(t){var e=t.In(a);return{batchId:t.batchId,Dn:e}})},mh.prototype.zo=function(r){var i=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var e=r.batch.keys(),n=i.bu.Yr({Xr:!0});return i.Wn.zo(t,r.batch,r.streamToken).next(function(){return i.ku(t,r,n)}).next(function(){return n.apply(t)}).next(function(){return i.Wn.oa(t)}).next(function(){return i.vu.Yn(t,e)})})},mh.prototype.Lu=function(t){var r=this;return this.persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return r.Wn.Zo(e,t).next(function(t){return Zs(null!==t),n=t.keys(),r.Wn.ra(e,t)}).next(function(){return r.Wn.oa(e)}).next(function(){return r.vu.Yn(e,n)})})},mh.prototype.sa=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e.Wn.sa(t)})},mh.prototype.Yo=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly",function(t){return e.Wn.Yo(t)})},mh.prototype.Jo=function(e){var n=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary",function(t){return n.Wn.Jo(t,e)})},mh.prototype._h=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.Yh._h(t)})},mh.prototype.Mu=function(a){var h=this,c=a.Ee,f=this.gu;return this.persistence.runTransaction("Apply remote event","readwrite-primary",function(o){var i=h.bu.Yr({Xr:!0});f=h.gu;var s=[];a.as.forEach(function(t,e){var n=f.get(e);if(n){s.push(h.Yh.bh(o,t.Is,e).next(function(){return h.Yh.ph(o,t.Ts,e)}));var r=t.resumeToken;if(0<r.rt()){var i=n.we(r,c).Ie(o.Oh);f=f.Ae(e,i),mh.Ou(n,i,t)&&s.push(h.Yh.Ih(o,i))}}});var u=cs(),n=gs();if(a.cs.forEach(function(t,e){n=n.add(t)}),s.push(i.getEntries(o,n).next(function(r){a.cs.forEach(function(t,e){var n=r.get(t);e instanceof Io&&e.version.isEqual(Lr.min())?(i.kn(t,c),u=u.Ae(t,e)):null==n||0<e.version.S(n.version)||0===e.version.S(n.version)&&n.hasPendingWrites?(i.Nn(e,c),u=u.Ae(t,e)):Hs("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),a._s.has(t)&&s.push(h.persistence.hh.Wo(o,t))})})),!c.isEqual(Lr.min())){var t=h.Yh._h(o).next(function(t){return h.Yh.dh(o,o.Oh,c)});s.push(t)}return fu.vn(s).next(function(){return i.apply(o)}).next(function(){return h.vu.Jn(o,u)})}).then(function(t){return h.gu=f,t})},mh.Ou=function(t,e,n){return Zs(0<e.resumeToken.rt()),0===t.resumeToken.rt()||e.Ee.D()-t.Ee.D()>=this.xu||0<n.Ts.size+n.Es.size+n.Is.size},mh.prototype.Bu=function(c){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h=this;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(n){return fu.forEach(c,function(e){return fu.forEach(e.hr,function(t){return h.persistence.hh.yh(n,e.targetId,t)}).next(function(){return fu.forEach(e.or,function(t){return h.persistence.hh.vh(n,e.targetId,t)})})})})];case 1:return t.sent(),[3,3];case 2:if(!$a(e=t.sent()))throw e;return Hs("LocalStore","Failed to update sequence numbers: "+e),[3,3];case 3:for(n=0,r=c;n<r.length;n++)i=r[n],o=i.targetId,i.fromCache||(s=this.gu.get(o),u=s.Ee,a=s.Re(u),this.gu=this.gu.Ae(o,a));return[2]}})})},mh.prototype.qu=function(e){var n=this;return this.persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===e&&(e=-1),n.Wn.ea(t,e)})},mh.prototype.Uu=function(e){var n=this;return this.persistence.runTransaction("read document","readonly",function(t){return n.vu.Kn(t,e)})},mh.prototype.Qu=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite",function(e){var n;return i.Yh.gh(e,r).next(function(t){return t?(n=t,fu.resolve(n)):i.Yh.oh(e).next(function(t){return n=new Vo(r,t,0,e.Oh),i.Yh.fh(e,n).next(function(){return n})})})}).then(function(t){return null===i.gu.get(t.targetId)&&(i.gu=i.gu.Ae(t.targetId,t),i.pu.set(r,t.targetId)),t})},mh.prototype.gh=function(t,e){var n=this.pu.get(e);return void 0!==n?fu.resolve(this.gu.get(n)):this.Yh.gh(t,e)},mh.prototype.Wu=function(t,e){var n=this,r=this.gu.get(t),i=e?"readwrite":"readwrite-primary";return this.persistence.runTransaction("Release target",i,function(t){return e?fu.resolve():n.persistence.hh.removeTarget(t,r)}).then(function(){n.gu=n.gu.remove(t),n.pu.delete(r.target)})},mh.prototype.ju=function(t,n){var r=this,i=Lr.min(),o=gs();return this.persistence.runTransaction("Execute query","readonly",function(e){return r.gh(e,t.ee()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.Yh.Sh(e,t.targetId).next(function(t){o=t})}).next(function(){return r.Vu.Zn(e,t,n?i:Lr.min(),n?o:gs())}).next(function(t){return{documents:t,Ku:o}})})},mh.prototype.ku=function(t,i,o){var e=this,s=i.batch,n=s.keys(),u=fu.resolve();return n.forEach(function(r){u=u.next(function(){return o.Ln(t,r)}).next(function(t){var e=t,n=i.Rn.get(r);Zs(null!==n),(!e||e.version.S(n)<0)&&(e=s.at(r,e,i))&&o.Nn(e,i.wn)})}),u.next(function(){return e.Wn.ra(t,s)})},mh.prototype.Iu=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(t){return e.mu(t,n.gu)})},mh);function mh(t,e,n){this.persistence=t,this.Vu=e,this.gu=new Jo(ru),this.pu=new au(function(t){return t.canonicalId()}),this.yu=Lr.min(),this.Wn=t.vo(n),this.bu=t.Co(),this.Yh=t.Do(),this.vu=new yu(this.bu,this.Wn,this.persistence.Fo()),this.Vu.Su(this.vu)}function wh(t,e){this.wu=t,this.Tu=e}function bh(t,e){this.ko=t,this.Aa=e,this.du=!1,this.fu=null}gh.xu=3e8;var Eh,Th=(n(Ih,Eh=gh),Ih.prototype.start=function(){return this.Gu()},Ih.prototype.zu=function(t){var n=this;return this.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return n.Wn.ta(e,t).next(function(t){return t?n.vu.Yn(e,t):fu.resolve(null)})})},Ih.prototype.Hu=function(t){this.Wn.ha(t)},Ih.prototype.ao=function(t){this.persistence.ao(t)},Ih.prototype.bo=function(){return this.persistence.bo()},Ih.prototype.Yu=function(e){var n=this,t=this.gu.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly",function(t){return n.Yh.si(t,e).next(function(t){return t?t.target:null})})},Ih.prototype.Kr=function(){var r=this;return this.persistence.runTransaction("Get new document changes","readonly",function(t){return r.bu.Kr(t,r.yu)}).then(function(t){var e=t.Gr,n=t.readTime;return r.yu=n,e})},Ih.prototype.Gu=function(){return y(this,void 0,void 0,function(){var e,n=this;return v(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.bu.Hr(t)})];case 1:return e.yu=t.sent(),[2]}})})},Ih);function Ih(t,e,n){var r=this;return(r=Eh.call(this,t,e,n)||this).persistence=t,r.Wn=t.vo(n),r.bu=t.Co(),r.Yh=t.Do(),r}function Nh(e){return y(this,void 0,void 0,function(){return v(this,function(t){if(e.code!==Sr.FAILED_PRECONDITION||e.message!==pu)throw e;return Hs("LocalStore","Unexpectedly lost primary lease"),[2]})})}var Ah=(kh.prototype.B=function(){return this.Ju.B()},kh.prototype.yh=function(t,e){var n=new _h(t,e);this.Ju=this.Ju.add(n),this.Zu=this.Zu.add(n)},kh.prototype.ec=function(t,e){var n=this;t.forEach(function(t){return n.yh(t,e)})},kh.prototype.vh=function(t,e){this.sc(new _h(t,e))},kh.prototype.ic=function(t,e){var n=this;t.forEach(function(t){return n.vh(t,e)})},kh.prototype.nc=function(t){var e=this,n=$r.EMPTY,r=new _h(n,t),i=new _h(n,t+1),o=[];return this.Zu.Ke([r,i],function(t){e.sc(t),o.push(t.key)}),o},kh.prototype.rc=function(){var e=this;this.Ju.forEach(function(t){return e.sc(t)})},kh.prototype.sc=function(t){this.Ju=this.Ju.delete(t),this.Zu=this.Zu.delete(t)},kh.prototype.hc=function(t){var e=$r.EMPTY,n=new _h(e,t),r=new _h(e,t+1),i=gs();return this.Zu.Ke([n,r],function(t){i=i.add(t.key)}),i},kh.prototype.Ch=function(t){var e=new _h(t,0),n=this.Ju.ze(e);return null!==n&&t.isEqual(n.key)},kh),_h=(Sh.Xu=function(t,e){return $r.N(t.key,e.key)||ru(t.oc,e.oc)},Sh.tc=function(t,e){return ru(t.oc,e.oc)||$r.N(t.key,e.key)},Sh);function Sh(t,e){this.key=t,this.oc=e}function kh(){this.Ju=new os(_h.Xu),this.Zu=new os(_h.tc)}function Dh(t,e){if(0!==e.length)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Kh(e.length,"argument")+".")}function xh(t,e,n){if(e.length!==n)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires "+Kh(n,"argument")+", but was called with "+Kh(e.length,"argument")+".")}function Oh(t,e,n){if(e.length<n)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Kh(n,"argument")+", but was called with "+Kh(e.length,"argument")+".")}function Rh(t,e,n,r){if(e.length<n||e.length>r)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Kh(e.length,"argument")+".")}function Ph(t,e,n,r){jh(t,e,Wh(n)+" argument",r)}function Lh(t,e,n,r){void 0!==r&&Ph(t,e,n,r)}function Vh(t,e,n,r){jh(t,e,n+" option",r)}function Ch(t,e,n,r){void 0!==r&&Vh(t,e,n,r)}function Uh(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(qh(s))}var u=qh(n);throw new kr(Sr.INVALID_ARGUMENT,"Invalid value "+u+" provided to function "+t+'() for option "'+e+'". Acceptable values: '+r.join(", "))}(t,n,r)}function jh(t,e,n,r){if(!("object"===e?Mh(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=qh(r);throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function Mh(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function qh(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":Js();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 Fh(t,e,n){if(void 0===n)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+Wh(e)+" argument, but it was undefined.")}function Bh(n,t,r){Zr(t,function(t,e){if(r.indexOf(t)<0)throw new kr(Sr.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function Gh(t,e,n,r){var i=qh(r);return new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+Wh(n)+" argument to be a "+e+", but it was: "+i)}function zh(t,e,n){if(n<=0)throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+Wh(e)+" argument to be a positive number, but it was: "+n+".")}function Wh(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Kh(t,e){return t+" "+e+(1===t?"":"s")}function Yh(){if("undefined"==typeof Uint8Array)throw new kr(Sr.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Qh(){if(!zs.nt().ac)throw new kr(Sr.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var Hh=(Jh.fromBase64String=function(t){xh("Blob.fromBase64String",arguments,1),Ph("Blob.fromBase64String","string",1,t),Qh();try{return new Jh(ei.fromBase64String(t))}catch(t){throw new kr(Sr.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Jh.fromUint8Array=function(t){if(xh("Blob.fromUint8Array",arguments,1),Yh(),!(t instanceof Uint8Array))throw Gh("Blob.fromUint8Array","Uint8Array",1,t);return new Jh(ei.fromUint8Array(t))},Jh.prototype.toBase64=function(){return xh("Blob.toBase64",arguments,0),Qh(),this.uc.toBase64()},Jh.prototype.toUint8Array=function(){return xh("Blob.toUint8Array",arguments,0),Yh(),this.uc.toUint8Array()},Jh.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Jh.prototype.isEqual=function(t){return this.uc.isEqual(t.uc)},Jh),$h=(Xh.documentId=function(){return Xh._c},Xh.prototype.isEqual=function(t){if(!(t instanceof Xh))throw Gh("isEqual","FieldPath",1,t);return this.cc.isEqual(t.cc)},Xh);function Xh(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(){if(!(t instanceof Array)||t.length<1)throw new kr(Sr.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(Ph("FieldPath","string",n,t[n]),0===t[n].length)throw new kr(Sr.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.cc=new Qr(t)}function Jh(t){Qh(),this.uc=t}$h._c=new $h(Qr.J().j());var Zh,tc,ec,nc,rc,ic=new RegExp("[~\\*/\\[\\]]"),oc=function(t){this.lc=t},sc=(n(Tc,rc=oc),Tc.prototype.Di=function(t){if(2!==t.dc)throw 1===t.dc?t.fc("FieldValue.delete() can only appear at the top level of your update data"):t.fc("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");return t.Vt.push(t.path),null},Tc.prototype.isEqual=function(t){return t instanceof Tc},Tc),uc=(n(Ec,nc=oc),Ec.prototype.Di=function(t){return new qi(t.path,Ni.instance)},Ec.prototype.isEqual=function(t){return t instanceof Ec},Ec),ac=(n(bc,ec=oc),bc.prototype.Di=function(t){var e=new Nc({dc:3,methodName:this.lc,Ec:!0},t.ii,t.serializer,t.ignoreUndefinedProperties),n=this.Tc.map(function(t){return kc(t,e)}),r=new _i(n);return new qi(t.path,r)},bc.prototype.isEqual=function(t){return this===t},bc),hc=(n(wc,tc=oc),wc.prototype.Di=function(t){var e=new Nc({dc:3,methodName:this.lc,Ec:!0},t.ii,t.serializer,t.ignoreUndefinedProperties),n=this.Tc.map(function(t){return kc(t,e)}),r=new Si(n);return new qi(t.path,r)},wc.prototype.isEqual=function(t){return this===t},wc),cc=(n(mc,Zh=oc),mc.prototype.Di=function(t){var e=new Nc({dc:3,methodName:this.lc},t.ii,t.serializer,t.ignoreUndefinedProperties),n=kc(this.Ic,e),r=new ki(t.serializer,n);return new qi(t.path,r)},mc.prototype.isEqual=function(t){return this===t},mc),fc=(Object.defineProperty(gc.prototype,"latitude",{get:function(){return this.wc},enumerable:!0,configurable:!0}),Object.defineProperty(gc.prototype,"longitude",{get:function(){return this.Rc},enumerable:!0,configurable:!0}),gc.prototype.isEqual=function(t){return this.wc===t.wc&&this.Rc===t.Rc},gc.prototype.p=function(t){return ru(this.wc,t.wc)||ru(this.Rc,t.Rc)},gc),lc=/^__.*__$/,pc=(vc.prototype.Ac=function(t,e){var n=[];return null!==this.Vt?n.push(new zi(t,this.data,this.Vt,e)):n.push(new Gi(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new Wi(t,this.fieldTransforms)),n},vc),dc=(yc.prototype.Ac=function(t,e){var n=[new zi(t,this.data,this.Vt,e)];return 0<this.fieldTransforms.length&&n.push(new Wi(t,this.fieldTransforms)),n},yc);function yc(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}function vc(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}function gc(t,e){if(xh("GeoPoint",arguments,2),Ph("GeoPoint","number",1,t),Ph("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new kr(Sr.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new kr(Sr.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.wc=t,this.Rc=e}function mc(t){var e=this;return(e=Zh.call(this,"FieldValue.increment")||this).Ic=t,e}function wc(t){var e=this;return(e=tc.call(this,"FieldValue.arrayRemove")||this).Tc=t,e}function bc(t){var e=this;return(e=ec.call(this,"FieldValue.arrayUnion")||this).Tc=t,e}function Ec(){return nc.call(this,"FieldValue.serverTimestamp")||this}function Tc(){return rc.call(this,"FieldValue.delete")||this}function Ic(t){switch(t){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw Js()}}var Nc=(Object.defineProperty(Sc.prototype,"path",{get:function(){return this.settings.path},enumerable:!0,configurable:!0}),Object.defineProperty(Sc.prototype,"dc",{get:function(){return this.settings.dc},enumerable:!0,configurable:!0}),Sc.prototype.Pc=function(t){return new Sc(Object.assign(Object.assign({},this.settings),t),this.ii,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.Vt)},Sc.prototype.Vc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Pc({path:n,Ec:!1});return r.gc(t),r},Sc.prototype.pc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Pc({path:n,Ec:!1});return r.mc(),r},Sc.prototype.yc=function(t){return this.Pc({path:void 0,Ec:!0})},Sc.prototype.fc=function(t){var e=!this.path||this.path.B()?"":" (found in field "+this.path.toString()+")";return new kr(Sr.INVALID_ARGUMENT,"Function "+this.settings.methodName+"() called with invalid data. "+t+e)},Sc.prototype.contains=function(e){return void 0!==this.Vt.find(function(t){return e.q(t)})||void 0!==this.fieldTransforms.find(function(t){return e.q(t.field)})},Sc.prototype.mc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.gc(this.path.get(t))},Sc.prototype.gc=function(t){if(0===t.length)throw this.fc("Document fields must not be empty");if(Ic(this.dc)&&lc.test(t))throw this.fc('Document fields cannot begin and end with "__"')},Sc),Ac=(_c.prototype.vc=function(t,e){var n=this.Sc(0,t);Oc("Data must be an object, but it was:",n,e);var r=Dc(e,n);return new pc(new Qi(r),null,n.fieldTransforms)},_c.prototype.Dc=function(t,e,n){var r=this.Sc(2,t);Oc("Data must be an object, but it was:",r,e);var i,o,s=Dc(e,r);if(n){for(var u=[],a=0,h=n;a<h.length;a++){var c=h[a],f=void 0;if(c instanceof $h)f=c.cc;else{if("string"!=typeof c)throw Js();f=Pc(t,c)}if(!r.contains(f))throw new kr(Sr.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");Lc(u,f)||u.push(f)}i=new Mi(u),o=r.fieldTransforms.filter(function(t){return i.dt(t.field)})}else i=new Mi(r.Vt),o=r.fieldTransforms;return new pc(new Qi(s),i,o)},_c.prototype.Cc=function(o,t){var s=this.Sc(1,o);Oc("Data must be an object, but it was:",s,t);var u=[],a=new Hi;Zr(t,function(t,e){var n=Pc(o,t),r=s.pc(n);if(e instanceof sc)u.push(n);else{var i=kc(e,r);null!=i&&(u.push(n),a.set(n,i))}});var e=new Mi(u);return new dc(a.yt(),e,s.fieldTransforms)},_c.prototype.Fc=function(t,e,n,r){var i=this.Sc(1,t),o=[Rc(t,e)],s=[n];if(r.length%2!=0)throw new kr(Sr.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(Rc(t,r[u])),s.push(r[u+1]);for(var a=[],h=new Hi,c=o.length-1;0<=c;--c)if(!Lc(a,o[c])){var f=o[c],l=s[c],p=i.pc(f);if(l instanceof sc)a.push(f);else{var d=kc(l,p);null!=d&&(a.push(f),h.set(f,d))}}var y=new Mi(a);return new dc(h.yt(),y,i.fieldTransforms)},_c.prototype.Sc=function(t,e){return new Nc({dc:t,methodName:e,path:Qr.G,Ec:!1},this.ii,this.serializer,this.ignoreUndefinedProperties)},_c.prototype.Nc=function(t,e,n){return void 0===n&&(n=!1),kc(e,this.Sc(n?4:3,t))},_c);function _c(t,e,n){this.ii=t,this.ignoreUndefinedProperties=e,this.serializer=n||zs.nt().bc(t)}function Sc(t,e,n,r,i,o){this.settings=t,this.ii=e,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.mc(),this.fieldTransforms=i||[],this.Vt=o||[]}function kc(s,t){if(xc(s))return Oc("Unsupported field value:",t,s),Dc(s,t);if(s instanceof oc)return function(t,e){if(!Ic(e.dc))throw e.fc(t.lc+"() can only be used with update() and set()");if(null===e.path)throw e.fc(t.lc+"() is not currently supported inside arrays");var n=t.Di(e);n&&e.fieldTransforms.push(n)}(s,t),null;if(t.path&&t.Vt.push(t.path),s instanceof Array){if(t.settings.Ec&&4!==t.dc)throw t.fc("Nested arrays are not supported");return function(t){for(var e=[],n=0,r=0,i=s;r<i.length;r++){var o=kc(i[r],t.yc(n));null==o&&(o={nullValue:"NULL_VALUE"}),e.push(o),n++}return{arrayValue:{values:e}}}(t)}return function(t,e){if(null===t)return{nullValue:"NULL_VALUE"};if("number"==typeof t)return e.serializer.ai(t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=Pr.fromDate(t);return{timestampValue:e.serializer.C(n)}}if(t instanceof Pr){var r=new Pr(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:e.serializer.C(r)}}if(t instanceof fc)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Hh)return{bytesValue:e.serializer.ui(t)};if(t instanceof yl){var i=e.ii,o=t.firestore.$c;if(!o.isEqual(i))throw e.fc("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:e.serializer._i(t.kc.path,t.firestore.$c)}}if(void 0===t&&e.ignoreUndefinedProperties)return null;throw e.fc("Unsupported field value: "+qh(t))}(s,t)}function Dc(t,r){var i={};return ti(t)?r.path&&0<r.path.length&&r.Vt.push(r.path):Zr(t,function(t,e){var n=kc(e,r.Vc(t));null!=n&&(i[t]=n)}),{mapValue:{fields:i}}}function xc(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Pr||t instanceof fc||t instanceof Hh||t instanceof yl||t instanceof oc)}function Oc(t,e,n){if(!xc(n)||!Mh(n)){var r=qh(n);throw"an object"===r?e.fc(t+" a custom object"):e.fc(t+" "+r)}}function Rc(t,e){if(e instanceof $h)return e.cc;if("string"==typeof e)return Pc(t,e);throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Pc(t,e){try{return function(e){if(0<=e.search(ic))throw new kr(Sr.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new($h.bind.apply($h,i([void 0],e.split("."))))}catch(t){throw new kr(Sr.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).cc}catch(e){var n=e instanceof Error?e.message:e.toString();throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. "+n)}}function Lc(t,e){return t.some(function(t){return t.isEqual(e)})}var Vc,Cc,Uc,jc=(Xc.prototype.qc=function(){return 1===this.state||2===this.state||4===this.state},Xc.prototype.Uc=function(){return 2===this.state},Xc.prototype.start=function(){3!==this.state?this.auth():this.Qc()},Xc.prototype.stop=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.qc()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Xc.prototype.Wc=function(){this.state=0,this.$a.reset()},Xc.prototype.jc=function(){var t=this;this.Uc()&&null===this.Bc&&(this.Bc=this.Tr.yr(this.Lc,6e4,function(){return t.Kc()}))},Xc.prototype.Gc=function(t){this.zc(),this.stream.send(t)},Xc.prototype.Kc=function(){return y(this,void 0,void 0,function(){return v(this,function(t){return this.Uc()?[2,this.close(0)]:[2]})})},Xc.prototype.zc=function(){this.Bc&&(this.Bc.cancel(),this.Bc=null)},Xc.prototype.close=function(e,n){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.zc(),this.$a.cancel(),this.xc++,3!==e?this.$a.reset():n&&n.code===Sr.RESOURCE_EXHAUSTED?($s(n.toString()),$s("Using maximum backoff delay to prevent overloading the backend."),this.$a.Vr()):n&&n.code===Sr.UNAUTHENTICATED&&this.Oc._(),null!==this.stream&&(this.Hc(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.Yc(n)];case 1:return t.sent(),[2]}})})},Xc.prototype.Hc=function(){},Xc.prototype.auth=function(){var n=this;this.state=1;var t=this.Jc(this.xc),e=this.xc;this.Oc.getToken().then(function(t){n.xc===e&&n.Xc(t)},function(e){t(function(){var t=new kr(Sr.UNKNOWN,"Fetching auth token failed: "+e.message);return n.Zc(t)})})},Xc.prototype.Xc=function(t){var e=this,n=this.Jc(this.xc);this.stream=this.t_(t),this.stream.e_(function(){n(function(){return e.state=2,e.listener.e_()})}),this.stream.Yc(function(t){n(function(){return e.Zc(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Xc.prototype.Qc=function(){var t=this;this.state=4,this.$a.gr(function(){return y(t,void 0,void 0,function(){return v(this,function(t){return this.state=0,this.start(),[2]})})})},Xc.prototype.Zc=function(t){return Hs("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},Xc.prototype.Jc=function(e){var n=this;return function(t){n.Tr.uo(function(){return n.xc===e?t():(Hs("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Xc),Mc=(n($c,Uc=jc),$c.prototype.t_=function(t){return this.Mc.s_("Listen",t)},$c.prototype.onMessage=function(t){this.$a.reset();var e=this.serializer.pi(t),n=this.serializer.bi(t);return this.listener.i_(e,n)},$c.prototype.n_=function(t){var e={};e.database=this.serializer.wi,e.addTarget=this.serializer.ee(t);var n=this.serializer.zi(t);n&&(e.labels=n),this.Gc(e)},$c.prototype.r_=function(t){var e={};e.database=this.serializer.wi,e.removeTarget=t,this.Gc(e)},$c),qc=(n(Hc,Cc=jc),Object.defineProperty(Hc.prototype,"o_",{get:function(){return this.h_},enumerable:!0,configurable:!0}),Hc.prototype.start=function(){this.h_=!1,Cc.prototype.start.call(this)},Hc.prototype.Hc=function(){this.h_&&this.a_([])},Hc.prototype.t_=function(t){return this.Mc.s_("Write",t)},Hc.prototype.onMessage=function(t){if(Zs(!!t.streamToken),this.lastStreamToken=this.serializer.ci(t.streamToken),this.h_){this.$a.reset();var e=this.serializer.Mi(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.u_(n,e)}return Zs(!t.writeResults||0===t.writeResults.length),this.h_=!0,this.listener.c_()},Hc.prototype.__=function(){var t={};t.database=this.serializer.wi,this.Gc(t)},Hc.prototype.a_=function(t){var e=this,n={streamToken:this.serializer.ui(this.lastStreamToken),writes:t.map(function(t){return e.serializer.vi(t)})};this.Gc(n)},Hc),Fc=(n(Qc,Vc=function(){this.l_=void 0}),Qc.prototype.d_=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Mc.d_(e,n,t)}).catch(function(t){throw t.code===Sr.UNAUTHENTICATED&&r.credentials._(),t})},Qc.prototype.f_=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Mc.f_(e,n,t)}).catch(function(t){throw t.code===Sr.UNAUTHENTICATED&&r.credentials._(),t})},Qc),Bc=(Yc.prototype.A_=function(r){return y(this,void 0,void 0,function(){var e,n=this;return v(this,function(t){switch(t.label){case 0:if(this.m_(),0<this.mutations.length)throw new kr(Sr.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(s,u){return y(this,void 0,void 0,function(){var n,e,r,i,o;return v(this,function(t){switch(t.label){case 0:return n=tu(s),e={database:n.serializer.wi,documents:u.map(function(t){return n.serializer.fi(t)})},[4,n.f_("BatchGetDocuments",e)];case 1:return r=t.sent(),i=new Map,r.forEach(function(t){var e=n.serializer.gi(t);i.set(e.key.toString(),e)}),o=[],[2,(u.forEach(function(t){var e=i.get(t.toString());Zs(!!e),o.push(e)}),o)]}})})}(this.T_,r)];case 1:return[2,((e=t.sent()).forEach(function(t){t instanceof Io||t instanceof To?n.P_(t):Js()}),e)]}})})},Yc.prototype.set=function(t,e){this.write(e.Ac(t,this.Rt(t))),this.R_.add(t)},Yc.prototype.update=function(t,e){try{this.write(e.Ac(t,this.V_(t)))}catch(t){this.w_=t}this.R_.add(t)},Yc.prototype.delete=function(t){this.write([new Ki(t,this.Rt(t))]),this.R_.add(t)},Yc.prototype.commit=function(){return y(this,void 0,void 0,function(){var e,n=this;return v(this,function(t){switch(t.label){case 0:if(this.m_(),this.w_)throw this.w_;return e=this.E_,this.mutations.forEach(function(t){e=e.remove(t.key)}),e.forEach(function(t,e){n.mutations.push(new Yi(t,n.Rt(t)))}),[4,function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return v(this,function(t){switch(t.label){case 0:return e=tu(i),n={database:e.serializer.wi,writes:o.map(function(t){return e.serializer.vi(t)})},[4,e.d_("Commit",n)];case 1:return r=t.sent(),[2,e.serializer.Mi(r.writeResults,r.commitTime)]}})})}(this.T_,this.mutations)];case 1:return t.sent(),this.I_=!0,[2]}})})},Yc.prototype.P_=function(t){var e;if(t instanceof To)e=t.version;else{if(!(t instanceof Io))throw Js();e=Lr.min()}var n=this.E_.get(t.key);if(null!==n){if(!e.isEqual(n))throw new kr(Sr.ABORTED,"Document version changed between two reads.")}else this.E_=this.E_.Ae(t.key,e)},Yc.prototype.Rt=function(t){var e=this.E_.get(t);return!this.R_.has(t)&&e?Fi.updateTime(e):Fi.ft()},Yc.prototype.V_=function(t){var e=this.E_.get(t);if(this.R_.has(t)||!e)return Fi.exists(!0);if(e.isEqual(Lr.min()))throw new kr(Sr.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Fi.updateTime(e)},Yc.prototype.write=function(t){this.m_(),this.mutations=this.mutations.concat(t)},Yc.prototype.m_=function(){},Yc),Gc=(Kc.prototype.v_=function(){var t=this;0===this.p_&&(this.S_("Unknown"),this.y_=this.Aa.yr("online_state_timeout",1e4,function(){return t.y_=null,t.D_("Backend didn't respond within 10 seconds."),t.S_("Offline"),Promise.resolve()}))},Kc.prototype.C_=function(t){"Online"===this.state?this.S_("Unknown"):(this.p_++,1<=this.p_&&(this.F_(),this.D_("Connection failed 1 times. Most recent error: "+t.toString()),this.S_("Offline")))},Kc.prototype.set=function(t){this.F_(),this.p_=0,"Online"===t&&(this.b_=!1),this.S_(t)},Kc.prototype.S_=function(t){t!==this.state&&(this.state=t,this.g_(t))},Kc.prototype.D_=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.b_?($s(e),this.b_=!1):Hs("OnlineStateTracker",e)},Kc.prototype.F_=function(){null!==this.y_&&(this.y_.cancel(),this.y_=null)},Kc),zc=(Wc.prototype.start=function(){return this.enableNetwork()},Wc.prototype.enableNetwork=function(){return this.networkEnabled=!0,this.X_()},Wc.prototype.X_=function(){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.q_()?(e=this.z_,[4,this.N_.Yo()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this.Z_()?this.tl():this.Q_.set("Unknown"),[4,this.el()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},Wc.prototype.disableNetwork=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.sl()];case 1:return t.sent(),this.Q_.set("Offline"),[2]}})})},Wc.prototype.sl=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return[4,this.z_.stop()];case 1:return t.sent(),[4,this.W_.stop()];case 2:return t.sent(),0<this.k_.length&&(Hs("RemoteStore","Stopping write stream with "+this.k_.length+" pending writes"),this.k_=[]),this.il(),[2]}})})},Wc.prototype.mo=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return Hs("RemoteStore","RemoteStore shutting down."),this.networkEnabled=!1,[4,this.sl()];case 1:return t.sent(),this.x_.mo(),this.Q_.set("Unknown"),[2]}})})},Wc.prototype.listen=function(t){this.L_.has(t.targetId)||(this.L_.set(t.targetId,t),this.Z_()?this.tl():this.W_.Uc()&&this.nl(t))},Wc.prototype.rl=function(t){this.L_.delete(t),this.W_.Uc()&&this.hl(t),0===this.L_.size&&(this.W_.Uc()?this.W_.jc():this.q_()&&this.Q_.set("Unknown"))},Wc.prototype.si=function(t){return this.L_.get(t)||null},Wc.prototype.ei=function(t){return this.ol.ei(t)},Wc.prototype.nl=function(t){this.M_.Ns(t.targetId),this.W_.n_(t)},Wc.prototype.hl=function(t){this.M_.Ns(t),this.W_.r_(t)},Wc.prototype.tl=function(){this.M_=new Ds(this),this.W_.start(),this.Q_.v_()},Wc.prototype.Z_=function(){return this.q_()&&!this.W_.qc()&&0<this.L_.size},Wc.prototype.q_=function(){return!this.O_&&this.isPrimary&&this.networkEnabled},Wc.prototype.il=function(){this.M_=null},Wc.prototype.j_=function(){return y(this,void 0,void 0,function(){var n=this;return v(this,function(t){return this.L_.forEach(function(t,e){n.nl(t)}),[2]})})},Wc.prototype.K_=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return this.il(),this.Z_()?(this.Q_.C_(e),this.tl()):this.Q_.set("Unknown"),[2]})})},Wc.prototype.G_=function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return v(this,function(t){switch(t.label){case 0:if(this.Q_.set("Online"),!(i instanceof Ts&&2===i.state&&i.cause))return[3,6];t.label=1;case 1:return t.trys.push([1,3,,5]),[4,this.al(i)];case 2:return t.sent(),[3,5];case 3:return e=t.sent(),Hs("RemoteStore","Failed to remove targets %s: %s ",i.targetIds.join(","),e),[4,this.ul(e)];case 4:return t.sent(),[3,5];case 5:return[3,13];case 6:if(i instanceof bs?this.M_.qs(i):i instanceof Es?this.M_.Hs(i):this.M_.Ws(i),o.isEqual(Lr.min()))return[3,13];t.label=7;case 7:return t.trys.push([7,11,,13]),[4,this.N_._h()];case 8:return n=t.sent(),0<=o.S(n)?[4,this.cl(o)]:[3,10];case 9:t.sent(),t.label=10;case 10:return[3,13];case 11:return Hs("RemoteStore","Failed to raise snapshot:",r=t.sent()),[4,this.ul(r)];case 12:return t.sent(),[3,13];case 13:return[2]}})})},Wc.prototype.ul=function(n){return y(this,void 0,void 0,function(){var e=this;return v(this,function(t){switch(t.label){case 0:if(!$a(n))throw n;return this.O_=!0,[4,this.sl()];case 1:return t.sent(),this.Q_.set("Offline"),this.Aa.Ua(function(){return y(e,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return Hs("RemoteStore","Retrying IndexedDB access"),[4,this.N_._h()];case 1:return t.sent(),this.O_=!1,[4,this.X_()];case 2:return t.sent(),[2]}})})}),[2]}})})},Wc.prototype.cl=function(r){var i=this,t=this.M_.Xs(r);return t.as.forEach(function(t,e){if(0<t.resumeToken.rt()){var n=i.L_.get(e);n&&i.L_.set(e,n.we(t.resumeToken,r))}}),t.us.forEach(function(t){var e=i.L_.get(t);if(e){i.L_.set(t,e.we(ei.ht,e.Ee)),i.hl(t);var n=new Vo(e.target,t,1,e.sequenceNumber);i.nl(n)}}),this.ol.Mu(t)},Wc.prototype.al=function(o){return y(this,void 0,void 0,function(){var e,n,r,i;return v(this,function(t){switch(t.label){case 0:e=o.cause,n=0,r=o.targetIds,t.label=1;case 1:return n<r.length?(i=r[n],this.L_.has(i)?[4,this.ol._l(i,e)]:[3,3]):[3,5];case 2:t.sent(),this.L_.delete(i),this.M_.removeTarget(i),t.label=3;case 3:t.label=4;case 4:return n++,[3,1];case 5:return[2]}})})},Wc.prototype.el=function(){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return this.ll()?(e=0<this.k_.length?this.k_[this.k_.length-1].batchId:-1,[4,this.N_.qu(e)]):[3,5];case 1:return null!==(n=t.sent())?[3,2]:(0===this.k_.length&&this.z_.jc(),[3,4]);case 2:return this.dl(n),[4,this.el()];case 3:t.sent(),t.label=4;case 4:t.label=5;case 5:return this.fl()&&this.Tl(),[2]}})})},Wc.prototype.ll=function(){return this.q_()&&this.k_.length<10},Wc.prototype.El=function(){return this.k_.length},Wc.prototype.dl=function(t){this.k_.push(t),this.z_.Uc()&&this.z_.o_&&this.z_.a_(t.mutations)},Wc.prototype.fl=function(){return this.q_()&&!this.z_.qc()&&0<this.k_.length},Wc.prototype.Tl=function(){this.z_.start()},Wc.prototype.H_=function(){return y(this,void 0,void 0,function(){return v(this,function(t){return this.z_.__(),[2]})})},Wc.prototype.J_=function(){var r=this;return this.N_.Jo(this.z_.lastStreamToken).then(function(){for(var t=0,e=r.k_;t<e.length;t++){var n=e[t];r.z_.a_(n.mutations)}}).catch(Nh)},Wc.prototype.u_=function(t,e){var n=this,r=this.k_.shift(),i=cu.from(r,t,e,this.z_.lastStreamToken);return this.ol.Il(i).then(function(){return n.el()})},Wc.prototype.Y_=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return e&&0<this.k_.length?this.z_.o_?[4,this.wl(e)]:[3,2]:[3,5];case 1:return t.sent(),[3,4];case 2:return[4,this.Rl(e)];case 3:t.sent(),t.label=4;case 4:this.fl()&&this.Tl(),t.label=5;case 5:return[2]}})})},Wc.prototype.Rl=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return $o(e.code)?[2,(Hs("RemoteStore","RemoteStore error before completed handshake; resetting stream token: ",this.z_.lastStreamToken),this.z_.lastStreamToken=ei.ht,this.N_.Jo(ei.ht).catch(Nh))]:[2]})})},Wc.prototype.wl=function(i){return y(this,void 0,void 0,function(){var e,n,r=this;return v(this,function(t){return $o(n=i.code)&&n!==Sr.ABORTED?(e=this.k_.shift(),[2,(this.z_.Wc(),this.ol.Al(e.batchId,i).then(function(){return r.el()}))]):[2]})})},Wc.prototype.ml=function(){return new Bc(this.T_)},Wc.prototype.U_=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.sl()];case 1:return t.sent(),this.Q_.set("Unknown"),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},Wc.prototype.Pl=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.q_()?(Hs("RemoteStore","RemoteStore restarting streams for new credential"),[4,this.U_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Wc.prototype.Vl=function(e){return y(this,void 0,void 0,function(){return v(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.sl()];case 3:t.sent(),this.Q_.set("Unknown"),t.label=4;case 4:t.label=5;case 5:return[2]}})})},Wc);function Wc(t,e,n,r,i){var o,s,u,a,h,c,f,l,p=this;this.N_=t,this.T_=e,this.Aa=n,this.k_=[],this.L_=new Map,this.M_=null,this.networkEnabled=!1,this.isPrimary=!1,this.O_=!1,this.x_=i,this.x_.B_(function(t){n.uo(function(){return y(p,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.q_()?(Hs("RemoteStore","Restarting streams for network reachability change."),[4,this.U_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Q_=new Gc(n,r),this.W_=(h=this.T_,c=n,f={e_:this.j_.bind(this),Yc:this.K_.bind(this),i_:this.G_.bind(this)},l=tu(h),new Mc(c,l.Mc,l.credentials,l.serializer,f)),this.z_=(o=this.T_,s=n,u={e_:this.H_.bind(this),Yc:this.Y_.bind(this),c_:this.J_.bind(this),u_:this.u_.bind(this)},a=tu(o),new qc(s,a.Mc,a.credentials,a.serializer,u))}function Kc(t,e){this.Aa=t,this.g_=e,this.state="Unknown",this.p_=0,this.y_=null,this.b_=!0}function Yc(t){this.T_=t,this.E_=ys(),this.mutations=[],this.I_=!1,this.w_=null,this.R_=new Set}function Qc(t,e,n){var r=this;return(r=Vc.call(this)||this).Mc=t,r.credentials=e,r.serializer=n,r}function Hc(t,e,n,r,i){var o=this;return(o=Cc.call(this,t,"write_stream_connection_backoff","write_stream_idle",e,n,i)||this).serializer=r,o.h_=!1,o.lastStreamToken=ei.ht,o}function $c(t,e,n,r,i){var o=this;return(o=Uc.call(this,t,"listen_stream_connection_backoff","listen_stream_idle",e,n,i)||this).serializer=r,o}function Xc(t,e,n,r,i,o){this.Tr=t,this.Lc=n,this.Mc=r,this.Oc=i,this.listener=o,this.state=0,this.xc=0,this.Bc=null,this.stream=null,this.$a=new Du(t,e)}function Jc(t,e){return"firestore_clients_"+t+"_"+e}function Zc(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.t()&&(r+="_"+e.uid),r}function tf(t,e){return"firestore_targets_"+t+"_"+e}function ef(t){this.key=t}function nf(t){this.key=t}function rf(t,e,n){this.query=t,this.targetId=e,this.view=n}function of(t){this.key=t,this.qd=!1}function sf(){this.gf=void 0,this.pf=[]}var uf,af,hf=(qf.gl=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 kr(r.error.code,r.error.message)),i?new qf(t,e,r.state,o):($s("SharedClientState","Failed to parse mutation state for ID '"+e+"': "+n),null)},qf.prototype.pl=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)},qf),cf=(Mf.gl=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 kr(n.error.code,n.error.message)),r?new Mf(t,n.state,i):($s("SharedClientState","Failed to parse target state for ID '"+t+"': "+e),null)},Mf.prototype.pl=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)},Mf),ff=(jf.gl=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=ws(),o=0;r&&o<n.activeTargetIds.length;++o)r=oi(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new jf(t,i):($s("SharedClientState","Failed to parse client data for instance '"+t+"': "+e),null)},jf),lf=(Uf.gl=function(t){var e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new Uf(e.clientId,e.onlineState):($s("SharedClientState","Failed to parse online state: "+t),null)},Uf),pf=(Cf.prototype.yl=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},Cf.prototype.bl=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},Cf.prototype.pl=function(){var t={activeTargetIds:this.activeTargetIds.W(),updateTimeMs:Date.now()};return JSON.stringify(t)},Cf),df=(Vf.Gh=function(t){return!(!t.window||null==t.window.localStorage)},Vf.prototype.start=function(){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h,c,f,l=this;return v(this,function(t){switch(t.label){case 0:return[4,this.ol.bo()];case 1:for(e=t.sent(),n=0,r=e;n<r.length;n++)(i=r[n])!==this.vl&&(o=this.getItem(Jc(this.persistenceKey,i)))&&(s=ff.gl(i,o))&&(this.Cl=this.Cl.Ae(s.clientId,s));for(this.xl(),(u=this.storage.getItem(this.Ol))&&(a=this.Bl(u))&&this.ql(a),h=0,c=this.Fl;h<c.length;h++)f=c[h],this.Dl(f);return this.Fl=[],this.platform.window.addEventListener("unload",function(){return l.mo()}),this.ro=!0,[2]}})})},Vf.prototype.lr=function(t){this.setItem(this.$l,JSON.stringify(t))},Vf.prototype.Ul=function(){return this.Ql(this.Cl)},Vf.prototype.Wl=function(n){var r=!1;return this.Cl.forEach(function(t,e){e.activeTargetIds.has(n)&&(r=!0)}),r},Vf.prototype.jl=function(t){this.Kl(t,"pending")},Vf.prototype.Gl=function(t,e,n){this.Kl(t,e,n),this.zl(t)},Vf.prototype.Hl=function(t){var e="not-current";if(this.Wl(t)){var n=this.storage.getItem(tf(this.persistenceKey,t));if(n){var r=cf.gl(t,n);r&&(e=r.state)}}return this.Yl.yl(t),this.xl(),e},Vf.prototype.Jl=function(t){this.Yl.bl(t),this.xl()},Vf.prototype.Xl=function(t){return this.Yl.activeTargetIds.has(t)},Vf.prototype.Zl=function(t){this.removeItem(tf(this.persistenceKey,t))},Vf.prototype.td=function(t,e,n){this.ed(t,e,n)},Vf.prototype.Du=function(t,e,n){var r=this;e.forEach(function(t){r.zl(t)}),this.currentUser=t,n.forEach(function(t){r.jl(t)})},Vf.prototype.sd=function(t){this.nd(t)},Vf.prototype.mo=function(){this.ro&&(this.platform.window.removeEventListener("storage",this.Sl),this.removeItem(this.Nl),this.ro=!1)},Vf.prototype.getItem=function(t){var e=this.storage.getItem(t);return Hs("SharedClientState","READ",t,e),e},Vf.prototype.setItem=function(t,e){Hs("SharedClientState","SET",t,e),this.storage.setItem(t,e)},Vf.prototype.removeItem=function(t){Hs("SharedClientState","REMOVE",t),this.storage.removeItem(t)},Vf.prototype.Dl=function(u){var t=this;if(u.storageArea===this.storage){if(Hs("SharedClientState","EVENT",u.key,u.newValue),u.key===this.Nl)return void $s("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Tr.Ua(function(){return y(t,void 0,void 0,function(){var e,n,r,i,o,s;return v(this,function(t){if(this.ro){if(null!==u.key)if(this.kl.test(u.key)){if(null==u.newValue)return e=this.rd(u.key),[2,this.hd(e,null)];if(n=this.od(u.key,u.newValue))return[2,this.hd(n.clientId,n)]}else if(this.Ll.test(u.key)){if(null!==u.newValue&&(r=this.ad(u.key,u.newValue)))return[2,this.ud(r)]}else if(this.Ml.test(u.key)){if(null!==u.newValue&&(i=this._d(u.key,u.newValue)))return[2,this.ld(i)]}else if(u.key===this.Ol){if(null!==u.newValue&&(o=this.Bl(u.newValue)))return[2,this.ql(o)]}else u.key===this.$l&&(s=function(t){var e=gu.dr;if(null!=t)try{var n=JSON.parse(t);Zs("number"==typeof n),e=n}catch(t){$s("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(u.newValue))!==gu.dr&&this.ur(s)}else this.Fl.push(u);return[2]})})})}},Object.defineProperty(Vf.prototype,"Yl",{get:function(){return this.Cl.get(this.vl)},enumerable:!0,configurable:!0}),Vf.prototype.xl=function(){this.setItem(this.Nl,this.Yl.pl())},Vf.prototype.Kl=function(t,e,n){var r=new hf(this.currentUser,t,e,n),i=Zc(this.persistenceKey,this.currentUser,t);this.setItem(i,r.pl())},Vf.prototype.zl=function(t){var e=Zc(this.persistenceKey,this.currentUser,t);this.removeItem(e)},Vf.prototype.nd=function(t){var e={clientId:this.vl,onlineState:t};this.storage.setItem(this.Ol,JSON.stringify(e))},Vf.prototype.ed=function(t,e,n){var r=tf(this.persistenceKey,t),i=new cf(t,e,n);this.setItem(r,i.pl())},Vf.prototype.rd=function(t){var e=this.kl.exec(t);return e?e[1]:null},Vf.prototype.od=function(t,e){var n=this.rd(t);return ff.gl(n,e)},Vf.prototype.ad=function(t,e){var n=this.Ll.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return hf.gl(new Tr(i),r,e)},Vf.prototype._d=function(t,e){var n=this.Ml.exec(t),r=Number(n[1]);return cf.gl(r,e)},Vf.prototype.Bl=function(t){return lf.gl(t)},Vf.prototype.ud=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return e.user.uid===this.currentUser.uid?[2,this.ol.dd(e.batchId,e.state,e.error)]:(Hs("SharedClientState","Ignoring mutation for non-active user "+e.user.uid),[2])})})},Vf.prototype.ld=function(t){return this.ol.fd(t.targetId,t.state,t.error)},Vf.prototype.hd=function(t,e){var n=this,r=e?this.Cl.Ae(t,e):this.Cl.remove(t),i=this.Ql(this.Cl),o=this.Ql(r),s=[],u=[];return o.forEach(function(t){i.has(t)||s.push(t)}),i.forEach(function(t){o.has(t)||u.push(t)}),this.ol.Td(s,u).then(function(){n.Cl=r})},Vf.prototype.ql=function(t){this.Cl.get(t.clientId)&&this.g_(t.onlineState)},Vf.prototype.Ql=function(t){var n=ws();return t.forEach(function(t,e){n=n.He(e.activeTargetIds)}),n},Vf),yf=(Lf.prototype.jl=function(t){},Lf.prototype.Gl=function(t,e,n){},Lf.prototype.Hl=function(t){return this.Ed.yl(t),this.Id[t]||"not-current"},Lf.prototype.td=function(t,e,n){this.Id[t]=e},Lf.prototype.Jl=function(t){this.Ed.bl(t)},Lf.prototype.Xl=function(t){return this.Ed.activeTargetIds.has(t)},Lf.prototype.Zl=function(t){delete this.Id[t]},Lf.prototype.Ul=function(){return this.Ed.activeTargetIds},Lf.prototype.Wl=function(t){return this.Ed.activeTargetIds.has(t)},Lf.prototype.start=function(){return this.Ed=new pf,Promise.resolve()},Lf.prototype.Du=function(t,e,n){},Lf.prototype.sd=function(t){},Lf.prototype.mo=function(){},Lf.prototype.lr=function(t){},Lf),vf=(Object.defineProperty(Pf.prototype,"Pd",{get:function(){return this.wd},enumerable:!0,configurable:!0}),Pf.prototype.Vd=function(t,e){var u=this,a=e?e.gd:new Ns,h=e?e.md:this.md,c=e?e.ns:this.ns,f=h,l=!1,p=this.query.oe()&&h.size===this.query.limit?h.last():null,d=this.query.ae()&&h.size===this.query.limit?h.first():null;if(t.pe(function(t,e){var n=h.get(t),r=e instanceof To?e:null;r=r&&(u.query.matches(r)?r:null);var i=!!n&&u.ns.has(n.key),o=!!r&&(r.At||u.ns.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.pd(n,r)||(a.track({type:2,doc:r}),s=!0,(p&&0<u.query.se(r,p)||d&&u.query.se(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.oe()||this.query.ae())for(;f.size>this.query.limit;){var n=this.query.oe()?f.last():f.first();f=f.delete(n.key),c=c.delete(n.key),a.track({type:1,doc:n})}return{md:f,gd:a,yd:l,ns:c}},Pf.prototype.pd=function(t,e){return t.At&&e.hasCommittedMutations&&!e.At},Pf.prototype.xn=function(t,e,n){var o=this,r=this.md;this.md=t.md,this.ns=t.ns;var i=t.gd.es();i.sort(function(t,e){return r=t.type,i=e.type,n(r)-n(i)||o.query.se(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 Js()}}var r,i}),this.bd(n);var s=e?this.vd():[],u=0===this.Ad.size&&this.fs?1:0,a=u!==this.Rd;return this.Rd=u,0!==i.length||a?{snapshot:new As(this.query,t.md,r,i,t.ns,0==u,a,!1),Sd:s}:{Sd:s}},Pf.prototype.Dd=function(t){return this.fs&&"Offline"===t?(this.fs=!1,this.xn({md:this.md,gd:new Ns,ns:this.ns,yd:!1},!1)):{Sd:[]}},Pf.prototype.Cd=function(t){return!this.wd.has(t)&&!!this.md.has(t)&&!this.md.get(t).At},Pf.prototype.bd=function(t){var e=this;t&&(t.Ts.forEach(function(t){return e.wd=e.wd.add(t)}),t.Es.forEach(function(t){}),t.Is.forEach(function(t){return e.wd=e.wd.delete(t)}),this.fs=t.fs)},Pf.prototype.vd=function(){var e=this;if(!this.fs)return[];var n=this.Ad;this.Ad=gs(),this.md.forEach(function(t){e.Cd(t.key)&&(e.Ad=e.Ad.add(t.key))});var r=[];return n.forEach(function(t){e.Ad.has(t)||r.push(new nf(t))}),this.Ad.forEach(function(t){n.has(t)||r.push(new ef(t))}),r},Pf.prototype.Fd=function(t){this.wd=t.Ku,this.Ad=gs();var e=this.Vd(t.documents);return this.xn(e,!0)},Pf.prototype.Nd=function(){return As.os(this.query,this.md,this.ns,0===this.Rd)},Pf),gf=(Rf.prototype.Ld=function(){this.Md()},Rf.prototype.Md=function(){var t=this;this.$a.gr(function(){return y(t,void 0,void 0,function(){var e,n,r=this;return v(this,function(t){return e=this.$d.ml(),(n=this.Od(e))&&n.then(function(t){r.Aa.uo(function(){return e.commit().then(function(){r.Va.resolve(t)}).catch(function(t){r.xd(t)})})}).catch(function(t){r.xd(t)}),[2]})})})},Rf.prototype.Od=function(t){try{var e=this.updateFunction(t);return!ri(e)&&e.catch&&e.then?e:(this.Va.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Va.reject(t),null}},Rf.prototype.xd=function(t){var e=this;0<this.kd&&this.Bd(t)?(--this.kd,this.Aa.uo(function(){return e.Md(),Promise.resolve()})):this.Va.reject(t)},Rf.prototype.Bd=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!$o(e)},Rf),mf=(Object.defineProperty(Of.prototype,"tf",{get:function(){return!0},enumerable:!0,configurable:!0}),Of.prototype.subscribe=function(t){this.Wd=t},Of.prototype.listen=function(s){return y(this,void 0,void 0,function(){var e,n,r,i,o;return v(this,function(t){switch(t.label){case 0:return this.ef("listen()"),(r=this.jd.get(s))?(e=r.targetId,this.Ud.Hl(e),n=r.view.Nd(),[3,4]):[3,1];case 1:return[4,this.N_.Qu(s.ee())];case 2:return i=t.sent(),o=this.Ud.Hl(i.targetId),e=i.targetId,[4,this.sf(s,e,"current"===o)];case 3:n=t.sent(),this.tf&&this.$d.listen(i),t.label=4;case 4:return[2,n]}})})},Of.prototype.sf=function(u,a,h){return y(this,void 0,void 0,function(){var e,n,r,i,o,s;return v(this,function(t){switch(t.label){case 0:return[4,this.N_.ju(u,!0)];case 1:return e=t.sent(),n=new vf(u,e.Ku),r=n.Vd(e.documents),i=Ss.ds(a,h&&"Offline"!==this.onlineState),o=n.xn(r,this.tf,i),this.if(a,o.Sd),s=new rf(u,a,n),[2,(this.jd.set(u,s),this.Kd.has(a)?this.Kd.get(a).push(u):this.Kd.set(a,[u]),o.snapshot)]}})})},Of.prototype.rl=function(i){return y(this,void 0,void 0,function(){var e,n,r=this;return v(this,function(t){switch(t.label){case 0:return this.ef("unlisten()"),e=this.jd.get(i),1<(n=this.Kd.get(e.targetId)).length?[2,(this.Kd.set(e.targetId,n.filter(function(t){return!t.isEqual(i)})),void this.jd.delete(i))]:this.tf?(this.Ud.Jl(e.targetId),this.Ud.Wl(e.targetId)?[3,2]:[4,this.N_.Wu(e.targetId,!1).then(function(){r.Ud.Zl(e.targetId),r.$d.rl(e.targetId),r.nf(e.targetId)}).catch(Nh)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.nf(e.targetId),[4,this.N_.Wu(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},Of.prototype.write=function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return v(this,function(t){switch(t.label){case 0:this.ef("write()"),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.N_.$u(i)];case 2:return e=t.sent(),this.Ud.jl(e.batchId),this.rf(e.batchId,o),[4,this.hf(e.Dn)];case 3:return t.sent(),[4,this.$d.el()];case 4:return t.sent(),[3,6];case 5:return n=t.sent(),r=ah(n,"Failed to persist write"),o.reject(r),[3,6];case 6:return[2]}})})},Of.prototype.runTransaction=function(t,e,n){new gf(t,this.$d,e,n).Ld()},Of.prototype.Mu=function(n){return y(this,void 0,void 0,function(){var e,r=this;return v(this,function(t){switch(t.label){case 0:this.ef("applyRemoteEvent()"),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.N_.Mu(n)];case 2:return e=t.sent(),n.as.forEach(function(t,e){var n=r.Hd.get(e);n&&(Zs(t.Ts.size+t.Es.size+t.Is.size<=1),0<t.Ts.size?n.qd=!0:0<t.Es.size?Zs(n.qd):0<t.Is.size&&(Zs(n.qd),n.qd=!1))}),[4,this.hf(e,n)];case 3:return t.sent(),[3,6];case 4:return[4,Nh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Of.prototype.Dd=function(r,t){this.ef("applyOnlineStateChange()");var i=[];this.jd.forEach(function(t,e){var n=e.view.Dd(r);n.snapshot&&i.push(n.snapshot)}),this.Wd.af(r),this.Wd.i_(i),this.onlineState=r},Of.prototype._l=function(u,a){return y(this,void 0,void 0,function(){var e,n,r,i,o,s=this;return v(this,function(t){switch(t.label){case 0:return this.ef("rejectListens()"),this.Ud.td(u,"rejected",a),e=this.Hd.get(u),(n=e&&e.key)?(r=(r=new Jo($r.N)).Ae(n,new Io(n,Lr.min())),i=gs().add(n),o=new _s(Lr.min(),new Map,new os(ru),r,i),[4,this.Mu(o)]):[3,2];case 1:return t.sent(),this.zd=this.zd.remove(n),this.Hd.delete(u),this.uf(),[3,4];case 2:return[4,this.N_.Wu(u,!1).then(function(){return s.nf(u,a)}).catch(Nh)];case 3:t.sent(),t.label=4;case 4:return[2]}})})},Of.prototype.Il=function(r){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:this.ef("applySuccessfulWrite()"),e=r.batch.batchId,this.cf(e,null),this._f(e),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.N_.zo(r)];case 2:return n=t.sent(),this.Ud.Gl(e,"acknowledged"),[4,this.hf(n)];case 3:return t.sent(),[3,6];case 4:return[4,Nh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Of.prototype.Al=function(n,r){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:this.ef("rejectFailedWrite()"),this.cf(n,r),this._f(n),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.N_.Lu(n)];case 2:return e=t.sent(),this.Ud.Gl(n,"rejected",r),[4,this.hf(e)];case 3:return t.sent(),[3,6];case 4:return[4,Nh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Of.prototype.lf=function(o){return y(this,void 0,void 0,function(){var e,n,r,i;return v(this,function(t){switch(t.label){case 0:this.$d.q_()||Hs("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.N_.sa()];case 2:return-1===(e=t.sent())?[2,void o.resolve()]:((n=this.Xd.get(e)||[]).push(o),this.Xd.set(e,n),[3,4]);case 3:return r=t.sent(),i=ah(r,"Initialization of waitForPendingWrites() operation failed"),o.reject(i),[3,4];case 4:return[2]}})})},Of.prototype._f=function(t){(this.Xd.get(t)||[]).forEach(function(t){t.resolve()}),this.Xd.delete(t)},Of.prototype.df=function(e){this.Xd.forEach(function(t){t.forEach(function(t){t.reject(new kr(Sr.CANCELLED,e))})}),this.Xd.clear()},Of.prototype.rf=function(t,e){var n=this.Jd[this.currentUser.s()];n=(n=n||new Jo(ru)).Ae(t,e),this.Jd[this.currentUser.s()]=n},Of.prototype.cf=function(t,e){var n=this.Jd[this.currentUser.s()];if(n){var r=n.get(t);r&&(e?r.reject(e):r.resolve(),n=n.remove(t)),this.Jd[this.currentUser.s()]=n}},Of.prototype.nf=function(t,e){var n=this;void 0===e&&(e=null),this.Ud.Jl(t);for(var r=0,i=this.Kd.get(t);r<i.length;r++){var o=i[r];this.jd.delete(o),e&&this.Wd.ff(o,e)}this.Kd.delete(t),this.tf&&this.Yd.nc(t).forEach(function(t){n.Yd.Ch(t)||n.Tf(t)})},Of.prototype.Tf=function(t){var e=this.zd.get(t);null!==e&&(this.$d.rl(e),this.zd=this.zd.remove(t),this.Hd.delete(e),this.uf())},Of.prototype.if=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof ef?(this.Yd.yh(i.key,t),this.Ef(i)):i instanceof nf?(Hs("SyncEngine","Document no longer in limbo: "+i.key),this.Yd.vh(i.key,t),this.Yd.Ch(i.key)||this.Tf(i.key)):Js()}},Of.prototype.Ef=function(t){var e=t.key;this.zd.get(e)||(Hs("SyncEngine","New document in limbo: "+e),this.Gd.push(e),this.uf())},Of.prototype.uf=function(){for(;0<this.Gd.length&&this.zd.size<this.Qd;){var t=this.Gd.shift(),e=this.Zd.next();this.Hd.set(e,new of(t)),this.zd=this.zd.Ae(t,e),this.$d.listen(new Vo(_o.Wt(t.path).ee(),e,2,gu.dr))}},Of.prototype.If=function(){return this.zd},Of.prototype.wf=function(){return this.Gd},Of.prototype.hf=function(r,a){return y(this,void 0,void 0,function(){var o,s,e,u=this;return v(this,function(t){switch(t.label){case 0:return o=[],s=[],e=[],this.jd.forEach(function(t,i){e.push(Promise.resolve().then(function(){var n=i.view.Vd(r);return n.yd?u.N_.ju(i.query,!1).then(function(t){var e=t.documents;return i.view.Vd(e,n)}):n}).then(function(t){var e=a&&a.as.get(i.targetId),n=i.view.xn(t,u.tf,e);if(u.if(i.targetId,n.Sd),n.snapshot){u.tf&&u.Ud.td(i.targetId,n.snapshot.fromCache?"not-current":"current"),o.push(n.snapshot);var r=vu.ar(i.targetId,n.snapshot);s.push(r)}}))}),[4,Promise.all(e)];case 1:return t.sent(),this.Wd.i_(o),[4,this.N_.Bu(s)];case 2:return t.sent(),[2]}})})},Of.prototype.ef=function(t){},Of.prototype.Pl=function(n){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.currentUser.isEqual(n)?[3,3]:[4,this.N_.Du(n)];case 1:return e=t.sent(),this.currentUser=n,this.df("'waitForPendingWrites' promise is rejected due to a user change."),this.Ud.Du(n,e.Fu,e.Nu),[4,this.hf(e.Cu)];case 2:t.sent(),t.label=3;case 3:return[4,this.$d.Pl()];case 4:return t.sent(),[2]}})})},Of.prototype.enableNetwork=function(){return this.$d.enableNetwork()},Of.prototype.disableNetwork=function(){return this.$d.disableNetwork()},Of.prototype.ei=function(t){var e=this.Hd.get(t);if(e&&e.qd)return gs().add(e.key);var n=gs(),r=this.Kd.get(t);if(!r)return n;for(var i=0,o=r;i<o.length;i++){var s=o[i],u=this.jd.get(s);n=n.He(u.view.Pd)}return n},Of),wf=(n(xf,uf=mf),Object.defineProperty(xf.prototype,"tf",{get:function(){return!0===this.Rf},enumerable:!0,configurable:!0}),xf.prototype.enableNetwork=function(){return this.N_.ao(!0),uf.prototype.enableNetwork.call(this)},xf.prototype.disableNetwork=function(){return this.N_.ao(!1),uf.prototype.disableNetwork.call(this)},xf.prototype.Af=function(r){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return[4,this.N_.ju(r.query,!0)];case 1:return e=t.sent(),n=r.view.Fd(e),[2,(this.Rf&&this.if(r.targetId,n.Sd),n)]}})})},xf.prototype.Dd=function(t,e){this.tf&&0===e&&(uf.prototype.Dd.call(this,t,e),this.Ud.sd(t)),this.tf||1!==e||uf.prototype.Dd.call(this,t,e)},xf.prototype.dd=function(n,r,i){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.ef("applyBatchState()"),[4,this.N_.zu(n)];case 1:return null===(e=t.sent())?[3,6]:"pending"!==r?[3,3]:[4,this.$d.el()];case 2:return t.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(this.cf(n,i||null),this.N_.Hu(n)):Js(),t.label=4;case 4:return[4,this.hf(e)];case 5:return t.sent(),[3,7];case 6:Hs("SyncEngine","Cannot apply mutation batch with id: "+n),t.label=7;case 7:return[2]}})})},xf.prototype.Vl=function(h){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a=this;return v(this,function(t){switch(t.label){case 0:return!0!==h||!0===this.Rf?[3,3]:(e=this.Ud.Ul(),[4,this.mf(e.W(),!0)]);case 1:return n=t.sent(),this.Rf=!0,[4,this.$d.Vl(!0)];case 2:for(t.sent(),r=0,i=n;r<i.length;r++)o=i[r],this.$d.listen(o);return[3,7];case 3:return!1!==h||!1===this.Rf?[3,7]:(s=[],u=Promise.resolve(),this.Kd.forEach(function(t,e){a.Ud.Xl(e)?s.push(e):u=u.then(function(){return a.nf(e),a.N_.Wu(e,!0)}),a.$d.rl(e)}),[4,u]);case 4:return t.sent(),[4,this.mf(s,!1)];case 5:return t.sent(),this.Pf(),this.Rf=!1,[4,this.$d.Vl(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},xf.prototype.Pf=function(){var n=this;this.Hd.forEach(function(t,e){n.$d.rl(e)}),this.Yd.rc(),this.Hd=new Map,this.zd=new Jo($r.N)},xf.prototype.mf=function(d,t){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h,c,f,l,p;return v(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.Kd.get(o))&&0!==u.length?[4,this.N_.Wu(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.N_.Qu(u[0].ee())];case 3:s=t.sent(),a=0,h=u,t.label=4;case 4:return a<h.length?(c=h[a],f=this.jd.get(c),[4,this.Af(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.N_.Yu(o)];case 9:return p=t.sent(),[4,this.N_.Qu(p)];case 10:return s=t.sent(),[4,this.sf(this.Vf(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.Wd.i_(n),e)]}})})},xf.prototype.Vf=function(t){return new _o(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)},xf.prototype.bo=function(){return this.N_.bo()},xf.prototype.fd=function(r,i,o){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return this.Rf?(Hs("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!this.Kd.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.N_.Kr()];case 3:return e=t.sent(),n=_s.ls(r,"current"===i),[4,this.hf(e,n)];case 4:return t.sent(),[3,8];case 5:return[4,this.N_.Wu(r,!0)];case 6:return t.sent(),this.nf(r,o),[3,8];case 7:Js(),t.label=8;case 8:return[2]}})})},xf.prototype.Td=function(l,p){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,h,c,f=this;return v(this,function(t){switch(t.label){case 0:if(!this.Rf)return[3,10];e=0,n=l,t.label=1;case 1:return e<n.length?(r=n[e],this.Kd.has(r)?(Hs("SyncEngine","Adding an already active target "+r),[3,5]):[4,this.N_.Yu(r)]):[3,6];case 2:return i=t.sent(),[4,this.N_.Qu(i)];case 3:return o=t.sent(),[4,this.sf(this.Vf(i),o.targetId,!1)];case 4:t.sent(),this.$d.listen(o),t.label=5;case 5:return e++,[3,1];case 6:s=function(e){return v(this,function(t){switch(t.label){case 0:return u.Kd.has(e)?[4,u.N_.Wu(e,!1).then(function(){f.$d.rl(e),f.nf(e)}).catch(Nh)]:[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]}})})},xf),bf=(Df.prototype.listen=function(u){return y(this,void 0,void 0,function(){var e,n,r,i,o,s;return v(this,function(t){switch(t.label){case 0:if(e=u.query,n=!1,(r=this.yf.get(e))||(n=!0,r=new sf),!n)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),i=r,[4,this.ol.listen(e)];case 2:return i.gf=t.sent(),[3,4];case 3:return o=t.sent(),s=ah(o,"Initialization of query '"+u.query+"' failed"),[2,void u.onError(s)];case 4:return this.yf.set(e,r),r.pf.push(u),u.Dd(this.onlineState),r.gf&&u.vf(r.gf)&&this.Sf(),[2]}})})},Df.prototype.rl=function(o){return y(this,void 0,void 0,function(){var e,n,r,i;return v(this,function(t){return e=o.query,n=!1,(r=this.yf.get(e))&&0<=(i=r.pf.indexOf(o))&&(r.pf.splice(i,1),n=0===r.pf.length),n?[2,(this.yf.delete(e),this.ol.rl(e))]:[2]})})},Df.prototype.i_=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,s=this.yf.get(o);if(s){for(var u=0,a=s.pf;u<a.length;u++)a[u].vf(i)&&(e=!0);s.gf=i}}e&&this.Sf()},Df.prototype.ff=function(t,e){var n=this.yf.get(t);if(n)for(var r=0,i=n.pf;r<i.length;r++)i[r].onError(e);this.yf.delete(t)},Df.prototype.af=function(i){this.onlineState=i;var o=!1;this.yf.forEach(function(t,e){for(var n=0,r=e.pf;n<r.length;n++)r[n].Dd(i)&&(o=!0)}),o&&this.Sf()},Df.prototype.Df=function(t){this.bf.add(t),t.next()},Df.prototype.Cf=function(t){this.bf.delete(t)},Df.prototype.Sf=function(){this.bf.forEach(function(t){t.next()})},Df),Ef=(kf.prototype.vf=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 As(t.query,t.docs,t.ss,e,t.ns,t.fromCache,t.rs,!0)}var o=!1;return this.Nf?this.kf(t)&&(this.Ff.next(t),o=!0):this.Lf(t,this.onlineState)&&(this.Mf(t),o=!0),this.$f=t,o},kf.prototype.onError=function(t){this.Ff.error(t)},kf.prototype.Dd=function(t){this.onlineState=t;var e=!1;return this.$f&&!this.Nf&&this.Lf(this.$f,t)&&(this.Mf(this.$f),e=!0),e},kf.prototype.Lf=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.Of&&n||t.docs.B()&&"Offline"!==e)},kf.prototype.kf=function(t){if(0<t.docChanges.length)return!0;var e=this.$f&&this.$f.hasPendingWrites!==t.hasPendingWrites;return!(!t.rs&&!e)&&!0===this.options.includeMetadataChanges},kf.prototype.Mf=function(t){t=As.os(t.query,t.docs,t.ns,t.fromCache),this.Nf=!0,this.Ff.next(t)},kf),Tf=(Sf.prototype.Su=function(t){this.xf=t},Sf.prototype.Zn=function(e,r,i,o){var s=this;return r.te()||i.isEqual(Lr.min())?this.Bf(e,r):this.xf.Yn(e,o).next(function(t){var n=s.qf(r,t);return(r.oe()||r.ae())&&s.yd(r.Bt,n,o,i)?s.Bf(e,r):(Ys()<=l.DEBUG&&Hs("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),s.xf.Zn(e,r,i).next(function(e){return n.forEach(function(t){e=e.Ae(t.key,t)}),e}))})},Sf.prototype.qf=function(n,t){var r=new os(function(t,e){return n.se(t,e)});return t.forEach(function(t,e){e instanceof To&&n.matches(e)&&(r=r.add(e))}),r},Sf.prototype.yd=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.S(r))},Sf.prototype.Bf=function(t,e){return Ys()<=l.DEBUG&&Hs("IndexFreeQueryEngine","Using full collection scan to execute query:",e.toString()),this.xf.Zn(t,e,Lr.min())},Sf),If=(_f.prototype.Go=function(t){return fu.resolve(0===this.Wn.length)},_f.prototype.zo=function(t,e,n){var r=e.batchId,i=this.Wf(r,"acknowledged");return Zs(0===i),this.Wn[i],this.lastStreamToken=n,fu.resolve()},_f.prototype.Yo=function(t){return fu.resolve(this.lastStreamToken)},_f.prototype.Jo=function(t,e){return this.lastStreamToken=e,fu.resolve()},_f.prototype.Xo=function(t,e,n,r){var i=this.Uf;this.Uf++,0<this.Wn.length&&this.Wn[this.Wn.length-1];var o=new hu(i,e,n,r);this.Wn.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.Qf=this.Qf.add(new _h(a.key,i)),this.jn.Dr(t,a.key.path.L())}return fu.resolve(o)},_f.prototype.Zo=function(t,e){return fu.resolve(this.jf(e))},_f.prototype.ea=function(t,e){var n=e+1,r=this.Kf(n),i=r<0?0:r;return fu.resolve(this.Wn.length>i?this.Wn[i]:null)},_f.prototype.sa=function(){return fu.resolve(0===this.Wn.length?-1:this.Uf-1)},_f.prototype.ia=function(t){return fu.resolve(this.Wn.slice())},_f.prototype.Gn=function(t,e){var n=this,r=new _h(e,0),i=new _h(e,Number.POSITIVE_INFINITY),o=[];return this.Qf.Ke([r,i],function(t){var e=n.jf(t.oc);o.push(e)}),fu.resolve(o)},_f.prototype.Xn=function(t,e){var r=this,i=new os(ru);return e.forEach(function(t){var e=new _h(t,0),n=new _h(t,Number.POSITIVE_INFINITY);r.Qf.Ke([e,n],function(t){i=i.add(t.oc)})}),fu.resolve(this.Gf(i))},_f.prototype.nr=function(t,e){var n=e.path,r=n.length+1,i=n;$r.et(i)||(i=i.child(""));var o=new _h(new $r(i),0),s=new os(ru);return this.Qf.Ge(function(t){var e=t.key.path;return!!n.q(e)&&(e.length===r&&(s=s.add(t.oc)),!0)},o),fu.resolve(this.Gf(s))},_f.prototype.Gf=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.jf(t);null!==e&&r.push(e)}),r},_f.prototype.ra=function(n,r){var i=this;Zs(0===this.Wf(r.batchId,"removed")),this.Wn.shift();var o=this.Qf;return fu.forEach(r.mutations,function(t){var e=new _h(t.key,r.batchId);return o=o.delete(e),i.hh.Bo(n,t.key)}).next(function(){i.Qf=o})},_f.prototype.ha=function(t){},_f.prototype.Ch=function(t,e){var n=new _h(e,0),r=this.Qf.ze(n);return fu.resolve(e.isEqual(r&&r.key))},_f.prototype.oa=function(t){return this.Wn.length,fu.resolve()},_f.prototype.Wf=function(t,e){return this.Kf(t)},_f.prototype.Kf=function(t){return 0===this.Wn.length?0:t-this.Wn[0].batchId},_f.prototype.jf=function(t){var e=this.Kf(t);return e<0||e>=this.Wn.length?null:this.Wn[e]},_f),Nf=(Af.prototype.Nn=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.Ae(r,{Mr:e,size:s,readTime:n}),this.size+=s-o,this.jn.Dr(t,r.path.L())},Af.prototype.kn=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Af.prototype.Ln=function(t,e){var n=this.docs.get(e);return fu.resolve(n?n.Mr:null)},Af.prototype.getEntries=function(t,e){var n=this,r=fs();return e.forEach(function(t){var e=n.docs.get(t);r=r.Ae(t,e?e.Mr:null)}),fu.resolve(r)},Af.prototype.Zn=function(t,e,n){for(var r=ps(),i=new $r(e.path.child("")),o=this.docs.ve(i);o.$e();){var s=o.Ne(),u=s.key,a=s.value,h=a.Mr,c=a.readTime;if(!e.path.q(u.path))break;c.S(n)<=0||h instanceof To&&e.matches(h)&&(r=r.Ae(h.key,h))}return fu.resolve(r)},Af.prototype.Hf=function(t,e){return fu.forEach(this.docs,function(t){return e(t)})},Af.prototype.Yr=function(t){return new Af.Jr(this)},Af.prototype.Zr=function(t){return fu.resolve(this.size)},Af);function Af(t,e){this.jn=t,this.zf=e,this.docs=new Jo($r.N),this.size=0}function _f(t,e){this.jn=t,this.hh=e,this.Wn=[],this.Uf=1,this.lastStreamToken=ei.ht,this.Qf=new os(_h.Xu)}function Sf(){}function kf(t,e,n){this.query=t,this.Ff=e,this.Nf=!1,this.$f=null,this.onlineState="Unknown",this.options=n||{}}function Df(t){this.ol=t,this.yf=new au(function(t){return t.canonicalId()}),this.onlineState="Unknown",this.bf=new Set,this.ol.subscribe(this)}function xf(t,e,n,r,i){var o=this;return(o=uf.call(this,t,e,n,r,i)||this).N_=t,o.Rf=void 0,o}function Of(t,e,n,r,i){this.N_=t,this.$d=e,this.Ud=n,this.currentUser=r,this.Qd=i,this.Wd=null,this.jd=new au(function(t){return t.canonicalId()}),this.Kd=new Map,this.Gd=[],this.zd=new Jo($r.N),this.Hd=new Map,this.Yd=new Ah,this.Jd={},this.Xd=new Map,this.Zd=$u.rh(),this.onlineState="Unknown"}function Rf(t,e,n,r){this.Aa=t,this.$d=e,this.updateFunction=n,this.Va=r,this.kd=5,this.$a=new Du(this.Aa,"transaction_retry")}function Pf(t,e){this.query=t,this.wd=e,this.Rd=null,this.fs=!1,this.Ad=gs(),this.ns=gs(),this.md=new Is(t.se.bind(t))}function Lf(){this.Ed=new pf,this.Id={},this.ol=null,this.g_=null,this.ur=null}function Vf(t,e,n,r,i){if(this.Tr=t,this.platform=e,this.persistenceKey=n,this.vl=r,this.ol=null,this.g_=null,this.ur=null,this.Sl=this.Dl.bind(this),this.Cl=new Jo(ru),this.ro=!1,this.Fl=[],!Vf.Gh(this.platform))throw new kr(Sr.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.Nl=Jc(this.persistenceKey,this.vl),this.$l="firestore_sequence_number_"+this.persistenceKey,this.Cl=this.Cl.Ae(this.vl,new pf),this.kl=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Ll=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.Ml=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Ol="firestore_online_state_"+this.persistenceKey,this.platform.window.addEventListener("storage",this.Sl)}function Cf(){this.activeTargetIds=ws()}function Uf(t,e){this.clientId=t,this.onlineState=e}function jf(t,e){this.clientId=t,this.activeTargetIds=e}function Mf(t,e,n){this.targetId=t,this.state=e,this.error=n}function qf(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}function Ff(t){var e=this;return(e=af.call(this)||this).th=t,e}Nf.Jr=(n(Ff,af=lu),Ff.prototype.xn=function(n){var r=this,i=[];return this.Dn.forEach(function(t,e){e?i.push(r.th.Nn(n,e,r.readTime)):r.th.kn(t)}),fu.vn(i)},Ff.prototype.Mn=function(t,e){return this.th.Ln(t,e)},Ff.prototype.On=function(t,e){return this.th.getEntries(t,e)},Ff);var Bf,Gf,zf=(ol.prototype.js=function(t,n){return this.Yf.forEach(function(t,e){return n(e)}),fu.resolve()},ol.prototype._h=function(t){return fu.resolve(this.lastRemoteSnapshotVersion)},ol.prototype.lh=function(t){return fu.resolve(this.Jf)},ol.prototype.oh=function(t){return this.highestTargetId=this.Zf.next(),fu.resolve(this.highestTargetId)},ol.prototype.dh=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Jf&&(this.Jf=e),fu.resolve()},ol.prototype.Th=function(t){this.Yf.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.Zf=new $u(e),this.highestTargetId=e),t.sequenceNumber>this.Jf&&(this.Jf=t.sequenceNumber)},ol.prototype.fh=function(t,e){return this.Th(e),this.targetCount+=1,fu.resolve()},ol.prototype.Ih=function(t,e){return this.Th(e),fu.resolve()},ol.prototype.wh=function(t,e){return this.Yf.delete(e.target),this.Xf.nc(e.targetId),--this.targetCount,fu.resolve()},ol.prototype.Ah=function(n,r,i){var o=this,s=0,u=[];return this.Yf.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.Yf.delete(t),u.push(o.Rh(n,e.targetId)),s++)}),fu.vn(u).next(function(){return s})},ol.prototype.Vh=function(t){return fu.resolve(this.targetCount)},ol.prototype.gh=function(t,e){var n=this.Yf.get(e)||null;return fu.resolve(n)},ol.prototype.ph=function(t,e,n){return this.Xf.ec(e,n),fu.resolve()},ol.prototype.bh=function(e,t,n){this.Xf.ic(t,n);var r=this.persistence.hh,i=[];return r&&t.forEach(function(t){i.push(r.Bo(e,t))}),fu.vn(i)},ol.prototype.Rh=function(t,e){return this.Xf.nc(e),fu.resolve()},ol.prototype.Sh=function(t,e){var n=this.Xf.hc(e);return fu.resolve(n)},ol.prototype.Ch=function(t,e){return fu.resolve(this.Xf.Ch(e))},ol),Wf=(il.prototype.start=function(){return Promise.resolve()},il.prototype.mo=function(){return this.qh=!1,Promise.resolve()},Object.defineProperty(il.prototype,"ro",{get:function(){return this.qh},enumerable:!0,configurable:!0}),il.prototype.ho=function(){},il.prototype.Fo=function(){return this.jn},il.prototype.vo=function(t){var e=this.tT[t.s()];return e||(e=new If(this.jn,this.hh),this.tT[t.s()]=e),e},il.prototype.Do=function(){return this.Yh},il.prototype.Co=function(){return this.Qn},il.prototype.runTransaction=function(t,e,n){var r=this;Hs("MemoryPersistence","Starting transaction:",t);var i=new Kf(this.Bh.next());return this.hh.sT(),n(i).next(function(t){return r.hh.iT(i).next(function(){return t})}).yn().then(function(t){return i.Un(),t})},il.prototype.nT=function(e,n){return fu.Sn(Object.values(this.tT).map(function(t){return function(){return t.Ch(e,n)}}))},il),Kf=(n(rl,Gf=du),rl),Yf=(nl.oT=function(t){return new nl(t)},Object.defineProperty(nl.prototype,"aT",{get:function(){if(this.hT)return this.hT;throw Js()},enumerable:!0,configurable:!0}),nl.prototype.yh=function(t,e,n){return this.rT.yh(n,e),this.aT.delete(n),fu.resolve()},nl.prototype.vh=function(t,e,n){return this.rT.vh(n,e),this.aT.add(n),fu.resolve()},nl.prototype.Bo=function(t,e){return this.aT.add(e),fu.resolve()},nl.prototype.removeTarget=function(t,e){var n=this;this.rT.nc(e.targetId).forEach(function(t){return n.aT.add(t)});var r=this.persistence.Do();return r.Sh(t,e.targetId).next(function(t){t.forEach(function(t){return n.aT.add(t)})}).next(function(){return r.wh(t,e)})},nl.prototype.sT=function(){this.hT=new Set},nl.prototype.iT=function(t){var n=this,r=this.persistence.Co().Yr();return fu.forEach(this.aT,function(e){return n.uT(t,e).next(function(t){t||r.kn(e)})}).next(function(){return n.hT=null,r.apply(t)})},nl.prototype.Wo=function(t,e){var n=this;return this.uT(t,e).next(function(t){t?n.aT.delete(e):n.aT.add(e)})},nl.prototype.eT=function(t){return 0},nl.prototype.uT=function(t,e){var n=this;return fu.Sn([function(){return fu.resolve(n.rT.Ch(e))},function(){return n.persistence.Do().Ch(t,e)},function(){return n.persistence.nT(t,e)}])},nl),Qf=(el.prototype.initialize=function(n){return y(this,void 0,void 0,function(){var e=this;return v(this,function(t){switch(t.label){case 0:return this.Ud=this.cT(n),this.persistence=this._T(n),[4,this.persistence.start()];case 1:return t.sent(),this.lT=this.dT(n),this.N_=this.fT(n),this.$d=this.TT(n),this.ol=this.ET(n),this.IT=this.wT(n),this.Ud.g_=function(t){return e.ol.Dd(t,1)},this.$d.ol=this.ol,[4,this.N_.start()];case 2:return t.sent(),[4,this.Ud.start()];case 3:return t.sent(),[4,this.$d.start()];case 4:return t.sent(),[4,this.$d.Vl(this.ol.tf)];case 5:return t.sent(),[2]}})})},el.prototype.wT=function(t){return new bf(this.ol)},el.prototype.dT=function(t){return null},el.prototype.fT=function(t){return new gh(this.persistence,new Tf,t.RT)},el.prototype._T=function(t){return new Wf(Yf.oT)},el.prototype.TT=function(t){var e=this;return new zc(this.N_,t.T_,t.Aa,function(t){return e.ol.Dd(t,0)},t.platform.AT())},el.prototype.cT=function(t){return new yf},el.prototype.ET=function(t){return new mf(this.N_,this.$d,this.Ud,t.RT,t.Qd)},el.prototype.clearPersistence=function(t){throw new kr(Sr.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.")},el),Hf=(n(tl,Bf=Qf),tl.prototype.initialize=function(e){return y(this,void 0,void 0,function(){var n=this;return v(this,function(t){switch(t.label){case 0:return[4,Bf.prototype.initialize.call(this,e)];case 1:return t.sent(),[4,this.persistence.no(function(e){return y(n,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return[4,this.ol.Vl(e)];case 1:return t.sent(),this.lT&&(e&&!this.lT.ro?this.lT.start(this.N_):e||this.lT.stop()),[2]}})})})];case 2:return t.sent(),[2]}})})},tl.prototype.fT=function(t){return new Th(this.persistence,new Tf,t.RT)},tl.prototype.ET=function(t){var e=new wf(this.N_,this.$d,this.Ud,t.RT,t.Qd);return this.Ud instanceof df&&(this.Ud.ol=e),e},tl.prototype.dT=function(t){var e=this.persistence.hh.ko;return new yh(e,t.Aa)},tl.prototype._T=function(t){var e=ua.$o(t.mT),n=t.platform.bc(t.mT.ii);return new ua(t.PT.synchronizeTabs,e,t.clientId,t.platform,lh.hu(t.PT.cacheSizeBytes),t.Aa,n,this.Ud)},tl.prototype.cT=function(t){if(t.PT.VT&&t.PT.synchronizeTabs){if(!df.Gh(t.platform))throw new kr(Sr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var e=ua.$o(t.mT);return new df(t.Aa,t.platform,e,t.clientId,t.RT)}return new yf},tl.prototype.clearPersistence=function(t){var e=ua.$o(t);return ua.clearPersistence(e)},tl),$f=(Zf.prototype.start=function(e,n){var r=this;this.gT();var i=new ku,o=new ku,s=!1;return this.credentials.l(function(t){if(!s)return s=!0,Hs("FirestoreClient","Initializing. user=",t.uid),r.pT(e,n,t,o).then(i.resolve,i.reject);r.Aa.Ua(function(){return r.Pl(t)})}),this.Aa.uo(function(){return i.promise}),o.promise},Zf.prototype.enableNetwork=function(){var t=this;return this.gT(),this.Aa.enqueue(function(){return t.ol.enableNetwork()})},Zf.prototype.pT=function(a,h,c,f){return y(this,void 0,void 0,function(){var r,i,o,s,u=this;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.platform.yT(this.mT)];case 1:return r=t.sent(),i=this.platform.bc(this.mT.ii),e=r,n=this.credentials,o=new Fc(e,n,i),[4,a.initialize({Aa:this.Aa,mT:this.mT,platform:this.platform,T_:o,clientId:this.clientId,RT:c,Qd:100,PT:h})];case 2:return t.sent(),this.persistence=a.persistence,this.Ud=a.Ud,this.N_=a.N_,this.$d=a.$d,this.ol=a.ol,this.lT=a.lT,this.bT=a.IT,this.persistence.ho(function(){return y(u,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})}),f.resolve(),[3,4];case 3:if(s=t.sent(),f.reject(s),!this.vT(s))throw s;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+s),this.pT(new Qf,{VT:!1},c,f))];case 4:return[2]}var e,n})})},Zf.prototype.vT=function(t){return"FirebaseError"===t.name?t.code===Sr.FAILED_PRECONDITION||t.code===Sr.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},Zf.prototype.gT=function(){if(this.Aa.La)throw new kr(Sr.FAILED_PRECONDITION,"The client has already been terminated.")},Zf.prototype.Pl=function(t){return this.Aa.Wa(),Hs("FirestoreClient","Credential Changed. Current user: "+t.uid),this.ol.Pl(t)},Zf.prototype.disableNetwork=function(){var t=this;return this.gT(),this.Aa.enqueue(function(){return t.ol.disableNetwork()})},Zf.prototype.terminate=function(){var t=this;return this.Aa.qa(function(){return y(t,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.lT&&this.lT.stop(),[4,this.$d.mo()];case 1:return t.sent(),[4,this.Ud.mo()];case 2:return t.sent(),[4,this.persistence.mo()];case 3:return t.sent(),this.credentials.T(),[2]}})})})},Zf.prototype.waitForPendingWrites=function(){var t=this;this.gT();var e=new ku;return this.Aa.uo(function(){return t.ol.lf(e)}),e.promise},Zf.prototype.listen=function(t,e,n){var r=this;this.gT();var i=new Ef(t,e,n);return this.Aa.uo(function(){return r.bT.listen(i)}),i},Zf.prototype.rl=function(t){var e=this;this.ST||this.Aa.uo(function(){return e.bT.rl(t)})},Zf.prototype.DT=function(o){return y(this,void 0,void 0,function(){var i,e=this;return v(this,function(t){switch(t.label){case 0:return this.gT(),i=new ku,[4,this.Aa.enqueue(function(){return y(e,void 0,void 0,function(){var e,n,r;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.N_.Uu(o)];case 1:return(e=t.sent())instanceof To?i.resolve(e):e instanceof Io?i.resolve(null):i.reject(new kr(Sr.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),[3,3];case 2:return n=t.sent(),r=ah(n,"Failed to get document '"+o+" from cache"),i.reject(r),[3,3];case 3:return[2]}})})})];case 1:return[2,(t.sent(),i.promise)]}})})},Zf.prototype.CT=function(a){return y(this,void 0,void 0,function(){var u,e=this;return v(this,function(t){switch(t.label){case 0:return this.gT(),u=new ku,[4,this.Aa.enqueue(function(){return y(e,void 0,void 0,function(){var e,n,r,i,o,s;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.N_.ju(a,!0)];case 1:return e=t.sent(),n=new vf(a,e.Ku),r=n.Vd(e.documents),i=n.xn(r,!1),u.resolve(i.snapshot),[3,3];case 2:return o=t.sent(),s=ah(o,"Failed to execute query '"+a+" against cache"),u.reject(s),[3,3];case 3:return[2]}})})})];case 1:return[2,(t.sent(),u.promise)]}})})},Zf.prototype.write=function(t){var e=this;this.gT();var n=new ku;return this.Aa.uo(function(){return e.ol.write(t,n)}),n.promise},Zf.prototype.ii=function(){return this.mT.ii},Zf.prototype.Df=function(t){var e=this;this.gT(),this.Aa.uo(function(){return e.bT.Df(t),Promise.resolve()})},Zf.prototype.Cf=function(t){var e=this;this.ST||this.Aa.uo(function(){return e.bT.Cf(t),Promise.resolve()})},Object.defineProperty(Zf.prototype,"ST",{get:function(){return this.Aa.La},enumerable:!0,configurable:!0}),Zf.prototype.transaction=function(t){var e=this;this.gT();var n=new ku;return this.Aa.uo(function(){return e.ol.runTransaction(e.Aa,t,n),Promise.resolve()}),n.promise},Zf),Xf=(Jf.prototype.next=function(t){this.FT(this.observer.next,t)},Jf.prototype.error=function(t){this.FT(this.observer.error,t)},Jf.prototype.NT=function(){this.muted=!0},Jf.prototype.FT=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},Jf);function Jf(t){this.observer=t,this.muted=!1}function Zf(t,e,n,r){this.platform=t,this.mT=e,this.credentials=n,this.Aa=r,this.clientId=eu.cn()}function tl(){return null!==Bf&&Bf.apply(this,arguments)||this}function el(){}function nl(t){this.persistence=t,this.rT=new Ah,this.hT=null}function rl(t){var e=this;return(e=Gf.call(this)||this).Oh=t,e}function il(t){var e=this;this.tT={},this.Bh=new gu(0),this.qh=!1,this.qh=!0,this.hh=t(this),this.Yh=new zf(this),this.jn=new Vu,this.Qn=new Nf(this.jn,function(t){return e.hh.eT(t)})}function ol(t){this.persistence=t,this.Yf=new au(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Lr.min(),this.highestTargetId=0,this.Jf=0,this.Xf=new Ah,this.targetCount=0,this.Zf=$u.nh()}function sl(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 ul,al,hl=(Pl.prototype.kT=function(t){switch(hi(t)){case 0:return null;case 1:return t.booleanValue;case 2:return vi(t.integerValue||t.doubleValue);case 3:return this.LT(t.timestampValue);case 4:return this.MT(t);case 5:return t.stringValue;case 6:return new Hh(gi(t.bytesValue));case 7:return this.OT(t.referenceValue);case 8:return this.xT(t.geoPointValue);case 9:return this.BT(t.arrayValue);case 10:return this.qT(t.mapValue);default:throw Js()}},Pl.prototype.qT=function(t){var n=this,r={};return Zr(t.fields||{},function(t,e){r[t]=n.kT(e)}),r},Pl.prototype.xT=function(t){return new fc(vi(t.latitude),vi(t.longitude))},Pl.prototype.BT=function(t){var e=this;return(t.values||[]).map(function(t){return e.kT(t)})},Pl.prototype.MT=function(t){switch(this.$T){case"previous":var e=function t(e){var n=e.mapValue.fields.__previous_value__;return si(n)?t(n):n}(t);return null==e?null:this.kT(e);case"estimate":return this.LT(ui(t));default:return null}},Pl.prototype.LT=function(t){var e=yi(t),n=new Pr(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},Pl.prototype.OT=function(t){var e=Cr.K(t);Zs(Gs(e));var n=new uu(e.get(1),e.get(3)),r=new $r(e.k(5));return n.isEqual(this.firestore.$c)||$s("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.$c.projectId+"/"+this.firestore.$c.database+") instead."),new yl(r,this.firestore,this.converter)},Pl),cl=lh.uu,fl=(Rl.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&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},Rl),ll=(Object.defineProperty(Ol.prototype,"JT",{get:function(){return this.XT||(this.XT=new Ac(this.$c,this.YT.ignoreUndefinedProperties)),this.XT},enumerable:!0,configurable:!0}),Ol.prototype.settings=function(t){xh("Firestore.settings",arguments,1),Ph("Firestore.settings","object",1,t);var e=new fl(t);if(this.jT&&!this.YT.isEqual(e))throw new kr(Sr.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.YT=e).credentials&&(this.zT=function(t){if(!t)return new Dr;switch(t.type){case"gapi":var e=t.ZT;return Zs(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Rr(e,t.V||"0");case"provider":return t.ZT;default:throw new kr(Sr.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},Ol.prototype.enableNetwork=function(){return this.WT(),this.jT.enableNetwork()},Ol.prototype.disableNetwork=function(){return this.WT(),this.jT.disableNetwork()},Ol.prototype.enablePersistence=function(t){var e,n;if(this.jT)throw new kr(Sr.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&&$s("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.tE(this.HT,{VT:!0,cacheSizeBytes:this.YT.cacheSizeBytes,synchronizeTabs:r})},Ol.prototype.clearPersistence=function(){return y(this,void 0,void 0,function(){var r,e=this;return v(this,function(t){if(void 0!==this.jT&&!this.jT.ST)throw new kr(Sr.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return r=new ku,[2,(this.QT.Ma(function(){return y(e,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=this.eE(),[4,this.HT.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)]})})},Ol.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(Ol.prototype,"sE",{get:function(){return this.WT(),this.jT.ST},enumerable:!0,configurable:!0}),Ol.prototype.waitForPendingWrites=function(){return this.WT(),this.jT.waitForPendingWrites()},Ol.prototype.onSnapshotsInSync=function(t){if(this.WT(),sl(t))return this.iE(t);Ph("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.iE(e)},Ol.prototype.iE=function(t){var e=this,n=new Xf({next:function(){t.next&&t.next()},error:function(t){throw Js()}});return this.jT.Df(n),function(){n.NT(),e.jT.Cf(n)}},Ol.prototype.WT=function(){return this.jT||this.tE(new Qf,{VT:!1}),this.jT},Ol.prototype.eE=function(){return new su(this.$c,this.GT,this.YT.host,this.YT.ssl,this.YT.forceLongPolling)},Ol.prototype.tE=function(t,e){var n=this.eE();return this.jT=new $f(zs.nt(),n,this.zT,this.QT),this.jT.start(t,e)},Ol.KT=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new kr(Sr.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new kr(Sr.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new uu(n)},Object.defineProperty(Ol.prototype,"app",{get:function(){if(!this.UT)throw new kr(Sr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.UT},enumerable:!0,configurable:!0}),Ol.prototype.collection=function(t){return xh("Firestore.collection",arguments,1),Ph("Firestore.collection","non-empty string",1,t),this.WT(),new El(Cr.K(t),this)},Ol.prototype.doc=function(t){return xh("Firestore.doc",arguments,1),Ph("Firestore.doc","non-empty string",1,t),this.WT(),yl.nE(Cr.K(t),this)},Ol.prototype.collectionGroup=function(t){if(xh("Firestore.collectionGroup",arguments,1),Ph("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new kr(Sr.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.WT(),new wl(new _o(Cr.G,t),this)},Ol.prototype.runTransaction=function(e){var n=this;return xh("Firestore.runTransaction",arguments,1),Ph("Firestore.runTransaction","function",1,e),this.WT().transaction(function(t){return e(new pl(n,t))})},Ol.prototype.batch=function(){return this.WT(),new dl(this)},Object.defineProperty(Ol,"logLevel",{get:function(){switch(Ys()){case l.DEBUG:return"debug";case l.SILENT:return"silent";default:return"error"}},enumerable:!0,configurable:!0}),Ol.setLogLevel=function(t){switch(xh("Firestore.setLogLevel",arguments,1),Ph("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":Qs(l.DEBUG);break;case"error":Qs(l.ERROR);break;case"silent":Qs(l.SILENT);break;default:throw new kr(Sr.INVALID_ARGUMENT,"Invalid log level: "+t)}},Ol.prototype.rE=function(){return this.YT.timestampsInSnapshots},Ol),pl=(xl.prototype.get=function(t){var n=this;xh("Transaction.get",arguments,1);var r=Ul("Transaction.get",t,this.hE);return this.oE.A_([r.kc]).then(function(t){if(!t||1!==t.length)return Js();var e=t[0];if(e instanceof Io)return new gl(n.hE,r.kc,null,!1,!1,r.aE);if(e instanceof To)return new gl(n.hE,r.kc,e,!1,!1,r.aE);throw Js()})},xl.prototype.set=function(t,e,n){Rh("Transaction.set",arguments,2,3);var r=Ul("Transaction.set",t,this.hE);n=Ll("Transaction.set",n);var i=jl(r.aE,e,"Transaction.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.hE.JT.Dc(s,o,n.mergeFields):this.hE.JT.vc(s,o);return this.oE.set(r.kc,u),this},xl.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 $h?(Oh("Transaction.update",arguments,3),r=Ul("Transaction.update",t,this.hE),this.hE.JT.Fc("Transaction.update",e,n,o)):(xh("Transaction.update",arguments,2),r=Ul("Transaction.update",t,this.hE),this.hE.JT.Cc("Transaction.update",e)),this.oE.update(r.kc,i),this},xl.prototype.delete=function(t){xh("Transaction.delete",arguments,1);var e=Ul("Transaction.delete",t,this.hE);return this.oE.delete(e.kc),this},xl),dl=(Dl.prototype.set=function(t,e,n){Rh("WriteBatch.set",arguments,2,3),this._E();var r=Ul("WriteBatch.set",t,this.hE);n=Ll("WriteBatch.set",n);var i=jl(r.aE,e,"WriteBatch.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.hE.JT.Dc(s,o,n.mergeFields):this.hE.JT.vc(s,o);return this.uE=this.uE.concat(u.Ac(r.kc,Fi.ft())),this},Dl.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return this._E(),i="string"==typeof e||e instanceof $h?(Oh("WriteBatch.update",arguments,3),r=Ul("WriteBatch.update",t,this.hE),this.hE.JT.Fc("WriteBatch.update",e,n,o)):(xh("WriteBatch.update",arguments,2),r=Ul("WriteBatch.update",t,this.hE),this.hE.JT.Cc("WriteBatch.update",e)),this.uE=this.uE.concat(i.Ac(r.kc,Fi.exists(!0))),this},Dl.prototype.delete=function(t){xh("WriteBatch.delete",arguments,1),this._E();var e=Ul("WriteBatch.delete",t,this.hE);return this.uE=this.uE.concat(new Ki(e.kc,Fi.ft())),this},Dl.prototype.commit=function(){return this._E(),this.cE=!0,0<this.uE.length?this.hE.WT().write(this.uE):Promise.resolve()},Dl.prototype._E=function(){if(this.cE)throw new kr(Sr.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},Dl),yl=(kl.nE=function(t,e,n){if(t.length%2!=0)throw new kr(Sr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.j()+" has "+t.length);return new kl(new $r(t),e,n)},Object.defineProperty(kl.prototype,"id",{get:function(){return this.kc.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(kl.prototype,"parent",{get:function(){return new El(this.kc.path.L(),this.firestore,this.aE)},enumerable:!0,configurable:!0}),Object.defineProperty(kl.prototype,"path",{get:function(){return this.kc.path.j()},enumerable:!0,configurable:!0}),kl.prototype.collection=function(t){if(xh("DocumentReference.collection",arguments,1),Ph("DocumentReference.collection","non-empty string",1,t),!t)throw new kr(Sr.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Cr.K(t);return new El(this.kc.path.child(e),this.firestore)},kl.prototype.isEqual=function(t){if(!(t instanceof kl))throw Gh("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.kc.isEqual(t.kc)&&this.aE===t.aE},kl.prototype.set=function(t,e){Rh("DocumentReference.set",arguments,1,2),e=Ll("DocumentReference.set",e);var n=jl(this.aE,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore.JT.Dc(i,r,e.mergeFields):this.firestore.JT.vc(i,r);return this.jT.write(o.Ac(this.kc,Fi.ft()))},kl.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 $h?(Oh("DocumentReference.update",arguments,2),this.firestore.JT.Fc("DocumentReference.update",t,e,r)):(xh("DocumentReference.update",arguments,1),this.firestore.JT.Cc("DocumentReference.update",t)),this.jT.write(n.Ac(this.kc,Fi.exists(!0)))},kl.prototype.delete=function(){return xh("DocumentReference.delete",arguments,0),this.jT.write([new Ki(this.kc,Fi.ft())])},kl.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rh("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||sl(t[i])||(Bh("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),Ch("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=sl(t[i])?t[i]:(Ph("DocumentReference.onSnapshot","function",i,t[i]),Lh("DocumentReference.onSnapshot","function",i+1,t[i+1]),Lh("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.lE(o,n)},kl.prototype.lE=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 Xf({next:function(t){if(n.next){var e=t.docs.get(r.kc);n.next(new gl(r.firestore,r.kc,e,t.fromCache,t.hasPendingWrites,r.aE))}},error:e}),o=this.jT.listen(_o.Wt(this.kc.path),i,t);return function(){i.NT(),r.jT.rl(o)}},kl.prototype.get=function(n){var r=this;return Rh("DocumentReference.get",arguments,0,1),Cl("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.WT().DT(r.kc).then(function(t){e(new gl(r.firestore,r.kc,t,!0,t instanceof To&&t.At,r.aE))},t):r.dE(e,t,n)})},kl.prototype.dE=function(e,n,r){var i=this.lE({includeMetadataChanges:!0,Of:!0},{next:function(t){i(),!t.exists&&t.metadata.fromCache?n(new kr(Sr.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new kr(Sr.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})},kl.prototype.withConverter=function(t){return new kl(this.kc,this.firestore,t)},kl),vl=(Sl.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},Sl),gl=(_l.prototype.data=function(t){if(Rh("DocumentSnapshot.data",arguments,0,1),t=Vl("DocumentSnapshot.data",t),this.fE){if(this.aE){var e=new ml(this.hE,this.kc,this.fE,this.TE,this.EE);return this.aE.fromFirestore(e,t)}return new hl(this.hE,this.hE.rE(),t.serverTimestamps,void 0).kT(this.fE.Lt())}},_l.prototype.get=function(t,e){if(Rh("DocumentSnapshot.get",arguments,1,2),e=Vl("DocumentSnapshot.get",e),this.fE){var n=this.fE.data().field(Rc("DocumentSnapshot.get",t));if(null!==n)return new hl(this.hE,this.hE.rE(),e.serverTimestamps,this.aE).kT(n)}},Object.defineProperty(_l.prototype,"id",{get:function(){return this.kc.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(_l.prototype,"ref",{get:function(){return new yl(this.kc,this.hE,this.aE)},enumerable:!0,configurable:!0}),Object.defineProperty(_l.prototype,"exists",{get:function(){return null!==this.fE},enumerable:!0,configurable:!0}),Object.defineProperty(_l.prototype,"metadata",{get:function(){return new vl(this.EE,this.TE)},enumerable:!0,configurable:!0}),_l.prototype.isEqual=function(t){if(!(t instanceof _l))throw Gh("isEqual","DocumentSnapshot",1,t);return this.hE===t.hE&&this.TE===t.TE&&this.kc.isEqual(t.kc)&&(null===this.fE?null===t.fE:this.fE.isEqual(t.fE))&&this.aE===t.aE},_l),ml=(n(Al,al=gl),Al.prototype.data=function(t){return al.prototype.data.call(this,t)},Al),wl=(Nl.prototype.where=function(t,e,n){xh("Query.where",arguments,3),Fh("Query.where",3,n);var r,i=function(t,e){if(!t.some(function(t){return t===e}))throw new kr(Sr.INVALID_ARGUMENT,"Invalid value "+qh(e)+" provided to function Query.where() for its "+Wh(2)+" argument. Acceptable values: "+t.join(", "));return e}(["<","<=","==",">=",">","array-contains","in","array-contains-any"],e),o=Rc("Query.where",t);if(o.Y()){if("array-contains"===i||"array-contains-any"===i)throw new kr(Sr.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+i+"' queries on FieldPath.documentId().");if("in"===i){this.wE(n,i);for(var s=[],u=0,a=n;u<a.length;u++){var h=a[u];s.push(this.RE(h))}r={arrayValue:{values:s}}}else r=this.RE(n)}else"in"!==i&&"array-contains-any"!==i||this.wE(n,i),r=this.firestore.JT.Nc("Query.where",n,"in"===i);var c=So.create(o,i,r);return this.AE(c),new Nl(this.IE.Gt(c),this.firestore,this.aE)},Nl.prototype.orderBy=function(t,e){var n;if(Rh("Query.orderBy",arguments,1,2),Lh("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n="asc";else{if("desc"!==e)throw new kr(Sr.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n="desc"}if(null!==this.IE.startAt)throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this.IE.endAt)throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=Rc("Query.orderBy",t),i=new Lo(r,n);return this.mE(i),new Nl(this.IE.zt(i),this.firestore,this.aE)},Nl.prototype.limit=function(t){return xh("Query.limit",arguments,1),Ph("Query.limit","number",1,t),zh("Query.limit",1,t),new Nl(this.IE.Ht(t),this.firestore,this.aE)},Nl.prototype.limitToLast=function(t){return xh("Query.limitToLast",arguments,1),Ph("Query.limitToLast","number",1,t),zh("Query.limitToLast",1,t),new Nl(this.IE.Yt(t),this.firestore,this.aE)},Nl.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Oh("Query.startAt",arguments,1);var r=this.PE("Query.startAt",t,e,!0);return new Nl(this.IE.Jt(r),this.firestore,this.aE)},Nl.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Oh("Query.startAfter",arguments,1);var r=this.PE("Query.startAfter",t,e,!1);return new Nl(this.IE.Jt(r),this.firestore,this.aE)},Nl.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Oh("Query.endBefore",arguments,1);var r=this.PE("Query.endBefore",t,e,!0);return new Nl(this.IE.Xt(r),this.firestore,this.aE)},Nl.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Oh("Query.endAt",arguments,1);var r=this.PE("Query.endAt",t,e,!1);return new Nl(this.IE.Xt(r),this.firestore,this.aE)},Nl.prototype.isEqual=function(t){if(!(t instanceof Nl))throw Gh("isEqual","Query",1,t);return this.firestore===t.firestore&&this.IE.isEqual(t.IE)},Nl.prototype.withConverter=function(t){return new Nl(this.IE,this.firestore,t)},Nl.prototype.PE=function(t,e,n,r){if(Fh(t,1,e),e instanceof gl){if(0<n.length)throw new kr(Sr.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new kr(Sr.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");return this.VE(i.fE,r)}var o=[e].concat(n);return this.gE(t,o,r)},Nl.prototype.VE=function(t,e){for(var n=[],r=0,i=this.IE.orderBy;r<i.length;r++){var o=i[r];if(o.field.Y())n.push(mi(this.firestore.$c,t.key));else{var s=t.field(o.field);if(si(s))throw new kr(Sr.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.j();throw new kr(Sr.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 Po(n,e)},Nl.prototype.gE=function(t,e,n){var r=this.IE.xt;if(e.length>r.length)throw new kr(Sr.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 kr(Sr.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof s);if(!this.IE._e()&&-1!==s.indexOf("/"))throw new kr(Sr.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.IE.path.child(Cr.K(s));if(!$r.et(u))throw new kr(Sr.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 $r(u);i.push(mi(this.firestore.$c,a))}else{var h=this.firestore.JT.Nc(t,s);i.push(h)}}return new Po(i,n)},Nl.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Rh("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||sl(t[i])||(Bh("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),Ch("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=sl(t[i])?t[i]:(Ph("Query.onSnapshot","function",i,t[i]),Lh("Query.onSnapshot","function",i+1,t[i+1]),Lh("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.pE(this.IE),this.lE(r,n)},Nl.prototype.lE=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 Xf({next:function(t){e.next&&e.next(new bl(n.firestore,n.IE,t,n.aE))},error:r}),o=this.firestore.WT(),s=o.listen(this.IE,i,t);return function(){i.NT(),o.rl(s)}},Nl.prototype.pE=function(t){if(t.ae()&&0===t.xt.length)throw new kr(Sr.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},Nl.prototype.get=function(n){var r=this;return Rh("Query.get",arguments,0,1),Cl("Query.get",n),this.pE(this.IE),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.WT().CT(r.IE).then(function(t){e(new bl(r.firestore,r.IE,t,r.aE))},t):r.dE(e,t,n)})},Nl.prototype.dE=function(e,n,r){var i=this.lE({includeMetadataChanges:!0,Of:!0},{next:function(t){i(),t.metadata.fromCache&&r&&"server"===r.source?n(new kr(Sr.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})},Nl.prototype.RE=function(t){if("string"==typeof t){if(""===t)throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this.IE._e()&&-1!==t.indexOf("/"))throw new kr(Sr.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.IE.path.child(Cr.K(t));if(!$r.et(e))throw new kr(Sr.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 mi(this.firestore.$c,new $r(e))}if(t instanceof yl){var n=t;return mi(this.firestore.$c,n.kc)}throw new kr(Sr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+qh(t)+".")},Nl.prototype.wE=function(t,e){if(!Array.isArray(t)||0===t.length)throw new kr(Sr.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new kr(Sr.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new kr(Sr.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 kr(Sr.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},Nl.prototype.AE=function(t){if(t instanceof So){var e=["array-contains","array-contains-any"],n=["in","array-contains-any"],r=0<=e.indexOf(t.op),i=0<=n.indexOf(t.op);if(t.ue()){var o=this.IE.jt();if(null!==o&&!o.isEqual(t.field))throw new kr(Sr.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.IE.Kt();null!==s&&this.yE(t.field,s)}else if(i||r){var u=null;if(i&&(u=this.IE.ce(n)),null===u&&r&&(u=this.IE.ce(e)),null!=u)throw u===t.op?new kr(Sr.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new kr(Sr.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+u.toString()+"' filters.")}}},Nl.prototype.mE=function(t){if(null===this.IE.Kt()){var e=this.IE.jt();null!==e&&this.yE(e,t.field)}},Nl.prototype.yE=function(t,e){if(!e.isEqual(t))throw new kr(Sr.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.")},Nl),bl=(Object.defineProperty(Il.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(Il.prototype,"empty",{get:function(){return this.vE.docs.B()},enumerable:!0,configurable:!0}),Object.defineProperty(Il.prototype,"size",{get:function(){return this.vE.docs.size},enumerable:!0,configurable:!0}),Il.prototype.forEach=function(e,n){var r=this;Rh("QuerySnapshot.forEach",arguments,1,2),Ph("QuerySnapshot.forEach","function",1,e),this.vE.docs.forEach(function(t){e.call(n,r.CE(t))})},Object.defineProperty(Il.prototype,"query",{get:function(){return new wl(this.bE,this.hE,this.aE)},enumerable:!0,configurable:!0}),Il.prototype.docChanges=function(t){t&&(Bh("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),Ch("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.vE.hs)throw new kr(Sr.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.SE&&this.DE===e||(this.SE=function(i,e,o,s){if(o.ss.B()){var n=0;return o.docChanges.map(function(t){var e=new ml(i,t.doc.key,t.doc,o.fromCache,o.ns.has(t.doc.key),s);return t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:n++}})}var u=o.ss;return o.docChanges.filter(function(t){return e||3!==t.type}).map(function(t){var e=new ml(i,t.doc.key,t.doc,o.fromCache,o.ns.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 Js()}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this.hE,e,this.vE,this.aE),this.DE=e),this.SE},Il.prototype.isEqual=function(t){if(!(t instanceof Il))throw Gh("isEqual","QuerySnapshot",1,t);return this.hE===t.hE&&this.bE.isEqual(t.bE)&&this.vE.isEqual(t.vE)&&this.aE===t.aE},Il.prototype.CE=function(t){return new ml(this.hE,t.key,t,this.metadata.fromCache,this.vE.ns.has(t.key),this.aE)},Il),El=(n(Tl,ul=wl),Object.defineProperty(Tl.prototype,"id",{get:function(){return this.IE.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(Tl.prototype,"parent",{get:function(){var t=this.IE.path.L();return t.B()?null:new yl(new $r(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(Tl.prototype,"path",{get:function(){return this.IE.path.j()},enumerable:!0,configurable:!0}),Tl.prototype.doc=function(t){if(Rh("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=eu.cn()),Ph("CollectionReference.doc","non-empty string",1,t),""===t)throw new kr(Sr.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Cr.K(t);return yl.nE(this.IE.path.child(e),this.firestore,this.aE)},Tl.prototype.add=function(t){xh("CollectionReference.add",arguments,1),Ph("CollectionReference.add","object",1,this.aE?this.aE.toFirestore(t):t);var e=this.doc();return e.set(t).then(function(){return e})},Tl.prototype.withConverter=function(t){return new Tl(this.FE,this.firestore,t)},Tl);function Tl(t,e,n){var r=this;if(((r=ul.call(this,_o.Wt(t),e,n)||this).FE=t).length%2!=1)throw new kr(Sr.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.j()+" has "+t.length);return r}function Il(t,e,n,r){this.hE=t,this.bE=e,this.vE=n,this.aE=r,this.SE=null,this.DE=null,this.metadata=new vl(n.hasPendingWrites,n.fromCache)}function Nl(t,e,n){this.IE=t,this.firestore=e,this.aE=n}function Al(){return null!==al&&al.apply(this,arguments)||this}function _l(t,e,n,r,i,o){this.hE=t,this.kc=e,this.fE=n,this.TE=r,this.EE=i,this.aE=o}function Sl(t,e){this.hasPendingWrites=t,this.fromCache=e}function kl(t,e,n){this.kc=t,this.firestore=e,this.aE=n,this.jT=this.firestore.WT()}function Dl(t){this.hE=t,this.uE=[],this.cE=!1}function xl(t,e){this.hE=t,this.oE=e}function Ol(t,e,n){var r=this;if(void 0===n&&(n=new Qf),this.UT=null,this.QT=new oh,this.INTERNAL={delete:function(){return y(r,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.WT(),[4,this.jT.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var i=t;this.UT=i,this.$c=Ol.KT(i),this.GT=i.name,this.zT=new xr(e)}else{var o=t;if(!o.projectId)throw new kr(Sr.INVALID_ARGUMENT,"Must provide projectId");this.$c=new uu(o.projectId,o.database),this.GT="[DEFAULT]",this.zT=new Dr}this.HT=n,this.YT=new fl({})}function Rl(t){var e,n,r,i;if(void 0===t.host){if(void 0!==t.ssl)throw new kr(Sr.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Vh("settings","non-empty string","host",t.host),this.host=t.host,Ch("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(Bh("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling","ignoreUndefinedProperties"]),Ch("settings","object","credentials",t.credentials),this.credentials=t.credentials,Ch("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),Ch("settings","boolean","ignoreUndefinedProperties",t.ignoreUndefinedProperties),!0===t.timestampsInSnapshots?$s("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&$s("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,this.ignoreUndefinedProperties=null!==(r=t.ignoreUndefinedProperties)&&void 0!==r&&r,Ch("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=lh._u;else{if(t.cacheSizeBytes!==cl&&t.cacheSizeBytes<lh.cu)throw new kr(Sr.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+lh.cu);this.cacheSizeBytes=t.cacheSizeBytes}Ch("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=null!==(i=t.experimentalForceLongPolling)&&void 0!==i&&i}function Pl(t,e,n,r){this.firestore=t,this.timestampsInSnapshots=e,this.$T=n,this.converter=r}function Ll(t,e){if(void 0===e)return{merge:!1};if(Bh(t,e,["merge","mergeFields"]),Ch(t,"boolean","merge",e.merge),n=t,void 0!==(r=e.mergeFields)&&function(t,e,n,r){if(!(n instanceof Array))throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+qh(n));for(var i=0;i<n.length;++i)if(!r(n[i]))throw new kr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be a string or a FieldPath, but the value at index "+i+" was: "+qh(n[i]))}(n,"mergeFields",r,function(t){return"string"==typeof t||t instanceof $h}),void 0!==e.mergeFields&&void 0!==e.merge)throw new kr(Sr.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');var n,r;return e}function Vl(t,e){return void 0===e?{}:(Bh(t,e,["serverTimestamps"]),Uh(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function Cl(t,e){Lh(t,"object",1,e),e&&(Bh(t,e,["source"]),Uh(t,0,"source",e.source,["default","server","cache"]))}function Ul(t,e,n){if(e instanceof yl){if(e.firestore!==n)throw new kr(Sr.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Gh(t,"DocumentReference",1,e)}function jl(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}function Ml(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new kr(Sr.INVALID_ARGUMENT,t)}return n.prototype=t.prototype,Object.assign(n,t),n}var ql,Fl=Ml(ll,"Use firebase.firestore() instead."),Bl=Ml(pl,"Use firebase.firestore().runTransaction() instead."),Gl=Ml(dl,"Use firebase.firestore().batch() instead."),zl=Ml(yl,"Use firebase.firestore().doc() instead."),Wl=Ml(gl),Kl=Ml(ml),Yl=Ml(wl),Ql=Ml(bl),Hl=Ml(El,"Use firebase.firestore().collection() instead."),$l=Ml((hp.delete=function(){return Dh("FieldValue.delete",arguments),new sc},hp.serverTimestamp=function(){return Dh("FieldValue.serverTimestamp",arguments),new uc},hp.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Oh("FieldValue.arrayUnion",arguments,1),new ac(t)},hp.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Oh("FieldValue.arrayRemove",arguments,1),new hc(t)},hp.increment=function(t){return Ph("FieldValue.increment","number",1,t),xh("FieldValue.increment",arguments,1),new cc(t)},hp.prototype.isEqual=function(t){return this===t},hp),"Use FieldValue.<field>() instead."),Xl=Ml(Hh,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Jl={Firestore:Fl,GeoPoint:fc,Timestamp:Pr,Blob:Xl,Transaction:Bl,WriteBatch:Gl,DocumentReference:zl,DocumentSnapshot:Wl,Query:Yl,QueryDocumentSnapshot:Kl,QuerySnapshot:Ql,CollectionReference:Hl,FieldPath:$h,FieldValue:$l,setLogLevel:ll.setLogLevel,CACHE_SIZE_UNLIMITED:cl},Zl=(ap.prototype.B_=function(t){},ap.prototype.mo=function(){},ap),tp=(up.prototype.B_=function(t){this.ME.push(t)},up.prototype.mo=function(){window.removeEventListener("online",this.NE),window.removeEventListener("offline",this.kE)},up.prototype.OE=function(){window.addEventListener("online",this.NE),window.addEventListener("offline",this.kE)},up.prototype.$E=function(){Hs("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.ME;t<e.length;t++)(0,e[t])(0)},up.prototype.LE=function(){Hs("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.ME;t<e.length;t++)(0,e[t])(1)},up.Gh=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},up),ep=(sp.prototype.e_=function(t){this.qE=t},sp.prototype.Yc=function(t){this.UE=t},sp.prototype.onMessage=function(t){this.QE=t},sp.prototype.close=function(){this.BE()},sp.prototype.send=function(t){this.xE(t)},sp.prototype.WE=function(){this.qE()},sp.prototype.jE=function(t){this.UE(t)},sp.prototype.KE=function(t){this.QE(t)},sp),np={BatchGetDocuments:"batchGet",Commit:"commit"},rp="gl-js/ fire/"+Er,ip=(op.prototype.zE=function(t,e){if(e)for(var n in e.o)e.o.hasOwnProperty(n)&&(t[n]=e.o[n]);t["X-Goog-Api-Client"]=rp},op.prototype.d_=function(a,r,i){var h=this,c=this.HE(a);return new Promise(function(o,s){var u=new br;u.listenOnce(mr.COMPLETE,function(){try{switch(u.getLastErrorCode()){case gr.NO_ERROR:var t=u.getResponseJson();Hs("Connection","XHR received:",JSON.stringify(t)),o(t);break;case gr.TIMEOUT:Hs("Connection",'RPC "'+a+'" timed out'),s(new kr(Sr.DEADLINE_EXCEEDED,"Request time out"));break;case gr.HTTP_ERROR:var e=u.getStatus();if(Hs("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(Sr).indexOf(i)?i:Sr.UNKNOWN);s(new kr(r,n.message))}else s(new kr(Sr.UNKNOWN,"Server responded with status "+u.getStatus()))}else Hs("Connection",'RPC "'+a+'" failed'),s(new kr(Sr.UNAVAILABLE,"Connection failed."));break;default:Js()}}finally{Hs("Connection",'RPC "'+a+'" completed.')}var i});var t=Object.assign({},r);delete t.database;var e=JSON.stringify(t);Hs("Connection","XHR sending: ",c+" "+e);var n={"Content-Type":"text/plain"};h.zE(n,i),u.send(c,"POST",e,n,15)})},op.prototype.f_=function(t,e,n){return this.d_(t,e,n)},op.prototype.s_=function(t,e){var n,r,i=[this.GE,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=vr(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.ii.projectId+"/databases/"+this.ii.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.zE(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)}})}Hs("Connection","Creating WebChannel: "+u+" "+s);var h=o.createWebChannel(u,s),c=!1,f=!1,l=new ep({xE:function(t){f?Hs("Connection","Not sending because WebChannel is closed:",t):(c||(Hs("Connection","Opening WebChannel transport."),h.open(),c=!0),Hs("Connection","WebChannel sending:",t),h.send(t))},BE:function(){return h.close()}});return a(wr.EventType.OPEN,function(){f||Hs("Connection","WebChannel transport opened.")}),a(wr.EventType.CLOSE,function(){f||(f=!0,Hs("Connection","WebChannel transport closed"),l.jE())}),a(wr.EventType.ERROR,function(t){f||(f=!0,Hs("Connection","WebChannel transport errored:",t),l.jE(new kr(Sr.UNAVAILABLE,"The operation could not be completed")))}),a(wr.EventType.MESSAGE,function(t){var e;if(!f){var n=t.data[0];Zs(!!n);var r=n.error||(null===(e=n[0])||void 0===e?void 0:e.error);if(r){Hs("Connection","WebChannel received error:",r);var i=r.status,o=function(){var t=co[i];if(void 0!==t)return Xo(t)}(),s=r.message;void 0===o&&(o=Sr.INTERNAL,s="Unknown error status: "+i+" with message "+r.message),f=!0,l.jE(new kr(o,s)),h.close()}else Hs("Connection","WebChannel received:",n),l.KE(n)}}),setTimeout(function(){l.WE()},0),l},op.prototype.HE=function(t){var e=np[t];return this.GE+"/v1/projects/"+this.ii.projectId+"/databases/"+this.ii.database+"/documents:"+e},op);function op(t){this.ii=t.ii;var e=t.ssl?"https":"http";this.GE=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}function sp(t){this.xE=t.xE,this.BE=t.BE}function up(){var t=this;this.NE=function(){return t.$E()},this.kE=function(){return t.LE()},this.ME=[],this.OE()}function ap(){}function hp(){}function cp(){this.ac="undefined"!=typeof atob}zs.an((Object.defineProperty(cp.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(cp.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),cp.prototype.yT=function(t){return Promise.resolve(new ip(t))},cp.prototype.AT=function(){return new(tp.Gh()?tp:Zl)},cp.prototype.bc=function(t){return new Fs(t,{hi:!0})},cp.prototype.un=function(t){return JSON.stringify(t)},cp.prototype.atob=function(t){return atob(t)},cp.prototype.btoa=function(t){return btoa(t)},cp.prototype._n=function(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n},new cp)),(ql=fp).INTERNAL.registerComponent(new E("firestore",function(t){return e=t.getProvider("app").getImmediate(),n=t.getProvider("auth-internal"),new ll(e,n,new Hf);var e,n},"PUBLIC").setServiceProps(Object.assign({},Jl))),ql.registerVersion("@firebase/firestore","1.14.6")}).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