diff --git a/firebase-app.js b/firebase-app.js deleted file mode 100644 index 9ac213e..0000000 --- a/firebase-app.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).firebase=t()}(this,function(){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var r=function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}!function(){function e(){this.byteToCharMap_=null,this.charToByteMap_=null,this.byteToCharMapWebSafe_=null,this.charToByteMapWebSafe_=null,this.ENCODED_VALS_BASE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",this.HAS_NATIVE_SUPPORT="function"==typeof atob}Object.defineProperty(e.prototype,"ENCODED_VALS",{get:function(){return this.ENCODED_VALS_BASE+"+/="},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ENCODED_VALS_WEBSAFE",{get:function(){return this.ENCODED_VALS_BASE+"-_."},enumerable:!0,configurable:!0}),e.prototype.encodeByteArray=function(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var r=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[],o=0;o>2,p=(3&i)<<4|s>>4,f=(15&s)<<2|l>>6,h=63&l;c||(h=64,a||(f=64)),n.push(r[u],r[p],r[f],r[h])}return n.join("")},e.prototype.encodeString=function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(function(e){for(var t=[],r=0,n=0;n>6|192:(55296==(64512&o)&&n+1>18|240,t[r++]=o>>12&63|128):t[r++]=o>>12|224,o>>6&63|128),63&o|128)}return t}(e),t)},e.prototype.decodeString=function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],r=0,n=0;r>10)),t[n++]=String.fromCharCode(56320+(1023&a))}else{i=e[r++];var s=e[r++];t[n++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},e.prototype.decodeStringToByteArray=function(e,t){this.init_();for(var r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[],o=0;o>4;if(n.push(l),64!==s){var u=a<<4&240|s>>2;if(n.push(u),64!==c){var p=s<<6&192|c;n.push(p)}}}return n},e.prototype.init_=function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}}();function y(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var r in t)t.hasOwnProperty(r)&&(e[r]=y(e[r],t[r]));return e}var b=function(n){function o(e,t){var r=n.call(this,t)||this;return r.code=e,r.name="FirebaseError",Object.setPrototypeOf(r,o.prototype),Error.captureStackTrace&&Error.captureStackTrace(r,a.prototype.create),r}return function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(o,n),o}(Error),a=function(){function e(e,t,r){this.service=e,this.serviceName=t,this.errors=r}return e.prototype.create=function(e){for(var t,r,n=[],o=1;o"})):"Error",u=this.serviceName+": "+l+" ("+s+").",p=new b(s,u);try{for(var f=v(Object.keys(a)),h=f.next();!h.done;h=f.next()){var d=h.value;"_"!==d.slice(-1)&&(d in p&&console.warn('Overwriting FirebaseError base field "'+d+'" can cause unexpected behavior.'),p[d]=a[d])}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}return p},e}();var g=/\{\$([^}]+)}/g;function _(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function n(e,t){var r=new o(e,t);return r.subscribe.bind(r)}var s,e,o=function(){function e(e,t){var r=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(function(){e(r)}).catch(function(e){r.error(e)})}return e.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},e.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},e.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},e.prototype.subscribe=function(e,t,r){var n,o=this;if(void 0===e&&void 0===t&&void 0===r)throw new Error("Missing Observer.");void 0===(n=function(e,t){var r,n;if("object"!=typeof e||null===e)return!1;try{for(var o=v(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(a in e&&"function"==typeof e[a])return!0}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:r}).next&&(n.next=c),void 0===n.error&&(n.error=c),void 0===n.complete&&(n.complete=c);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{o.finalError?n.error(o.finalError):n.complete()}catch(e){}}),this.observers.push(n),i},e.prototype.unsubscribeOne=function(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},e.prototype.forEachObserver=function(e){if(!this.finalized)for(var t=0;t>>0),r=0;function y(t,e,n){return t.call.apply(t.bind,arguments)}function w(e,n,t){if(!e)throw Error();if(2/g,J=/"/g,z=/'/g,Y=/\x00/g,$=/[\x00&<>"']/;function Z(t,e){return-1!=t.indexOf(e)}function Q(t,e){return t")&&(t=t.replace(X,">")),-1!=t.indexOf('"')&&(t=t.replace(J,""")),-1!=t.indexOf("'")&&(t=t.replace(z,"'")),-1!=t.indexOf("\0")&&(t=t.replace(Y,"�"))),t}function ft(t){l.setTimeout(function(){throw t},0)}function dt(t,e){st||function(){if(l.Promise&&l.Promise.resolve){var t=l.Promise.resolve(void 0);st=function(){t.then(mt)}}else st=function(){var t=mt;!g(l.setImmediate)||l.Window&&l.Window.prototype&&!nt("Edge")&&l.Window.prototype.setImmediate==l.setImmediate?(at||(at=function(){var t=l.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!nt("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",t.src="",document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(""),t.close();var n="callImmediate"+Math.random(),i="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=I(function(t){"*"!=i&&t.origin!=i||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,i)}}}),void 0===t||nt("Trident")||nt("MSIE"))return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){l.setTimeout(t,0)};var e=new t,n={},i=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).yb;n.yb=null,t()}},function(t){i.next={yb:t},i=i.next,e.port2.postMessage(0)}}()),at(t)):l.setImmediate(t)}}(),pt||(st(),pt=!0),vt.add(t,e)}var pt=!1,vt=new C;function mt(){for(var t;n=e=void 0,n=null,(e=vt).a&&(n=e.a,e.a=e.a.next,e.a||(e.b=null),n.next=null),t=n;){try{t.a.call(t.b)}catch(t){ft(t)}P(R,t)}var e,n;pt=!1}function gt(t,e){if(this.a=bt,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=s)try{var n=this;t.call(e,function(t){Pt(n,yt,t)},function(t){if(!(t instanceof jt))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}Pt(n,wt,t)})}catch(t){Pt(this,wt,t)}}var bt=0,yt=2,wt=3;function It(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}It.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var Tt=new _(function(){return new It},function(t){t.reset()});function kt(t,e,n){var i=Tt.get();return i.g=t,i.b=e,i.f=n,i}function Et(t){if(t instanceof gt)return t;var e=new gt(s);return Pt(e,yt,t),e}function St(n){return new gt(function(t,e){e(n)})}function At(t,e,n){Ct(t,e,n,null)||dt(T(e,t))}function Nt(n){return new gt(function(i){var r=n.length,o=[];if(r)for(var t=function(t,e,n){r--,o[t]=e?{Eb:!0,value:n}:{Eb:!1,reason:n},0==r&&i(o)},e=0;eparseFloat($t)){qt=String(Qt);break t}}qt=$t}var te,ee={};function ne(s){return t=s,e=function(){for(var t=0,e=B(String(qt)).split("."),n=B(String(s)).split("."),i=Math.max(e.length,n.length),r=0;0==t&&r>>0);function Ce(e){return g(e)?e:(e[Pe]||(e[Pe]=function(t){return e.handleEvent(t)}),e[Pe])}function Re(){Ut.call(this),this.m=new ve(this),(this.Pb=this).Wa=null}function De(t,e,n,i,r){t.m.add(String(e),n,!1,i,r)}function Le(t,e,n,i,r){t.m.add(String(e),n,!0,i,r)}function xe(t,e,n,i){if(!(e=t.m.a[String(e)]))return!0;e=e.concat();for(var r=!0,o=0;o>4&15).toString(16)+(15&t).toString(16)}Be.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Qe(e,en,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.i)&&t.push(Qe(e,en,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.c)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(Qe(n,"/"==n.charAt(0)?rn:nn,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.g)&&t.push("#",Qe(n,an)),t.join("")},Be.prototype.resolve=function(t){var e=new Be(this),n=!!t.f;n?Ge(e,t.f):n=!!t.i,n?e.i=t.i:n=!!t.b,n?e.b=t.b:n=null!=t.m;var i=t.c;if(n)We(e,t.m);else if(n=!!t.c){if("/"!=i.charAt(0))if(this.b&&!this.c)i="/"+i;else{var r=e.c.lastIndexOf("/");-1!=r&&(i=e.c.substr(0,r+1)+i)}if(".."==(r=i)||"."==r)i="";else if(Z(r,"./")||Z(r,"/.")){i=0==r.lastIndexOf("/",0),r=r.split("/");for(var o=[],a=0;a2*t.c&&Fe(t)))}function ln(t,e){return un(t),e=pn(t,e),qe(t.a.b,e)}function fn(t,e,n){hn(t,e),0"),Ln(""),Ln("
");var jn={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function Un(t,e,n){var i=arguments,r=document,o=String(i[0]),a=i[1];if(!vn&&a&&(a.name||a.type)){if(o=["<",o],a.name&&o.push(' name="',lt(a.name),'"'),a.type){o.push(' type="',lt(a.type),'"');var s={};ct(s,a),delete s.type,a=s}o.push(">"),o=o.join("")}return o=r.createElement(o),a&&(h(a)?o.className=a:v(a)?o.className=a.join(" "):Mn(o,a)),2'),s.document.write((a=t)instanceof Rn&&a.constructor===Rn&&a.b===Dn?a.a:(O("expected object of type SafeHtml, got '"+a+"' of type "+p(a)),"type_error:SafeHtml")),s.document.close())):(s=i.open(Nn(e).toString(),n,s))&&t.noopener&&(s.opener=null),s)try{s.focus()}catch(t){}return s}var $n=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Zn=/^[^@]+@[^@]+$/;function Qn(){var e=null;return new gt(function(t){"complete"==l.document.readyState?t():(e=function(){t()},Te(window,"load",e))}).s(function(t){throw ke(window,"load",e),t})}function ti(t){return t=t||hi(),!("file:"!==vi()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function ei(){var t=l.window;try{return!(!t||t==t.top)}catch(t){return!1}}function ni(){return void 0!==l.WorkerGlobalScope&&"function"==typeof l.importScripts}function ii(){return Wh.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":Wh.INTERNAL.hasOwnProperty("node")?"Node":ni()?"Worker":"Browser"}function ri(){var t=ii();return"ReactNative"===t||"Node"===t}var oi="Firefox",ai="Chrome";function si(t){var e=t.toLowerCase();return Z(e,"opera/")||Z(e,"opr/")||Z(e,"opios/")?"Opera":Z(e,"iemobile")?"IEMobile":Z(e,"msie")||Z(e,"trident/")?"IE":Z(e,"edge/")?"Edge":Z(e,"firefox/")?oi:Z(e,"silk/")?"Silk":Z(e,"blackberry")?"Blackberry":Z(e,"webos")?"Webos":!Z(e,"safari/")||Z(e,"chrome/")||Z(e,"crios/")||Z(e,"android")?!Z(e,"chrome/")&&!Z(e,"crios/")||Z(e,"edge/")?Z(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":ai:"Safari"}var ui={Sc:"FirebaseCore-web",Uc:"FirebaseUI-web"};function ci(t,e){e=e||[];var n,i=[],r={};for(n in ui)r[ui[n]]=!0;for(n=0;n>4),64!=a&&(t(o<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(t,function(t){e+=String.fromCharCode(t)}),e}function ur(t){this.c=t.sub,this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function cr(t){return(t=hr(t))&&t.sub&&t.iss&&t.aud&&t.exp?new ur(t):null}function hr(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n Auth section -> Sign in method tab.",t):"http"==i||"https"==i?n=ht("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",Bi.call(this,e,n)}function fo(t,e,n){Bi.call(this,t,n),(t=e||{}).Ab&&Ci(this,"email",t.Ab),t.$&&Ci(this,"phoneNumber",t.$),t.credential&&Ci(this,"credential",t.credential)}function po(t){if(t.code){var e=t.code||"";0==e.indexOf(Wi)&&(e=e.substring(Wi.length));var n={credential:ro(t)};if(t.email)n.Ab=t.email;else if(t.phoneNumber)n.$=t.phoneNumber;else if(!n.credential)return new Bi(e,t.message||void 0);return new fo(e,n,t.message)}return null}function vo(){}function mo(t){return t.c||(t.c=t.b())}function go(){}function bo(t){if(t.f||"undefined"!=typeof XMLHttpRequest||"undefined"==typeof ActiveXObject)return t.f;for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n=function t(e){return e.c?e.c:e.a?t(e.a):(O("Root logger has no level set."),null)}(this).value)for(g(e)&&(e=e()),t=new To(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var _o,Po={},Co=null;function Ro(t){var e;if(Co||(Co=new ko(""),(Po[""]=Co).c=No),!(e=Po[t])){e=new ko(t);var n=t.lastIndexOf("."),i=t.substr(n+1);(n=Ro(t.substr(0,n))).b||(n.b={}),(n.b[i]=e).a=n,Po[t]=e}return e}function Do(t,e){t&&t.log(Oo,e,void 0)}function Lo(t){this.f=t}function xo(t){Re.call(this),this.u=t,this.readyState=Mo,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.i=new Headers,this.b=null,this.o="GET",this.g="",this.a=!1,this.h=Ro("goog.net.FetchXmlHttp"),this.l=this.c=this.f=null}E(Lo,vo),Lo.prototype.a=function(){return new xo(this.f)},Lo.prototype.b=(_o={},function(){return _o}),E(xo,Re);var Mo=0;function jo(t){t.c.read().then(t.bc.bind(t)).catch(t.Ma.bind(t))}function Uo(t,e){e&&t.f&&(t.status=t.f.status,t.statusText=t.f.statusText),t.readyState=4,t.f=null,t.c=null,t.l=null,Vo(t)}function Vo(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function Ko(t){Re.call(this),this.headers=new Ke,this.D=t||null,this.c=!1,this.A=this.a=null,this.h=this.N=this.l="",this.f=this.I=this.i=this.G=!1,this.g=0,this.u=null,this.o=Fo,this.v=this.O=!1}(t=xo.prototype).open=function(t,e){if(this.readyState!=Mo)throw this.abort(),Error("Error reopening a connection");this.o=t,this.g=e,this.readyState=1,Vo(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.i,method:this.o,credentials:void 0,cache:void 0};t&&(e.body=t),this.u.fetch(new Request(this.g,e)).then(this.gc.bind(this),this.Ma.bind(this))},t.abort=function(){this.response=this.responseText="",this.i=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,Uo(this,!1)),this.readyState=Mo},t.gc=function(t){this.a&&(this.f=t,this.b||(this.b=t.headers,this.readyState=2,Vo(this)),this.a&&(this.readyState=3,Vo(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.ec.bind(this),this.Ma.bind(this)):void 0!==l.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.l=new TextDecoder,jo(this)):t.text().then(this.fc.bind(this),this.Ma.bind(this)))))},t.bc=function(t){if(this.a){var e=this.l.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?Uo(this,!0):Vo(this),3==this.readyState&&jo(this)}},t.fc=function(t){this.a&&(this.response=this.responseText=t,Uo(this,!0))},t.ec=function(t){this.a&&(this.response=t,Uo(this,!0))},t.Ma=function(t){var e=this.h;e&&e.log(Ao,"Failed to fetch url "+this.g,t instanceof Error?t:Error(t)),this.a&&Uo(this,!0)},t.setRequestHeader=function(t,e){this.i.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.h)&&t.log(Ao,"Attempting to get response header but no headers have been received for url: "+this.g,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.h;return t&&t.log(Ao,"Attempting to get all response headers but no headers have been received for url: "+this.g,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},E(Ko,Re);var Fo="";Ko.prototype.b=Ro("goog.net.XhrIo");var qo=/^https?$/i,Ho=["POST","PUT"];function Bo(e,t,n,i,r){if(e.a)throw Error("[goog.net.XhrIo] Object is active with another request="+e.l+"; newUri="+t);n=n?n.toUpperCase():"GET",e.l=t,e.h="",e.N=n,e.G=!1,e.c=!0,e.a=e.D?e.D.a():co.a(),e.A=e.D?mo(e.D):mo(co),e.a.onreadystatechange=I(e.Jb,e);try{Do(e.b,Qo(e,"Opening Xhr")),e.I=!0,e.a.open(n,String(t),!0),e.I=!1}catch(t){return Do(e.b,Qo(e,"Error opening Xhr: "+t.message)),void Wo(e,t)}t=i||"";var o,a=new Ke(e.headers);r&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(m(t)||h(t))x(t,e,void 0);else for(var n=Ve(t),i=Ue(t),r=i.length,o=0;o>>7|r<<25)^(r>>>18|r<<14)^r>>>3)|0,a=(0|n[e-7])+((i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10)|0;n[e]=o+a|0}i=0|t.a[0],r=0|t.a[1];var s=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;e<64;e++){var f=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&r^i&s^r&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|mu[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=r,r=i,i=a+f|0}t.a[0]=t.a[0]+i|0,t.a[1]=t.a[1]+r|0,t.a[2]=t.a[2]+s|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function Au(t,e,n){void 0===n&&(n=e.length);var i=0,r=t.c;if(h(e))for(;i>r&255;return M(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}function Du(t,e){for(var n=0;nt.f&&(t.a=t.f),e)}function ac(t){this.f=t,this.b=this.a=null,this.c=0}function sc(t,e){var n=e[ya],i=e.refreshToken;e=uc(e.expiresIn),t.b=n,t.c=e,t.a=i}function uc(t){return k()+1e3*parseInt(t,10)}function cc(e,t){return(i=e.f,r=t,new gt(function(e,n){"refresh_token"==r.grant_type&&r.refresh_token||"authorization_code"==r.grant_type&&r.code?Aa(i,i.i+"?key="+encodeURIComponent(i.b),function(t){t?t.error?n(ms(t)):t.access_token&&t.refresh_token?e(t):n(new Bi("internal-error")):n(new Bi("network-request-failed"))},"POST",cn(r).toString(),i.f,i.m.get()):n(new Bi("internal-error"))})).then(function(t){return e.b=t.access_token,e.c=uc(t.expires_in),e.a=t.refresh_token,{accessToken:e.b,expirationTime:e.c,refreshToken:e.a}}).s(function(t){throw"auth/user-token-expired"==t.code&&(e.a=null),t});var i,r}function hc(t,e){this.a=t||null,this.b=e||null,Ri(this,{lastSignInTime:Si(e||null),creationTime:Si(t||null)})}function lc(t,e,n,i,r,o){Ri(this,{uid:t,displayName:i||null,photoURL:r||null,email:n||null,phoneNumber:o||null,providerId:e})}function fc(t,e){for(var n in ue.call(this,t),e)this[n]=e[n]}function dc(t,e,n){var i;this.G=[],this.l=t.apiKey,this.o=t.appName,this.u=t.authDomain||null,t=Wh.SDK_VERSION?ci(Wh.SDK_VERSION):null,this.c=new ga(this.l,dr(lr),t),this.h=new ac(this.c),wc(this,e[ya]),sc(this.h,e),Ci(this,"refreshToken",this.h.a),kc(this,n||{}),Re.call(this),this.I=!1,this.u&&di()&&(this.a=Ju(this.u,this.l,this.o)),this.N=[],this.i=null,this.A=(i=this,new rc(function(){return i.F(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var t=i.h.c-k()-3e5;return 0this.c-3e4?this.a?cc(this,{grant_type:"refresh_token",refresh_token:this.a}):Et(null):Et({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},hc.prototype.w=function(){return{lastLoginAt:this.b,createdAt:this.a}},E(fc,ue),E(dc,Re),dc.prototype.pa=function(t){this.ka=t,Ea(this.c,t)},dc.prototype.ea=function(){return this.ka},dc.prototype.ya=function(){return q(this.O)},dc.prototype.Ha=function(){this.A.b&&(this.A.stop(),this.A.start())},Ci(dc.prototype,"providerId","firebase"),(t=dc.prototype).reload=function(){var t=this;return Vc(this,Sc(this).then(function(){return Cc(t).then(function(){return Ic(t)}).then(Ec)}))},t.ac=function(t){return this.F(t).then(function(t){return new ic(t)})},t.F=function(t){var e=this;return Vc(this,Sc(this).then(function(){return e.h.getToken(t)}).then(function(t){if(!t)throw new Bi("internal-error");return t.accessToken!=e.ra&&(wc(e,t.accessToken),e.dispatchEvent(new fc("tokenChanged"))),_c(e,"refreshToken",t.refreshToken),t.accessToken}))},t.wc=function(t){if(!(t=t.users)||!t.length)throw new Bi("internal-error");kc(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt});for(var e=(i=(i=t).providerUserInfo)&&i.length?M(i,function(t){return new lc(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[],n=0;n=Dh.length)throw new Bi("internal-error","Argument validator received an unsupported number of arguments.");n=Dh[r],i=(i?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.K+".";break t}i=null}}if(i)throw new Bi("argument-error",t+" failed: "+i)}(t=kh.prototype).za=function(){var e=this;return this.f?this.f:this.f=_h(this,Et().then(function(){if(pi()&&!ni())return Qn();throw new Bi("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return e.o.g(e.v())}).then(function(t){return e.g=t,ps(e.u,ts,{})}).then(function(t){e.a[Ah]=t.recaptchaSiteKey}).s(function(t){throw e.f=null,t}))},t.render=function(){Ph(this);var n=this;return _h(this,this.za().then(function(){if(null===n.c){var t=n.l;if(!n.i){var e=xn(t);t=Un("DIV"),e.appendChild(t)}n.c=n.g.render(t,n.a)}return n.c}))},t.verify=function(){Ph(this);var r=this;return _h(this,this.render().then(function(e){return new gt(function(n){var t=r.g.getResponse(e);if(t)n(t);else{var i=function(t){var e;t&&(e=i,K(r.m,function(t){return t==e}),n(t))};r.m.push(i),r.i&&r.g.execute(r.c)}})}))},t.reset=function(){Ph(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){Ph(this),this.D=!0,this.o.c();for(var t=0;ta[0]&&e[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function f(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0>2,l=(3&o)<<4|s>>4,f=(15&s)<<2|c>>6,d=63&c;u||(d=64,a||(f=64)),r.push(n[h],n[l],n[f],n[d])}return r.join("")},t.prototype.encodeString=function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(function(t){for(var e=[],n=0,r=0;r>6|192:(55296==(64512&i)&&r+1>18|240,e[n++]=i>>12&63|128):e[n++]=i>>12|224,i>>6&63|128),63&i|128)}return e}(t),e)},t.prototype.decodeString=function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,r=0;n>10)),e[r++]=String.fromCharCode(56320+(1023&a))}else{o=t[n++];var s=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&s)}}return e.join("")}(this.decodeStringToByteArray(t,e))},t.prototype.decodeStringToByteArray=function(t,e){this.init_();for(var n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4;if(r.push(c),64!==s){var h=a<<4&240|s>>2;if(r.push(h),64!==u){var l=s<<6&192|u;r.push(l)}}}return r},t.prototype.init_=function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}}();function l(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var y=function(r){function i(t,e){var n=r.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,i.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,d.prototype.create),n}return s(i,r),i}(Error),d=function(){function t(t,e,n){this.service=t,this.serviceName=e,this.errors=n}return t.prototype.create=function(t){for(var e,n,r=[],i=1;i"})):"Error",h=this.serviceName+": "+c+" ("+s+").",l=new y(s,h);try{for(var f=C(Object.keys(a)),d=f.next();!d.done;d=f.next()){var p=d.value;"_"!==p.slice(-1)&&(p in l&&console.warn('Overwriting FirebaseError base field "'+p+'" can cause unexpected behavior.'),l[p]=a[p])}}catch(t){e={error:t}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(e)throw e.error}}return l},t}();var p,m=/\{\$([^}]+)}/g,g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},v=v||{},w=g;function E(t){return"string"==typeof t}function S(t){return"number"==typeof t}function T(t,e){t=t.split("."),e=e||w;for(var n=0;n>>0),M=0;function _(t,e,n){return t.call.apply(t.bind,arguments)}function O(e,n,t){if(!e)throw Error();if(2parseFloat(ht)){et=String(ft);break t}}et=ht}var dt,pt={};function yt(s){return t=s,e=function(){for(var t=0,e=G(String(et)).split("."),n=G(String(s)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i>>0);function Bt(e){return"function"==D(e)?e:(e[Ft]||(e[Ft]=function(t){return e.handleEvent(t)}),e[Ft])}function Ut(){V.call(this),this.c=new At(this),(this.J=this).B=null}function Qt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;oe.length?Re:(e=e.substr(r,n),t.A=r+n,e))}function Pe(t){t.R=P()+t.O,qe(t,t.O)}function qe(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=me(x(t.bb,t),e)}function Ve(t){t.i&&(w.clearTimeout(t.i),t.i=null)}function Fe(t){t.g.Da()||t.m||t.g.na(t)}function Be(t){Ve(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,ee(t.P),ue(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function Ue(t,e){try{t.g.Ga(t,e),fe(4)}catch(t){}}function Qe(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(N(t)||E(t))B(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(N(t)||E(t)){n=[];for(var r=t.length,i=0;i2*t.c&&Ge(t))}function Ge(t){if(t.c!=t.a.length){for(var e=0,n=0;e>4&15).toString(16)+(15&t).toString(16)}He.prototype.toString=function(){var t=[],e=this.f;e&&t.push(on(e,sn,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.j)&&t.push(on(e,sn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(on(n,"/"==n.charAt(0)?cn:un,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",on(n,ln)),t.join("")},He.prototype.resolve=function(t){var e=Ye(this),n=!!t.f;n?Xe(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?Je(e,t.b):n=null!=t.i;var r=t.a;if(n)Ze(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(j(i,"./")||j(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a=t.f}function kn(t){return t.b?1:t.a?t.a.a.c:0}function Rn(t,e){return t=t.b?t.b==e:!!t.a&&(e=Tn(e),je(t.a.a.b,e))}function Mn(t,e){t.a?t.a.add(e):t.b=e}function _n(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=Tn(e),n=je(t.a.a.b,n)),n&&We(t.a.a,Tn(e)))}function On(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return Q(t.c);var e=t.c;return B(t.a.C(),function(t){e=e.concat(t.j)}),e}function xn(){}function Ln(){this.a=new xn}function Pn(t,r,e){var i=e||"";try{Qe(t,function(t,e){var n=t;k(t)&&(n=Kt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function qn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}Cn.prototype.cancel=function(){var t;this.c=On(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(B(this.a.C(),function(t){t.cancel()}),(t=this.a.a).b={},t.a.length=0,t.c=0)},xn.prototype.stringify=function(t){return w.JSON.stringify(t,void 0)},xn.prototype.parse=function(t){return w.JSON.parse(t,void 0)};var Vn=w.JSON.parse;function Fn(t){Ut.call(this),this.headers=new Ke,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=Bn,this.D=this.F=!1}q(Fn,Ut);var Bn="",Un=/^https?$/i,Qn=["POST","PUT"];function Kn(t){return"content-type"==t.toLowerCase()}function Wn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Gn(t),zn(t)}function Gn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function jn(t){if(t.b&&void 0!==v&&(!t.s[1]||4!=Yn(t)||2!=t.T()))if(t.l&&4==Yn(t))ne(t.Fa,0,t);else if(t.dispatchEvent("readystatechange"),4==Yn(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.A).match(ze)[1]||null;if(!o&&w.self&&w.self.location){var a=w.self.location.protocol;o=a.substr(0,a.length-1)}i=!Un.test(o?o.toLowerCase():"")}e=i}e?(t.dispatchEvent("complete"),t.dispatchEvent("success")):(t.h=6,t.f=t.za()+" ["+t.T()+"]",Gn(t))}finally{zn(t)}}}function zn(t,e){if(t.a){Hn(t);var n=t.a,r=t.s[0]?I:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function Hn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(w.clearTimeout(t.m),t.m=null)}function Yn(t){return t.a?t.a.readyState:0}function Xn(t,e){return t.a?t.a.getResponseHeader(e):null}function Jn(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;var i;if(i="",X(n,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),n=i,E(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if((n=t.indexOf("#"))<0&&(n=t.length),(r=t.indexOf("?"))<0||n=e.b.f-(e.h?1:0)||(e.h?(e.f=n.j.concat(e.f),0):1==e.u||2==e.u||e.A>=(e.Pa?0:e.Qa)||(e.h=me(x(e.Ia,e,n),hr(e,e.A)),e.A++,0))))&&(2!=i||!sr(this)))switch(r&&0r)throw new Ur(Br.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+li(e.length,"argument")+".")}function Zr(t,e,n,r){ii(t,e,hi(n)+" argument",r)}function $r(t,e,n,r){void 0!==r&&Zr(t,e,n,r)}function ti(t,e,n,r){ii(t,e,n+" option",r)}function ei(t,e,n,r){void 0!==r&&ti(t,e,n,r)}function ni(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new Ur(Br.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+ai(r));for(var o=0;ot.length&&Pr("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&Pr("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n},n.prototype.construct=function(t,e,n){var r=Object.create(Object.getPrototypeOf(this));return r.init(t,e,n),r},Object.defineProperty(n.prototype,"length",{get:function(){return this.len},enumerable:!0,configurable:!0}),n.prototype.isEqual=function(t){return 0===n.comparator(this,t)},n.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof n?t.forEach(function(t){e.push(t)}):"string"==typeof t?e.push(t):Pr("Unknown parameter type for Path.child(): "+t),this.construct(e)},n.prototype.limit=function(){return this.offset+this.length},n.prototype.popFirst=function(t){return t=void 0===t?1:t,qr(this.length>=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},n.prototype.popLast=function(){return qr(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},n.prototype.firstSegment=function(){return qr(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},n.prototype.lastSegment=function(){return this.get(this.length-1)},n.prototype.get=function(t){return qr(te.length?1:0},n}(),Ni=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.canonicalString=function(){return this.toArray().join("/")},e.prototype.toString=function(){return this.canonicalString()},e.fromString=function(t){if(0<=t.indexOf("//"))throw new Ur(Br.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new e(t.split("/").filter(function(t){return 0=i,"Should have found mutation after "+i),o=r.serializer.fromDbMutationBatch(e)),n.done()}).next(function(){return o})},i.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return mo(t).loadAll(na.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.fromDbMutationBatch(t)})})},i.prototype.getAllMutationBatchesAffectingDocumentKey=function(u,c){var h=this,t=ra.prefixForPath(this.userId,c.path),e=IDBKeyRange.lowerBound(t),l=[];return go(u).iterate({range:e},function(e,t,n){var r=f(e,3),i=r[0],o=r[1],a=r[2],s=Qi(o);if(i===h.userId&&c.path.isEqual(s))return mo(u).get(a).next(function(t){if(!t)throw Pr("Dangling document-mutation reference found: "+e+" which points to "+a);qr(t.userId===h.userId,"Unexpected user '"+t.userId+"' for mutation batch "+a),l.push(h.serializer.fromDbMutationBatch(t))});n.done()}).next(function(){return l})},i.prototype.getAllMutationBatchesAffectingDocumentKeys=function(r,t){var c=this,h=new Yi(di),i=[];return t.forEach(function(u){var t=ra.prefixForPath(c.userId,u.path),e=IDBKeyRange.lowerBound(t),n=go(r).iterate({range:e},function(t,e,n){var r=f(t,3),i=r[0],o=r[1],a=r[2],s=Qi(o);i===c.userId&&u.path.isEqual(s)?h=h.add(a):n.done()});i.push(n)}),ho.waitFor(i).next(function(){return c.lookupMutationBatches(r,h)})},i.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var u=this;qr(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),qr(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var c=e.path,h=c.length+1,n=ra.prefixForPath(this.userId,c),r=IDBKeyRange.lowerBound(n),l=new Yi(di);return go(t).iterate({range:r},function(t,e,n){var r=f(t,3),i=r[0],o=r[1],a=r[2],s=Qi(o);i===u.userId&&c.isPrefixOf(s)?s.length===h&&(l=l.add(a)):n.done()}).next(function(){return u.lookupMutationBatches(t,l)})},i.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(mo(t).get(e).next(function(t){if(null===t)throw Pr("Dangling document-mutation reference found, which points to "+e);qr(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))}))}),ho.waitFor(i).next(function(){return r})},i.prototype.removeMutationBatch=function(e,n){var r=this;return po(e.simpleDbTransaction,this.userId,n).next(function(t){return r.removeCachedMutationKeys(n.batchId),ho.forEach(t,function(t){return r.referenceDelegate.removeMutationReference(e,t)})})},i.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},i.prototype.performConsistencyCheck=function(n){var o=this;return this.checkEmpty(n).next(function(t){if(!t)return ho.resolve();var e=IDBKeyRange.lowerBound(ra.prefixForUser(o.userId)),i=[];return go(n).iterate({range:e},function(t,e,n){if(t[0]===o.userId){var r=Qi(t[1]);i.push(r)}else n.done()}).next(function(){qr(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.canonicalString()}))})})},i.prototype.containsKey=function(t,e){return fo(t,this.userId,e)},i.prototype.getMutationQueueMetadata=function(t){var e=this;return vo(t).get(this.userId).next(function(t){return t||new ea(e.userId,-1,"")})},i}();function fo(t,a,e){var n=ra.prefixForPath(a,e.path),s=n[1],r=IDBKeyRange.lowerBound(n),u=!1;return go(t).iterate({range:r,keysOnly:!0},function(t,e,n){var r=f(t,3),i=r[0],o=r[1];r[2];i===a&&o===s&&(u=!0),n.done()}).next(function(){return u})}function po(t,e,n){var r,i,o=t.store(na.store),a=t.store(ra.store),s=[],u=IDBKeyRange.only(n.batchId),c=0,h=o.iterate({range:u},function(t,e,n){return c++,n.delete()});s.push(h.next(function(){qr(1===c,"Dangling document-mutation reference found: Missing batch "+n.batchId)}));var l=[];try{for(var f=C(n.mutations),d=f.next();!d.done;d=f.next()){var p=d.value,y=ra.key(e,p.key.path,n.batchId);s.push(a.delete(y)),l.push(p.key)}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}return ho.waitFor(s).next(function(){return l})}function yo(t){return t instanceof Uint8Array?(qr("YES"===process.env.USE_MOCK_PERSISTENCE,"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function mo(t){return _a.getStore(t,na.store)}function go(t){return _a.getStore(t,ra.store)}function vo(t){return _a.getStore(t,ea.store)}var bo,wo;(wo=bo||(bo={}))[wo.QueryCache=0]="QueryCache",wo[wo.SyncEngine=1]="SyncEngine";var Eo=function(){function t(t,e){qr((1&(this.generatorId=t))===t,"Generator ID "+t+" contains more than 1 reserved bits"),this.seek(void 0!==e?e:this.generatorId)}return t.prototype.next=function(){var t=this.nextId;return this.nextId+=2,t},t.prototype.after=function(t){return this.seek(t+2),this.next()},t.prototype.seek=function(t){qr((1&t)===this.generatorId,"Cannot supply target ID from different generator ID"),this.nextId=t},t.forQueryCache=function(){return new t(bo.QueryCache,2)},t.forSyncEngine=function(){return new t(bo.SyncEngine)},t}(),So="SimpleDb",To=function(){function s(t){this.db=t,12.2===s.getIOSVersion(l())&&xr("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return s.openOrCreate=function(o,t,a){return qr(s.isAvailable(),"IndexedDB not supported in current environment."),Or(So,"Opening database:",o),new ho(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new s(e))},i.onblocked=function(){r(new Ur(Br.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 Ur(Br.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){Or(So,'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result,n=new Co(i.transaction);a.createOrUpgrade(e,n,t.oldVersion,Jo).next(function(){Or(So,"Database upgrade to version "+Jo+" complete")})}}).toPromise()},s.delete=function(t){return Or(So,"Removing database:",t),Ao(window.indexedDB.deleteDatabase(t)).toPromise()},s.isAvailable=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(void 0===window.navigator)return"YES"===process.env.USE_MOCK_PERSISTENCE;var t=l(),e=s.getIOSVersion(t),n=0",t),this.store.put(t)))},t.prototype.add=function(t){return Or(So,"ADD",this.store.name,t,t),Ao(this.store.add(t))},t.prototype.get=function(e){var n=this;return Ao(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Or(So,"GET",n.store.name,e,t),t})},t.prototype.delete=function(t){return Or(So,"DELETE",this.store.name,t),Ao(this.store.delete(t))},t.prototype.count=function(){return Or(So,"COUNT",this.store.name),Ao(this.store.count())},t.prototype.loadAll=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.iterateCursor(n,function(t,e){r.push(e)}).next(function(){return r})},t.prototype.deleteAll=function(t,e){Or(So,"DELETE ALL",this.store.name);var n=this.options(t,e);n.keysOnly=!1;var r=this.cursor(n);return this.iterateCursor(r,function(t,e,n){return n.delete()})},t.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},t.prototype.iterateSerial=function(i){var t=this.cursor({});return new ho(function(n,r){t.onerror=function(t){var e=ko(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()}})},t.prototype.iterateCursor=function(t,a){var s=[];return new ho(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 Io(e),r=a(e.primaryKey,e.value,n);if(r instanceof ho){var i=r.catch(function(t){return n.done(),ho.reject(t)});s.push(i)}n.isDone?o():null===n.skipToKey?e.continue():e.continue(n.skipToKey)}else o()}}).next(function(){return ho.waitFor(s)})},t.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(qr(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.keysOnly?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function Ao(t){return new ho(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=ko(t.target.error);r(e)}})}var No=!1;function ko(t){var e=To.getIOSVersion(l());if(12.2<=e&&e<13){var n="An internal error was encountered in the Indexed Database server";if(0<=t.message.indexOf(n)){var r=new Ur("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 No||(No=!0,setTimeout(function(){throw r},0)),r}}return t}var Ro=function(){function t(t,e){this.referenceDelegate=t,this.serializer=e,this.targetIdGenerator=Eo.forQueryCache()}return t.prototype.allocateTargetId=function(e){var n=this;return this.retrieveMetadata(e).next(function(t){return t.highestTargetId=n.targetIdGenerator.after(t.highestTargetId),n.saveMetadata(e,t).next(function(){return t.highestTargetId})})},t.prototype.getLastRemoteSnapshotVersion=function(t){return this.retrieveMetadata(t).next(function(t){return Wi.fromTimestamp(new Ki(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},t.prototype.getHighestSequenceNumber=function(t){return Oo(t.simpleDbTransaction)},t.prototype.setTargetsMetadata=function(e,n,r){var i=this;return this.retrieveMetadata(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.toTimestamp()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.saveMetadata(e,t)})},t.prototype.addQueryData=function(e,n){var r=this;return this.saveQueryData(e,n).next(function(){return r.retrieveMetadata(e).next(function(t){return t.targetCount+=1,r.updateMetadataFromQueryData(n,t),r.saveMetadata(e,t)})})},t.prototype.updateQueryData=function(t,e){return this.saveQueryData(t,e)},t.prototype.removeQueryData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return Mo(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return qr(0e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.getQueryCount=function(t){return this.retrieveMetadata(t).next(function(t){return t.targetCount})},t.prototype.getQueryData=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),a=null;return Mo(t).iterate({range:n,index:ua.queryTargetsIndexName},function(t,e,n){var r=o.serializer.fromDbTarget(e);i.isEqual(r.query)&&(a=r,n.done())}).next(function(){return a})},t.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],a=xo(n);return t.forEach(function(t){var e=Fi(t.path);o.push(a.put(new ca(r,e))),o.push(i.referenceDelegate.addReference(n,t))}),ho.waitFor(o)},t.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=xo(n);return ho.forEach(t,function(t){var e=Fi(t.path);return ho.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,t)])})},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=xo(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=xo(t),o=oo();return r.iterate({range:n,keysOnly:!0},function(t,e,n){var r=Qi(t[1]),i=new Mi(r);o=o.add(i)}).next(function(){return o})},t.prototype.containsKey=function(t,e){var n=Fi(e.path),r=IDBKeyRange.bound([n],[yi(n)],!1,!0),o=0;return xo(t).iterate({index:ca.documentTargetsIndex,keysOnly:!0,range:r},function(t,e,n){var r=f(t,2),i=r[0];r[1];0!==i&&(o++,n.done())}).next(function(){return 0h.params.maximumSequenceNumbersToCollect?(Or("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+t),h.params.maximumSequenceNumbersToCollect):t,a=Date.now(),h.nthSequenceNumber(e,i)}).next(function(t){return r=t,s=Date.now(),h.removeTargets(e,r,n)}).next(function(t){return o=t,u=Date.now(),h.removeOrphanedDocuments(e,r)}).next(function(t){(c=Date.now(),Mr()<=Er.DEBUG)&&Or("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(a-l)+"ms\n\tDetermined least recently used "+i+" in "+(s-a)+"ms\n\tRemoved "+o+" targets in "+(u-s)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms");return ho.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},t}(),Na="IndexedDbPersistence",ka="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Ra="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",Ma=function(r){function t(t,e){var n=r.call(this)||this;return n.simpleDbTransaction=t,n.currentSequenceNumber=e,n}return s(t,r),t}(function(){}),_a=function(){function c(t,e,n,r,i,o,a){if(this.persistenceKey=t,this.clientId=e,this.queue=r,this.multiClientParams=a,this._started=!1,this.isPrimary=!1,this.networkEnabled=!0,this.inForeground=!1,this.lastGarbageCollectionTime=Number.NEGATIVE_INFINITY,this.primaryStateListener=function(t){return Promise.resolve()},!c.isAvailable())throw new Ur(Br.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");if(this.referenceDelegate=new Ba(this,o),this.dbName=t+c.MAIN_DATABASE,this.serializer=new Ea(i),this.document=n.document,this.allowTabSynchronization=void 0!==a,this.queryCache=new Ro(this.referenceDelegate,this.serializer),this.indexManager=new va,this.remoteDocumentCache=new Qo(this.serializer,this.indexManager,this.allowTabSynchronization),!n.window||!n.window.localStorage)throw new Ur(Br.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=n.window,this.webStorage=this.window.localStorage}return c.getStore=function(t,e){if(t instanceof Ma)return To.getStore(t.simpleDbTransaction,e);throw Pr("IndexedDbPersistence must use instances of IndexedDbTransaction")},c.createIndexedDbPersistence=function(n,r,i,o,a,s){return h(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,(e=new c(n,r,i,o,a,s)).start()];case 1:return t.sent(),[2,e]}})})},c.createMultiClientIndexedDbPersistence=function(n,r,i,o,a,s,u){return h(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,(e=new c(n,r,i,o,a,s,u)).start()];case 1:return t.sent(),[2,e]}})})},c.prototype.start=function(){var n=this;return qr(!this.started,"IndexedDbPersistence double-started!"),qr(null!==this.window,"Expected 'window' to be defined"),To.openOrCreate(this.dbName,Jo,new Zo(this.serializer)).then(function(t){return n.simpleDb=t,n.updateClientMetadataAndTryBecomePrimary()}).then(function(){return n.attachVisibilityHandler(),n.attachWindowUnloadHook(),n.scheduleClientMetadataAndPrimaryLeaseRefreshes(),n.startRemoteDocumentCache()}).then(function(){return n.simpleDb.runTransaction("readonly",[ha.store],function(t){return Oo(t).next(function(t){var e=n.multiClientParams?n.multiClientParams.sequenceNumberSyncer:void 0;n.listenSequence=new Ci(t,e)})})}).then(function(){n._started=!0}).catch(function(t){return n.simpleDb&&n.simpleDb.close(),Promise.reject(t)})},c.prototype.startRemoteDocumentCache=function(){var e=this;return this.simpleDb.runTransaction("readonly",ga,function(t){return e.remoteDocumentCache.start(t)})},c.prototype.setPrimaryStateListener=function(n){var t=this;return this.primaryStateListener=function(e){return h(t,void 0,void 0,function(){return b(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},c.prototype.setDatabaseDeletedListener=function(n){var t=this;this.simpleDb.setVersionChangeListener(function(e){return h(t,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return null!==e.newVersion?[3,2]:[4,n()];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},c.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget(function(){return h(e,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.started?[4,this.updateClientMetadataAndTryBecomePrimary()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},c.prototype.updateClientMetadataAndTryBecomePrimary=function(){var r=this;return this.simpleDb.runTransaction("readwrite",ga,function(n){return La(n).put(new pa(r.clientId,Date.now(),r.networkEnabled,r.inForeground,r.remoteDocumentCache.lastProcessedDocumentChangeId)).next(function(){if(r.isPrimary)return r.verifyPrimaryLease(n).next(function(t){t||(r.isPrimary=!1,r.queue.enqueueAndForget(function(){return r.primaryStateListener(!1)}))})}).next(function(){return r.canActAsPrimary(n)}).next(function(t){var e=r.isPrimary;return r.isPrimary=t,e!==r.isPrimary&&r.queue.enqueueAndForget(function(){return r.primaryStateListener(r.isPrimary)}),e&&!r.isPrimary?r.releasePrimaryLeaseIfHeld(n):r.isPrimary?r.acquireOrExtendPrimaryLease(n):void 0})})},c.prototype.verifyPrimaryLease=function(t){var e=this;return xa(t).get(ta.key).next(function(t){return ho.resolve(e.isLocalClient(t))})},c.prototype.removeClientMetadata=function(t){return La(t).delete(this.clientId)},c.prototype.maybeGarbageCollectMultiClientState=function(){return h(this,void 0,void 0,function(){var r,i,o=this;return b(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.isWithinAge(this.lastGarbageCollectionTime,18e5)?[3,2]:(this.lastGarbageCollectionTime=Date.now(),i=[],[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(n){var e=c.getStore(n,pa.store);return e.loadAll().next(function(t){r=o.filterActiveClients(t,18e5),i=t.filter(function(t){return-1===r.indexOf(t)})}).next(function(){return ho.forEach(i,function(t){return e.delete(t.clientId)})}).next(function(){if(0<(r=r.filter(function(t){return t.clientId!==o.clientId})).length){var t=r.map(function(t){return t.lastProcessedDocumentChangeId||0}),e=Math.min.apply(Math,a(t));return o.remoteDocumentCache.removeDocumentChangesThroughChangeId(n,e)}})})]);case 1:t.sent(),i.forEach(function(t){o.window.localStorage.removeItem(o.zombiedClientLocalStorageKey(t.clientId))}),t.label=2;case 2:return[2]}})})},c.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(vi.ClientMetadataRefresh,4e3,function(){return t.updateClientMetadataAndTryBecomePrimary().then(function(){return t.maybeGarbageCollectMultiClientState()}).then(function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},c.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},c.prototype.canActAsPrimary=function(e){var i=this;return xa(e).get(ta.key).next(function(t){if(null!==t&&i.isWithinAge(t.leaseTimestampMs,5e3)&&!i.isClientZombied(t.ownerId)){if(i.isLocalClient(t)&&i.networkEnabled)return!0;if(!i.isLocalClient(t)){if(!t.allowTabSynchronization)throw new Ur(Br.FAILED_PRECONDITION,Ra);return!1}}return!(!i.networkEnabled||!i.inForeground)||La(e).loadAll().next(function(t){return void 0===i.filterActiveClients(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&&Or(Na,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},c.prototype.shutdown=function(){return h(this,void 0,void 0,function(){var e=this;return b(this,function(t){switch(t.label){case 0:return this._started=!1,this.markClientZombied(),this.clientMetadataRefresher&&this.clientMetadataRefresher.cancel(),this.detachVisibilityHandler(),this.detachWindowUnloadHook(),[4,this.simpleDb.runTransaction("readwrite",[ta.store,pa.store],function(t){return e.releasePrimaryLeaseIfHeld(t).next(function(){return e.removeClientMetadata(t)})})];case 1:return t.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}})})},c.prototype.filterActiveClients=function(t,e){var n=this;return t.filter(function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)})},c.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction("readonly",[pa.store],function(t){return La(t).loadAll().next(function(t){return e.filterActiveClients(t,18e5).map(function(t){return t.clientId})})})},c.clearPersistence=function(n){return h(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return c.isAvailable()?(e=n+c.MAIN_DATABASE,[4,To.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(c.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),c.prototype.getMutationQueue=function(t){return qr(this.started,"Cannot initialize MutationQueue before persistence is started."),lo.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},c.prototype.getQueryCache=function(){return qr(this.started,"Cannot initialize QueryCache before persistence is started."),this.queryCache},c.prototype.getRemoteDocumentCache=function(){return qr(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},c.prototype.getIndexManager=function(){return qr(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},c.prototype.runTransaction=function(n,t,r){var i=this;return Or(Na,"Starting transaction:",n),this.simpleDb.runTransaction("readonly"===t?"readonly":"readwrite",ga,function(e){return"readwrite-primary"===t?i.verifyPrimaryLease(e).next(function(t){if(!t)throw xr("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.queue.enqueueAndForget(function(){return i.primaryStateListener(!1)}),new Ur(Br.FAILED_PRECONDITION,ka);return r(new Ma(e,i.listenSequence.next()))}).next(function(t){return i.acquireOrExtendPrimaryLease(e).next(function(){return t})}):i.verifyAllowTabSynchronization(e).next(function(){return r(new Ma(e,i.listenSequence.next()))})})},c.prototype.verifyAllowTabSynchronization=function(t){var e=this;return xa(t).get(ta.key).next(function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new Ur(Br.FAILED_PRECONDITION,Ra)})},c.prototype.acquireOrExtendPrimaryLease=function(t){var e=new ta(this.clientId,this.allowTabSynchronization,Date.now());return xa(t).put(ta.key,e)},c.isAvailable=function(){return To.isAvailable()},c.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},c.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=xa(t);return n.get(ta.key).next(function(t){return e.isLocalClient(t)?(Or(Na,"Releasing primary lease."),n.delete(ta.key)):ho.resolve()})},c.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t "+n),!1))},c.prototype.attachVisibilityHandler=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.documentVisibilityHandler=function(){t.queue.enqueueAndForget(function(){return t.inForeground="visible"===t.document.visibilityState,t.updateClientMetadataAndTryBecomePrimary()})},this.document.addEventListener("visibilitychange",this.documentVisibilityHandler),this.inForeground="visible"===this.document.visibilityState)},c.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(qr(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},c.prototype.attachWindowUnloadHook=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.windowUnloadHandler=function(){t.markClientZombied(),t.queue.enqueueAndForget(function(){return t.shutdown()})},this.window.addEventListener("unload",this.windowUnloadHandler))},c.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(qr("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},c.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return Or(Na,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return xr(Na,"Failed to get zombied client id.",t),!1}},c.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){xr("Failed to set zombie client id.",t)}},c.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},c.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},c.MAIN_DATABASE="main",c}();function Oa(n){return h(this,void 0,void 0,function(){return b(this,function(t){if((e=n).code!==Br.FAILED_PRECONDITION||e.message!==ka)throw n;var e;return Or(Na,"Unexpectedly lost primary lease"),[2]})})}function xa(t){return t.store(ta.store)}function La(t){return t.store(pa.store)}var Pa,qa,Va,Fa,Ba=function(){function t(t,e){this.db=t,this.garbageCollector=new Aa(this,e)}return t.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocmentCount(t);return this.db.getQueryCache().getQueryCount(t).next(function(e){return n.next(function(t){return e+t})})},t.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},t.prototype.forEachTarget=function(t,e){return this.db.getQueryCache().forEachTarget(t,e)},t.prototype.forEachOrphanedDocumentSequenceNumber=function(t,n){return this.forEachOrphanedDocument(t,function(t,e){return n(e)})},t.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},t.prototype.addReference=function(t,e){return Ua(t,e)},t.prototype.removeReference=function(t,e){return Ua(t,e)},t.prototype.removeTargets=function(t,e,n){return this.db.getQueryCache().removeTargets(t,e,n)},t.prototype.removeMutationReference=function(t,e){return Ua(t,e)},t.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?ho.resolve(!0):(r=e,i=!1,vo(n=t).iterateSerial(function(t){return fo(n,t,r).next(function(t){return t&&(i=!0),ho.resolve(!t)})}).next(function(){return i}));var n,r,i},t.prototype.removeOrphanedDocuments=function(r,i){var o=this,a=0,s=0,u=[];return this.forEachOrphanedDocument(r,function(e,t){if(t<=i){var n=o.isPinned(r,e).next(function(t){if(!t)return a++,o.removeOrphanedDocument(r,e).next(function(t){s+=t})});u.push(n)}}).next(function(){return ho.waitFor(u)}).next(function(){return o.db.getRemoteDocumentCache().updateSize(r,-s)}).next(function(){return a})},t.prototype.removeOrphanedDocument=function(t,e){var n,r=0,i=this.db.getRemoteDocumentCache();return ho.waitFor([xo(t).delete((n=e,[0,Fi(n.path)])),i.removeEntry(t,e).next(function(t){r+=t})]).next(function(){return r})},t.prototype.removeTarget=function(t,e){var n=e.copy({sequenceNumber:t.currentSequenceNumber});return this.db.getQueryCache().updateQueryData(t,n)},t.prototype.updateLimboDocument=function(t,e){return Ua(t,e)},t.prototype.forEachOrphanedDocument=function(t,a){var s,e=xo(t),u=Ci.INVALID;return e.iterate({index:ca.documentTargetsIndex},function(t,e){var n=f(t,2),r=n[0],i=(n[1],e.path),o=e.sequenceNumber;0===r?(u!==Ci.INVALID&&a(new Mi(Qi(s)),u),u=o,s=i):u=Ci.INVALID}).next(function(){u!==Ci.INVALID&&a(new Mi(Qi(s)),u)})},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},t}();function Ua(t,e){return xo(t).put((n=e,r=t.currentSequenceNumber,new ca(0,Fi(n.path),r)));var n,r}(qa=Pa||(Pa={}))[qa.NullValue=0]="NullValue",qa[qa.BooleanValue=1]="BooleanValue",qa[qa.NumberValue=2]="NumberValue",qa[qa.TimestampValue=3]="TimestampValue",qa[qa.StringValue=4]="StringValue",qa[qa.BlobValue=5]="BlobValue",qa[qa.RefValue=6]="RefValue",qa[qa.GeoPointValue=7]="GeoPointValue",qa[qa.ArrayValue=8]="ArrayValue",qa[qa.ObjectValue=9]="ObjectValue",(Fa=Va||(Va={}))[Fa.Default=0]="Default",Fa[Fa.Estimate=1]="Estimate",Fa[Fa.Previous=2]="Previous";var Qa=function(){function n(t,e){this.serverTimestampBehavior=t,this.timestampsInSnapshots=e}return n.fromSnapshotOptions=function(t,e){switch(t.serverTimestamps){case"estimate":return new n(Va.Estimate,e);case"previous":return new n(Va.Previous,e);case"none":case void 0:return new n(Va.Default,e);default:return Pr("fromSnapshotOptions() called with invalid options.")}},n}(),Ka=function(){function t(){}return t.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},t.prototype.defaultCompareTo=function(t){return qr(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),di(this.typeOrder,t.typeOrder)},t}(),Wa=function(e){function n(){var t=e.call(this)||this;return t.typeOrder=Pa.NullValue,t.internalValue=null,t}return s(n,e),n.prototype.value=function(t){return null},n.prototype.isEqual=function(t){return t instanceof n},n.prototype.compareTo=function(t){return t instanceof n?0:this.defaultCompareTo(t)},n.INSTANCE=new n,n}(Ka),Ga=function(n){function e(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.BooleanValue,e}return s(e,n),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue===t.internalValue},e.prototype.compareTo=function(t){return t instanceof e?di(this,t):this.defaultCompareTo(t)},e.of=function(t){return t?e.TRUE:e.FALSE},e.TRUE=new e(!0),e.FALSE=new e(!1),e}(Ka),ja=function(n){function r(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.NumberValue,e}return s(r,n),r.prototype.value=function(t){return this.internalValue},r.prototype.compareTo=function(t){return t instanceof r?(e=this.internalValue,n=t.internalValue,e"},e}(Ka),es=function(n){function e(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.BlobValue,e}return s(e,n),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue.isEqual(t.internalValue)},e.prototype.compareTo=function(t){return t instanceof e?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},e}(Ka),ns=function(r){function n(t,e){var n=r.call(this)||this;return n.databaseId=t,n.key=e,n.typeOrder=Pa.RefValue,n}return s(n,r),n.prototype.value=function(t){return this.key},n.prototype.isEqual=function(t){return t instanceof n&&(this.key.isEqual(t.key)&&this.databaseId.isEqual(t.databaseId))},n.prototype.compareTo=function(t){if(t instanceof n){var e=this.databaseId.compareTo(t.databaseId);return 0!==e?e:Mi.comparator(this.key,t.key)}return this.defaultCompareTo(t)},n}(Ka),rs=function(n){function e(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.GeoPointValue,e}return s(e,n),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue.isEqual(t.internalValue)},e.prototype.compareTo=function(t){return t instanceof e?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},e}(Ka),is=function(n){function a(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.ObjectValue,e}return s(a,n),a.prototype.value=function(n){var r={};return this.internalValue.inorderTraversal(function(t,e){r[t]=e.value(n)}),r},a.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},a.prototype.isEqual=function(t){if(t instanceof a){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext();if(r.key!==i.key||!r.value.isEqual(i.value))return!1}return!e.hasNext()&&!n.hasNext()}return!1},a.prototype.compareTo=function(t){if(t instanceof a){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext(),o=di(r.key,i.key)||r.value.compareTo(i.value);if(o)return o}return di(e.hasNext(),n.hasNext())}return this.defaultCompareTo(t)},a.prototype.set=function(t,e){if(qr(!t.isEmpty(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.setChild(t.firstSegment(),e);var n=this.child(t.firstSegment());n instanceof a||(n=a.EMPTY);var r=n.set(t.popFirst(),e);return this.setChild(t.firstSegment(),r)},a.prototype.delete=function(t){if(qr(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new a(this.internalValue.remove(t.firstSegment()));var e=this.child(t.firstSegment());if(e instanceof a){var n=e.delete(t.popFirst());return new a(this.internalValue.insert(t.firstSegment(),n))}return this},a.prototype.contains=function(t){return null!==this.field(t)},a.prototype.field=function(t){qr(!t.isEmpty(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof a?e.internalValue.get(t):null}),e},a.prototype.fieldMask=function(){var i=new Yi(Ri.comparator);return this.internalValue.forEach(function(t,e){var n=new Ri([t]);if(e instanceof a){var r=e.fieldMask().fields;r.isEmpty()?i=i.add(n):r.forEach(function(t){i=i.add(n.child(t))})}else i=i.add(n)}),as.fromSet(i)},a.prototype.toString=function(){return this.internalValue.toString()},a.prototype.child=function(t){return this.internalValue.get(t)||void 0},a.prototype.setChild=function(t,e){return new a(this.internalValue.insert(t,e))},a.EMPTY=new a(new Gi(di)),a}(Ka),os=function(n){function i(t){var e=n.call(this)||this;return e.internalValue=t,e.typeOrder=Pa.ArrayValue,e}return s(i,n),i.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},i.prototype.contains=function(t){var e,n;try{for(var r=C(this.internalValue),i=r.next();!i.done;i=r.next()){if(i.value.isEqual(t))return!0}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!1},i.prototype.forEach=function(t){this.internalValue.forEach(t)},i.prototype.isEqual=function(t){if(t instanceof i){if(this.internalValue.length!==t.internalValue.length)return!1;for(var e=0;e=this.RESUME_TOKEN_MAX_AGE_MICROS||0i?this.mutationQueue[i]:null)},t.prototype.getAllMutationBatches=function(t){return ho.resolve(this.mutationQueue.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,e=new gs(n,0),i=new gs(n,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([e,i],function(t){qr(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.findMutationBatch(t.targetOrBatchId);qr(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),ho.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var r=this,i=new Yi(di);return e.forEach(function(e){var t=new gs(e,0),n=new gs(e,Number.POSITIVE_INFINITY);r.batchesByDocumentKey.forEachInRange([t,n],function(t){qr(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.targetOrBatchId)})}),ho.resolve(this.findMutationBatches(i))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){qr(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;Mi.isDocumentKey(i)||(i=i.child(""));var o=new gs(new Mi(i),0),a=new Yi(di);return this.batchesByDocumentKey.forEachWhile(function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(a=a.add(t.targetOrBatchId)),!0)},o),ho.resolve(this.findMutationBatches(a))},t.prototype.findMutationBatches=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.findMutationBatch(t);null!==e&&r.push(e)}),r},t.prototype.removeMutationBatch=function(n,r){var i=this;qr(0===this.indexOfExistingBatchId(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var o=this.batchesByDocumentKey;return ho.forEach(r.mutations,function(t){var e=new gs(t.key,r.batchId);return o=o.delete(e),i.referenceDelegate.removeMutationReference(n,t.key)}).next(function(){i.batchesByDocumentKey=o})},t.prototype.removeCachedMutationKeys=function(t){},t.prototype.containsKey=function(t,e){var n=new gs(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return ho.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&qr(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),ho.resolve()},t.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return qr(0<=n&&n=this.mutationQueue.length)return null;var n=this.mutationQueue[e];return qr(n.batchId===t,"If found batch must match"),n},t}(),ws=function(){function t(t){this.persistence=t,this.queries=new Fo(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Wi.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new ms,this.targetCount=0,this.targetIdGenerator=Eo.forQueryCache()}return t.prototype.getTargetCount=function(t){return ho.resolve(this.targetCount)},t.prototype.forEachTarget=function(t,n){return this.queries.forEach(function(t,e){return n(e)}),ho.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return ho.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return ho.resolve(this.highestSequenceNumber)},t.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,ho.resolve(e)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),ho.resolve()},t.prototype.saveQueryData=function(t){this.queries.set(t.query,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},t.prototype.addQueryData=function(t,e){return qr(!this.queries.has(e.query),"Adding a query that already exists"),this.saveQueryData(e),this.targetCount+=1,ho.resolve()},t.prototype.updateQueryData=function(t,e){return qr(this.queries.has(e.query),"Updating a non-existent query"),this.saveQueryData(e),ho.resolve()},t.prototype.removeQueryData=function(t,e){return qr(0this.maxDelayMs&&(this.currentBaseMs=this.maxDelayMs)},t.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},t.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},t}(),Ps="PersistentStream";(xs=Os||(Os={}))[xs.Initial=0]="Initial",xs[xs.Starting=1]="Starting",xs[xs.Open=2]="Open",xs[xs.Error=3]="Error",xs[xs.Backoff=4]="Backoff";var qs,Vs,Fs,Bs,Us=function(){function t(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=Os.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new Ls(t,e,1e3,1.5,6e4)}return t.prototype.isStarted=function(){return this.state===Os.Starting||this.state===Os.Open||this.state===Os.Backoff},t.prototype.isOpen=function(){return this.state===Os.Open},t.prototype.start=function(){this.state!==Os.Error?(qr(this.state===Os.Initial,"Already started"),this.auth()):this.performBackoff()},t.prototype.stop=function(){return h(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(Os.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.inhibitBackoff=function(){qr(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=Os.Initial,this.backoff.reset()},t.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,function(){return t.handleIdleCloseTimer()}))},t.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},t.prototype.handleIdleCloseTimer=function(){return h(this,void 0,void 0,function(){return b(this,function(t){return this.isOpen()?[2,this.close(Os.Initial)]:[2]})})},t.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},t.prototype.close=function(e,n){return h(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return qr(this.isStarted(),"Only started streams should be closed."),qr(e===Os.Error||Ms(n),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==Os.Error?this.backoff.reset():n&&n.code===Br.RESOURCE_EXHAUSTED?(xr(n.toString()),xr("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):n&&n.code===Br.UNAUTHENTICATED&&this.credentialsProvider.invalidateToken(),null!==this.stream&&(this.tearDown(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.onClose(n)];case 1:return t.sent(),[2]}})})},t.prototype.tearDown=function(){},t.prototype.auth=function(){var n=this;qr(this.state===Os.Initial,"Must be in initial state to auth"),this.state=Os.Starting;var t=this.getCloseGuardedDispatcher(this.closeCount),e=this.closeCount;this.credentialsProvider.getToken().then(function(t){n.closeCount===e&&n.startStream(t)},function(e){t(function(){var t=new Ur(Br.UNKNOWN,"Fetching auth token failed: "+e.message);return n.handleStreamClose(t)})})},t.prototype.startStream=function(t){var e=this;qr(this.state===Os.Starting,"Trying to start stream in a non-starting state");var n=this.getCloseGuardedDispatcher(this.closeCount);this.stream=this.startRpc(t),this.stream.onOpen(function(){n(function(){return qr(e.state===Os.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=Os.Open,e.listener.onOpen()})}),this.stream.onClose(function(t){n(function(){return e.handleStreamClose(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},t.prototype.performBackoff=function(){var t=this;qr(this.state===Os.Error,"Should only perform backoff when in Error state"),this.state=Os.Backoff,this.backoff.backoffAndRun(function(){return h(t,void 0,void 0,function(){return b(this,function(t){return qr(this.state===Os.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=Os.Initial,this.start(),qr(this.isStarted(),"PersistentStream should have started"),[2]})})})},t.prototype.handleStreamClose=function(t){return qr(this.isStarted(),"Can't handle server close on non-started stream"),Or(Ps,"close with error: "+t),this.stream=null,this.close(Os.Error,t)},t.prototype.getCloseGuardedDispatcher=function(e){var n=this;return function(t){n.queue.enqueueAndForget(function(){return n.closeCount===e?t():(Or(Ps,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},t}(),Qs=function(a){function t(t,e,n,r,i){var o=a.call(this,t,vi.ListenStreamConnectionBackoff,vi.ListenStreamIdle,e,n,i)||this;return o.serializer=r,o}return s(t,a),t.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},t.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},t.prototype.watch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.addTarget=this.serializer.toTarget(t);var n=this.serializer.toListenRequestLabels(t);n&&(e.labels=n),this.sendRequest(e)},t.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},t}(Us),Ks=function(a){function t(t,e,n,r,i){var o=a.call(this,t,vi.WriteStreamConnectionBackoff,vi.WriteStreamIdle,e,n,i)||this;return o.serializer=r,o.handshakeComplete_=!1,o}return s(t,a),Object.defineProperty(t.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.handshakeComplete_=!1,a.prototype.start.call(this)},t.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},t.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},t.prototype.onMessage=function(t){if(qr(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.handshakeComplete_){this.backoff.reset();var e=this.serializer.fromWriteResults(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.onMutationResult(n,e)}return qr(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},t.prototype.writeHandshake=function(){qr(this.isOpen(),"Writing handshake requires an opened stream"),qr(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},t.prototype.writeMutations=function(t){var e=this;qr(this.isOpen(),"Writing mutations requires an opened stream"),qr(this.handshakeComplete_,"Handshake must be complete before writing mutations"),qr(0=":return e.GREATER_THAN_OR_EQUAL;case">":return e.GREATER_THAN;case"array-contains":return e.ARRAY_CONTAINS;case"in":return e.IN;case"array-contains-any":return e.ARRAY_CONTAINS_ANY;default:return Pr("Unknown FieldFilter operator: "+t)}},e.prototype.toString=function(){return this.name},e.prototype.isEqual=function(t){return this.name===t.name},e.LESS_THAN=new e("<"),e.LESS_THAN_OR_EQUAL=new e("<="),e.EQUAL=new e("=="),e.GREATER_THAN=new e(">"),e.GREATER_THAN_OR_EQUAL=new e(">="),e.ARRAY_CONTAINS=new e("array-contains"),e.IN=new e("in"),e.ARRAY_CONTAINS_ANY=new e("array-contains-any"),e}(),Eu=function(i){function r(t,e,n){var r=i.call(this)||this;return r.field=t,r.op=e,r.value=n,r}return s(r,i),r.create=function(t,e,n){if(t.isKeyField())return e===wu.IN?(qr(n instanceof os,"Comparing on key with IN, but filter value not an ArrayValue"),qr(n.internalValue.every(function(t){return t instanceof ns}),"Comparing on key with IN, but an array value was not a RefValue"),new Tu(t,n)):(qr(n instanceof ns,"Comparing on key, but filter value not a RefValue"),qr(e!==wu.ARRAY_CONTAINS&&e!==wu.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new Su(t,e,n));if(n.isEqual(Wa.INSTANCE)){if(e!==wu.EQUAL)throw new Ur(Br.INVALID_ARGUMENT,"Invalid query. You can only perform equals comparisons on null.");return new r(t,e,n)}if(n.isEqual(Ja.NAN)){if(e!==wu.EQUAL)throw new Ur(Br.INVALID_ARGUMENT,"Invalid query. You can only perform equals comparisons on NaN.");return new r(t,e,n)}return e===wu.ARRAY_CONTAINS?new Iu(t,n):e===wu.IN?(qr(n instanceof os,"IN filter has invalid value: "+n.toString()),new Cu(t,n)):e===wu.ARRAY_CONTAINS_ANY?(qr(n instanceof os,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new Du(t,n)):new r(t,e,n)},r.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},r.prototype.matchesComparison=function(t){switch(this.op){case wu.LESS_THAN:return t<0;case wu.LESS_THAN_OR_EQUAL:return t<=0;case wu.EQUAL:return 0===t;case wu.GREATER_THAN:return 0() instead."),qc=/^__.*__$/,Vc=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new fs(t,this.data,this.fieldMask,e)):n.push(new ls(t,this.data,e)),0=",">","array-contains"],2,e)}var a=jc("Query.where",t),s=wu.fromString(e);if(a.isKeyField()){if(s===wu.ARRAY_CONTAINS||s===wu.ARRAY_CONTAINS_ANY)throw new Ur(Br.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+s.toString()+"' queries on FieldPath.documentId().");if(s===wu.IN){this.validateDisjunctiveFilterElements(n,s);var u=[];try{for(var c=C(n),h=c.next();!h.done;h=c.next()){var l=h.value;u.push(this.parseDocumentIdValue(l))}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}o=new os(u)}else o=this.parseDocumentIdValue(n)}else s!==wu.IN&&s!==wu.ARRAY_CONTAINS_ANY||this.validateDisjunctiveFilterElements(n,s),o=this.firestore._dataConverter.parseQueryValue("Query.where",n);var f=Eu.create(a,s,o);return this.validateNewFilter(f),new d(this._query.addFilter(f),this.firestore)},d.prototype.orderBy=function(t,e){var n;if(Jr("Query.orderBy",arguments,1,2),$r("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=Au.ASCENDING;else{if("desc"!==e)throw new Ur(Br.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=Au.DESCENDING}if(null!==this._query.startAt)throw new Ur(Br.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this._query.endAt)throw new Ur(Br.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=jc("Query.orderBy",t),i=new ku(r,n);return this.validateNewOrderBy(i),new d(this._query.addOrderBy(i),this.firestore)},d.prototype.limit=function(t){if(Yr("Query.limit",arguments,1),Zr("Query.limit","number",1,t),t<=0)throw new Ur(Br.INVALID_ARGUMENT,"Invalid Query. Query limit ("+t+") is invalid. Limit must be positive.");return new d(this._query.withLimit(t),this.firestore)},d.prototype.startAt=function(t){for(var e=[],n=1;nr.length)throw new Ur(Br.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, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var a=this._query.getFirstOrderByField();null!==a&&this.validateOrderByAndInequalityMatch(t.field,a)}else if(i||r){var s=null;if(i&&(s=this._query.findFilterOperator(n)),null===s&&r&&(s=this._query.findFilterOperator(e)),null!=s)throw s===t.op?new Ur(Br.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new Ur(Br.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},d.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},d.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new Ur(Br.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.")},d}(),ah=function(){function e(t,e,n){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new nh(n.hasPendingWrites,n.fromCache)}return Object.defineProperty(e.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e,n){var r=this;Jr("QuerySnapshot.forEach",arguments,1,2),Zr("QuerySnapshot.forEach","function",1,e),this._snapshot.docs.forEach(function(t){e.call(n,r.convertToDocumentImpl(t))})},Object.defineProperty(e.prototype,"query",{get:function(){return new oh(this._originalQuery,this._firestore)},enumerable:!0,configurable:!0}),e.prototype.docChanges=function(t){t&&(ui("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),ei("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new Ur(Br.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,e,o){{if(o.oldDocs.isEmpty()){var n,r=0;return o.docChanges.map(function(t){var e=new ih(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key));return qr(t.type===Js.Added,"Invalid event type for first snapshot"),qr(!n||o.query.docComparator(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var a=o.oldDocs;return o.docChanges.filter(function(t){return e||t.type!==Js.Metadata}).map(function(t){var e=new ih(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key)),n=-1,r=-1;return t.type!==Js.Added&&(qr(0<=(n=a.indexOf(t.doc.key)),"Index for document not found"),a=a.delete(t.doc.key)),t.type!==Js.Removed&&(a=a.add(t.doc),r=a.indexOf(t.doc.key)),{type:function(t){switch(t){case Js.Added:return"added";case Js.Modified:case Js.Metadata:return"modified";case Js.Removed:return"removed";default:return Pr("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}}(this._firestore,e,this._snapshot),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},e.prototype.isEqual=function(t){if(!(t instanceof e))throw ci("isEqual","QuerySnapshot",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)},e.prototype.convertToDocumentImpl=function(t){return new ih(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key))},e}();a(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(ah.prototype.docChanges,t,{get:function(){return function(){throw new Ur(Br.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(t){}});var sh=function(r){function t(t,e){var n=r.call(this,vu.atPath(t),e)||this;if(t.length%2!=1)throw new Ur(Br.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.canonicalString()+" has "+t.length);return n}return s(t,r),Object.defineProperty(t.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new eh(new Mi(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),t.prototype.doc=function(t){if(Jr("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=fi.newId()),Zr("CollectionReference.doc","non-empty string",1,t),""===t)throw new Ur(Br.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Ni.fromString(t);return eh.forPath(this._query.path.child(e),this.firestore)},t.prototype.add=function(t){Yr("CollectionReference.add",arguments,1),Zr("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},t}(oh);function uh(t,e){if(void 0===e)return{merge:!1};if(ui(t,e,["merge","mergeFields"]),ei(t,"boolean","merge",e.merge),ni(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof wc}),void 0!==e.mergeFields&&void 0!==e.merge)throw new Ur(Br.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function ch(t,e){return void 0===e?{}:(ui(t,e,["serverTimestamps"]),ri(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function hh(t,e){$r(t,"object",1,e),e&&(ui(t,e,["source"]),ri(t,0,"source",e.source,["default","server","cache"]))}function lh(t,e,n){if(e instanceof eh){if(e.firestore!==n)throw new Ur(Br.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw ci(t,"DocumentReference",1,e)}var fh=Qr(Zc,"Use firebase.firestore() instead."),dh=Qr($c,"Use firebase.firestore().runTransaction() instead."),ph=Qr(th,"Use firebase.firestore().batch() instead."),yh=Qr(eh,"Use firebase.firestore().doc() instead."),mh=Qr(rh),gh=Qr(ih),vh=Qr(oh),bh=Qr(ah),wh=Qr(sh,"Use firebase.firestore().collection() instead."),Eh={Firestore:fh,GeoPoint:gu,Timestamp:Ki,Blob:Ei,Transaction:dh,WriteBatch:ph,DocumentReference:yh,DocumentSnapshot:mh,Query:vh,QueryDocumentSnapshot:gh,QuerySnapshot:bh,CollectionReference:wh,FieldPath:wc,FieldValue:Pc,setLogLevel:Zc.setLogLevel,CACHE_SIZE_UNLIMITED:Yc};function Sh(t){t.INTERNAL.registerService("firestore",function(t){return new Zc(t)},function(t){qr(t&&"object"==typeof t,"shallowCopy() expects object parameter.");var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}(Eh))}var Th=function(){function t(){}return t.prototype.addCallback=function(t){},t.prototype.shutdown=function(){},t}(),Ih="ConnectivityMonitor",Ch=function(){function t(){var t=this;this.networkAvailableListener=function(){return t.onNetworkAvailable()},this.networkUnavailableListener=function(){return t.onNetworkUnavailable()},this.callbacks=[],this.configureNetworkMonitoring()}return t.prototype.addCallback=function(t){this.callbacks.push(t)},t.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},t.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},t.prototype.onNetworkAvailable=function(){var e,t;Or(Ih,"Network connectivity changed: AVAILABLE");try{for(var n=C(this.callbacks),r=n.next();!r.done;r=n.next()){(0,r.value)(0)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.prototype.onNetworkUnavailable=function(){var e,t;Or(Ih,"Network connectivity changed: UNAVAILABLE");try{for(var n=C(this.callbacks),r=n.next();!r.done;r=n.next()){(0,r.value)(1)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t.isAvailable=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),Dh=function(){function t(t){this.sendFn=t.sendFn,this.closeFn=t.closeFn}return t.prototype.onOpen=function(t){qr(!this.wrappedOnOpen,"Called onOpen on stream twice!"),this.wrappedOnOpen=t},t.prototype.onClose=function(t){qr(!this.wrappedOnClose,"Called onClose on stream twice!"),this.wrappedOnClose=t},t.prototype.onMessage=function(t){qr(!this.wrappedOnMessage,"Called onMessage on stream twice!"),this.wrappedOnMessage=t},t.prototype.close=function(){this.closeFn()},t.prototype.send=function(t){this.sendFn(t)},t.prototype.callOnOpen=function(){qr(void 0!==this.wrappedOnOpen,"Cannot call onOpen because no callback was set"),this.wrappedOnOpen()},t.prototype.callOnClose=function(t){qr(void 0!==this.wrappedOnClose,"Cannot call onClose because no callback was set"),this.wrappedOnClose(t)},t.prototype.callOnMessage=function(t){qr(void 0!==this.wrappedOnMessage,"Cannot call onMessage because no callback was set"),this.wrappedOnMessage(t)},t}(),Ah="Connection",Nh={BatchGetDocuments:"batchGet",Commit:"commit"},kh="gl-js/ fire/"+kr,Rh=function(){function t(t){this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.baseUrl=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}return t.prototype.modifyHeadersForRequest=function(t,e){if(e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n]);t["X-Goog-Api-Client"]=kh},t.prototype.invokeRPC=function(o,a,s){var u=this,c=this.makeUrl(o);return new Promise(function(n,r){var i=new Nr;i.listenOnce(Dr.COMPLETE,function(){try{switch(i.getLastErrorCode()){case Cr.NO_ERROR:var t=i.getResponseJson();Or(Ah,"XHR received:",JSON.stringify(t)),n(t);break;case Cr.TIMEOUT:Or(Ah,'RPC "'+o+'" timed out'),r(new Ur(Br.DEADLINE_EXCEEDED,"Request time out"));break;case Cr.HTTP_ERROR:var e=i.getStatus();Or(Ah,'RPC "'+o+'" failed with status:',e,"response text:",i.getResponseText()),0a[0]&&t[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||0"})}(i,r):"Error",s=this.serviceName+": "+a+" ("+o+").",c=new f(o,s),p=0,l=Object.keys(r);p>>0),b=0;function y(t,e,n){return t.call.apply(t.bind,arguments)}function w(e,n,t){if(!e)throw Error();if(2"}else o=void 0===t?"undefined":null===t?"null":typeof t;O("Argument is not a %s (or a non-Element, non-Location mock); got: %s",e,o)}}R.prototype.add=function(t,e){var n=C.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},D.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},D.prototype.reset=function(){this.next=this.b=this.a=null};var x=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(h(t))return h(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n/g,lt=/"/g,ft=/'/g,dt=/\x00/g,pt=/[\x00&<>"']/;function vt(t,e){return-1!=t.indexOf(e)}function mt(t,e){return t");var Rt,Ct,Dt=Pt("");function Lt(t,e){for(var n=t.split("%s"),i="",r=Array.prototype.slice.call(arguments,1);r.length&&1")&&(t=t.replace(ht,">")),-1!=t.indexOf('"')&&(t=t.replace(lt,""")),-1!=t.indexOf("'")&&(t=t.replace(ft,"'")),-1!=t.indexOf("\0")&&(t=t.replace(dt,"�"))),t}function Mt(t){l.setTimeout(function(){throw t},0)}function jt(){var t=l.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!St("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",function(t){var e=at(z(Q));L(t,"HTMLIFrameElement"),t.src=et(e).toString()}(t),document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(Ot(Dt)),t.close();var n="callImmediate"+Math.random(),i="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=I(function(t){"*"!=i&&t.origin!=i||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,i)}}}),void 0===t||St("Trident")||St("MSIE"))return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){l.setTimeout(t,0)};var e=new t,n={},i=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).yb;n.yb=null,t()}},function(t){i.next={yb:t},i=i.next,e.port2.postMessage(0)}}function Ut(t,e){Ct||function(){if(l.Promise&&l.Promise.resolve){var t=l.Promise.resolve(void 0);Ct=function(){t.then(Kt)}}else Ct=function(){var t=Kt;!m(l.setImmediate)||l.Window&&l.Window.prototype&&!St("Edge")&&l.Window.prototype.setImmediate==l.setImmediate?(Rt=Rt||jt())(t):l.setImmediate(t)}}(),Vt||(Ct(),Vt=!0),Ft.add(t,e)}Pt("
");var Vt=!1,Ft=new R;function Kt(){for(var t;n=e=void 0,n=null,(e=Ft).a&&(n=e.a,e.a=e.a.next,e.a||(e.b=null),n.next=null),t=n;){try{t.a.call(t.b)}catch(t){Mt(t)}P(C,t)}var e,n;Vt=!1}function qt(t,e){if(this.a=Ht,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=d)try{var n=this;t.call(e,function(t){ee(n,Bt,t)},function(t){if(!(t instanceof ue))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}ee(n,Gt,t)})}catch(t){ee(this,Gt,t)}}var Ht=0,Bt=2,Gt=3;function Wt(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}Wt.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var Xt=new _(function(){return new Wt},function(t){t.reset()});function Jt(t,e,n){var i=Xt.get();return i.g=t,i.b=e,i.f=n,i}function Yt(t){if(t instanceof qt)return t;var e=new qt(d);return ee(e,Bt,t),e}function zt(n){return new qt(function(t,e){e(n)})}function $t(t,e,n){ne(t,e,n,null)||Ut(T(e,t))}function Zt(n){return new qt(function(i){var r=n.length,o=[];if(r)for(var t=function(t,e,n){r--,o[t]=e?{Gb:!0,value:n}:{Gb:!1,reason:n},0==r&&i(o)},e=0;eparseFloat(Te)){de=String(ke);break t}}de=Te}var Ae,Se={};function Ne(s){return function(t,e){var n=Se;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(s,function(){for(var t=0,e=st(String(de)).split("."),n=st(String(s)).split("."),i=Math.max(e.length,n.length),r=0;0==t&&r>>0);function en(e){return m(e)?e:(e[tn]||(e[tn]=function(t){return e.handleEvent(t)}),e[tn])}function nn(){ce.call(this),this.u=new Ve(this),(this.Sb=this).Xa=null}function rn(t,e,n,i,r){t.u.add(String(e),n,!1,i,r)}function on(t,e,n,i,r){t.u.add(String(e),n,!0,i,r)}function an(t,e,n,i){if(!(e=t.u.a[String(e)]))return!0;e=e.concat();for(var r=!0,o=0;o>4&15).toString(16)+(15&t).toString(16)}vn.prototype.toString=function(){var t=[],e=this.f;e&&t.push(kn(e,Sn,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.i)&&t.push(kn(e,Sn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.l)&&t.push(":",String(n))),(n=this.c)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(kn(n,"/"==n.charAt(0)?On:Nn,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.g)&&t.push("#",kn(n,Pn)),t.join("")},vn.prototype.resolve=function(t){var e=new vn(this),n=!!t.f;n?mn(e,t.f):n=!!t.i,n?e.i=t.i:n=!!t.b,n?e.b=t.b:n=null!=t.l;var i=t.c;if(n)gn(e,t.l);else if(n=!!t.c){if("/"!=i.charAt(0))if(this.b&&!this.c)i="/"+i;else{var r=e.c.lastIndexOf("/");-1!=r&&(i=e.c.substr(0,r+1)+i)}if(".."==(r=i)||"."==r)i="";else if(vt(r,"./")||vt(r,"/.")){i=0==r.lastIndexOf("/",0),r=r.split("/");for(var o=[],a=0;a2*t.c&&fn(t)))}function xn(t,e){return Cn(t),e=Un(t,e),dn(t.a.b,e)}function Mn(t,e,n){Ln(t,e),0"),o=o.join("")}return o=r.createElement(o),a&&(h(a)?o.className=a:p(a)?o.className=a.join(" "):Kn(o,a)),2'),a.document.write(Ot(t)),a.document.close())):(a=i.open(bt(e).toString(),n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(t){}return a}var ni=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ii=/^[^@]+@[^@]+$/;function ri(){var e=null;return new qt(function(t){"complete"==l.document.readyState?t():(e=function(){t()},We(window,"load",e))}).s(function(t){throw Xe(window,"load",e),t})}function oi(t){return t=t||vi(),!("file:"!==wi()&&"ionic:"!==wi()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function ai(){var t=l.window;try{return!(!t||t==t.top)}catch(t){return!1}}function si(){return void 0!==l.WorkerGlobalScope&&"function"==typeof l.importScripts}function ui(){return fl.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":fl.INTERNAL.hasOwnProperty("node")?"Node":si()?"Worker":"Browser"}function ci(){var t=ui();return"ReactNative"===t||"Node"===t}var hi="Firefox",li="Chrome";function fi(t){var e=t.toLowerCase();return vt(e,"opera/")||vt(e,"opr/")||vt(e,"opios/")?"Opera":vt(e,"iemobile")?"IEMobile":vt(e,"msie")||vt(e,"trident/")?"IE":vt(e,"edge/")?"Edge":vt(e,"firefox/")?hi:vt(e,"silk/")?"Silk":vt(e,"blackberry")?"Blackberry":vt(e,"webos")?"Webos":!vt(e,"safari/")||vt(e,"chrome/")||vt(e,"crios/")||vt(e,"android")?!vt(e,"chrome/")&&!vt(e,"crios/")||vt(e,"edge/")?vt(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":li:"Safari"}var di={Wc:"FirebaseCore-web",Yc:"FirebaseUI-web"};function pi(t,e){e=e||[];var n,i=[],r={};for(n in di)r[di[n]]=!0;for(n=0;n>4),64!=a&&(t(o<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(t,function(t){e+=String.fromCharCode(t)}),e}function Tr(t){this.f=t.sub,this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.c=t.firebase&&t.firebase.tenant||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function Er(t){return(t=kr(t))&&t.sub&&t.iss&&t.aud&&t.exp?new Tr(t):null}function kr(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n Auth section -> Sign in method tab.",t):"http"==i||"https"==i?n=Lt("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",Yi.call(this,e,n)}function So(t,e,n){Yi.call(this,t,n),(t=e||{}).Ab&&Mi(this,"email",t.Ab),t.ba&&Mi(this,"phoneNumber",t.ba),t.credential&&Mi(this,"credential",t.credential),t.Qb&&Mi(this,"tenantId",t.Qb)}function No(t){if(t.code){var e=t.code||"";0==e.indexOf($i)&&(e=e.substring($i.length));var n={credential:bo(t),Qb:t.tenantId};if(t.email)n.Ab=t.email;else if(t.phoneNumber)n.ba=t.phoneNumber;else if(!n.credential)return new Yi(e,t.message||void 0);return new So(e,n,t.message)}return null}function Oo(){}function _o(t){return t.c||(t.c=t.b())}function Po(){}function Ro(t){if(t.f||"undefined"!=typeof XMLHttpRequest||"undefined"==typeof ActiveXObject)return t.f;for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n=function t(e){return e.c?e.c:e.a?t(e.a):(O("Root logger has no level set."),null)}(this).value)for(m(e)&&(e=e()),t=new xo(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var qo,Ho={},Bo=null;function Go(t){var e;if(Bo||(Bo=new Mo(""),(Ho[""]=Bo).c=Fo),!(e=Ho[t])){e=new Mo(t);var n=t.lastIndexOf("."),i=t.substr(n+1);(n=Go(t.substr(0,n))).b||(n.b={}),(n.b[i]=e).a=n,Ho[t]=e}return e}function Wo(t,e){t&&t.log(Ko,e,void 0)}function Xo(t){this.f=t}function Jo(t){nn.call(this),this.o=t,this.readyState=Yo,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.i=new Headers,this.b=null,this.m="GET",this.g="",this.a=!1,this.h=Go("goog.net.FetchXmlHttp"),this.l=this.c=this.f=null}k(Xo,Oo),Xo.prototype.a=function(){return new Jo(this.f)},Xo.prototype.b=(qo={},function(){return qo}),k(Jo,nn);var Yo=0;function zo(t){t.c.read().then(t.ec.bind(t)).catch(t.Oa.bind(t))}function $o(t,e){e&&t.f&&(t.status=t.f.status,t.statusText=t.f.statusText),t.readyState=4,t.f=null,t.c=null,t.l=null,Zo(t)}function Zo(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function Qo(t){nn.call(this),this.headers=new ln,this.B=t||null,this.c=!1,this.w=this.a=null,this.h=this.O=this.l="",this.f=this.J=this.i=this.I=!1,this.g=0,this.o=null,this.m=ta,this.v=this.P=!1}(t=Jo.prototype).open=function(t,e){if(this.readyState!=Yo)throw this.abort(),Error("Error reopening a connection");this.m=t,this.g=e,this.readyState=1,Zo(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.i,method:this.m,credentials:void 0,cache:void 0};t&&(e.body=t),this.o.fetch(new Request(this.g,e)).then(this.jc.bind(this),this.Oa.bind(this))},t.abort=function(){this.response=this.responseText="",this.i=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,$o(this,!1)),this.readyState=Yo},t.jc=function(t){this.a&&(this.f=t,this.b||(this.b=t.headers,this.readyState=2,Zo(this)),this.a&&(this.readyState=3,Zo(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.hc.bind(this),this.Oa.bind(this)):void 0!==l.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.l=new TextDecoder,zo(this)):t.text().then(this.ic.bind(this),this.Oa.bind(this)))))},t.ec=function(t){if(this.a){var e=this.l.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?$o(this,!0):Zo(this),3==this.readyState&&zo(this)}},t.ic=function(t){this.a&&(this.response=this.responseText=t,$o(this,!0))},t.hc=function(t){this.a&&(this.response=t,$o(this,!0))},t.Oa=function(t){var e=this.h;e&&e.log(Vo,"Failed to fetch url "+this.g,t instanceof Error?t:Error(t)),this.a&&$o(this,!0)},t.setRequestHeader=function(t,e){this.i.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.h)&&t.log(Vo,"Attempting to get response header but no headers have been received for url: "+this.g,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.h;return t&&t.log(Vo,"Attempting to get all response headers but no headers have been received for url: "+this.g,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},k(Qo,nn);var ta="";Qo.prototype.b=Go("goog.net.XhrIo");var ea=/^https?$/i,na=["POST","PUT"];function ia(e,t,n,i,r){if(e.a)throw Error("[goog.net.XhrIo] Object is active with another request="+e.l+"; newUri="+t);n=n?n.toUpperCase():"GET",e.l=t,e.h="",e.O=n,e.I=!1,e.c=!0,e.a=e.B?e.B.a():Eo.a(),e.w=e.B?_o(e.B):_o(Eo),e.a.onreadystatechange=I(e.Lb,e);try{Wo(e.b,fa(e,"Opening Xhr")),e.J=!0,e.a.open(n,String(t),!0),e.J=!1}catch(t){return Wo(e.b,fa(e,"Error opening Xhr: "+t.message)),void oa(e,t)}t=i||"";var o=new ln(e.headers);r&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(v(t)||h(t))M(t,e,void 0);else for(var n=hn(t),i=cn(t),r=i.length,o=0;o>>7|r<<25)^(r>>>18|r<<14)^r>>>3)|0,a=(0|n[e-7])+((i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10)|0;n[e]=o+a|0}i=0|t.a[0],r=0|t.a[1];var s=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;e<64;e++){var f=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&r^i&s^r&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|Pu[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=r,r=i,i=a+f|0}t.a[0]=t.a[0]+i|0,t.a[1]=t.a[1]+r|0,t.a[2]=t.a[2]+s|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function Fu(t,e,n){void 0===n&&(n=e.length);var i=0,r=t.c;if(h(e))for(;i>r&255;return function(t){return j(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}function Xu(t,e){for(var n=0;nt.f&&(t.a=t.f),e)}function Ac(t){this.f=t,this.b=this.a=null,this.c=0}function Sc(t,e){var n=e[Ca],i=e.refreshToken;e=Nc(e.expiresIn),t.b=n,t.c=e,t.a=i}function Nc(t){return E()+1e3*parseInt(t,10)}function Oc(e,t){return function(t,i){return new qt(function(e,n){"refresh_token"==i.grant_type&&i.refresh_token||"authorization_code"==i.grant_type&&i.code?Va(t,t.l+"?key="+encodeURIComponent(t.c),function(t){t?t.error?n(_s(t)):t.access_token&&t.refresh_token?e(t):n(new Yi("internal-error")):n(new Yi("network-request-failed"))},"POST",Dn(i).toString(),t.g,t.u.get()):n(new Yi("internal-error"))})}(e.f,t).then(function(t){return e.b=t.access_token,e.c=Nc(t.expires_in),e.a=t.refresh_token,{accessToken:e.b,expirationTime:e.c,refreshToken:e.a}}).s(function(t){throw"auth/user-token-expired"==t.code&&(e.a=null),t})}function _c(t,e){this.a=t||null,this.b=e||null,ji(this,{lastSignInTime:Pi(e||null),creationTime:Pi(t||null)})}function Pc(t,e,n,i,r,o){ji(this,{uid:t,displayName:i||null,photoURL:r||null,email:n||null,phoneNumber:o||null,providerId:e})}function Rc(t,e){for(var n in Ce.call(this,t),e)this[n]=e[n]}function Cc(t,e,n){this.I=[],this.l=t.apiKey,this.m=t.appName,this.o=t.authDomain||null,t=fl.SDK_VERSION?pi(fl.SDK_VERSION):null,this.a=new Pa(this.l,Nr(Ar),t),this.b=new Ac(this.a),Vc(this,e[Ca]),Sc(this.b,e),Mi(this,"refreshToken",this.b.a),qc(this,n||{}),nn.call(this),this.J=!1,this.o&&bi()&&(this.i=fc(this.o,this.l,this.m)),this.O=[],this.h=null,this.w=function(e){return new Ec(function(){return e.G(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var t=e.b.c-E()-3e5;return 0this.c-3e4?this.a?Oc(this,{grant_type:"refresh_token",refresh_token:this.a}):Yt(null):Yt({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},_c.prototype.A=function(){return{lastLoginAt:this.b,createdAt:this.a}},k(Rc,Ce),k(Cc,nn),Cc.prototype.ua=function(t){this.ga=t,ja(this.a,t)},Cc.prototype.ha=function(){return this.ga},Cc.prototype.Ca=function(){return H(this.P)},Cc.prototype.Ja=function(){this.w.b&&(this.w.stop(),this.w.start())},Mi(Cc.prototype,"providerId","firebase"),(t=Cc.prototype).reload=function(){var t=this;return rh(this,Bc(this).then(function(){return zc(t).then(function(){return Fc(t)}).then(Hc)}))},t.dc=function(t){return this.G(t).then(function(t){return new Tc(t)})},t.G=function(t){var e=this;return rh(this,Bc(this).then(function(){return e.b.getToken(t)}).then(function(t){if(!t)throw new Yi("internal-error");return t.accessToken!=e.ma&&(Vc(e,t.accessToken),e.dispatchEvent(new Rc("tokenChanged"))),Jc(e,"refreshToken",t.refreshToken),t.accessToken}))},t.zc=function(t){if(!(t=t.users)||!t.length)throw new Yi("internal-error");qc(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt,tenantId:t.tenantId});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?j(t,function(t){return new Pc(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n=Qh.length)throw new Yi("internal-error","Argument validator received an unsupported number of arguments.");n=Qh[r],i=(i?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.M+".";break t}i=null}}if(i)throw new Yi("argument-error",t+" failed: "+i)}(t=Hh.prototype).Da=function(){var e=this;return this.f?this.f:this.f=Yh(this,Yt().then(function(){if(yi()&&!si())return ri();throw new Yi("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return e.m.g(e.v())}).then(function(t){return e.g=t,Ns(e.o,ds,{})}).then(function(t){e.a[Wh]=t.recaptchaSiteKey}).s(function(t){throw e.f=null,t}))},t.render=function(){zh(this);var n=this;return Yh(this,this.Da().then(function(){if(null===n.c){var t=n.u;if(!n.i){var e=Fn(t);t=Hn("DIV"),e.appendChild(t)}n.c=n.g.render(t,n.a)}return n.c}))},t.verify=function(){zh(this);var r=this;return Yh(this,this.render().then(function(i){return new qt(function(e){var t=r.g.getResponse(i);if(t)e(t);else{var n=function(t){t&&(function(t,e){K(t.l,function(t){return t==e})}(r,n),e(t))};r.l.push(n),r.i&&r.g.execute(r.c)}})}))},t.reset=function(){zh(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){zh(this),this.B=!0,this.m.c();for(var t=0;ta[0]&&e[1]"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new d(i,s),c=0,h=Object.keys(r);c>>0),P=0;function x(t,e,n){return t.call.apply(t.bind,arguments)}function F(e,n,t){if(!e)throw Error();if(2parseFloat(dt)){ot=String(yt);break t}}ot=dt}var gt,vt={};function bt(s){return function(t,e){var n=vt;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(s,function(){for(var t=0,e=Y(String(ot)).split("."),n=Y(String(s)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i>>0);function jt(e){return"function"==R(e)?e:(e[Qt]||(e[Qt]=function(t){return e.handleEvent(t)}),e[Qt])}function Wt(){K.call(this),this.c=new Mt(this),(this.J=this).B=null}function Gt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;oe.length?_e:(e=e.substr(r,n),t.A=r+n,e))}function Be(t){t.R=B()+t.O,Ue(t,t.O)}function Ue(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=we(q(t.bb,t),e)}function Ke(t){t.i&&(C.clearTimeout(t.i),t.i=null)}function Qe(t){t.g.Da()||t.m||t.g.na(t)}function je(t){Ke(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,oe(t.P),fe(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function We(t,e){try{t.g.Ga(t,e),ye(4)}catch(t){}}function Ge(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(L(t)||D(t))j(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(L(t)||D(t)){n=[];for(var r=t.length,i=0;i2*t.c&&Ye(t))}function Ye(t){if(t.c!=t.a.length){for(var e=0,n=0;e>4&15).toString(16)+(15&t).toString(16)}Ze.prototype.toString=function(){var t=[],e=this.f;e&&t.push(cn(e,ln,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(cn(e,ln,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(cn(n,"/"==n.charAt(0)?pn:fn,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",cn(n,mn)),t.join("")},Ze.prototype.resolve=function(t){var e=$e(this),n=!!t.f;n?tn(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?en(e,t.b):n=null!=t.i;var r=t.a;if(n)nn(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(X(i,"./")||X(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a=t.f}function On(t){return t.b?1:t.a?t.a.a.c:0}function _n(t,e){return t=t.b?t.b==e:!!t.a&&(e=Nn(e),Xe(t.a.a.b,e))}function Pn(t,e){t.a?t.a.add(e):t.b=e}function xn(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=Nn(e),n=Xe(t.a.a.b,n)),n&&He(t.a.a,Nn(e)))}function Fn(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return G(t.c);var e=t.c;return j(t.a.C(),function(t){e=e.concat(t.j)}),e}function qn(){}function Vn(){this.a=new qn}function Bn(t,r,e){var i=e||"";try{Ge(t,function(t,e){var n=t;O(t)&&(n=zt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Un(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}kn.prototype.cancel=function(){this.c=Fn(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(j(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},qn.prototype.stringify=function(t){return C.JSON.stringify(t,void 0)},qn.prototype.parse=function(t){return C.JSON.parse(t,void 0)};var Kn=C.JSON.parse;function Qn(t){Wt.call(this),this.headers=new ze,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=jn,this.D=this.F=!1}U(Qn,Wt);var jn="",Wn=/^https?$/i,Gn=["POST","PUT"];function zn(t){return"content-type"==t.toLowerCase()}function Hn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Yn(t),Jn(t)}function Yn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Xn(t){if(t.b&&void 0!==I&&(!t.s[1]||4!=$n(t)||2!=t.T()))if(t.l&&4==$n(t))ae(t.Fa,0,t);else if(t.dispatchEvent("readystatechange"),4==$n(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.A).match(Je)[1]||null;if(!o&&C.self&&C.self.location){var a=C.self.location.protocol;o=a.substr(0,a.length-1)}i=!Wn.test(o?o.toLowerCase():"")}e=i}e?(t.dispatchEvent("complete"),t.dispatchEvent("success")):(t.h=6,t.f=t.za()+" ["+t.T()+"]",Yn(t))}finally{Jn(t)}}}function Jn(t,e){if(t.a){Zn(t);var n=t.a,r=t.s[0]?k:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function Zn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(C.clearTimeout(t.m),t.m=null)}function $n(t){return t.a?t.a.readyState:0}function tr(t,e){return t.a?t.a.getResponseHeader(e):null}function er(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;if(n=function(t){var n="";return tt(t,function(t,e){n+=e,n+=":",n+=t,n+="\r\n"}),n}(n),D(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if((n=t.indexOf("#"))<0&&(n=t.length),(r=t.indexOf("?"))<0||n=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Pa?0:t.Qa))&&(t.h=we(q(t.Ia,t,e),dr(t,t.A)),t.A++,!0))}(this,t)||2==n&&lr(this)))switch(e&&0r)throw new zr(Gr.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+bi(e.length,"argument")+".")}function oi(t,e,n,r){li(t,e,vi(n)+" argument",r)}function ai(t,e,n,r){void 0!==r&&oi(t,e,n,r)}function si(t,e,n,r){li(t,e,n+" option",r)}function ui(t,e,n,r){void 0!==r&&si(t,e,n,r)}function ci(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new zr(Gr.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+pi(r));for(var o=0;o=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},qi.prototype.popLast=function(){return Ur(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},qi.prototype.firstSegment=function(){return Ur(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},qi.prototype.lastSegment=function(){return this.get(this.length-1)},qi.prototype.get=function(t){return Ur(te.length?1:0},qi);function qi(t,e,n){void 0===e?e=0:e>t.length&&Br("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&Br("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n}var Vi,Bi=(t(Ui,Vi=Fi),Ui.prototype.construct=function(t,e,n){return new Ui(t,e,n)},Ui.prototype.canonicalString=function(){return this.toArray().join("/")},Ui.prototype.toString=function(){return this.canonicalString()},Ui.fromString=function(t){if(0<=t.indexOf("//"))throw new zr(Gr.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new Ui(t.split("/").filter(function(t){return 0",t),this.store.put(t)))},Jo.prototype.add=function(t){return Fr(Qo,"ADD",this.store.name,t,t),Zo(this.store.add(t))},Jo.prototype.get=function(e){var n=this;return Zo(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Fr(Qo,"GET",n.store.name,e,t),t})},Jo.prototype.delete=function(t){return Fr(Qo,"DELETE",this.store.name,t),Zo(this.store.delete(t))},Jo.prototype.count=function(){return Fr(Qo,"COUNT",this.store.name),Zo(this.store.count())},Jo.prototype.loadAll=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.iterateCursor(n,function(t,e){r.push(e)}).next(function(){return r})},Jo.prototype.deleteAll=function(t,e){Fr(Qo,"DELETE ALL",this.store.name);var n=this.options(t,e);n.keysOnly=!1;var r=this.cursor(n);return this.iterateCursor(r,function(t,e,n){return n.delete()})},Jo.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},Jo.prototype.iterateSerial=function(i){var t=this.cursor({});return new Uo(function(n,r){t.onerror=function(t){var e=ta(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()}})},Jo.prototype.iterateCursor=function(t,a){var s=[];return new Uo(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 Go(e),r=a(e.primaryKey,e.value,n);if(r instanceof Uo){var i=r.catch(function(t){return n.done(),Uo.reject(t)});s.push(i)}n.isDone?o():null===n.skipToKey?e.continue():e.continue(n.skipToKey)}else o()}}).next(function(){return Uo.waitFor(s)})},Jo.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(Ur(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},Jo.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.keysOnly?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},Jo);function Jo(t){this.store=t}function Zo(t){return new Uo(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=ta(t.target.error);r(e)}})}var $o=!1;function ta(t){var e=jo.getIOSVersion(h());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 zr("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 $o||($o=!0,setTimeout(function(){throw r},0)),r}}return t}var ea=(na.forUser=function(t,e,n,r){return Ur(""!==t.uid,"UserID must not be an empty string."),new na(t.isAuthenticated()?t.uid:"",e,n,r)},na.prototype.checkEmpty=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return aa(t).iterate({index:gu.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},na.prototype.acknowledgeBatch=function(e,t,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=oa(n),ua(e).put(t)})},na.prototype.getLastStreamToken=function(t){return this.getMutationQueueMetadata(t).next(function(t){return t.lastStreamToken})},na.prototype.setLastStreamToken=function(e,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=oa(n),ua(e).put(t)})},na.prototype.addMutationBatch=function(c,h,l,f){var p=this,d=sa(c),m=aa(c);return m.add({}).next(function(t){Ur("number"==typeof t,"Auto-generated key is not a number");for(var e=new Fo(t,h,l,f),n=p.serializer.toDbMutationBatch(p.userId,e),r=[],i=new So(function(t,e){return Si(t.canonicalString(),e.canonicalString())}),o=0,a=f;o=i,"Should have found mutation after "+i),o=r.serializer.fromDbMutationBatch(e)),n.done()}).next(function(){return o})},na.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return aa(t).iterate({index:gu.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},na.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return aa(t).loadAll(gu.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.fromDbMutationBatch(t)})})},na.prototype.getAllMutationBatchesAffectingDocumentKey=function(s,u){var c=this,t=bu.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),h=[];return sa(s).iterate({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],a=uo(i);if(r===c.userId&&u.path.isEqual(a))return aa(s).get(o).next(function(t){if(!t)throw Br("Dangling document-mutation reference found: "+e+" which points to "+o);Ur(t.userId===c.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),h.push(c.serializer.fromDbMutationBatch(t))});n.done()}).next(function(){return h})},na.prototype.getAllMutationBatchesAffectingDocumentKeys=function(r,t){var u=this,c=new So(Si),i=[];return t.forEach(function(s){var t=bu.prefixForPath(u.userId,s.path),e=IDBKeyRange.lowerBound(t),n=sa(r).iterate({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=uo(i);r===u.userId&&s.path.isEqual(a)?c=c.add(o):n.done()});i.push(n)}),Uo.waitFor(i).next(function(){return u.lookupMutationBatches(r,c)})},na.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var s=this;Ur(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),Ur(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var u=e.path,c=u.length+1,n=bu.prefixForPath(this.userId,u),r=IDBKeyRange.lowerBound(n),h=new So(Si);return sa(t).iterate({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=uo(i);r===s.userId&&u.isPrefixOf(a)?a.length===c&&(h=h.add(o)):n.done()}).next(function(){return s.lookupMutationBatches(t,h)})},na.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(aa(t).get(e).next(function(t){if(null===t)throw Br("Dangling document-mutation reference found, which points to "+e);Ur(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))}))}),Uo.waitFor(i).next(function(){return r})},na.prototype.removeMutationBatch=function(e,n){var r=this;return ia(e.simpleDbTransaction,this.userId,n).next(function(t){return e.addOnCommittedListener(function(){r.removeCachedMutationKeys(n.batchId)}),Uo.forEach(t,function(t){return r.referenceDelegate.removeMutationReference(e,t)})})},na.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},na.prototype.performConsistencyCheck=function(n){var o=this;return this.checkEmpty(n).next(function(t){if(!t)return Uo.resolve();var e=IDBKeyRange.lowerBound(bu.prefixForUser(o.userId)),i=[];return sa(n).iterate({range:e},function(t,e,n){if(t[0]===o.userId){var r=uo(t[1]);i.push(r)}else n.done()}).next(function(){Ur(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.canonicalString()}))})})},na.prototype.containsKey=function(t,e){return ra(t,this.userId,e)},na.prototype.getMutationQueueMetadata=function(t){var e=this;return ua(t).get(this.userId).next(function(t){return t||new mu(e.userId,-1,"")})},na);function na(t,e,n,r){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=r,this.documentKeysByBatchId={}}function ra(t,o,e){var n=bu.prefixForPath(o,e.path),a=n[1],r=IDBKeyRange.lowerBound(n),s=!1;return sa(t).iterate({range:r,keysOnly:!0},function(t,e,n){var r=t[0],i=t[1];t[2];r===o&&i===a&&(s=!0),n.done()}).next(function(){return s})}function ia(t,e,n){var r=t.store(gu.store),i=t.store(bu.store),o=[],a=IDBKeyRange.only(n.batchId),s=0,u=r.iterate({range:a},function(t,e,n){return s++,n.delete()});o.push(u.next(function(){Ur(1===s,"Dangling document-mutation reference found: Missing batch "+n.batchId)}));for(var c=[],h=0,l=n.mutations;ht.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.saveMetadata(e,t)})},da.prototype.addTargetData=function(e,n){var r=this;return this.saveTargetData(e,n).next(function(){return r.retrieveMetadata(e).next(function(t){return t.targetCount+=1,r.updateMetadataFromTargetData(n,t),r.saveMetadata(e,t)})})},da.prototype.updateTargetData=function(t,e){return this.saveTargetData(t,e)},da.prototype.removeTargetData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return ma(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return Ur(0e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},da.prototype.getTargetCount=function(t){return this.retrieveMetadata(t).next(function(t){return t.targetCount})},da.prototype.getTargetData=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),a=null;return ma(t).iterate({range:n,index:Nu.queryTargetsIndexName},function(t,e,n){var r=o.serializer.fromDbTarget(e);i.isEqual(r.target)&&(a=r,n.done())}).next(function(){return a})},da.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],a=va(n);return t.forEach(function(t){var e=oo(t.path);o.push(a.put(new ku(r,e))),o.push(i.referenceDelegate.addReference(n,t))}),Uo.waitFor(o)},da.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=va(n);return Uo.forEach(t,function(t){var e=oo(t.path);return Uo.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,t)])})},da.prototype.removeMatchingKeysForTargetId=function(t,e){var n=va(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},da.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=va(t),o=_o();return r.iterate({range:n,keysOnly:!0},function(t,e,n){var r=uo(t[1]),i=new Gi(r);o=o.add(i)}).next(function(){return o})},da.prototype.containsKey=function(t,e){var n=oo(e.path),r=IDBKeyRange.bound([n],[Ii(n)],!1,!0),i=0;return va(t).iterate({index:ku.documentTargetsIndex,keysOnly:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0"},ws);function ws(t,e){var n=vs.call(this)||this;return n.localWriteTime=t,n.previousValue=e,n.typeOrder=Ba.TimestampValue,n}var Ts,Ss=(t(Es,Ts=Ha),Es.prototype.value=function(t){return this.internalValue},Es.prototype.isEqual=function(t){return t instanceof Es&&this.internalValue.isEqual(t.internalValue)},Es.prototype.compareTo=function(t){return t instanceof Es?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},Es);function Es(t){var e=Ts.call(this)||this;return e.internalValue=t,e.typeOrder=Ba.BlobValue,e}var Is,Cs=(t(Ds,Is=Ha),Ds.prototype.value=function(t){return this.key},Ds.prototype.isEqual=function(t){return t instanceof Ds&&this.key.isEqual(t.key)&&this.databaseId.isEqual(t.databaseId)},Ds.prototype.compareTo=function(t){if(t instanceof Ds){var e=this.databaseId.compareTo(t.databaseId);return 0!==e?e:Gi.comparator(this.key,t.key)}return this.defaultCompareTo(t)},Ds);function Ds(t,e){var n=Is.call(this)||this;return n.databaseId=t,n.key=e,n.typeOrder=Ba.RefValue,n}var Ns,As=(t(ks,Ns=Ha),ks.prototype.value=function(t){return this.internalValue},ks.prototype.isEqual=function(t){return t instanceof ks&&this.internalValue.isEqual(t.internalValue)},ks.prototype.compareTo=function(t){return t instanceof ks?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},ks);function ks(t){var e=Ns.call(this)||this;return e.internalValue=t,e.typeOrder=Ba.GeoPointValue,e}var Rs,Ms=(t(Ls,Rs=Ha),Ls.prototype.value=function(n){var r={};return this.internalValue.inorderTraversal(function(t,e){r[t]=e.value(n)}),r},Ls.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},Ls.prototype.isEqual=function(t){if(t instanceof Ls){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext();if(r.key!==i.key||!r.value.isEqual(i.value))return!1}return!e.hasNext()&&!n.hasNext()}return!1},Ls.prototype.compareTo=function(t){if(t instanceof Ls){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext(),o=Si(r.key,i.key)||r.value.compareTo(i.value);if(o)return o}return Si(e.hasNext(),n.hasNext())}return this.defaultCompareTo(t)},Ls.prototype.set=function(t,e){if(Ur(!t.isEmpty(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.setChild(t.firstSegment(),e);var n=this.child(t.firstSegment());n instanceof Ls||(n=Ls.EMPTY);var r=n.set(t.popFirst(),e);return this.setChild(t.firstSegment(),r)},Ls.prototype.delete=function(t){if(Ur(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new Ls(this.internalValue.remove(t.firstSegment()));var e=this.child(t.firstSegment());if(e instanceof Ls){var n=e.delete(t.popFirst());return new Ls(this.internalValue.insert(t.firstSegment(),n))}return this},Ls.prototype.contains=function(t){return null!==this.field(t)},Ls.prototype.field=function(t){Ur(!t.isEmpty(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof Ls?e.internalValue.get(t):null}),e},Ls.prototype.fieldMask=function(){var i=new So(ji.comparator);return this.internalValue.forEach(function(t,e){var n=new ji([t]);if(e instanceof Ls){var r=e.fieldMask().fields;r.isEmpty()?i=i.add(n):r.forEach(function(t){i=i.add(n.child(t))})}else i=i.add(n)}),ba.fromSet(i)},Ls.prototype.toString=function(){return this.internalValue.toString()},Ls.prototype.child=function(t){return this.internalValue.get(t)||void 0},Ls.prototype.setChild=function(t,e){return new Ls(this.internalValue.insert(t,e))},Ls.EMPTY=new Ls(new po(Si)),Ls);function Ls(t){var e=Rs.call(this)||this;return e.internalValue=t,e.typeOrder=Ba.ObjectValue,e}var Os,_s=(t(Ps,Os=Ha),Ps.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},Ps.prototype.contains=function(t){for(var e=0,n=this.internalValue;eh.params.maximumSequenceNumbersToCollect?(Fr("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+t),h.params.maximumSequenceNumbersToCollect):t,a=Date.now(),h.nthSequenceNumber(e,i)}).next(function(t){return r=t,s=Date.now(),h.removeTargets(e,r,n)}).next(function(t){return o=t,u=Date.now(),h.removeOrphanedDocuments(e,r)}).next(function(t){return c=Date.now(),Pr()<=Cr.DEBUG&&Fr("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(a-l)+"ms\n\tDetermined least recently used "+i+" in "+(s-a)+"ms\n\tRemoved "+o+" targets in "+(u-s)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms"),Uo.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},rc);function rc(t,e){this.delegate=t,this.params=e}var ic=(oc.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},oc.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},oc);function oc(){this.onCommittedListeners=[]}var ac,sc="IndexedDbPersistence",uc="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",cc="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",hc=(t(lc,ac=ic),lc);function lc(t,e){var n=ac.call(this)||this;return n.simpleDbTransaction=t,n.currentSequenceNumber=e,n}var fc=(pc.getStore=function(t,e){if(t instanceof hc)return jo.getStore(t.simpleDbTransaction,e);throw Br("IndexedDbPersistence must use instances of IndexedDbTransaction")},pc.createIndexedDbPersistence=function(n){return p(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:if(!pc.isAvailable())throw new zr(Gr.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(e=new pc(n.allowTabSynchronization,n.persistenceKey,n.clientId,n.platform,n.lruParams,n.queue,n.serializer,n.sequenceNumberSyncer)).start()];case 1:return t.sent(),[2,e]}})})},pc.prototype.start=function(){var e=this;return Ur(!this.started,"IndexedDbPersistence double-started!"),Ur(null!==this.window,"Expected 'window' to be defined"),jo.openOrCreate(this.dbName,cu,new hu(this.serializer)).then(function(t){return e.simpleDb=t,e.updateClientMetadataAndTryBecomePrimary()}).then(function(){return e.attachVisibilityHandler(),e.attachWindowUnloadHook(),e.scheduleClientMetadataAndPrimaryLeaseRefreshes(),e.simpleDb.runTransaction("readonly-idempotent",[Mu.store],function(t){return ga(t)})}).then(function(t){e.listenSequence=new _i(t,e.sequenceNumberSyncer)}).then(function(){e._started=!0}).catch(function(t){return e.simpleDb&&e.simpleDb.close(),Promise.reject(t)})},pc.prototype.setPrimaryStateListener=function(n){var t=this;return this.primaryStateListener=function(e){return p(t,void 0,void 0,function(){return m(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},pc.prototype.setDatabaseDeletedListener=function(n){var t=this;this.simpleDb.setVersionChangeListener(function(e){return p(t,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return null!==e.newVersion?[3,2]:[4,n()];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},pc.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget(function(){return p(e,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.started?[4,this.updateClientMetadataAndTryBecomePrimary()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},pc.prototype.updateClientMetadataAndTryBecomePrimary=function(){var n=this;return this.simpleDb.runTransaction("readwrite-idempotent",Bu,function(e){return yc(e).put(new xu(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.verifyPrimaryLease(e).next(function(t){t||(n.isPrimary=!1,n.queue.enqueueAndForget(function(){return n.primaryStateListener(!1)}))})}).next(function(){return n.canActAsPrimary(e)}).next(function(t){return n.isPrimary&&!t?n.releasePrimaryLeaseIfHeld(e).next(function(){return!1}):!!t&&n.acquireOrExtendPrimaryLease(e).next(function(){return!0})})}).catch(function(t){if(!n.allowTabSynchronization)throw t;return Fr(sc,"Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.queue.enqueueAndForget(function(){return n.primaryStateListener(t)}),n.isPrimary=t})},pc.prototype.verifyPrimaryLease=function(t){var e=this;return mc(t).get(pu.key).next(function(t){return Uo.resolve(e.isLocalClient(t))})},pc.prototype.removeClientMetadata=function(t){return yc(t).delete(this.clientId)},pc.prototype.maybeGarbageCollectMultiClientState=function(){return p(this,void 0,void 0,function(){var i=this;return m(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.isWithinAge(this.lastGarbageCollectionTime,18e5)?[3,2]:(this.lastGarbageCollectionTime=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary-idempotent",function(t){var r=pc.getStore(t,xu.store);return r.loadAll().next(function(t){var e=i.filterActiveClients(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return Uo.forEach(n,function(t){return r.delete(t.clientId)}).next(function(){return n})})})]);case 1:t.sent().forEach(function(t){i.window.localStorage.removeItem(i.zombiedClientLocalStorageKey(t.clientId))}),t.label=2;case 2:return[2]}})})},pc.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(Hi.ClientMetadataRefresh,4e3,function(){return t.updateClientMetadataAndTryBecomePrimary().then(function(){return t.maybeGarbageCollectMultiClientState()}).then(function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},pc.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},pc.prototype.canActAsPrimary=function(e){var i=this;return mc(e).get(pu.key).next(function(t){if(null!==t&&i.isWithinAge(t.leaseTimestampMs,5e3)&&!i.isClientZombied(t.ownerId)){if(i.isLocalClient(t)&&i.networkEnabled)return!0;if(!i.isLocalClient(t)){if(!t.allowTabSynchronization)throw new zr(Gr.FAILED_PRECONDITION,cc);return!1}}return!(!i.networkEnabled||!i.inForeground)||yc(e).loadAll().next(function(t){return void 0===i.filterActiveClients(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&&Fr(sc,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},pc.prototype.shutdown=function(){return p(this,void 0,void 0,function(){var e=this;return m(this,function(t){switch(t.label){case 0:return this._started=!1,this.markClientZombied(),this.clientMetadataRefresher&&(this.clientMetadataRefresher.cancel(),this.clientMetadataRefresher=null),this.detachVisibilityHandler(),this.detachWindowUnloadHook(),[4,this.simpleDb.runTransaction("readwrite-idempotent",[pu.store,xu.store],function(t){return e.releasePrimaryLeaseIfHeld(t).next(function(){return e.removeClientMetadata(t)})})];case 1:return t.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}})})},pc.prototype.filterActiveClients=function(t,e){var n=this;return t.filter(function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)})},pc.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction("readonly-idempotent",[xu.store],function(t){return yc(t).loadAll().next(function(t){return e.filterActiveClients(t,18e5).map(function(t){return t.clientId})})})},pc.clearPersistence=function(n){return p(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return pc.isAvailable()?(e=n+pc.MAIN_DATABASE,[4,jo.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(pc.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),pc.prototype.getMutationQueue=function(t){return Ur(this.started,"Cannot initialize MutationQueue before persistence is started."),ea.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},pc.prototype.getTargetCache=function(){return Ur(this.started,"Cannot initialize TargetCache before persistence is started."),this.targetCache},pc.prototype.getRemoteDocumentCache=function(){return Ur(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},pc.prototype.getIndexManager=function(){return Ur(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},pc.prototype.runTransaction=function(n,t,r){var i=this;Fr(sc,"Starting transaction:",n);var o,e=t.endsWith("idempotent"),a=t.startsWith("readonly")?e?"readonly-idempotent":"readonly":e?"readwrite-idempotent":"readwrite";return this.simpleDb.runTransaction(a,Bu,function(e){return o=new hc(e,i.listenSequence.next()),"readwrite-primary"===t||"readwrite-primary-idempotent"===t?i.verifyPrimaryLease(e).next(function(t){return!!t||i.canActAsPrimary(e)}).next(function(t){if(!t)throw qr("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.queue.enqueueAndForget(function(){return i.primaryStateListener(!1)}),new zr(Gr.FAILED_PRECONDITION,uc);return r(o)}).next(function(t){return i.acquireOrExtendPrimaryLease(e).next(function(){return t})}):i.verifyAllowTabSynchronization(e).next(function(){return r(o)})}).then(function(t){return o.raiseOnCommittedEvent(),t})},pc.prototype.verifyAllowTabSynchronization=function(t){var e=this;return mc(t).get(pu.key).next(function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new zr(Gr.FAILED_PRECONDITION,cc)})},pc.prototype.acquireOrExtendPrimaryLease=function(t){var e=new pu(this.clientId,this.allowTabSynchronization,Date.now());return mc(t).put(pu.key,e)},pc.isAvailable=function(){return jo.isAvailable()},pc.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},pc.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=mc(t);return n.get(pu.key).next(function(t){return e.isLocalClient(t)?(Fr(sc,"Releasing primary lease."),n.delete(pu.key)):Uo.resolve()})},pc.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t "+n),1))},pc.prototype.attachVisibilityHandler=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.documentVisibilityHandler=function(){t.queue.enqueueAndForget(function(){return t.inForeground="visible"===t.document.visibilityState,t.updateClientMetadataAndTryBecomePrimary()})},this.document.addEventListener("visibilitychange",this.documentVisibilityHandler),this.inForeground="visible"===this.document.visibilityState)},pc.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(Ur(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},pc.prototype.attachWindowUnloadHook=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.windowUnloadHandler=function(){t.markClientZombied(),t.queue.enqueueAndForget(function(){return t.shutdown()})},this.window.addEventListener("unload",this.windowUnloadHandler))},pc.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(Ur("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},pc.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return Fr(sc,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return qr(sc,"Failed to get zombied client id.",t),!1}},pc.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){qr("Failed to set zombie client id.",t)}},pc.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},pc.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},pc.MAIN_DATABASE="main",pc);function pc(t,e,n,r,i,o,a,s){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.queue=o,this.sequenceNumberSyncer=s,this._started=!1,this.isPrimary=!1,this.networkEnabled=!0,this.windowUnloadHandler=null,this.inForeground=!1,this.documentVisibilityHandler=null,this.clientMetadataRefresher=null,this.lastGarbageCollectionTime=Number.NEGATIVE_INFINITY,this.primaryStateListener=function(t){return Promise.resolve()},this.referenceDelegate=new gc(this,i),this.dbName=e+pc.MAIN_DATABASE,this.serializer=new Gu(a),this.document=r.document,this.targetCache=new pa(this.referenceDelegate,this.serializer),this.indexManager=new Uu,this.remoteDocumentCache=new Zs(this.serializer,this.indexManager),!r.window||!r.window.localStorage)throw new zr(Gr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.webStorage=this.window.localStorage}function dc(e){return p(this,void 0,void 0,function(){return m(this,function(t){if(!function(t){return t.code===Gr.FAILED_PRECONDITION&&t.message===uc}(e))throw e;return Fr(sc,"Unexpectedly lost primary lease"),[2]})})}function mc(t){return t.store(pu.store)}function yc(t){return t.store(xu.store)}var gc=(vc.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocmentCount(t);return this.db.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},vc.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},vc.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},vc.prototype.forEachOrphanedDocumentSequenceNumber=function(t,n){return this.forEachOrphanedDocument(t,function(t,e){return n(e)})},vc.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},vc.prototype.addReference=function(t,e){return bc(t,e)},vc.prototype.removeReference=function(t,e){return bc(t,e)},vc.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},vc.prototype.removeMutationReference=function(t,e){return bc(t,e)},vc.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?Uo.resolve(!0):function(e,n){var r=!1;return ua(e).iterateSerial(function(t){return ra(e,t,n).next(function(t){return t&&(r=!0),Uo.resolve(!t)})}).next(function(){return r})}(t,e)},vc.prototype.removeOrphanedDocuments=function(r,i){var o=this,a=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[],u=0;return this.forEachOrphanedDocument(r,function(e,t){if(t<=i){var n=o.isPinned(r,e).next(function(t){if(!t)return u++,a.getEntry(r,e).next(function(){return a.removeEntry(e),va(r).delete(function(t){return[0,oo(t.path)]}(e))})});s.push(n)}}).next(function(){return Uo.waitFor(s)}).next(function(){return a.apply(r)}).next(function(){return u})},vc.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},vc.prototype.updateLimboDocument=function(t,e){return bc(t,e)},vc.prototype.forEachOrphanedDocument=function(t,o){var a,e=va(t),s=_i.INVALID;return e.iterate({index:ku.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(s!==_i.INVALID&&o(new Gi(uo(a)),s),s=i,a=r):s=_i.INVALID}).next(function(){s!==_i.INVALID&&o(new Gi(uo(a)),s)})},vc.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},vc);function vc(t,e){this.db=t,this.inMemoryPins=null,this.garbageCollector=new nc(this,e)}function bc(t,e){return va(t).put(function(t,e){return new ku(0,oo(t.path),e)}(e,t.currentSequenceNumber))}var wc=Number,Tc=wc.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),Sc=wc.MAX_SAFE_INTEGER||Math.pow(2,53)-1,Ec=wc.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function Ic(t){return null==t}function Cc(t){return Ec(t)&&t<=Sc&&Tc<=t}var Dc,Nc,Ac=(kc.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:";for(var e=0,n=this.filters;e=":return _c.GREATER_THAN_OR_EQUAL;case">":return _c.GREATER_THAN;case"array-contains":return _c.ARRAY_CONTAINS;case"in":return _c.IN;case"array-contains-any":return _c.ARRAY_CONTAINS_ANY;default:return Br("Unknown FieldFilter operator: "+t)}},_c.prototype.toString=function(){return this.name},_c.prototype.isEqual=function(t){return this.name===t.name},_c.LESS_THAN=new _c("<"),_c.LESS_THAN_OR_EQUAL=new _c("<="),_c.EQUAL=new _c("=="),_c.GREATER_THAN=new _c(">"),_c.GREATER_THAN_OR_EQUAL=new _c(">="),_c.ARRAY_CONTAINS=new _c("array-contains"),_c.IN=new _c("in"),_c.ARRAY_CONTAINS_ANY=new _c("array-contains-any"),_c);function _c(t){this.name=t}var Pc,xc=(t(Fc,Pc=Lc),Fc.create=function(t,e,n){if(t.isKeyField())return e===Oc.IN?(Ur(n instanceof _s,"Comparing on key with IN, but filter value not an ArrayValue"),Ur(n.internalValue.every(function(t){return t instanceof Cs}),"Comparing on key with IN, but an array value was not a RefValue"),new Kc(t,n)):(Ur(n instanceof Cs,"Comparing on key, but filter value not a RefValue"),Ur(e!==Oc.ARRAY_CONTAINS&&e!==Oc.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new Vc(t,e,n));if(n.isEqual(Ja.INSTANCE)){if(e!==Oc.EQUAL)throw new zr(Gr.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new Fc(t,e,n)}if(n.isEqual(hs.NAN)){if(e!==Oc.EQUAL)throw new zr(Gr.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new Fc(t,e,n)}return e===Oc.ARRAY_CONTAINS?new Wc(t,n):e===Oc.IN?(Ur(n instanceof _s,"IN filter has invalid value: "+n.toString()),new Hc(t,n)):e===Oc.ARRAY_CONTAINS_ANY?(Ur(n instanceof _s,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new Jc(t,n)):new Fc(t,e,n)},Fc.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},Fc.prototype.matchesComparison=function(t){switch(this.op){case Oc.LESS_THAN:return t<0;case Oc.LESS_THAN_OR_EQUAL:return t<=0;case Oc.EQUAL:return 0===t;case Oc.GREATER_THAN:return 0=this.RESUME_TOKEN_MAX_AGE_MICROS||0i?this.mutationQueue[i]:null)},vh.prototype.getHighestUnacknowledgedBatchId=function(){return Uo.resolve(0===this.mutationQueue.length?-1:this.nextBatchId-1)},vh.prototype.getAllMutationBatches=function(t){return Uo.resolve(this.mutationQueue.slice())},vh.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,e=new ph(n,0),i=new ph(n,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([e,i],function(t){Ur(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.findMutationBatch(t.targetOrBatchId);Ur(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),Uo.resolve(o)},vh.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var r=this,i=new So(Si);return e.forEach(function(e){var t=new ph(e,0),n=new ph(e,Number.POSITIVE_INFINITY);r.batchesByDocumentKey.forEachInRange([t,n],function(t){Ur(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.targetOrBatchId)})}),Uo.resolve(this.findMutationBatches(i))},vh.prototype.getAllMutationBatchesAffectingQuery=function(t,e){Ur(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;Gi.isDocumentKey(i)||(i=i.child(""));var o=new ph(new Gi(i),0),a=new So(Si);return this.batchesByDocumentKey.forEachWhile(function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(a=a.add(t.targetOrBatchId)),!0)},o),Uo.resolve(this.findMutationBatches(a))},vh.prototype.findMutationBatches=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.findMutationBatch(t);null!==e&&r.push(e)}),r},vh.prototype.removeMutationBatch=function(n,r){var i=this;Ur(0===this.indexOfExistingBatchId(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var o=this.batchesByDocumentKey;return Uo.forEach(r.mutations,function(t){var e=new ph(t.key,r.batchId);return o=o.delete(e),i.referenceDelegate.removeMutationReference(n,t.key)}).next(function(){i.batchesByDocumentKey=o})},vh.prototype.removeCachedMutationKeys=function(t){},vh.prototype.containsKey=function(t,e){var n=new ph(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return Uo.resolve(e.isEqual(r&&r.key))},vh.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&Ur(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),Uo.resolve()},vh.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return Ur(0<=n&&n=this.mutationQueue.length)return null;var n=this.mutationQueue[e];return Ur(n.batchId===t,"If found batch must match"),n},vh);function vh(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.nextBatchId=1,this.lastStreamToken=jr(),this.batchesByDocumentKey=new So(ph.compareByKey)}var bh,wh=(Th.prototype.addEntry=function(t,e,n){Ur(!n.isEqual(lo.MIN),"Cannot add a document with a read time of zero");var r=e.key,i=this.docs.get(r),o=i?i.size:0,a=this.sizer(e);return this.docs=this.docs.insert(r,{maybeDocument:e,size:a,readTime:n}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())},Th.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Th.prototype.getEntry=function(t,e){var n=this.docs.get(e);return Uo.resolve(n?n.maybeDocument:null)},Th.prototype.getEntries=function(t,e){var n=this,r=Ao();return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.maybeDocument:null)}),Uo.resolve(r)},Th.prototype.getDocumentsMatchingQuery=function(t,e,n){Ur(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=Ro(),i=new Gi(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var a=o.getNext(),s=a.key,u=a.value,c=u.maybeDocument,h=u.readTime;if(!e.path.isPrefixOf(s.path))break;h.compareTo(n)<=0||c instanceof Vs&&e.matches(c)&&(r=r.insert(c.key,c))}return Uo.resolve(r)},Th.prototype.forEachDocumentKey=function(t,e){return Uo.forEach(this.docs,function(t){return e(t)})},Th.prototype.getNewDocumentChanges=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},Th.prototype.newChangeBuffer=function(t){return new Th.RemoteDocumentChangeBuffer(this)},Th.prototype.getSize=function(t){return Uo.resolve(this.size)},Th.RemoteDocumentChangeBuffer=(t(Sh,bh=Ys),Sh.prototype.applyChanges=function(n){var r=this,i=[];return this.changes.forEach(function(t,e){e?i.push(r.documentCache.addEntry(n,e,r.readTime)):r.documentCache.removeEntry(t)}),Uo.waitFor(i)},Sh.prototype.getFromCache=function(t,e){return this.documentCache.getEntry(t,e)},Sh.prototype.getAllFromCache=function(t,e){return this.documentCache.getEntries(t,e)},Sh),Th);function Th(t,e){this.indexManager=t,this.sizer=e,this.docs=new po(Gi.comparator),this.size=0}function Sh(t){var e=bh.call(this)||this;return e.documentCache=t,e}var Eh=(Ih.prototype.forEachTarget=function(t,n){return this.targets.forEach(function(t,e){return n(e)}),Uo.resolve()},Ih.prototype.getLastRemoteSnapshotVersion=function(t){return Uo.resolve(this.lastRemoteSnapshotVersion)},Ih.prototype.getHighestSequenceNumber=function(t){return Uo.resolve(this.highestSequenceNumber)},Ih.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,Uo.resolve(e)},Ih.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),Uo.resolve()},Ih.prototype.saveTargetData=function(t){this.targets.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},Ih.prototype.addTargetData=function(t,e){return Ur(!this.targets.has(e.target),"Adding a target that already exists"),this.saveTargetData(e),this.targetCount+=1,Uo.resolve()},Ih.prototype.updateTargetData=function(t,e){return Ur(this.targets.has(e.target),"Updating a non-existent target"),this.saveTargetData(e),Uo.resolve()},Ih.prototype.removeTargetData=function(t,e){return Ur(0this.maxDelayMs&&(this.currentBaseMs=this.maxDelayMs)},Ph.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},Ph.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},Ph);function Ph(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.queue=t,this.timerId=e,this.initialDelayMs=n,this.backoffFactor=r,this.maxDelayMs=i,this.currentBaseMs=0,this.timerPromise=null,this.lastAttemptTime=Date.now(),this.reset()}var xh,Fh,qh="PersistentStream";(Fh=xh=xh||{})[Fh.Initial=0]="Initial",Fh[Fh.Starting=1]="Starting",Fh[Fh.Open=2]="Open",Fh[Fh.Error=3]="Error",Fh[Fh.Backoff=4]="Backoff";var Vh=(Bh.prototype.isStarted=function(){return this.state===xh.Starting||this.state===xh.Open||this.state===xh.Backoff},Bh.prototype.isOpen=function(){return this.state===xh.Open},Bh.prototype.start=function(){this.state!==xh.Error?(Ur(this.state===xh.Initial,"Already started"),this.auth()):this.performBackoff()},Bh.prototype.stop=function(){return p(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(xh.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Bh.prototype.inhibitBackoff=function(){Ur(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=xh.Initial,this.backoff.reset()},Bh.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,function(){return t.handleIdleCloseTimer()}))},Bh.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},Bh.prototype.handleIdleCloseTimer=function(){return p(this,void 0,void 0,function(){return m(this,function(t){return this.isOpen()?[2,this.close(xh.Initial)]:[2]})})},Bh.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},Bh.prototype.close=function(e,n){return p(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return Ur(this.isStarted(),"Only started streams should be closed."),Ur(e===xh.Error||Ic(n),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==xh.Error?this.backoff.reset():n&&n.code===Gr.RESOURCE_EXHAUSTED?(qr(n.toString()),qr("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):n&&n.code===Gr.UNAUTHENTICATED&&this.credentialsProvider.invalidateToken(),null!==this.stream&&(this.tearDown(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.onClose(n)];case 1:return t.sent(),[2]}})})},Bh.prototype.tearDown=function(){},Bh.prototype.auth=function(){var n=this;Ur(this.state===xh.Initial,"Must be in initial state to auth"),this.state=xh.Starting;var t=this.getCloseGuardedDispatcher(this.closeCount),e=this.closeCount;this.credentialsProvider.getToken().then(function(t){n.closeCount===e&&n.startStream(t)},function(e){t(function(){var t=new zr(Gr.UNKNOWN,"Fetching auth token failed: "+e.message);return n.handleStreamClose(t)})})},Bh.prototype.startStream=function(t){var e=this;Ur(this.state===xh.Starting,"Trying to start stream in a non-starting state");var n=this.getCloseGuardedDispatcher(this.closeCount);this.stream=this.startRpc(t),this.stream.onOpen(function(){n(function(){return Ur(e.state===xh.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=xh.Open,e.listener.onOpen()})}),this.stream.onClose(function(t){n(function(){return e.handleStreamClose(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Bh.prototype.performBackoff=function(){var t=this;Ur(this.state===xh.Error,"Should only perform backoff when in Error state"),this.state=xh.Backoff,this.backoff.backoffAndRun(function(){return p(t,void 0,void 0,function(){return m(this,function(t){return Ur(this.state===xh.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=xh.Initial,this.start(),Ur(this.isStarted(),"PersistentStream should have started"),[2]})})})},Bh.prototype.handleStreamClose=function(t){return Ur(this.isStarted(),"Can't handle server close on non-started stream"),Fr(qh,"close with error: "+t),this.stream=null,this.close(xh.Error,t)},Bh.prototype.getCloseGuardedDispatcher=function(e){var n=this;return function(t){n.queue.enqueueAndForget(function(){return n.closeCount===e?t():(Fr(qh,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Bh);function Bh(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=xh.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new _h(t,e)}var Uh,Kh=(t(Qh,Uh=Vh),Qh.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},Qh.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},Qh.prototype.watch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.addTarget=this.serializer.toTarget(t);var n=this.serializer.toListenRequestLabels(t);n&&(e.labels=n),this.sendRequest(e)},Qh.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},Qh);function Qh(t,e,n,r,i){var o=Uh.call(this,t,Hi.ListenStreamConnectionBackoff,Hi.ListenStreamIdle,e,n,i)||this;return o.serializer=r,o}var jh,Wh=(t(Gh,jh=Vh),Object.defineProperty(Gh.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),Gh.prototype.start=function(){this.handshakeComplete_=!1,jh.prototype.start.call(this)},Gh.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},Gh.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},Gh.prototype.onMessage=function(t){if(Ur(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.handshakeComplete_){this.backoff.reset();var e=this.serializer.fromWriteResults(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.onMutationResult(n,e)}return Ur(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},Gh.prototype.writeHandshake=function(){Ur(this.isOpen(),"Writing handshake requires an opened stream"),Ur(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},Gh.prototype.writeMutations=function(t){var e=this;Ur(this.isOpen(),"Writing mutations requires an opened stream"),Ur(this.handshakeComplete_,"Handshake must be complete before writing mutations"),Ur(0() instead."),Np=/^__.*__$/,Ap=(kp.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new _a(t,this.data,this.fieldMask,e)):n.push(new Ma(t,this.data,e)),0=",">","array-contains","in","array-contains-any"],2,e);var i=Kp("Query.where",t),o=Oc.fromString(e);if(i.isKeyField()){if(o===Oc.ARRAY_CONTAINS||o===Oc.ARRAY_CONTAINS_ANY)throw new zr(Gr.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===Oc.IN){this.validateDisjunctiveFilterElements(n,o);for(var a=[],s=0,u=n;sr.length)throw new zr(Gr.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, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var a=this._query.getFirstOrderByField();null!==a&&this.validateOrderByAndInequalityMatch(t.field,a)}else if(i||r){var s=null;if(i&&(s=this._query.findFilterOperator(n)),null===s&&r&&(s=this._query.findFilterOperator(e)),null!=s)throw s===t.op?new zr(Gr.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new zr(Gr.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},hd.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},hd.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new zr(Gr.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.")},hd);function hd(t,e){this._query=t,this.firestore=e}var ld=(Object.defineProperty(fd.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(fd.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(fd.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),fd.prototype.forEach=function(e,n){var r=this;ii("QuerySnapshot.forEach",arguments,1,2),oi("QuerySnapshot.forEach","function",1,e),this._snapshot.docs.forEach(function(t){e.call(n,r.convertToDocumentImpl(t))})},Object.defineProperty(fd.prototype,"query",{get:function(){return new cd(this._originalQuery,this._firestore)},enumerable:!0,configurable:!0}),fd.prototype.docChanges=function(t){t&&(mi("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),ui("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new zr(Gr.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,e,o){if(o.oldDocs.isEmpty()){var n,r=0;return o.docChanges.map(function(t){var e=new sd(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key));return Ur(t.type===sl.Added,"Invalid event type for first snapshot"),Ur(!n||o.query.docComparator(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var a=o.oldDocs;return o.docChanges.filter(function(t){return e||t.type!==sl.Metadata}).map(function(t){var e=new sd(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key)),n=-1,r=-1;return t.type!==sl.Added&&(Ur(0<=(n=a.indexOf(t.doc.key)),"Index for document not found"),a=a.delete(t.doc.key)),t.type!==sl.Removed&&(r=(a=a.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case sl.Added:return"added";case sl.Modified:case sl.Metadata:return"modified";case sl.Removed:return"removed";default:return Br("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this._firestore,e,this._snapshot),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},fd.prototype.isEqual=function(t){if(!(t instanceof fd))throw yi("isEqual","QuerySnapshot",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)},fd.prototype.convertToDocumentImpl=function(t){return new sd(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key))},fd);function fd(t,e,n){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new nd(n.hasPendingWrites,n.fromCache)}a(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(ld.prototype.docChanges,t,{get:function(){return function(){throw new zr(Gr.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(t){}});var pd,dd=(t(md,pd=cd),Object.defineProperty(md.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(md.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new td(new Gi(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(md.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),md.prototype.doc=function(t){if(ii("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=wi.newId()),oi("CollectionReference.doc","non-empty string",1,t),""===t)throw new zr(Gr.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Bi.fromString(t);return td.forPath(this._query.path.child(e),this.firestore)},md.prototype.add=function(t){ni("CollectionReference.add",arguments,1),oi("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},md);function md(t,e){var n=pd.call(this,Rc.atPath(t),e)||this;if(t.length%2!=1)throw new zr(Gr.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.canonicalString()+" has "+t.length);return n}function yd(t,e){if(void 0===e)return{merge:!1};if(mi(t,e,["merge","mergeFields"]),ui(t,"boolean","merge",e.merge),ci(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof Xf}),void 0!==e.mergeFields&&void 0!==e.merge)throw new zr(Gr.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function gd(t,e){return void 0===e?{}:(mi(t,e,["serverTimestamps"]),hi(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function vd(t,e){ai(t,"object",1,e),e&&(mi(t,e,["source"]),hi(t,0,"source",e.source,["default","server","cache"]))}function bd(t,e,n){if(e instanceof td){if(e.firestore!==n)throw new zr(Gr.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw yi(t,"DocumentReference",1,e)}var wd=Yr(Hp,"Use firebase.firestore() instead."),Td=Yr(Xp,"Use firebase.firestore().runTransaction() instead."),Sd=Yr(Zp,"Use firebase.firestore().batch() instead."),Ed=Yr(td,"Use firebase.firestore().doc() instead."),Id=Yr(id),Cd=Yr(sd),Dd=Yr(cd),Nd=Yr(ld),Ad=Yr(dd,"Use firebase.firestore().collection() instead."),kd={Firestore:wd,GeoPoint:Pl,Timestamp:co,Blob:ki,Transaction:Td,WriteBatch:Sd,DocumentReference:Ed,DocumentSnapshot:Id,Query:Dd,QueryDocumentSnapshot:Cd,QuerySnapshot:Nd,CollectionReference:Ad,FieldPath:Xf,FieldValue:Dp,setLogLevel:Hp.setLogLevel,CACHE_SIZE_UNLIMITED:Wp};function Rd(t){t.INTERNAL.registerComponent(new w("firestore",function(t){var e=t.getProvider("app").getImmediate();return new Hp(e,t.getProvider("auth-internal"))},"PUBLIC").setServiceProps(function(t){Ur(t&&"object"==typeof t,"shallowCopy() expects object parameter.");var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}(kd)))}var Md=(Ld.prototype.addCallback=function(t){},Ld.prototype.shutdown=function(){},Ld);function Ld(){}var Od="ConnectivityMonitor",_d=(Pd.prototype.addCallback=function(t){this.callbacks.push(t)},Pd.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},Pd.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},Pd.prototype.onNetworkAvailable=function(){Fr(Od,"Network connectivity changed: AVAILABLE");for(var t=0,e=this.callbacks;t","http://*/","https://*/", "identity"], diff --git a/spinner.gif b/res/spinner.gif similarity index 100% rename from spinner.gif rename to res/spinner.gif diff --git a/slotInfo.json b/slotInfo.json deleted file mode 100644 index 92dcb83..0000000 --- a/slotInfo.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "A": -} \ No newline at end of file diff --git a/background.js b/src/bg/background.js similarity index 87% rename from background.js rename to src/bg/background.js index dfee684..7ed4083 100644 --- a/background.js +++ b/src/bg/background.js @@ -14,6 +14,6 @@ function(request, sender) { if (request.action == "LaunchTimetableFile") - chrome.tabs.create({ url: chrome.runtime.getURL("table.html") }); + chrome.tabs.create({ url: chrome.runtime.getURL("/src/timetable/table.html") }); } ); \ No newline at end of file diff --git a/activateGPA.js b/src/gpa/activateGPA.js similarity index 69% rename from activateGPA.js rename to src/gpa/activateGPA.js index b08e0ae..e5af4b4 100644 --- a/activateGPA.js +++ b/src/gpa/activateGPA.js @@ -3,6 +3,8 @@ Source: https://github.com/IITH/aims-gpa-calculator */ var exclude_list = [ + 'Minor core', + 'Honors core', 'Honours project', 'Honours coursework', 'FCC', @@ -55,27 +57,43 @@ show_total_gpa = function(){ if ($(".cgpa_cal_check").length==0) add_checkboxes(); elems = $(".hierarchyLi.dataLi").not(".hierarchyHdr, .hierarchySubHdr"); + var type_credits_map = new Map(); elems.each(function(i){ if ($(this).find(".cgpa_cal_check:checked").length == 0 ) return; var course = new Object(); - course.id = $(this).children(".col1").html().trim(); + course.code = $(this).children(".col1").contents().filter(function(){ + return this.nodeType == Node.TEXT_NODE; + }).text().trim(); course.name = $(this).children(".col2").html().trim(); course.type = $(this).children(".col5").html().trim().slice(6); course.grade = $(this).children(".col8").html().trim().slice(6); - course.credits = $(this).children(".col3").html().trim().slice(6); + course.credits = Number($(this).children(".col3").html().trim().slice(6)); if (!(course.grade in grade_values)) return; + + if (type_credits_map.has(course.type)) + type_credits_map.set(course.type, type_credits_map.get(course.type) + course.credits); + else + type_credits_map.set(course.type, course.credits); + + grade_value = grade_values[course.grade]; - credits = Number(course.credits); + credits = course.credits; total_grades += credits * grade_value; total_credits += credits; courses.push(course); }); console.log(total_grades, total_credits); var gpa = (total_grades / total_credits).toFixed(2); - return {courses: courses, + return { + name: $(".stuName").text().trim(), + rollno: $(".studentInfoDiv>.flexDiv:nth-child(3)").find("span").text().trim(), + branch: $(".studentInfoDiv>.flexDiv:nth-child(5)").find("div:nth-child(1)").find("span").text().trim(), + student_type: $(".studentInfoDiv>.flexDiv:nth-child(5)").find("div:nth-child(2)").find("span").text().trim(), + type_credits_map: JSON.stringify(Array.from(type_credits_map)), + courses: JSON.stringify(courses), gpa: gpa }; } diff --git a/src/gpa/gpa_report.html b/src/gpa/gpa_report.html new file mode 100644 index 0000000..05dac6b --- /dev/null +++ b/src/gpa/gpa_report.html @@ -0,0 +1,128 @@ + + + + GPA Report + + + +
+

Details

+ + + + + + + + + + + + + + + + + + + + + +
+

Summary

+ + + + + +
CategoryCredits
+

Selected Courses

+ + + + + + + +
CodeNameCreditsGrade
+
+
+ + + + + \ No newline at end of file diff --git a/src/gpa/gpa_report.js b/src/gpa/gpa_report.js new file mode 100644 index 0000000..d9f3b52 --- /dev/null +++ b/src/gpa/gpa_report.js @@ -0,0 +1,54 @@ +var data = JSON.parse(localStorage.getItem("courseGPA")); + + + +document.getElementsByClassName("value name")[0].innerText = data.name; +document.getElementsByClassName("value cgpa")[0].innerText = data.gpa; +document.getElementsByClassName("value rollno")[0].innerText = data.rollno; +document.getElementsByClassName("value branch")[0].innerText = data.branch; +document.getElementsByClassName("value student-type")[0].innerText = data.student_type; + + +var summary_table = document.getElementsByClassName("summary")[0]; +var total_credits = 0; +//right now the code in other file is such that the excluded courses are not reaching here. +var type_credits_map = new Map(JSON.parse(data.type_credits_map)); +for(var [type, credits] of type_credits_map.entries()) { + var row = document.createElement("tr"); + console.log(type, credits); + total_credits += credits; + row.innerHTML = `${type}${credits}`; + summary_table.appendChild(row); +} +var total_row = document.createElement("tr"); +total_row.className = "total"; +total_row.innerHTML = `Total${total_credits}`; +summary_table.appendChild(total_row); +console.log(data); + + +var courses_table = document.getElementsByClassName("courses")[0]; +var courses_array = JSON.parse(data.courses); +courses_array.sort(function(a, b){ + if (a.code < b.code) + return -1; + if (a.code > b.code) + return 1; + else return 0; +}); +for (var course of courses_array) { + var row = document.createElement("tr"); + row.innerHTML = `${course.code} + ${course.name} + ${course.credits} + ${course.grade}`; + courses_table.appendChild(row); +} + + +document.addEventListener('DOMContentLoaded', function() { + document.getElementsByClassName("download-pdf")[0].addEventListener('click', function() { + var element = document.getElementsByClassName('report')[0]; + html2pdf(element); + }); +}); \ No newline at end of file diff --git a/popup.html b/src/popup/popup.html similarity index 95% rename from popup.html rename to src/popup/popup.html index 9a01e2e..a815d92 100644 --- a/popup.html +++ b/src/popup/popup.html @@ -1,7 +1,6 @@ -