!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).firebase)}(this,function(Zi){"use strict";try{(function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(Zi),r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return(l=Object.assign||function(t){for(var e,n=1,r=arguments.length;ns[0]&&e[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||0>6|192:(55296==(64512&i)&&r+1>18|240,e[n++]=i>>12&63|128):e[n++]=i>>12|224,e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}function h(t){try{return p.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var u={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},y=function(t,e){if(!t)throw c(e)},c=function(t){return new Error("Firebase Database ("+u.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},p={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(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i>2,o=(3&o)<<4|a>>4,a=(15&a)<<2|l>>6,l=63&l;h||(l=64,s||(a=64)),r.push(n[u],n[o],n[a],n[l])}return r.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(a(t),e)},decodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,r=0;n>10)),e[r++]=String.fromCharCode(56320+(1023&i))):(o=t[n++],s=t[n++],e[r++]=String.fromCharCode((15&a)<<12|(63&o)<<6|63&s))}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray:function(t,e){this.init_();for(var n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i>4;r.push(o),64!==a&&(s=s<<4&240|a>>2,r.push(s),64!==h&&(h=a<<6&192|h,r.push(h)))}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};function d(t){return function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:var r=n;return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var i in n)n.hasOwnProperty(i)&&"__proto__"!==i&&(e[i]=t(e[i],n[i]));return e}(void 0,t)}var g=(v.prototype.wrapCallback=function(n){var r=this;return function(t,e){t?r.reject(t):r.resolve(e),"function"==typeof n&&(r.promise.catch(function(){}),1===n.length?n(t):n(t,e))}},v);function v(){var n=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}function m(){return"undefined"!=typeof window&&(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")}function C(){return!0===u.NODE_ADMIN}var E,w="FirebaseError",b=(n(S,E=Error),S);function S(t,e,n){e=E.call(this,e)||this;return e.code=t,e.customData=n,e.name=w,Object.setPrototypeOf(e,S.prototype),Error.captureStackTrace&&Error.captureStackTrace(e,T.prototype.create),e}var T=(I.prototype.create=function(t){for(var e=[],n=1;n"})):"Error",t=this.serviceName+": "+t+" ("+o+").";return new b(o,t,i)},I);function I(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var N=/\{\$([^}]+)}/g;function R(t){return JSON.parse(t)}function P(t){return JSON.stringify(t)}function D(t){var e={},n={},r={},i="";try{var o=t.split("."),e=R(h(o[0])||""),n=R(h(o[1])||""),i=o[2],r=n.d||{};delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function k(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function A(t,e,n){var r,i={};for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=e.call(n,t[r],r,t));return i}var F=(L.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},L.prototype.compress_=function(t,e){e=e||0;var n=this.W_;if("string"==typeof t)for(var r=0;r<16;r++)n[r]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(r=0;r<16;r++)n[r]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(r=16;r<80;r++){var i=n[r-3]^n[r-8]^n[r-14]^n[r-16];n[r]=4294967295&(i<<1|i>>>31)}for(var o,s,a=this.chain_[0],h=this.chain_[1],l=this.chain_[2],u=this.chain_[3],c=this.chain_[4],r=0;r<80;r++){s=r<40?r<20?(o=u^h&(l^u),1518500249):(o=h^l^u,1859775393):r<60?(o=h&l|u&(h|l),2400959708):(o=h^l^u,3395469782);i=(a<<5|a>>>27)+o+c+s+n[r]&4294967295,c=u,u=l,l=4294967295&(h<<30|h>>>2),h=a,a=i}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+h&4294967295,this.chain_[2]=this.chain_[2]+l&4294967295,this.chain_[3]=this.chain_[3]+u&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295},L.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r>i&255,++r;return t},L);function L(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t 4. Need to update it?")}t+=" failed: ";return t+=r+" argument "}function q(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(W(t,e,r)+"must be a valid function.")}function Q(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(W(t,e,r)+"must be a valid context object.")}function U(t){for(var e=0,n=0;n>6|192:(o<65536?e[n++]=o>>12|224:(e[n++]=o>>18|240,e[n++]=o>>12&63|128),e[n++]=o>>6&63|128),e[n++]=63&o|128)}return e}(t);return(t=new F).update(e),t=t.digest(),p.encodeByteArray(t)}function ht(t,e){y(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(Ct.logLevel=V.VERBOSE,bt=Ct.log.bind(Ct),e&&mt.set("logging_enabled",!0)):"function"==typeof t?bt=t:(bt=null,mt.remove("logging_enabled"))}function lt(){for(var t=[],e=0;e=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(t/Math.pow(2,-1074))));for(var o=[],s=52;s;--s)o.push(r%2?1:0),r=Math.floor(r/2);for(s=11;s;--s)o.push(n%2?1:0),n=Math.floor(n/2);o.push(e?1:0),o.reverse();var a=o.join(""),h="";for(s=0;s<64;s+=8){var l=parseInt(a.substr(s,8),2).toString(16);1===l.length&&(l="0"+l),h+=l}return h.toLowerCase()}function kt(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw ct("Exception was thrown by user callback.",t),e},Math.floor(0))}}function At(t,e){return"object"==typeof(e=setTimeout(t,e))&&e.unref&&e.unref(),e}var Ft=new RegExp("^-?(0*)\\d{1,10}$"),Lt=function(t){if(Ft.test(t)){t=Number(t);if(-2147483648<=t&&t<=2147483647)return t}return null},Mt=(Object.defineProperty(Wt,"Empty",{get:function(){return new Wt("")},enumerable:!1,configurable:!0}),Wt.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},Wt.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},Wt.prototype.popFront=function(){var t=this.pieceNum_;return t=this.pieces_.length)return null;for(var t=[],e=this.pieceNum_;e=this.pieces_.length},Wt.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return Wt.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},Wt.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;it.getLength())return!1;for(;eQt.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+Qt.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>Qt.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Qt.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},Qt.prototype.toErrorString=function(){return 0===this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},Qt);function Qt(t,e){this.errorPrefix_=e,this.parts_=t.slice(),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n"),t},Bt.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},Bt);function Bt(t,e,n,r,i,o,s){void 0===i&&(i=!1),void 0===o&&(o=""),void 0===s&&(s=!1),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=s,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=vt.get("host:"+t)||this.host}function zt(t,e){var n=ie(t),r=n.namespace;return"firebase.com"===n.domain&&ut(n.host+" is no longer supported. Please use .firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||ut("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:")&&ct("Insecure Firebase access from a secure page. Please use https in calls to new Firebase()."),t="ws"===n.scheme||"wss"===n.scheme,{repoInfo:new jt(n.host,n.secure,r,e,t,"",r!==n.subdomain),path:new Mt(n.pathString)}}function Kt(t){return"string"==typeof t&&0!==t.length&&!oe.test(t)}function Yt(t){return"string"==typeof t&&0!==t.length&&!se.test(t)}function Gt(t){return null===t||"string"==typeof t||"number"==typeof t&&!pt(t)||t&&"object"==typeof t&&O(t,".sv")}function Xt(t,e,n,r,i){i&&void 0===n||he(W(t,e,i),n,r)}function $t(t,e,n,r,i){if(!i||void 0!==n){var o=W(t,e,i);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var s=[];Ot(n,function(t,e){t=new Mt(t);if(he(o,e,r.child(t)),".priority"===t.getBack()&&!Gt(e))throw new Error(o+"contains an invalid value for '"+t.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(t)}),function(t,e){for(var n,r=0;rae/3&&U(t)>ae)throw new Error(n+"contains a string greater than "+ae+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(Ot(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!Kt(t)))throw new Error(n+" contains an invalid key ("+t+") "+r.toErrorString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(t),he(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},le=(ue.prototype.cancel=function(t){M("OnDisconnect.cancel",0,1,arguments.length),q("OnDisconnect.cancel",1,t,!0);var e=new g;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},ue.prototype.remove=function(t){M("OnDisconnect.remove",0,1,arguments.length),ne("OnDisconnect.remove",this.path_),q("OnDisconnect.remove",1,t,!0);var e=new g;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},ue.prototype.set=function(t,e){M("OnDisconnect.set",1,2,arguments.length),ne("OnDisconnect.set",this.path_),Xt("OnDisconnect.set",1,t,this.path_,!1),q("OnDisconnect.set",2,e,!0);var n=new g;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},ue.prototype.setWithPriority=function(t,e,n){M("OnDisconnect.setWithPriority",2,3,arguments.length),ne("OnDisconnect.setWithPriority",this.path_),Xt("OnDisconnect.setWithPriority",1,t,this.path_,!1),Jt("OnDisconnect.setWithPriority",2,e,!1),q("OnDisconnect.setWithPriority",3,n,!0);var r=new g;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},ue.prototype.update=function(t,e){if(M("OnDisconnect.update",1,2,arguments.length),ne("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;rthis.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),this.allWrites_.push({path:t,snap:e,writeId:n,visible:r}),r&&(this.visibleWrites_=this.visibleWrites_.addWrite(t,e)),this.lastWriteId_=n},Ir.prototype.addMerge=function(t,e,n){y(n>this.lastWriteId_,"Stacking an older merge on top of newer ones"),this.allWrites_.push({path:t,children:e,writeId:n,visible:!0}),this.visibleWrites_=this.visibleWrites_.addWrites(t,e),this.lastWriteId_=n},Ir.prototype.getWrite=function(t){for(var e=0;edocument.domain="'+document.domain+'";<\/script>');var i=""+e+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(t){Tt("frame writing exception"),t.stack&&Tt(t.stack),Tt(t)}}var si="";function ai(t){si=t}var hi=null;"undefined"!=typeof MozWebSocket?hi=MozWebSocket:"undefined"!=typeof WebSocket&&(hi=WebSocket);var li=(ui.connectionURL_=function(t,e,n){var r={v:"5"};return"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(Ut)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL(Vt,r)},ui.prototype.open=function(e,t){var n,r=this;this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,vt.set("previous_websocket_failure",!0);try{C()||(n={headers:{"X-Firebase-GMPID":this.applicationId||""}},this.mySock=new hi(this.connURL,[],n))}catch(t){this.log_("Error instantiating WebSocket.");e=t.message||t.data;return e&&this.log_(e),void this.onClosed_()}this.mySock.onopen=function(){r.log_("Websocket connected."),r.everConnected_=!0},this.mySock.onclose=function(){r.log_("Websocket connection was disconnected."),r.mySock=null,r.onClosed_()},this.mySock.onmessage=function(t){r.handleIncomingFrame(t)},this.mySock.onerror=function(t){r.log_("WebSocket error. Closing connection.");t=t.message||t.data;t&&r.log_(t),r.onClosed_()}},ui.prototype.start=function(){},ui.forceDisallow=function(){ui.forceDisallow_=!0},ui.isAvailable=function(){var t,e=!1;return"undefined"!=typeof navigator&&navigator.userAgent&&((t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/))&&1=Ti.MAX_TRANSACTION_RETRIES_?(c=!0,p="maxretry",r.concat(this.serverSyncTree_.ackUserWrite(l.currentWriteId,!0))):(s=this.getLatestState_(l.path,i),l.currentInputSnapshot=s,void 0!==(h=t[o].update(s.val()))?(he("transaction failed: Data returned ",h,l.path),a=hn(h),"object"==typeof h&&null!=h&&O(h,".priority")||(a=a.updatePriority(s.getPriority())),u=l.currentWriteId,h=this.generateServerValues(),h=xn(a,s,h),l.currentOutputSnapshotRaw=a,l.currentOutputSnapshotResolved=h,l.currentWriteId=this.getNextWriteId_(),i.splice(i.indexOf(u),1),(r=r.concat(this.serverSyncTree_.applyUserOverwrite(l.path,h,l.currentWriteId,l.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(u,!0))):(c=!0,p="nodata",r.concat(this.serverSyncTree_.ackUserWrite(l.currentWriteId,!0))))),this.eventQueue_.raiseEventsForChangedPath(e,r),r=[],c&&(t[o].status=Li.COMPLETED,l=t[o].unwatcher,setTimeout(l,Math.floor(0)),t[o].onComplete&&("nodata"===p?(c=new Ai(this,t[o].path),l=t[o].currentInputSnapshot,c=new fn(l,c,Fe),n.push(t[o].onComplete.bind(null,null,!1,c))):n.push(t[o].onComplete.bind(null,new Error(p),!1,null))))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(o=0;o