text: !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(cp){"use strict";try{(function(){cp=cp&&Object.prototype.hasOwnProperty.call(cp,"default")?cp.default:cp;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=(I.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},I.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},I.prototype.setServiceProps=function(t){return this.serviceProps=t,this},I);function I(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}function T(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,_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A=A||{},S=_||self;function x(){}function k(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function L(t){var e=k(t);return"array"==e||"object"==e&&"number"==typeof t.length}function D(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var R="closure_uid_"+(1e9*Math.random()>>>0),O=0;function P(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")?P:V).apply(null,arguments)}function M(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 U(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]=++O);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 H(t){return/^[\s\xa0]*$/.test(t)}var K,W=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function X(t,e){return-1!=t.indexOf(e)}function Y(t,e){return t<e?-1:e<t?1:0}t:{var Q=S.navigator;if(Q){var J=Q.userAgent;if(J){K=J;break t}}K=""}function Z(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function $(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[" "]=x;var rt,it,ot=X(K,"Opera"),st=X(K,"Trident")||X(K,"MSIE"),ut=X(K,"Edge"),at=ut||st,ht=X(K,"Gecko")&&!(X(K.toLowerCase(),"webkit")&&!X(K,"Edge"))&&!(X(K,"Trident")||X(K,"MSIE"))&&!X(K,"Edge"),ct=X(K.toLowerCase(),"webkit")&&!X(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=W(String(rt)).split("."),n=W(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=Y(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||Y(0==o[2].length,0==s[2].length)||Y(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"),It=function(){if(!S.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{S.addEventListener("test",x,e),S.removeEventListener("test",x,e)}catch(t){}return t}();function Tt(t,e){this.type=t,this.a=this.target=e,this.defaultPrevented=!1}function Nt(t,e){if(Tt.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:_t[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}Tt.prototype.b=function(){this.defaultPrevented=!0},U(Nt,Tt);var _t={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 At="closure_listenable_"+(1e6*Math.random()|0),St=0;function xt(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 kt(t){t.V=!0,t.listener=null,t.proxy=null,t.src=null,t.aa=null}function Lt(t){this.src=t,this.a={},this.b=0}function Dt(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&&(kt(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}Lt.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Rt(t,e,r,i);return-1<s?(e=t[s],n||(e.X=!1)):((e=new xt(e,this.src,o,!!r,i)).X=n,t.push(e)),e};var Ot="closure_lm_"+(1e6*Math.random()|0),Pt={};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[At]?e.sa(n,r,D(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[At]?t.ra(e,n,D(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=D(i)?!!i.capture:!!i;if(s&&!bt)return null;var u,a,h=Ft(t);if(h||(t[Ot]=h=new Lt(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)It||(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 Mt(t){if("number"!=typeof t&&t&&!t.V){var e=t.src;if(e&&e[At])Dt(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))?(Dt(n,t),0==n.b&&(n.src=null,e[Ot]=null)):kt(t)}}}function jt(t){return t in Pt?Pt[t]:Pt[t]="on"+t}function Ut(t,e){var n=t.listener,r=t.aa||t.src;return t.X&&Mt(t),n.call(r,e)}function qt(t,e){if(t.V)return!0;if(bt)return Ut(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 Ut(t,e=new Nt(e,this))}function Ft(t){return(t=t[Ot])instanceof Lt?t:null}var Bt="__closure_events_fn_"+(1e9*Math.random()>>>0);function Gt(e){return"function"==k(e)?e:(e[Bt]||(e[Bt]=function(t){return e.handleEvent(t)}),e[Bt])}function zt(){q.call(this),this.c=new Lt(this),(this.J=this).A=null}function Ht(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var s=e[o];if(s&&!s.V&&s.capture==n){var u=s.listener,a=s.aa||s.src;s.X&&Dt(t.c,s),i=!1!==u.call(a,r)&&i}}return i&&!r.defaultPrevented}U(zt,q),zt.prototype[At]=!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=D(i)?!!i.capture:!!i,r=Gt(r),e&&e[At]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Rt(s=e.a[n],r,i,o))&&(kt(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)&&Mt(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 Tt(t,n);else if(t instanceof Tt)t.target=t.target||n;else{var i=t;et(t=new Tt(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var s=t.a=e[o];i=Ht(s,r,!0,t)&&i}if(i=Ht(s=t.a=n,r,!0,t)&&i,i=Ht(s,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Ht(s=t.a=e[o],r,!1,t)&&i;return i},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++)kt(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 Wt(){this.b=this.a=null}var Xt,Yt=(Qt.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 Qt(function(){return new Jt},function(t){t.reset()},100));function Qt(t,e,n){this.f=n,this.c=t,this.g=e,this.b=0,this.a=null}function Jt(){this.next=this.b=this.a=null}function Zt(t){S.setTimeout(function(){throw t},0)}function $t(t,e){var n;Xt||(n=S.Promise.resolve(void 0),Xt=function(){n.then(ne)}),te||(Xt(),te=!0),ee.add(t,e)}Wt.prototype.add=function(t,e){var n=Yt.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Jt.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var te=!(Jt.prototype.reset=function(){this.next=this.b=this.a=null}),ee=new Wt;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){Zt(t)}var e=Yt;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"==k(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={}}U(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},U(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))},U(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){Z(t.a,function(t,e){this.a.hasOwnProperty(e)&&Mt(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){Tt.call(this,"serverreachability",t)}function ve(t){var e=de();e.dispatchEvent(new ye(e))}function ge(t){Tt.call(this,"statevent",t)}function me(t){var e=de();e.dispatchEvent(new ge(e))}function we(t){Tt.call(this,"timingevent",t)}function be(t,e){if("function"!=k(t))throw Error("Fn must not be null and must be a function");return S.setTimeout(function(){t()},e)}U(ye,Tt),U(ge,Tt),U(we,Tt);var Ee={NO_ERROR:0,Va:1,bb:2,ab:3,Ya:4,$a:5,cb:6,za:7,TIMEOUT:8,gb:9},Ie={Xa:"complete",kb:"success",Aa:"error",za:"abort",ib:"ready",jb:"readystatechange",TIMEOUT:"timeout",eb:"incrementaldata",hb:"progress",Za:"downloadprogress",lb:"uploadprogress"};function Te(){}function Ne(t){var e;return(e=t.a)||(e=t.a={}),e}function _e(){}Te.prototype.a=null;var Ae,Se={OPEN:"a",Wa:"b",Aa:"c",fb:"d"};function xe(){Tt.call(this,"d")}function ke(){Tt.call(this,"c")}function Le(){}function De(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}U(xe,Tt),U(ke,Tt),U(Le,Te),Ae=new Le;var Re=45e3,Oe={},Pe={};function Ve(t,e,n){t.B=1,t.f=rn(Je(e)),t.j=n,t.F=!0,Ce(t,null)}function Ce(t,e){t.s=j(),Ue(t),t.A=Je(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?$(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 Me(t,e,n){for(var r=!0;!t.l&&t.w<n.length;){var i=je(t,n);if(i==Pe){4==e&&(t.c=4,me(14),r=!1);break}if(i==Oe){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?Pe:(n=Number(e.substring(n,r)),isNaN(n)?Oe:(r+=1)+n>e.length?Pe:(e=e.substr(r,n),t.w=r+n,e))}function Ue(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(Tn(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),!H(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&&(X(h,"spdy")||X(h,"quic")||X(h,"h2"))&&(c.f=c.g,c.a=new Set,c.b&&(_n(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){An(u.b,l);var p=l,d=u.D;d&&p.setTimeout(d),p.h&&(Fe(p),Ue(p)),u.a=l}else tr(u);0<n.f.length&&Qn(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):Wn(n):"noop"!=i[0]&&n.c&&n.c.ma(i),n.m=0);ve(4)}catch(t){}}function He(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(L(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(L(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(L(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 We(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Xe(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;)Xe(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function Xe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(N=De.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)&&!H(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?(Me(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,Ue(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),Me(this,t,e),this.b&&4!=t&&Ue(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(){We(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},N.K=function(){return We(this),this.a.concat()},N.get=function(t,e){return Xe(this.b,t)?this.b[t]:e},N.set=function(t,e){Xe(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 Ye=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Qe(t,e){if(this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,t instanceof Qe){this.a=void 0!==e?e:t.a,Ze(this,t.f),this.j=t.j,$e(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(Ye))?(this.a=!!e,Ze(this,n[1]||"",!0),this.j=on(n[2]||""),$e(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 Je(t){return new Qe(t)}function Ze(t,e,n){t.f=n?on(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function $e(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)}Qe.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),Xe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Xe((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&We(t)))}function vn(t,e){return dn(t),e=mn(t,e),Xe(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 In(t){return t.b||t.a&&t.a.size>=t.f}function Tn(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 _n(t,e){t.a?t.a.add(e):t.b=e}function An(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=T(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 xn(){}function kn(){this.a=new xn}function Ln(t,r,e){var i=e||"";try{He(t,function(t,e){var n=t;D(t)&&(n=Kt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Dn(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=T(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()}},xn.prototype.stringify=function(t){return S.JSON.stringify(t,void 0)},xn.prototype.parse=function(t){return S.JSON.parse(t,void 0)};var Rn=S.JSON.parse;function On(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=Pn,this.B=this.F=!1}U(On,zt);var Pn="",Vn=/^https?$/i,Cn=["POST","PUT"];function Mn(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,Un(t),Fn(t)}function Un(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function qn(t){if(t.b&&void 0!==A&&(!t.s[1]||4!=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(Ye)[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()+"]",Un(t)}}finally{Fn(t)}}}function Fn(t,e){if(t.a){Bn(t);var n=t.a,r=t.s[0]?x:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function 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="",Z(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 Hn(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=Hn("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=Hn("baseRetryDelayMs",5e3,t),this.Ga=Hn("retryDelaySeedMs",1e4,t),this.Da=Hn("forwardChannelMaxRetries",2,t),this.ga=Hn("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 kn,this.fa=t&&t.fastHandshake||!1,t&&t.forceLongPolling&&(this.W=!1),this.O=void 0}function Wn(t){if(Xn(t),3==t.u){var e=t.H++,n=Je(t.v);nn(n,"SID",t.B),nn(n,"RID",e),nn(n,"TYPE","terminate"),Zn(t,n),(e=new De(t,e,void 0)).B=2,e.f=rn(Je(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(),Ue(e)}sr(t)}function Xn(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 Yn(t,e){t.f.push(new wn(t.Fa++,e)),3==t.u&&Qn(t)}function Qn(t){In(t.b)||t.g||(t.g=!0,$t(t.xa,t),t.o=0)}function Jn(t,e){var n;n=e?e.W:t.H++;var r=Je(t.v);nn(r,"SID",t.B),nn(r,"RID",n),nn(r,"AID",t.G),Zn(t,r),t.h&&t.j&&zn(r,t.h,t.j),n=new De(t,n,t.o+1),null===t.h&&(n.m=t.j),e&&(t.f=e.i.concat(t.f)),e=$n(t,n,1e3),n.setTimeout(Math.round(.5*t.ga)+Math.round(.5*t.ga*Math.random())),_n(t.b,n),Ve(n,r,e)}function Zn(t,n){t.c&&He({},function(t,e){nn(n,e,t)})}function $n(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{Ln(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,$t(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,An(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)),Qn(t)}else tr(t);else if(3==(i=e.c)||0==i&&0<t.A||!(1==r&&function(t,e){if(!(Tn(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 Qe("//www.google.com/images/cleardot.gif"),S.location&&"http"==S.location.protocol||Ze(n,"https"),rn(n)),function(t,e){var n=new le;if(S.Image){var r=new Image;r.onload=M(Dn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=M(Dn,n,r,"TestLoadImage: error",!1,e),r.onabort=M(Dn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=M(Dn,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),Xn(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 Qe?Je(r):new Qe(r,void 0);if(""!=h.c)e&&$e(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 Qe(null,void 0),i&&Ze(a,i),o&&$e(a,o),s&&tn(a,s),u&&(a.g=u),h=a}return t.N&&Z(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),Zn(t,h),h}function ar(t,e){if(e&&!t.w)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new On(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)&&!H(t)&&(this.a.h=t),this.h=e&&e.supportsCrossDomainXhr||!1,this.g=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!H(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){xe.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(){ke.call(this),this.status=1}function dr(t){this.a=t}(N=On.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(Ae),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&&He(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Mn,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!==A&&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)),On.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 De(this,t,void 0),r=this.j;if(this.F&&(r?et(r=$(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=$n(this,n,e),nn(i=Je(this.v),"RID",t),nn(i,"CVER",22),this.s&&nn(i,"X-HTTP-Session-Id",this.s),Zn(this,i),this.h&&r&&zn(i,this.h,r),_n(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?Jn(this,t):0==this.f.length||In(this.b)||Jn(this))},N.wa=function(){this.i=null,this.a=new De(this,"rpc",this.J),null===this.h&&(this.a.m=this.j),this.a.J=0;var t=Je(this.ea);nn(t,"RID","rpc"),nn(t,"SID",this.B),nn(t,"CI",this.U?"0":"1"),nn(t,"AID",this.G),Zn(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(Je(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)},U(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),Qn(t)},N.close=function(){Wn(this.a)},N.La=function(t){if("string"==typeof t){var e={};e.__data__=t,Yn(this.a,e)}else this.g?((e={}).__data__=Kt(t),Yn(this.a,e)):Yn(this.a,t)},N.C=function(){this.a.c=null,delete this.f,Wn(this.a),delete this.a,fr.M.C.call(this)},U(lr,xe),U(pr,ke),U(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,Ie.COMPLETE="complete",(_e.EventType=Se).OPEN="a",Se.CLOSE="b",Se.ERROR="c",Se.MESSAGE="d",zt.prototype.listen=zt.prototype.ra,On.prototype.listenOnce=On.prototype.sa,On.prototype.getLastError=On.prototype.Ma,On.prototype.getLastErrorCode=On.prototype.qa,On.prototype.getStatus=On.prototype.S,On.prototype.getResponseJson=On.prototype.Ja,On.prototype.getResponseText=On.prototype.Y,On.prototype.send=On.prototype.$;var yr={createWebChannelTransport:function(){return new cr},ErrorCode:Ee,EventType:Ie,WebChannel:_e,XhrIo:On},vr=yr.createWebChannelTransport,gr=yr.ErrorCode,mr=yr.EventType,wr=yr.WebChannel,br=yr.XhrIo,Er=cp.SDK_VERSION,Ir=(Tr.prototype.t=function(){return null!=this.uid},Tr.prototype.s=function(){return this.t()?"uid:"+this.uid:"anonymous-user"},Tr.prototype.isEqual=function(t){return t.uid===this.uid},Tr);function Tr(t){this.uid=t}Ir.UNAUTHENTICATED=new Ir(null),Ir.i=new Ir("google-credentials-uid"),Ir.h=new Ir("first-party-uid");function Nr(t,e){this.user=e,this.type="OAuth",this.o={},this.o.Authorization="Bearer "+t}var _r,Ar,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"},xr=(n(Hr,Ar=Error),Hr),kr=(zr.prototype.getToken=function(){return Promise.resolve(null)},zr.prototype._=function(){},zr.prototype.l=function(t){(this.u=t)(Ir.UNAUTHENTICATED)},zr.prototype.T=function(){this.u=null},zr),Lr=(Gr.prototype.getToken=function(){var e=this,n=this.m,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.m!==n)throw new xr(Sr.ABORTED,"getToken aborted due to token change.");return t?($s("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.A=function(){var t=this.auth&&this.auth.getUid();return $s(null===t||"string"==typeof t),new Ir(t)},Gr),Dr=(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 Dr(this.P,this.V))},Fr.prototype.l=function(t){t(Ir.h)},Fr.prototype.T=function(){},Fr.prototype._=function(){},Fr),Or=(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),Pr=(Ur.v=function(t){return new Ur(t)},Ur.min=function(){return new Ur(new Or(0,0))},Ur.prototype.S=function(t){return this.timestamp.p(t.timestamp)},Ur.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Ur.prototype.D=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Ur.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Ur.prototype.C=function(){return this.timestamp},Ur),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.k(e)},jr.prototype.limit=function(){return this.offset+this.length},jr.prototype.$=function(t){return t=void 0===t?1:t,this.k(this.segments,this.offset+t,this.length-t)},jr.prototype.M=function(){return this.k(this.segments,this.offset,this.length-1)},jr.prototype.L=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(Mr,_r=Vr),Mr.prototype.k=function(t,e,n){return new Mr(t,e,n)},Mr.prototype.j=function(){return this.W().join("/")},Mr.prototype.toString=function(){return this.j()},Mr.K=function(t){if(0<=t.indexOf("//"))throw new xr(Sr.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new Mr(t.split("/").filter(function(t){return 0<t.length}))},Mr);function Mr(){return null!==_r&&_r.apply(this,arguments)||this}function jr(t,e,n){void 0===e?e=0:e>t.length&&Zs(),void 0===n?n=t.length-e:n>t.length-e&&Zs(),this.segments=t,this.offset=e,this.F=n}function Ur(t){this.timestamp=t}function qr(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new xr(Sr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new xr(Sr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new xr(Sr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new xr(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=Ir.h}function Gr(t){var e=this;this.I=null,this.currentUser=Ir.UNAUTHENTICATED,this.R=!1,this.m=0,this.u=null,this.forceRefresh=!1,this.I=function(){e.m++,e.currentUser=e.A(),e.R=!0,e.u&&e.u(e.currentUser)},this.m=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 Hr(t,e){var n=this;return(n=Ar.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,Wr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Xr=(n(Yr,Kr=Vr),Yr.prototype.k=function(t,e,n){return new Yr(t,e,n)},Yr.H=function(t){return Wr.test(t)},Yr.prototype.j=function(){return this.W().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),Yr.H(t)||(t="`"+t+"`"),t}).join(".")},Yr.prototype.toString=function(){return this.j()},Yr.prototype.Y=function(){return 1===this.length&&"__name__"===this.get(0)},Yr.J=function(){return new Yr(["__name__"])},Yr.X=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new xr(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 xr(Sr.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[r+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new xr(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 xr(Sr.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new Yr(e)},Yr);function Yr(){return null!==Kr&&Kr.apply(this,arguments)||this}Xr.G=new Xr([]);var Qr=(Jr.Z=function(t){return new Jr(Cr.K(t).$(5))},Jr.prototype.tt=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},Jr.prototype.isEqual=function(t){return null!==t&&0===Cr.N(this.path,t.path)},Jr.prototype.toString=function(){return this.path.toString()},Jr.N=function(t,e){return Cr.N(t.path,e.path)},Jr.et=function(t){return t.length%2==0},Jr.st=function(t){return new Jr(new Cr(t.slice()))},Jr);function Jr(t){this.path=t}function Zr(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function $r(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}Qr.EMPTY=new Qr(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 Or(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:Zs()}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(Zr(e)!==Zr(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 Zs()}}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 Zs()}}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,Qr.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):Zs();var t,e,n}(t)}function yi(t){if($s(!!t),"string"!=typeof t)return{seconds:vi(t.seconds),nanos:vi(t.nanos)};var e=0,n=ai.exec(t);if($s(!!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 Ii(t){return t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Ti(t){return t&&"mapValue"in t}var Ni=(_i.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},_i.prototype.at=function(t,e){return e},_i.prototype.ut=function(t){return null},_i.prototype.isEqual=function(t){return t instanceof _i},_i);function _i(){}Ni.instance=new Ni;var Ai=(Di.prototype.ot=function(t,e){return this.apply(t)},Di.prototype.at=function(t,e){return this.apply(t)},Di.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}}},Di.prototype.ut=function(t){return null},Di.prototype.isEqual=function(t){return t instanceof Di&&iu(this.elements,t.elements,ci)},Di),Si=(Li.prototype.ot=function(t,e){return this.apply(t)},Li.prototype.at=function(t,e){return this.apply(t)},Li.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}}},Li.prototype.ut=function(t){return null},Li.prototype.isEqual=function(t){return t instanceof Li&&iu(this.elements,t.elements,ci)},Li),xi=(ki.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)},ki.prototype.at=function(t,e){return e},ki.prototype.ut=function(t){return wi(e=t)||e&&"doubleValue"in e?t:{integerValue:0};var e},ki.prototype.isEqual=function(t){return t instanceof ki&&ci(this.ct,t.ct)},ki.prototype.asNumber=function(t){return vi(t.integerValue||t.doubleValue)},ki);function ki(t,e){this.serializer=t,this.ct=e}function Li(t){this.elements=t}function Di(t){this.elements=t}function Ri(t){return bi(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function Oi(t,e){this.version=t,this.transformResults=e}var Pi,Vi,Ci,Mi,ji,Ui=(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 Io&&t.version.isEqual(this.updateTime):void 0===this.exists||this.exists===t instanceof Io},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 Io?t.version:Pr.min()},ro),Gi=(n(no,ji=Bi),no.prototype.at=function(t,e){this.It(t);var n=e.version;return new Io(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 Io(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,Mi=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 Io(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 Io(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 Io?t.data():Xi.empty(),this.pt(e)},eo.prototype.pt=function(t){var n=this,r=new Yi(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),Hi=(n(to,Ci=Bi),to.prototype.at=function(t,e){if(this.It(t),$s(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 Io(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 Io(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 Io?t.field(i.field):void 0,s=i.transform.ut(o||null);null!=s&&(e=null==e?(new Yi).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=[];$s(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 Io&&(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 Io&&(a=e.field(s.field)),null===a&&n instanceof Io&&(a=n.field(s.field)),r.push(u.ot(a,t))}return r},to.prototype.St=function(t,e){for(var n=new Yi(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($i,Vi=Bi),$i.prototype.at=function(t,e){return this.It(t),new To(this.key,e.version,{hasCommittedMutations:!0})},$i.prototype.ot=function(t,e,n){return this.It(t),this.Rt.Et(t)?new To(this.key,Pr.min()):t},$i.prototype.Pt=function(t){return null},$i.prototype.isEqual=function(t){return t instanceof $i&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},$i),Wi=(n(Zi,Pi=Bi),Zi.prototype.at=function(t,e){Zs()},Zi.prototype.ot=function(t,e,n){Zs()},Zi.prototype.Pt=function(t){Zs()},Zi.prototype.isEqual=function(t){return t instanceof Zi&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},Zi),Xi=(Ji.empty=function(){return new Ji({mapValue:{}})},Ji.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(!Ti(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t.O()])||null},Ji.prototype.isEqual=function(t){return ci(this.proto,t.proto)},Ji),Yi=(Qi.prototype.set=function(t,e){return this.Nt(t,e),this},Qi.prototype.delete=function(t){return this.Nt(t,null),this},Qi.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)},Qi.prototype.yt=function(){var t=this.kt(Xr.G,this.Ft);return null!=t?new Xi(t):this.Ct},Qi.prototype.kt=function(r,t){var i=this,o=!1,e=this.Ct.field(r),s=Ti(e)?Object.assign({},e.mapValue.fields):{};return t.forEach(function(t,e){if(t instanceof Map){var n=i.kt(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},Qi);function Qi(t){void 0===t&&(t=Xi.empty()),this.Ct=t,this.Ft=new Map}function Ji(t){this.proto=t}function Zi(t,e){var n=this;return(n=Pi.call(this)||this).key=t,n.Rt=e,n.type=4,n}function $i(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=Mi.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(Xr.N)}function uo(t){var u=[];return $r(t.fields||{},function(t,e){var n=new Xr([t]);if(Ti(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 Ui(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,Io=(n(Yo,Eo=ao),Yo.prototype.field=function(t){return this.$t.field(t)},Yo.prototype.data=function(){return this.$t},Yo.prototype.Mt=function(){return this.$t.proto},Yo.prototype.isEqual=function(t){return t instanceof Yo&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.At===t.At&&this.hasCommittedMutations===t.hasCommittedMutations&&this.$t.isEqual(t.$t)},Yo.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.$t.toString()+", {hasLocalMutations: "+this.At+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(Yo.prototype,"hasPendingWrites",{get:function(){return this.At||this.hasCommittedMutations},enumerable:!0,configurable:!0}),Yo),To=(n(Xo,bo=ao),Xo.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(Xo.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),Xo.prototype.isEqual=function(t){return t instanceof Xo&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Xo),No=(n(Wo,wo=ao),Wo.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Wo.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),Wo.prototype.isEqual=function(t){return t instanceof Wo&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Wo),_o=(Ko.prototype.canonicalId=function(){if(null===this.Lt){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.Lt=t}return this.Lt},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.xt=function(){return Qr.et(this.path)&&null===this.collectionGroup&&0===this.filters.length},Ko),Ao=(Ho.Wt=function(t){return new Ho(t)},Object.defineProperty(Ho.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 Po(t)),this.qt.push(new Po(Xr.J(),"asc"));else{for(var n=!1,r=0,i=this.Ot;r<i.length;r++){var o=i[r];this.qt.push(o),o.field.Y()&&(n=!0)}if(!n){var s=0<this.Ot.length?this.Ot[this.Ot.length-1].dir:"asc";this.qt.push(new Po(Xr.J(),s))}}}return this.qt},enumerable:!0,configurable:!0}),Ho.prototype.Gt=function(t){var e=this.filters.concat([t]);return new Ho(this.path,this.collectionGroup,this.Ot.slice(),e,this.limit,this.Bt,this.startAt,this.endAt)},Ho.prototype.zt=function(t){var e=this.Ot.concat([t]);return new Ho(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},Ho.prototype.Ht=function(t){return new Ho(this.path,this.collectionGroup,this.Ot.slice(),this.filters.slice(),t,"F",this.startAt,this.endAt)},Ho.prototype.Yt=function(t){return new Ho(this.path,this.collectionGroup,this.Ot.slice(),this.filters.slice(),t,"L",this.startAt,this.endAt)},Ho.prototype.Jt=function(t){return new Ho(this.path,this.collectionGroup,this.Ot.slice(),this.filters.slice(),this.limit,this.Bt,t,this.endAt)},Ho.prototype.Xt=function(t){return new Ho(this.path,this.collectionGroup,this.Ot.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,t)},Ho.prototype.Zt=function(t){return new Ho(t,null,this.Ot.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},Ho.prototype.te=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.Ot.length||1===this.Ot.length&&this.Ot[0].field.Y())},Ho.prototype.canonicalId=function(){return this.ee().canonicalId()+"|lt:"+this.Bt},Ho.prototype.toString=function(){return"Query(target="+this.ee().toString()+"; limitType="+this.Bt+")"},Ho.prototype.isEqual=function(t){return this.ee().isEqual(t.ee())&&this.Bt===t.Bt},Ho.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},Ho.prototype.matches=function(t){return this.ie(t)&&this.ne(t)&&this.re(t)&&this.he(t)},Ho.prototype.oe=function(){return!ri(this.limit)&&"F"===this.Bt},Ho.prototype.ae=function(){return!ri(this.limit)&&"L"===this.Bt},Ho.prototype.Kt=function(){return 0<this.Ot.length?this.Ot[0].field:null},Ho.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},Ho.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},Ho.prototype.xt=function(){return this.ee().xt()},Ho.prototype._e=function(){return null!==this.collectionGroup},Ho.prototype.ee=function(){if(!this.Ut)if("F"===this.Bt)this.Ut=new _o(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 Po(r.field,i))}var o=this.endAt?new Oo(this.endAt.position,!this.endAt.before):null,s=this.startAt?new Oo(this.startAt.position,!this.startAt.before):null;this.Ut=new _o(this.path,this.collectionGroup,t,this.filters,this.limit,o,s)}return this.Ut},Ho.prototype.ie=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.tt(this.collectionGroup)&&this.path.q(e):Qr.et(this.path)?this.path.isEqual(e):this.path.U(e)},Ho.prototype.ne=function(t){for(var e=0,n=this.Ot;e<n.length;e++){var r=n[e];if(!r.field.Y()&&null===t.field(r.field))return!1}return!0},Ho.prototype.re=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},Ho.prototype.he=function(t){return!(this.startAt&&!this.startAt.le(this.orderBy,t)||this.endAt&&this.endAt.le(this.orderBy,t))},Ho.prototype.Qt=function(t){},Ho),So=(n(zo,mo=function(){}),zo.create=function(t,e,n){if(t.Y())return"in"===e?new ko(t,n):new xo(t,e,n);if(Ei(n)){if("=="!==e)throw new xr(Sr.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new zo(t,e,n)}if(Ii(n)){if("=="!==e)throw new xr(Sr.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new zo(t,e,n)}return"array-contains"===e?new Lo(t,n):"in"===e?new Do(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 Zs()}},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),xo=(n(Go,go=So),Go.prototype.matches=function(t){var e=Qr.N(t.key,this.key);return this.de(e)},Go),ko=(n(Bo,vo=So),Bo.prototype.matches=function(e){return this.keys.some(function(t){return t.isEqual(e.key)})},Bo),Lo=(n(Fo,yo=So),Fo.prototype.matches=function(t){var e=t.field(this.field);return bi(e)&&fi(e.arrayValue,this.value)},Fo),Do=(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(Uo,lo=So),Uo.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)})},Uo),Oo=(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()?Qr.N(Qr.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),Po=(Mo.prototype.compare=function(t,e){var n,r,i,o,s=this.fe?Qr.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):Zs());switch(this.dir){case"asc":return s;case"desc":return-1*s;default:return Zs()}},Mo.prototype.canonicalId=function(){return this.field.j()+this.dir.toString()},Mo.prototype.toString=function(){return this.field.j()+" ("+this.dir+")"},Mo.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},Mo),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=Pr.min()),void 0===o&&(o=Pr.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 Mo(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 Uo(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 Qr.Z(t.referenceValue)}),n}function Go(t,e,n){var r=this;return(r=go.call(this,t,e,n)||this).key=Qr.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 Ho(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.Ot=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.Lt=null}function Wo(){return null!==wo&&wo.apply(this,arguments)||this}function Xo(t,e,n){var r=this;return(r=bo.call(this,t,e)||this).hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}function Yo(t,e,n,r){var i=this;return(i=Eo.call(this,t,e)||this).$t=n,i.At=!!r.At,i.hasCommittedMutations=!!r.hasCommittedMutations,i}function Qo(t){switch(t){case Sr.OK:return Zs();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 Zs()}}function Jo(t){if(void 0===t)return Qs("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 Zs()}}(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 Zo=(rs.prototype.me=function(t,e){return new rs(this.N,this.root.me(t,e,this.N).Ae(null,null,ts.Pe,null,null))},rs.prototype.remove=function(t){return new rs(this.N,this.root.remove(t,this.N).Ae(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 $o(this.root,null,this.N,!1)},rs.prototype.ve=function(t){return new $o(this.root,t,this.N,!1)},rs.prototype.Se=function(){return new $o(this.root,null,this.N,!0)},rs.prototype.De=function(t){return new $o(this.root,t,this.N,!0)},rs),$o=(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.ke=function(){return 0<this.Fe.length},ns.prototype.$e=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.Ae=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.me=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.Ae(null,null,null,r.left.me(t,e,n),null):0===i?r.Ae(null,e,null,null,null):r.Ae(null,null,null,null,r.right.me(t,e,n))).Me()},es.prototype.Le=function(){if(this.left.B())return es.EMPTY;var t=this;return t.left.xe()||t.left.left.xe()||(t=t.Oe()),(t=t.Ae(null,null,null,t.left.Le(),null)).Me()},es.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.B()||r.left.xe()||r.left.left.xe()||(r=r.Oe()),r=r.Ae(null,null,null,r.left.remove(t,e),null);else{if(r.left.xe()&&(r=r.Be()),r.right.B()||r.right.xe()||r.right.left.xe()||(r=r.qe()),0===e(t,r.key)){if(r.right.B())return es.EMPTY;n=r.right.min(),r=r.Ae(n.key,n.value,null,null,r.right.Le())}r=r.Ae(null,null,null,null,r.right.remove(t,e))}return r.Me()},es.prototype.xe=function(){return this.color},es.prototype.Me=function(){var t=this;return t.right.xe()&&!t.left.xe()&&(t=t.Ue()),t.left.xe()&&t.left.left.xe()&&(t=t.Be()),t.left.xe()&&t.right.xe()&&(t=t.Qe()),t},es.prototype.Oe=function(){var t=this.Qe();return t.right.left.xe()&&(t=(t=(t=t.Ae(null,null,null,null,t.right.Be())).Ue()).Qe()),t},es.prototype.qe=function(){var t=this.Qe();return t.left.left.xe()&&(t=(t=t.Be()).Qe()),t},es.prototype.Ue=function(){var t=this.Ae(null,null,es.RED,null,this.right.left);return this.right.Ae(null,null,this.color,t,null)},es.prototype.Be=function(){var t=this.Ae(null,null,es.RED,this.left.right,null);return this.left.Ae(null,null,this.color,null,t)},es.prototype.Qe=function(){var t=this.left.Ae(null,null,!this.left.color,null,null),e=this.right.Ae(null,null,!this.right.color,null,null);return this.Ae(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.xe()&&this.left.xe())throw Zs();if(this.right.xe())throw Zs();var t=this.left.je();if(t!==this.right.je())throw Zs();return t+(this.xe()?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 Zs()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"value",{get:function(){throw Zs()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"color",{get:function(){throw Zs()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"left",{get:function(){throw Zs()},enumerable:!0,configurable:!0}),Object.defineProperty(is.prototype,"right",{get:function(){throw Zs()},enumerable:!0,configurable:!0}),is.prototype.Ae=function(t,e,n,r,i){return this},is.prototype.me=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.xe=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.ke();){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.ke();)if(!t(n.Ne().key))return},hs.prototype.ze=function(t){var e=this.data.ve(t);return e.ke()?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.Ae(this.data.remove(t).me(t,!0))},hs.prototype.delete=function(t){return this.has(t)?this.Ae(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.ke();){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.Ae=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.ke=function(){return this.Ye.ke()},as),us=new Zo(Qr.N);function as(t){this.Ye=t}function hs(t){this.N=t,this.data=new Zo(this.N)}function cs(){return us}function fs(){return cs()}var ls=new Zo(Qr.N);function ps(){return ls}var ds=new Zo(Qr.N);function ys(){return ds}var vs=new os(Qr.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.ms=e}function Is(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 Ts=(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.Ae(e.Je.me(t.key,t),e.Xe.me(t,null))},Cs.prototype.delete=function(t){var e=this.get(t);return e?this.Ae(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.ke();){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.Ae=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.me(e,t):3===t.type&&1!==n.type?this.ts=this.ts.me(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.ts=this.ts.me(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.ts=this.ts.me(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.me(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.ts=this.ts.me(e,{type:2,doc:t.doc}):Zs()},Vs.prototype.es=function(){var n=[];return this.ts.pe(function(t,e){n.push(e)}),n},Vs),_s=(Ps.os=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:0,doc:t})}),new Ps(t,e,Ts.Ze(e),i,n,r,!0,!1)},Object.defineProperty(Ps.prototype,"hasPendingWrites",{get:function(){return!this.ns.B()},enumerable:!0,configurable:!0}),Ps.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},Ps),As=(Os.ls=function(t,e){var n=new Map;return n.set(t,Ss.ds(t,e)),new Os(Pr.min(),n,ws(),cs(),gs())},Os),Ss=(Rs.ds=function(t,e){return new Rs(ei.ht,e,gs(),gs(),gs())},Rs),xs=(Object.defineProperty(Ds.prototype,"fs",{get:function(){return this.gs},enumerable:!0,configurable:!0}),Object.defineProperty(Ds.prototype,"resumeToken",{get:function(){return this.Vs},enumerable:!0,configurable:!0}),Object.defineProperty(Ds.prototype,"ys",{get:function(){return 0!==this.As},enumerable:!0,configurable:!0}),Object.defineProperty(Ds.prototype,"bs",{get:function(){return this.ps},enumerable:!0,configurable:!0}),Ds.prototype.vs=function(t){0<t.rt()&&(this.ps=!0,this.Vs=t)},Ds.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:Zs()}}),new Ss(this.Vs,this.gs,n,r,i)},Ds.prototype.Ds=function(){this.ps=!1,this.Ps=js()},Ds.prototype.Cs=function(t,e){this.ps=!0,this.Ps=this.Ps.me(t,e)},Ds.prototype.Fs=function(t){this.ps=!0,this.Ps=this.Ps.remove(t)},Ds.prototype.Ns=function(){this.As+=1},Ds.prototype.ks=function(){--this.As},Ds.prototype.$s=function(){this.ps=!0,this.gs=!0},Ds),ks=(Ls.prototype.qs=function(t){for(var e=0,n=t.ws;e<n.length;e++){var r=n[e];t.Rs instanceof Io?this.Us(r,t.Rs):t.Rs instanceof To&&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)}},Ls.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.ks(),e.ys||e.Ds(),e.vs(n.resumeToken);break;case 2:e.ks(),e.ys||r.removeTarget(t);break;case 3:r.Gs(t)&&(e.$s(),e.vs(n.resumeToken));break;case 4:r.Gs(t)&&(r.zs(t),e.vs(n.resumeToken));break;default:Zs()}})},Ls.prototype.js=function(t,n){var r=this;0<t.targetIds.length?t.targetIds.forEach(n):this.Ls.forEach(function(t,e){r.Gs(e)&&n(e)})},Ls.prototype.Hs=function(t){var e=t.targetId,n=t.ms.count,r=this.Ys(e);if(r){var i=r.target;if(i.xt())if(0===n){var o=new Qr(i.path);this.Qs(e,o,new To(o,Pr.min()))}else $s(1===n);else this.Js(e)!==n&&(this.zs(e),this.Bs=this.Bs.add(e))}},Ls.prototype.Xs=function(i){var o=this,s=new Map;this.Ls.forEach(function(t,e){var n=o.Ys(e);if(n){if(t.fs&&n.target.xt()){var r=new Qr(n.target.path);null!==o.xs.get(r)||o.Zs(e,r)||o.Qs(e,r,new To(r,i))}t.bs&&(s.set(e,t.Ss()),t.Ds())}});var r=gs();this.Os.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 As(i,s,this.Bs,this.xs,r);return this.xs=cs(),this.Os=Ms(),this.Bs=new os(ru),t},Ls.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.xs=this.xs.me(e.key,e),this.Os=this.Os.me(e.key,this.ti(e.key).add(t))}},Ls.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.Os=this.Os.me(e,this.ti(e).delete(t)),n&&(this.xs=this.xs.me(e,n))}},Ls.prototype.removeTarget=function(t){this.Ls.delete(t)},Ls.prototype.Js=function(t){var e=this.Ks(t).Ss();return this.Ms.ei(t).size+e.Ts.size-e.Is.size},Ls.prototype.Ns=function(t){this.Ks(t).Ns()},Ls.prototype.Ks=function(t){var e=this.Ls.get(t);return e||(e=new xs,this.Ls.set(t,e)),e},Ls.prototype.ti=function(t){var e=this.Os.get(t);return e||(e=new os(ru),this.Os=this.Os.me(t,e)),e},Ls.prototype.Gs=function(t){var e=null!==this.Ys(t);return e||Ys("WatchChangeAggregator","Detected inactive target",t),e},Ls.prototype.Ys=function(t){var e=this.Ls.get(t);return e&&e.ys?null:this.Ms.si(t)},Ls.prototype.zs=function(e){var n=this;this.Ls.set(e,new xs),this.Ms.ei(e).forEach(function(t){n.Qs(e,t,null)})},Ls.prototype.Zs=function(t,e){return this.Ms.ei(t).has(e)},Ls);function Ls(t){this.Ms=t,this.Ls=new Map,this.xs=cs(),this.Os=Ms(),this.Bs=new os(ru)}function Ds(){this.As=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 Os(t,e,n,r,i){this.Ee=t,this.as=e,this.us=n,this.cs=r,this._s=i}function Ps(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 Zo(Qr.N)}function Cs(n){this.N=n?function(t,e){return n(t,e)||Qr.N(t.key,e.key)}:function(t,e){return Qr.N(t.key,e.key)},this.Je=ps(),this.Xe=new Zo(this.N)}function Ms(){return new Zo(Qr.N)}function js(){return new Zo(Qr.N)}var Us={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:Jo(t.code);return new xr(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 Or(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?($s(void 0===t||"string"==typeof t),ei.fromBase64String(t||"")):($s(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 $s(!!t),Pr.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 $s(Gs(e)),e},Bs.prototype.fi=function(t){return this._i(t.path)},Bs.prototype.Z=function(t){var e=this.di(t);return $s(e.get(1)===this.ii.projectId),$s(!e.get(3)&&!this.ii.database||e.get(3)===this.ii.database),new Qr(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 $s(4<t.length&&"documents"===t.get(4)),t.$(5)},Bs.prototype.Ri=function(t,e){return{name:this.fi(t),fields:e.proto.mapValue.fields}},Bs.prototype.mi=function(t){return{name:this.fi(t.key),fields:t.Mt().mapValue.fields,updateTime:this.C(t.version.C())}},Bs.prototype.Ai=function(t,e){var n=this.Z(t.name),r=this.fromVersion(t.updateTime),i=new Xi({mapValue:{fields:t.fields}});return new Io(n,r,i,{hasCommittedMutations:!!e})},Bs.prototype.Pi=function(t){$s(!!t.found),t.found.name,t.found.updateTime;var e=this.Z(t.found.name),n=this.fromVersion(t.found.updateTime),r=new Xi({mapValue:{fields:t.found.fields}});return new Io(e,n,r,{})},Bs.prototype.Vi=function(t){$s(!!t.missing),$s(!!t.readTime);var e=this.Z(t.missing),n=this.fromVersion(t.readTime);return new To(e,n)},Bs.prototype.gi=function(t){return"found"in t?this.Pi(t):"missing"in t?this.Vi(t):Zs()},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 Is(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 Xi({mapValue:{fields:u.document.fields}}),f=new Io(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):Pr.min(),g=new To(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 Zs();t.filter;var I=t.filter;I.targetId;var T=I.count||0,N=new ho(T),_=I.targetId;e=new Es(_,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:Zs()},Bs.prototype.bi=function(t){if(!("targetChange"in t))return Pr.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length||!e.readTime?Pr.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 Hi)e={transform:{document:this.fi(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.Di(t)})}};else{if(!(t instanceof Wi))return Zs();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 Xi({mapValue:{fields:t.update.fields}});if(t.updateMask){var o=this.ki(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.$i(t)});return $s(!0===n.exists),new Hi(u,a)}if(t.verify){var h=this.Z(t.verify);return new Wi(h,n)}return Zs()},Bs.prototype.Ci=function(t){return void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:Zs()},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.Mi=function(t,e){var n=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);n.isEqual(Pr.min())&&(n=this.fromVersion(e));var r=null;return t.transformResults&&0<t.transformResults.length&&(r=t.transformResults),new Oi(n,r)},Bs.prototype.Li=function(t,e){var n=this;return t&&0<t.length?($s(void 0!==e),t.map(function(t){return n.Mi(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 Ai)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 xi)return{fieldPath:t.field.j(),increment:e.ct};throw Zs()},Bs.prototype.$i=function(t){var e=null;if("setToServerValue"in t)$s("REQUEST_TIME"===t.setToServerValue),e=Ni.instance;else if("appendMissingElements"in t){var n=t.appendMissingElements.values||[];e=new Ai(n)}else if("removeAllFromArray"in t){var r=t.removeAllFromArray.values||[];e=new Si(r)}else"increment"in t?e=new xi(this,t.increment):Zs();var i=Xr.X(t.fieldPath);return new qi(i,e)},Bs.prototype.xi=function(t){return{documents:[this.Ei(t.path)]}},Bs.prototype.Oi=function(t){$s(1===t.documents.length);var e=t.documents[0];return Ao.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.M()),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){$s(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 Ao(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 Zs()}},Bs.prototype.ee=function(t){var e,n=t.target;return(e=n.xt()?{documents:this.xi(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):Zs()});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)}):Zs():[]},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 Oo(n,e)},Bs.prototype.en=function(t){return Us[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 Zs()}},Bs.prototype.hn=function(t){return{fieldPath:t.j()}},Bs.prototype.on=function(t){return Xr.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 Po(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(Ii(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 Zs()}},Bs.prototype.Si=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.j())}),{fieldPaths:e}},Bs.prototype.ki=function(t){var e=t.fieldPaths||[];return new Ui(e.map(function(t){return Xr.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&&Zs(),Ks.platform=t},Ks.nt=function(){return Ks.platform||Zs(),Ks.platform},Ks),Hs=new h("@firebase/firestore");function Ks(){}function Ws(){return Hs.logLevel}function Xs(t){Hs.logLevel=t}function Ys(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Hs.logLevel<=l.DEBUG){var r=e.map(Js);Hs.debug.apply(Hs,i(["Firestore ("+Er+"): "+t],r))}}function Qs(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Hs.logLevel<=l.ERROR){var r=e.map(Js);Hs.error.apply(Hs,i(["Firestore ("+Er+"): "+t],r))}}function Js(t){if("string"==typeof t)return t;var e=zs.nt();try{return e.un(t)}catch(e){return t}}function Zs(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE ("+Er+") INTERNAL ASSERTION FAILED: "+t;throw Qs(e),new Error(e)}function $s(t){t||Zs()}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(Du.prototype,"ln",{get:function(){return"(default)"===this.database},enumerable:!0,configurable:!0}),Du.prototype.isEqual=function(t){return t instanceof Du&&t.projectId===this.projectId&&t.database===this.database},Du.prototype.S=function(t){return ru(this.projectId,t.projectId)||ru(this.database,t.database)},Du),au=(Lu.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}},Lu.prototype.has=function(t){return void 0!==this.get(t)},Lu.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]]},Lu.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},Lu.prototype.forEach=function(u){$r(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)}})},Lu.prototype.B=function(){return ti(this.fn)},Lu),hu=(ku.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},ku.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},ku.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.me(t.key,e))}),i},ku.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},gs())},ku.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)})},ku),cu=(xu.from=function(t,e,n,r){$s(t.mutations.length===n.length);for(var i=ys(),o=t.mutations,s=0;s<o.length;s++)i=i.me(o[s].key,n[s].version);return new xu(t,e,n,r,i)},xu),fu=(Su.prototype.B=function(){return this.mn.B()},Su.prototype.gn=function(t,e){var n=new lu(t,e);this.mn=this.mn.add(n),this.Pn=this.Pn.add(n)},Su.prototype.pn=function(t,e){var n=this;t.forEach(function(t){return n.gn(t,e)})},Su.prototype.yn=function(t,e){this.bn(new lu(t,e))},Su.prototype.vn=function(t,e){var n=this;t.forEach(function(t){return n.yn(t,e)})},Su.prototype.Sn=function(t){var e=this,n=Qr.EMPTY,r=new lu(n,t),i=new lu(n,t+1),o=[];return this.Pn.Ke([r,i],function(t){e.bn(t),o.push(t.key)}),o},Su.prototype.Dn=function(){var e=this;this.mn.forEach(function(t){return e.bn(t)})},Su.prototype.bn=function(t){this.mn=this.mn.delete(t),this.Pn=this.Pn.delete(t)},Su.prototype.Cn=function(t){var e=Qr.EMPTY,n=new lu(e,t),r=new lu(e,t+1),i=gs();return this.Pn.Ke([n,r],function(t){i=i.add(t.key)}),i},Su.prototype.Fn=function(t){var e=new lu(t,0),n=this.mn.ze(e);return null!==n&&t.isEqual(n.key)},Su),lu=(Au.An=function(t,e){return Qr.N(t.key,e.key)||ru(t.Nn,e.Nn)},Au.Vn=function(t,e){return ru(t.Nn,e.Nn)||Qr.N(t.key,e.key)},Au),pu=(_u.prototype.catch=function(t){return this.next(void 0,t)},_u.prototype.next=function(r,i){var o=this;return this.Ln&&Zs(),this.Ln=!0,this.Mn?this.error?this.xn(i,this.error):this.On(r,this.result):new _u(function(e,n){o.kn=function(t){o.On(r,t).next(e,n)},o.$n=function(t){o.xn(i,t).next(e,n)}})},_u.prototype.Bn=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},_u.prototype.qn=function(t){try{var e=t();return e instanceof _u?e:_u.resolve(e)}catch(t){return _u.reject(t)}},_u.prototype.On=function(t,e){return t?this.qn(function(){return t(e)}):_u.resolve(e)},_u.prototype.xn=function(t,e){return t?this.qn(function(){return t(e)}):_u.reject(e)},_u.resolve=function(n){return new _u(function(t,e){t(n)})},_u.reject=function(n){return new _u(function(t,e){e(n)})},_u.Un=function(t){return new _u(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()})},_u.Qn=function(t){for(var n=_u.resolve(!1),e=function(e){n=n.next(function(t){return t?_u.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},_u.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.Un(i)},_u),du=(Object.defineProperty(Nu.prototype,"readTime",{get:function(){return this.Kn},set:function(t){this.Kn=t},enumerable:!0,configurable:!0}),Nu.prototype.Gn=function(t,e){this.zn(),this.readTime=e,this.Wn.set(t.key,t)},Nu.prototype.Hn=function(t,e){this.zn(),e&&(this.readTime=e),this.Wn.set(t,null)},Nu.prototype.Yn=function(t,e){this.zn();var n=this.Wn.get(e);return void 0!==n?pu.resolve(n):this.Jn(t,e)},Nu.prototype.getEntries=function(t,e){return this.Xn(t,e)},Nu.prototype.apply=function(t){return this.zn(),this.jn=!0,this.Zn(t)},Nu.prototype.zn=function(){},Nu),yu="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",vu=(Tu.prototype.er=function(t){this.tr.push(t)},Tu.prototype.sr=function(){this.tr.forEach(function(t){return t()})},Tu),gu=(Iu.prototype.hr=function(e,n){var r=this;return this.nr.or(e,n).next(function(t){return r.ar(e,n,t)})},Iu.prototype.ar=function(t,r,i){return this.ir.Yn(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].ot(r,t);return t})},Iu.prototype.ur=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.me(t,e)}),o},Iu.prototype.cr=function(e,t){var n=this;return this.ir.getEntries(e,t).next(function(t){return n._r(e,t)})},Iu.prototype._r=function(r,i){var o=this;return this.nr.lr(r,i).next(function(t){var e=o.ur(r,i,t),n=cs();return e.forEach(function(t,e){e=e||new To(t,Pr.min()),n=n.me(t,e)}),n})},Iu.prototype.dr=function(t,e,n){return e.xt()?this.Tr(t,e.path):e._e()?this.Er(t,e,n):this.Ir(t,e,n)},Iu.prototype.Tr=function(t,e){return this.hr(t,new Qr(e)).next(function(t){var e=ps();return t instanceof Io&&(e=e.me(t.key,t)),e})},Iu.prototype.Er=function(n,r,i){var o=this,s=r.collectionGroup,u=ps();return this.rr.wr(n,s).next(function(t){return pu.forEach(t,function(t){var e=r.Zt(t.child(s));return o.Ir(n,e,i).next(function(t){t.forEach(function(t,e){u=u.me(t,e)})})}).next(function(){return u})})},Iu.prototype.Ir=function(e,n,t){var c,f,r=this;return this.ir.dr(e,n,t).next(function(t){return c=t,r.nr.Rr(e,n)}).next(function(t){return f=t,r.mr(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 Io?c.me(u,h):c.remove(u)}})}).next(function(){return c.forEach(function(t,e){n.matches(e)||(c=c.remove(t))}),c})},Iu.prototype.mr=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.ir.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof Io&&(h=h.me(t,e))}),h})},Iu),mu=(Eu.Vr=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 Eu(t,e.fromCache,n,r)},Eu),wu=(bu.prototype.pr=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},bu.prototype.next=function(){var t=++this.previousValue;return this.yr&&this.yr(t),t},bu);function bu(t,e){var n=this;this.previousValue=t,e&&(e.gr=function(t){return n.pr(t)},this.yr=function(t){return e.br(t)})}function Eu(t,e,n,r){this.targetId=t,this.fromCache=e,this.Ar=n,this.Pr=r}function Iu(t,e,n){this.ir=t,this.nr=e,this.rr=n}function Tu(){this.tr=[]}function Nu(){this.Wn=new au(function(t){return t.toString()}),this.jn=!1}function _u(t){var e=this;this.kn=null,this.$n=null,this.result=void 0,this.error=void 0,this.Mn=!1,this.Ln=!1,t(function(t){e.Mn=!0,e.result=t,e.kn&&e.kn(t)},function(t){e.Mn=!0,e.error=t,e.$n&&e.$n(t)})}function Au(t,e){this.key=t,this.Nn=e}function Su(){this.mn=new os(lu.An),this.Pn=new os(lu.Vn)}function xu(t,e,n,r,i){this.batch=t,this.wn=e,this.En=n,this.streamToken=r,this.Rn=i}function ku(t,e,n,r){this.batchId=t,this.Tn=e,this.baseMutations=n,this.mutations=r}function Lu(t){this.dn=t,this.fn={}}function Du(t,e){this.projectId=t,this.database=e||"(default)"}wu.vr=-1;function Ru(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}var Ou=(ju.prototype.reset=function(){this.kr=0},ju.prototype.Lr=function(){this.kr=this.Nr},ju.prototype.xr=function(t){var e=this;this.cancel();var n=Math.floor(this.kr+this.Or()),r=Math.max(0,Date.now()-this.Mr),i=Math.max(0,n-r);0<i&&Ys("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.kr+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.$r=this.Sr.Br(this.Dr,i,function(){return e.Mr=Date.now(),t()}),this.kr*=this.Fr,this.kr<this.Cr&&(this.kr=this.Cr),this.kr>this.Nr&&(this.kr=this.Nr)},ju.prototype.cancel=function(){null!==this.$r&&(this.$r.cancel(),this.$r=null)},ju.prototype.Or=function(){return(Math.random()-.5)*this.kr},ju),Pu=(Mu.jr=function(t,e,n,r,i){var o=new Mu(t,e,Date.now()+n,r,i);return o.start(n),o},Mu.prototype.start=function(t){var e=this;this.Kr=setTimeout(function(){return e.Gr()},t)},Mu.prototype.zr=function(){return this.Gr()},Mu.prototype.cancel=function(t){null!==this.Kr&&(this.clearTimeout(),this.Wr.reject(new xr(Sr.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},Mu.prototype.Gr=function(){var e=this;this.qr.Hr(function(){return null!==e.Kr?(e.clearTimeout(),e.op().then(function(t){return e.Wr.resolve(t)})):Promise.resolve()})},Mu.prototype.clearTimeout=function(){null!==this.Kr&&(this.Qr(this),clearTimeout(this.Kr),this.Kr=null)},Mu),Vu=(Object.defineProperty(Cu.prototype,"hh",{get:function(){return this.Xr},enumerable:!0,configurable:!0}),Cu.prototype.Hr=function(t){this.enqueue(t)},Cu.prototype.oh=function(t){this.ah(),this.uh(t)},Cu.prototype._h=function(t){return this.ah(),this.uh(t)},Cu.prototype.lh=function(n){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.ah(),this.Xr?[3,2]:(this.Xr=!0,(e=zs.nt().window)&&e.removeEventListener("visibilitychange",this.nh),[4,this._h(n)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},Cu.prototype.enqueue=function(t){return this.ah(),this.Xr?new Promise(function(t){}):this.uh(t)},Cu.prototype.dh=function(i){var t=this;this.ah(),this.Xr||(this.Jr=this.Jr.then(function(){var n=new Ru,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.ih.reset(),[3,3];case 2:if("IndexedDbTransactionError"!==(e=t.sent()).name)throw n.resolve(),e;return Ys("AsyncQueue","Operation failed with retryable error: "+e),this.ih.xr(r),[3,3];case 3:return[2]}})})};return t.Hr(r),n.promise}))},Cu.prototype.uh=function(t){var e=this,n=this.Yr.then(function(){return e.eh=!0,t().catch(function(t){throw e.th=t,e.eh=!1,Qs("INTERNAL UNHANDLED ERROR: ",t.stack||t.message||""),t}).then(function(t){return e.eh=!1,t})});return this.Yr=n},Cu.prototype.Br=function(t,e,n){var r=this;this.ah(),-1<this.sh.indexOf(t)&&(e=0);var i=Pu.jr(this,t,e,n,function(t){return r.fh(t)});return this.Zr.push(i),i},Cu.prototype.ah=function(){this.th&&Zs()},Cu.prototype.Th=function(){},Cu.prototype.Eh=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.Yr];case 1:t.sent(),t.label=2;case 2:if(e!==this.Yr)return[3,0];t.label=3;case 3:return[2]}})})},Cu.prototype.Ih=function(t){for(var e=0,n=this.Zr;e<n.length;e++)if(n[e].Dr===t)return!0;return!1},Cu.prototype.rh=function(r){var i=this;return this.Eh().then(function(){i.Zr.sort(function(t,e){return t.Ur-e.Ur});for(var t=0,e=i.Zr;t<e.length;t++){var n=e[t];if(n.zr(),"all"!==r&&n.Dr===r)break}return i.Eh()})},Cu.prototype.wh=function(t){this.sh.push(t)},Cu.prototype.fh=function(t){var e=this.Zr.indexOf(t);this.Zr.splice(e,1)},Cu);function Cu(){var t=this;this.Yr=Promise.resolve(),this.Jr=Promise.resolve(),this.Xr=!1,this.Zr=[],this.th=null,this.eh=!1,this.sh=[],this.ih=new Ou(this,"async_queue_retry"),this.nh=function(){t.rh("async_queue_retry")};var e=zs.nt().window;e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.nh)}function Mu(t,e,n,r,i){this.qr=t,this.Dr=e,this.Ur=n,this.op=r,this.Qr=i,this.Wr=new Ru,this.then=this.Wr.promise.then.bind(this.Wr.promise),this.catch=this.Wr.promise.catch.bind(this.Wr.promise),this.Wr.promise.catch(function(t){})}function ju(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Sr=t,this.Dr=e,this.Cr=n,this.Fr=r,this.Nr=i,this.kr=0,this.$r=null,this.Mr=Date.now(),this.reset()}function Uu(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 qu=(zu.prototype.Ah=function(){return++this.mh},zu.prototype.Ph=function(t){var e=[t,this.Ah()];if(this.buffer.size<this.Rh)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();Uu(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(zu.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),zu),Fu={Vh:!1,gh:0,ph:0,yh:0},Bu=(Gu.Dh=function(t){return new Gu(t,Gu.Ch,Gu.Fh)},Gu);function Gu(t,e,n){this.bh=t,this.vh=e,this.Sh=n}function zu(t){this.Rh=t,this.buffer=new os(Uu),this.mh=0}Bu.Nh=-1,Bu.kh=1048576,Bu.$h=41943040,Bu.Ch=10,Bu.Fh=1e3,Bu.Mh=new Bu(Bu.$h,Bu.Ch,Bu.Fh),Bu.DISABLED=new Bu(Bu.Nh,0,0);var Hu=(Xu.prototype.start=function(t){this.Lh.Bh.bh!==Bu.Nh&&this.qh(t)},Xu.prototype.stop=function(){this.Oh&&(this.Oh.cancel(),this.Oh=null)},Object.defineProperty(Xu.prototype,"Uh",{get:function(){return null!==this.Oh},enumerable:!0,configurable:!0}),Xu.prototype.qh=function(n){var t=this,e=this.xh?3e5:6e4;Ys("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.Oh=this.qr.Br("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.Oh=null,this.xh=!0,t.label=1;case 1:return t.trys.push([1,3,,7]),[4,n.Qh(this.Lh)];case 2:return t.sent(),[3,7];case 3:return"IndexedDbTransactionError"!==(e=t.sent()).name?[3,4]:(Ys("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]);case 4:return[4,Sh(e)];case 5:t.sent(),t.label=6;case 6:return[3,7];case 7:return[4,this.qh(n)];case 8:return t.sent(),[2]}})})})},Xu),Ku=(Wu.prototype.jh=function(t,e){return this.Wh.Kh(t).next(function(t){return Math.floor(e/100*t)})},Wu.prototype.Gh=function(t,e){var n=this;if(0===e)return pu.resolve(wu.vr);var r=new qu(e);return this.Wh.js(t,function(t){return r.Ph(t.sequenceNumber)}).next(function(){return n.Wh.zh(t,function(t){return r.Ph(t)})}).next(function(){return r.maxValue})},Wu.prototype.Hh=function(t,e,n){return this.Wh.Hh(t,e,n)},Wu.prototype.Yh=function(t,e){return this.Wh.Yh(t,e)},Wu.prototype.Jh=function(e,n){var r=this;return this.Bh.bh===Bu.Nh?(Ys("LruGarbageCollector","Garbage collection skipped; disabled"),pu.resolve(Fu)):this.Xh(e).next(function(t){return t<r.Bh.bh?(Ys("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.Bh.bh),Fu):r.Zh(e,n)})},Wu.prototype.Xh=function(t){return this.Wh.Xh(t)},Wu.prototype.Zh=function(e,n){var r,i,o,s,u,a,h,c=this,f=Date.now();return this.jh(e,this.Bh.vh).next(function(t){return i=t>c.Bh.Sh?(Ys("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+c.Bh.Sh+" from "+t),c.Bh.Sh):t,s=Date.now(),c.Gh(e,i)}).next(function(t){return r=t,u=Date.now(),c.Hh(e,r,n)}).next(function(t){return o=t,a=Date.now(),c.Yh(e,r)}).next(function(t){return h=Date.now(),Ws()<=l.DEBUG&&Ys("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"),pu.resolve({Vh:!0,gh:i,ph:o,yh:t})})},Wu);function Wu(t,e){this.Wh=t,this.Bh=e}function Xu(t,e){this.Lh=t,this.qr=e,this.xh=!1,this.Oh=null}function Yu(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Ju(e)),e=Qu(t.get(n),e);return Ju(e)}function Qu(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 Ju(t){return t+""}function Zu(t){var e=t.length;if($s(2<=e),2===e)return $s(""===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)&&Zs(),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:Zs()}o=s+2}return new Cr(r)}var $u,ta=(ha.eo=function(o,t,s){return Ys("SimpleDb","Opening database:",o),new pu(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 xr(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 xr(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){Ys("SimpleDb",'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;s.createOrUpgrade(e,i.transaction,t.oldVersion,Ua).next(function(){Ys("SimpleDb","Database upgrade to version "+Ua+" complete")})}}).Bn()},ha.delete=function(t){return Ys("SimpleDb","Removing database:",t),ca(window.indexedDB.deleteDatabase(t)).Bn()},ha.so=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(ha.io())return!0;if(void 0===window.navigator)return!1;var t=p(),e=ha.to(t),n=0<e&&e<10,r=ha.no(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},ha.io=function(){var t;return"undefined"!=typeof __PRIVATE_process&&"YES"===(null===(t=__PRIVATE_process.__PRIVATE_env)||void 0===t?void 0:t.ro)},ha.ho=function(t,e){return t.store(e)},ha.to=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.no=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=ra.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),pu.reject(t)}).Bn(),r={},n.catch(function(){}),[4,e.ao];case 2:return[2,(r.value=(t.sent(),n),r)];case 3:return i=t.sent(),o="FirebaseError"!==i.name&&u<3,Ys("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),ea=(Object.defineProperty(aa.prototype,"Mn",{get:function(){return this.co},enumerable:!0,configurable:!0}),Object.defineProperty(aa.prototype,"lo",{get:function(){return this._o},enumerable:!0,configurable:!0}),Object.defineProperty(aa.prototype,"cursor",{set:function(t){this.uo=t},enumerable:!0,configurable:!0}),aa.prototype.done=function(){this.co=!0},aa.prototype.do=function(t){this._o=t},aa.prototype.delete=function(){return ca(this.uo.delete())},aa),na=(n(ua,$u=xr),ua),ra=(sa.open=function(t,e,n){return new sa(t.transaction(n,e))},Object.defineProperty(sa.prototype,"ao",{get:function(){return this.fo.promise},enumerable:!0,configurable:!0}),sa.prototype.abort=function(t){t&&this.fo.reject(t),this.aborted||(Ys("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},sa.prototype.store=function(t){var e=this.transaction.objectStore(t);return new ia(e)},sa),ia=(oa.prototype.put=function(t,e){return ca(void 0!==e?(Ys("SimpleDb","PUT",this.store.name,t,e),this.store.put(e,t)):(Ys("SimpleDb","PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},oa.prototype.add=function(t){return Ys("SimpleDb","ADD",this.store.name,t,t),ca(this.store.add(t))},oa.prototype.get=function(e){var n=this;return ca(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Ys("SimpleDb","GET",n.store.name,e,t),t})},oa.prototype.delete=function(t){return Ys("SimpleDb","DELETE",this.store.name,t),ca(this.store.delete(t))},oa.prototype.count=function(){return Ys("SimpleDb","COUNT",this.store.name),ca(this.store.count())},oa.prototype.To=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.Eo(n,function(t,e){r.push(e)}).next(function(){return r})},oa.prototype.Io=function(t,e){Ys("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.wo=!1;var r=this.cursor(n);return this.Eo(r,function(t,e,n){return n.delete()})},oa.prototype.Ro=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.Eo(r,e)},oa.prototype.mo=function(i){var t=this.cursor({});return new pu(function(n,r){t.onerror=function(t){var e=la(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()}})},oa.prototype.Eo=function(t,s){var u=[];return new pu(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 ea(e),r=s(e.primaryKey,e.value,n);if(r instanceof pu){var i=r.catch(function(t){return n.done(),pu.reject(t)});u.push(i)}n.Mn?o():null===n.lo?e.continue():e.continue(n.lo)}else o()}}).next(function(){return pu.Un(u)})},oa.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},oa.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.wo?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},oa);function oa(t){this.store=t}function sa(t){var n=this;this.transaction=t,this.aborted=!1,this.fo=new Ru,this.transaction.oncomplete=function(){n.fo.resolve()},this.transaction.onabort=function(){t.error?n.fo.reject(new na(t.error)):n.fo.resolve()},this.transaction.onerror=function(t){var e=la(t.target.error);n.fo.reject(new na(e))}}function ua(t){var e=this;return(e=$u.call(this,Sr.UNAVAILABLE,"IndexedDB transaction failed: "+t)||this).name="IndexedDbTransactionError",e}function aa(t){this.uo=t,this.co=!1,this._o=null}function ha(t){this.db=t,12.2===ha.to(p())&&Qs("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 ca(t){return new pu(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=la(t.target.error);r(e)}})}var fa=!1;function la(t){var e=ta.to(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 xr("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 fa||(fa=!0,setTimeout(function(){throw r},0)),r}}return t}var pa=(da.Vo=function(t,e,n,r){return $s(""!==t.uid),new da(t.t()?t.uid:"",e,n,r)},da.prototype.po=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return ga(t).Ro({index:Ka.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},da.prototype.yo=function(e,t,n){return this.bo(e).next(function(t){return t.lastStreamToken=n.toBase64(),wa(e).put(t)})},da.prototype.vo=function(t){return this.bo(t).next(function(t){return ei.fromBase64String(t.lastStreamToken)})},da.prototype.So=function(e,n){return this.bo(e).next(function(t){return t.lastStreamToken=n.toBase64(),wa(e).put(t)})},da.prototype.Do=function(h,c,f,l){var p=this,d=ma(h),y=ga(h);return y.add({}).next(function(t){$s("number"==typeof t);for(var e=new hu(t,c,f,l),n=p.serializer.Co(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=Wa.key(p.userId,u.key.path,t);i=i.add(u.key.path.M()),r.push(y.put(n)),r.push(d.put(a,Wa.PLACEHOLDER))}return i.forEach(function(t){r.push(p.rr.Fo(h,t))}),h.er(function(){p.Po[t]=e.keys()}),pu.Un(r).next(function(){return e})})},da.prototype.No=function(t,e){var n=this;return ga(t).get(e).next(function(t){return t?($s(t.userId===n.userId),n.serializer.ko(t)):null})},da.prototype.$o=function(t,n){var r=this;return this.Po[n]?pu.resolve(this.Po[n]):this.No(t,n).next(function(t){if(t){var e=t.keys();return r.Po[n]=e}return null})},da.prototype.Mo=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return ga(t).Ro({index:Ka.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&($s(e.batchId>=i),o=r.serializer.ko(e)),n.done()}).next(function(){return o})},da.prototype.Lo=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return ga(t).Ro({index:Ka.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},da.prototype.xo=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return ga(t).To(Ka.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.ko(t)})})},da.prototype.or=function(u,a){var h=this,t=Wa.prefixForPath(this.userId,a.path),e=IDBKeyRange.lowerBound(t),c=[];return ma(u).Ro({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Zu(i);if(r===h.userId&&a.path.isEqual(s))return ga(u).get(o).next(function(t){if(!t)throw Zs();$s(t.userId===h.userId),c.push(h.serializer.ko(t))});n.done()}).next(function(){return c})},da.prototype.lr=function(r,t){var a=this,h=new os(ru),i=[];return t.forEach(function(u){var t=Wa.prefixForPath(a.userId,u.path),e=IDBKeyRange.lowerBound(t),n=ma(r).Ro({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Zu(i);r===a.userId&&u.path.isEqual(s)?h=h.add(o):n.done()});i.push(n)}),pu.Un(i).next(function(){return a.Oo(r,h)})},da.prototype.Rr=function(t,e){var u=this,a=e.path,h=a.length+1,n=Wa.prefixForPath(this.userId,a),r=IDBKeyRange.lowerBound(n),c=new os(ru);return ma(t).Ro({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],s=Zu(i);r===u.userId&&a.q(s)?s.length===h&&(c=c.add(o)):n.done()}).next(function(){return u.Oo(t,c)})},da.prototype.Oo=function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(ga(e).get(t).next(function(t){if(null===t)throw Zs();$s(t.userId===n.userId),r.push(n.serializer.ko(t))}))}),pu.Un(i).next(function(){return r})},da.prototype.Bo=function(e,n){var r=this;return va(e.qo,this.userId,n).next(function(t){return e.er(function(){r.Uo(n.batchId)}),pu.forEach(t,function(t){return r.Ao.Qo(e,t)})})},da.prototype.Uo=function(t){delete this.Po[t]},da.prototype.Wo=function(n){var o=this;return this.po(n).next(function(t){if(!t)return pu.resolve();var e=IDBKeyRange.lowerBound(Wa.prefixForUser(o.userId)),i=[];return ma(n).Ro({range:e},function(t,e,n){if(t[0]===o.userId){var r=Zu(t[1]);i.push(r)}else n.done()}).next(function(){$s(0===i.length)})})},da.prototype.Fn=function(t,e){return ya(t,this.userId,e)},da.prototype.bo=function(t){var e=this;return wa(t).get(this.userId).next(function(t){return t||new Ha(e.userId,-1,"")})},da);function da(t,e,n,r){this.userId=t,this.serializer=e,this.rr=n,this.Ao=r,this.Po={}}function ya(t,o,e){var n=Wa.prefixForPath(o,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),u=!1;return ma(t).Ro({range:r,wo:!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 va(t,e,n){var r=t.store(Ka.store),i=t.store(Wa.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.Ro({range:s},function(t,e,n){return u++,n.delete()});o.push(a.next(function(){$s(1===u)}));for(var h=[],c=0,f=n.mutations;c<f.length;c++){var l=f[c],p=Wa.key(e,l.key.path,n.batchId);o.push(i.delete(p)),h.push(l.key)}return pu.Un(o).next(function(){return h})}function ga(t){return ph.ho(t,Ka.store)}function ma(t){return ph.ho(t,Wa.store)}function wa(t){return ph.ho(t,Ha.store)}var ba=(Ta.prototype.next=function(){return this.jo+=2,this.jo},Ta.Ko=function(){return new Ta(0)},Ta.Go=function(){return new Ta(-1)},Ta),Ea=(Ia.prototype.zo=function(n){var r=this;return this.Ho(n).next(function(t){var e=new ba(t.highestTargetId);return t.highestTargetId=e.next(),r.Yo(n,t).next(function(){return t.highestTargetId})})},Ia.prototype.Jo=function(t){return this.Ho(t).next(function(t){return Pr.v(new Or(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},Ia.prototype.Xo=function(t){return Aa(t.qo)},Ia.prototype.Zo=function(e,n,r){var i=this;return this.Ho(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.C()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.Yo(e,t)})},Ia.prototype.ta=function(e,n){var r=this;return this.ea(e,n).next(function(){return r.Ho(e).next(function(t){return t.targetCount+=1,r.sa(n,t),r.Yo(e,t)})})},Ia.prototype.ia=function(t,e){return this.ea(t,e)},Ia.prototype.na=function(e,t){var n=this;return this.ra(e,t.targetId).next(function(){return Na(e).delete(t.targetId)}).next(function(){return n.Ho(e)}).next(function(t){return $s(0<t.targetCount),--t.targetCount,n.Yo(e,t)})},Ia.prototype.Hh=function(r,i,o){var s=this,u=0,a=[];return Na(r).Ro(function(t,e){var n=s.serializer.ha(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(u++,a.push(s.na(r,n)))}).next(function(){return pu.Un(a)}).next(function(){return u})},Ia.prototype.js=function(t,r){var i=this;return Na(t).Ro(function(t,e){var n=i.serializer.ha(e);r(n)})},Ia.prototype.Ho=function(t){return _a(t.qo)},Ia.prototype.Yo=function(t,e){return ph.ho(t,eh.store).put(eh.key,e)},Ia.prototype.ea=function(t,e){return Na(t).put(this.serializer.oa(e))},Ia.prototype.sa=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},Ia.prototype.aa=function(t){return this.Ho(t).next(function(t){return t.targetCount})},Ia.prototype.ua=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),s=null;return Na(t).Ro({range:n,index:$a.queryTargetsIndexName},function(t,e,n){var r=o.serializer.ha(e);i.isEqual(r.target)&&(s=r,n.done())}).next(function(){return s})},Ia.prototype.ca=function(n,t,r){var i=this,o=[],s=Sa(n);return t.forEach(function(t){var e=Yu(t.path);o.push(s.put(new th(r,e))),o.push(i.Ao.gn(n,t))}),pu.Un(o)},Ia.prototype._a=function(n,t,r){var i=this,o=Sa(n);return pu.forEach(t,function(t){var e=Yu(t.path);return pu.Un([o.delete([r,e]),i.Ao.yn(n,t)])})},Ia.prototype.ra=function(t,e){var n=Sa(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},Ia.prototype.la=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Sa(t),o=gs();return r.Ro({range:n,wo:!0},function(t,e,n){var r=Zu(t[1]),i=new Qr(r);o=o.add(i)}).next(function(){return o})},Ia.prototype.Fn=function(t,e){var n=Yu(e.path),r=IDBKeyRange.bound([n],[ou(n)],!1,!0),i=0;return Sa(t).Ro({index:th.documentTargetsIndex,wo:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},Ia.prototype.si=function(t,e){var n=this;return Na(t).get(e).next(function(t){return t?n.serializer.ha(t):null})},Ia);function Ia(t,e){this.Ao=t,this.serializer=e}function Ta(t){this.jo=t}function Na(t){return ph.ho(t,$a.store)}function _a(t){return ta.ho(t,eh.store).get(eh.key).next(function(t){return $s(null!==t),t})}function Aa(t){return _a(t).next(function(t){return t.highestListenSequenceNumber})}function Sa(t){return ph.ho(t,th.store)}var xa,ka=(La.prototype.Gn=function(t,e,n){return Ra(t).put(Oa(e),n)},La.prototype.Hn=function(t,e){var n=Ra(t),r=Oa(e);return n.delete(r)},La.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.da(e,t)})},La.prototype.Yn=function(t,e){var n=this;return Ra(t).get(Oa(e)).next(function(t){return n.fa(t)})},La.prototype.Ta=function(t,e){var n=this;return Ra(t).get(Oa(e)).next(function(t){var e=n.fa(t);return e?{Ea:e,size:Pa(t)}:null})},La.prototype.getEntries=function(t,e){var r=this,i=fs();return this.Ia(t,e,function(t,e){var n=r.fa(e);i=i.me(t,n)}).next(function(){return i})},La.prototype.wa=function(t,e){var r=this,i=fs(),o=new Zo(Qr.N);return this.Ia(t,e,function(t,e){var n=r.fa(e);o=n?(i=i.me(t,n),o.me(t,Pa(e))):(i=i.me(t,null),o.me(t,0))}).next(function(){return{Ra:i,ma:o}})},La.prototype.Ia=function(t,e,i){if(e.B())return pu.resolve();var n=IDBKeyRange.bound(e.first().path.W(),e.last().path.W()),o=e.be(),s=o.Ne();return Ra(t).Ro({range:n},function(t,e,n){for(var r=Qr.st(t);s&&Qr.N(s,r)<0;)i(s,null),s=o.Ne();s&&s.isEqual(r)&&(i(s,e),s=o.ke()?o.Ne():null),s?n.do(s.path.W()):n.done()}).next(function(){for(;s;)i(s,null),s=o.ke()?o.Ne():null})},La.prototype.dr=function(t,i,e){var o=this,s=ps(),u=i.path.length+1,n={};if(e.isEqual(Pr.min())){var r=i.path.W();n.range=IDBKeyRange.lowerBound(r)}else{var a=i.path.W(),h=this.serializer.Aa(e);n.range=IDBKeyRange.lowerBound([a,h],!0),n.index=Ja.collectionReadTimeIndex}return Ra(t).Ro(n,function(t,e,n){if(t.length===u){var r=o.serializer.Pa(e);i.path.q(r.key.path)?r instanceof Io&&i.matches(r)&&(s=s.me(r.key,r)):n.done()}}).next(function(){return s})},La.prototype.Va=function(t,e){var r=this,i=cs(),o=this.serializer.Aa(e),n=Ra(t),s=IDBKeyRange.lowerBound(o,!0);return n.Ro({index:Ja.readTimeIndex,range:s},function(t,e){var n=r.serializer.Pa(e);i=i.me(n.key,n),o=e.readTime}).next(function(){return{ga:i,readTime:r.serializer.pa(o)}})},La.prototype.ya=function(t){var r=this,e=Ra(t),i=Pr.min();return e.Ro({index:Ja.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(i=r.serializer.pa(e.readTime)),n.done()}).next(function(){return i})},La.prototype.ba=function(t){return new La.va(this,!!t&&t.Sa)},La.prototype.Da=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},La.prototype.getMetadata=function(t){return Da(t).get(Za.key).next(function(t){return $s(!!t),t})},La.prototype.da=function(t,e){return Da(t).put(Za.key,e)},La.prototype.fa=function(t){if(t){var e=this.serializer.Pa(t);return e instanceof To&&e.version.isEqual(Pr.min())?null:e}return null},La);function La(t,e){this.serializer=t,this.rr=e}function Da(t){return ph.ho(t,Za.store)}function Ra(t){return ph.ho(t,Ja.store)}function Oa(t){return t.path.W()}function Pa(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Zs();e=t.noDocument}return JSON.stringify(e).length}function Va(t,e){var n=this;return(n=xa.call(this)||this).Ca=t,n.Sa=e,n.Fa=new au(function(t){return t.toString()}),n}ka.va=(n(Va,xa=du),Va.prototype.Zn=function(s){var u=this,a=[],h=0,c=new os(function(t,e){return ru(t.j(),e.j())});return this.Wn.forEach(function(t,e){var n=u.Fa.get(t);if(e){var r=u.Ca.serializer.Na(e,u.readTime);c=c.add(t.path.M());var i=Pa(r);h+=i-n,a.push(u.Ca.Gn(s,t,r))}else if(h-=n,u.Sa){var o=u.Ca.serializer.Na(new To(t,Pr.min()),u.readTime);a.push(u.Ca.Gn(s,t,o))}else a.push(u.Ca.Hn(s,t))}),c.forEach(function(t){a.push(u.Ca.rr.Fo(s,t))}),a.push(this.Ca.updateMetadata(s,h)),pu.Un(a)},Va.prototype.Jn=function(t,e){var n=this;return this.Ca.Ta(t,e).next(function(t){return null===t?(n.Fa.set(e,0),null):(n.Fa.set(e,t.size),t.Ea)})},Va.prototype.Xn=function(t,e){var n=this;return this.Ca.wa(t,e).next(function(t){var e=t.Ra;return t.ma.forEach(function(t,e){n.Fa.set(t,e)}),e})},Va);function Ca(t,e){this.seconds=t,this.nanoseconds=e}var Ma=(za.prototype.Fo=function(t,e){return this.ka.add(e),pu.resolve()},za.prototype.wr=function(t,e){return pu.resolve(this.ka.getEntries(e))},za),ja=(Ga.prototype.add=function(t){var e=t.O(),n=t.M(),r=this.index[e]||new os(Cr.N),i=!r.has(n);return this.index[e]=r.add(n),i},Ga.prototype.has=function(t){var e=t.O(),n=t.M(),r=this.index[e];return r&&r.has(n)},Ga.prototype.getEntries=function(t){return(this.index[t]||new os(Cr.N)).W()},Ga),Ua=10,qa=(Ba.prototype.createOrUpgrade=function(n,r,t,e){var i=this;$s(t<e&&0<=t&&e<=Ua);var o,s=new ra(r);t<1&&1<=e&&(n.createObjectStore(Fa.store),(o=n).createObjectStore(Ha.store,{keyPath:Ha.keyPath}),o.createObjectStore(Ka.store,{keyPath:Ka.keyPath,autoIncrement:!0}).createIndex(Ka.userMutationsIndex,Ka.userMutationsKeyPath,{unique:!0}),o.createObjectStore(Wa.store),rh(n),n.createObjectStore(Ja.store));var u,a=pu.resolve();return t<3&&3<=e&&(0!==t&&((u=n).deleteObjectStore(th.store),u.deleteObjectStore($a.store),u.deleteObjectStore(eh.store),rh(n)),a=a.next(function(){return t=s.store(eh.store),e=new eh(0,0,Pr.min().C(),0),t.put(eh.key,e);var t,e})),t<4&&4<=e&&(0!==t&&(a=a.next(function(){return r=n,(i=s).store(Ka.store).To().next(function(t){r.deleteObjectStore(Ka.store),r.createObjectStore(Ka.store,{keyPath:Ka.keyPath,autoIncrement:!0}).createIndex(Ka.userMutationsIndex,Ka.userMutationsKeyPath,{unique:!0});var e=i.store(Ka.store),n=t.map(function(t){return e.put(t)});return pu.Un(n)});var r,i})),a=a.next(function(){n.createObjectStore(ih.store,{keyPath:ih.keyPath})})),t<5&&5<=e&&(a=a.next(function(){return i.removeAcknowledgedMutations(s)})),t<6&&6<=e&&(a=a.next(function(){return n.createObjectStore(Za.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(Ja.store)).createIndex(Ja.readTimeIndex,Ja.readTimeIndexPath,{unique:!1}),t.createIndex(Ja.collectionReadTimeIndex,Ja.collectionReadTimeIndexPath,{unique:!1})})),t<10&&10<=e&&(a=a.next(function(){return i.rewriteCanonicalIds(s)})),a},Ba.prototype.addDocumentGlobal=function(e){var n=0;return e.store(Ja.store).Ro(function(t,e){n+=Pa(e)}).next(function(){var t=new Za(n);return e.store(Za.store).put(Za.key,t)})},Ba.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(Ha.store),e=r.store(Ka.store);return t.To().next(function(t){return pu.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.To(Ka.userMutationsIndex,t).next(function(t){return pu.forEach(t,function(t){$s(t.userId===n.userId);var e=i.serializer.ko(t);return va(r,n.userId,e).next(function(){})})})})})},Ba.prototype.ensureSequenceNumbers=function(t){var s=t.store(th.store),e=t.store(Ja.store);return Aa(t).next(function(i){var o=[];return e.Ro(function(t,e){var n=new Cr(t),r=[0,Yu(n)];o.push(s.get(r).next(function(t){return t?pu.resolve():(e=n,s.put(new th(0,Yu(e),i)));var e}))}).next(function(){return pu.Un(o)})})},Ba.prototype.createCollectionParentIndex=function(t,e){function i(t){if(o.add(t)){var e=t.O(),n=t.M();return r.put({collectionId:e,parent:Yu(n)})}}t.createObjectStore(nh.store,{keyPath:nh.keyPath});var r=e.store(nh.store),o=new ja;return e.store(Ja.store).Ro({wo:!0},function(t,e){var n=new Cr(t);return i(n.M())}).next(function(){return e.store(Wa.store).Ro({wo:!0},function(t,e){t[0];var n=t[1],r=(t[2],Zu(n));return i(r.M())})})},Ba.prototype.rewriteCanonicalIds=function(t){var i=this,o=t.store($a.store);return o.Ro(function(t,e){var n=i.serializer.ha(e),r=i.serializer.oa(n);return o.put(r)})},Ba),Fa=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};function Ba(t){this.serializer=t}function Ga(){this.index={}}function za(){this.ka=new ja}Fa.store="owner",Fa.key="owner";var Ha=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};Ha.store="mutationQueues",Ha.keyPath="userId";var Ka=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Ka.store="mutations",Ka.keyPath="batchId",Ka.userMutationsIndex="userMutationsIndex",Ka.userMutationsKeyPath=["userId","batchId"];var Wa=(Xa.prefixForUser=function(t){return[t]},Xa.prefixForPath=function(t,e){return[t,Yu(e)]},Xa.key=function(t,e,n){return[t,Yu(e),n]},Xa);function Xa(){}Wa.store="documentMutations",Wa.PLACEHOLDER=new Wa;function Ya(t,e){this.path=t,this.readTime=e}function Qa(t,e){this.path=t,this.version=e}var Ja=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};Ja.store="remoteDocuments",Ja.readTimeIndex="readTimeIndex",Ja.readTimeIndexPath="readTime",Ja.collectionReadTimeIndex="collectionReadTimeIndex",Ja.collectionReadTimeIndexPath=["parentPath","readTime"];var Za=function(t){this.byteSize=t};Za.store="remoteDocumentGlobal",Za.key="remoteDocumentGlobalKey";var $a=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};$a.store="targets",$a.keyPath="targetId",$a.queryTargetsIndexName="queryTargetsIndex",$a.queryTargetsKeyPath=["canonicalId","targetId"];var th=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};th.store="targetDocuments",th.keyPath=["targetId","path"],th.documentTargetsIndex="documentTargetsIndex",th.documentTargetsKeyPath=["path","targetId"];var eh=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};eh.key="targetGlobalKey",eh.store="targetGlobal";var nh=function(t,e){this.collectionId=t,this.parent=e};function rh(t){t.createObjectStore(th.store,{keyPath:th.keyPath}).createIndex(th.documentTargetsIndex,th.documentTargetsKeyPath,{unique:!0}),t.createObjectStore($a.store,{keyPath:$a.keyPath}).createIndex($a.queryTargetsIndexName,$a.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(eh.store)}nh.store="collectionParents",nh.keyPath=["collectionId","parent"];var ih=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};ih.store="clientMetadata",ih.keyPath="clientId";var oh=i(i(i([Ha.store,Ka.store,Wa.store,Ja.store,$a.store,Fa.store,eh.store,th.store],[ih.store]),[Za.store]),[nh.store]),sh=(uh.prototype.Fo=function(t,e){var n=this;if(this.$a.has(e))return pu.resolve();var r=e.O(),i=e.M();t.er(function(){n.$a.add(e)});var o={collectionId:r,parent:Yu(i)};return ah(t).put(o)},uh.prototype.wr=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[ou(i),""],!1,!0);return ah(t).To(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(Zu(r.parent))}return o})},uh);function uh(){this.$a=new ja}function ah(t){return ph.ho(t,nh.store)}var hh,ch=(vh.prototype.Pa=function(t){if(t.document)return this.Ma.Ai(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=Qr.st(t.noDocument.path),n=this.La(t.noDocument.readTime);return new To(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}if(t.unknownDocument){var r=Qr.st(t.unknownDocument.path),i=this.La(t.unknownDocument.version);return new No(r,i)}return Zs()},vh.prototype.Na=function(t,e){var n=this.Aa(e),r=t.key.path.M().W();if(t instanceof Io){var i=this.Ma.mi(t),o=t.hasCommittedMutations;return new Ja(null,null,i,o,n,r)}if(t instanceof To){var s=t.key.path.W(),u=this.xa(t.version),a=t.hasCommittedMutations;return new Ja(null,new Ya(s,u),null,a,n,r)}if(t instanceof No){var h=t.key.path.W(),c=this.xa(t.version);return new Ja(new Qa(h,c),null,null,!0,n,r)}return Zs()},vh.prototype.Aa=function(t){var e=t.C();return[e.seconds,e.nanoseconds]},vh.prototype.pa=function(t){var e=new Or(t[0],t[1]);return Pr.v(e)},vh.prototype.xa=function(t){var e=t.C();return new Ca(e.seconds,e.nanoseconds)},vh.prototype.La=function(t){var e=new Or(t.seconds,t.nanoseconds);return Pr.v(e)},vh.prototype.Co=function(t,e){var n=this,r=e.baseMutations.map(function(t){return n.Ma.vi(t)}),i=e.mutations.map(function(t){return n.Ma.vi(t)});return new Ka(t,e.batchId,e.Tn.toMillis(),r,i)},vh.prototype.ko=function(t){var e=this,n=(t.baseMutations||[]).map(function(t){return e.Ma.Fi(t)}),r=t.mutations.map(function(t){return e.Ma.Fi(t)}),i=Or.fromMillis(t.localWriteTimeMs);return new hu(t.batchId,i,n,r)},vh.prototype.ha=function(t){var e,n=this.La(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.La(t.lastLimboFreeSnapshotVersion):Pr.min();return e=void 0!==t.query.documents?this.Ma.Oi(t.query):this.Ma.Wi(t.query),new Vo(e,t.targetId,0,t.lastListenSequenceNumber,n,r,ei.fromBase64String(t.resumeToken))},vh.prototype.oa=function(t){var e,n=this.xa(t.Ee),r=this.xa(t.lastLimboFreeSnapshotVersion);e=t.target.xt()?this.Ma.xi(t.target):this.Ma.Bi(t.target);var i=t.resumeToken.toBase64();return new $a(t.targetId,t.target.canonicalId(),n,i,t.sequenceNumber,r,e)},vh),fh="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",lh=(n(yh,hh=vu),yh),ph=(dh.ho=function(t,e){if(t instanceof lh)return ta.ho(t.qo,e);throw Zs()},dh.prototype.start=function(){var e=this;return ta.eo(this.Ga,Ua,new qa(this.serializer)).then(function(t){return e.Ja=t,e.Xa()}).then(function(){return e.Za(),e.tu(),e.eu(),e.Ja.runTransaction("readonly",[eh.store],function(t){return Aa(t)})}).then(function(t){e.su=new wu(t,e.Ba)}).then(function(){e.qa=!0}).catch(function(t){return e.Ja&&e.Ja.close(),Promise.reject(t)})},dh.prototype.iu=function(n){var t=this;return this.Ka=function(e){return y(t,void 0,void 0,function(){return v(this,function(t){return this.Uh?[2,n(e)]:[2]})})},n(this.isPrimary)},dh.prototype.nu=function(n){var t=this;this.Ja.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]}})})})},dh.prototype.ru=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Sr.Hr(function(){return y(e,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.Uh?[4,this.Xa()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},dh.prototype.Xa=function(){var n=this;return this.Ja.runTransaction("readwrite",oh,function(e){return mh(e).put(new ih(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.hu(e).next(function(t){t||(n.isPrimary=!1,n.Sr.Hr(function(){return n.Ka(!1)}))})}).next(function(){return n.ou(e)}).next(function(t){return n.isPrimary&&!t?n.au(e).next(function(){return!1}):!!t&&n.uu(e).next(function(){return!0})})}).catch(function(t){if(!n.allowTabSynchronization)throw t;return Ys("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.Sr.Hr(function(){return n.Ka(t)}),n.isPrimary=t})},dh.prototype.hu=function(t){var e=this;return gh(t).get(Fa.key).next(function(t){return pu.resolve(e.cu(t))})},dh.prototype._u=function(t){return mh(t).delete(this.clientId)},dh.prototype.lu=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.du(this.ja,18e5)?[3,2]:(this.ja=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var r=dh.ho(t,ih.store);return r.To().next(function(t){var e=i.fu(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return pu.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.Tu(t.clientId))}),t.label=2;case 2:return[2]}})})},dh.prototype.eu=function(){var t=this;this.Wa=this.Sr.Br("client_metadata_refresh",4e3,function(){return t.Xa().then(function(){return t.lu()}).then(function(){return t.eu()})})},dh.prototype.cu=function(t){return!!t&&t.ownerId===this.clientId},dh.prototype.ou=function(e){var i=this;return gh(e).get(Fa.key).next(function(t){if(null!==t&&i.du(t.leaseTimestampMs,5e3)&&!i.Eu(t.ownerId)){if(i.cu(t)&&i.networkEnabled)return!0;if(!i.cu(t)){if(!t.allowTabSynchronization)throw new xr(Sr.FAILED_PRECONDITION,fh);return!1}}return!(!i.networkEnabled||!i.inForeground)||mh(e).To().next(function(t){return void 0===i.fu(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&&Ys("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},dh.prototype.Iu=function(){return y(this,void 0,void 0,function(){var e=this;return v(this,function(t){switch(t.label){case 0:return this.qa=!1,this.wu(),this.Wa&&(this.Wa.cancel(),this.Wa=null),this.Ru(),this.mu(),[4,this.Ja.runTransaction("readwrite",[Fa.store,ih.store],function(t){return e.au(t).next(function(){return e._u(t)})})];case 1:return t.sent(),this.Ja.close(),this.Au(),[2]}})})},dh.prototype.fu=function(t,e){var n=this;return t.filter(function(t){return n.du(t.updateTimeMs,e)&&!n.Eu(t.clientId)})},dh.prototype.Pu=function(){var e=this;return this.Ja.runTransaction("readonly",[ih.store],function(t){return mh(t).To().next(function(t){return e.fu(t,18e5).map(function(t){return t.clientId})})})},dh.clearPersistence=function(n){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return dh.so()?(e=n+dh.za,[4,ta.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(dh.prototype,"Uh",{get:function(){return this.qa},enumerable:!0,configurable:!0}),dh.prototype.Vu=function(t){return pa.Vo(t,this.serializer,this.rr,this.Ao)},dh.prototype.gu=function(){return this.Ha},dh.prototype.pu=function(){return this.ir},dh.prototype.yu=function(){return this.rr},dh.prototype.runTransaction=function(n,t,r){var i=this;Ys("IndexedDbPersistence","Starting transaction:",n);var o,e="readonly"===t?"readonly":"readwrite";return this.Ja.runTransaction(e,oh,function(e){return o=new lh(e,i.su.next()),"readwrite-primary"===t?i.hu(e).next(function(t){return!!t||i.ou(e)}).next(function(t){if(!t)throw Qs("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.Sr.Hr(function(){return i.Ka(!1)}),new xr(Sr.FAILED_PRECONDITION,yu);return r(o)}).next(function(t){return i.uu(e).next(function(){return t})}):i.bu(e).next(function(){return r(o)})}).then(function(t){return o.sr(),t})},dh.prototype.bu=function(t){var e=this;return gh(t).get(Fa.key).next(function(t){if(null!==t&&e.du(t.leaseTimestampMs,5e3)&&!e.Eu(t.ownerId)&&!e.cu(t)&&!t.allowTabSynchronization)throw new xr(Sr.FAILED_PRECONDITION,fh)})},dh.prototype.uu=function(t){var e=new Fa(this.clientId,this.allowTabSynchronization,Date.now());return gh(t).put(Fa.key,e)},dh.so=function(){return ta.so()},dh.vu=function(t){var e=t.ii.projectId;return t.ii.ln||(e+="."+t.ii.database),"firestore/"+t.persistenceKey+"/"+e+"/"},dh.prototype.au=function(t){var e=this,n=gh(t);return n.get(Fa.key).next(function(t){return e.cu(t)?(Ys("IndexedDbPersistence","Releasing primary lease."),n.delete(Fa.key)):pu.resolve()})},dh.prototype.du=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(Qs("Detected an update time that is in the future: "+t+" > "+n),1))},dh.prototype.Za=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Qa=function(){t.Sr.Hr(function(){return t.inForeground="visible"===t.document.visibilityState,t.Xa()})},this.document.addEventListener("visibilitychange",this.Qa),this.inForeground="visible"===this.document.visibilityState)},dh.prototype.Ru=function(){this.Qa&&(this.document.removeEventListener("visibilitychange",this.Qa),this.Qa=null)},dh.prototype.tu=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.Ua=function(){t.wu(),t.Sr.Hr(function(){return t.Iu()})},this.window.addEventListener("unload",this.Ua))},dh.prototype.mu=function(){this.Ua&&(this.window.removeEventListener("unload",this.Ua),this.Ua=null)},dh.prototype.Eu=function(t){try{var e=null!==this.Ya.getItem(this.Tu(t));return Ys("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Qs("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},dh.prototype.wu=function(){try{this.Ya.setItem(this.Tu(this.clientId),String(Date.now()))}catch(t){Qs("Failed to set zombie client id.",t)}},dh.prototype.Au=function(){try{this.Ya.removeItem(this.Tu(this.clientId))}catch(t){}},dh.prototype.Tu=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},dh);function dh(t,e,n,r,i,o,s,u){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Sr=o,this.Ba=u,this.qa=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Ua=null,this.inForeground=!1,this.Qa=null,this.Wa=null,this.ja=Number.NEGATIVE_INFINITY,this.Ka=function(t){return Promise.resolve()},!dh.so())throw new xr(Sr.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");if(this.Ao=new wh(this,i),this.Ga=e+dh.za,this.serializer=new ch(s),this.document=r.document,this.Ha=new Ea(this.Ao,this.serializer),this.rr=new sh,this.ir=new ka(this.serializer,this.rr),!r.window||!r.window.localStorage)throw new xr(Sr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.Ya=this.window.localStorage}function yh(t,e){var n=this;return(n=hh.call(this)||this).qo=t,n.Oa=e,n}function vh(t){this.Ma=t}function gh(t){return t.store(Fa.store)}function mh(t){return t.store(ih.store)}ph.za="main";var wh=(bh.prototype.Kh=function(t){var n=this.Du(t);return this.db.gu().aa(t).next(function(e){return n.next(function(t){return e+t})})},bh.prototype.Du=function(t){var e=0;return this.zh(t,function(t){e++}).next(function(){return e})},bh.prototype.js=function(t,e){return this.db.gu().js(t,e)},bh.prototype.zh=function(t,n){return this.Cu(t,function(t,e){return n(e)})},bh.prototype.Fu=function(t){this.Su=t},bh.prototype.gn=function(t,e){return Eh(t,e)},bh.prototype.yn=function(t,e){return Eh(t,e)},bh.prototype.Hh=function(t,e,n){return this.db.gu().Hh(t,e,n)},bh.prototype.Qo=function(t,e){return Eh(t,e)},bh.prototype.Nu=function(t,e){return this.Su.Fn(e)?pu.resolve(!0):(r=e,i=!1,wa(n=t).mo(function(t){return ya(n,t,r).next(function(t){return t&&(i=!0),pu.resolve(!t)})}).next(function(){return i}));var n,r,i},bh.prototype.Yh=function(r,i){var o=this,s=this.db.pu().ba(),u=[],a=0;return this.Cu(r,function(e,t){if(t<=i){var n=o.Nu(r,e).next(function(t){if(!t)return a++,s.Yn(r,e).next(function(){return s.Hn(e),Sa(r).delete([0,Yu(e.path)])})});u.push(n)}}).next(function(){return pu.Un(u)}).next(function(){return s.apply(r)}).next(function(){return a})},bh.prototype.removeTarget=function(t,e){var n=e.Ie(t.Oa);return this.db.gu().ia(t,n)},bh.prototype.ku=function(t,e){return Eh(t,e)},bh.prototype.Cu=function(t,o){var s,e=Sa(t),u=wu.vr;return e.Ro({index:th.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(u!==wu.vr&&o(new Qr(Zu(s)),u),u=i,s=r):u=wu.vr}).next(function(){u!==wu.vr&&o(new Qr(Zu(s)),u)})},bh.prototype.Xh=function(t){return this.db.pu().Da(t)},bh);function bh(t,e){this.db=t,this.Su=null,this.Lh=new Ku(this,e)}function Eh(t,e){return Sa(t).put((n=e,r=t.Oa,new th(0,Yu(n.path),r)));var n,r}var Ih=(Th.prototype.start=function(){return Promise.resolve()},Th.prototype.Qu=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.nr,m=this.qu,[4,this.persistence.runTransaction("Handle user change","readonly",function(v){var g;return r.nr.xo(v).next(function(t){return g=t,e=r.persistence.Vu(i),m=new gu(r.Bu,e,r.persistence.yu()),e.xo(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.cr(v,r).next(function(t){return{Wu:t,ju:e,Ku:n}})})})];case 1:return n=t.sent(),[2,(this.nr=e,this.qu=m,this.$u.Uu(this.qu),n)]}})})},Th.prototype.Gu=function(u){var a,h=this,c=Or.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.qu.cr(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.nr.Do(s,c,e,u)})}).then(function(t){var e=t.In(a);return{batchId:t.batchId,Wn:e}})},Th.prototype.yo=function(r){var i=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var e=r.batch.keys(),n=i.Bu.ba({Sa:!0});return i.nr.yo(t,r.batch,r.streamToken).next(function(){return i.zu(t,r,n)}).next(function(){return n.apply(t)}).next(function(){return i.nr.Wo(t)}).next(function(){return i.qu.cr(t,e)})})},Th.prototype.Hu=function(t){var r=this;return this.persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return r.nr.No(e,t).next(function(t){return $s(null!==t),n=t.keys(),r.nr.Bo(e,t)}).next(function(){return r.nr.Wo(e)}).next(function(){return r.qu.cr(e,n)})})},Th.prototype.Lo=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e.nr.Lo(t)})},Th.prototype.vo=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly",function(t){return e.nr.vo(t)})},Th.prototype.So=function(e){var n=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary",function(t){return n.nr.So(t,e)})},Th.prototype.Jo=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.Ha.Jo(t)})},Th.prototype.Yu=function(a){var h=this,c=a.Ee,f=this.Lu;return this.persistence.runTransaction("Apply remote event","readwrite-primary",function(o){var i=h.Bu.ba({Sa:!0});f=h.Lu;var s=[];a.as.forEach(function(t,e){var n=f.get(e);if(n){s.push(h.Ha._a(o,t.Is,e).next(function(){return h.Ha.ca(o,t.Ts,e)}));var r=t.resumeToken;if(0<r.rt()){var i=n.we(r,c).Ie(o.Oa);f=f.me(e,i),Th.Ju(n,i,t)&&s.push(h.Ha.ia(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 To&&e.version.isEqual(Pr.min())?(i.Hn(t,c),u=u.me(t,e)):null==n||0<e.version.S(n.version)||0===e.version.S(n.version)&&n.hasPendingWrites?(i.Gn(e,c),u=u.me(t,e)):Ys("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),a._s.has(t)&&s.push(h.persistence.Ao.ku(o,t))})})),!c.isEqual(Pr.min())){var t=h.Ha.Jo(o).next(function(t){return h.Ha.Zo(o,o.Oa,c)});s.push(t)}return pu.Un(s).next(function(){return i.apply(o)}).next(function(){return h.qu._r(o,u)})}).then(function(t){return h.Lu=f,t})},Th.Ju=function(t,e,n){return $s(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},Th.prototype.Zu=function(t){for(var n=this,e=0,r=t;e<r.length;e++){var i=r[e],o=i.targetId;if(this.Mu.pn(i.Ar,o),this.Mu.vn(i.Pr,o),!i.fromCache){var s=this.Lu.get(o),u=s.Ee,a=s.Re(u);this.Lu=this.Lu.me(o,a)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(e){return pu.forEach(t,function(t){return pu.forEach(t.Pr,function(t){return n.persistence.Ao.yn(e,t)})})})},Th.prototype.tc=function(e){var n=this;return this.persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===e&&(e=-1),n.nr.Mo(t,e)})},Th.prototype.ec=function(e){var n=this;return this.persistence.runTransaction("read document","readonly",function(t){return n.qu.hr(t,e)})},Th.prototype.sc=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite",function(e){var n;return i.Ha.ua(e,r).next(function(t){return t?(n=t,pu.resolve(n)):i.Ha.zo(e).next(function(t){return n=new Vo(r,t,0,e.Oa),i.Ha.ta(e,n).next(function(){return n})})})}).then(function(t){return null===i.Lu.get(t.targetId)&&(i.Lu=i.Lu.me(t.targetId,t),i.xu.set(r,t.targetId)),t})},Th.prototype.ua=function(t,e){var n=this.xu.get(e);return void 0!==n?pu.resolve(this.Lu.get(n)):this.Ha.ua(t,e)},Th.prototype.ic=function(n,r){var i=this,o=this.Lu.get(n),t=r?"readwrite":"readwrite-primary";return this.persistence.runTransaction("Release target",t,function(e){var t=i.Mu.Sn(n);return r?pu.resolve():pu.forEach(t,function(t){return i.persistence.Ao.yn(e,t)}).next(function(){i.persistence.Ao.removeTarget(e,o)})}).then(function(){i.Lu=i.Lu.remove(n),i.xu.delete(o.target)})},Th.prototype.nc=function(t,n){var r=this,i=Pr.min(),o=gs();return this.persistence.runTransaction("Execute query","readonly",function(e){return r.ua(e,t.ee()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.Ha.la(e,t.targetId).next(function(t){o=t})}).next(function(){return r.$u.dr(e,t,n?i:Pr.min(),n?o:gs())}).next(function(t){return{documents:t,rc:o}})})},Th.prototype.hc=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly",function(t){return n.Ha.la(t,e)})},Th.prototype.zu=function(t,i,o){var e=this,s=i.batch,n=s.keys(),u=pu.resolve();return n.forEach(function(r){u=u.next(function(){return o.Yn(t,r)}).next(function(t){var e=t,n=i.Rn.get(r);$s(null!==n),(!e||e.version.S(n)<0)&&(e=s.at(r,e,i))&&o.Gn(e,i.wn)})}),u.next(function(){return e.nr.Bo(t,s)})},Th.prototype.Qh=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(t){return e.Jh(t,n.Lu)})},Th);function Th(t,e,n){this.persistence=t,this.$u=e,this.Mu=new fu,this.Lu=new Zo(ru),this.xu=new au(function(t){return t.canonicalId()}),this.Ou=Pr.min(),this.persistence.Ao.Fu(this.Mu),this.nr=t.Vu(n),this.Bu=t.pu(),this.Ha=t.gu(),this.qu=new gu(this.Bu,this.nr,this.persistence.yu()),this.$u.Uu(this.qu)}Ih.Xu=3e8;var Nh,_h=(n(Ah,Nh=Ih),Ah.prototype.start=function(){return this.oc()},Ah.prototype.ac=function(t){var n=this;return this.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return n.nr.$o(e,t).next(function(t){return t?n.qu.cr(e,t):pu.resolve(null)})})},Ah.prototype.uc=function(t){this.nr.Uo(t)},Ah.prototype.ru=function(t){this.persistence.ru(t)},Ah.prototype.Pu=function(){return this.persistence.Pu()},Ah.prototype.cc=function(e){var n=this,t=this.Lu.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly",function(t){return n.Ha.si(t,e).next(function(t){return t?t.target:null})})},Ah.prototype.Va=function(){var r=this;return this.persistence.runTransaction("Get new document changes","readonly",function(t){return r.Bu.Va(t,r.Ou)}).then(function(t){var e=t.ga,n=t.readTime;return r.Ou=n,e})},Ah.prototype.oc=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.ya(t)})];case 1:return e.Ou=t.sent(),[2]}})})},Ah);function Ah(t,e,n){var r=this;return(r=Nh.call(this,t,e,n)||this).persistence=t,r.nr=t.Vu(n),r.Bu=t.pu(),r.Ha=t.gu(),r}function Sh(e){return y(this,void 0,void 0,function(){return v(this,function(t){if(e.code!==Sr.FAILED_PRECONDITION||e.message!==yu)throw e;return Ys("LocalStore","Unexpectedly lost primary lease"),[2]})})}function xh(t,e){if(0!==e.length)throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Hh(e.length,"argument")+".")}function kh(t,e,n){if(e.length!==n)throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires "+Hh(n,"argument")+", but was called with "+Hh(e.length,"argument")+".")}function Lh(t,e,n){if(e.length<n)throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Hh(n,"argument")+", but was called with "+Hh(e.length,"argument")+".")}function Dh(t,e,n,r){if(e.length<n||e.length>r)throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Hh(e.length,"argument")+".")}function Rh(t,e,n,r){Mh(t,e,zh(n)+" argument",r)}function Oh(t,e,n,r){void 0!==r&&Rh(t,e,n,r)}function Ph(t,e,n,r){Mh(t,e,n+" option",r)}function Vh(t,e,n,r){void 0!==r&&Ph(t,e,n,r)}function Ch(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(Uh(s))}var u=Uh(n);throw new xr(Sr.INVALID_ARGUMENT,"Invalid value "+u+" provided to function "+t+'() for option "'+e+'". Acceptable values: '+r.join(", "))}(t,n,r)}function Mh(t,e,n,r){if(!("object"===e?jh(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=Uh(r);throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function jh(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function Uh(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":Zs();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 qh(t,e,n){if(void 0===n)throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+zh(e)+" argument, but it was undefined.")}function Fh(n,t,r){$r(t,function(t,e){if(r.indexOf(t)<0)throw new xr(Sr.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function Bh(t,e,n,r){var i=Uh(r);return new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+zh(n)+" argument to be a "+e+", but it was: "+i)}function Gh(t,e,n){if(n<=0)throw new xr(Sr.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+zh(e)+" argument to be a positive number, but it was: "+n+".")}function zh(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Hh(t,e){return t+" "+e+(1===t?"":"s")}function Kh(){if("undefined"==typeof Uint8Array)throw new xr(Sr.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Wh(){if(!zs.nt()._c)throw new xr(Sr.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var Xh=(Jh.fromBase64String=function(t){kh("Blob.fromBase64String",arguments,1),Rh("Blob.fromBase64String","string",1,t),Wh();try{return new Jh(ei.fromBase64String(t))}catch(t){throw new xr(Sr.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Jh.fromUint8Array=function(t){if(kh("Blob.fromUint8Array",arguments,1),Kh(),!(t instanceof Uint8Array))throw Bh("Blob.fromUint8Array","Uint8Array",1,t);return new Jh(ei.fromUint8Array(t))},Jh.prototype.toBase64=function(){return kh("Blob.toBase64",arguments,0),Wh(),this.lc.toBase64()},Jh.prototype.toUint8Array=function(){return kh("Blob.toUint8Array",arguments,0),Kh(),this.lc.toUint8Array()},Jh.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Jh.prototype.isEqual=function(t){return this.lc.isEqual(t.lc)},Jh),Yh=(Qh.documentId=function(){return Qh.fc},Qh.prototype.isEqual=function(t){if(!(t instanceof Qh))throw Bh("isEqual","FieldPath",1,t);return this.dc.isEqual(t.dc)},Qh);function Qh(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(){if(!(t instanceof Array)||t.length<1)throw new xr(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(Rh("FieldPath","string",n,t[n]),0===t[n].length)throw new xr(Sr.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.dc=new Xr(t)}function Jh(t){Wh(),this.lc=t}Yh.fc=new Yh(Xr.J().j());var Zh,$h,tc,ec,nc,rc=new RegExp("[~\\*/\\[\\]]"),ic=function(t){this.Tc=t},oc=(n(Ec,nc=ic),Ec.prototype.Di=function(t){if(2!==t.Ec)throw 1===t.Ec?t.Ic("FieldValue.delete() can only appear at the top level of your update data"):t.Ic("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");return t.Vt.push(t.path),null},Ec.prototype.isEqual=function(t){return t instanceof Ec},Ec),sc=(n(bc,ec=ic),bc.prototype.Di=function(t){return new qi(t.path,Ni.instance)},bc.prototype.isEqual=function(t){return t instanceof bc},bc),uc=(n(wc,tc=ic),wc.prototype.Di=function(t){var n=t.Rc({Ec:3,methodName:this.Tc}),e=this.wc.map(function(t,e){return Sc(t,n.mc(e))}),r=new Ai(e);return new qi(t.path,r)},wc.prototype.isEqual=function(t){return this===t},wc),ac=(n(mc,$h=ic),mc.prototype.Di=function(t){var n=t.Rc({Ec:3,methodName:this.Tc}),e=this.wc.map(function(t,e){return Sc(t,n.mc(e))}),r=new Si(e);return new qi(t.path,r)},mc.prototype.isEqual=function(t){return this===t},mc),hc=(n(gc,Zh=ic),gc.prototype.Di=function(t){t.Rc({methodName:this.Tc});var e=Sc(this.Ac,t),n=new xi(t.serializer,e);return new qi(t.path,n)},gc.prototype.isEqual=function(t){return this===t},gc),cc=(Object.defineProperty(vc.prototype,"latitude",{get:function(){return this.Pc},enumerable:!0,configurable:!0}),Object.defineProperty(vc.prototype,"longitude",{get:function(){return this.Vc},enumerable:!0,configurable:!0}),vc.prototype.isEqual=function(t){return this.Pc===t.Pc&&this.Vc===t.Vc},vc.prototype.p=function(t){return ru(this.Pc,t.Pc)||ru(this.Vc,t.Vc)},vc),fc=/^__.*__$/,lc=(yc.prototype.gc=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 Hi(t,this.fieldTransforms)),n},yc),pc=(dc.prototype.gc=function(t,e){var n=[new zi(t,this.data,this.Vt,e)];return 0<this.fieldTransforms.length&&n.push(new Hi(t,this.fieldTransforms)),n},dc);function dc(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}function yc(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}function vc(t,e){if(kh("GeoPoint",arguments,2),Rh("GeoPoint","number",1,t),Rh("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new xr(Sr.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new xr(Sr.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.Pc=t,this.Vc=e}function gc(t){var e=this;return(e=Zh.call(this,"FieldValue.increment")||this).Ac=t,e}function mc(t){var e=this;return(e=$h.call(this,"FieldValue.arrayRemove")||this).wc=t,e}function wc(t){var e=this;return(e=tc.call(this,"FieldValue.arrayUnion")||this).wc=t,e}function bc(){return ec.call(this,"FieldValue.serverTimestamp")||this}function Ec(){return nc.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 Zs()}}var Tc=(Object.defineProperty(Ac.prototype,"path",{get:function(){return this.settings.path},enumerable:!0,configurable:!0}),Object.defineProperty(Ac.prototype,"Ec",{get:function(){return this.settings.Ec},enumerable:!0,configurable:!0}),Ac.prototype.Rc=function(t){return new Ac(Object.assign(Object.assign({},this.settings),t),this.ii,this.serializer,this.fieldTransforms,this.Vt)},Ac.prototype.yc=function(t){var e=null==this.path?null:this.path.child(t),n=this.Rc({path:e,bc:!1});return n.vc(t),n},Ac.prototype.Sc=function(t){var e=null==this.path?null:this.path.child(t),n=this.Rc({path:e,bc:!1});return n.pc(),n},Ac.prototype.mc=function(t){return this.Rc({path:null,bc:!0})},Ac.prototype.Ic=function(t){var e=null===this.path||this.path.B()?"":" (found in field "+this.path.toString()+")";return new xr(Sr.INVALID_ARGUMENT,"Function "+this.settings.methodName+"() called with invalid data. "+t+e)},Ac.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)})},Ac.prototype.pc=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.vc(this.path.get(t))},Ac.prototype.vc=function(t){if(0===t.length)throw this.Ic("Document fields must not be empty");if(Ic(this.Ec)&&fc.test(t))throw this.Ic('Document fields cannot begin and end with "__"')},Ac),Nc=(_c.prototype.Cc=function(t,e){var n=this.Fc(0,t);Lc("Data must be an object, but it was:",n,e);var r=xc(e,n);return new lc(new Xi(r),null,n.fieldTransforms)},_c.prototype.Nc=function(t,e,n){var r=this.Fc(2,t);Lc("Data must be an object, but it was:",r,e);var i,o,s=xc(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 Yh)f=c.dc;else{if("string"!=typeof c)throw Zs();f=Rc(t,c)}if(!r.contains(f))throw new xr(Sr.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");Oc(u,f)||u.push(f)}i=new Ui(u),o=r.fieldTransforms.filter(function(t){return i.dt(t.field)})}else i=new Ui(r.Vt),o=r.fieldTransforms;return new lc(new Xi(s),i,o)},_c.prototype.kc=function(o,t){var s=this.Fc(1,o);Lc("Data must be an object, but it was:",s,t);var u=[],a=new Yi;$r(t,function(t,e){var n=Rc(o,t),r=s.Sc(n);if(e instanceof oc)u.push(n);else{var i=Sc(e,r);null!=i&&(u.push(n),a.set(n,i))}});var e=new Ui(u);return new pc(a.yt(),e,s.fieldTransforms)},_c.prototype.$c=function(t,e,n,r){var i=this.Fc(1,t),o=[Dc(t,e)],s=[n];if(r.length%2!=0)throw new xr(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(Dc(t,r[u])),s.push(r[u+1]);for(var a=[],h=new Yi,c=o.length-1;0<=c;--c)if(!Oc(a,o[c])){var f=o[c],l=s[c],p=i.Sc(f);if(l instanceof oc)a.push(f);else{var d=Sc(l,p);null!=d&&(a.push(f),h.set(f,d))}}var y=new Ui(a);return new pc(h.yt(),y,i.fieldTransforms)},_c.prototype.Fc=function(t,e){return new Tc({Ec:t,methodName:e,path:Xr.G,bc:!1},this.ii,this.serializer)},_c.prototype.Mc=function(t,e,n){return void 0===n&&(n=!1),Sc(e,this.Fc(n?4:3,t))},_c);function _c(t,e){this.ii=t,this.serializer=e||zs.nt().Dc(t)}function Ac(t,e,n,r,i){this.settings=t,this.ii=e,this.serializer=n,void 0===r&&this.pc(),this.fieldTransforms=r||[],this.Vt=i||[]}function Sc(s,t){if(kc(s))return Lc("Unsupported field value:",t,s),xc(s,t);if(s instanceof ic)return function(t,e){if(!Ic(e.Ec))throw e.Ic(t.Tc+"() can only be used with update() and set()");if(null===e.path)throw e.Ic(t.Tc+"() 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.bc&&4!==t.Ec)throw t.Ic("Nested arrays are not supported");return function(t){for(var e=[],n=0,r=0,i=s;r<i.length;r++){var o=Sc(i[r],t.mc(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=Or.fromDate(t);return{timestampValue:e.serializer.C(n)}}if(t instanceof Or){var r=new Or(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:e.serializer.C(r)}}if(t instanceof cc)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Xh)return{bytesValue:e.serializer.ui(t)};if(t instanceof dl){var i=e.ii,o=t.firestore.Lc;if(!o.isEqual(i))throw e.Ic("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:e.serializer._i(t.xc.path,t.firestore.Lc)}}throw e.Ic("Unsupported field value: "+Uh(t))}(s,t)}function xc(t,r){var i={};return ti(t)?r.path&&0<r.path.length&&r.Vt.push(r.path):$r(t,function(t,e){var n=Sc(e,r.yc(t));null!=n&&(i[t]=n)}),{mapValue:{fields:i}}}function kc(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Or||t instanceof cc||t instanceof Xh||t instanceof dl||t instanceof ic)}function Lc(t,e,n){if(!kc(n)||!jh(n)){var r=Uh(n);throw"an object"===r?e.Ic(t+" a custom object"):e.Ic(t+" "+r)}}function Dc(t,e){if(e instanceof Yh)return e.dc;if("string"==typeof e)return Rc(t,e);throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Rc(t,e){try{return function(e){if(0<=e.search(rc))throw new xr(Sr.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(Yh.bind.apply(Yh,i([void 0],e.split("."))))}catch(t){throw new xr(Sr.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).dc}catch(e){var n=e instanceof Error?e.message:e.toString();throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. "+n)}}function Oc(t,e){return t.some(function(t){return t.isEqual(e)})}var Pc,Vc,Cc,Mc=(Qc.prototype.Wc=function(){return 1===this.state||2===this.state||4===this.state},Qc.prototype.jc=function(){return 2===this.state},Qc.prototype.start=function(){3!==this.state?this.auth():this.Kc()},Qc.prototype.stop=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.Wc()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Qc.prototype.Gc=function(){this.state=0,this.ih.reset()},Qc.prototype.zc=function(){var t=this;this.jc()&&null===this.Qc&&(this.Qc=this.Sr.Br(this.Oc,6e4,function(){return t.Hc()}))},Qc.prototype.Yc=function(t){this.Jc(),this.stream.send(t)},Qc.prototype.Hc=function(){return y(this,void 0,void 0,function(){return v(this,function(t){return this.jc()?[2,this.close(0)]:[2]})})},Qc.prototype.Jc=function(){this.Qc&&(this.Qc.cancel(),this.Qc=null)},Qc.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.Jc(),this.ih.cancel(),this.Uc++,3!==e?this.ih.reset():n&&n.code===Sr.RESOURCE_EXHAUSTED?(Qs(n.toString()),Qs("Using maximum backoff delay to prevent overloading the backend."),this.ih.Lr()):n&&n.code===Sr.UNAUTHENTICATED&&this.qc._(),null!==this.stream&&(this.Xc(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.Zc(n)];case 1:return t.sent(),[2]}})})},Qc.prototype.Xc=function(){},Qc.prototype.auth=function(){var n=this;this.state=1;var t=this.t_(this.Uc),e=this.Uc;this.qc.getToken().then(function(t){n.Uc===e&&n.e_(t)},function(e){t(function(){var t=new xr(Sr.UNKNOWN,"Fetching auth token failed: "+e.message);return n.s_(t)})})},Qc.prototype.e_=function(t){var e=this,n=this.t_(this.Uc);this.stream=this.i_(t),this.stream.n_(function(){n(function(){return e.state=2,e.listener.n_()})}),this.stream.Zc(function(t){n(function(){return e.s_(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Qc.prototype.Kc=function(){var t=this;this.state=4,this.ih.xr(function(){return y(t,void 0,void 0,function(){return v(this,function(t){return this.state=0,this.start(),[2]})})})},Qc.prototype.s_=function(t){return Ys("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},Qc.prototype.t_=function(e){var n=this;return function(t){n.Sr.Hr(function(){return n.Uc===e?t():(Ys("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Qc),jc=(n(Yc,Cc=Mc),Yc.prototype.i_=function(t){return this.Bc.r_("Listen",t)},Yc.prototype.onMessage=function(t){this.ih.reset();var e=this.serializer.pi(t),n=this.serializer.bi(t);return this.listener.h_(e,n)},Yc.prototype.o_=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.Yc(e)},Yc.prototype.a_=function(t){var e={};e.database=this.serializer.wi,e.removeTarget=t,this.Yc(e)},Yc),Uc=(n(Xc,Vc=Mc),Object.defineProperty(Xc.prototype,"c_",{get:function(){return this.u_},enumerable:!0,configurable:!0}),Xc.prototype.start=function(){this.u_=!1,Vc.prototype.start.call(this)},Xc.prototype.Xc=function(){this.u_&&this.__([])},Xc.prototype.i_=function(t){return this.Bc.r_("Write",t)},Xc.prototype.onMessage=function(t){if($s(!!t.streamToken),this.lastStreamToken=this.serializer.ci(t.streamToken),this.u_){this.ih.reset();var e=this.serializer.Li(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.l_(n,e)}return $s(!t.writeResults||0===t.writeResults.length),this.u_=!0,this.listener.d_()},Xc.prototype.f_=function(){var t={};t.database=this.serializer.wi,this.Yc(t)},Xc.prototype.__=function(t){var e=this,n={streamToken:this.serializer.ui(this.lastStreamToken),writes:t.map(function(t){return e.serializer.vi(t)})};this.Yc(n)},Xc),qc=(n(Wc,Pc=function(){this.T_=void 0}),Wc.prototype.E_=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Bc.E_(e,n,t)}).catch(function(t){throw t.code===Sr.UNAUTHENTICATED&&r.credentials._(),t})},Wc.prototype.I_=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.Bc.I_(e,n,t)}).catch(function(t){throw t.code===Sr.UNAUTHENTICATED&&r.credentials._(),t})},Wc),Fc=(Kc.prototype.V_=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.g_(),0<this.mutations.length)throw new xr(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.I_("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());$s(!!e),o.push(e)}),o)]}})})}(this.w_,r)];case 1:return[2,((e=t.sent()).forEach(function(t){t instanceof To||t instanceof Io?n.p_(t):Zs()}),e)]}})})},Kc.prototype.set=function(t,e){this.write(e.gc(t,this.Rt(t))),this.P_.add(t)},Kc.prototype.update=function(t,e){try{this.write(e.gc(t,this.y_(t)))}catch(t){this.A_=t}this.P_.add(t)},Kc.prototype.delete=function(t){this.write([new Ki(t,this.Rt(t))]),this.P_.add(t)},Kc.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.g_(),this.A_)throw this.A_;return e=this.R_,this.mutations.forEach(function(t){e=e.remove(t.key)}),e.forEach(function(t,e){n.mutations.push(new Wi(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.E_("Commit",n)];case 1:return r=t.sent(),[2,e.serializer.Li(r.writeResults,r.commitTime)]}})})}(this.w_,this.mutations)];case 1:return t.sent(),this.m_=!0,[2]}})})},Kc.prototype.p_=function(t){var e;if(t instanceof Io)e=t.version;else{if(!(t instanceof To))throw Zs();e=Pr.min()}var n=this.R_.get(t.key);if(null!==n){if(!e.isEqual(n))throw new xr(Sr.ABORTED,"Document version changed between two reads.")}else this.R_=this.R_.me(t.key,e)},Kc.prototype.Rt=function(t){var e=this.R_.get(t);return!this.P_.has(t)&&e?Fi.updateTime(e):Fi.ft()},Kc.prototype.y_=function(t){var e=this.R_.get(t);if(this.P_.has(t)||!e)return Fi.exists(!0);if(e.isEqual(Pr.min()))throw new xr(Sr.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Fi.updateTime(e)},Kc.prototype.write=function(t){this.g_(),this.mutations=this.mutations.concat(t)},Kc.prototype.g_=function(){},Kc),Bc=(Hc.prototype.C_=function(){var t=this;0===this.v_&&(this.F_("Unknown"),this.S_=this.qr.Br("online_state_timeout",1e4,function(){return t.S_=null,t.N_("Backend didn't respond within 10 seconds."),t.F_("Offline"),Promise.resolve()}))},Hc.prototype.k_=function(t){"Online"===this.state?this.F_("Unknown"):(this.v_++,1<=this.v_&&(this.M_(),this.N_("Connection failed 1 times. Most recent error: "+t.toString()),this.F_("Offline")))},Hc.prototype.set=function(t){this.M_(),this.v_=0,"Online"===t&&(this.D_=!1),this.F_(t)},Hc.prototype.F_=function(t){t!==this.state&&(this.state=t,this.b_(t))},Hc.prototype.N_=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.D_?(Qs(e),this.D_=!1):Ys("OnlineStateTracker",e)},Hc.prototype.M_=function(){null!==this.S_&&(this.S_.cancel(),this.S_=null)},Hc),Gc=(zc.prototype.start=function(){return this.enableNetwork()},zc.prototype.enableNetwork=function(){return this.networkEnabled=!0,this.el()},zc.prototype.el=function(){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:return this.W_()?(e=this.J_,[4,this.L_.vo()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this.sl()?this.il():this.K_.set("Unknown"),[4,this.nl()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},zc.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.rl()];case 1:return t.sent(),this.K_.set("Offline"),[2]}})})},zc.prototype.rl=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return[4,this.J_.stop()];case 1:return t.sent(),[4,this.G_.stop()];case 2:return t.sent(),0<this.x_.length&&(Ys("RemoteStore","Stopping write stream with "+this.x_.length+" pending writes"),this.x_=[]),this.hl(),[2]}})})},zc.prototype.Iu=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return Ys("RemoteStore","RemoteStore shutting down."),this.networkEnabled=!1,[4,this.rl()];case 1:return t.sent(),this.U_.Iu(),this.K_.set("Unknown"),[2]}})})},zc.prototype.listen=function(t){this.O_.has(t.targetId)||(this.O_.set(t.targetId,t),this.sl()?this.il():this.G_.jc()&&this.ol(t))},zc.prototype.al=function(t){this.O_.delete(t),this.G_.jc()&&this.ul(t),0===this.O_.size&&(this.G_.jc()?this.G_.zc():this.W_()&&this.K_.set("Unknown"))},zc.prototype.si=function(t){return this.O_.get(t)||null},zc.prototype.ei=function(t){return this.cl.ei(t)},zc.prototype.ol=function(t){this.B_.Ns(t.targetId),this.G_.o_(t)},zc.prototype.ul=function(t){this.B_.Ns(t),this.G_.a_(t)},zc.prototype.il=function(){this.B_=new ks(this),this.G_.start(),this.K_.C_()},zc.prototype.sl=function(){return this.W_()&&!this.G_.Wc()&&0<this.O_.size},zc.prototype.W_=function(){return!this.q_&&this.isPrimary&&this.networkEnabled},zc.prototype.hl=function(){this.B_=null},zc.prototype.z_=function(){return y(this,void 0,void 0,function(){var n=this;return v(this,function(t){return this.O_.forEach(function(t,e){n.ol(t)}),[2]})})},zc.prototype.H_=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return this.hl(),this.sl()?(this.K_.k_(e),this.il()):this.K_.set("Unknown"),[2]})})},zc.prototype.Y_=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.K_.set("Online"),!(i instanceof Is&&2===i.state&&i.cause))return[3,6];t.label=1;case 1:return t.trys.push([1,3,,5]),[4,this._l(i)];case 2:return t.sent(),[3,5];case 3:return e=t.sent(),Ys("RemoteStore","Failed to remove targets %s: %s ",i.targetIds.join(","),e),[4,this.ll(e)];case 4:return t.sent(),[3,5];case 5:return[3,13];case 6:if(i instanceof bs?this.B_.qs(i):i instanceof Es?this.B_.Hs(i):this.B_.Ws(i),o.isEqual(Pr.min()))return[3,13];t.label=7;case 7:return t.trys.push([7,11,,13]),[4,this.L_.Jo()];case 8:return n=t.sent(),0<=o.S(n)?[4,this.dl(o)]:[3,10];case 9:t.sent(),t.label=10;case 10:return[3,13];case 11:return Ys("RemoteStore","Failed to raise snapshot:",r=t.sent()),[4,this.ll(r)];case 12:return t.sent(),[3,13];case 13:return[2]}})})},zc.prototype.ll=function(n){return y(this,void 0,void 0,function(){var e=this;return v(this,function(t){switch(t.label){case 0:if("IndexedDbTransactionError"!==n.name)throw n;return this.q_=!0,[4,this.rl()];case 1:return t.sent(),this.K_.set("Offline"),this.qr.dh(function(){return y(e,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return Ys("RemoteStore","Retrying IndexedDB access"),[4,this.L_.Jo()];case 1:return t.sent(),this.q_=!1,[4,this.el()];case 2:return t.sent(),[2]}})})}),[2]}})})},zc.prototype.dl=function(r){var i=this,t=this.B_.Xs(r);return t.as.forEach(function(t,e){if(0<t.resumeToken.rt()){var n=i.O_.get(e);n&&i.O_.set(e,n.we(t.resumeToken,r))}}),t.us.forEach(function(t){var e=i.O_.get(t);if(e){i.O_.set(t,e.we(ei.ht,e.Ee)),i.ul(t);var n=new Vo(e.target,t,1,e.sequenceNumber);i.ol(n)}}),this.cl.Yu(t)},zc.prototype._l=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.O_.has(i)?[4,this.cl.fl(i,e)]:[3,3]):[3,5];case 2:t.sent(),this.O_.delete(i),this.B_.removeTarget(i),t.label=3;case 3:t.label=4;case 4:return n++,[3,1];case 5:return[2]}})})},zc.prototype.nl=function(){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return this.Tl()?(e=0<this.x_.length?this.x_[this.x_.length-1].batchId:-1,[4,this.L_.tc(e)]):[3,5];case 1:return null!==(n=t.sent())?[3,2]:(0===this.x_.length&&this.J_.zc(),[3,4]);case 2:return this.El(n),[4,this.nl()];case 3:t.sent(),t.label=4;case 4:t.label=5;case 5:return this.Il()&&this.wl(),[2]}})})},zc.prototype.Tl=function(){return this.W_()&&this.x_.length<10},zc.prototype.Rl=function(){return this.x_.length},zc.prototype.El=function(t){this.x_.push(t),this.J_.jc()&&this.J_.c_&&this.J_.__(t.mutations)},zc.prototype.Il=function(){return this.W_()&&!this.J_.Wc()&&0<this.x_.length},zc.prototype.wl=function(){this.J_.start()},zc.prototype.X_=function(){return y(this,void 0,void 0,function(){return v(this,function(t){return this.J_.f_(),[2]})})},zc.prototype.tl=function(){var r=this;return this.L_.So(this.J_.lastStreamToken).then(function(){for(var t=0,e=r.x_;t<e.length;t++){var n=e[t];r.J_.__(n.mutations)}}).catch(Sh)},zc.prototype.l_=function(t,e){var n=this,r=this.x_.shift(),i=cu.from(r,t,e,this.J_.lastStreamToken);return this.cl.ml(i).then(function(){return n.nl()})},zc.prototype.Z_=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return e&&0<this.x_.length?this.J_.c_?[4,this.Al(e)]:[3,2]:[3,5];case 1:return t.sent(),[3,4];case 2:return[4,this.Pl(e)];case 3:t.sent(),t.label=4;case 4:this.Il()&&this.wl(),t.label=5;case 5:return[2]}})})},zc.prototype.Pl=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return Qo(e.code)?[2,(Ys("RemoteStore","RemoteStore error before completed handshake; resetting stream token: ",this.J_.lastStreamToken),this.J_.lastStreamToken=ei.ht,this.L_.So(ei.ht).catch(Sh))]:[2]})})},zc.prototype.Al=function(i){return y(this,void 0,void 0,function(){var e,n,r=this;return v(this,function(t){return Qo(n=i.code)&&n!==Sr.ABORTED?(e=this.x_.shift(),[2,(this.J_.Gc(),this.cl.Vl(e.batchId,i).then(function(){return r.nl()}))]):[2]})})},zc.prototype.gl=function(){return new Fc(this.w_)},zc.prototype.j_=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.rl()];case 1:return t.sent(),this.K_.set("Unknown"),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},zc.prototype.pl=function(){return y(this,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.W_()?(Ys("RemoteStore","RemoteStore restarting streams for new credential"),[4,this.j_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},zc.prototype.yl=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.rl()];case 3:t.sent(),this.K_.set("Unknown"),t.label=4;case 4:t.label=5;case 5:return[2]}})})},zc);function zc(t,e,n,r,i){var o,s,u,a,h,c,f,l,p=this;this.L_=t,this.w_=e,this.qr=n,this.x_=[],this.O_=new Map,this.B_=null,this.networkEnabled=!1,this.isPrimary=!1,this.q_=!1,this.U_=i,this.U_.Q_(function(t){n.Hr(function(){return y(p,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.W_()?(Ys("RemoteStore","Restarting streams for network reachability change."),[4,this.j_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.K_=new Bc(n,r),this.G_=(h=this.w_,c=n,f={n_:this.z_.bind(this),Zc:this.H_.bind(this),h_:this.Y_.bind(this)},l=tu(h),new jc(c,l.Bc,l.credentials,l.serializer,f)),this.J_=(o=this.w_,s=n,u={n_:this.X_.bind(this),Zc:this.Z_.bind(this),d_:this.tl.bind(this),l_:this.l_.bind(this)},a=tu(o),new Uc(s,a.Bc,a.credentials,a.serializer,u))}function Hc(t,e){this.qr=t,this.b_=e,this.state="Unknown",this.v_=0,this.S_=null,this.D_=!0}function Kc(t){this.w_=t,this.R_=ys(),this.mutations=[],this.m_=!1,this.A_=null,this.P_=new Set}function Wc(t,e,n){var r=this;return(r=Pc.call(this)||this).Bc=t,r.credentials=e,r.serializer=n,r}function Xc(t,e,n,r,i){var o=this;return(o=Vc.call(this,t,"write_stream_connection_backoff","write_stream_idle",e,n,i)||this).serializer=r,o.u_=!1,o.lastStreamToken=ei.ht,o}function Yc(t,e,n,r,i){var o=this;return(o=Cc.call(this,t,"listen_stream_connection_backoff","listen_stream_idle",e,n,i)||this).serializer=r,o}function Qc(t,e,n,r,i,o){this.Sr=t,this.Oc=n,this.Bc=r,this.qc=i,this.listener=o,this.state=0,this.Uc=0,this.Qc=null,this.stream=null,this.ih=new Ou(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 $c(t,e){return"firestore_targets_"+t+"_"+e}function tf(t){this.key=t}function ef(t){this.key=t}function nf(t,e,n){this.query=t,this.targetId=e,this.view=n}function rf(t){this.key=t,this.Wd=!1}function of(){this.yf=void 0,this.bf=[]}var sf,uf,af=(Uf.bl=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 xr(r.error.code,r.error.message)),i?new Uf(t,e,r.state,o):(Qs("SharedClientState","Failed to parse mutation state for ID '"+e+"': "+n),null)},Uf.prototype.vl=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)},Uf),hf=(jf.bl=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 xr(n.error.code,n.error.message)),r?new jf(t,n.state,i):(Qs("SharedClientState","Failed to parse target state for ID '"+t+"': "+e),null)},jf.prototype.vl=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)},jf),cf=(Mf.bl=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 Mf(t,i):(Qs("SharedClientState","Failed to parse client data for instance '"+t+"': "+e),null)},Mf),ff=(Cf.bl=function(t){var e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new Cf(e.clientId,e.onlineState):(Qs("SharedClientState","Failed to parse online state: "+t),null)},Cf),lf=(Vf.prototype.Sl=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},Vf.prototype.Dl=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},Vf.prototype.vl=function(){var t={activeTargetIds:this.activeTargetIds.W(),updateTimeMs:Date.now()};return JSON.stringify(t)},Vf),pf=(Pf.so=function(t){return!(!t.window||null==t.window.localStorage)},Pf.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.cl.Pu()];case 1:for(e=t.sent(),n=0,r=e;n<r.length;n++)(i=r[n])!==this.Cl&&(o=this.getItem(Jc(this.persistenceKey,i)))&&(s=cf.bl(i,o))&&(this.kl=this.kl.me(s.clientId,s));for(this.Ul(),(u=this.storage.getItem(this.ql))&&(a=this.Ql(u))&&this.Wl(a),h=0,c=this.$l;h<c.length;h++)f=c[h],this.Nl(f);return this.$l=[],this.platform.window.addEventListener("unload",function(){return l.Iu()}),this.Uh=!0,[2]}})})},Pf.prototype.br=function(t){this.setItem(this.Ll,JSON.stringify(t))},Pf.prototype.jl=function(){return this.Kl(this.kl)},Pf.prototype.Gl=function(n){var r=!1;return this.kl.forEach(function(t,e){e.activeTargetIds.has(n)&&(r=!0)}),r},Pf.prototype.zl=function(t){this.Hl(t,"pending")},Pf.prototype.Yl=function(t,e,n){this.Hl(t,e,n),this.Jl(t)},Pf.prototype.Xl=function(t){var e="not-current";if(this.Gl(t)){var n=this.storage.getItem($c(this.persistenceKey,t));if(n){var r=hf.bl(t,n);r&&(e=r.state)}}return this.Zl.Sl(t),this.Ul(),e},Pf.prototype.td=function(t){this.Zl.Dl(t),this.Ul()},Pf.prototype.ed=function(t){return this.Zl.activeTargetIds.has(t)},Pf.prototype.sd=function(t){this.removeItem($c(this.persistenceKey,t))},Pf.prototype.nd=function(t,e,n){this.rd(t,e,n)},Pf.prototype.Qu=function(t,e,n){var r=this;e.forEach(function(t){r.Jl(t)}),this.currentUser=t,n.forEach(function(t){r.zl(t)})},Pf.prototype.hd=function(t){this.od(t)},Pf.prototype.Iu=function(){this.Uh&&(this.platform.window.removeEventListener("storage",this.Fl),this.removeItem(this.Ml),this.Uh=!1)},Pf.prototype.getItem=function(t){var e=this.storage.getItem(t);return Ys("SharedClientState","READ",t,e),e},Pf.prototype.setItem=function(t,e){Ys("SharedClientState","SET",t,e),this.storage.setItem(t,e)},Pf.prototype.removeItem=function(t){Ys("SharedClientState","REMOVE",t),this.storage.removeItem(t)},Pf.prototype.Nl=function(u){var t=this;if(u.storageArea===this.storage){if(Ys("SharedClientState","EVENT",u.key,u.newValue),u.key===this.Ml)return void Qs("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Sr.dh(function(){return y(t,void 0,void 0,function(){var e,n,r,i,o,s;return v(this,function(t){if(this.Uh){if(null!==u.key)if(this.xl.test(u.key)){if(null==u.newValue)return e=this.ad(u.key),[2,this.ud(e,null)];if(n=this._d(u.key,u.newValue))return[2,this.ud(n.clientId,n)]}else if(this.Ol.test(u.key)){if(null!==u.newValue&&(r=this.ld(u.key,u.newValue)))return[2,this.dd(r)]}else if(this.Bl.test(u.key)){if(null!==u.newValue&&(i=this.fd(u.key,u.newValue)))return[2,this.Td(i)]}else if(u.key===this.ql){if(null!==u.newValue&&(o=this.Ql(u.newValue)))return[2,this.Wl(o)]}else u.key===this.Ll&&(s=function(t){var e=wu.vr;if(null!=t)try{var n=JSON.parse(t);$s("number"==typeof n),e=n}catch(t){Qs("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(u.newValue))!==wu.vr&&this.gr(s)}else this.$l.push(u);return[2]})})})}},Object.defineProperty(Pf.prototype,"Zl",{get:function(){return this.kl.get(this.Cl)},enumerable:!0,configurable:!0}),Pf.prototype.Ul=function(){this.setItem(this.Ml,this.Zl.vl())},Pf.prototype.Hl=function(t,e,n){var r=new af(this.currentUser,t,e,n),i=Zc(this.persistenceKey,this.currentUser,t);this.setItem(i,r.vl())},Pf.prototype.Jl=function(t){var e=Zc(this.persistenceKey,this.currentUser,t);this.removeItem(e)},Pf.prototype.od=function(t){var e={clientId:this.Cl,onlineState:t};this.storage.setItem(this.ql,JSON.stringify(e))},Pf.prototype.rd=function(t,e,n){var r=$c(this.persistenceKey,t),i=new hf(t,e,n);this.setItem(r,i.vl())},Pf.prototype.ad=function(t){var e=this.xl.exec(t);return e?e[1]:null},Pf.prototype._d=function(t,e){var n=this.ad(t);return cf.bl(n,e)},Pf.prototype.ld=function(t,e){var n=this.Ol.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return af.bl(new Ir(i),r,e)},Pf.prototype.fd=function(t,e){var n=this.Bl.exec(t),r=Number(n[1]);return hf.bl(r,e)},Pf.prototype.Ql=function(t){return ff.bl(t)},Pf.prototype.dd=function(e){return y(this,void 0,void 0,function(){return v(this,function(t){return e.user.uid===this.currentUser.uid?[2,this.cl.Ed(e.batchId,e.state,e.error)]:(Ys("SharedClientState","Ignoring mutation for non-active user "+e.user.uid),[2])})})},Pf.prototype.Td=function(t){return this.cl.Id(t.targetId,t.state,t.error)},Pf.prototype.ud=function(t,e){var n=this,r=e?this.kl.me(t,e):this.kl.remove(t),i=this.Kl(this.kl),o=this.Kl(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.cl.wd(s,u).then(function(){n.kl=r})},Pf.prototype.Wl=function(t){this.kl.get(t.clientId)&&this.b_(t.onlineState)},Pf.prototype.Kl=function(t){var n=ws();return t.forEach(function(t,e){n=n.He(e.activeTargetIds)}),n},Pf),df=(Of.prototype.zl=function(t){},Of.prototype.Yl=function(t,e,n){},Of.prototype.Xl=function(t){return this.Rd.Sl(t),this.md[t]||"not-current"},Of.prototype.nd=function(t,e,n){this.md[t]=e},Of.prototype.td=function(t){this.Rd.Dl(t)},Of.prototype.ed=function(t){return this.Rd.activeTargetIds.has(t)},Of.prototype.sd=function(t){delete this.md[t]},Of.prototype.jl=function(){return this.Rd.activeTargetIds},Of.prototype.Gl=function(t){return this.Rd.activeTargetIds.has(t)},Of.prototype.start=function(){return this.Rd=new lf,Promise.resolve()},Of.prototype.Qu=function(t,e,n){},Of.prototype.hd=function(t){},Of.prototype.Iu=function(){},Of.prototype.br=function(t){},Of),yf=(Object.defineProperty(Rf.prototype,"pd",{get:function(){return this.Ad},enumerable:!0,configurable:!0}),Rf.prototype.yd=function(t,e){var u=this,a=e?e.bd:new Ns,h=e?e.gd:this.gd,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 Io?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.vd(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{gd:f,bd:a,Sd:l,ns:c}},Rf.prototype.vd=function(t,e){return t.At&&e.hasCommittedMutations&&!e.At},Rf.prototype.Zn=function(t,e,n){var o=this,r=this.gd;this.gd=t.gd,this.ns=t.ns;var i=t.bd.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 Zs()}}var r,i}),this.Dd(n);var s=e?this.Cd():[],u=0===this.Vd.size&&this.fs?1:0,a=u!==this.Pd;return this.Pd=u,0!==i.length||a?{snapshot:new _s(this.query,t.gd,r,i,t.ns,0==u,a,!1),Fd:s}:{Fd:s}},Rf.prototype.Nd=function(t){return this.fs&&"Offline"===t?(this.fs=!1,this.Zn({gd:this.gd,bd:new Ns,ns:this.ns,Sd:!1},!1)):{Fd:[]}},Rf.prototype.kd=function(t){return!this.Ad.has(t)&&!!this.gd.has(t)&&!this.gd.get(t).At},Rf.prototype.Dd=function(t){var e=this;t&&(t.Ts.forEach(function(t){return e.Ad=e.Ad.add(t)}),t.Es.forEach(function(t){}),t.Is.forEach(function(t){return e.Ad=e.Ad.delete(t)}),this.fs=t.fs)},Rf.prototype.Cd=function(){var e=this;if(!this.fs)return[];var n=this.Vd;this.Vd=gs(),this.gd.forEach(function(t){e.kd(t.key)&&(e.Vd=e.Vd.add(t.key))});var r=[];return n.forEach(function(t){e.Vd.has(t)||r.push(new ef(t))}),this.Vd.forEach(function(t){n.has(t)||r.push(new tf(t))}),r},Rf.prototype.$d=function(t){this.Ad=t.rc,this.Vd=gs();var e=this.yd(t.documents);return this.Zn(e,!0)},Rf.prototype.Md=function(){return _s.os(this.query,this.gd,this.ns,0===this.Pd)},Rf),vf=(Df.prototype.Od=function(){this.Bd()},Df.prototype.Bd=function(){var t=this;this.ih.xr(function(){return y(t,void 0,void 0,function(){var e,n,r=this;return v(this,function(t){return e=this.Ld.gl(),(n=this.qd(e))&&n.then(function(t){r.qr.Hr(function(){return e.commit().then(function(){r.Wr.resolve(t)}).catch(function(t){r.Ud(t)})})}).catch(function(t){r.Ud(t)}),[2]})})})},Df.prototype.qd=function(t){try{var e=this.updateFunction(t);return!ri(e)&&e.catch&&e.then?e:(this.Wr.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Wr.reject(t),null}},Df.prototype.Ud=function(t){var e=this;0<this.xd&&this.Qd(t)?(--this.xd,this.qr.Hr(function(){return e.Bd(),Promise.resolve()})):this.Wr.reject(t)},Df.prototype.Qd=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!Qo(e)},Df),gf=(Object.defineProperty(Lf.prototype,"if",{get:function(){return!0},enumerable:!0,configurable:!0}),Lf.prototype.subscribe=function(t){this.Gd=t},Lf.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.nf("listen()"),(r=this.zd.get(s))?(e=r.targetId,this.jd.Xl(e),n=r.view.Md(),[3,4]):[3,1];case 1:return[4,this.L_.sc(s.ee())];case 2:return i=t.sent(),o=this.jd.Xl(i.targetId),e=i.targetId,[4,this.rf(s,e,"current"===o)];case 3:n=t.sent(),this.if&&this.Ld.listen(i),t.label=4;case 4:return[2,n]}})})},Lf.prototype.rf=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.L_.nc(u,!0)];case 1:return e=t.sent(),n=new yf(u,e.rc),r=n.yd(e.documents),i=Ss.ds(a,h&&"Offline"!==this.onlineState),o=n.Zn(r,this.if,i),this.hf(a,o.Fd),s=new nf(u,a,n),[2,(this.zd.set(u,s),this.Hd.has(a)?this.Hd.get(a).push(u):this.Hd.set(a,[u]),o.snapshot)]}})})},Lf.prototype.al=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.nf("unlisten()"),e=this.zd.get(i),1<(n=this.Hd.get(e.targetId)).length?[2,(this.Hd.set(e.targetId,n.filter(function(t){return!t.isEqual(i)})),void this.zd.delete(i))]:this.if?(this.jd.td(e.targetId),this.jd.Gl(e.targetId)?[3,2]:[4,this.L_.ic(e.targetId,!1).then(function(){r.jd.sd(e.targetId),r.Ld.al(e.targetId),r.af(e.targetId)}).catch(Sh)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.af(e.targetId),[4,this.L_.ic(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},Lf.prototype.write=function(r,i){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:this.nf("write()"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.L_.Gu(r)];case 2:return e=t.sent(),[3,4];case 3:if("IndexedDbTransactionError"===(n=t.sent()).name)return[2,(Qs("SyncEngine","Dropping write that cannot be persisted: "+n),void i.reject(new xr(Sr.UNAVAILABLE,"Failed to persist write: "+n)))];throw n;case 4:return this.jd.zl(e.batchId),this.uf(e.batchId,i),[4,this.cf(e.Wn)];case 5:return t.sent(),[4,this.Ld.nl()];case 6:return t.sent(),[2]}})})},Lf.prototype.runTransaction=function(t,e,n){new vf(t,this.Ld,e,n).Od()},Lf.prototype.Yu=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.nf("applyRemoteEvent()"),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.L_.Yu(n)];case 2:return e=t.sent(),n.as.forEach(function(t,e){var n=r.Xd.get(e);n&&($s(t.Ts.size+t.Es.size+t.Is.size<=1),0<t.Ts.size?n.Wd=!0:0<t.Es.size?$s(n.Wd):0<t.Is.size&&($s(n.Wd),n.Wd=!1))}),[4,this.cf(e,n)];case 3:return t.sent(),[3,6];case 4:return[4,Sh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Lf.prototype.Nd=function(r,t){this.nf("applyOnlineStateChange()");var i=[];this.zd.forEach(function(t,e){var n=e.view.Nd(r);n.snapshot&&i.push(n.snapshot)}),this.Gd._f(r),this.Gd.h_(i),this.onlineState=r},Lf.prototype.fl=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.nf("rejectListens()"),this.jd.nd(u,"rejected",a),e=this.Xd.get(u),(n=e&&e.key)?(this.Jd=this.Jd.remove(n),this.Xd.delete(u),this.lf(),r=(r=new Zo(Qr.N)).me(n,new To(n,Pr.min())),i=gs().add(n),o=new As(Pr.min(),new Map,new os(ru),r,i),[2,this.Yu(o)]):[4,this.L_.ic(u,!1).then(function(){return s.af(u,a)}).catch(Sh)];case 1:return t.sent(),[2]}})})},Lf.prototype.ml=function(r){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:this.nf("applySuccessfulWrite()"),e=r.batch.batchId,this.df(e,null),this.ff(e),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.L_.yo(r)];case 2:return n=t.sent(),this.jd.Yl(e,"acknowledged"),[4,this.cf(n)];case 3:return t.sent(),[3,6];case 4:return[4,Sh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Lf.prototype.Vl=function(n,r){return y(this,void 0,void 0,function(){var e;return v(this,function(t){switch(t.label){case 0:this.nf("rejectFailedWrite()"),this.df(n,r),this.ff(n),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.L_.Hu(n)];case 2:return e=t.sent(),this.jd.Yl(n,"rejected",r),[4,this.cf(e)];case 3:return t.sent(),[3,6];case 4:return[4,Sh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},Lf.prototype.Tf=function(r){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return this.Ld.W_()||Ys("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),[4,this.L_.Lo()];case 1:return-1===(e=t.sent())?[2,void r.resolve()]:((n=this.ef.get(e)||[]).push(r),this.ef.set(e,n),[2])}})})},Lf.prototype.ff=function(t){(this.ef.get(t)||[]).forEach(function(t){t.resolve()}),this.ef.delete(t)},Lf.prototype.Ef=function(e){this.ef.forEach(function(t){t.forEach(function(t){t.reject(new xr(Sr.CANCELLED,e))})}),this.ef.clear()},Lf.prototype.uf=function(t,e){var n=this.tf[this.currentUser.s()];n=(n=n||new Zo(ru)).me(t,e),this.tf[this.currentUser.s()]=n},Lf.prototype.df=function(t,e){var n=this.tf[this.currentUser.s()];if(n){var r=n.get(t);r&&(e?r.reject(e):r.resolve(),n=n.remove(t)),this.tf[this.currentUser.s()]=n}},Lf.prototype.af=function(t,e){var n=this;void 0===e&&(e=null),this.jd.td(t);for(var r=0,i=this.Hd.get(t);r<i.length;r++){var o=i[r];this.zd.delete(o),e&&this.Gd.If(o,e)}if(this.Hd.delete(t),this.if){var s=this.Zd.Cn(t);this.Zd.Sn(t),s.forEach(function(t){n.Zd.Fn(t)||n.wf(t)})}},Lf.prototype.wf=function(t){var e=this.Jd.get(t);null!==e&&(this.Ld.al(e),this.Jd=this.Jd.remove(t),this.Xd.delete(e),this.lf())},Lf.prototype.hf=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof tf?(this.Zd.gn(i.key,t),this.Rf(i)):i instanceof ef?(Ys("SyncEngine","Document no longer in limbo: "+i.key),this.Zd.yn(i.key,t),this.Zd.Fn(i.key)||this.wf(i.key)):Zs()}},Lf.prototype.Rf=function(t){var e=t.key;this.Jd.get(e)||(Ys("SyncEngine","New document in limbo: "+e),this.Yd.push(e),this.lf())},Lf.prototype.lf=function(){for(;0<this.Yd.length&&this.Jd.size<this.Kd;){var t=this.Yd.shift(),e=this.sf.next();this.Xd.set(e,new rf(t)),this.Jd=this.Jd.me(t,e),this.Ld.listen(new Vo(Ao.Wt(t.path).ee(),e,2,wu.vr))}},Lf.prototype.mf=function(){return this.Jd},Lf.prototype.Af=function(){return this.Yd},Lf.prototype.cf=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.zd.forEach(function(t,i){e.push(Promise.resolve().then(function(){var n=i.view.yd(r);return n.Sd?u.L_.nc(i.query,!1).then(function(t){var e=t.documents;return i.view.yd(e,n)}):n}).then(function(t){var e=a&&a.as.get(i.targetId),n=i.view.Zn(t,u.if,e);if(u.hf(i.targetId,n.Fd),n.snapshot){u.if&&u.jd.nd(i.targetId,n.snapshot.fromCache?"not-current":"current"),o.push(n.snapshot);var r=mu.Vr(i.targetId,n.snapshot);s.push(r)}}))}),[4,Promise.all(e)];case 1:return t.sent(),this.Gd.h_(o),[4,this.L_.Zu(s)];case 2:return t.sent(),[2]}})})},Lf.prototype.nf=function(t){},Lf.prototype.pl=function(r){return y(this,void 0,void 0,function(){var e,n;return v(this,function(t){switch(t.label){case 0:return e=!this.currentUser.isEqual(r),this.currentUser=r,e?(this.Ef("'waitForPendingWrites' promise is rejected due to a user change."),[4,this.L_.Qu(r)]):[3,3];case 1:return n=t.sent(),this.jd.Qu(r,n.ju,n.Ku),[4,this.cf(n.Wu)];case 2:t.sent(),t.label=3;case 3:return[4,this.Ld.pl()];case 4:return t.sent(),[2]}})})},Lf.prototype.enableNetwork=function(){return this.Ld.enableNetwork()},Lf.prototype.disableNetwork=function(){return this.Ld.disableNetwork()},Lf.prototype.ei=function(t){var e=this.Xd.get(t);if(e&&e.Wd)return gs().add(e.key);var n=gs(),r=this.Hd.get(t);if(!r)return n;for(var i=0,o=r;i<o.length;i++){var s=o[i],u=this.zd.get(s);n=n.He(u.view.pd)}return n},Lf),mf=(n(kf,sf=gf),Object.defineProperty(kf.prototype,"if",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),kf.prototype.enableNetwork=function(){return this.L_.ru(!0),sf.prototype.enableNetwork.call(this)},kf.prototype.disableNetwork=function(){return this.L_.ru(!1),sf.prototype.disableNetwork.call(this)},kf.prototype.Pf=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.L_.nc(r.query,!0)];case 1:return e=t.sent(),n=r.view.$d(e),[2,(this.isPrimary&&this.hf(r.targetId,n.Fd),n)]}})})},kf.prototype.Nd=function(t,e){this.if&&0===e&&(sf.prototype.Nd.call(this,t,e),this.jd.hd(t)),this.if||1!==e||sf.prototype.Nd.call(this,t,e)},kf.prototype.Ed=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.nf("applyBatchState()"),[4,this.L_.ac(n)];case 1:return null===(e=t.sent())?[3,6]:"pending"!==r?[3,3]:[4,this.Ld.nl()];case 2:return t.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(this.df(n,i||null),this.L_.uc(n)):Zs(),t.label=4;case 4:return[4,this.cf(e)];case 5:return t.sent(),[3,7];case 6:Ys("SyncEngine","Cannot apply mutation batch with id: "+n),t.label=7;case 7:return[2]}})})},kf.prototype.yl=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.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.Ld.yl(!0)]);case 1:return t.sent(),e=this.jd.jl(),[4,this.Vf(e.W())];case 2:for(n=t.sent(),r=0,i=n;r<i.length;r++)o=i[r],this.Ld.listen(o);return[3,7];case 3:return!1!==h||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,s=[],u=Promise.resolve(),this.Hd.forEach(function(t,e){a.jd.ed(e)?s.push(e):u=u.then(function(){return a.af(e),a.L_.ic(e,!0)}),a.Ld.al(e)}),[4,u]);case 4:return t.sent(),[4,this.Vf(s)];case 5:return t.sent(),this.gf(),[4,this.Ld.yl(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},kf.prototype.gf=function(){var n=this;this.Xd.forEach(function(t,e){n.Ld.al(e)}),this.Zd.Dn(),this.Xd=new Map,this.Jd=new Zo(Qr.N)},kf.prototype.Vf=function(d){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.Hd.get(o))&&0!==u.length?[4,this.L_.ic(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.L_.sc(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.zd.get(c),[4,this.Pf(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.L_.cc(o)];case 9:return p=t.sent(),[4,this.L_.sc(p)];case 10:return s=t.sent(),[4,this.rf(this.pf(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.Gd.h_(n),e)]}})})},kf.prototype.pf=function(t){return new Ao(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)},kf.prototype.Pu=function(){return this.L_.Pu()},kf.prototype.Id=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.isPrimary?(Ys("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!this.Hd.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.L_.Va()];case 3:return e=t.sent(),n=As.ls(r,"current"===i),[4,this.cf(e,n)];case 4:return t.sent(),[3,8];case 5:return[4,this.L_.ic(r,!0)];case 6:return t.sent(),this.af(r,o),[3,8];case 7:Zs(),t.label=8;case 8:return[2]}})})},kf.prototype.wd=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.isPrimary)return[3,10];e=0,n=l,t.label=1;case 1:return e<n.length?(r=n[e],this.Hd.has(r)?(Ys("SyncEngine","Adding an already active target "+r),[3,5]):[4,this.L_.cc(r)]):[3,6];case 2:return i=t.sent(),[4,this.L_.sc(i)];case 3:return o=t.sent(),[4,this.rf(this.pf(i),o.targetId,!1)];case 4:t.sent(),this.Ld.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.Hd.has(e)?[4,u.L_.ic(e,!1).then(function(){f.Ld.al(e),f.af(e)}).catch(Sh)]:[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]}})})},kf),wf=(xf.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.vf.get(e))||(n=!0,r=new of),!n)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),i=r,[4,this.cl.listen(e)];case 2:return i.yf=t.sent(),[3,4];case 3:if(o=t.sent(),Qs("EventManager",s="Initialization of query '"+e+"' failed: "+o),"IndexedDbTransactionError"!==o.name)throw o;return[2,void u.onError(new xr(Sr.UNAVAILABLE,s))];case 4:return this.vf.set(e,r),r.bf.push(u),u.Nd(this.onlineState),r.yf&&u.Df(r.yf)&&this.Cf(),[2]}})})},xf.prototype.al=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.vf.get(e))&&0<=(i=r.bf.indexOf(o))&&(r.bf.splice(i,1),n=0===r.bf.length),n?[2,(this.vf.delete(e),this.cl.al(e))]:[2]})})},xf.prototype.h_=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,s=this.vf.get(o);if(s){for(var u=0,a=s.bf;u<a.length;u++)a[u].Df(i)&&(e=!0);s.yf=i}}e&&this.Cf()},xf.prototype.If=function(t,e){var n=this.vf.get(t);if(n)for(var r=0,i=n.bf;r<i.length;r++)i[r].onError(e);this.vf.delete(t)},xf.prototype._f=function(i){this.onlineState=i;var o=!1;this.vf.forEach(function(t,e){for(var n=0,r=e.bf;n<r.length;n++)r[n].Nd(i)&&(o=!0)}),o&&this.Cf()},xf.prototype.Ff=function(t){this.Sf.add(t),t.next()},xf.prototype.Nf=function(t){this.Sf.delete(t)},xf.prototype.Cf=function(){this.Sf.forEach(function(t){t.next()})},xf),bf=(Sf.prototype.Df=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 _s(t.query,t.docs,t.ss,e,t.ns,t.fromCache,t.rs,!0)}var o=!1;return this.$f?this.Lf(t)&&(this.kf.next(t),o=!0):this.xf(t,this.onlineState)&&(this.Of(t),o=!0),this.Mf=t,o},Sf.prototype.onError=function(t){this.kf.error(t)},Sf.prototype.Nd=function(t){this.onlineState=t;var e=!1;return this.Mf&&!this.$f&&this.xf(this.Mf,t)&&(this.Of(this.Mf),e=!0),e},Sf.prototype.xf=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.Bf&&n||t.docs.B()&&"Offline"!==e)},Sf.prototype.Lf=function(t){if(0<t.docChanges.length)return!0;var e=this.Mf&&this.Mf.hasPendingWrites!==t.hasPendingWrites;return!(!t.rs&&!e)&&!0===this.options.includeMetadataChanges},Sf.prototype.Of=function(t){t=_s.os(t.query,t.docs,t.ns,t.fromCache),this.$f=!0,this.kf.next(t)},Sf),Ef=(Af.prototype.Uu=function(t){this.qf=t},Af.prototype.dr=function(e,r,i,o){var s=this;return r.te()||i.isEqual(Pr.min())?this.Uf(e,r):this.qf.cr(e,o).next(function(t){var n=s.Qf(r,t);return(r.oe()||r.ae())&&s.Sd(r.Bt,n,o,i)?s.Uf(e,r):(Ws()<=l.DEBUG&&Ys("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),s.qf.dr(e,r,i).next(function(e){return n.forEach(function(t){e=e.me(t.key,t)}),e}))})},Af.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 Io&&n.matches(e)&&(r=r.add(e))}),r},Af.prototype.Sd=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))},Af.prototype.Uf=function(t,e){return Ws()<=l.DEBUG&&Ys("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.qf.dr(t,e,Pr.min())},Af),If=(_f.prototype.po=function(t){return pu.resolve(0===this.nr.length)},_f.prototype.yo=function(t,e,n){var r=e.batchId,i=this.Kf(r,"acknowledged");return $s(0===i),this.nr[i],this.lastStreamToken=n,pu.resolve()},_f.prototype.vo=function(t){return pu.resolve(this.lastStreamToken)},_f.prototype.So=function(t,e){return this.lastStreamToken=e,pu.resolve()},_f.prototype.Do=function(t,e,n,r){var i=this.Wf;this.Wf++,0<this.nr.length&&this.nr[this.nr.length-1];var o=new hu(i,e,n,r);this.nr.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.jf=this.jf.add(new lu(a.key,i)),this.rr.Fo(t,a.key.path.M())}return pu.resolve(o)},_f.prototype.No=function(t,e){return pu.resolve(this.Gf(e))},_f.prototype.Mo=function(t,e){var n=e+1,r=this.zf(n),i=r<0?0:r;return pu.resolve(this.nr.length>i?this.nr[i]:null)},_f.prototype.Lo=function(){return pu.resolve(0===this.nr.length?-1:this.Wf-1)},_f.prototype.xo=function(t){return pu.resolve(this.nr.slice())},_f.prototype.or=function(t,e){var n=this,r=new lu(e,0),i=new lu(e,Number.POSITIVE_INFINITY),o=[];return this.jf.Ke([r,i],function(t){var e=n.Gf(t.Nn);o.push(e)}),pu.resolve(o)},_f.prototype.lr=function(t,e){var r=this,i=new os(ru);return e.forEach(function(t){var e=new lu(t,0),n=new lu(t,Number.POSITIVE_INFINITY);r.jf.Ke([e,n],function(t){i=i.add(t.Nn)})}),pu.resolve(this.Hf(i))},_f.prototype.Rr=function(t,e){var n=e.path,r=n.length+1,i=n;Qr.et(i)||(i=i.child(""));var o=new lu(new Qr(i),0),s=new os(ru);return this.jf.Ge(function(t){var e=t.key.path;return!!n.q(e)&&(e.length===r&&(s=s.add(t.Nn)),!0)},o),pu.resolve(this.Hf(s))},_f.prototype.Hf=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.Gf(t);null!==e&&r.push(e)}),r},_f.prototype.Bo=function(n,r){var i=this;$s(0===this.Kf(r.batchId,"removed")),this.nr.shift();var o=this.jf;return pu.forEach(r.mutations,function(t){var e=new lu(t.key,r.batchId);return o=o.delete(e),i.Ao.Qo(n,t.key)}).next(function(){i.jf=o})},_f.prototype.Uo=function(t){},_f.prototype.Fn=function(t,e){var n=new lu(e,0),r=this.jf.ze(n);return pu.resolve(e.isEqual(r&&r.key))},_f.prototype.Wo=function(t){return this.nr.length,pu.resolve()},_f.prototype.Kf=function(t,e){return this.zf(t)},_f.prototype.zf=function(t){return 0===this.nr.length?0:t-this.nr[0].batchId},_f.prototype.Gf=function(t){var e=this.zf(t);return e<0||e>=this.nr.length?null:this.nr[e]},_f),Tf=(Nf.prototype.Gn=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.Yf(e);return this.docs=this.docs.me(r,{Ea:e,size:s,readTime:n}),this.size+=s-o,this.rr.Fo(t,r.path.M())},Nf.prototype.Hn=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Nf.prototype.Yn=function(t,e){var n=this.docs.get(e);return pu.resolve(n?n.Ea:null)},Nf.prototype.getEntries=function(t,e){var n=this,r=fs();return e.forEach(function(t){var e=n.docs.get(t);r=r.me(t,e?e.Ea:null)}),pu.resolve(r)},Nf.prototype.dr=function(t,e,n){for(var r=ps(),i=new Qr(e.path.child("")),o=this.docs.ve(i);o.ke();){var s=o.Ne(),u=s.key,a=s.value,h=a.Ea,c=a.readTime;if(!e.path.q(u.path))break;c.S(n)<=0||h instanceof Io&&e.matches(h)&&(r=r.me(h.key,h))}return pu.resolve(r)},Nf.prototype.Jf=function(t,e){return pu.forEach(this.docs,function(t){return e(t)})},Nf.prototype.ba=function(t){return new Nf.va(this)},Nf.prototype.Da=function(t){return pu.resolve(this.size)},Nf);function Nf(t,e){this.rr=t,this.Yf=e,this.docs=new Zo(Qr.N),this.size=0}function _f(t,e){this.rr=t,this.Ao=e,this.nr=[],this.Wf=1,this.lastStreamToken=ei.ht,this.jf=new os(lu.An)}function Af(){}function Sf(t,e,n){this.query=t,this.kf=e,this.$f=!1,this.Mf=null,this.onlineState="Unknown",this.options=n||{}}function xf(t){this.cl=t,this.vf=new au(function(t){return t.canonicalId()}),this.onlineState="Unknown",this.Sf=new Set,this.cl.subscribe(this)}function kf(t,e,n,r,i){var o=this;return(o=sf.call(this,t,e,n,r,i)||this).L_=t,o.isPrimary=void 0,o}function Lf(t,e,n,r,i){this.L_=t,this.Ld=e,this.jd=n,this.currentUser=r,this.Kd=i,this.Gd=null,this.zd=new au(function(t){return t.canonicalId()}),this.Hd=new Map,this.Yd=[],this.Jd=new Zo(Qr.N),this.Xd=new Map,this.Zd=new fu,this.tf={},this.ef=new Map,this.sf=ba.Go(),this.onlineState="Unknown"}function Df(t,e,n,r){this.qr=t,this.Ld=e,this.updateFunction=n,this.Wr=r,this.xd=5,this.ih=new Ou(this.qr,"transaction_retry")}function Rf(t,e){this.query=t,this.Ad=e,this.Pd=null,this.fs=!1,this.Vd=gs(),this.ns=gs(),this.gd=new Ts(t.se.bind(t))}function Of(){this.Rd=new lf,this.md={},this.cl=null,this.b_=null,this.gr=null}function Pf(t,e,n,r,i){if(this.Sr=t,this.platform=e,this.persistenceKey=n,this.Cl=r,this.cl=null,this.b_=null,this.gr=null,this.Fl=this.Nl.bind(this),this.kl=new Zo(ru),this.Uh=!1,this.$l=[],!Pf.so(this.platform))throw new xr(Sr.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.Ml=Jc(this.persistenceKey,this.Cl),this.Ll="firestore_sequence_number_"+this.persistenceKey,this.kl=this.kl.me(this.Cl,new lf),this.xl=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Ol=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.Bl=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.ql="firestore_online_state_"+this.persistenceKey,this.platform.window.addEventListener("storage",this.Fl)}function Vf(){this.activeTargetIds=ws()}function Cf(t,e){this.clientId=t,this.onlineState=e}function Mf(t,e){this.clientId=t,this.activeTargetIds=e}function jf(t,e,n){this.targetId=t,this.state=e,this.error=n}function Uf(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}function qf(t){var e=this;return(e=uf.call(this)||this).Ca=t,e}Tf.va=(n(qf,uf=du),qf.prototype.Zn=function(n){var r=this,i=[];return this.Wn.forEach(function(t,e){e?i.push(r.Ca.Gn(n,e,r.readTime)):r.Ca.Hn(t)}),pu.Un(i)},qf.prototype.Jn=function(t,e){return this.Ca.Yn(t,e)},qf.prototype.Xn=function(t,e){return this.Ca.getEntries(t,e)},qf);var Ff,Bf,Gf=(il.prototype.js=function(t,n){return this.Xf.forEach(function(t,e){return n(e)}),pu.resolve()},il.prototype.Jo=function(t){return pu.resolve(this.lastRemoteSnapshotVersion)},il.prototype.Xo=function(t){return pu.resolve(this.Zf)},il.prototype.zo=function(t){return this.highestTargetId=this.eT.next(),pu.resolve(this.highestTargetId)},il.prototype.Zo=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Zf&&(this.Zf=e),pu.resolve()},il.prototype.ea=function(t){this.Xf.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.eT=new ba(e),this.highestTargetId=e),t.sequenceNumber>this.Zf&&(this.Zf=t.sequenceNumber)},il.prototype.ta=function(t,e){return this.ea(e),this.targetCount+=1,pu.resolve()},il.prototype.ia=function(t,e){return this.ea(e),pu.resolve()},il.prototype.na=function(t,e){return this.Xf.delete(e.target),this.tT.Sn(e.targetId),--this.targetCount,pu.resolve()},il.prototype.Hh=function(n,r,i){var o=this,s=0,u=[];return this.Xf.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.Xf.delete(t),u.push(o.ra(n,e.targetId)),s++)}),pu.Un(u).next(function(){return s})},il.prototype.aa=function(t){return pu.resolve(this.targetCount)},il.prototype.ua=function(t,e){var n=this.Xf.get(e)||null;return pu.resolve(n)},il.prototype.ca=function(e,t,n){this.tT.pn(t,n);var r=this.persistence.Ao,i=[];return r&&t.forEach(function(t){i.push(r.gn(e,t))}),pu.Un(i)},il.prototype._a=function(e,t,n){this.tT.vn(t,n);var r=this.persistence.Ao,i=[];return r&&t.forEach(function(t){i.push(r.yn(e,t))}),pu.Un(i)},il.prototype.ra=function(t,e){return this.tT.Sn(e),pu.resolve()},il.prototype.la=function(t,e){var n=this.tT.Cn(e);return pu.resolve(n)},il.prototype.Fn=function(t,e){return pu.resolve(this.tT.Fn(e))},il),zf=(rl.prototype.start=function(){return Promise.resolve()},rl.prototype.Iu=function(){return this.qa=!1,Promise.resolve()},Object.defineProperty(rl.prototype,"Uh",{get:function(){return this.qa},enumerable:!0,configurable:!0}),rl.prototype.nu=function(){},rl.prototype.yu=function(){return this.rr},rl.prototype.Vu=function(t){var e=this.sT[t.s()];return e||(e=new If(this.rr,this.Ao),this.sT[t.s()]=e),e},rl.prototype.gu=function(){return this.Ha},rl.prototype.pu=function(){return this.ir},rl.prototype.runTransaction=function(t,e,n){var r=this;Ys("MemoryPersistence","Starting transaction:",t);var i=new Hf(this.su.next());return this.Ao.nT(),n(i).next(function(t){return r.Ao.rT(i).next(function(){return t})}).Bn().then(function(t){return i.sr(),t})},rl.prototype.hT=function(e,n){return pu.Qn(Object.values(this.sT).map(function(t){return function(){return t.Fn(e,n)}}))},rl),Hf=(n(nl,Bf=vu),nl),Kf=(el.aT=function(t){return new el(t)},Object.defineProperty(el.prototype,"uT",{get:function(){if(this.oT)return this.oT;throw Zs()},enumerable:!0,configurable:!0}),el.prototype.Fu=function(t){this.Su=t},el.prototype.gn=function(t,e){return this.uT.delete(e),pu.resolve()},el.prototype.yn=function(t,e){return this.uT.add(e),pu.resolve()},el.prototype.Qo=function(t,e){return this.uT.add(e),pu.resolve()},el.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.gu();return r.la(t,e.targetId).next(function(t){t.forEach(function(t){return n.uT.add(t)})}).next(function(){return r.na(t,e)})},el.prototype.nT=function(){this.oT=new Set},el.prototype.rT=function(t){var n=this,r=this.persistence.pu().ba();return pu.forEach(this.uT,function(e){return n.cT(t,e).next(function(t){t||r.Hn(e)})}).next(function(){return n.oT=null,r.apply(t)})},el.prototype.ku=function(t,e){var n=this;return this.cT(t,e).next(function(t){t?n.uT.delete(e):n.uT.add(e)})},el.prototype.iT=function(t){return 0},el.prototype.cT=function(t,e){var n=this;return pu.Qn([function(){return n.persistence.gu().Fn(t,e)},function(){return n.persistence.hT(t,e)},function(){return pu.resolve(n.Su.Fn(e))}])},el),Wf=(tl.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.jd=this._T(n),this.persistence=this.lT(n),[4,this.persistence.start()];case 1:return t.sent(),this.dT=this.fT(n),this.L_=this.TT(n),this.Ld=this.ET(n),this.cl=this.IT(n),this.wT=this.RT(n),this.jd.b_=function(t){return e.cl.Nd(t,1)},this.Ld.cl=this.cl,[4,this.L_.start()];case 2:return t.sent(),[4,this.jd.start()];case 3:return t.sent(),[4,this.Ld.start()];case 4:return t.sent(),[4,this.Ld.yl(this.cl.if)];case 5:return t.sent(),[2]}})})},tl.prototype.RT=function(t){return new wf(this.cl)},tl.prototype.fT=function(t){return null},tl.prototype.TT=function(t){return new Ih(this.persistence,new Ef,t.mT)},tl.prototype.lT=function(t){return new zf(Kf.aT)},tl.prototype.ET=function(t){var e=this;return new Gc(this.L_,t.w_,t.qr,function(t){return e.cl.Nd(t,0)},t.platform.AT())},tl.prototype._T=function(t){return new df},tl.prototype.IT=function(t){return new gf(this.L_,this.Ld,this.jd,t.mT,t.Kd)},tl.prototype.clearPersistence=function(t){throw new xr(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.")},tl),Xf=(n($f,Ff=Wf),$f.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,Ff.prototype.initialize.call(this,e)];case 1:return t.sent(),[4,this.persistence.iu(function(e){return y(n,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return[4,this.cl.yl(e)];case 1:return t.sent(),this.dT&&(e&&!this.dT.Uh?this.dT.start(this.L_):e||this.dT.stop()),[2]}})})})];case 2:return t.sent(),[2]}})})},$f.prototype.TT=function(t){return new _h(this.persistence,new Ef,t.mT)},$f.prototype.IT=function(t){var e=new mf(this.L_,this.Ld,this.jd,t.mT,t.Kd);return this.jd instanceof pf&&(this.jd.cl=e),e},$f.prototype.fT=function(t){var e=this.persistence.Ao.Lh;return new Hu(e,t.qr)},$f.prototype.lT=function(t){var e=ph.vu(t.PT),n=t.platform.Dc(t.PT.ii);return new ph(t.VT.synchronizeTabs,e,t.clientId,t.platform,Bu.Dh(t.VT.cacheSizeBytes),t.qr,n,this.jd)},$f.prototype._T=function(t){if(t.VT.gT&&t.VT.synchronizeTabs){if(!pf.so(t.platform))throw new xr(Sr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var e=ph.vu(t.PT);return new pf(t.qr,t.platform,e,t.clientId,t.mT)}return new df},$f.prototype.clearPersistence=function(t){var e=ph.vu(t);return ph.clearPersistence(e)},$f),Yf=(Zf.prototype.start=function(e,n){var r=this;this.pT();var i=new Ru,o=new Ru,s=!1;return this.credentials.l(function(t){if(!s)return s=!0,Ys("FirestoreClient","Initializing. user=",t.uid),r.yT(e,n,t,o).then(i.resolve,i.reject);r.qr.Hr(function(){return r.pl(t)})}),this.qr.Hr(function(){return i.promise}),o.promise},Zf.prototype.enableNetwork=function(){var t=this;return this.pT(),this.qr.enqueue(function(){return t.cl.enableNetwork()})},Zf.prototype.yT=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.bT(this.PT)];case 1:return r=t.sent(),i=this.platform.Dc(this.PT.ii),e=r,n=this.credentials,o=new qc(e,n,i),[4,a.initialize({qr:this.qr,PT:this.PT,platform:this.platform,w_:o,clientId:this.clientId,mT:c,Kd:100,VT:h})];case 2:return t.sent(),this.persistence=a.persistence,this.jd=a.jd,this.L_=a.L_,this.Ld=a.Ld,this.cl=a.cl,this.dT=a.dT,this.vT=a.wT,this.persistence.nu(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.ST(s))throw s;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+s),this.yT(new Wf,{gT:!1},c,f))];case 4:return[2]}var e,n})})},Zf.prototype.ST=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.pT=function(){if(this.qr.hh)throw new xr(Sr.FAILED_PRECONDITION,"The client has already been terminated.")},Zf.prototype.pl=function(t){return this.qr.Th(),Ys("FirestoreClient","Credential Changed. Current user: "+t.uid),this.cl.pl(t)},Zf.prototype.disableNetwork=function(){var t=this;return this.pT(),this.qr.enqueue(function(){return t.cl.disableNetwork()})},Zf.prototype.terminate=function(){var t=this;return this.qr.lh(function(){return y(t,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.dT&&this.dT.stop(),[4,this.Ld.Iu()];case 1:return t.sent(),[4,this.jd.Iu()];case 2:return t.sent(),[4,this.persistence.Iu()];case 3:return t.sent(),this.credentials.T(),[2]}})})})},Zf.prototype.waitForPendingWrites=function(){var t=this;this.pT();var e=new Ru;return this.qr.Hr(function(){return t.cl.Tf(e)}),e.promise},Zf.prototype.listen=function(t,e,n){var r=this;this.pT();var i=new bf(t,e,n);return this.qr.Hr(function(){return r.vT.listen(i)}),i},Zf.prototype.al=function(t){var e=this;this.DT||this.qr.Hr(function(){return e.vT.al(t)})},Zf.prototype.CT=function(t){var e=this;return this.pT(),this.qr.enqueue(function(){return e.L_.ec(t)}).then(function(t){if(t instanceof Io)return t;if(t instanceof To)return null;throw new xr(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.)")})},Zf.prototype.FT=function(i){var t=this;return this.pT(),this.qr.enqueue(function(){return y(t,void 0,void 0,function(){var e,n,r;return v(this,function(t){switch(t.label){case 0:return[4,this.L_.nc(i,!0)];case 1:return e=t.sent(),n=new yf(i,e.rc),r=n.yd(e.documents),[2,n.Zn(r,!1).snapshot]}})})})},Zf.prototype.write=function(t){var e=this;this.pT();var n=new Ru;return this.qr.Hr(function(){return e.cl.write(t,n)}),n.promise},Zf.prototype.ii=function(){return this.PT.ii},Zf.prototype.Ff=function(t){var e=this;this.pT(),this.qr.Hr(function(){return e.vT.Ff(t),Promise.resolve()})},Zf.prototype.Nf=function(t){this.DT||this.vT.Nf(t)},Object.defineProperty(Zf.prototype,"DT",{get:function(){return this.qr.hh},enumerable:!0,configurable:!0}),Zf.prototype.transaction=function(t){var e=this;this.pT();var n=new Ru;return this.qr.Hr(function(){return e.cl.runTransaction(e.qr,t,n),Promise.resolve()}),n.promise},Zf),Qf=(Jf.prototype.next=function(t){this.NT(this.observer.next,t)},Jf.prototype.error=function(t){this.NT(this.observer.error,t)},Jf.prototype.kT=function(){this.muted=!0},Jf.prototype.NT=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.PT=e,this.credentials=n,this.qr=r,this.clientId=eu.cn()}function $f(){return null!==Ff&&Ff.apply(this,arguments)||this}function tl(){}function el(t){this.persistence=t,this.Su=null,this.oT=null}function nl(t){var e=this;return(e=Bf.call(this)||this).Oa=t,e}function rl(t){var e=this;this.sT={},this.su=new wu(0),this.qa=!1,this.qa=!0,this.Ao=t(this),this.Ha=new Gf(this),this.rr=new Ma,this.ir=new Tf(this.rr,function(t){return e.Ao.iT(t)})}function il(t){this.persistence=t,this.Xf=new au(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Pr.min(),this.highestTargetId=0,this.Zf=0,this.tT=new fu,this.targetCount=0,this.eT=ba.Ko()}function ol(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 sl,ul,al=(Rl.prototype.MT=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.xT(t);case 5:return t.stringValue;case 6:return new Xh(gi(t.bytesValue));case 7:return this.OT(t.referenceValue);case 8:return this.BT(t.geoPointValue);case 9:return this.qT(t.arrayValue);case 10:return this.UT(t.mapValue);default:throw Zs()}},Rl.prototype.UT=function(t){var n=this,r={};return $r(t.fields||{},function(t,e){r[t]=n.MT(e)}),r},Rl.prototype.BT=function(t){return new cc(vi(t.latitude),vi(t.longitude))},Rl.prototype.qT=function(t){var e=this;return(t.values||[]).map(function(t){return e.MT(t)})},Rl.prototype.xT=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.MT(e);case"estimate":return this.LT(ui(t));default:return null}},Rl.prototype.LT=function(t){var e=yi(t),n=new Or(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},Rl.prototype.OT=function(t){var e=Cr.K(t);$s(Gs(e));var n=new uu(e.get(1),e.get(3)),r=new Qr(e.$(5));return n.isEqual(this.firestore.Lc)||Qs("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.Lc.projectId+"/"+this.firestore.Lc.database+") instead."),new dl(r,this.firestore,this.converter)},Rl),hl=Bu.Nh,cl=(Dl.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},Dl),fl=(Ll.prototype.settings=function(t){kh("Firestore.settings",arguments,1),Rh("Firestore.settings","object",1,t);var e=new cl(t);if(this.KT&&!this.JT.isEqual(e))throw new xr(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.JT=e).credentials&&(this.HT=function(t){if(!t)return new kr;switch(t.type){case"gapi":var e=t.ZT;return $s(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Rr(e,t.V||"0");case"provider":return t.ZT;default:throw new xr(Sr.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},Ll.prototype.enableNetwork=function(){return this.jT(),this.KT.enableNetwork()},Ll.prototype.disableNetwork=function(){return this.jT(),this.KT.disableNetwork()},Ll.prototype.enablePersistence=function(t){var e,n;if(this.KT)throw new xr(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&&Qs("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.YT,{gT:!0,cacheSizeBytes:this.JT.cacheSizeBytes,synchronizeTabs:r})},Ll.prototype.clearPersistence=function(){return y(this,void 0,void 0,function(){var r,e=this;return v(this,function(t){if(void 0!==this.KT&&!this.KT.DT)throw new xr(Sr.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return r=new Ru,[2,(this.WT.oh(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.YT.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)]})})},Ll.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(Ll.prototype,"sE",{get:function(){return this.jT(),this.KT.DT},enumerable:!0,configurable:!0}),Ll.prototype.waitForPendingWrites=function(){return this.jT(),this.KT.waitForPendingWrites()},Ll.prototype.onSnapshotsInSync=function(t){if(this.jT(),ol(t))return this.iE(t);Rh("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.iE(e)},Ll.prototype.iE=function(t){var e=this,n=new Qf({next:function(){t.next&&t.next()},error:function(t){throw Zs()}});return this.KT.Ff(n),function(){n.kT(),e.KT.Nf(n)}},Ll.prototype.jT=function(){return this.KT||this.tE(new Wf,{gT:!1}),this.KT},Ll.prototype.eE=function(){return new su(this.Lc,this.zT,this.JT.host,this.JT.ssl,this.JT.forceLongPolling)},Ll.prototype.tE=function(t,e){var n=this.eE();return this.KT=new Yf(zs.nt(),n,this.HT,this.WT),this.KT.start(t,e)},Ll.GT=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new xr(Sr.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new xr(Sr.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new uu(n)},Object.defineProperty(Ll.prototype,"app",{get:function(){if(!this.QT)throw new xr(Sr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.QT},enumerable:!0,configurable:!0}),Ll.prototype.collection=function(t){return kh("Firestore.collection",arguments,1),Rh("Firestore.collection","non-empty string",1,t),this.jT(),new bl(Cr.K(t),this)},Ll.prototype.doc=function(t){return kh("Firestore.doc",arguments,1),Rh("Firestore.doc","non-empty string",1,t),this.jT(),dl.nE(Cr.K(t),this)},Ll.prototype.collectionGroup=function(t){if(kh("Firestore.collectionGroup",arguments,1),Rh("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new xr(Sr.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.jT(),new ml(new Ao(Cr.G,t),this)},Ll.prototype.runTransaction=function(e){var n=this;return kh("Firestore.runTransaction",arguments,1),Rh("Firestore.runTransaction","function",1,e),this.jT().transaction(function(t){return e(new ll(n,t))})},Ll.prototype.batch=function(){return this.jT(),new pl(this)},Object.defineProperty(Ll,"logLevel",{get:function(){switch(Ws()){case l.DEBUG:return"debug";case l.SILENT:return"silent";default:return"error"}},enumerable:!0,configurable:!0}),Ll.setLogLevel=function(t){switch(kh("Firestore.setLogLevel",arguments,1),Rh("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":Xs(l.DEBUG);break;case"error":Xs(l.ERROR);break;case"silent":Xs(l.SILENT);break;default:throw new xr(Sr.INVALID_ARGUMENT,"Invalid log level: "+t)}},Ll.prototype.rE=function(){return this.JT.timestampsInSnapshots},Ll),ll=(kl.prototype.get=function(t){var n=this;kh("Transaction.get",arguments,1);var r=Cl("Transaction.get",t,this.hE);return this.oE.V_([r.xc]).then(function(t){if(!t||1!==t.length)return Zs();var e=t[0];if(e instanceof To)return new vl(n.hE,r.xc,null,!1,!1,r.aE);if(e instanceof Io)return new vl(n.hE,r.xc,e,!1,!1,r.aE);throw Zs()})},kl.prototype.set=function(t,e,n){Dh("Transaction.set",arguments,2,3);var r=Cl("Transaction.set",t,this.hE);n=Ol("Transaction.set",n);var i=Ml(r.aE,e,"Transaction.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.hE.XT.Nc(s,o,n.mergeFields):this.hE.XT.Cc(s,o);return this.oE.set(r.xc,u),this},kl.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 Yh?(Lh("Transaction.update",arguments,3),r=Cl("Transaction.update",t,this.hE),this.hE.XT.$c("Transaction.update",e,n,o)):(kh("Transaction.update",arguments,2),r=Cl("Transaction.update",t,this.hE),this.hE.XT.kc("Transaction.update",e)),this.oE.update(r.xc,i),this},kl.prototype.delete=function(t){kh("Transaction.delete",arguments,1);var e=Cl("Transaction.delete",t,this.hE);return this.oE.delete(e.xc),this},kl),pl=(xl.prototype.set=function(t,e,n){Dh("WriteBatch.set",arguments,2,3),this._E();var r=Cl("WriteBatch.set",t,this.hE);n=Ol("WriteBatch.set",n);var i=Ml(r.aE,e,"WriteBatch.set"),o=i[0],s=i[1],u=n.merge||n.mergeFields?this.hE.XT.Nc(s,o,n.mergeFields):this.hE.XT.Cc(s,o);return this.uE=this.uE.concat(u.gc(r.xc,Fi.ft())),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 this._E(),i="string"==typeof e||e instanceof Yh?(Lh("WriteBatch.update",arguments,3),r=Cl("WriteBatch.update",t,this.hE),this.hE.XT.$c("WriteBatch.update",e,n,o)):(kh("WriteBatch.update",arguments,2),r=Cl("WriteBatch.update",t,this.hE),this.hE.XT.kc("WriteBatch.update",e)),this.uE=this.uE.concat(i.gc(r.xc,Fi.exists(!0))),this},xl.prototype.delete=function(t){kh("WriteBatch.delete",arguments,1),this._E();var e=Cl("WriteBatch.delete",t,this.hE);return this.uE=this.uE.concat(new Ki(e.xc,Fi.ft())),this},xl.prototype.commit=function(){return this._E(),this.cE=!0,0<this.uE.length?this.hE.jT().write(this.uE):Promise.resolve()},xl.prototype._E=function(){if(this.cE)throw new xr(Sr.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},xl),dl=(Sl.nE=function(t,e,n){if(t.length%2!=0)throw new xr(Sr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.j()+" has "+t.length);return new Sl(new Qr(t),e,n)},Object.defineProperty(Sl.prototype,"id",{get:function(){return this.xc.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(Sl.prototype,"parent",{get:function(){return new bl(this.xc.path.M(),this.firestore,this.aE)},enumerable:!0,configurable:!0}),Object.defineProperty(Sl.prototype,"path",{get:function(){return this.xc.path.j()},enumerable:!0,configurable:!0}),Sl.prototype.collection=function(t){if(kh("DocumentReference.collection",arguments,1),Rh("DocumentReference.collection","non-empty string",1,t),!t)throw new xr(Sr.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Cr.K(t);return new bl(this.xc.path.child(e),this.firestore)},Sl.prototype.isEqual=function(t){if(!(t instanceof Sl))throw Bh("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.xc.isEqual(t.xc)&&this.aE===t.aE},Sl.prototype.set=function(t,e){Dh("DocumentReference.set",arguments,1,2),e=Ol("DocumentReference.set",e);var n=Ml(this.aE,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore.XT.Nc(i,r,e.mergeFields):this.firestore.XT.Cc(i,r);return this.KT.write(o.gc(this.xc,Fi.ft()))},Sl.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 Yh?(Lh("DocumentReference.update",arguments,2),this.firestore.XT.$c("DocumentReference.update",t,e,r)):(kh("DocumentReference.update",arguments,1),this.firestore.XT.kc("DocumentReference.update",t)),this.KT.write(n.gc(this.xc,Fi.exists(!0)))},Sl.prototype.delete=function(){return kh("DocumentReference.delete",arguments,0),this.KT.write([new Ki(this.xc,Fi.ft())])},Sl.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Dh("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||ol(t[i])||(Fh("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),Vh("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=ol(t[i])?t[i]:(Rh("DocumentReference.onSnapshot","function",i,t[i]),Oh("DocumentReference.onSnapshot","function",i+1,t[i+1]),Oh("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.lE(o,n)},Sl.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 Qf({next:function(t){if(n.next){var e=t.docs.get(r.xc);n.next(new vl(r.firestore,r.xc,e,t.fromCache,t.hasPendingWrites,r.aE))}},error:e}),o=this.KT.listen(Ao.Wt(this.xc.path),i,t);return function(){i.kT(),r.KT.al(o)}},Sl.prototype.get=function(n){var r=this;return Dh("DocumentReference.get",arguments,0,1),Vl("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.jT().CT(r.xc).then(function(t){e(new vl(r.firestore,r.xc,t,!0,t instanceof Io&&t.At,r.aE))},t):r.dE(e,t,n)})},Sl.prototype.dE=function(e,n,r){var i=this.lE({includeMetadataChanges:!0,Bf:!0},{next:function(t){i(),!t.exists&&t.metadata.fromCache?n(new xr(Sr.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new xr(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})},Sl.prototype.withConverter=function(t){return new Sl(this.xc,this.firestore,t)},Sl),yl=(Al.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},Al),vl=(_l.prototype.data=function(t){if(Dh("DocumentSnapshot.data",arguments,0,1),t=Pl("DocumentSnapshot.data",t),this.fE){if(this.aE){var e=new gl(this.hE,this.xc,this.fE,this.TE,this.EE);return this.aE.fromFirestore(e,t)}return new al(this.hE,this.hE.rE(),t.serverTimestamps,void 0).MT(this.fE.Mt())}},_l.prototype.get=function(t,e){if(Dh("DocumentSnapshot.get",arguments,1,2),e=Pl("DocumentSnapshot.get",e),this.fE){var n=this.fE.data().field(Dc("DocumentSnapshot.get",t));if(null!==n)return new al(this.hE,this.hE.rE(),e.serverTimestamps,this.aE).MT(n)}},Object.defineProperty(_l.prototype,"id",{get:function(){return this.xc.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(_l.prototype,"ref",{get:function(){return new dl(this.xc,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 yl(this.EE,this.TE)},enumerable:!0,configurable:!0}),_l.prototype.isEqual=function(t){if(!(t instanceof _l))throw Bh("isEqual","DocumentSnapshot",1,t);return this.hE===t.hE&&this.TE===t.TE&&this.xc.isEqual(t.xc)&&(null===this.fE?null===t.fE:this.fE.isEqual(t.fE))&&this.aE===t.aE},_l),gl=(n(Nl,ul=vl),Nl.prototype.data=function(t){return ul.prototype.data.call(this,t)},Nl),ml=(Tl.prototype.where=function(t,e,n){kh("Query.where",arguments,3),qh("Query.where",3,n);var r,i=function(t,e){if(!t.some(function(t){return t===e}))throw new xr(Sr.INVALID_ARGUMENT,"Invalid value "+Uh(e)+" provided to function Query.where() for its "+zh(2)+" argument. Acceptable values: "+t.join(", "));return e}(["<","<=","==",">=",">","array-contains","in","array-contains-any"],e),o=Dc("Query.where",t);if(o.Y()){if("array-contains"===i||"array-contains-any"===i)throw new xr(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.XT.Mc("Query.where",n,"in"===i);var c=So.create(o,i,r);return this.mE(c),new Tl(this.IE.Gt(c),this.firestore,this.aE)},Tl.prototype.orderBy=function(t,e){var n;if(Dh("Query.orderBy",arguments,1,2),Oh("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n="asc";else{if("desc"!==e)throw new xr(Sr.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n="desc"}if(null!==this.IE.startAt)throw new xr(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 xr(Sr.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=Dc("Query.orderBy",t),i=new Po(r,n);return this.AE(i),new Tl(this.IE.zt(i),this.firestore,this.aE)},Tl.prototype.limit=function(t){return kh("Query.limit",arguments,1),Rh("Query.limit","number",1,t),Gh("Query.limit",1,t),new Tl(this.IE.Ht(t),this.firestore,this.aE)},Tl.prototype.limitToLast=function(t){return kh("Query.limitToLast",arguments,1),Rh("Query.limitToLast","number",1,t),Gh("Query.limitToLast",1,t),new Tl(this.IE.Yt(t),this.firestore,this.aE)},Tl.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Lh("Query.startAt",arguments,1);var r=this.PE("Query.startAt",t,e,!0);return new Tl(this.IE.Jt(r),this.firestore,this.aE)},Tl.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Lh("Query.startAfter",arguments,1);var r=this.PE("Query.startAfter",t,e,!1);return new Tl(this.IE.Jt(r),this.firestore,this.aE)},Tl.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Lh("Query.endBefore",arguments,1);var r=this.PE("Query.endBefore",t,e,!0);return new Tl(this.IE.Xt(r),this.firestore,this.aE)},Tl.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Lh("Query.endAt",arguments,1);var r=this.PE("Query.endAt",t,e,!1);return new Tl(this.IE.Xt(r),this.firestore,this.aE)},Tl.prototype.isEqual=function(t){if(!(t instanceof Tl))throw Bh("isEqual","Query",1,t);return this.firestore===t.firestore&&this.IE.isEqual(t.IE)},Tl.prototype.withConverter=function(t){return new Tl(this.IE,this.firestore,t)},Tl.prototype.PE=function(t,e,n,r){if(qh(t,1,e),e instanceof vl){if(0<n.length)throw new xr(Sr.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new xr(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)},Tl.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.Lc,t.key));else{var s=t.field(o.field);if(si(s))throw new xr(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 xr(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 Oo(n,e)},Tl.prototype.gE=function(t,e,n){var r=this.IE.Ot;if(e.length>r.length)throw new xr(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 xr(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 xr(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(!Qr.et(u))throw new xr(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 Qr(u);i.push(mi(this.firestore.Lc,a))}else{var h=this.firestore.XT.Mc(t,s);i.push(h)}}return new Oo(i,n)},Tl.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Dh("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||ol(t[i])||(Fh("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),Vh("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=ol(t[i])?t[i]:(Rh("Query.onSnapshot","function",i,t[i]),Oh("Query.onSnapshot","function",i+1,t[i+1]),Oh("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)},Tl.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 Qf({next:function(t){e.next&&e.next(new wl(n.firestore,n.IE,t,n.aE))},error:r}),o=this.firestore.jT(),s=o.listen(this.IE,i,t);return function(){i.kT(),o.al(s)}},Tl.prototype.pE=function(t){if(t.ae()&&0===t.Ot.length)throw new xr(Sr.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},Tl.prototype.get=function(n){var r=this;return Dh("Query.get",arguments,0,1),Vl("Query.get",n),this.pE(this.IE),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.jT().FT(r.IE).then(function(t){e(new wl(r.firestore,r.IE,t,r.aE))},t):r.dE(e,t,n)})},Tl.prototype.dE=function(e,n,r){var i=this.lE({includeMetadataChanges:!0,Bf:!0},{next:function(t){i(),t.metadata.fromCache&&r&&"server"===r.source?n(new xr(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})},Tl.prototype.RE=function(t){if("string"==typeof t){if(""===t)throw new xr(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 xr(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(!Qr.et(e))throw new xr(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.Lc,new Qr(e))}if(t instanceof dl){var n=t;return mi(this.firestore.Lc,n.xc)}throw new xr(Sr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Uh(t)+".")},Tl.prototype.wE=function(t,e){if(!Array.isArray(t)||0===t.length)throw new xr(Sr.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new xr(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 xr(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 xr(Sr.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},Tl.prototype.mE=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 xr(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 xr(Sr.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new xr(Sr.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+u.toString()+"' filters.")}}},Tl.prototype.AE=function(t){if(null===this.IE.Kt()){var e=this.IE.jt();null!==e&&this.yE(e,t.field)}},Tl.prototype.yE=function(t,e){if(!e.isEqual(t))throw new xr(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.")},Tl),wl=(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;Dh("QuerySnapshot.forEach",arguments,1,2),Rh("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 ml(this.bE,this.hE,this.aE)},enumerable:!0,configurable:!0}),Il.prototype.docChanges=function(t){t&&(Fh("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),Vh("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.vE.hs)throw new xr(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 gl(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 gl(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 Zs()}}(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 Bh("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 gl(this.hE,t.key,t,this.metadata.fromCache,this.vE.ns.has(t.key),this.aE)},Il),bl=(n(El,sl=ml),Object.defineProperty(El.prototype,"id",{get:function(){return this.IE.path.O()},enumerable:!0,configurable:!0}),Object.defineProperty(El.prototype,"parent",{get:function(){var t=this.IE.path.M();return t.B()?null:new dl(new Qr(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(El.prototype,"path",{get:function(){return this.IE.path.j()},enumerable:!0,configurable:!0}),El.prototype.doc=function(t){if(Dh("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=eu.cn()),Rh("CollectionReference.doc","non-empty string",1,t),""===t)throw new xr(Sr.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Cr.K(t);return dl.nE(this.IE.path.child(e),this.firestore,this.aE)},El.prototype.add=function(t){kh("CollectionReference.add",arguments,1),Rh("CollectionReference.add","object",1,this.aE?this.aE.toFirestore(t):t);var e=this.doc();return e.set(t).then(function(){return e})},El.prototype.withConverter=function(t){return new El(this.FE,this.firestore,t)},El);function El(t,e,n){var r=this;if(((r=sl.call(this,Ao.Wt(t),e,n)||this).FE=t).length%2!=1)throw new xr(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 yl(n.hasPendingWrites,n.fromCache)}function Tl(t,e,n){this.IE=t,this.firestore=e,this.aE=n}function Nl(){return null!==ul&&ul.apply(this,arguments)||this}function _l(t,e,n,r,i,o){this.hE=t,this.xc=e,this.fE=n,this.TE=r,this.EE=i,this.aE=o}function Al(t,e){this.hasPendingWrites=t,this.fromCache=e}function Sl(t,e,n){this.xc=t,this.firestore=e,this.aE=n,this.KT=this.firestore.jT()}function xl(t){this.hE=t,this.uE=[],this.cE=!1}function kl(t,e){this.hE=t,this.oE=e}function Ll(t,e,n){var r=this;if(void 0===n&&(n=new Wf),this.QT=null,this.WT=new Vu,this.INTERNAL={delete:function(){return y(r,void 0,void 0,function(){return v(this,function(t){switch(t.label){case 0:return this.jT(),[4,this.KT.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var i=t;this.QT=i,this.Lc=Ll.GT(i),this.zT=i.name,this.HT=new Lr(e)}else{var o=t;if(!o.projectId)throw new xr(Sr.INVALID_ARGUMENT,"Must provide projectId");this.Lc=new uu(o.projectId,o.database),this.zT="[DEFAULT]",this.HT=new kr}this.YT=n,this.JT=new cl({}),this.XT=new Nc(this.Lc)}function Dl(t){var e,n;if(void 0===t.host){if(void 0!==t.ssl)throw new xr(Sr.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Ph("settings","non-empty string","host",t.host),this.host=t.host,Vh("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(Fh("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),Vh("settings","object","credentials",t.credentials),this.credentials=t.credentials,Vh("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?Qs("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&Qs("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,Vh("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=Bu.$h;else{if(t.cacheSizeBytes!==hl&&t.cacheSizeBytes<Bu.kh)throw new xr(Sr.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+Bu.kh);this.cacheSizeBytes=t.cacheSizeBytes}Vh("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}function Rl(t,e,n,r){this.firestore=t,this.timestampsInSnapshots=e,this.$T=n,this.converter=r}function Ol(t,e){if(void 0===e)return{merge:!1};if(Fh(t,e,["merge","mergeFields"]),Vh(t,"boolean","merge",e.merge),n=t,void 0!==(r=e.mergeFields)&&function(t,e,n,r){if(!(n instanceof Array))throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+Uh(n));for(var i=0;i<n.length;++i)if(!r(n[i]))throw new xr(Sr.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be a string or a FieldPath, but the value at index "+i+" was: "+Uh(n[i]))}(n,"mergeFields",r,function(t){return"string"==typeof t||t instanceof Yh}),void 0!==e.mergeFields&&void 0!==e.merge)throw new xr(Sr.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');var n,r;return e}function Pl(t,e){return void 0===e?{}:(Fh(t,e,["serverTimestamps"]),Ch(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function Vl(t,e){Oh(t,"object",1,e),e&&(Fh(t,e,["source"]),Ch(t,0,"source",e.source,["default","server","cache"]))}function Cl(t,e,n){if(e instanceof dl){if(e.firestore!==n)throw new xr(Sr.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Bh(t,"DocumentReference",1,e)}function Ml(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}function jl(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new xr(Sr.INVALID_ARGUMENT,t)}return n.prototype=t.prototype,Object.assign(n,t),n}var Ul,ql=jl(fl,"Use firebase.firestore() instead."),Fl=jl(ll,"Use firebase.firestore().runTransaction() instead."),Bl=jl(pl,"Use firebase.firestore().batch() instead."),Gl=jl(dl,"Use firebase.firestore().doc() instead."),zl=jl(vl),Hl=jl(gl),Kl=jl(ml),Wl=jl(wl),Xl=jl(bl,"Use firebase.firestore().collection() instead."),Yl=jl((ap.delete=function(){return xh("FieldValue.delete",arguments),new oc},ap.serverTimestamp=function(){return xh("FieldValue.serverTimestamp",arguments),new sc},ap.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Lh("FieldValue.arrayUnion",arguments,1),new uc(t)},ap.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Lh("FieldValue.arrayRemove",arguments,1),new ac(t)},ap.increment=function(t){return Rh("FieldValue.increment","number",1,t),kh("FieldValue.increment",arguments,1),new hc(t)},ap.prototype.isEqual=function(t){return this===t},ap),"Use FieldValue.<field>() instead."),Ql=jl(Xh,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Jl={Firestore:ql,GeoPoint:cc,Timestamp:Or,Blob:Ql,Transaction:Fl,WriteBatch:Bl,DocumentReference:Gl,DocumentSnapshot:zl,Query:Kl,QueryDocumentSnapshot:Hl,QuerySnapshot:Wl,CollectionReference:Xl,FieldPath:Yh,FieldValue:Yl,setLogLevel:fl.setLogLevel,CACHE_SIZE_UNLIMITED:hl},Zl=(up.prototype.Q_=function(t){},up.prototype.Iu=function(){},up),$l=(sp.prototype.Q_=function(t){this.LE.push(t)},sp.prototype.Iu=function(){window.removeEventListener("online",this.NE),window.removeEventListener("offline",this.$E)},sp.prototype.xE=function(){window.addEventListener("online",this.NE),window.addEventListener("offline",this.$E)},sp.prototype.kE=function(){Ys("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.LE;t<e.length;t++)(0,e[t])(0)},sp.prototype.ME=function(){Ys("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.LE;t<e.length;t++)(0,e[t])(1)},sp.so=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},sp),tp=(op.prototype.n_=function(t){this.qE=t},op.prototype.Zc=function(t){this.UE=t},op.prototype.onMessage=function(t){this.QE=t},op.prototype.close=function(){this.BE()},op.prototype.send=function(t){this.OE(t)},op.prototype.WE=function(){this.qE()},op.prototype.jE=function(t){this.UE(t)},op.prototype.KE=function(t){this.QE(t)},op),ep={BatchGetDocuments:"batchGet",Commit:"commit"},np="gl-js/ fire/"+Er,rp=(ip.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"]=np},ip.prototype.E_=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();Ys("Connection","XHR received:",JSON.stringify(t)),o(t);break;case gr.TIMEOUT:Ys("Connection",'RPC "'+a+'" timed out'),s(new xr(Sr.DEADLINE_EXCEEDED,"Request time out"));break;case gr.HTTP_ERROR:var e=u.getStatus();if(Ys("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 xr(r,n.message))}else s(new xr(Sr.UNKNOWN,"Server responded with status "+u.getStatus()))}else Ys("Connection",'RPC "'+a+'" failed'),s(new xr(Sr.UNAVAILABLE,"Connection failed."));break;default:Zs()}}finally{Ys("Connection",'RPC "'+a+'" completed.')}var i});var t=Object.assign({},r);delete t.database;var e=JSON.stringify(t);Ys("Connection","XHR sending: ",c+" "+e);var n={"Content-Type":"text/plain"};h.zE(n,i),u.send(c,"POST",e,n,15)})},ip.prototype.I_=function(t,e,n){return this.E_(t,e,n)},ip.prototype.r_=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)}})}Ys("Connection","Creating WebChannel: "+u+" "+s);var h=o.createWebChannel(u,s),c=!1,f=!1,l=new tp({OE:function(t){f?Ys("Connection","Not sending because WebChannel is closed:",t):(c||(Ys("Connection","Opening WebChannel transport."),h.open(),c=!0),Ys("Connection","WebChannel sending:",t),h.send(t))},BE:function(){return h.close()}});return a(wr.EventType.OPEN,function(){f||Ys("Connection","WebChannel transport opened.")}),a(wr.EventType.CLOSE,function(){f||(f=!0,Ys("Connection","WebChannel transport closed"),l.jE())}),a(wr.EventType.ERROR,function(t){f||(f=!0,Ys("Connection","WebChannel transport errored:",t),l.jE(new xr(Sr.UNAVAILABLE,"The operation could not be completed")))}),a(wr.EventType.MESSAGE,function(t){var e;if(!f){var n=t.data[0];$s(!!n);var r=n.error||(null===(e=n[0])||void 0===e?void 0:e.error);if(r){Ys("Connection","WebChannel received error:",r);var i=r.status,o=function(){var t=co[i];if(void 0!==t)return Jo(t)}(),s=r.message;void 0===o&&(o=Sr.INTERNAL,s="Unknown error status: "+i+" with message "+r.message),f=!0,l.jE(new xr(o,s)),h.close()}else Ys("Connection","WebChannel received:",n),l.KE(n)}}),setTimeout(function(){l.WE()},0),l},ip.prototype.HE=function(t){var e=ep[t];return this.GE+"/v1/projects/"+this.ii.projectId+"/databases/"+this.ii.database+"/documents:"+e},ip);function ip(t){this.ii=t.ii;var e=t.ssl?"https":"http";this.GE=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}function op(t){this.OE=t.OE,this.BE=t.BE}function sp(){var t=this;this.NE=function(){return t.kE()},this.$E=function(){return t.ME()},this.LE=[],this.xE()}function up(){}function ap(){}function hp(){this._c="undefined"!=typeof atob}zs.an((Object.defineProperty(hp.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(hp.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),hp.prototype.bT=function(t){return Promise.resolve(new rp(t))},hp.prototype.AT=function(){return new($l.so()?$l:Zl)},hp.prototype.Dc=function(t){return new Fs(t,{hi:!0})},hp.prototype.un=function(t){return JSON.stringify(t)},hp.prototype.atob=function(t){return atob(t)},hp.prototype.btoa=function(t){return btoa(t)},hp.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 hp)),(Ul=cp).INTERNAL.registerComponent(new E("firestore",function(t){return e=t.getProvider("app").getImmediate(),n=t.getProvider("auth-internal"),new fl(e,n,new Xf);var e,n},"PUBLIC").setServiceProps(Object.assign({},Jl))),Ul.registerVersion("@firebase/firestore","1.14.3")}).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
  