/*! For license information please see main.0e1253d3.js.LICENSE.txt */ !function(){var e={637:function(e,t,n){"use strict";var r,i,o=n(388),a=n(971),l=n(826),s=n(386),u=((r={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",r["bad-app-name"]="Illegal App name: '{$appName}",r["duplicate-app"]="Firebase App named '{$appName}' already exists",r["app-deleted"]="Firebase App named '{$appName}' already deleted",r["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",r["invalid-log-argument"]="First argument to `onLog` must be null or a function.",r),c=new a.LL("app","Firebase",u),d="@firebase/app",f="[DEFAULT]",h=((i={})[d]="fire-core",i["@firebase/analytics"]="fire-analytics",i["@firebase/app-check"]="fire-app-check",i["@firebase/auth"]="fire-auth",i["@firebase/database"]="fire-rtdb",i["@firebase/functions"]="fire-fn",i["@firebase/installations"]="fire-iid",i["@firebase/messaging"]="fire-fcm",i["@firebase/performance"]="fire-perf",i["@firebase/remote-config"]="fire-rc",i["@firebase/storage"]="fire-gcs",i["@firebase/firestore"]="fire-fst",i["fire-js"]="fire-js",i["firebase-wrapper"]="fire-js-all",i),p=new s.Yd("@firebase/app"),v=function(){function e(e,t,n){var r=this;this.firebase_=n,this.isDeleted_=!1,this.name_=t.name,this.automaticDataCollectionEnabled_=t.automaticDataCollectionEnabled||!1,this.options_=(0,a.p$)(e),this.container=new l.H0(t.name),this._addComponent(new l.wA("app",(function(){return r}),"PUBLIC")),this.firebase_.INTERNAL.components.forEach((function(e){return r._addComponent(e)}))}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(e){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!1,configurable:!0}),e.prototype.delete=function(){var e=this;return new Promise((function(t){e.checkDestroyed_(),t()})).then((function(){return e.firebase_.INTERNAL.removeApp(e.name_),Promise.all(e.container.getProviders().map((function(e){return e.delete()})))})).then((function(){e.isDeleted_=!0}))},e.prototype._getService=function(e,t){var n;void 0===t&&(t=f),this.checkDestroyed_();var r=this.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==(null===(n=r.getComponent())||void 0===n?void 0:n.instantiationMode)||r.initialize(),r.getImmediate({identifier:t})},e.prototype._removeServiceInstance=function(e,t){void 0===t&&(t=f),this.container.getProvider(e).clearInstance(t)},e.prototype._addComponent=function(e){try{this.container.addComponent(e)}catch(t){p.debug("Component "+e.name+" failed to register with FirebaseApp "+this.name,t)}},e.prototype._addOrOverwriteComponent=function(e){this.container.addOrOverwriteComponent(e)},e.prototype.toJSON=function(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}},e.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw c.create("app-deleted",{appName:this.name_})},e}();v.prototype.name&&v.prototype.options||v.prototype.delete||console.log("dc");var y=function e(){var t=function(e){var t={},n=new Map,r={__esModule:!0,initializeApp:function(n,i){void 0===i&&(i={}),"object"===typeof i&&null!==i||(i={name:i});var o=i;void 0===o.name&&(o.name=f);var l=o.name;if("string"!==typeof l||!l)throw c.create("bad-app-name",{appName:String(l)});if((0,a.r3)(t,l))throw c.create("duplicate-app",{appName:l});var s=new e(n,o,r);return t[l]=s,s},app:i,registerVersion:function(e,t,n){var r,i=null!==(r=h[e])&&void 0!==r?r:e;n&&(i+="-"+n);var a=i.match(/\s|\//),s=t.match(/\s|\//);if(a||s){var u=['Unable to register library "'+i+'" with version "'+t+'":'];return a&&u.push('library name "'+i+'" contains illegal characters (whitespace or "/")'),a&&s&&u.push("and"),s&&u.push('version name "'+t+'" contains illegal characters (whitespace or "/")'),void p.warn(u.join(" "))}o(new l.wA(i+"-version",(function(){return{library:i,version:t}}),"VERSION"))},setLogLevel:s.Ub,onLog:function(e,t){if(null!==e&&"function"!==typeof e)throw c.create("invalid-log-argument");(0,s.Am)(e,t)},apps:null,SDK_VERSION:"8.10.0",INTERNAL:{registerComponent:o,removeApp:function(e){delete t[e]},components:n,useAsService:function(e,t){return"serverAuth"===t?null:t}}};function i(e){if(e=e||f,!(0,a.r3)(t,e))throw c.create("no-app",{appName:e});return t[e]}function o(o){var l=o.name;if(n.has(l))return p.debug("There were multiple attempts to register component "+l+"."),"PUBLIC"===o.type?r[l]:null;if(n.set(l,o),"PUBLIC"===o.type){var s=function(e){if(void 0===e&&(e=i()),"function"!==typeof e[l])throw c.create("invalid-app-argument",{appName:l});return e[l]()};void 0!==o.serviceProps&&(0,a.ZB)(s,o.serviceProps),r[l]=s,e.prototype[l]=function(){for(var e=[],t=0;t=0&&p.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}var _=y.initializeApp;y.initializeApp=function(){for(var e=[],t=0;tn?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r};function A(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}var M=function(e){(0,o.hu)(!T(e),"Invalid JSON number");var t,n,r,i,a,l=1023;0===e?(n=0,r=0,t=1/e===-1/0?1:0):(t=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(e)/Math.LN2),l))+l,r=Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,r=Math.round(e/Math.pow(2,-1074))));var s=[];for(a=52;a;a-=1)s.push(r%2?1:0),r=Math.floor(r/2);for(a=11;a;a-=1)s.push(n%2?1:0),n=Math.floor(n/2);s.push(t?1:0),s.reverse();var u=s.join(""),c="";for(a=0;a<64;a+=8){var d=parseInt(u.substr(a,8),2).toString(16);1===d.length&&(d="0"+d),c+=d}return c.toLowerCase()};var j=new RegExp("^-?(0*)\\d{1,10}$"),F=-2147483648,z=2147483647,q=function(e){if(j.test(e)){var t=Number(e);if(t>=F&&t<=z)return t}return null},U=function(e){try{e()}catch(t){setTimeout((function(){var e=t.stack||"";throw x("Exception was thrown by user callback.",e),t}),Math.floor(0))}},W=function(e,t){var n=setTimeout(e,t);return"object"===typeof n&&n.unref&&n.unref(),n},H=function(){function e(e,t){var n=this;this.appName_=e,this.appCheckProvider=t,this.appCheck=null===t||void 0===t?void 0:t.getImmediate({optional:!0}),this.appCheck||null===t||void 0===t||t.get().then((function(e){return n.appCheck=e}))}return e.prototype.getToken=function(e){var t=this;return this.appCheck?this.appCheck.getToken(e):new Promise((function(n,r){setTimeout((function(){t.appCheck?t.getToken(e).then(n,r):n(null)}),0)}))},e.prototype.addTokenChangeListener=function(e){var t;null===(t=this.appCheckProvider)||void 0===t||t.get().then((function(t){return t.addTokenListener(e)}))},e.prototype.notifyForInvalidToken=function(){x('Provided AppCheck credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly.')},e}(),B=function(){function e(e,t,n){var r=this;this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit((function(e){return r.auth_=e}))}return e.prototype.getToken=function(e){var t=this;return this.auth_?this.auth_.getToken(e).catch((function(e){return e&&"auth/token-not-initialized"===e.code?(k("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)})):new Promise((function(n,r){setTimeout((function(){t.auth_?t.getToken(e).then(n,r):n(null)}),0)}))},e.prototype.addTokenChangeListener=function(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then((function(t){return t.addAuthTokenListener(e)}))},e.prototype.removeTokenChangeListener=function(e){this.authProvider_.get().then((function(t){return t.removeAuthTokenListener(e)}))},e.prototype.notifyForInvalidToken=function(){var e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',x(e)},e}(),V=function(){function e(e){this.accessToken=e}return e.prototype.getToken=function(e){return Promise.resolve({accessToken:this.accessToken})},e.prototype.addTokenChangeListener=function(e){e(this.accessToken)},e.prototype.removeTokenChangeListener=function(e){},e.prototype.notifyForInvalidToken=function(){},e.OWNER="owner",e}(),Q="5",Y=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,K="websocket",$="long_polling",G=function(){function e(e,t,n,r,i,o,a){void 0===i&&(i=!1),void 0===o&&(o=""),void 0===a&&(a=!1),this.secure=t,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=h.get("host:"+e)||this._host}return e.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},e.prototype.isCustomHost=function(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain},Object.defineProperty(e.prototype,"host",{get:function(){return this._host},set:function(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&h.set("host:"+this._host,this.internalHost))},enumerable:!1,configurable:!0}),e.prototype.toString=function(){var e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e},e.prototype.toURLString=function(){var e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?"?ns="+this.namespace:"";return""+e+this.host+"/"+t},e}();function X(e,t,n){var r;if((0,o.hu)("string"===typeof t,"typeof type must == string"),(0,o.hu)("object"===typeof n,"typeof params must == object"),t===K)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==$)throw new Error("Unknown connection type: "+t);r=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}(function(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams})(e)&&(n.ns=e.namespace);var i=[];return A(n,(function(e,t){i.push(e+"="+t)})),r+i.join("&")}var Z=function(){function e(){this.counters_={}}return e.prototype.incrementCounter=function(e,t){void 0===t&&(t=1),(0,o.r3)(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t},e.prototype.get=function(){return(0,o.p$)(this.counters_)},e}(),J={},ee={};function te(e){var t=e.toString();return J[t]||(J[t]=new Z),J[t]}var ne=function(){function e(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}return e.prototype.closeAfter=function(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponsedocument.domain="'+document.domain+'";<\/script>';var l=""+a+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(l),this.myIFrame.doc.close()}catch(s){k("frame writing exception"),s.stack&&k(s.stack),k(s)}}}return e.createIFrame_=function(){var e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||k("No IE domain setting required")}catch(n){var t=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+t+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e},e.prototype.close=function(){var e=this;this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout((function(){null!==e.myIFrame&&(document.body.removeChild(e.myIFrame),e.myIFrame=null)}),Math.floor(0)));var t=this.onDisconnect;t&&(this.onDisconnect=null,t())},e.prototype.startLongPoll=function(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););},e.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;var e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;for(var t=this.urlFn(e),n="",r=0;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+n.length<=1870))break;var i=this.pendingSegs.shift();n=n+"&seg"+r+"="+i.seg+"&ts"+r+"="+i.ts+"&d"+r+"="+i.d,r++}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1},e.prototype.enqueueSegment=function(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()},e.prototype.addLongPollTag_=function(e,t){var n=this;this.outstandingRequests.add(t);var r=function(){n.outstandingRequests.delete(t),n.newRequest_()},i=setTimeout(r,Math.floor(25e3));this.addTag(e,(function(){clearTimeout(i),r()}))},e.prototype.addTag=function(e,t){var n=this;(0,o.Yr)()?this.doNodeLongPoll(e,t):setTimeout((function(){try{if(!n.sendNewPolls)return;var r=n.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=e,r.onload=r.onreadystatechange=function(){var e=r.readyState;e&&"loaded"!==e&&"complete"!==e||(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),t())},r.onerror=function(){k("Long-poll script failed to load: "+e),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(r)}catch(i){}}),Math.floor(1))},e}(),le=null;"undefined"!==typeof MozWebSocket?le=MozWebSocket:"undefined"!==typeof WebSocket&&(le=WebSocket);var se=function(){function e(t,n,r,i,o,a,l){this.connId=t,this.applicationId=r,this.appCheckToken=i,this.authToken=o,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=C(this.connId),this.stats_=te(n),this.connURL=e.connectionURL_(n,a,l,i),this.nodeAdmin=n.nodeAdmin}return e.connectionURL_=function(e,t,n,r){var i={};return i.v=Q,!(0,o.Yr)()&&"undefined"!==typeof location&&location.hostname&&Y.test(location.hostname)&&(i.r="f"),t&&(i.s=t),n&&(i.ls=n),r&&(i.ac=r),X(e,K,i)},e.prototype.open=function(e,t){var n=this;this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,h.set("previous_websocket_failure",!0);try{if((0,o.Yr)()){var r=this.nodeAdmin?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+s+"/"+process.platform+"/"+r,"X-Firebase-GMPID":this.applicationId||""}};this.authToken&&(i.headers.Authorization="Bearer "+this.authToken),this.appCheckToken&&(i.headers["X-Firebase-AppCheck"]=this.appCheckToken);var a={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0},l=0===this.connURL.indexOf("wss://")?a.HTTPS_PROXY||a.https_proxy:a.HTTP_PROXY||a.http_proxy;l&&(i.proxy={origin:l}),this.mySock=new le(this.connURL,[],i)}else{i={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}};this.mySock=new le(this.connURL,[],i)}}catch(c){this.log_("Error instantiating WebSocket.");var u=c.message||c.data;return u&&this.log_(u),void this.onClosed_()}this.mySock.onopen=function(){n.log_("Websocket connected."),n.everConnected_=!0},this.mySock.onclose=function(){n.log_("Websocket connection was disconnected."),n.mySock=null,n.onClosed_()},this.mySock.onmessage=function(e){n.handleIncomingFrame(e)},this.mySock.onerror=function(e){n.log_("WebSocket error. Closing connection.");var t=e.message||e.data;t&&n.log_(t),n.onClosed_()}},e.prototype.start=function(){},e.forceDisallow=function(){e.forceDisallow_=!0},e.isAvailable=function(){var t=!1;if("undefined"!==typeof navigator&&navigator.userAgent){var n=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);n&&n.length>1&&parseFloat(n[1])<4.4&&(t=!0)}return!t&&null!==le&&!e.forceDisallow_},e.previouslyFailed=function(){return h.isInMemoryStorage||!0===h.get("previous_websocket_failure")},e.prototype.markConnectionHealthy=function(){h.remove("previous_websocket_failure")},e.prototype.appendFrame_=function(e){if(this.frames.push(e),this.frames.length===this.totalFrames){var t=this.frames.join("");this.frames=null;var n=(0,o.cI)(t);this.onMessage(n)}},e.prototype.handleNewFrameCount_=function(e){this.totalFrames=e,this.frames=[]},e.prototype.extractFrameCount_=function(e){if((0,o.hu)(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e},e.prototype.handleIncomingFrame=function(e){if(null!==this.mySock){var t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{var n=this.extractFrameCount_(t);null!==n&&this.appendFrame_(n)}}},e.prototype.send=function(e){this.resetKeepAlive();var t=(0,o.Pz)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var n=L(t,16384);n.length>1&&this.sendString_(String(n.length));for(var r=0;r0)return this.transports_[0];throw new Error("No transports available")},e.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},e}(),ce=function(){function e(e,t,n,r,i,o,a,l,s,u){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=l,this.onKill_=s,this.lastSessionId=u,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=C("c:"+this.id+":"),this.transportManager_=new ue(t),this.log_("Connection created"),this.start_()}return e.prototype.start_=function(){var e=this,t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((function(){e.conn_&&e.conn_.open(n,r)}),Math.floor(0));var i=t.healthyTimeout||0;i>0&&(this.healthyTimeout_=W((function(){e.healthyTimeout_=null,e.isHealthy_||(e.conn_&&e.conn_.bytesReceived>102400?(e.log_("Connection exceeded healthy timeout but has received "+e.conn_.bytesReceived+" bytes. Marking connection healthy."),e.isHealthy_=!0,e.conn_.markConnectionHealthy()):e.conn_&&e.conn_.bytesSent>10240?e.log_("Connection exceeded healthy timeout but has sent "+e.conn_.bytesSent+" bytes. Leaving connection alive."):(e.log_("Closing unhealthy connection after timeout."),e.close()))}),Math.floor(i)))},e.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},e.prototype.disconnReceiver_=function(e){var t=this;return function(n){e===t.conn_?t.onConnectionLost_(n):e===t.secondaryConn_?(t.log_("Secondary connection lost."),t.onSecondaryConnectionLost_()):t.log_("closing an old connection")}},e.prototype.connReceiver_=function(e){var t=this;return function(n){2!==t.state_&&(e===t.rx_?t.onPrimaryMessageReceived_(n):e===t.secondaryConn_?t.onSecondaryMessageReceived_(n):t.log_("message on old connection"))}},e.prototype.sendRequest=function(e){var t={t:"d",d:e};this.sendData_(t)},e.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},e.prototype.onSecondaryControl_=function(e){if("t"in e){var t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},e.prototype.onSecondaryMessageReceived_=function(e){var t=R("t",e),n=R("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}},e.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))},e.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()},e.prototype.onPrimaryMessageReceived_=function(e){var t=R("t",e),n=R("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)},e.prototype.onDataMessage_=function(e){this.onPrimaryResponse_(),this.onMessage_(e)},e.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},e.prototype.onControl_=function(e){var t=R("t",e);if("d"in e){var n=e.d;if("h"===t)this.onHandshake_(n);else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var r=0;r0,"Requires a non-empty array")}return e.prototype.trigger=function(e){for(var t=[],n=1;n0&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}return e.prototype.toString=function(){for(var e="",t=this.pieceNum_;t=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function me(e){return e.pieces_.length-e.pieceNum_}function ge(e){var t=e.pieceNum_;return t=e.pieces_.length)return null;for(var t=[],n=e.pieceNum_;n0&&n.push(i[r])}return new pe(n,0)}function Ce(e){return e.pieceNum_>=e.pieces_.length}function Se(e,t){var n=ye(e),r=ye(t);if(null===n)return t;if(n===r)return Se(ge(e),ge(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Ee(e,t){for(var n=be(e,0),r=be(t,0),i=0;ime(t))return!1;for(;n768)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(e.parts_.length>32)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Ie(e))}function Ie(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}var Oe,Re,De=function(e){function t(){var t,n,r=e.call(this,["visible"])||this;return"undefined"!==typeof document&&"undefined"!==typeof document.addEventListener&&("undefined"!==typeof document.hidden?(n="visibilitychange",t="hidden"):"undefined"!==typeof document.mozHidden?(n="mozvisibilitychange",t="mozHidden"):"undefined"!==typeof document.msHidden?(n="msvisibilitychange",t="msHidden"):"undefined"!==typeof document.webkitHidden&&(n="webkitvisibilitychange",t="webkitHidden")),r.visible_=!0,n&&document.addEventListener(n,(function(){var e=!document[t];e!==r.visible_&&(r.visible_=e,r.trigger("visible",e))}),!1),r}return(0,a.ZT)(t,e),t.getInstance=function(){return new t},t.prototype.getInitialEvent=function(e){return(0,o.hu)("visible"===e,"Unknown event type: "+e),[this.visible_]},t}(fe),Le=1e3,Ae=function(e){function t(n,r,i,a,l,s,u,c){var d=e.call(this)||this;if(d.repoInfo_=n,d.applicationId_=r,d.onDataUpdate_=i,d.onConnectStatus_=a,d.onServerInfoUpdate_=l,d.authTokenProvider_=s,d.appCheckTokenProvider_=u,d.authOverride_=c,d.id=t.nextPersistentConnectionId_++,d.log_=C("p:"+d.id+":"),d.interruptReasons_={},d.listens=new Map,d.outstandingPuts_=[],d.outstandingGets_=[],d.outstandingPutCount_=0,d.outstandingGetCount_=0,d.onDisconnectRequestQueue_=[],d.connected_=!1,d.reconnectDelay_=Le,d.maxReconnectDelay_=3e5,d.securityDebugCallback_=null,d.lastSessionId=null,d.establishConnectionTimer_=null,d.visible_=!1,d.requestCBHash_={},d.requestNumber_=0,d.realtime_=null,d.authToken_=null,d.appCheckToken_=null,d.forceTokenRefresh_=!1,d.invalidAuthTokenCount_=0,d.invalidAppCheckTokenCount_=0,d.firstConnection_=!0,d.lastConnectionAttemptTime_=null,d.lastConnectionEstablishedTime_=null,c&&!(0,o.Yr)())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return De.getInstance().on("visible",d.onVisible_,d),-1===n.host.indexOf("fblocal")&&he.getInstance().on("online",d.onOnline_,d),d}return(0,a.ZT)(t,e),t.prototype.sendRequest=function(e,t,n){var r=++this.requestNumber_,i={r:r,a:e,b:t};this.log_((0,o.Pz)(i)),(0,o.hu)(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)},t.prototype.get=function(e){var t=this;this.initConnection_();var n=new o.BH,r={p:e._path.toString(),q:e._queryObject},i={action:"g",request:r,onComplete:function(e){var i=e.d;"ok"===e.s?(t.onDataUpdate_(r.p,i,!1,null),n.resolve(i)):n.reject(i)}};this.outstandingGets_.push(i),this.outstandingGetCount_++;var a=this.outstandingGets_.length-1;return this.connected_||setTimeout((function(){var e=t.outstandingGets_[a];void 0!==e&&i===e&&(delete t.outstandingGets_[a],t.outstandingGetCount_--,0===t.outstandingGetCount_&&(t.outstandingGets_=[]),t.log_("get "+a+" timed out on connection"),n.reject(new Error("Client is offline.")))}),3e3),this.connected_&&this.sendGet_(a),n.promise},t.prototype.listen=function(e,t,n,r){this.initConnection_();var i=e._queryIdentifier,a=e._path.toString();this.log_("Listen called for "+a+" "+i),this.listens.has(a)||this.listens.set(a,new Map),(0,o.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),(0,o.hu)(!this.listens.get(a).has(i),"listen() called twice for same path/queryId.");var l={onComplete:r,hashFn:t,query:e,tag:n};this.listens.get(a).set(i,l),this.connected_&&this.sendListen_(l)},t.prototype.sendGet_=function(e){var t=this,n=this.outstandingGets_[e];this.sendRequest("g",n.request,(function(r){delete t.outstandingGets_[e],t.outstandingGetCount_--,0===t.outstandingGetCount_&&(t.outstandingGets_=[]),n.onComplete&&n.onComplete(r)}))},t.prototype.sendListen_=function(e){var n=this,r=e.query,i=r._path.toString(),o=r._queryIdentifier;this.log_("Listen on "+i+" for "+o);var a={p:i};e.tag&&(a.q=r._queryObject,a.t=e.tag),a.h=e.hashFn(),this.sendRequest("q",a,(function(a){var l=a.d,s=a.s;t.warnOnListenWarnings_(l,r),(n.listens.get(i)&&n.listens.get(i).get(o))===e&&(n.log_("listen response",a),"ok"!==s&&n.removeListen_(i,o),e.onComplete&&e.onComplete(s,l))}))},t.warnOnListenWarnings_=function(e,t){if(e&&"object"===typeof e&&(0,o.r3)(e,"w")){var n=(0,o.DV)(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+t._queryParams.getIndex().toString()+'"',i=t._path.toString();x("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+r+" at "+i+" to your security rules for better performance.")}}},t.prototype.refreshAuthToken=function(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},(function(){})),this.reduceReconnectDelayIfAdminCredential_(e)},t.prototype.reduceReconnectDelayIfAdminCredential_=function(e){(e&&40===e.length||(0,o.GJ)(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},t.prototype.refreshAppCheckToken=function(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},(function(){}))},t.prototype.tryAuth=function(){var e=this;if(this.connected_&&this.authToken_){var t=this.authToken_,n=(0,o.w9)(t)?"auth":"gauth",r={cred:t};null===this.authOverride_?r.noauth=!0:"object"===typeof this.authOverride_&&(r.authvar=this.authOverride_),this.sendRequest(n,r,(function(n){var r=n.s,i=n.d||"error";e.authToken_===t&&("ok"===r?e.invalidAuthTokenCount_=0:e.onAuthRevoked_(r,i))}))}},t.prototype.tryAppCheck=function(){var e=this;this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},(function(t){var n=t.s,r=t.d||"error";"ok"===n?e.invalidAppCheckTokenCount_=0:e.onAppCheckRevoked_(n,r)}))},t.prototype.unlisten=function(e,t){var n=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+r),(0,o.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&&this.connected_&&this.sendUnlisten_(n,r,e._queryObject,t)},t.prototype.sendUnlisten_=function(e,t,n,r){this.log_("Unlisten on "+e+" for "+t);var i={p:e};r&&(i.q=n,i.t=r),this.sendRequest("n",i)},t.prototype.onDisconnectPut=function(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})},t.prototype.onDisconnectMerge=function(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})},t.prototype.onDisconnectCancel=function(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})},t.prototype.sendOnDisconnect_=function(e,t,n,r){var i={p:t,d:n};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,(function(e){r&&setTimeout((function(){r(e.s,e.d)}),Math.floor(0))}))},t.prototype.put=function(e,t,n,r){this.putInternal("p",e,t,n,r)},t.prototype.merge=function(e,t,n,r){this.putInternal("m",e,t,n,r)},t.prototype.putInternal=function(e,t,n,r,i){this.initConnection_();var o={p:t,d:n};void 0!==i&&(o.h=i),this.outstandingPuts_.push({action:e,request:o,onComplete:r}),this.outstandingPutCount_++;var a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)},t.prototype.sendPut_=function(e){var t=this,n=this.outstandingPuts_[e].action,r=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(n,r,(function(r){t.log_(n+" response",r),delete t.outstandingPuts_[e],t.outstandingPutCount_--,0===t.outstandingPutCount_&&(t.outstandingPuts_=[]),i&&i(r.s,r.d)}))},t.prototype.reportStats=function(e){var t=this;if(this.connected_){var n={c:e};this.log_("reportStats",n),this.sendRequest("s",n,(function(e){if("ok"!==e.s){var n=e.d;t.log_("reportStats","Error sending stats: "+n)}}))}},t.prototype.onDataMessage_=function(e){if("r"in e){this.log_("from server: "+(0,o.Pz)(e));var t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}},t.prototype.onDataPush_=function(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):S("Unrecognized action received from server: "+(0,o.Pz)(e)+"\nAre you using the latest client?")},t.prototype.onReady_=function(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)},t.prototype.scheduleConnect_=function(e){var t=this;(0,o.hu)(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout((function(){t.establishConnectionTimer_=null,t.establishConnection_()}),Math.floor(e))},t.prototype.initConnection_=function(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)},t.prototype.onVisible_=function(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=Le,this.realtime_||this.scheduleConnect_(0)),this.visible_=e},t.prototype.onOnline_=function(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Le,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())},t.prototype.onRealtimeDisconnect_=function(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=Le),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();var e=(new Date).getTime()-this.lastConnectionAttemptTime_,t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},t.prototype.establishConnection_=function(){return(0,a.mG)(this,void 0,void 0,(function(){var e,n,r,i,l,s,u,c,d,f,h,p,v,y,m=this;return(0,a.Jh)(this,(function(g){switch(g.label){case 0:if(!this.shouldReconnect_())return[3,4];this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null,e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),r=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+t.nextConnectionId_++,l=this.lastSessionId,s=!1,u=null,c=function(){u?u.close():(s=!0,r())},d=function(e){(0,o.hu)(u,"sendRequest call when we're not connected not allowed."),u.sendRequest(e)},this.realtime_={close:c,sendRequest:d},f=this.forceTokenRefresh_,this.forceTokenRefresh_=!1,g.label=1;case 1:return g.trys.push([1,3,,4]),[4,Promise.all([this.authTokenProvider_.getToken(f),this.appCheckTokenProvider_.getToken(f)])];case 2:return h=a.CR.apply(void 0,[g.sent(),2]),p=h[0],v=h[1],s?k("getToken() completed but was canceled"):(k("getToken() completed. Creating connection."),this.authToken_=p&&p.accessToken,this.appCheckToken_=v&&v.token,u=new ce(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,n,r,(function(e){x(e+" ("+m.repoInfo_.toString()+")"),m.interrupt("server_kill")}),l)),[3,4];case 3:return y=g.sent(),this.log_("Failed to get token: "+y),s||(this.repoInfo_.nodeAdmin&&x(y),c()),[3,4];case 4:return[2]}}))}))},t.prototype.interrupt=function(e){k("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},t.prototype.resume=function(e){k("Resuming connection for reason: "+e),delete this.interruptReasons_[e],(0,o.xb)(this.interruptReasons_)&&(this.reconnectDelay_=Le,this.realtime_||this.scheduleConnect_(0))},t.prototype.handleTimestamp_=function(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})},t.prototype.cancelSentTransactions_=function(){for(var e=0;e=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},t.prototype.onAppCheckRevoked_=function(e,t){k("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())},t.prototype.onSecurityDebugPacket_=function(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))},t.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth(),this.tryAppCheck();try{for(var i=(0,a.XA)(this.listens.values()),o=i.next();!o.done;o=i.next()){var l=o.value;try{for(var s=(n=void 0,(0,a.XA)(l.values())),u=s.next();!u.done;u=s.next()){var c=u.value;this.sendListen_(c)}}catch(h){n={error:h}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}}catch(p){e={error:p}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}for(var d=0;d0},e.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}},e}(),Ue=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:He.EMPTY_NODE,this.right=null!=o?o:He.EMPTY_NODE}return e.prototype.copy=function(t,n,r,i,o){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},e.prototype.count=function(){return this.left.count()+1+this.right.count()},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)},e.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},e.prototype.minKey=function(){return this.min_().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(e,t,n){var r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp_()},e.prototype.removeMin_=function(){if(this.left.isEmpty())return He.EMPTY_NODE;var e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),(e=e.copy(null,null,null,e.left.removeMin_(),null)).fixUp_()},e.prototype.remove=function(e,t){var n,r;if(t(e,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return He.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()},e.prototype.isRed_=function(){return this.color},e.prototype.fixUp_=function(){var e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e},e.prototype.moveRedLeft_=function(){var e=this.colorFlip_();return e.right.left.isRed_()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight_())).rotateLeft_()).colorFlip_()),e},e.prototype.moveRedRight_=function(){var e=this.colorFlip_();return e.left.left.isRed_()&&(e=(e=e.rotateRight_()).colorFlip_()),e},e.prototype.rotateLeft_=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight_=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip_=function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)},e.prototype.checkMaxDepth_=function(){var e=this.check_();return Math.pow(2,e)<=this.count()+1},e.prototype.check_=function(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");var e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)},e.RED=!0,e.BLACK=!1,e}(),We=function(){function e(){}return e.prototype.copy=function(e,t,n,r,i){return this},e.prototype.insert=function(e,t,n){return new Ue(e,t,null)},e.prototype.remove=function(e,t){return this},e.prototype.count=function(){return 0},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(e){return!1},e.prototype.reverseTraversal=function(e){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.check_=function(){return 0},e.prototype.isRed_=function(){return!1},e}(),He=function(){function e(t,n){void 0===n&&(n=e.EMPTY_NODE),this.comparator_=t,this.root_=n}return e.prototype.insert=function(t,n){return new e(this.comparator_,this.root_.insert(t,n,this.comparator_).copy(null,null,Ue.BLACK,null,null))},e.prototype.remove=function(t){return new e(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,Ue.BLACK,null,null))},e.prototype.get=function(e){for(var t,n=this.root_;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null},e.prototype.getPredecessorKey=function(e){for(var t,n=this.root_,r=null;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")},e.prototype.isEmpty=function(){return this.root_.isEmpty()},e.prototype.count=function(){return this.root_.count()},e.prototype.minKey=function(){return this.root_.minKey()},e.prototype.maxKey=function(){return this.root_.maxKey()},e.prototype.inorderTraversal=function(e){return this.root_.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.root_.reverseTraversal(e)},e.prototype.getIterator=function(e){return new qe(this.root_,null,this.comparator_,!1,e)},e.prototype.getIteratorFrom=function(e,t){return new qe(this.root_,e,this.comparator_,!1,t)},e.prototype.getReverseIteratorFrom=function(e,t){return new qe(this.root_,e,this.comparator_,!0,t)},e.prototype.getReverseIterator=function(e){return new qe(this.root_,null,this.comparator_,!0,e)},e.EMPTY_NODE=new We,e}();function Be(e,t){return I(e.name,t.name)}function Ve(e,t){return I(e,t)}var Qe,Ye,Ke,$e=function(e){return"number"===typeof e?"number:"+M(e):"string:"+e},Ge=function(e){if(e.isLeafNode()){var t=e.val();(0,o.hu)("string"===typeof t||"number"===typeof t||"object"===typeof t&&(0,o.r3)(t,".sv"),"Priority must be a string or number.")}else(0,o.hu)(e===Re||e.isEmpty(),"priority of unexpected type.");(0,o.hu)(e===Re||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},Xe=function(){function e(t,n){void 0===n&&(n=e.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=n,this.lazyHash_=null,(0,o.hu)(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Ge(this.priorityNode_)}return Object.defineProperty(e,"__childrenNodeConstructor",{get:function(){return Qe},set:function(e){Qe=e},enumerable:!1,configurable:!0}),e.prototype.isLeafNode=function(){return!0},e.prototype.getPriority=function(){return this.priorityNode_},e.prototype.updatePriority=function(t){return new e(this.value_,t)},e.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.getChild=function(t){return Ce(t)?this:".priority"===ye(t)?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.hasChild=function(){return!1},e.prototype.getPredecessorChildName=function(e,t){return null},e.prototype.updateImmediateChild=function(t,n){return".priority"===t?this.updatePriority(n):n.isEmpty()&&".priority"!==t?this:e.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,n).updatePriority(this.priorityNode_)},e.prototype.updateChild=function(t,n){var r=ye(t);return null===r?n:n.isEmpty()&&".priority"!==r?this:((0,o.hu)(".priority"!==r||1===me(t),".priority must be the last token in a path"),this.updateImmediateChild(r,e.__childrenNodeConstructor.EMPTY_NODE.updateChild(ge(t),n)))},e.prototype.isEmpty=function(){return!1},e.prototype.numChildren=function(){return 0},e.prototype.forEachChild=function(e,t){return!1},e.prototype.val=function(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},e.prototype.hash=function(){if(null===this.lazyHash_){var e="";this.priorityNode_.isEmpty()||(e+="priority:"+$e(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"===t?M(this.value_):this.value_,this.lazyHash_=m(e)}return this.lazyHash_},e.prototype.getValue=function(){return this.value_},e.prototype.compareTo=function(t){return t===e.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof e.__childrenNodeConstructor?-1:((0,o.hu)(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},e.prototype.compareToLeafNode_=function(t){var n=typeof t.value_,r=typeof this.value_,i=e.VALUE_TYPE_ORDER.indexOf(n),a=e.VALUE_TYPE_ORDER.indexOf(r);return(0,o.hu)(i>=0,"Unknown leaf type: "+n),(0,o.hu)(a>=0,"Unknown leaf type: "+r),i===a?"object"===r?0:this.value_0;)r.getNext(),i=r.peek();return r},e.prototype.compareTo=function(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===st?-1:0},e.prototype.withIndex=function(t){if(t===ze||this.indexMap_.hasIndex(t))return this;var n=this.indexMap_.addIndex(t,this.children_);return new e(this.children_,this.priorityNode_,n)},e.prototype.isIndexed=function(e){return e===ze||this.indexMap_.hasIndex(e)},e.prototype.equals=function(e){if(e===this)return!0;if(e.isLeafNode())return!1;var t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){for(var n=this.getIterator(tt),r=t.getIterator(tt),i=n.getNext(),o=r.getNext();i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=n.getNext(),o=r.getNext()}return null===i&&null===o}return!1}return!1},e.prototype.resolveIndex_=function(e){return e===ze?null:this.indexMap_.get(e.toString())},e.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,e}(),st=new(function(e){function t(){return e.call(this,new He(Ve),lt.EMPTY_NODE,at.Default)||this}return(0,a.ZT)(t,e),t.prototype.compareTo=function(e){return e===this?0:1},t.prototype.equals=function(e){return e===this},t.prototype.getPriority=function(){return this},t.prototype.getImmediateChild=function(e){return lt.EMPTY_NODE},t.prototype.isEmpty=function(){return!1},t}(lt));Object.defineProperties(Me,{MIN:{value:new Me(N,lt.EMPTY_NODE)},MAX:{value:new Me(P,st)}}),Fe.__EMPTY_NODE=lt.EMPTY_NODE,Xe.__childrenNodeConstructor=lt,Re=st,function(e){Ke=e}(st);function ut(e,t){if(void 0===t&&(t=null),null===e)return lt.EMPTY_NODE;if("object"===typeof e&&".priority"in e&&(t=e[".priority"]),(0,o.hu)(null===t||"string"===typeof t||"number"===typeof t||"object"===typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"===typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!==typeof e||".sv"in e)return new Xe(e,ut(t));if(e instanceof Array){var n=lt.EMPTY_NODE;return A(e,(function(t,r){if((0,o.r3)(e,t)&&"."!==t.substring(0,1)){var i=ut(r);!i.isLeafNode()&&i.isEmpty()||(n=n.updateImmediateChild(t,i))}})),n.updatePriority(ut(t))}var r=[],i=!1;if(A(e,(function(e,t){if("."!==e.substring(0,1)){var n=ut(t);n.isEmpty()||(i=i||!n.getPriority().isEmpty(),r.push(new Me(e,n)))}})),0===r.length)return lt.EMPTY_NODE;var a=it(r,Be,(function(e){return e.name}),Ve);if(i){var l=it(r,tt.getCompare());return new lt(a,ut(t),new at({".priority":l},{".priority":tt}))}return new lt(a,ut(t),at.Default)}!function(e){Ye=e}(ut);var ct=function(e){function t(t){var n=e.call(this)||this;return n.indexPath_=t,(0,o.hu)(!Ce(t)&&".priority"!==ye(t),"Can't create PathIndex with empty path or .priority key"),n}return(0,a.ZT)(t,e),t.prototype.extractChild=function(e){return e.getChild(this.indexPath_)},t.prototype.isDefinedOn=function(e){return!e.getChild(this.indexPath_).isEmpty()},t.prototype.compare=function(e,t){var n=this.extractChild(e.node),r=this.extractChild(t.node),i=n.compareTo(r);return 0===i?I(e.name,t.name):i},t.prototype.makePost=function(e,t){var n=ut(e),r=lt.EMPTY_NODE.updateChild(this.indexPath_,n);return new Me(t,r)},t.prototype.maxPost=function(){var e=lt.EMPTY_NODE.updateChild(this.indexPath_,st);return new Me(P,e)},t.prototype.toString=function(){return be(this.indexPath_,0).join("/")},t}(je),dt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,a.ZT)(t,e),t.prototype.compare=function(e,t){var n=e.node.compareTo(t.node);return 0===n?I(e.name,t.name):n},t.prototype.isDefinedOn=function(e){return!0},t.prototype.indexedValueChanged=function(e,t){return!e.equals(t)},t.prototype.minPost=function(){return Me.MIN},t.prototype.maxPost=function(){return Me.MAX},t.prototype.makePost=function(e,t){var n=ut(e);return new Me(t,n)},t.prototype.toString=function(){return".value"},t}(je),ft=new dt,ht="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",pt=function(){var e=0,t=[];return function(n){var r,i=n===e;e=n;var a=new Array(8);for(r=7;r>=0;r--)a[r]=ht.charAt(n%64),n=Math.floor(n/64);(0,o.hu)(0===n,"Cannot push at time == 0");var l=a.join("");if(i){for(r=11;r>=0&&63===t[r];r--)t[r]=0;t[r]++}else for(r=0;r<12;r++)t[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)l+=ht.charAt(t[r]);return(0,o.hu)(20===l.length,"nextPushId: Length should be 20."),l}}(),vt=function(e){if("2147483647"===e)return"-";var t=q(e);if(null!=t)return""+(t+1);for(var n=new Array(e.length),r=0;r=0&&"z"===n[i];)i--;if(-1===i)return P;var o=n[i],a=ht.charAt(ht.indexOf(o)+1);return n[i]=a,n.slice(0,i+1).join("")},yt=function(e){if("-2147483648"===e)return N;var t=q(e);if(null!=t)return""+(t-1);for(var n=new Array(e.length),r=0;r=0)return null!=i&&i.trackChildChange(bt(t,n,f)),s.updateImmediateChild(t,n);null!=i&&i.trackChildChange(_t(t,f));var v=s.updateImmediateChild(t,lt.EMPTY_NODE);return null!=h&&this.rangedFilter_.matches(h)?(null!=i&&i.trackChildChange(gt(h.name,h.node)),v.updateImmediateChild(h.name,h.node)):v}return n.isEmpty()?e:d&&a(c,u)>=0?(null!=i&&(i.trackChildChange(_t(c.name,c.node)),i.trackChildChange(gt(t,n))),s.updateImmediateChild(t,n).updateImmediateChild(c.name,lt.EMPTY_NODE)):e},e}(),St=function(){function e(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=tt}return e.prototype.hasStart=function(){return this.startSet_},e.prototype.hasStartAfter=function(){return this.startAfterSet_},e.prototype.hasEndBefore=function(){return this.endBeforeSet_},e.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_},e.prototype.getIndexStartValue=function(){return(0,o.hu)(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},e.prototype.getIndexStartName=function(){return(0,o.hu)(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:N},e.prototype.hasEnd=function(){return this.endSet_},e.prototype.getIndexEndValue=function(){return(0,o.hu)(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},e.prototype.getIndexEndName=function(){return(0,o.hu)(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:P},e.prototype.hasLimit=function(){return this.limitSet_},e.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},e.prototype.getLimit=function(){return(0,o.hu)(this.limitSet_,"Only valid if limit has been set"),this.limit_},e.prototype.getIndex=function(){return this.index_},e.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},e.prototype.isDefault=function(){return this.loadsAllData()&&this.index_===tt},e.prototype.copy=function(){var t=new e;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t},e}();function Et(e,t,n){var r=e.copy();return r.startSet_=!0,void 0===t&&(t=null),r.indexStartValue_=t,null!=n?(r.startNameSet_=!0,r.indexStartName_=n):(r.startNameSet_=!1,r.indexStartName_=""),r}function xt(e,t,n){var r=e.copy();return r.endSet_=!0,void 0===t&&(t=null),r.indexEndValue_=t,void 0!==n?(r.endNameSet_=!0,r.indexEndName_=n):(r.endNameSet_=!1,r.indexEndName_=""),r}function Tt(e,t){var n=e.copy();return n.index_=t,n}function Nt(e){var t,n={};return e.isDefault()||(e.index_===tt?t="$priority":e.index_===ft?t="$value":e.index_===ze?t="$key":((0,o.hu)(e.index_ instanceof ct,"Unrecognized index type!"),t=e.index_.toString()),n.orderBy=(0,o.Pz)(t),e.startSet_&&(n.startAt=(0,o.Pz)(e.indexStartValue_),e.startNameSet_&&(n.startAt+=","+(0,o.Pz)(e.indexStartName_))),e.endSet_&&(n.endAt=(0,o.Pz)(e.indexEndValue_),e.endNameSet_&&(n.endAt+=","+(0,o.Pz)(e.indexEndName_))),e.limitSet_&&(e.isViewFromLeft()?n.limitToFirst=e.limit_:n.limitToLast=e.limit_)),n}function Pt(e){var t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_)),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_)),e.limitSet_){t.l=e.limit_;var n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==tt&&(t.i=e.index_.toString()),t}var It=function(e){function t(t,n,r,i){var o=e.call(this)||this;return o.repoInfo_=t,o.onDataUpdate_=n,o.authTokenProvider_=r,o.appCheckTokenProvider_=i,o.log_=C("p:rest:"),o.listens_={},o}return(0,a.ZT)(t,e),t.prototype.reportStats=function(e){throw new Error("Method not implemented.")},t.getListenId_=function(e,t){return void 0!==t?"tag$"+t:((0,o.hu)(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())},t.prototype.listen=function(e,n,r,i){var a=this,l=e._path.toString();this.log_("Listen called for "+l+" "+e._queryIdentifier);var s=t.getListenId_(e,r),u={};this.listens_[s]=u;var c=Nt(e._queryParams);this.restRequest_(l+".json",c,(function(e,t){var n=t;(404===e&&(n=null,e=null),null===e&&a.onDataUpdate_(l,n,!1,r),(0,o.DV)(a.listens_,s)===u)&&i(e?401===e?"permission_denied":"rest_error:"+e:"ok",null)}))},t.prototype.unlisten=function(e,n){var r=t.getListenId_(e,n);delete this.listens_[r]},t.prototype.get=function(e){var t=this,n=Nt(e._queryParams),r=e._path.toString(),i=new o.BH;return this.restRequest_(r+".json",n,(function(e,n){var o=n;404===e&&(o=null,e=null),null===e?(t.onDataUpdate_(r,o,!1,null),i.resolve(o)):i.reject(new Error(o))})),i.promise},t.prototype.refreshAuthToken=function(e){},t.prototype.restRequest_=function(e,t,n){var r=this;return void 0===t&&(t={}),t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then((function(i){var l=(0,a.CR)(i,2),s=l[0],u=l[1];s&&s.accessToken&&(t.auth=s.accessToken),u&&u.token&&(t.ac=u.token);var c=(r.repoInfo_.secure?"https://":"http://")+r.repoInfo_.host+e+"?ns="+r.repoInfo_.namespace+(0,o.xO)(t);r.log_("Sending REST request for "+c);var d=new XMLHttpRequest;d.onreadystatechange=function(){if(n&&4===d.readyState){r.log_("REST Response for "+c+" received. status:",d.status,"response:",d.responseText);var e=null;if(d.status>=200&&d.status<300){try{e=(0,o.cI)(d.responseText)}catch(t){x("Failed to parse JSON response for "+c+": "+d.responseText)}n(null,e)}else 401!==d.status&&404!==d.status&&x("Got unsuccessful REST response for "+c+" Status: "+d.status),n(d.status);n=null}},d.open("GET",c,!0),d.send()}))},t}(de),Ot=function(){function e(){this.rootNode_=lt.EMPTY_NODE}return e.prototype.getNode=function(e){return this.rootNode_.getChild(e)},e.prototype.updateSnapshot=function(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)},e}();function Rt(){return{value:null,children:new Map}}function Dt(e,t,n){if(Ce(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{var r=ye(t);e.children.has(r)||e.children.set(r,Rt()),Dt(e.children.get(r),t=ge(t),n)}}function Lt(e,t){if(Ce(t))return e.value=null,e.children.clear(),!0;if(null!==e.value){if(e.value.isLeafNode())return!1;var n=e.value;return e.value=null,n.forEachChild(tt,(function(t,n){Dt(e,new pe(t),n)})),Lt(e,t)}if(e.children.size>0){var r=ye(t);if(t=ge(t),e.children.has(r))Lt(e.children.get(r),t)&&e.children.delete(r);return 0===e.children.size}return!0}function At(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach((function(e,n){t(n,e)}))}(e,(function(e,r){At(r,new pe(t.toString()+"/"+e),n)}))}var Mt,jt=function(){function e(e){this.collection_=e,this.last_=null}return e.prototype.get=function(){var e=this.collection_.get(),t=(0,a.pi)({},e);return this.last_&&A(this.last_,(function(e,n){t[e]=t[e]-n})),this.last_=e,t},e}(),Ft=function(){function e(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new jt(e);var n=1e4+2e4*Math.random();W(this.reportStats_.bind(this),Math.floor(n))}return e.prototype.reportStats_=function(){var e=this,t=this.statsListener_.get(),n={},r=!1;A(t,(function(t,i){i>0&&(0,o.r3)(e.statsToReport_,t)&&(n[t]=i,r=!0)})),r&&this.server_.reportStats(n),W(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},e}();function zt(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Mt||(Mt={}));var qt,Ut=function(){function e(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=Mt.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}return e.prototype.operationForChild=function(t){if(Ce(this.path)){if(null!=this.affectedTree.value)return(0,o.hu)(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new pe(t));return new e(ve(),n,this.revert)}return(0,o.hu)(ye(this.path)===t,"operationForChild called for unrelated child."),new e(ge(this.path),this.affectedTree,this.revert)},e}(),Wt=function(){function e(e,t){this.source=e,this.path=t,this.type=Mt.LISTEN_COMPLETE}return e.prototype.operationForChild=function(t){return Ce(this.path)?new e(this.source,ve()):new e(this.source,ge(this.path))},e}(),Ht=function(){function e(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=Mt.OVERWRITE}return e.prototype.operationForChild=function(t){return Ce(this.path)?new e(this.source,ve(),this.snap.getImmediateChild(t)):new e(this.source,ge(this.path),this.snap)},e}(),Bt=function(){function e(e,t,n){this.source=e,this.path=t,this.children=n,this.type=Mt.MERGE}return e.prototype.operationForChild=function(t){if(Ce(this.path)){var n=this.children.subtree(new pe(t));return n.isEmpty()?null:n.value?new Ht(this.source,ve(),n.value):new e(this.source,ve(),n)}return(0,o.hu)(ye(this.path)===t,"Can't get a merge for a child not on the path of the operation"),new e(this.source,ge(this.path),this.children)},e.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},e}(),Vt=function(){function e(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}return e.prototype.isFullyInitialized=function(){return this.fullyInitialized_},e.prototype.isFiltered=function(){return this.filtered_},e.prototype.isCompleteForPath=function(e){if(Ce(e))return this.isFullyInitialized()&&!this.filtered_;var t=ye(e);return this.isCompleteForChild(t)},e.prototype.isCompleteForChild=function(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)},e.prototype.getNode=function(){return this.node_},e}(),Qt=function(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()};function Yt(e,t,n,r,i,a){var l=r.filter((function(e){return e.type===n}));l.sort((function(t,n){return function(e,t,n){if(null==t.childName||null==n.childName)throw(0,o.g5)("Should only compare child_ events.");var r=new Me(t.childName,t.snapshotNode),i=new Me(n.childName,n.snapshotNode);return e.index_.compare(r,i)}(e,t,n)})),l.forEach((function(n){var r=function(e,t,n){return"value"===t.type||"child_removed"===t.type||(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_)),t}(e,n,a);i.forEach((function(i){i.respondsTo(n.type)&&t.push(i.createEvent(r,e.query_))}))}))}function Kt(e,t){return{eventCache:e,serverCache:t}}function $t(e,t,n,r){return Kt(new Vt(t,n,r),e.serverCache)}function Gt(e,t,n,r){return Kt(e.eventCache,new Vt(t,n,r))}function Xt(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function Zt(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}var Jt=function(){function e(e,t){void 0===t&&(qt||(qt=new He(O)),t=qt),this.value=e,this.children=t}return e.fromObject=function(t){var n=new e(null);return A(t,(function(e,t){n=n.set(new pe(e),t)})),n},e.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},e.prototype.findRootMostMatchingPathAndValue=function(e,t){if(null!=this.value&&t(this.value))return{path:ve(),value:this.value};if(Ce(e))return null;var n=ye(e),r=this.children.get(n);if(null!==r){var i=r.findRootMostMatchingPathAndValue(ge(e),t);return null!=i?{path:ke(new pe(n),i.path),value:i.value}:null}return null},e.prototype.findRootMostValueAndPath=function(e){return this.findRootMostMatchingPathAndValue(e,(function(){return!0}))},e.prototype.subtree=function(t){if(Ce(t))return this;var n=ye(t),r=this.children.get(n);return null!==r?r.subtree(ge(t)):new e(null)},e.prototype.set=function(t,n){if(Ce(t))return new e(n,this.children);var r=ye(t),i=(this.children.get(r)||new e(null)).set(ge(t),n),o=this.children.insert(r,i);return new e(this.value,o)},e.prototype.remove=function(t){if(Ce(t))return this.children.isEmpty()?new e(null):new e(null,this.children);var n=ye(t),r=this.children.get(n);if(r){var i=r.remove(ge(t)),o=void 0;return o=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&o.isEmpty()?new e(null):new e(this.value,o)}return this},e.prototype.get=function(e){if(Ce(e))return this.value;var t=ye(e),n=this.children.get(t);return n?n.get(ge(e)):null},e.prototype.setTree=function(t,n){if(Ce(t))return n;var r=ye(t),i=(this.children.get(r)||new e(null)).setTree(ge(t),n),o=void 0;return o=i.isEmpty()?this.children.remove(r):this.children.insert(r,i),new e(this.value,o)},e.prototype.fold=function(e){return this.fold_(ve(),e)},e.prototype.fold_=function(e,t){var n={};return this.children.inorderTraversal((function(r,i){n[r]=i.fold_(ke(e,r),t)})),t(e,this.value,n)},e.prototype.findOnPath=function(e,t){return this.findOnPath_(e,ve(),t)},e.prototype.findOnPath_=function(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(Ce(e))return null;var i=ye(e),o=this.children.get(i);return o?o.findOnPath_(ge(e),ke(t,i),n):null},e.prototype.foreachOnPath=function(e,t){return this.foreachOnPath_(e,ve(),t)},e.prototype.foreachOnPath_=function(t,n,r){if(Ce(t))return this;this.value&&r(n,this.value);var i=ye(t),o=this.children.get(i);return o?o.foreachOnPath_(ge(t),ke(n,i),r):new e(null)},e.prototype.foreach=function(e){this.foreach_(ve(),e)},e.prototype.foreach_=function(e,t){this.children.inorderTraversal((function(n,r){r.foreach_(ke(e,n),t)})),this.value&&t(e,this.value)},e.prototype.foreachChild=function(e){this.children.inorderTraversal((function(t,n){n.value&&e(t,n.value)}))},e}(),en=function(){function e(e){this.writeTree_=e}return e.empty=function(){return new e(new Jt(null))},e}();function tn(e,t,n){if(Ce(t))return new en(new Jt(n));var r=e.writeTree_.findRootMostValueAndPath(t);if(null!=r){var i=r.path,o=r.value,a=Se(i,t);return o=o.updateChild(a,n),new en(e.writeTree_.set(i,o))}var l=new Jt(n),s=e.writeTree_.setTree(t,l);return new en(s)}function nn(e,t,n){var r=e;return A(n,(function(e,n){r=tn(r,ke(t,e),n)})),r}function rn(e,t){if(Ce(t))return en.empty();var n=e.writeTree_.setTree(t,new Jt(null));return new en(n)}function on(e,t){return null!=an(e,t)}function an(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Se(n.path,t)):null}function ln(e){var t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(tt,(function(e,n){t.push(new Me(e,n))})):e.writeTree_.children.inorderTraversal((function(e,n){null!=n.value&&t.push(new Me(e,n.value))})),t}function sn(e,t){if(Ce(t))return e;var n=an(e,t);return new en(null!=n?new Jt(n):e.writeTree_.subtree(t))}function un(e){return e.writeTree_.isEmpty()}function cn(e,t){return dn(ve(),e.writeTree_,t)}function dn(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);var r=null;return t.children.inorderTraversal((function(t,i){".priority"===t?((0,o.hu)(null!==i.value,"Priority writes must always be leaf nodes"),r=i.value):n=dn(ke(e,t),i,n)})),n.getChild(e).isEmpty()||null===r||(n=n.updateChild(ke(e,".priority"),r)),n}function fn(e,t){return En(t,e)}function hn(e,t){var n=e.allWrites.findIndex((function(e){return e.writeId===t}));(0,o.hu)(n>=0,"removeWrite called with nonexistent writeId.");var r=e.allWrites[n];e.allWrites.splice(n,1);for(var i=r.visible,a=!1,l=e.allWrites.length-1;i&&l>=0;){var s=e.allWrites[l];s.visible&&(l>=n&&pn(s,r.path)?i=!1:Te(r.path,s.path)&&(a=!0)),l--}if(i){if(a)return function(e){e.visibleWrites=yn(e.allWrites,vn,ve()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0;r.snap?e.visibleWrites=rn(e.visibleWrites,r.path):A(r.children,(function(t){e.visibleWrites=rn(e.visibleWrites,ke(r.path,t))}));return!0}return!1}function pn(e,t){if(e.snap)return Te(e.path,t);for(var n in e.children)if(e.children.hasOwnProperty(n)&&Te(ke(e.path,n),t))return!0;return!1}function vn(e){return e.visible}function yn(e,t,n){for(var r=en.empty(),i=0;i0||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&n.push(mt(Xt(t)))}}(t,a,f),{viewCache:a,changes:f}}function In(e,t,n,r,i,a){var l=t.eventCache;if(null!=wn(r,n))return t;var s=void 0,u=void 0;if(Ce(n))if((0,o.hu)(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){var c=Zt(t),d=_n(r,c instanceof lt?c:lt.EMPTY_NODE);s=e.filter.updateFullNode(t.eventCache.getNode(),d,a)}else{var f=gn(r,Zt(t));s=e.filter.updateFullNode(t.eventCache.getNode(),f,a)}else{var h=ye(n);if(".priority"===h){(0,o.hu)(1===me(n),"Can't have a priority with additional path components");var p=l.getNode(),v=bn(r,n,p,u=t.serverCache.getNode());s=null!=v?e.filter.updatePriority(p,v):l.getNode()}else{var y=ge(n),m=void 0;if(l.isCompleteForChild(h)){u=t.serverCache.getNode();var g=bn(r,n,l.getNode(),u);m=null!=g?l.getNode().getImmediateChild(h).updateChild(y,g):l.getNode().getImmediateChild(h)}else m=Cn(r,h,t.serverCache);s=null!=m?e.filter.updateChild(l.getNode(),h,m,y,i,a):l.getNode()}}return $t(t,s,l.isFullyInitialized()||Ce(n),e.filter.filtersNodes())}function On(e,t,n,r,i,o,a,l){var s,u=t.serverCache,c=a?e.filter:e.filter.getIndexedFilter();if(Ce(n))s=c.updateFullNode(u.getNode(),r,null);else if(c.filtersNodes()&&!u.isFiltered()){var d=u.getNode().updateChild(n,r);s=c.updateFullNode(u.getNode(),d,null)}else{var f=ye(n);if(!u.isCompleteForPath(n)&&me(n)>1)return t;var h=ge(n),p=u.getNode().getImmediateChild(f).updateChild(h,r);s=".priority"===f?c.updatePriority(u.getNode(),p):c.updateChild(u.getNode(),f,p,h,Tn,null)}var v=Gt(t,s,u.isFullyInitialized()||Ce(n),c.filtersNodes());return In(e,v,n,i,new Nn(i,v,o),l)}function Rn(e,t,n,r,i,o,a){var l,s,u=t.eventCache,c=new Nn(i,t,o);if(Ce(n))s=e.filter.updateFullNode(t.eventCache.getNode(),r,a),l=$t(t,s,!0,e.filter.filtersNodes());else{var d=ye(n);if(".priority"===d)s=e.filter.updatePriority(t.eventCache.getNode(),r),l=$t(t,s,u.isFullyInitialized(),u.isFiltered());else{var f=ge(n),h=u.getNode().getImmediateChild(d),p=void 0;if(Ce(f))p=r;else{var v=c.getCompleteChild(d);p=null!=v?".priority"===_e(f)&&v.getChild(we(f)).isEmpty()?v:v.updateChild(f,r):lt.EMPTY_NODE}if(h.equals(p))l=t;else l=$t(t,e.filter.updateChild(u.getNode(),d,p,f,c,a),u.isFullyInitialized(),e.filter.filtersNodes())}}return l}function Dn(e,t){return e.eventCache.isCompleteForChild(t)}function Ln(e,t,n){return n.foreach((function(e,n){t=t.updateChild(e,n)})),t}function An(e,t,n,r,i,o,a,l){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;var s,u=t;s=Ce(n)?r:new Jt(null).setTree(n,r);var c=t.serverCache.getNode();return s.children.inorderTraversal((function(n,r){if(c.hasChild(n)){var s=Ln(0,t.serverCache.getNode().getImmediateChild(n),r);u=On(e,u,new pe(n),s,i,o,a,l)}})),s.children.inorderTraversal((function(n,r){var s=!t.serverCache.isCompleteForChild(n)&&void 0===r.value;if(!c.hasChild(n)&&!s){var d=Ln(0,t.serverCache.getNode().getImmediateChild(n),r);u=On(e,u,new pe(n),d,i,o,a,l)}})),u}var Mn,jn=function(){function e(e,t){this.query_=e,this.eventRegistrations_=[];var n,r=this.query_._queryParams,i=new wt(r.getIndex()),o=(n=r).loadsAllData()?new wt(n.getIndex()):n.hasLimit()?new Ct(n):new kt(n);this.processor_=function(e){return{filter:e}}(o);var a=t.serverCache,l=t.eventCache,s=i.updateFullNode(lt.EMPTY_NODE,a.getNode(),null),u=o.updateFullNode(lt.EMPTY_NODE,l.getNode(),null),c=new Vt(s,a.isFullyInitialized(),i.filtersNodes()),d=new Vt(u,l.isFullyInitialized(),o.filtersNodes());this.viewCache_=Kt(d,c),this.eventGenerator_=new Qt(this.query_)}return Object.defineProperty(e.prototype,"query",{get:function(){return this.query_},enumerable:!1,configurable:!0}),e}();function Fn(e,t){var n=Zt(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!Ce(t)&&!n.getImmediateChild(ye(t)).isEmpty())?n.getChild(t):null}function zn(e){return 0===e.eventRegistrations_.length}function qn(e,t,n){var r=[];if(n){(0,o.hu)(null==t,"A cancel should cancel all event registrations.");var i=e.query._path;e.eventRegistrations_.forEach((function(e){var t=e.createCancelEvent(n,i);t&&r.push(t)}))}if(t){for(var a=[],l=0;le.lastWriteId,"Stacking an older write on top of newer ones"),void 0===i&&(i=!0),e.allWrites.push({path:t,snap:n,writeId:r,visible:i}),i&&(e.visibleWrites=tn(e.visibleWrites,t,n)),e.lastWriteId=r}(e.pendingWriteTree_,t,n,r,i),i?dr(e,new Ht({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function ir(e,t,n,r){!function(e,t,n,r){(0,o.hu)(r>e.lastWriteId,"Stacking an older merge on top of newer ones"),e.allWrites.push({path:t,children:n,writeId:r,visible:!0}),e.visibleWrites=nn(e.visibleWrites,t,n),e.lastWriteId=r}(e.pendingWriteTree_,t,n,r);var i=Jt.fromObject(n);return dr(e,new Bt({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,i))}function or(e,t,n){void 0===n&&(n=!1);var r=function(e,t){for(var n=0;n0&&!r)if(u){e.listenProvider_.stopListening(br(t),null)}else s.forEach((function(t){var n=e.queryToTagMap.get(yr(t));e.listenProvider_.stopListening(br(t),n)}));!function(e,t){for(var n=0;n0}function Lr(e,t){A(e.node.children,(function(n,r){t(new Pr(n,e,r))}))}function Ar(e,t,n,r){n&&!r&&t(e),Lr(e,(function(e){Ar(e,t,!0,r)})),n&&r&&t(e)}function Mr(e){return new pe(null===e.parent?e.name:Mr(e.parent)+"/"+e.name)}function jr(e){null!==e.parent&&function(e,t,n){var r=function(e){return void 0===Or(e)&&!Dr(e)}(n),i=(0,o.r3)(e.node.children,t);r&&i?(delete e.node.children[t],e.node.childCount--,jr(e)):r||i||(e.node.children[t]=n.node,e.node.childCount++,jr(e))}(e.parent,e.name,e)}var Fr=/[\[\].#$\/\u0000-\u001F\u007F]/,zr=/[\[\].#$\u0000-\u001F\u007F]/,qr=10485760,Ur=function(e){return"string"===typeof e&&0!==e.length&&!Fr.test(e)},Wr=function(e){return"string"===typeof e&&0!==e.length&&!zr.test(e)},Hr=function(e){return null===e||"string"===typeof e||"number"===typeof e&&!T(e)||e&&"object"===typeof e&&(0,o.r3)(e,".sv")},Br=function(e,t,n,r){r&&void 0===t||Vr((0,o.gK)(e,"value"),t,n)},Vr=function e(t,n,r){var i=r instanceof pe?new Ne(r,t):r;if(void 0===n)throw new Error(t+"contains undefined "+Ie(i));if("function"===typeof n)throw new Error(t+"contains a function "+Ie(i)+" with contents = "+n.toString());if(T(n))throw new Error(t+"contains "+n.toString()+" "+Ie(i));if("string"===typeof n&&n.length>qr/3&&(0,o.ug)(n)>qr)throw new Error(t+"contains a string greater than "+"10485760 utf8 bytes "+Ie(i)+" ('"+n.substring(0,50)+"...')");if(n&&"object"===typeof n){var a=!1,l=!1;if(A(n,(function(n,r){if(".value"===n)a=!0;else if(".priority"!==n&&".sv"!==n&&(l=!0,!Ur(n)))throw new Error(t+" contains an invalid key ("+n+") "+Ie(i)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=(0,o.ug)(t),Pe(e)}(i,n),e(t,r,i),function(e){var t=e.parts_.pop();e.byteLength_-=(0,o.ug)(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)})),a&&l)throw new Error(t+' contains ".value" child '+Ie(i)+" in addition to actual children.")}},Qr=function(e,t,n,r){if(!r||void 0!==t){var i=(0,o.gK)(e,"values");if(!t||"object"!==typeof t||Array.isArray(t))throw new Error(i+" must be an object containing the children to replace.");var a=[];A(t,(function(e,t){var r=new pe(e);if(Vr(i,t,ke(n,r)),".priority"===_e(r)&&!Hr(t))throw new Error(i+"contains an invalid value for '"+r.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");a.push(r)})),function(e,t){var n,r;for(n=0;n=0)e.server_=new It(e.repoInfo_,(function(t,n,r,i){di(e,t,n,r,i)}),e.authTokenProvider_,e.appCheckProvider_),setTimeout((function(){return fi(e,!0)}),0);else{if("undefined"!==typeof n&&null!==n){if("object"!==typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{(0,o.Pz)(n)}catch(r){throw new Error("Invalid authOverride provided: "+r)}}e.persistentConnection_=new Ae(e.repoInfo_,t,(function(t,n,r,i){di(e,t,n,r,i)}),(function(t){fi(e,t)}),(function(t){!function(e,t){A(t,(function(t,n){hi(e,t,n)}))}(e,t)}),e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener((function(t){e.server_.refreshAuthToken(t)})),e.appCheckProvider_.addTokenChangeListener((function(t){e.server_.refreshAppCheckToken(t.token)})),e.statsReporter_=function(e,t){var n=e.toString();return ee[n]||(ee[n]=t()),ee[n]}(e.repoInfo_,(function(){return new Ft(e.stats_,e.server_)})),e.infoData_=new Ot,e.infoSyncTree_=new nr({startListening:function(t,n,r,i){var o=[],a=e.infoData_.getNode(t._path);return a.isEmpty()||(o=ar(e.infoSyncTree_,t._path,a),setTimeout((function(){i("ok")}),0)),o},stopListening:function(){}}),hi(e,"connected",!1),e.serverSyncTree_=new nr({startListening:function(t,n,r,i){return e.server_.listen(t,r,n,(function(n,r){var o=i(n,r);ri(e.eventQueue_,t._path,o)})),[]},stopListening:function(t,n){e.server_.unlisten(t,n)}})}function ui(e){var t=e.infoData_.getNode(new pe(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function ci(e){return(t=(t={timestamp:ui(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function di(e,t,n,r,i){e.dataUpdateCount++;var a=new pe(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;var l=[];if(i)if(r){var s=(0,o.UI)(n,(function(e){return ut(e)}));l=function(e,t,n,r){var i=mr(e,r);if(i){var o=gr(i),a=o.path,l=o.queryId,s=Se(a,t),u=Jt.fromObject(n);return _r(e,a,new Bt(zt(l),s,u))}return[]}(e.serverSyncTree_,a,s,i)}else{var u=ut(n);l=function(e,t,n,r){var i=mr(e,r);if(null!=i){var o=gr(i),a=o.path,l=o.queryId,s=Se(a,t);return _r(e,a,new Ht(zt(l),s,n))}return[]}(e.serverSyncTree_,a,u,i)}else if(r){var c=(0,o.UI)(n,(function(e){return ut(e)}));l=function(e,t,n){var r=Jt.fromObject(n);return dr(e,new Bt({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,r))}(e.serverSyncTree_,a,c)}else{var d=ut(n);l=ar(e.serverSyncTree_,a,d)}var f=a;l.length>0&&(f=Si(e,a)),ri(e.eventQueue_,f,l)}function fi(e,t){hi(e,"connected",t),!1===t&&function(e){bi(e,"onDisconnectEvents");var t=ci(e),n=Rt();At(e.onDisconnect_,ve(),(function(r,i){var o=xr(r,i,e.serverSyncTree_,t);Dt(n,r,o)}));var r=[];At(n,ve(),(function(t,n){r=r.concat(ar(e.serverSyncTree_,t,n));var i=Pi(e,t);Si(e,i)})),e.onDisconnect_=Rt(),ri(e.eventQueue_,ve(),r)}(e)}function hi(e,t,n){var r=new pe("/.info/"+t),i=ut(n);e.infoData_.updateSnapshot(r,i);var o=ar(e.infoSyncTree_,r,i);ri(e.eventQueue_,r,o)}function pi(e){return e.nextWriteId_++}function vi(e,t,n,r,i){bi(e,"set",{path:t.toString(),value:n,priority:r});var o=ci(e),a=ut(n,r),l=ur(e.serverSyncTree_,t),s=Tr(a,l,o),u=pi(e),c=rr(e.serverSyncTree_,t,s,u,!0);ti(e.eventQueue_,c),e.server_.put(t.toString(),a.val(!0),(function(n,r){var o="ok"===n;o||x("set at "+t+" failed: "+n);var a=or(e.serverSyncTree_,u,!o);ri(e.eventQueue_,t,a),wi(e,i,n,r)}));var d=Pi(e,t);Si(e,d),ri(e.eventQueue_,d,[])}function yi(e,t,n){e.server_.onDisconnectCancel(t.toString(),(function(r,i){"ok"===r&&Lt(e.onDisconnect_,t),wi(e,n,r,i)}))}function mi(e,t,n,r){var i=ut(n);e.server_.onDisconnectPut(t.toString(),i.val(!0),(function(n,o){"ok"===n&&Dt(e.onDisconnect_,t,i),wi(e,r,n,o)}))}function gi(e,t,n){var r;r=".info"===ye(t._path)?lr(e.infoSyncTree_,t,n):lr(e.serverSyncTree_,t,n),ni(e.eventQueue_,t._path,r)}function _i(e){e.persistentConnection_&&e.persistentConnection_.interrupt(ai)}function bi(e){for(var t=[],n=1;n0,"Sending zero length transaction queue"),n.every((function(e){return 0===e.status}))&&function(e,t,n){for(var r=n.map((function(e){return e.currentWriteId})),i=ki(e,t,r),a=i,l=i.hash(),s=0;s=25)f=!0,s="maxretry",i=i.concat(or(e.serverSyncTree_,c.currentWriteId,!0));else{var h=ki(e,c.path,a);c.currentInputSnapshot=h;var p=t[l].update(h.val());if(void 0!==p){Vr("transaction failed: Data returned ",p,c.path);var v=ut(p);"object"===typeof p&&null!=p&&(0,o.r3)(p,".priority")||(v=v.updatePriority(h.getPriority()));var y=c.currentWriteId,m=ci(e),g=Tr(v,h,m);c.currentOutputSnapshotRaw=v,c.currentOutputSnapshotResolved=g,c.currentWriteId=pi(e),a.splice(a.indexOf(y),1),i=(i=i.concat(rr(e.serverSyncTree_,c.path,g,c.currentWriteId,c.applyLocally))).concat(or(e.serverSyncTree_,y,!0))}else f=!0,s="nodata",i=i.concat(or(e.serverSyncTree_,c.currentWriteId,!0))}ri(e.eventQueue_,n,i),i=[],f&&(t[l].status=2,u=t[l].unwatcher,setTimeout(u,Math.floor(0)),t[l].onComplete&&("nodata"===s?r.push((function(){return t[l].onComplete(null,!1,t[l].currentInputSnapshot)})):r.push((function(){return t[l].onComplete(new Error(s),!1,null)}))))},s=0;s0?n:void 0)}Lr(t,(function(t){Ni(e,t)}))}function Pi(e,t){var n=Mr(Ei(e,t)),r=Ir(e.transactionQueueTree_,t);return function(e,t,n){for(var r=n?e:e.parent;null!==r;){if(t(r))return!0;r=r.parent}}(r,(function(t){Ii(e,t)})),Ii(e,r),Ar(r,(function(t){Ii(e,t)})),n}function Ii(e,t){var n=Or(t);if(n){for(var r=[],i=[],a=-1,l=0;l.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||E("Cannot parse Firebase url. Please use https://.firebaseio.com"),n.secure||"undefined"!==typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&x("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new G(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new pe(n.pathString)}},Ri=function(e){var t="",n="",r="",i="",o="",l=!0,s="https",u=443;if("string"===typeof e){var c=e.indexOf("//");c>=0&&(s=e.substring(0,c-1),e=e.substring(c+2));var d=e.indexOf("/");-1===d&&(d=e.length);var f=e.indexOf("?");-1===f&&(f=e.length),t=e.substring(0,Math.min(d,f)),d0){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(o){}t+="/"+i}return t}(e.substring(d,f)));var h=function(e){var t,n,r={};"?"===e.charAt(0)&&(e=e.substring(1));try{for(var i=(0,a.XA)(e.split("&")),o=i.next();!o.done;o=i.next()){var l=o.value;if(0!==l.length){var s=l.split("=");2===s.length?r[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):x("Invalid query segment '"+l+"' in query '"+e+"'")}}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(e.substring(Math.min(e.length,f)));(c=t.indexOf(":"))>=0?(l="https"===s||"wss"===s,u=parseInt(t.substring(c+1),10)):c=t.length;var p=t.slice(0,c);if("localhost"===p.toLowerCase())n="localhost";else if(p.split(".").length<=2)n=p;else{var v=t.indexOf(".");r=t.substring(0,v).toLowerCase(),n=t.substring(v+1),o=r}"ns"in h&&(o=h.ns)}return{host:t,port:u,domain:n,subdomain:r,secure:l,scheme:s,pathString:i,namespace:o}},Di=function(){function e(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}return e.prototype.getPath=function(){var e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path},e.prototype.getEventType=function(){return this.eventType},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+(0,o.Pz)(this.snapshot.exportVal())},e}(),Li=function(){function e(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}return e.prototype.getPath=function(){return this.path},e.prototype.getEventType=function(){return"cancel"},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.path.toString()+":cancel"},e}(),Ai=function(){function e(e,t){this.snapshotCallback=e,this.cancelCallback=t}return e.prototype.onValue=function(e,t){this.snapshotCallback.call(null,e,t)},e.prototype.onCancel=function(e){return(0,o.hu)(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)},Object.defineProperty(e.prototype,"hasCancelCallback",{get:function(){return!!this.cancelCallback},enumerable:!1,configurable:!0}),e.prototype.matches=function(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context},e}(),Mi=function(){function e(e,t){this._repo=e,this._path=t}return e.prototype.cancel=function(){var e=new o.BH;return yi(this._repo,this._path,e.wrapCallback((function(){}))),e.promise},e.prototype.remove=function(){Xr("OnDisconnect.remove",this._path);var e=new o.BH;return mi(this._repo,this._path,null,e.wrapCallback((function(){}))),e.promise},e.prototype.set=function(e){Xr("OnDisconnect.set",this._path),Br("OnDisconnect.set",e,this._path,!1);var t=new o.BH;return mi(this._repo,this._path,e,t.wrapCallback((function(){}))),t.promise},e.prototype.setWithPriority=function(e,t){Xr("OnDisconnect.setWithPriority",this._path),Br("OnDisconnect.setWithPriority",e,this._path,!1),Yr("OnDisconnect.setWithPriority",t,!1);var n=new o.BH;return function(e,t,n,r,i){var o=ut(n,r);e.server_.onDisconnectPut(t.toString(),o.val(!0),(function(n,r){"ok"===n&&Dt(e.onDisconnect_,t,o),wi(0,i,n,r)}))}(this._repo,this._path,e,t,n.wrapCallback((function(){}))),n.promise},e.prototype.update=function(e){Xr("OnDisconnect.update",this._path),Qr("OnDisconnect.update",e,this._path,!1);var t=new o.BH;return function(e,t,n,r){if((0,o.xb)(n))return k("onDisconnect().update() called with empty data. Don't do anything."),void wi(0,r,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,(function(i,o){"ok"===i&&A(n,(function(n,r){var i=ut(r);Dt(e.onDisconnect_,ke(t,n),i)})),wi(0,r,i,o)}))}(this._repo,this._path,e,t.wrapCallback((function(){}))),t.promise},e}(),ji=function(){function e(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}return Object.defineProperty(e.prototype,"key",{get:function(){return Ce(this._path)?null:_e(this._path)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ref",{get:function(){return new Ui(this._repo,this._path)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_queryIdentifier",{get:function(){var e=Pt(this._queryParams),t=D(e);return"{}"===t?"default":t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_queryObject",{get:function(){return Pt(this._queryParams)},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){if(!((t=(0,o.m9)(t))instanceof e))return!1;var n=this._repo===t._repo,r=xe(this._path,t._path),i=this._queryIdentifier===t._queryIdentifier;return n&&r&&i},e.prototype.toJSON=function(){return this.toString()},e.prototype.toString=function(){return this._repo.toString()+function(e){for(var t="",n=e.pieceNum_;n0?Si(e,t):t;ri(e.eventQueue_,s,a),wi(0,r,n,i)})),A(n,(function(n){var r=Pi(e,ke(t,n));Si(e,r)})),ri(e.eventQueue_,t,[])}}(e._repo,e._path,t,n.wrapCallback((function(){}))),n.promise}function Zi(e){return function(e,t){var n=cr(e.serverSyncTree_,t);return null!=n?Promise.resolve(n):e.server_.get(t).then((function(n){var r=ut(n).withIndex(t._queryParams.getIndex()),i=ar(e.serverSyncTree_,t._path,r);return ni(e.eventQueue_,t._path,i),Promise.resolve(r)}),(function(n){return bi(e,"get for query "+(0,o.Pz)(t)+" failed: "+n),Promise.reject(new Error(n))}))}((e=(0,o.m9)(e))._repo,e).then((function(t){return new Wi(t,new Ui(e._repo,e._path),e._queryParams.getIndex())}))}var Ji=function(){function e(e){this.callbackContext=e}return e.prototype.respondsTo=function(e){return"value"===e},e.prototype.createEvent=function(e,t){var n=t._queryParams.getIndex();return new Di("value",this,new Wi(e.snapshotNode,new Ui(t._repo,t._path),n))},e.prototype.getEventRunner=function(e){var t=this;return"cancel"===e.getEventType()?function(){return t.callbackContext.onCancel(e.error)}:function(){return t.callbackContext.onValue(e.snapshot,null)}},e.prototype.createCancelEvent=function(e,t){return this.callbackContext.hasCancelCallback?new Li(this,e,t):null},e.prototype.matches=function(t){return t instanceof e&&(!t.callbackContext||!this.callbackContext||t.callbackContext.matches(this.callbackContext))},e.prototype.hasAnyCallback=function(){return null!==this.callbackContext},e}(),eo=function(){function e(e,t){this.eventType=e,this.callbackContext=t}return e.prototype.respondsTo=function(e){var t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t},e.prototype.createCancelEvent=function(e,t){return this.callbackContext.hasCancelCallback?new Li(this,e,t):null},e.prototype.createEvent=function(e,t){(0,o.hu)(null!=e.childName,"Child events should have a childName.");var n=Vi(new Ui(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new Di(e.type,this,new Wi(e.snapshotNode,n,r),e.prevName)},e.prototype.getEventRunner=function(e){var t=this;return"cancel"===e.getEventType()?function(){return t.callbackContext.onCancel(e.error)}:function(){return t.callbackContext.onValue(e.snapshot,e.prevName)}},e.prototype.matches=function(t){return t instanceof e&&(this.eventType===t.eventType&&(!this.callbackContext||!t.callbackContext||this.callbackContext.matches(t.callbackContext)))},e.prototype.hasAnyCallback=function(){return!!this.callbackContext},e}();function to(e,t,n,r,i){var o;if("object"===typeof r&&(o=void 0,i=r),"function"===typeof r&&(o=r),i&&i.onlyOnce){var a=n,l=function(t,n){gi(e._repo,e,u),a(t,n)};l.userCallback=n.userCallback,l.context=n.context,n=l}var s=new Ai(n,o||void 0),u="value"===t?new Ji(s):new eo(t,s);return function(e,t,n){var r;r=".info"===ye(t._path)?sr(e.infoSyncTree_,t,n):sr(e.serverSyncTree_,t,n),ni(e.eventQueue_,t._path,r)}(e._repo,e,u),function(){return gi(e._repo,e,u)}}function no(e,t,n,r){return to(e,"value",t,n,r)}function ro(e,t,n,r){return to(e,"child_added",t,n,r)}function io(e,t,n,r){return to(e,"child_changed",t,n,r)}function oo(e,t,n,r){return to(e,"child_moved",t,n,r)}function ao(e,t,n,r){return to(e,"child_removed",t,n,r)}function lo(e,t,n){var r=null,i=n?new Ai(n):null;"value"===t?r=new Ji(i):t&&(r=new eo(t,i)),gi(e._repo,e,r)}var so=function(){},uo=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Br("endAt",this._value,e._path,!0);var t=xt(e._queryParams,this._value,this._key);if(qi(t),zi(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new ji(e._repo,e._path,t,e._orderByCalled)},t}(so);function co(e,t){return $r("endAt","key",t,!0),new uo(e,t)}var fo=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Br("endBefore",this._value,e._path,!1);var t=function(e,t,n){var r;return e.index_===ze?("string"===typeof t&&(t=yt(t)),r=xt(e,t,n)):r=xt(e,t,null==n?N:yt(n)),r.endBeforeSet_=!0,r}(e._queryParams,this._value,this._key);if(qi(t),zi(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new ji(e._repo,e._path,t,e._orderByCalled)},t}(so);function ho(e,t){return $r("endBefore","key",t,!0),new fo(e,t)}var po=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Br("startAt",this._value,e._path,!0);var t=Et(e._queryParams,this._value,this._key);if(qi(t),zi(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new ji(e._repo,e._path,t,e._orderByCalled)},t}(so);function vo(e,t){return void 0===e&&(e=null),$r("startAt","key",t,!0),new po(e,t)}var yo=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Br("startAfter",this._value,e._path,!1);var t=function(e,t,n){var r;e.index_===ze?("string"===typeof t&&(t=vt(t)),r=Et(e,t,n)):r=Et(e,t,null==n?P:vt(n));return r.startAfterSet_=!0,r}(e._queryParams,this._value,this._key);if(qi(t),zi(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new ji(e._repo,e._path,t,e._orderByCalled)},t}(so);function mo(e,t){return $r("startAfter","key",t,!0),new yo(e,t)}var go=function(e){function t(t){var n=e.call(this)||this;return n._limit=t,n}return(0,a.ZT)(t,e),t.prototype._apply=function(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new ji(e._repo,e._path,function(e,t){var n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}(e._queryParams,this._limit),e._orderByCalled)},t}(so);function _o(e){if("number"!==typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new go(e)}var bo=function(e){function t(t){var n=e.call(this)||this;return n._limit=t,n}return(0,a.ZT)(t,e),t.prototype._apply=function(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new ji(e._repo,e._path,function(e,t){var n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}(e._queryParams,this._limit),e._orderByCalled)},t}(so);function wo(e){if("number"!==typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new bo(e)}var ko=function(e){function t(t){var n=e.call(this)||this;return n._path=t,n}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Fi(e,"orderByChild");var t=new pe(this._path);if(Ce(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");var n=new ct(t),r=Tt(e._queryParams,n);return zi(r),new ji(e._repo,e._path,r,!0)},t}(so);function Co(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return Gr("orderByChild","path",e,!1),new ko(e)}var So=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Fi(e,"orderByKey");var t=Tt(e._queryParams,ze);return zi(t),new ji(e._repo,e._path,t,!0)},t}(so);function Eo(){return new So}var xo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Fi(e,"orderByPriority");var t=Tt(e._queryParams,tt);return zi(t),new ji(e._repo,e._path,t,!0)},t}(so);function To(){return new xo}var No=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,a.ZT)(t,e),t.prototype._apply=function(e){Fi(e,"orderByValue");var t=Tt(e._queryParams,ft);return zi(t),new ji(e._repo,e._path,t,!0)},t}(so);function Po(){return new No}var Io=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,a.ZT)(t,e),t.prototype._apply=function(e){if(Br("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new uo(this._value,this._key)._apply(new po(this._value,this._key)._apply(e))},t}(so);function Oo(e,t){return $r("equalTo","key",t,!0),new Io(e,t)}function Ro(e){for(var t,n,r=[],i=1;i=(null!==r&&void 0!==r?r:t.logLevel)&&e({level:o[n].toLowerCase(),message:l,args:i,type:t.name})}},r=0,i=a;r>6|192,t[n++]=63&i|128):55296===(64512&i)&&r+1>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},c={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"===typeof atob,encodeByteArray:function(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i>2,d=(3&o)<<4|l>>4,f=(15&l)<<2|u>>6,h=63&u;s||(h=64,a||(f=64)),r.push(n[c],n[d],n[f],n[h])}return r.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(u(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],n=0,r=0;n191&&i<224){var o=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&o)}else if(i>239&&i<365){var a=((7&i)<<18|(63&(o=e[n++]))<<12|(63&(l=e[n++]))<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(a>>10)),t[r++]=String.fromCharCode(56320+(1023&a))}else{o=e[n++];var l=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&l)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4;if(r.push(u),64!==l){var c=a<<4&240|l>>2;if(r.push(c),64!==s){var d=l<<6&192|s;r.push(d)}}}return r},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)}}},d=function(e){var t=u(e);return c.encodeByteArray(t,!0)},f=function(e){return d(e).replace(/\./g,"")},h=function(e){try{return c.decodeString(e,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function p(e){return v(void 0,e)}function v(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 n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=v(e[n],t[n]));return e}var y=function(){function e(){var e=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))}return e.prototype.wrapCallback=function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"===typeof e&&(t.promise.catch((function(){})),1===e.length?e(n):e(n,r))}},e}();function m(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var n=t||"demo-project",i=e.iat||0,o=e.sub||e.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");var a=(0,r.pi)({iss:"https://securetoken.google.com/"+n,aud:n,iat:i,exp:i+3600,auth_time:i,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}}},e);return[f(JSON.stringify({alg:"none",type:"JWT"})),f(JSON.stringify(a)),""].join(".")}function g(){return"undefined"!==typeof navigator&&"string"===typeof navigator.userAgent?navigator.userAgent:""}function _(){return"undefined"!==typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(g())}function b(){try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function w(){return"object"===typeof self&&self.self===self}function k(){return"object"===typeof navigator&&"ReactNative"===navigator.product}function C(){return!0===i||!0===o}var S=function(e){function t(n,r,i){var o=e.call(this,r)||this;return o.code=n,o.customData=i,o.name="FirebaseError",Object.setPrototypeOf(o,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(o,E.prototype.create),o}return(0,r.ZT)(t,e),t}(Error),E=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n}return e.prototype.create=function(e){for(var t=[],n=1;n"}))}var T=/\{\$([^}]+)}/g;function N(e){return JSON.parse(e)}function P(e){return JSON.stringify(e)}var I=function(e){var t={},n={},r={},i="";try{var o=e.split(".");t=N(h(o[0])||""),n=N(h(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(a){}return{header:t,claims:n,data:r,signature:i}},O=function(e){var t=I(e).claims;return!!t&&"object"===typeof t&&t.hasOwnProperty("iat")},R=function(e){var t=I(e).claims;return"object"===typeof t&&!0===t.admin};function D(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function A(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function M(e,t,n){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r}function j(e){for(var t=[],n=function(e,n){Array.isArray(n)?n.forEach((function(n){t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))})):t.push(encodeURIComponent(e)+"="+encodeURIComponent(n))},r=0,i=Object.entries(e);r>>31)}var o,a,l=this.chain_[0],s=this.chain_[1],u=this.chain_[2],c=this.chain_[3],d=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(o=c^s&(u^c),a=1518500249):(o=s^u^c,a=1859775393):r<60?(o=s&u|c&(s|u),a=2400959708):(o=s^u^c,a=3395469782);i=(l<<5|l>>>27)+o+d+a+n[r]&4294967295;d=c,c=u,u=4294967295&(s<<30|s>>>2),s=l,l=i}this.chain_[0]=this.chain_[0]+l&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+d&4294967295},e.prototype.update=function(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r=56;n--)this.buf_[n]=255&t,t/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)e[r]=this.chain_[n]>>i&255,++r;return e},e}();function z(e,t){var n=new q(e,t);return n.subscribe.bind(n)}var q=function(){function e(e,t){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then((function(){e(n)})).catch((function(e){n.error(e)}))}return e.prototype.next=function(e){this.forEachObserver((function(t){t.next(e)}))},e.prototype.error=function(e){this.forEachObserver((function(t){t.error(e)})),this.close(e)},e.prototype.complete=function(){this.forEachObserver((function(e){e.complete()})),this.close()},e.prototype.subscribe=function(e,t,n){var r,i=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!==typeof e||null===e)return!1;for(var n=0,r=t;nn&&(i=0===n?"none":"no more than "+n),i)throw new Error(e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")};function H(e,t){return e+" failed: "+t+" argument "}function B(e,t,n,r){if((!r||n)&&"function"!==typeof n)throw new Error(H(e,t)+"must be a valid function.")}function V(e,t,n,r){if((!r||n)&&("object"!==typeof n||null===n))throw new Error(H(e,t)+"must be a valid context object.")}var Q=function(e){for(var t=[],n=0,r=0;r=55296&&i<=56319){var o=i-55296;r++,l(r>6|192,t[n++]=63&i|128):i<65536?(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},Y=function(e){for(var t=0,n=0;n=55296&&r<=56319?(t+=4,n++):t+=3}return t};function K(e){return e&&e._delegate?e._delegate:e}},945:function(e){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="dist/",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]&&arguments[0]&&(p=!0),p)return h=(0,d.default)(h,v),(0,c.default)(h,v.once),h},m=function(){h=(0,f.default)(),y()},g=function(){h.forEach((function(e,t){e.node.removeAttribute("data-aos"),e.node.removeAttribute("data-aos-easing"),e.node.removeAttribute("data-aos-duration"),e.node.removeAttribute("data-aos-delay")}))},_=function(e){return!0===e||"mobile"===e&&u.default.mobile()||"phone"===e&&u.default.phone()||"tablet"===e&&u.default.tablet()||"function"==typeof e&&!0===e()},b=function(e){v=i(v,e),h=(0,f.default)();var t=document.all&&!window.atob;return _(v.disable)||t?g():(v.disableMutationObserver||s.default.isSupported()||(console.info('\n aos: MutationObserver is not supported on this browser,\n code mutations observing has been disabled.\n You may have to call "refreshHard()" by yourself.\n '),v.disableMutationObserver=!0),document.querySelector("body").setAttribute("data-aos-easing",v.easing),document.querySelector("body").setAttribute("data-aos-duration",v.duration),document.querySelector("body").setAttribute("data-aos-delay",v.delay),"DOMContentLoaded"===v.startEvent&&["complete","interactive"].indexOf(document.readyState)>-1?y(!0):"load"===v.startEvent?window.addEventListener(v.startEvent,(function(){y(!0)})):document.addEventListener(v.startEvent,(function(){y(!0)})),window.addEventListener("resize",(0,l.default)(y,v.debounceDelay,!0)),window.addEventListener("orientationchange",(0,l.default)(y,v.debounceDelay,!0)),window.addEventListener("scroll",(0,a.default)((function(){(0,c.default)(h,v.once)}),v.throttleDelay)),v.disableMutationObserver||s.default.ready("[data-aos]",m),h)};e.exports={init:b,refresh:y,refreshHard:m}},function(e,t){},,,,,function(e,t){(function(t){"use strict";function n(e,t,n){function r(t){var n=v,r=y;return v=y=void 0,S=t,g=e.apply(r,n)}function o(e){return S=e,_=setTimeout(c,t),E?r(e):g}function a(e){var n=t-(e-b);return x?k(n,m-(e-S)):n}function s(e){var n=e-b;return void 0===b||n>=t||n<0||x&&e-S>=m}function c(){var e=C();return s(e)?d(e):void(_=setTimeout(c,a(e)))}function d(e){return _=void 0,T&&v?r(e):(v=y=void 0,g)}function f(){void 0!==_&&clearTimeout(_),S=0,v=b=y=_=void 0}function h(){return void 0===_?g:d(C())}function p(){var e=C(),n=s(e);if(v=arguments,y=this,b=e,n){if(void 0===_)return o(b);if(x)return _=setTimeout(c,t),r(b)}return void 0===_&&(_=setTimeout(c,t)),g}var v,y,m,g,_,b,S=0,E=!1,x=!1,T=!0;if("function"!=typeof e)throw new TypeError(u);return t=l(t)||0,i(n)&&(E=!!n.leading,m=(x="maxWait"in n)?w(l(n.maxWait)||0,t):m,T="trailing"in n?!!n.trailing:T),p.cancel=f,p.flush=h,p}function r(e,t,r){var o=!0,a=!0;if("function"!=typeof e)throw new TypeError(u);return i(r)&&(o="leading"in r?!!r.leading:o,a="trailing"in r?!!r.trailing:a),n(e,t,{leading:o,maxWait:t,trailing:a})}function i(e){var t="undefined"==typeof e?"undefined":s(e);return!!e&&("object"==t||"function"==t)}function o(e){return!!e&&"object"==("undefined"==typeof e?"undefined":s(e))}function a(e){return"symbol"==("undefined"==typeof e?"undefined":s(e))||o(e)&&b.call(e)==d}function l(e){if("number"==typeof e)return e;if(a(e))return c;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(f,"");var n=p.test(e);return n||v.test(e)?y(e.slice(2),n?2:8):h.test(e)?c:+e}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u="Expected a function",c=NaN,d="[object Symbol]",f=/^\s+|\s+$/g,h=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,v=/^0o[0-7]+$/i,y=parseInt,m="object"==("undefined"==typeof t?"undefined":s(t))&&t&&t.Object===Object&&t,g="object"==("undefined"==typeof self?"undefined":s(self))&&self&&self.Object===Object&&self,_=m||g||Function("return this")(),b=Object.prototype.toString,w=Math.max,k=Math.min,C=function(){return _.Date.now()};e.exports=r}).call(t,function(){return this}())},function(e,t){(function(t){"use strict";function n(e,t,n){function i(t){var n=v,r=y;return v=y=void 0,S=t,g=e.apply(r,n)}function o(e){return S=e,_=setTimeout(c,t),E?i(e):g}function l(e){var n=t-(e-C);return x?w(n,m-(e-S)):n}function u(e){var n=e-C;return void 0===C||n>=t||n<0||x&&e-S>=m}function c(){var e=k();return u(e)?d(e):void(_=setTimeout(c,l(e)))}function d(e){return _=void 0,T&&v?i(e):(v=y=void 0,g)}function f(){void 0!==_&&clearTimeout(_),S=0,v=C=y=_=void 0}function h(){return void 0===_?g:d(k())}function p(){var e=k(),n=u(e);if(v=arguments,y=this,C=e,n){if(void 0===_)return o(C);if(x)return _=setTimeout(c,t),i(C)}return void 0===_&&(_=setTimeout(c,t)),g}var v,y,m,g,_,C,S=0,E=!1,x=!1,T=!0;if("function"!=typeof e)throw new TypeError(s);return t=a(t)||0,r(n)&&(E=!!n.leading,m=(x="maxWait"in n)?b(a(n.maxWait)||0,t):m,T="trailing"in n?!!n.trailing:T),p.cancel=f,p.flush=h,p}function r(e){var t="undefined"==typeof e?"undefined":l(e);return!!e&&("object"==t||"function"==t)}function i(e){return!!e&&"object"==("undefined"==typeof e?"undefined":l(e))}function o(e){return"symbol"==("undefined"==typeof e?"undefined":l(e))||i(e)&&_.call(e)==c}function a(e){if("number"==typeof e)return e;if(o(e))return u;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(d,"");var n=h.test(e);return n||p.test(e)?v(e.slice(2),n?2:8):f.test(e)?u:+e}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s="Expected a function",u=NaN,c="[object Symbol]",d=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,p=/^0o[0-7]+$/i,v=parseInt,y="object"==("undefined"==typeof t?"undefined":l(t))&&t&&t.Object===Object&&t,m="object"==("undefined"==typeof self?"undefined":l(self))&&self&&self.Object===Object&&self,g=y||m||Function("return this")(),_=Object.prototype.toString,b=Math.max,w=Math.min,k=function(){return g.Date.now()};e.exports=n}).call(t,function(){return this}())},function(e,t){"use strict";function n(e){var t=void 0,r=void 0;for(t=0;te.position?e.node.classList.add("aos-animate"):"undefined"!=typeof r&&("false"===r||!n&&"true"!==r)&&e.node.classList.remove("aos-animate")},r=function(e,t){var r=window.pageYOffset,i=window.innerHeight;e.forEach((function(e,o){n(e,i+r,t)}))};t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(12)),o=function(e,t){return e.forEach((function(e,n){e.node.classList.add("aos-init"),e.position=(0,i.default)(e.node,t.offset)})),e};t.default=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(13)),o=function(e,t){var n=0,r=0,o=window.innerHeight,a={offset:e.getAttribute("data-aos-offset"),anchor:e.getAttribute("data-aos-anchor"),anchorPlacement:e.getAttribute("data-aos-anchor-placement")};switch(a.offset&&!isNaN(a.offset)&&(r=parseInt(a.offset)),a.anchor&&document.querySelectorAll(a.anchor)&&(e=document.querySelectorAll(a.anchor)[0]),n=(0,i.default)(e).top,a.anchorPlacement){case"top-bottom":break;case"center-bottom":n+=e.offsetHeight/2;break;case"bottom-bottom":n+=e.offsetHeight;break;case"top-center":n+=o/2;break;case"bottom-center":n+=o/2+e.offsetHeight;break;case"center-center":n+=o/2+e.offsetHeight/2;break;case"top-top":n+=o;break;case"bottom-top":n+=e.offsetHeight+o;break;case"center-top":n+=e.offsetHeight/2+o}return a.anchorPlacement||a.offset||isNaN(t)||(r=t),n+r};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){for(var t=0,n=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft-("BODY"!=e.tagName?e.scrollLeft:0),n+=e.offsetTop-("BODY"!=e.tagName?e.scrollTop:0),e=e.offsetParent;return{top:n,left:t}};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return e=e||document.querySelectorAll("[data-aos]"),Array.prototype.map.call(e,(function(e){return{node:e}}))};t.default=n}])},725:function(e){"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(i){return!1}}()?Object.assign:function(e,o){for(var a,l,s=i(e),u=1;u