HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/RImmers2/portal.photomenu.nl/wwwroot/node_modules/firebase/database-node.js
/*! @license Firebase v3.6.4
    Build: 3.6.4-rc.2
    Terms: https://firebase.google.com/terms/

    ---

    typedarray.js
    Copyright (c) 2010, Linden Research, Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE. */
(function() {
  var firebase = require('./app-node');
  var h,aa=this;function n(a){return void 0!==a}function ba(){}function ca(a){a.Tb=function(){return a.Ve?a.Ve:a.Ve=new a}}
function da(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ea(a){return"array"==da(a)}function fa(a){var b=da(a);return"array"==b||"object"==b&&"number"==typeof a.length}function p(a){return"string"==typeof a}function ga(a){return"number"==typeof a}function ha(a){return"function"==da(a)}function ia(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function ja(a,b,c){return a.call.apply(a.bind,arguments)}
function ka(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function q(a,b,c){q=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ja:ka;return q.apply(null,arguments)}
function la(a,b){function c(){}c.prototype=b.prototype;a.zg=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.tg=function(a,c,f){for(var g=Array(arguments.length-2),k=2;k<arguments.length;k++)g[k-2]=arguments[k];return b.prototype[c].apply(a,g)}};function ma(){this.Va=-1};function na(){this.Va=-1;this.Va=64;this.M=[];this.Rd=[];this.zf=[];this.xd=[];this.xd[0]=128;for(var a=1;a<this.Va;++a)this.xd[a]=0;this.Md=this.Yb=0;this.reset()}la(na,ma);na.prototype.reset=function(){this.M[0]=1732584193;this.M[1]=4023233417;this.M[2]=2562383102;this.M[3]=271733878;this.M[4]=3285377520;this.Md=this.Yb=0};
function oa(a,b,c){c||(c=0);var d=a.zf;if(p(b))for(var e=0;16>e;e++)d[e]=b.charCodeAt(c)<<24|b.charCodeAt(c+1)<<16|b.charCodeAt(c+2)<<8|b.charCodeAt(c+3),c+=4;else for(e=0;16>e;e++)d[e]=b[c]<<24|b[c+1]<<16|b[c+2]<<8|b[c+3],c+=4;for(e=16;80>e;e++){var f=d[e-3]^d[e-8]^d[e-14]^d[e-16];d[e]=(f<<1|f>>>31)&4294967295}b=a.M[0];c=a.M[1];for(var g=a.M[2],k=a.M[3],m=a.M[4],l,e=0;80>e;e++)40>e?20>e?(f=k^c&(g^k),l=1518500249):(f=c^g^k,l=1859775393):60>e?(f=c&g|k&(c|g),l=2400959708):(f=c^g^k,l=3395469782),f=(b<<
5|b>>>27)+f+m+l+d[e]&4294967295,m=k,k=g,g=(c<<30|c>>>2)&4294967295,c=b,b=f;a.M[0]=a.M[0]+b&4294967295;a.M[1]=a.M[1]+c&4294967295;a.M[2]=a.M[2]+g&4294967295;a.M[3]=a.M[3]+k&4294967295;a.M[4]=a.M[4]+m&4294967295}
na.prototype.update=function(a,b){if(null!=a){n(b)||(b=a.length);for(var c=b-this.Va,d=0,e=this.Rd,f=this.Yb;d<b;){if(0==f)for(;d<=c;)oa(this,a,d),d+=this.Va;if(p(a))for(;d<b;){if(e[f]=a.charCodeAt(d),++f,++d,f==this.Va){oa(this,e);f=0;break}}else for(;d<b;)if(e[f]=a[d],++f,++d,f==this.Va){oa(this,e);f=0;break}}this.Yb=f;this.Md+=b}};function t(a,b){for(var c in a)b.call(void 0,a[c],c,a)}function pa(a,b){var c={},d;for(d in a)c[d]=b.call(void 0,a[d],d,a);return c}function qa(a,b){for(var c in a)if(!b.call(void 0,a[c],c,a))return!1;return!0}function ra(a){var b=0,c;for(c in a)b++;return b}function sa(a){for(var b in a)return b}function ta(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function ua(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}function va(a,b){for(var c in a)if(a[c]==b)return!0;return!1}
function wa(a,b,c){for(var d in a)if(b.call(c,a[d],d,a))return d}function xa(a,b){var c=wa(a,b,void 0);return c&&a[c]}function ya(a){for(var b in a)return!1;return!0}function za(a){var b={},c;for(c in a)b[c]=a[c];return b};function Aa(a){a=String(a);if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}throw Error("Invalid JSON string: "+a);}function Ba(){this.Dd=void 0}
function Ca(a,b,c){switch(typeof b){case "string":Da(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(null==b){c.push("null");break}if(ea(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],Ca(a,a.Dd?a.Dd.call(b,String(f),e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),Da(f,c),
c.push(":"),Ca(a,a.Dd?a.Dd.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}}var Ea={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Fa=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function Da(a,b){b.push('"',a.replace(Fa,function(a){if(a in Ea)return Ea[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return Ea[a]=e+b.toString(16)}),'"')};var u;a:{var Ga=aa.navigator;if(Ga){var Ha=Ga.userAgent;if(Ha){u=Ha;break a}}u=""};var v=Array.prototype,Ia=v.indexOf?function(a,b,c){return v.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(p(a))return p(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},Ja=v.forEach?function(a,b,c){v.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},Ka=v.filter?function(a,b,c){return v.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,g=p(a)?
a.split(""):a,k=0;k<d;k++)if(k in g){var m=g[k];b.call(c,m,k,a)&&(e[f++]=m)}return e},La=v.map?function(a,b,c){return v.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=p(a)?a.split(""):a,g=0;g<d;g++)g in f&&(e[g]=b.call(c,f[g],g,a));return e},Ma=v.reduce?function(a,b,c,d){for(var e=[],f=1,g=arguments.length;f<g;f++)e.push(arguments[f]);d&&(e[0]=q(b,d));return v.reduce.apply(a,e)}:function(a,b,c,d){var e=c;Ja(a,function(c,g){e=b.call(d,e,c,g,a)});return e},Na=v.every?function(a,b,
c){return v.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};function Oa(a,b){var c=Pa(a,b,void 0);return 0>c?null:p(a)?a.charAt(c):a[c]}function Pa(a,b,c){for(var d=a.length,e=p(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1}function Qa(a,b){var c=Ia(a,b);0<=c&&v.splice.call(a,c,1)}function Ra(a,b){a.sort(b||Sa)}function Sa(a,b){return a>b?1:a<b?-1:0};var Ta=-1!=u.indexOf("Opera")||-1!=u.indexOf("OPR"),Ua=-1!=u.indexOf("Trident")||-1!=u.indexOf("MSIE"),Va=-1!=u.indexOf("Gecko")&&-1==u.toLowerCase().indexOf("webkit")&&!(-1!=u.indexOf("Trident")||-1!=u.indexOf("MSIE")),Wa=-1!=u.toLowerCase().indexOf("webkit");
(function(){var a="",b;if(Ta&&aa.opera)return a=aa.opera.version,ha(a)?a():a;Va?b=/rv\:([^\);]+)(\)|;)/:Ua?b=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:Wa&&(b=/WebKit\/(\S+)/);b&&(a=(a=b.exec(u))?a[1]:"");return Ua&&(b=(b=aa.document)?b.documentMode:void 0,b>parseFloat(a))?String(b):a})();var Xa=null,Ya=null;
function Za(a,b){if(!fa(a))throw Error("encodeByteArray takes an array as a parameter");if(!Xa){Xa={};Ya={};for(var c=0;65>c;c++)Xa[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c),Ya[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(c)}for(var c=b?Ya:Xa,d=[],e=0;e<a.length;e+=3){var f=a[e],g=e+1<a.length,k=g?a[e+1]:0,m=e+2<a.length,l=m?a[e+2]:0,r=f>>2,f=(f&3)<<4|k>>4,k=(k&15)<<2|l>>6,l=l&63;m||(l=64,g||(k=64));d.push(c[r],c[f],c[k],c[l])}return d.join("")}
;function $a(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function w(a,b){if(Object.prototype.hasOwnProperty.call(a,b))return a[b]}function ab(a,b){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b(c,a[c])};function x(a,b,c,d){var e;d<b?e="at least "+b:d>c&&(e=0===c?"none":"no more than "+c);if(e)throw Error(a+" failed: Was called with "+d+(1===d?" argument.":" arguments.")+" Expects "+e+".");}function z(a,b,c){var d="";switch(b){case 1:d=c?"first":"First";break;case 2:d=c?"second":"Second";break;case 3:d=c?"third":"Third";break;case 4:d=c?"fourth":"Fourth";break;default:throw Error("errorPrefix called with argumentNumber > 4.  Need to update it?");}return a=a+" failed: "+(d+" argument ")}
function A(a,b,c,d){if((!d||n(c))&&!ha(c))throw Error(z(a,b,d)+"must be a valid function.");}function bb(a,b,c){if(n(c)&&(!ia(c)||null===c))throw Error(z(a,b,!0)+"must be a valid context object.");};function cb(a){var b=[];ab(a,function(a,d){ea(d)?Ja(d,function(d){b.push(encodeURIComponent(a)+"="+encodeURIComponent(d))}):b.push(encodeURIComponent(a)+"="+encodeURIComponent(d))});return b.length?"&"+b.join("&"):""};var db=firebase.Promise;function eb(){var a=this;this.reject=this.resolve=null;this.ra=new db(function(b,c){a.resolve=b;a.reject=c})}function fb(a,b){return function(c,d){c?a.reject(c):a.resolve(d);ha(b)&&(gb(a.ra),1===b.length?b(c):b(c,d))}}function gb(a){a.then(void 0,ba)};function hb(a,b){if(!a)throw ib(b);}function ib(a){return Error("Firebase Database ("+firebase.SDK_VERSION+") INTERNAL ASSERT FAILED: "+a)};function jb(a){for(var b=[],c=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);55296<=e&&56319>=e&&(e-=55296,d++,hb(d<a.length,"Surrogate pair missing trail surrogate."),e=65536+(e<<10)+(a.charCodeAt(d)-56320));128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(65536>e?b[c++]=e>>12|224:(b[c++]=e>>18|240,b[c++]=e>>12&63|128),b[c++]=e>>6&63|128),b[c++]=e&63|128)}return b}function kb(a){for(var b=0,c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b++:2048>d?b+=2:55296<=d&&56319>=d?(b+=4,c++):b+=3}return b};function lb(a){return"undefined"!==typeof JSON&&n(JSON.parse)?JSON.parse(a):Aa(a)}function B(a){if("undefined"!==typeof JSON&&n(JSON.stringify))a=JSON.stringify(a);else{var b=[];Ca(new Ba,a,b);a=b.join("")}return a};function mb(a,b){this.committed=a;this.snapshot=b};function nb(){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 ob(a){this.pe=a;this.zd=[];this.Ob=0;this.Td=-1;this.Db=null}function pb(a,b,c){a.Td=b;a.Db=c;a.Td<a.Ob&&(a.Db(),a.Db=null)}function qb(a,b,c){for(a.zd[b]=c;a.zd[a.Ob];){var d=a.zd[a.Ob];delete a.zd[a.Ob];for(var e=0;e<d.length;++e)if(d[e]){var f=a;rb(function(){f.pe(d[e])})}if(a.Ob===a.Td){a.Db&&(clearTimeout(a.Db),a.Db(),a.Db=null);break}a.Ob++}};function sb(){this.mc={}}sb.prototype.set=function(a,b){null==b?delete this.mc[a]:this.mc[a]=b};sb.prototype.get=function(a){return $a(this.mc,a)?this.mc[a]:null};sb.prototype.remove=function(a){delete this.mc[a]};sb.prototype.We=!0;function tb(a){this.rc=a;this.Ad="firebase:"}h=tb.prototype;h.set=function(a,b){null==b?this.rc.removeItem(this.Ad+a):this.rc.setItem(this.Ad+a,B(b))};h.get=function(a){a=this.rc.getItem(this.Ad+a);return null==a?null:lb(a)};h.remove=function(a){this.rc.removeItem(this.Ad+a)};h.We=!1;h.toString=function(){return this.rc.toString()};function ub(a){try{if("undefined"!==typeof window&&"undefined"!==typeof window[a]){var b=window[a];b.setItem("firebase:sentinel","cache");b.removeItem("firebase:sentinel");return new tb(b)}}catch(c){}return new sb}var vb=ub("localStorage"),wb=ub("sessionStorage");function xb(a,b,c){this.type=yb;this.source=a;this.path=b;this.Fa=c}xb.prototype.Jc=function(a){return this.path.e()?new xb(this.source,C,this.Fa.Q(a)):new xb(this.source,D(this.path),this.Fa)};xb.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" overwrite: "+this.Fa.toString()+")"};function zb(a,b){this.type=Ab;this.source=a;this.path=b}zb.prototype.Jc=function(){return this.path.e()?new zb(this.source,C):new zb(this.source,D(this.path))};zb.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" listen_complete)"};function Bb(a){this.lc=a}Bb.prototype.getToken=function(a){return this.lc.INTERNAL.getToken(a).then(null,function(a){return a&&"auth/token-not-initialized"===a.code?(E("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(a)})};function Cb(a,b){a.lc.INTERNAL.addAuthTokenListener(b)};function Db(){this.Hd=G}Db.prototype.j=function(a){return this.Hd.P(a)};Db.prototype.toString=function(){return this.Hd.toString()};function Eb(a,b,c,d,e){this.host=a.toLowerCase();this.domain=this.host.substr(this.host.indexOf(".")+1);this.Pc=b;this.le=c;this.rg=d;this.ef=e||"";this.Za=vb.get("host:"+a)||this.host}function Fb(a,b){b!==a.Za&&(a.Za=b,"s-"===a.Za.substr(0,2)&&vb.set("host:"+a.host,a.Za))}
function Gb(a,b,c){H("string"===typeof b,"typeof type must == string");H("object"===typeof c,"typeof params must == object");if("websocket"===b)b=(a.Pc?"wss://":"ws://")+a.Za+"/.ws?";else if("long_polling"===b)b=(a.Pc?"https://":"http://")+a.Za+"/.lp?";else throw Error("Unknown connection type: "+b);a.host!==a.Za&&(c.ns=a.le);var d=[];t(c,function(a,b){d.push(b+"="+a)});return b+d.join("&")}
Eb.prototype.toString=function(){var a=(this.Pc?"https://":"http://")+this.host;this.ef&&(a+="<"+this.ef+">");return a};function Hb(){this.qc={}}function Ib(a,b,c){n(c)||(c=1);$a(a.qc,b)||(a.qc[b]=0);a.qc[b]+=c}Hb.prototype.get=function(){return za(this.qc)};function Jb(a){this.Df=a;this.od=null}Jb.prototype.get=function(){var a=this.Df.get(),b=za(a);if(this.od)for(var c in this.od)b[c]-=this.od[c];this.od=a;return b};function Kb(){this.tb=[]}function Lb(a,b){for(var c=null,d=0;d<b.length;d++){var e=b[d],f=e.Wb();null===c||f.Z(c.Wb())||(a.tb.push(c),c=null);null===c&&(c=new Mb(f));c.add(e)}c&&a.tb.push(c)}function Nb(a,b,c){Lb(a,c);Ob(a,function(a){return a.Z(b)})}function Pb(a,b,c){Lb(a,c);Ob(a,function(a){return a.contains(b)||b.contains(a)})}
function Ob(a,b){for(var c=!0,d=0;d<a.tb.length;d++){var e=a.tb[d];if(e)if(e=e.Wb(),b(e)){for(var e=a.tb[d],f=0;f<e.fd.length;f++){var g=e.fd[f];if(null!==g){e.fd[f]=null;var k=g.Rb();Qb&&E("event: "+g.toString());rb(k)}}a.tb[d]=null}else c=!1}c&&(a.tb=[])}function Mb(a){this.qa=a;this.fd=[]}Mb.prototype.add=function(a){this.fd.push(a)};Mb.prototype.Wb=function(){return this.qa};function Rb(a,b,c,d){this.Xd=b;this.Jd=c;this.Bd=d;this.ed=a}Rb.prototype.Wb=function(){var a=this.Jd.ub();return"value"===this.ed?a.path:a.getParent().path};Rb.prototype.be=function(){return this.ed};Rb.prototype.Rb=function(){return this.Xd.Rb(this)};Rb.prototype.toString=function(){return this.Wb().toString()+":"+this.ed+":"+B(this.Jd.Ne())};function Sb(a,b,c){this.Xd=a;this.error=b;this.path=c}Sb.prototype.Wb=function(){return this.path};Sb.prototype.be=function(){return"cancel"};
Sb.prototype.Rb=function(){return this.Xd.Rb(this)};Sb.prototype.toString=function(){return this.path.toString()+":cancel"};function Tb(){}Tb.prototype.Qe=function(){return null};Tb.prototype.ae=function(){return null};var Ub=new Tb;function Vb(a,b,c){this.wf=a;this.Ja=b;this.wd=c}Vb.prototype.Qe=function(a){var b=this.Ja.N;if(Wb(b,a))return b.j().Q(a);b=null!=this.wd?new Xb(this.wd,!0,!1):this.Ja.w();return this.wf.nc(a,b)};Vb.prototype.ae=function(a,b,c){var d=null!=this.wd?this.wd:Yb(this.Ja);a=this.wf.Sd(d,b,1,c,a);return 0===a.length?null:a[0]};function I(a,b,c,d){this.type=a;this.Ia=b;this.Wa=c;this.me=d;this.Bd=void 0}function Zb(a){return new I($b,a)}var $b="value";function Xb(a,b,c){this.A=a;this.da=b;this.Qb=c}function ac(a){return a.da}function bc(a){return a.Qb}function cc(a,b){return b.e()?a.da&&!a.Qb:Wb(a,J(b))}function Wb(a,b){return a.da&&!a.Qb||a.A.Da(b)}Xb.prototype.j=function(){return this.A};function dc(a,b){return ec(a.name,b.name)}function fc(a,b){return ec(a,b)};function K(a,b){this.name=a;this.R=b}function gc(a,b){return new K(a,b)};function hc(a,b){return a&&"object"===typeof a?(H(".sv"in a,"Unexpected leaf node or priority contents"),b[a[".sv"]]):a}function ic(a,b){var c=new jc;kc(a,new L(""),function(a,e){lc(c,a,mc(e,b))});return c}function mc(a,b){var c=a.C().H(),c=hc(c,b),d;if(a.J()){var e=hc(a.Ca(),b);return e!==a.Ca()||c!==a.C().H()?new nc(e,M(c)):a}d=a;c!==a.C().H()&&(d=d.fa(new nc(c)));a.O(N,function(a,c){var e=mc(c,b);e!==c&&(d=d.T(a,e))});return d};(function(){var a=process.version;if("v0.10.22"===a||"v0.10.23"===a||"v0.10.24"===a){var b=function(a,b,c){this.chunk=a;this.encoding=b;this.callback=c},c=function(a,c,d,e,l){c.objectMode||!1===c.decodeStrings||"string"!==typeof d||(d=new Buffer(d,e));Buffer.isBuffer(d)&&(e="buffer");var r=c.objectMode?1:d.length;c.length+=r;var y=c.length<c.highWaterMark;y||(c.needDrain=!0);c.writing?c.buffer.push(new b(d,e,l)):(c.writelen=r,c.writecb=l,c.writing=!0,c.sync=!0,a._write(d,e,c.onwrite),c.sync=!1);return y},
d=function(a,b,c,d){var e=!0;if(!Buffer.isBuffer(c)&&"string"!==typeof c&&null!==c&&void 0!==c&&!b.objectMode){var r=new TypeError("Invalid non-string/buffer chunk");a.emit("error",r);process.nextTick(function(){d(r)});e=!1}return e},e=function(a,b){var c=Error("write after end");a.emit("error",c);process.nextTick(function(){b(c)})},a=require("_stream_writable");a.prototype.write=function(a,b,k){var m=this._writableState,l=!1;"function"===typeof b&&(k=b,b=null);Buffer.isBuffer(a)?b="buffer":b||(b=
m.defaultEncoding);"function"!==typeof k&&(k=function(){});m.ended?e(this,k):d(this,m,a,k)&&(l=c(this,m,a,b,k));return l};require("_stream_duplex").prototype.write=a.prototype.write}})();var oc=function(){var a=1;return function(){return a++}}(),H=hb,pc=ib;function qc(a){try{return(new Buffer(a,"base64")).toString("utf8")}catch(b){E("base64Decode failed: ",b)}return null}function rc(a){var b=jb(a);a=new na;a.update(b);var b=[],c=8*a.Md;56>a.Yb?a.update(a.xd,56-a.Yb):a.update(a.xd,a.Va-(a.Yb-56));for(var d=a.Va-1;56<=d;d--)a.Rd[d]=c&255,c/=256;oa(a,a.Rd);for(d=c=0;5>d;d++)for(var e=24;0<=e;e-=8)b[c]=a.M[d]>>e&255,++c;return Za(b)}
function sc(a){for(var b="",c=0;c<arguments.length;c++)b=fa(arguments[c])?b+sc.apply(null,arguments[c]):"object"===typeof arguments[c]?b+B(arguments[c]):b+arguments[c],b+=" ";return b}var Qb=null,tc=!0;
function uc(a,b){hb(!b||!0===a||!1===a,"Can't turn on custom loggers persistently.");!0===a?("undefined"!==typeof console&&("function"===typeof console.log?Qb=q(console.log,console):"object"===typeof console.log&&(Qb=function(a){console.log(a)})),b&&wb.set("logging_enabled",!0)):ha(a)?Qb=a:(Qb=null,wb.remove("logging_enabled"))}function E(a){!0===tc&&(tc=!1,null===Qb&&!0===wb.get("logging_enabled")&&uc(!0));if(Qb){var b=sc.apply(null,arguments);Qb(b)}}
function vc(a){return function(){E(a,arguments)}}function wc(a){if("undefined"!==typeof console){var b="FIREBASE INTERNAL ERROR: "+sc.apply(null,arguments);"undefined"!==typeof console.error?console.error(b):console.log(b)}}function xc(a){var b=sc.apply(null,arguments);throw Error("FIREBASE FATAL ERROR: "+b);}function O(a){if("undefined"!==typeof console){var b="FIREBASE WARNING: "+sc.apply(null,arguments);"undefined"!==typeof console.warn?console.warn(b):console.log(b)}}
function yc(a){var b,c,d,e,f,g=a;f=c=a=b="";d=!0;e="https";if(p(g)){var k=g.indexOf("//");0<=k&&(e=g.substring(0,k-1),g=g.substring(k+2));k=g.indexOf("/");-1===k&&(k=g.length);b=g.substring(0,k);f="";g=g.substring(k).split("/");for(k=0;k<g.length;k++)if(0<g[k].length){var m=g[k];try{m=decodeURIComponent(m.replace(/\+/g," "))}catch(l){}f+="/"+m}g=b.split(".");3===g.length?(a=g[1],c=g[0].toLowerCase()):2===g.length&&(a=g[0]);k=b.indexOf(":");0<=k&&(d="https"===e||"wss"===e)}"firebase"===a&&xc(b+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead");
c&&"undefined"!=c||xc("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com");d||"undefined"!==typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&O("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");return{gc:new Eb(b,d,c,"ws"===e||"wss"===e),path:new L(f)}}function zc(a){return ga(a)&&(a!=a||a==Number.POSITIVE_INFINITY||a==Number.NEGATIVE_INFINITY)}function Ac(a){a()}
function ec(a,b){if(a===b)return 0;if("[MIN_NAME]"===a||"[MAX_NAME]"===b)return-1;if("[MIN_NAME]"===b||"[MAX_NAME]"===a)return 1;var c=Bc(a),d=Bc(b);return null!==c?null!==d?0==c-d?a.length-b.length:c-d:-1:null!==d?1:a<b?-1:1}function Cc(a,b){if(b&&a in b)return b[a];throw Error("Missing required key ("+a+") in object: "+B(b));}
function Dc(a){if("object"!==typeof a||null===a)return B(a);var b=[],c;for(c in a)b.push(c);b.sort();c="{";for(var d=0;d<b.length;d++)0!==d&&(c+=","),c+=B(b[d]),c+=":",c+=Dc(a[b[d]]);return c+"}"}function Ec(a,b){if(a.length<=b)return[a];for(var c=[],d=0;d<a.length;d+=b)d+b>a?c.push(a.substring(d,a.length)):c.push(a.substring(d,d+b));return c}function Fc(a,b){if(ea(a))for(var c=0;c<a.length;++c)b(c,a[c]);else t(a,b)}
function Gc(a){H(!zc(a),"Invalid JSON number");var b,c,d,e;0===a?(d=c=0,b=-Infinity===1/a?1:0):(b=0>a,a=Math.abs(a),a>=Math.pow(2,-1022)?(d=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),c=d+1023,d=Math.round(a*Math.pow(2,52-d)-Math.pow(2,52))):(c=0,d=Math.round(a/Math.pow(2,-1074))));e=[];for(a=52;a;--a)e.push(d%2?1:0),d=Math.floor(d/2);for(a=11;a;--a)e.push(c%2?1:0),c=Math.floor(c/2);e.push(b?1:0);e.reverse();b=e.join("");c="";for(a=0;64>a;a+=8)d=parseInt(b.substr(a,8),2).toString(16),1===d.length&&
(d="0"+d),c+=d;return c.toLowerCase()}var Hc=/^-?\d{1,10}$/;function Bc(a){return Hc.test(a)&&(a=Number(a),-2147483648<=a&&2147483647>=a)?a:null}function rb(a){try{a()}catch(b){setTimeout(function(){O("Exception was thrown by user callback.",b.stack||"");throw b;},Math.floor(0))}}function Ic(a,b,c){Object.defineProperty(a,b,{get:c})}function Jc(a,b){var c=setTimeout(a,b);"object"===typeof c&&c.unref&&c.unref();return c};function Kc(a){var b={},c={},d={},e="";try{var f=a.split("."),b=lb(qc(f[0])||""),c=lb(qc(f[1])||""),e=f[2],d=c.d||{};delete c.d}catch(g){}return{wg:b,Ge:c,data:d,mg:e}}function Lc(a){a=Kc(a);var b=a.Ge;return!!a.mg&&!!b&&"object"===typeof b&&b.hasOwnProperty("iat")}function Mc(a){a=Kc(a).Ge;return"object"===typeof a&&!0===w(a,"admin")};function Nc(a,b,c){this.f=vc("p:rest:");this.L=a;this.Eb=b;this.Xc=c;this.$={}}function Oc(a,b){if(n(b))return"tag$"+b;H(Pc(a.m),"should have a tag if it's not a default query.");return a.path.toString()}h=Nc.prototype;
h.Xe=function(a,b,c,d){var e=a.path.toString();this.f("Listen called for "+e+" "+a.ja());var f=Oc(a,c),g={};this.$[f]=g;a=Qc(a.m);var k=this;Rc(this,e+".json",a,function(a,b){var r=b;404===a&&(a=r=null);null===a&&k.Eb(e,r,!1,c);w(k.$,f)===g&&d(a?401==a?"permission_denied":"rest_error:"+a:"ok",null)})};h.tf=function(a,b){var c=Oc(a,b);delete this.$[c]};h.hf=function(){};h.ne=function(){};h.bf=function(){};h.vd=function(){};h.put=function(){};h.Ye=function(){};h.ue=function(){};
function Rc(a,b,c,d){c=c||{};c.format="export";a.Xc.getToken(!1).then(function(e){(e=e&&e.accessToken)&&(c.auth=e);var f=(a.L.Pc?"https://":"http://")+a.L.host+b+"?"+cb(c);a.f("Sending REST request for "+f);var g=new XMLHttpRequest;g.onreadystatechange=function(){if(d&&4===g.readyState){a.f("REST Response for "+f+" received. status:",g.status,"response:",g.responseText);var b=null;if(200<=g.status&&300>g.status){try{b=lb(g.responseText)}catch(c){O("Failed to parse JSON response for "+f+": "+g.responseText)}d(null,
b)}else 401!==g.status&&404!==g.status&&O("Got unsuccessful REST response for "+f+" Status: "+g.status),d(g.status);d=null}};g.open("GET",f,!0);g.send()})};function Sc(a,b,c){this.type=Tc;this.source=a;this.path=b;this.children=c}Sc.prototype.Jc=function(a){if(this.path.e())return a=this.children.subtree(new L(a)),a.e()?null:a.value?new xb(this.source,C,a.value):new Sc(this.source,C,a);H(J(this.path)===a,"Can't get a merge for a child not on the path of the operation");return new Sc(this.source,D(this.path),this.children)};Sc.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"};function Uc(a,b){this.qf={};this.Sc=new Jb(a);this.va=b;var c=1E4+2E4*Math.random();Jc(q(this.jf,this),Math.floor(c))}Uc.prototype.jf=function(){var a=this.Sc.get(),b={},c=!1,d;for(d in a)0<a[d]&&$a(this.qf,d)&&(b[d]=a[d],c=!0);c&&this.va.ue(b);Jc(q(this.jf,this),Math.floor(6E5*Math.random()))};var Vc={},Wc={};function Xc(a){a=a.toString();Vc[a]||(Vc[a]=new Hb);return Vc[a]}function Yc(a,b){var c=a.toString();Wc[c]||(Wc[c]=b());return Wc[c]};var Zc=null,Zc=require("faye-websocket").Client;function $c(a,b,c,d){this.Ud=a;this.f=vc(this.Ud);this.frames=this.wc=null;this.nb=this.ob=this.Be=0;this.Ua=Xc(b);a={v:"5"};c&&(a.s=c);d&&(a.ls=d);this.Vd=Gb(b,"websocket",a)}var ad;
$c.prototype.open=function(a,b){this.gb=b;this.Vf=a;this.f("Websocket connecting to "+this.Vd);this.tc=!1;vb.set("previous_websocket_failure",!0);try{var c={headers:{"User-Agent":"Firebase/5/"+firebase.SDK_VERSION+"/"+process.platform+"/Node"}},d=process.env,e=0==this.Vd.indexOf("wss://")?d.HTTPS_PROXY||d.https_proxy:d.HTTP_PROXY||d.http_proxy;e&&(c.proxy={origin:e});this.Ha=new Zc(this.Vd,[],c)}catch(f){this.f("Error instantiating WebSocket.");(c=f.message||f.data)&&this.f(c);this.ab();return}var g=
this;this.Ha.onopen=function(){g.f("Websocket connected.");g.tc=!0};this.Ha.onclose=function(){g.f("Websocket connection was disconnected.");g.Ha=null;g.ab()};this.Ha.onmessage=function(a){if(null!==g.Ha)if(a=a.data,g.nb+=a.length,Ib(g.Ua,"bytes_received",a.length),bd(g),null!==g.frames)cd(g,a);else{a:{H(null===g.frames,"We already have a frame buffer");if(6>=a.length){var b=Number(a);if(!isNaN(b)){g.Be=b;g.frames=[];a=null;break a}}g.Be=1;g.frames=[]}null!==a&&cd(g,a)}};this.Ha.onerror=function(a){g.f("WebSocket error.  Closing connection.");
(a=a.message||a.data)&&g.f(a);g.ab()}};$c.prototype.start=function(){};$c.isAvailable=function(){var a=!1;if("undefined"!==typeof navigator&&navigator.userAgent){var b=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);b&&1<b.length&&4.4>parseFloat(b[1])&&(a=!0)}return!a&&null!==Zc&&!ad};$c.responsesRequiredToBeHealthy=2;$c.healthyTimeout=3E4;h=$c.prototype;h.pd=function(){vb.remove("previous_websocket_failure")};
function cd(a,b){a.frames.push(b);if(a.frames.length==a.Be){var c=a.frames.join("");a.frames=null;c=lb(c);a.Vf(c)}}h.send=function(a){bd(this);a=B(a);this.ob+=a.length;Ib(this.Ua,"bytes_sent",a.length);a=Ec(a,16384);1<a.length&&dd(this,String(a.length));for(var b=0;b<a.length;b++)dd(this,a[b])};h.Qc=function(){this.yb=!0;this.wc&&(clearInterval(this.wc),this.wc=null);this.Ha&&(this.Ha.close(),this.Ha=null)};
h.ab=function(){this.yb||(this.f("WebSocket is closing itself"),this.Qc(),this.gb&&(this.gb(this.tc),this.gb=null))};h.close=function(){this.yb||(this.f("WebSocket is being closed"),this.Qc())};function bd(a){clearInterval(a.wc);a.wc=setInterval(function(){a.Ha&&dd(a,"0");bd(a)},Math.floor(45E3))}function dd(a,b){try{a.Ha.send(b)}catch(c){a.f("Exception thrown from WebSocket.send():",c.message||c.data,"Closing connection."),setTimeout(q(a.ab,a),0)}};function ed(){this.eb={}}
function fd(a,b){var c=b.type,d=b.Wa;H("child_added"==c||"child_changed"==c||"child_removed"==c,"Only child changes supported for tracking");H(".priority"!==d,"Only non-priority child changes can be tracked.");var e=w(a.eb,d);if(e){var f=e.type;if("child_added"==c&&"child_removed"==f)a.eb[d]=new I("child_changed",b.Ia,d,e.Ia);else if("child_removed"==c&&"child_added"==f)delete a.eb[d];else if("child_removed"==c&&"child_changed"==f)a.eb[d]=new I("child_removed",e.me,d);else if("child_changed"==c&&
"child_added"==f)a.eb[d]=new I("child_added",b.Ia,d);else if("child_changed"==c&&"child_changed"==f)a.eb[d]=new I("child_changed",b.Ia,d,e.me);else throw pc("Illegal combination of changes: "+b+" occurred after "+e);}else a.eb[d]=b};function gd(a){this.V=a;this.g=a.m.g}function id(a,b,c,d){var e=[],f=[];Ja(b,function(b){"child_changed"===b.type&&a.g.kd(b.me,b.Ia)&&f.push(new I("child_moved",b.Ia,b.Wa))});jd(a,e,"child_removed",b,d,c);jd(a,e,"child_added",b,d,c);jd(a,e,"child_moved",f,d,c);jd(a,e,"child_changed",b,d,c);jd(a,e,$b,b,d,c);return e}function jd(a,b,c,d,e,f){d=Ka(d,function(a){return a.type===c});Ra(d,q(a.Ff,a));Ja(d,function(c){var d=kd(a,c,f);Ja(e,function(e){e.lf(c.type)&&b.push(e.createEvent(d,a.V))})})}
function kd(a,b,c){"value"!==b.type&&"child_removed"!==b.type&&(b.Bd=c.Se(b.Wa,b.Ia,a.g));return b}gd.prototype.Ff=function(a,b){if(null==a.Wa||null==b.Wa)throw pc("Should only compare child_ events.");return this.g.compare(new K(a.Wa,a.Ia),new K(b.Wa,b.Ia))};function ld(a,b){this.Od=a;this.Cf=b}function md(a){this.U=a}
md.prototype.bb=function(a,b,c,d){var e=new ed,f;if(b.type===yb)b.source.$d?c=nd(this,a,b.path,b.Fa,c,d,e):(H(b.source.Pe,"Unknown source."),f=b.source.Ae||bc(a.w())&&!b.path.e(),c=od(this,a,b.path,b.Fa,c,d,f,e));else if(b.type===Tc)b.source.$d?c=pd(this,a,b.path,b.children,c,d,e):(H(b.source.Pe,"Unknown source."),f=b.source.Ae||bc(a.w()),c=qd(this,a,b.path,b.children,c,d,f,e));else if(b.type===rd)if(b.Gd)if(b=b.path,null!=c.ic(b))c=a;else{f=new Vb(c,a,d);d=a.N.j();if(b.e()||".priority"===J(b))ac(a.w())?
b=c.Aa(Yb(a)):(b=a.w().j(),H(b instanceof P,"serverChildren would be complete if leaf node"),b=c.oc(b)),b=this.U.ya(d,b,e);else{var g=J(b),k=c.nc(g,a.w());null==k&&Wb(a.w(),g)&&(k=d.Q(g));b=null!=k?this.U.F(d,g,k,D(b),f,e):a.N.j().Da(g)?this.U.F(d,g,G,D(b),f,e):d;b.e()&&ac(a.w())&&(d=c.Aa(Yb(a)),d.J()&&(b=this.U.ya(b,d,e)))}d=ac(a.w())||null!=c.ic(C);c=sd(a,b,d,this.U.Ma())}else c=td(this,a,b.path,b.Mb,c,d,e);else if(b.type===Ab)d=b.path,b=a.w(),f=b.j(),g=b.da||d.e(),c=ud(this,new vd(a.N,new Xb(f,
g,b.Qb)),d,c,Ub,e);else throw pc("Unknown operation type: "+b.type);e=ta(e.eb);d=c;b=d.N;b.da&&(f=b.j().J()||b.j().e(),g=wd(a),(0<e.length||!a.N.da||f&&!b.j().Z(g)||!b.j().C().Z(g.C()))&&e.push(Zb(wd(d))));return new ld(c,e)};
function ud(a,b,c,d,e,f){var g=b.N;if(null!=d.ic(c))return b;var k;if(c.e())H(ac(b.w()),"If change path is empty, we must have complete server data"),bc(b.w())?(e=Yb(b),d=d.oc(e instanceof P?e:G)):d=d.Aa(Yb(b)),f=a.U.ya(b.N.j(),d,f);else{var m=J(c);if(".priority"==m)H(1==xd(c),"Can't have a priority with additional path components"),f=g.j(),k=b.w().j(),d=d.Yc(c,f,k),f=null!=d?a.U.fa(f,d):g.j();else{var l=D(c);Wb(g,m)?(k=b.w().j(),d=d.Yc(c,g.j(),k),d=null!=d?g.j().Q(m).F(l,d):g.j().Q(m)):d=d.nc(m,
b.w());f=null!=d?a.U.F(g.j(),m,d,l,e,f):g.j()}}return sd(b,f,g.da||c.e(),a.U.Ma())}function od(a,b,c,d,e,f,g,k){var m=b.w();g=g?a.U:a.U.Sb();if(c.e())d=g.ya(m.j(),d,null);else if(g.Ma()&&!m.Qb)d=m.j().F(c,d),d=g.ya(m.j(),d,null);else{var l=J(c);if(!cc(m,c)&&1<xd(c))return b;var r=D(c);d=m.j().Q(l).F(r,d);d=".priority"==l?g.fa(m.j(),d):g.F(m.j(),l,d,r,Ub,null)}m=m.da||c.e();b=new vd(b.N,new Xb(d,m,g.Ma()));return ud(a,b,c,e,new Vb(e,b,f),k)}
function nd(a,b,c,d,e,f,g){var k=b.N;e=new Vb(e,b,f);if(c.e())g=a.U.ya(b.N.j(),d,g),a=sd(b,g,!0,a.U.Ma());else if(f=J(c),".priority"===f)g=a.U.fa(b.N.j(),d),a=sd(b,g,k.da,k.Qb);else{c=D(c);var m=k.j().Q(f);if(!c.e()){var l=e.Qe(f);d=null!=l?".priority"===yd(c)&&l.P(c.parent()).e()?l:l.F(c,d):G}m.Z(d)?a=b:(g=a.U.F(k.j(),f,d,c,e,g),a=sd(b,g,k.da,a.U.Ma()))}return a}
function pd(a,b,c,d,e,f,g){var k=b;zd(d,function(d,l){var r=c.n(d);Wb(b.N,J(r))&&(k=nd(a,k,r,l,e,f,g))});zd(d,function(d,l){var r=c.n(d);Wb(b.N,J(r))||(k=nd(a,k,r,l,e,f,g))});return k}function Ad(a,b){zd(b,function(b,d){a=a.F(b,d)});return a}
function qd(a,b,c,d,e,f,g,k){if(b.w().j().e()&&!ac(b.w()))return b;var m=b;c=c.e()?d:Bd(Q,c,d);var l=b.w().j();c.children.ha(function(c,d){if(l.Da(c)){var F=b.w().j().Q(c),F=Ad(F,d);m=od(a,m,new L(c),F,e,f,g,k)}});c.children.ha(function(c,d){var F=!Wb(b.w(),c)&&null==d.value;l.Da(c)||F||(F=b.w().j().Q(c),F=Ad(F,d),m=od(a,m,new L(c),F,e,f,g,k))});return m}
function td(a,b,c,d,e,f,g){if(null!=e.ic(c))return b;var k=bc(b.w()),m=b.w();if(null!=d.value){if(c.e()&&m.da||cc(m,c))return od(a,b,c,m.j().P(c),e,f,k,g);if(c.e()){var l=Q;m.j().O(Cd,function(a,b){l=l.set(new L(a),b)});return qd(a,b,c,l,e,f,k,g)}return b}l=Q;zd(d,function(a){var b=c.n(a);cc(m,b)&&(l=l.set(a,m.j().P(b)))});return qd(a,b,c,l,e,f,k,g)};function Dd(a){this.g=a}h=Dd.prototype;h.F=function(a,b,c,d,e,f){H(a.vc(this.g),"A node must be indexed if only a child is updated");e=a.Q(b);if(e.P(d).Z(c.P(d))&&e.e()==c.e())return a;null!=f&&(c.e()?a.Da(b)?fd(f,new I("child_removed",e,b)):H(a.J(),"A child remove without an old child only makes sense on a leaf node"):e.e()?fd(f,new I("child_added",c,b)):fd(f,new I("child_changed",c,b,e)));return a.J()&&c.e()?a:a.T(b,c).lb(this.g)};
h.ya=function(a,b,c){null!=c&&(a.J()||a.O(N,function(a,e){b.Da(a)||fd(c,new I("child_removed",e,a))}),b.J()||b.O(N,function(b,e){if(a.Da(b)){var f=a.Q(b);f.Z(e)||fd(c,new I("child_changed",e,b,f))}else fd(c,new I("child_added",e,b))}));return b.lb(this.g)};h.fa=function(a,b){return a.e()?G:a.fa(b)};h.Ma=function(){return!1};h.Sb=function(){return this};function Ed(a){this.ce=new Dd(a.g);this.g=a.g;var b;a.ka?(b=Fd(a),b=a.g.Bc(Gd(a),b)):b=a.g.Ec();this.Rc=b;a.na?(b=Hd(a),a=a.g.Bc(Id(a),b)):a=a.g.Cc();this.sc=a}h=Ed.prototype;h.matches=function(a){return 0>=this.g.compare(this.Rc,a)&&0>=this.g.compare(a,this.sc)};h.F=function(a,b,c,d,e,f){this.matches(new K(b,c))||(c=G);return this.ce.F(a,b,c,d,e,f)};
h.ya=function(a,b,c){b.J()&&(b=G);var d=b.lb(this.g),d=d.fa(G),e=this;b.O(N,function(a,b){e.matches(new K(a,b))||(d=d.T(a,G))});return this.ce.ya(a,d,c)};h.fa=function(a){return a};h.Ma=function(){return!0};h.Sb=function(){return this.ce};function Jd(a){this.sa=new Ed(a);this.g=a.g;H(a.xa,"Only valid if limit has been set");this.oa=a.oa;this.Gb=!Kd(a)}h=Jd.prototype;h.F=function(a,b,c,d,e,f){this.sa.matches(new K(b,c))||(c=G);return a.Q(b).Z(c)?a:a.Cb()<this.oa?this.sa.Sb().F(a,b,c,d,e,f):Ld(this,a,b,c,e,f)};
h.ya=function(a,b,c){var d;if(b.J()||b.e())d=G.lb(this.g);else if(2*this.oa<b.Cb()&&b.vc(this.g)){d=G.lb(this.g);b=this.Gb?b.Xb(this.sa.sc,this.g):b.Vb(this.sa.Rc,this.g);for(var e=0;0<b.Oa.length&&e<this.oa;){var f=R(b),g;if(g=this.Gb?0>=this.g.compare(this.sa.Rc,f):0>=this.g.compare(f,this.sa.sc))d=d.T(f.name,f.R),e++;else break}}else{d=b.lb(this.g);d=d.fa(G);var k,m,l;if(this.Gb){b=d.Te(this.g);k=this.sa.sc;m=this.sa.Rc;var r=Md(this.g);l=function(a,b){return r(b,a)}}else b=d.Ub(this.g),k=this.sa.Rc,
m=this.sa.sc,l=Md(this.g);for(var e=0,y=!1;0<b.Oa.length;)f=R(b),!y&&0>=l(k,f)&&(y=!0),(g=y&&e<this.oa&&0>=l(f,m))?e++:d=d.T(f.name,G)}return this.sa.Sb().ya(a,d,c)};h.fa=function(a){return a};h.Ma=function(){return!0};h.Sb=function(){return this.sa.Sb()};
function Ld(a,b,c,d,e,f){var g;if(a.Gb){var k=Md(a.g);g=function(a,b){return k(b,a)}}else g=Md(a.g);H(b.Cb()==a.oa,"");var m=new K(c,d),l=a.Gb?Nd(b,a.g):Od(b,a.g),r=a.sa.matches(m);if(b.Da(c)){for(var y=b.Q(c),l=e.ae(a.g,l,a.Gb);null!=l&&(l.name==c||b.Da(l.name));)l=e.ae(a.g,l,a.Gb);e=null==l?1:g(l,m);if(r&&!d.e()&&0<=e)return null!=f&&fd(f,new I("child_changed",d,c,y)),b.T(c,d);null!=f&&fd(f,new I("child_removed",y,c));b=b.T(c,G);return null!=l&&a.sa.matches(l)?(null!=f&&fd(f,new I("child_added",
l.R,l.name)),b.T(l.name,l.R)):b}return d.e()?b:r&&0<=g(l,m)?(null!=f&&(fd(f,new I("child_removed",l.R,l.name)),fd(f,new I("child_added",d,c))),b.T(c,d).T(l.name,G)):b};function nc(a,b){this.B=a;H(n(this.B)&&null!==this.B,"LeafNode shouldn't be created with null/undefined value.");this.aa=b||G;Pd(this.aa);this.Bb=null}var Qd=["object","boolean","number","string"];h=nc.prototype;h.J=function(){return!0};h.C=function(){return this.aa};h.fa=function(a){return new nc(this.B,a)};h.Q=function(a){return".priority"===a?this.aa:G};h.P=function(a){return a.e()?this:".priority"===J(a)?this.aa:G};h.Da=function(){return!1};h.Se=function(){return null};
h.T=function(a,b){return".priority"===a?this.fa(b):b.e()&&".priority"!==a?this:G.T(a,b).fa(this.aa)};h.F=function(a,b){var c=J(a);if(null===c)return b;if(b.e()&&".priority"!==c)return this;H(".priority"!==c||1===xd(a),".priority must be the last token in a path");return this.T(c,G.F(D(a),b))};h.e=function(){return!1};h.Cb=function(){return 0};h.O=function(){return!1};h.H=function(a){return a&&!this.C().e()?{".value":this.Ca(),".priority":this.C().H()}:this.Ca()};
h.hash=function(){if(null===this.Bb){var a="";this.aa.e()||(a+="priority:"+Rd(this.aa.H())+":");var b=typeof this.B,a=a+(b+":"),a="number"===b?a+Gc(this.B):a+this.B;this.Bb=rc(a)}return this.Bb};h.Ca=function(){return this.B};h.pc=function(a){if(a===G)return 1;if(a instanceof P)return-1;H(a.J(),"Unknown node type");var b=typeof a.B,c=typeof this.B,d=Ia(Qd,b),e=Ia(Qd,c);H(0<=d,"Unknown leaf type: "+b);H(0<=e,"Unknown leaf type: "+c);return d===e?"object"===c?0:this.B<a.B?-1:this.B===a.B?0:1:e-d};
h.lb=function(){return this};h.vc=function(){return!0};h.Z=function(a){return a===this?!0:a.J()?this.B===a.B&&this.aa.Z(a.aa):!1};h.toString=function(){return B(this.H(!0))};function Sd(){}var Td={};function Md(a){return q(a.compare,a)}Sd.prototype.kd=function(a,b){return 0!==this.compare(new K("[MIN_NAME]",a),new K("[MIN_NAME]",b))};Sd.prototype.Ec=function(){return Ud};function Vd(a){H(!a.e()&&".priority"!==J(a),"Can't create PathIndex with empty path or .priority key");this.$b=a}la(Vd,Sd);h=Vd.prototype;h.uc=function(a){return!a.P(this.$b).e()};h.compare=function(a,b){var c=a.R.P(this.$b),d=b.R.P(this.$b),c=c.pc(d);return 0===c?ec(a.name,b.name):c};
h.Bc=function(a,b){var c=M(a),c=G.F(this.$b,c);return new K(b,c)};h.Cc=function(){var a=G.F(this.$b,Wd);return new K("[MAX_NAME]",a)};h.toString=function(){return this.$b.slice().join("/")};function Xd(){}la(Xd,Sd);h=Xd.prototype;h.compare=function(a,b){var c=a.R.C(),d=b.R.C(),c=c.pc(d);return 0===c?ec(a.name,b.name):c};h.uc=function(a){return!a.C().e()};h.kd=function(a,b){return!a.C().Z(b.C())};h.Ec=function(){return Ud};h.Cc=function(){return new K("[MAX_NAME]",new nc("[PRIORITY-POST]",Wd))};
h.Bc=function(a,b){var c=M(a);return new K(b,new nc("[PRIORITY-POST]",c))};h.toString=function(){return".priority"};var N=new Xd;function Yd(){}la(Yd,Sd);h=Yd.prototype;h.compare=function(a,b){return ec(a.name,b.name)};h.uc=function(){throw pc("KeyIndex.isDefinedOn not expected to be called.");};h.kd=function(){return!1};h.Ec=function(){return Ud};h.Cc=function(){return new K("[MAX_NAME]",G)};h.Bc=function(a){H(p(a),"KeyIndex indexValue must always be a string.");return new K(a,G)};h.toString=function(){return".key"};
var Cd=new Yd;function Zd(){}la(Zd,Sd);h=Zd.prototype;h.compare=function(a,b){var c=a.R.pc(b.R);return 0===c?ec(a.name,b.name):c};h.uc=function(){return!0};h.kd=function(a,b){return!a.Z(b)};h.Ec=function(){return Ud};h.Cc=function(){return $d};h.Bc=function(a,b){var c=M(a);return new K(b,c)};h.toString=function(){return".value"};var ae=new Zd;function be(){this.Pb=this.na=this.Ib=this.ka=this.xa=!1;this.oa=0;this.kb="";this.bc=null;this.xb="";this.Zb=null;this.vb="";this.g=N}var ce=new be;function Kd(a){return""===a.kb?a.ka:"l"===a.kb}function Gd(a){H(a.ka,"Only valid if start has been set");return a.bc}function Fd(a){H(a.ka,"Only valid if start has been set");return a.Ib?a.xb:"[MIN_NAME]"}function Id(a){H(a.na,"Only valid if end has been set");return a.Zb}
function Hd(a){H(a.na,"Only valid if end has been set");return a.Pb?a.vb:"[MAX_NAME]"}function de(a){var b=new be;b.xa=a.xa;b.oa=a.oa;b.ka=a.ka;b.bc=a.bc;b.Ib=a.Ib;b.xb=a.xb;b.na=a.na;b.Zb=a.Zb;b.Pb=a.Pb;b.vb=a.vb;b.g=a.g;b.kb=a.kb;return b}h=be.prototype;h.ie=function(a){var b=de(this);b.xa=!0;b.oa=a;b.kb="l";return b};h.je=function(a){var b=de(this);b.xa=!0;b.oa=a;b.kb="r";return b};h.Kd=function(a,b){var c=de(this);c.ka=!0;n(a)||(a=null);c.bc=a;null!=b?(c.Ib=!0,c.xb=b):(c.Ib=!1,c.xb="");return c};
h.dd=function(a,b){var c=de(this);c.na=!0;n(a)||(a=null);c.Zb=a;n(b)?(c.Pb=!0,c.vb=b):(c.yg=!1,c.vb="");return c};function ee(a,b){var c=de(a);c.g=b;return c}function fe(a){var b={};a.ka&&(b.sp=a.bc,a.Ib&&(b.sn=a.xb));a.na&&(b.ep=a.Zb,a.Pb&&(b.en=a.vb));if(a.xa){b.l=a.oa;var c=a.kb;""===c&&(c=Kd(a)?"l":"r");b.vf=c}a.g!==N&&(b.i=a.g.toString());return b}function S(a){return!(a.ka||a.na||a.xa)}function Pc(a){return S(a)&&a.g==N}
function Qc(a){var b={};if(Pc(a))return b;var c;a.g===N?c="$priority":a.g===ae?c="$value":a.g===Cd?c="$key":(H(a.g instanceof Vd,"Unrecognized index type!"),c=a.g.toString());b.orderBy=B(c);a.ka&&(b.startAt=B(a.bc),a.Ib&&(b.startAt+=","+B(a.xb)));a.na&&(b.endAt=B(a.Zb),a.Pb&&(b.endAt+=","+B(a.vb)));a.xa&&(Kd(a)?b.limitToFirst=a.oa:b.limitToLast=a.oa);return b}h.toString=function(){return B(fe(this))};function ge(a,b){this.ld=a;this.ac=b}ge.prototype.get=function(a){var b=w(this.ld,a);if(!b)throw Error("No index defined for "+a);return b===Td?null:b};function he(a,b,c){var d=pa(a.ld,function(d,f){var g=w(a.ac,f);H(g,"Missing index implementation for "+f);if(d===Td){if(g.uc(b.R)){for(var k=[],m=c.Ub(gc),l=R(m);l;)l.name!=b.name&&k.push(l),l=R(m);k.push(b);return ie(k,Md(g))}return Td}g=c.get(b.name);k=d;g&&(k=k.remove(new K(b.name,g)));return k.Na(b,b.R)});return new ge(d,a.ac)}
function je(a,b,c){var d=pa(a.ld,function(a){if(a===Td)return a;var d=c.get(b.name);return d?a.remove(new K(b.name,d)):a});return new ge(d,a.ac)}var ke=new ge({".priority":Td},{".priority":N});function le(){this.set={}}h=le.prototype;h.add=function(a,b){this.set[a]=null!==b?b:!0};h.contains=function(a){return $a(this.set,a)};h.get=function(a){return this.contains(a)?this.set[a]:void 0};h.remove=function(a){delete this.set[a]};h.clear=function(){this.set={}};h.e=function(){return ya(this.set)};h.count=function(){return ra(this.set)};function me(a,b){t(a.set,function(a,d){b(d,a)})}h.keys=function(){var a=[];t(this.set,function(b,c){a.push(c)});return a};function ne(a,b,c,d){this.Ud=a;this.f=vc(a);this.gc=b;this.nb=this.ob=0;this.Ua=Xc(b);this.sf=c;this.tc=!1;this.Ab=d;this.Vc=function(a){return Gb(b,"long_polling",a)}}var oe,pe;
ne.prototype.open=function(a,b){this.Je=0;this.ia=b;this.af=new ob(a);this.yb=!1;var c=this;this.qb=setTimeout(function(){c.f("Timed out trying to connect.");c.ab();c.qb=null},Math.floor(3E4));Ac(function(){if(!c.yb){c.Sa=new qe(function(a,b,d,k,m){re(c,arguments);if(c.Sa)if(c.qb&&(clearTimeout(c.qb),c.qb=null),c.tc=!0,"start"==a)c.id=b,c.dg=d;else if("close"===a)b?(c.Sa.of=!1,pb(c.af,b,function(){c.ab()})):c.ab();else throw Error("Unrecognized command received: "+a);},function(a,b){re(c,arguments);
qb(c.af,a,b)},function(){c.ab()},c.Vc);var a={start:"t"};a.ser=Math.floor(1E8*Math.random());c.Sa.qg&&(a.cb=c.Sa.qg);a.v="5";c.sf&&(a.s=c.sf);c.Ab&&(a.ls=c.Ab);a=c.Vc(a);c.f("Connecting via long-poll to "+a);se(c.Sa,a,function(){})}})};ne.prototype.start=function(){var a=this.Sa,b=this.dg;a.ke=this.id;a.$e=b;for(a.Qd=!0;te(a););};
ne.isAvailable=function(){return oe||!pe&&"undefined"!==typeof document&&null!=document.createElement&&!("object"===typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"===typeof Windows&&"object"===typeof Windows.sg)&&!1};h=ne.prototype;h.pd=function(){};h.Qc=function(){this.yb=!0;this.Sa&&(this.Sa.close(),this.Sa=null);this.Ze&&(document.body.removeChild(this.Ze),this.Ze=null);this.qb&&(clearTimeout(this.qb),this.qb=null)};
h.ab=function(){this.yb||(this.f("Longpoll is closing itself"),this.Qc(),this.ia&&(this.ia(this.tc),this.ia=null))};h.close=function(){this.yb||(this.f("Longpoll is being closed."),this.Qc())};h.send=function(a){a=B(a);this.ob+=a.length;Ib(this.Ua,"bytes_sent",a.length);a=jb(a);a=Za(a,!0);a=Ec(a,1840);for(var b=0;b<a.length;b++){var c=this.Sa;c.Nc.push({jg:this.Je,pg:a.length,Le:a[b]});c.Qd&&te(c);this.Je++}};function re(a,b){var c=B(b).length;a.nb+=c;Ib(a.Ua,"bytes_received",c)}
function qe(a,b,c,d){this.Vc=d;this.gb=c;this.re=new le;this.Nc=[];this.Wd=Math.floor(1E8*Math.random());this.of=!0;this.Ef=a;this.Wf=b}qe.prototype.close=function(){this.Qd=!1;if(this.rd){this.rd.ug.body.innerHTML="";var a=this;setTimeout(function(){null!==a.rd&&(document.body.removeChild(a.rd),a.rd=null)},Math.floor(0))}if(this.ke){var b={disconn:"t"};b.id=this.ke;b.pw=this.$e;b=this.Vc(b);ue(b)}if(b=this.gb)this.gb=null,b()};
function te(a){if(a.Qd&&a.of&&a.re.count()<(0<a.Nc.length?2:1)){a.Wd++;var b={};b.id=a.ke;b.pw=a.$e;b.ser=a.Wd;for(var b=a.Vc(b),c="",d=0;0<a.Nc.length;)if(1870>=a.Nc[0].Le.length+30+c.length){var e=a.Nc.shift(),c=c+"&seg"+d+"="+e.jg+"&ts"+d+"="+e.pg+"&d"+d+"="+e.Le;d++}else break;ve(a,b+c,a.Wd);return!0}return!1}function ve(a,b,c){function d(){a.re.remove(c);te(a)}a.re.add(c,1);var e=setTimeout(d,Math.floor(25E3));se(a,b,function(){clearTimeout(e);d()})}function se(a,b,c){we(a,b,c)}var xe=null;
function ue(a,b){xe||(xe=require("request"));xe(a,function(c,d,e){if(c)throw"Rest request for "+a.url+" failed.";b&&b(e)})}function we(a,b,c){ue({url:b,vg:!0},function(b){ye(a,b);c()})}function ye(a,b){eval("var jsonpCB = function(pLPCommand, pRTLPCB) {"+b+"}");jsonpCB(a.Ef,a.Wf)};function ze(a){Ae(this,a)}var Be=[ne,$c];function Ae(a,b){var c=$c&&$c.isAvailable(),d=c&&!(vb.We||!0===vb.get("previous_websocket_failure"));b.rg&&(c||O("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),d=!0);if(d)a.Tc=[$c];else{var e=a.Tc=[];Fc(Be,function(a,b){b&&b.isAvailable()&&e.push(b)})}}function Ce(a){if(0<a.Tc.length)return a.Tc[0];throw Error("No transports available");};function De(a,b,c,d,e,f,g){this.id=a;this.f=vc("c:"+this.id+":");this.pe=c;this.Ic=d;this.ia=e;this.oe=f;this.L=b;this.yd=[];this.He=0;this.rf=new ze(b);this.Ta=0;this.Ab=g;this.f("Connection created");Ee(this)}
function Ee(a){var b=Ce(a.rf);a.I=new b("c:"+a.id+":"+a.He++,a.L,void 0,a.Ab);a.te=b.responsesRequiredToBeHealthy||0;var c=Fe(a,a.I),d=Ge(a,a.I);a.Uc=a.I;a.Oc=a.I;a.D=null;a.zb=!1;setTimeout(function(){a.I&&a.I.open(c,d)},Math.floor(0));b=b.healthyTimeout||0;0<b&&(a.jd=Jc(function(){a.jd=null;a.zb||(a.I&&102400<a.I.nb?(a.f("Connection exceeded healthy timeout but has received "+a.I.nb+" bytes.  Marking connection healthy."),a.zb=!0,a.I.pd()):a.I&&10240<a.I.ob?a.f("Connection exceeded healthy timeout but has sent "+
a.I.ob+" bytes.  Leaving connection alive."):(a.f("Closing unhealthy connection after timeout."),a.close()))},Math.floor(b)))}function Ge(a,b){return function(c){b===a.I?(a.I=null,c||0!==a.Ta?1===a.Ta&&a.f("Realtime connection lost."):(a.f("Realtime connection failed."),"s-"===a.L.Za.substr(0,2)&&(vb.remove("host:"+a.L.host),a.L.Za=a.L.host)),a.close()):b===a.D?(a.f("Secondary connection lost."),c=a.D,a.D=null,a.Uc!==c&&a.Oc!==c||a.close()):a.f("closing an old connection")}}
function Fe(a,b){return function(c){if(2!=a.Ta)if(b===a.Oc){var d=Cc("t",c);c=Cc("d",c);if("c"==d){if(d=Cc("t",c),"d"in c)if(c=c.d,"h"===d){var d=c.ts,e=c.v,f=c.h;a.pf=c.s;Fb(a.L,f);0==a.Ta&&(a.I.start(),He(a,a.I,d),"5"!==e&&O("Protocol version mismatch detected"),c=a.rf,(c=1<c.Tc.length?c.Tc[1]:null)&&Ie(a,c))}else if("n"===d){a.f("recvd end transmission on primary");a.Oc=a.D;for(c=0;c<a.yd.length;++c)a.ud(a.yd[c]);a.yd=[];Je(a)}else"s"===d?(a.f("Connection shutdown command received. Shutting down..."),
a.oe&&(a.oe(c),a.oe=null),a.ia=null,a.close()):"r"===d?(a.f("Reset packet received.  New host: "+c),Fb(a.L,c),1===a.Ta?a.close():(Ke(a),Ee(a))):"e"===d?wc("Server Error: "+c):"o"===d?(a.f("got pong on primary."),Le(a),Me(a)):wc("Unknown control packet command: "+d)}else"d"==d&&a.ud(c)}else if(b===a.D)if(d=Cc("t",c),c=Cc("d",c),"c"==d)"t"in c&&(c=c.t,"a"===c?Ne(a):"r"===c?(a.f("Got a reset on secondary, closing it"),a.D.close(),a.Uc!==a.D&&a.Oc!==a.D||a.close()):"o"===c&&(a.f("got pong on secondary."),
a.nf--,Ne(a)));else if("d"==d)a.yd.push(c);else throw Error("Unknown protocol layer: "+d);else a.f("message on old connection")}}De.prototype.ua=function(a){Oe(this,{t:"d",d:a})};function Je(a){a.Uc===a.D&&a.Oc===a.D&&(a.f("cleaning up and promoting a connection: "+a.D.Ud),a.I=a.D,a.D=null)}
function Ne(a){0>=a.nf?(a.f("Secondary connection is healthy."),a.zb=!0,a.D.pd(),a.D.start(),a.f("sending client ack on secondary"),a.D.send({t:"c",d:{t:"a",d:{}}}),a.f("Ending transmission on primary"),a.I.send({t:"c",d:{t:"n",d:{}}}),a.Uc=a.D,Je(a)):(a.f("sending ping on secondary."),a.D.send({t:"c",d:{t:"p",d:{}}}))}De.prototype.ud=function(a){Le(this);this.pe(a)};function Le(a){a.zb||(a.te--,0>=a.te&&(a.f("Primary connection is healthy."),a.zb=!0,a.I.pd()))}
function Ie(a,b){a.D=new b("c:"+a.id+":"+a.He++,a.L,a.pf);a.nf=b.responsesRequiredToBeHealthy||0;a.D.open(Fe(a,a.D),Ge(a,a.D));Jc(function(){a.D&&(a.f("Timed out trying to upgrade."),a.D.close())},Math.floor(6E4))}function He(a,b,c){a.f("Realtime connection established.");a.I=b;a.Ta=1;a.Ic&&(a.Ic(c,a.pf),a.Ic=null);0===a.te?(a.f("Primary connection is healthy."),a.zb=!0):Jc(function(){Me(a)},Math.floor(5E3))}
function Me(a){a.zb||1!==a.Ta||(a.f("sending ping on primary."),Oe(a,{t:"c",d:{t:"p",d:{}}}))}function Oe(a,b){if(1!==a.Ta)throw"Connection is not connected";a.Uc.send(b)}De.prototype.close=function(){2!==this.Ta&&(this.f("Closing realtime connection."),this.Ta=2,Ke(this),this.ia&&(this.ia(),this.ia=null))};function Ke(a){a.f("Shutting down all connections");a.I&&(a.I.close(),a.I=null);a.D&&(a.D.close(),a.D=null);a.jd&&(clearTimeout(a.jd),a.jd=null)};function L(a,b){if(1==arguments.length){this.o=a.split("/");for(var c=0,d=0;d<this.o.length;d++)0<this.o[d].length&&(this.o[c]=this.o[d],c++);this.o.length=c;this.Y=0}else this.o=a,this.Y=b}function T(a,b){var c=J(a);if(null===c)return b;if(c===J(b))return T(D(a),D(b));throw Error("INTERNAL ERROR: innerPath ("+b+") is not within outerPath ("+a+")");}
function Pe(a,b){for(var c=a.slice(),d=b.slice(),e=0;e<c.length&&e<d.length;e++){var f=ec(c[e],d[e]);if(0!==f)return f}return c.length===d.length?0:c.length<d.length?-1:1}function J(a){return a.Y>=a.o.length?null:a.o[a.Y]}function xd(a){return a.o.length-a.Y}function D(a){var b=a.Y;b<a.o.length&&b++;return new L(a.o,b)}function yd(a){return a.Y<a.o.length?a.o[a.o.length-1]:null}h=L.prototype;
h.toString=function(){for(var a="",b=this.Y;b<this.o.length;b++)""!==this.o[b]&&(a+="/"+this.o[b]);return a||"/"};h.slice=function(a){return this.o.slice(this.Y+(a||0))};h.parent=function(){if(this.Y>=this.o.length)return null;for(var a=[],b=this.Y;b<this.o.length-1;b++)a.push(this.o[b]);return new L(a,0)};
h.n=function(a){for(var b=[],c=this.Y;c<this.o.length;c++)b.push(this.o[c]);if(a instanceof L)for(c=a.Y;c<a.o.length;c++)b.push(a.o[c]);else for(a=a.split("/"),c=0;c<a.length;c++)0<a[c].length&&b.push(a[c]);return new L(b,0)};h.e=function(){return this.Y>=this.o.length};h.Z=function(a){if(xd(this)!==xd(a))return!1;for(var b=this.Y,c=a.Y;b<=this.o.length;b++,c++)if(this.o[b]!==a.o[c])return!1;return!0};
h.contains=function(a){var b=this.Y,c=a.Y;if(xd(this)>xd(a))return!1;for(;b<this.o.length;){if(this.o[b]!==a.o[c])return!1;++b;++c}return!0};var C=new L("");function Qe(a,b){this.Pa=a.slice();this.Ga=Math.max(1,this.Pa.length);this.Me=b;for(var c=0;c<this.Pa.length;c++)this.Ga+=kb(this.Pa[c]);Re(this)}Qe.prototype.push=function(a){0<this.Pa.length&&(this.Ga+=1);this.Pa.push(a);this.Ga+=kb(a);Re(this)};Qe.prototype.pop=function(){var a=this.Pa.pop();this.Ga-=kb(a);0<this.Pa.length&&--this.Ga};
function Re(a){if(768<a.Ga)throw Error(a.Me+"has a key path longer than 768 bytes ("+a.Ga+").");if(32<a.Pa.length)throw Error(a.Me+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Se(a));}function Se(a){return 0==a.Pa.length?"":"in property '"+a.Pa.join(".")+"'"};function Te(a){a instanceof Ue||xc("Don't call new Database() directly - please use firebase.database().");this.ta=a;this.ba=new U(a,C);this.INTERNAL=new Ve(this)}var We={TIMESTAMP:{".sv":"timestamp"}};h=Te.prototype;h.app=null;h.gf=function(a){Xe(this,"ref");x("database.ref",0,1,arguments.length);return n(a)?this.ba.n(a):this.ba};
h.gg=function(a){Xe(this,"database.refFromURL");x("database.refFromURL",1,1,arguments.length);var b=yc(a);Ye("database.refFromURL",b);var c=b.gc;c.host!==this.ta.L.host&&xc("database.refFromURL: Host name does not match the current database: (found "+c.host+" but expected "+this.ta.L.host+")");return this.gf(b.path.toString())};function Xe(a,b){null===a.ta&&xc("Cannot call "+b+" on a deleted database.")}h.Pf=function(){x("database.goOffline",0,0,arguments.length);Xe(this,"goOffline");this.ta.$a()};
h.Qf=function(){x("database.goOnline",0,0,arguments.length);Xe(this,"goOnline");this.ta.hc()};Object.defineProperty(Te.prototype,"app",{get:function(){return this.ta.app}});function Ve(a){this.Xa=a}Ve.prototype.delete=function(){Xe(this.Xa,"delete");var a=Ze.Tb(),b=this.Xa.ta;w(a.jb,b.app.name)!==b&&xc("Database "+b.app.name+" has already been deleted.");b.$a();delete a.jb[b.app.name];this.Xa.ta=null;this.Xa.ba=null;this.Xa=this.Xa.INTERNAL=null;return firebase.Promise.resolve()};
Te.prototype.ref=Te.prototype.gf;Te.prototype.refFromURL=Te.prototype.gg;Te.prototype.goOnline=Te.prototype.Qf;Te.prototype.goOffline=Te.prototype.Pf;Ve.prototype["delete"]=Ve.prototype.delete;function jc(){this.k=this.B=null}jc.prototype.find=function(a){if(null!=this.B)return this.B.P(a);if(a.e()||null==this.k)return null;var b=J(a);a=D(a);return this.k.contains(b)?this.k.get(b).find(a):null};function lc(a,b,c){if(b.e())a.B=c,a.k=null;else if(null!==a.B)a.B=a.B.F(b,c);else{null==a.k&&(a.k=new le);var d=J(b);a.k.contains(d)||a.k.add(d,new jc);a=a.k.get(d);b=D(b);lc(a,b,c)}}
function $e(a,b){if(b.e())return a.B=null,a.k=null,!0;if(null!==a.B){if(a.B.J())return!1;var c=a.B;a.B=null;c.O(N,function(b,c){lc(a,new L(b),c)});return $e(a,b)}return null!==a.k?(c=J(b),b=D(b),a.k.contains(c)&&$e(a.k.get(c),b)&&a.k.remove(c),a.k.e()?(a.k=null,!0):!1):!0}function kc(a,b,c){null!==a.B?c(b,a.B):a.O(function(a,e){var f=new L(b.toString()+"/"+a);kc(e,f,c)})}jc.prototype.O=function(a){null!==this.k&&me(this.k,function(b,c){a(b,c)})};var af=/[\[\].#$\/\u0000-\u001F\u007F]/,bf=/[\[\].#$\u0000-\u001F\u007F]/;function cf(a){return p(a)&&0!==a.length&&!af.test(a)}function df(a){return null===a||p(a)||ga(a)&&!zc(a)||ia(a)&&$a(a,".sv")}function ef(a,b,c,d){d&&!n(b)||ff(z(a,1,d),b,c)}
function ff(a,b,c){c instanceof L&&(c=new Qe(c,a));if(!n(b))throw Error(a+"contains undefined "+Se(c));if(ha(b))throw Error(a+"contains a function "+Se(c)+" with contents: "+b.toString());if(zc(b))throw Error(a+"contains "+b.toString()+" "+Se(c));if(p(b)&&b.length>10485760/3&&10485760<kb(b))throw Error(a+"contains a string greater than 10485760 utf8 bytes "+Se(c)+" ('"+b.substring(0,50)+"...')");if(ia(b)){var d=!1,e=!1;ab(b,function(b,g){if(".value"===b)d=!0;else if(".priority"!==b&&".sv"!==b&&(e=
!0,!cf(b)))throw Error(a+" contains an invalid key ("+b+") "+Se(c)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');c.push(b);ff(a,g,c);c.pop()});if(d&&e)throw Error(a+' contains ".value" child '+Se(c)+" in addition to actual children.");}}
function gf(a,b){var c,d;for(c=0;c<b.length;c++){d=b[c];for(var e=d.slice(),f=0;f<e.length;f++)if((".priority"!==e[f]||f!==e.length-1)&&!cf(e[f]))throw Error(a+"contains an invalid key ("+e[f]+") in path "+d.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');}b.sort(Pe);e=null;for(c=0;c<b.length;c++){d=b[c];if(null!==e&&e.contains(d))throw Error(a+"contains a path "+e.toString()+" that is ancestor of another path "+d.toString());e=d}}
function hf(a,b,c){var d=z(a,1,!1);if(!ia(b)||ea(b))throw Error(d+" must be an object containing the children to replace.");var e=[];ab(b,function(a,b){var k=new L(a);ff(d,b,c.n(k));if(".priority"===yd(k)&&!df(b))throw Error(d+"contains an invalid value for '"+k.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");e.push(k)});gf(d,e)}
function jf(a,b,c){if(zc(c))throw Error(z(a,b,!1)+"is "+c.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!df(c))throw Error(z(a,b,!1)+"must be a valid Firebase priority (a string, finite number, server value, or null).");}
function kf(a,b,c){if(!c||n(b))switch(b){case "value":case "child_added":case "child_removed":case "child_changed":case "child_moved":break;default:throw Error(z(a,1,c)+'must be a valid event type: "value", "child_added", "child_removed", "child_changed", or "child_moved".');}}function lf(a,b){if(n(b)&&!cf(b))throw Error(z(a,2,!0)+'was an invalid key: "'+b+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").');}
function mf(a,b){if(!p(b)||0===b.length||bf.test(b))throw Error(z(a,1,!1)+'was an invalid path: "'+b+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"');}function nf(a,b){if(".info"===J(b))throw Error(a+" failed: Can't modify data under /.info/");}
function Ye(a,b){var c=b.path.toString(),d;!(d=!p(b.gc.host)||0===b.gc.host.length||!cf(b.gc.le))&&(d=0!==c.length)&&(c&&(c=c.replace(/^\/*\.info(\/|$)/,"/")),d=!(p(c)&&0!==c.length&&!bf.test(c)));if(d)throw Error(z(a,1,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".');};function V(a,b){this.ta=a;this.qa=b}V.prototype.cancel=function(a){x("Firebase.onDisconnect().cancel",0,1,arguments.length);A("Firebase.onDisconnect().cancel",1,a,!0);var b=new eb;this.ta.vd(this.qa,fb(b,a));return b.ra};V.prototype.cancel=V.prototype.cancel;V.prototype.remove=function(a){x("Firebase.onDisconnect().remove",0,1,arguments.length);nf("Firebase.onDisconnect().remove",this.qa);A("Firebase.onDisconnect().remove",1,a,!0);var b=new eb;of(this.ta,this.qa,null,fb(b,a));return b.ra};
V.prototype.remove=V.prototype.remove;V.prototype.set=function(a,b){x("Firebase.onDisconnect().set",1,2,arguments.length);nf("Firebase.onDisconnect().set",this.qa);ef("Firebase.onDisconnect().set",a,this.qa,!1);A("Firebase.onDisconnect().set",2,b,!0);var c=new eb;of(this.ta,this.qa,a,fb(c,b));return c.ra};V.prototype.set=V.prototype.set;
V.prototype.Hb=function(a,b,c){x("Firebase.onDisconnect().setWithPriority",2,3,arguments.length);nf("Firebase.onDisconnect().setWithPriority",this.qa);ef("Firebase.onDisconnect().setWithPriority",a,this.qa,!1);jf("Firebase.onDisconnect().setWithPriority",2,b);A("Firebase.onDisconnect().setWithPriority",3,c,!0);var d=new eb;pf(this.ta,this.qa,a,b,fb(d,c));return d.ra};V.prototype.setWithPriority=V.prototype.Hb;
V.prototype.update=function(a,b){x("Firebase.onDisconnect().update",1,2,arguments.length);nf("Firebase.onDisconnect().update",this.qa);if(ea(a)){for(var c={},d=0;d<a.length;++d)c[""+d]=a[d];a=c;O("Passing an Array to Firebase.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}hf("Firebase.onDisconnect().update",a,this.qa);A("Firebase.onDisconnect().update",2,b,!0);
c=new eb;qf(this.ta,this.qa,a,fb(c,b));return c.ra};V.prototype.update=V.prototype.update;function rf(a){H(ea(a)&&0<a.length,"Requires a non-empty array");this.Af=a;this.Ac={}}rf.prototype.Ce=function(a,b){var c;c=this.Ac[a]||[];var d=c.length;if(0<d){for(var e=Array(d),f=0;f<d;f++)e[f]=c[f];c=e}else c=[];for(d=0;d<c.length;d++)c[d].Fe.apply(c[d].La,Array.prototype.slice.call(arguments,1))};rf.prototype.dc=function(a,b,c){sf(this,a);this.Ac[a]=this.Ac[a]||[];this.Ac[a].push({Fe:b,La:c});(a=this.Re(a))&&b.apply(c,a)};
rf.prototype.Fc=function(a,b,c){sf(this,a);a=this.Ac[a]||[];for(var d=0;d<a.length;d++)if(a[d].Fe===b&&(!c||c===a[d].La)){a.splice(d,1);break}};function sf(a,b){H(Oa(a.Af,function(a){return a===b}),"Unknown event: "+b)};function tf(){rf.call(this,["online"]);this.ec=!0;if("undefined"!==typeof window&&"undefined"!==typeof window.addEventListener&&!nb()){var a=this;window.addEventListener("online",function(){a.ec||(a.ec=!0,a.Ce("online",!0))},!1);window.addEventListener("offline",function(){a.ec&&(a.ec=!1,a.Ce("online",!1))},!1)}}la(tf,rf);tf.prototype.Re=function(a){H("online"===a,"Unknown event type: "+a);return[this.ec]};ca(tf);function uf(){rf.call(this,["visible"]);var a,b;"undefined"!==typeof document&&"undefined"!==typeof document.addEventListener&&("undefined"!==typeof document.hidden?(b="visibilitychange",a="hidden"):"undefined"!==typeof document.mozHidden?(b="mozvisibilitychange",a="mozHidden"):"undefined"!==typeof document.msHidden?(b="msvisibilitychange",a="msHidden"):"undefined"!==typeof document.webkitHidden&&(b="webkitvisibilitychange",a="webkitHidden"));this.Kb=!0;if(b){var c=this;document.addEventListener(b,
function(){var b=!document[a];b!==c.Kb&&(c.Kb=b,c.Ce("visible",b))},!1)}}la(uf,rf);uf.prototype.Re=function(a){H("visible"===a,"Unknown event type: "+a);return[this.Kb]};ca(uf);var vf=function(){var a=0,b=[];return function(c){var d=c===a;a=c;for(var e=Array(8),f=7;0<=f;f--)e[f]="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c%64),c=Math.floor(c/64);H(0===c,"Cannot push at time == 0");c=e.join("");if(d){for(f=11;0<=f&&63===b[f];f--)b[f]=0;b[f]++}else for(f=0;12>f;f++)b[f]=Math.floor(64*Math.random());for(f=0;12>f;f++)c+="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]);H(20===c.length,"nextPushId: Length should be 20.");
return c}}();function wf(a,b){this.Ka=a;this.ba=b?b:xf}h=wf.prototype;h.Na=function(a,b){return new wf(this.Ka,this.ba.Na(a,b,this.Ka).X(null,null,!1,null,null))};h.remove=function(a){return new wf(this.Ka,this.ba.remove(a,this.Ka).X(null,null,!1,null,null))};h.get=function(a){for(var b,c=this.ba;!c.e();){b=this.Ka(a,c.key);if(0===b)return c.value;0>b?c=c.left:0<b&&(c=c.right)}return null};
function yf(a,b){for(var c,d=a.ba,e=null;!d.e();){c=a.Ka(b,d.key);if(0===c){if(d.left.e())return e?e.key:null;for(d=d.left;!d.right.e();)d=d.right;return d.key}0>c?d=d.left:0<c&&(e=d,d=d.right)}throw Error("Attempted to find predecessor key for a nonexistent key.  What gives?");}h.e=function(){return this.ba.e()};h.count=function(){return this.ba.count()};h.Dc=function(){return this.ba.Dc()};h.cc=function(){return this.ba.cc()};h.ha=function(a){return this.ba.ha(a)};
h.Ub=function(a){return new zf(this.ba,null,this.Ka,!1,a)};h.Vb=function(a,b){return new zf(this.ba,a,this.Ka,!1,b)};h.Xb=function(a,b){return new zf(this.ba,a,this.Ka,!0,b)};h.Te=function(a){return new zf(this.ba,null,this.Ka,!0,a)};function zf(a,b,c,d,e){this.Fd=e||null;this.ge=d;this.Oa=[];for(e=1;!a.e();)if(e=b?c(a.key,b):1,d&&(e*=-1),0>e)a=this.ge?a.left:a.right;else if(0===e){this.Oa.push(a);break}else this.Oa.push(a),a=this.ge?a.right:a.left}
function R(a){if(0===a.Oa.length)return null;var b=a.Oa.pop(),c;c=a.Fd?a.Fd(b.key,b.value):{key:b.key,value:b.value};if(a.ge)for(b=b.left;!b.e();)a.Oa.push(b),b=b.right;else for(b=b.right;!b.e();)a.Oa.push(b),b=b.left;return c}function Af(a){if(0===a.Oa.length)return null;var b;b=a.Oa;b=b[b.length-1];return a.Fd?a.Fd(b.key,b.value):{key:b.key,value:b.value}}function Bf(a,b,c,d,e){this.key=a;this.value=b;this.color=null!=c?c:!0;this.left=null!=d?d:xf;this.right=null!=e?e:xf}h=Bf.prototype;
h.X=function(a,b,c,d,e){return new Bf(null!=a?a:this.key,null!=b?b:this.value,null!=c?c:this.color,null!=d?d:this.left,null!=e?e:this.right)};h.count=function(){return this.left.count()+1+this.right.count()};h.e=function(){return!1};h.ha=function(a){return this.left.ha(a)||a(this.key,this.value)||this.right.ha(a)};function Cf(a){return a.left.e()?a:Cf(a.left)}h.Dc=function(){return Cf(this).key};h.cc=function(){return this.right.e()?this.key:this.right.cc()};
h.Na=function(a,b,c){var d,e;e=this;d=c(a,e.key);e=0>d?e.X(null,null,null,e.left.Na(a,b,c),null):0===d?e.X(null,b,null,null,null):e.X(null,null,null,null,e.right.Na(a,b,c));return Df(e)};function Ef(a){if(a.left.e())return xf;a.left.ea()||a.left.left.ea()||(a=Ff(a));a=a.X(null,null,null,Ef(a.left),null);return Df(a)}
h.remove=function(a,b){var c,d;c=this;if(0>b(a,c.key))c.left.e()||c.left.ea()||c.left.left.ea()||(c=Ff(c)),c=c.X(null,null,null,c.left.remove(a,b),null);else{c.left.ea()&&(c=Gf(c));c.right.e()||c.right.ea()||c.right.left.ea()||(c=Hf(c),c.left.left.ea()&&(c=Gf(c),c=Hf(c)));if(0===b(a,c.key)){if(c.right.e())return xf;d=Cf(c.right);c=c.X(d.key,d.value,null,null,Ef(c.right))}c=c.X(null,null,null,null,c.right.remove(a,b))}return Df(c)};h.ea=function(){return this.color};
function Df(a){a.right.ea()&&!a.left.ea()&&(a=If(a));a.left.ea()&&a.left.left.ea()&&(a=Gf(a));a.left.ea()&&a.right.ea()&&(a=Hf(a));return a}function Ff(a){a=Hf(a);a.right.left.ea()&&(a=a.X(null,null,null,null,Gf(a.right)),a=If(a),a=Hf(a));return a}function If(a){return a.right.X(null,null,a.color,a.X(null,null,!0,null,a.right.left),null)}function Gf(a){return a.left.X(null,null,a.color,null,a.X(null,null,!0,a.left.right,null))}
function Hf(a){return a.X(null,null,!a.color,a.left.X(null,null,!a.left.color,null,null),a.right.X(null,null,!a.right.color,null,null))}function Jf(){}h=Jf.prototype;h.X=function(){return this};h.Na=function(a,b){return new Bf(a,b,null)};h.remove=function(){return this};h.count=function(){return 0};h.e=function(){return!0};h.ha=function(){return!1};h.Dc=function(){return null};h.cc=function(){return null};h.ea=function(){return!1};var xf=new Jf;function P(a,b,c){this.k=a;(this.aa=b)&&Pd(this.aa);a.e()&&H(!this.aa||this.aa.e(),"An empty node cannot have a priority");this.wb=c;this.Bb=null}h=P.prototype;h.J=function(){return!1};h.C=function(){return this.aa||G};h.fa=function(a){return this.k.e()?this:new P(this.k,a,this.wb)};h.Q=function(a){if(".priority"===a)return this.C();a=this.k.get(a);return null===a?G:a};h.P=function(a){var b=J(a);return null===b?this:this.Q(b).P(D(a))};h.Da=function(a){return null!==this.k.get(a)};
h.T=function(a,b){H(b,"We should always be passing snapshot nodes");if(".priority"===a)return this.fa(b);var c=new K(a,b),d,e;b.e()?(d=this.k.remove(a),c=je(this.wb,c,this.k)):(d=this.k.Na(a,b),c=he(this.wb,c,this.k));e=d.e()?G:this.aa;return new P(d,e,c)};h.F=function(a,b){var c=J(a);if(null===c)return b;H(".priority"!==J(a)||1===xd(a),".priority must be the last token in a path");var d=this.Q(c).F(D(a),b);return this.T(c,d)};h.e=function(){return this.k.e()};h.Cb=function(){return this.k.count()};
var Kf=/^(0|[1-9]\d*)$/;h=P.prototype;h.H=function(a){if(this.e())return null;var b={},c=0,d=0,e=!0;this.O(N,function(f,g){b[f]=g.H(a);c++;e&&Kf.test(f)?d=Math.max(d,Number(f)):e=!1});if(!a&&e&&d<2*c){var f=[],g;for(g in b)f[g]=b[g];return f}a&&!this.C().e()&&(b[".priority"]=this.C().H());return b};h.hash=function(){if(null===this.Bb){var a="";this.C().e()||(a+="priority:"+Rd(this.C().H())+":");this.O(N,function(b,c){var d=c.hash();""!==d&&(a+=":"+b+":"+d)});this.Bb=""===a?"":rc(a)}return this.Bb};
h.Se=function(a,b,c){return(c=Lf(this,c))?(a=yf(c,new K(a,b)))?a.name:null:yf(this.k,a)};function Nd(a,b){var c;c=(c=Lf(a,b))?(c=c.Dc())&&c.name:a.k.Dc();return c?new K(c,a.k.get(c)):null}function Od(a,b){var c;c=(c=Lf(a,b))?(c=c.cc())&&c.name:a.k.cc();return c?new K(c,a.k.get(c)):null}h.O=function(a,b){var c=Lf(this,a);return c?c.ha(function(a){return b(a.name,a.R)}):this.k.ha(b)};h.Ub=function(a){return this.Vb(a.Ec(),a)};
h.Vb=function(a,b){var c=Lf(this,b);if(c)return c.Vb(a,function(a){return a});for(var c=this.k.Vb(a.name,gc),d=Af(c);null!=d&&0>b.compare(d,a);)R(c),d=Af(c);return c};h.Te=function(a){return this.Xb(a.Cc(),a)};h.Xb=function(a,b){var c=Lf(this,b);if(c)return c.Xb(a,function(a){return a});for(var c=this.k.Xb(a.name,gc),d=Af(c);null!=d&&0<b.compare(d,a);)R(c),d=Af(c);return c};h.pc=function(a){return this.e()?a.e()?0:-1:a.J()||a.e()?1:a===Wd?-1:0};
h.lb=function(a){if(a===Cd||va(this.wb.ac,a.toString()))return this;var b=this.wb,c=this.k;H(a!==Cd,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var d=[],e=!1,c=c.Ub(gc),f=R(c);f;)e=e||a.uc(f.R),d.push(f),f=R(c);d=e?ie(d,Md(a)):Td;e=a.toString();c=za(b.ac);c[e]=a;a=za(b.ld);a[e]=d;return new P(this.k,this.aa,new ge(a,c))};h.vc=function(a){return a===Cd||va(this.wb.ac,a.toString())};
h.Z=function(a){if(a===this)return!0;if(a.J())return!1;if(this.C().Z(a.C())&&this.k.count()===a.k.count()){var b=this.Ub(N);a=a.Ub(N);for(var c=R(b),d=R(a);c&&d;){if(c.name!==d.name||!c.R.Z(d.R))return!1;c=R(b);d=R(a)}return null===c&&null===d}return!1};function Lf(a,b){return b===Cd?null:a.wb.get(b.toString())}h.toString=function(){return B(this.H(!0))};function M(a,b){if(null===a)return G;var c=null;"object"===typeof a&&".priority"in a?c=a[".priority"]:"undefined"!==typeof b&&(c=b);H(null===c||"string"===typeof c||"number"===typeof c||"object"===typeof c&&".sv"in c,"Invalid priority type found: "+typeof c);"object"===typeof a&&".value"in a&&null!==a[".value"]&&(a=a[".value"]);if("object"!==typeof a||".sv"in a)return new nc(a,M(c));if(a instanceof Array){var d=G,e=a;t(e,function(a,b){if($a(e,b)&&"."!==b.substring(0,1)){var c=M(a);if(c.J()||!c.e())d=
d.T(b,c)}});return d.fa(M(c))}var f=[],g=!1,k=a;ab(k,function(a){if("string"!==typeof a||"."!==a.substring(0,1)){var b=M(k[a]);b.e()||(g=g||!b.C().e(),f.push(new K(a,b)))}});if(0==f.length)return G;var m=ie(f,dc,function(a){return a.name},fc);if(g){var l=ie(f,Md(N));return new P(m,M(c),new ge({".priority":l},{".priority":N}))}return new P(m,M(c),ke)}var Mf=Math.log(2);
function Nf(a){this.count=parseInt(Math.log(a+1)/Mf,10);this.Ke=this.count-1;this.Bf=a+1&parseInt(Array(this.count+1).join("1"),2)}function Of(a){var b=!(a.Bf&1<<a.Ke);a.Ke--;return b}
function ie(a,b,c,d){function e(b,d){var f=d-b;if(0==f)return null;if(1==f){var l=a[b],r=c?c(l):l;return new Bf(r,l.R,!1,null,null)}var l=parseInt(f/2,10)+b,f=e(b,l),y=e(l+1,d),l=a[l],r=c?c(l):l;return new Bf(r,l.R,!1,f,y)}a.sort(b);var f=function(b){function d(b,g){var k=r-b,y=r;r-=b;var y=e(k+1,y),k=a[k],F=c?c(k):k,y=new Bf(F,k.R,g,null,y);f?f.left=y:l=y;f=y}for(var f=null,l=null,r=a.length,y=0;y<b.count;++y){var F=Of(b),hd=Math.pow(2,b.count-(y+1));F?d(hd,!1):(d(hd,!1),d(hd,!0))}return l}(new Nf(a.length));
return null!==f?new wf(d||b,f):new wf(d||b)}function Rd(a){return"number"===typeof a?"number:"+Gc(a):"string:"+a}function Pd(a){if(a.J()){var b=a.H();H("string"===typeof b||"number"===typeof b||"object"===typeof b&&$a(b,".sv"),"Priority must be a string or number.")}else H(a===Wd||a.e(),"priority of unexpected type.");H(a===Wd||a.C().e(),"Priority nodes can't have a priority of their own.")}var G=new P(new wf(fc),null,ke);function Pf(){P.call(this,new wf(fc),G,ke)}la(Pf,P);h=Pf.prototype;
h.pc=function(a){return a===this?0:1};h.Z=function(a){return a===this};h.C=function(){return this};h.Q=function(){return G};h.e=function(){return!1};var Wd=new Pf,Ud=new K("[MIN_NAME]",G),$d=new K("[MAX_NAME]",Wd);function W(a,b,c){this.A=a;this.V=b;this.g=c}W.prototype.H=function(){x("Firebase.DataSnapshot.val",0,0,arguments.length);return this.A.H()};W.prototype.val=W.prototype.H;W.prototype.Ne=function(){x("Firebase.DataSnapshot.exportVal",0,0,arguments.length);return this.A.H(!0)};W.prototype.exportVal=W.prototype.Ne;W.prototype.Lf=function(){x("Firebase.DataSnapshot.exists",0,0,arguments.length);return!this.A.e()};W.prototype.exists=W.prototype.Lf;
W.prototype.n=function(a){x("Firebase.DataSnapshot.child",0,1,arguments.length);ga(a)&&(a=String(a));mf("Firebase.DataSnapshot.child",a);var b=new L(a),c=this.V.n(b);return new W(this.A.P(b),c,N)};W.prototype.child=W.prototype.n;W.prototype.Da=function(a){x("Firebase.DataSnapshot.hasChild",1,1,arguments.length);mf("Firebase.DataSnapshot.hasChild",a);var b=new L(a);return!this.A.P(b).e()};W.prototype.hasChild=W.prototype.Da;
W.prototype.C=function(){x("Firebase.DataSnapshot.getPriority",0,0,arguments.length);return this.A.C().H()};W.prototype.getPriority=W.prototype.C;W.prototype.forEach=function(a){x("Firebase.DataSnapshot.forEach",1,1,arguments.length);A("Firebase.DataSnapshot.forEach",1,a,!1);if(this.A.J())return!1;var b=this;return!!this.A.O(this.g,function(c,d){return a(new W(d,b.V.n(c),N))})};W.prototype.forEach=W.prototype.forEach;
W.prototype.gd=function(){x("Firebase.DataSnapshot.hasChildren",0,0,arguments.length);return this.A.J()?!1:!this.A.e()};W.prototype.hasChildren=W.prototype.gd;W.prototype.getKey=function(){x("Firebase.DataSnapshot.key",0,0,arguments.length);return this.V.getKey()};Ic(W.prototype,"key",W.prototype.getKey);W.prototype.Cb=function(){x("Firebase.DataSnapshot.numChildren",0,0,arguments.length);return this.A.Cb()};W.prototype.numChildren=W.prototype.Cb;
W.prototype.ub=function(){x("Firebase.DataSnapshot.ref",0,0,arguments.length);return this.V};Ic(W.prototype,"ref",W.prototype.ub);function vd(a,b){this.N=a;this.Id=b}function sd(a,b,c,d){return new vd(new Xb(b,c,d),a.Id)}function wd(a){return a.N.da?a.N.j():null}vd.prototype.w=function(){return this.Id};function Yb(a){return a.Id.da?a.Id.j():null};function Qf(a,b){this.V=a;var c=a.m,d=new Dd(c.g),c=S(c)?new Dd(c.g):c.xa?new Jd(c):new Ed(c);this.ff=new md(c);var e=b.w(),f=b.N,g=d.ya(G,e.j(),null),k=c.ya(G,f.j(),null);this.Ja=new vd(new Xb(k,f.da,c.Ma()),new Xb(g,e.da,d.Ma()));this.Ya=[];this.Jf=new gd(a)}function Rf(a){return a.V}h=Qf.prototype;h.w=function(){return this.Ja.w().j()};h.fb=function(a){var b=Yb(this.Ja);return b&&(S(this.V.m)||!a.e()&&!b.Q(J(a)).e())?b.P(a):null};h.e=function(){return 0===this.Ya.length};h.Lb=function(a){this.Ya.push(a)};
h.ib=function(a,b){var c=[];if(b){H(null==a,"A cancel should cancel all event registrations.");var d=this.V.path;Ja(this.Ya,function(a){(a=a.Ie(b,d))&&c.push(a)})}if(a){for(var e=[],f=0;f<this.Ya.length;++f){var g=this.Ya[f];if(!g.matches(a))e.push(g);else if(a.Ue()){e=e.concat(this.Ya.slice(f+1));break}}this.Ya=e}else this.Ya=[];return c};
h.bb=function(a,b,c){a.type===Tc&&null!==a.source.Fb&&(H(Yb(this.Ja),"We should always have a full cache before handling merges"),H(wd(this.Ja),"Missing event cache, even though we have a server cache"));var d=this.Ja;a=this.ff.bb(d,a,b,c);b=this.ff;c=a.Od;H(c.N.j().vc(b.U.g),"Event snap not indexed");H(c.w().j().vc(b.U.g),"Server snap not indexed");H(ac(a.Od.w())||!ac(d.w()),"Once a server snap is complete, it should never go back");this.Ja=a.Od;return Sf(this,a.Cf,a.Od.N.j(),null)};
function Tf(a,b){var c=a.Ja.N,d=[];c.j().J()||c.j().O(N,function(a,b){d.push(new I("child_added",b,a))});c.da&&d.push(Zb(c.j()));return Sf(a,d,c.j(),b)}function Sf(a,b,c,d){return id(a.Jf,b,c,d?[d]:a.Ya)};function Uf(a,b,c){this.Nb=a;this.pb=b;this.rb=c||null}h=Uf.prototype;h.lf=function(a){return"value"===a};h.createEvent=function(a,b){var c=b.m.g;return new Rb("value",this,new W(a.Ia,b.ub(),c))};h.Rb=function(a){var b=this.rb;if("cancel"===a.be()){H(this.pb,"Raising a cancel event on a listener with no cancel callback");var c=this.pb;return function(){c.call(b,a.error)}}var d=this.Nb;return function(){d.call(b,a.Jd)}};h.Ie=function(a,b){return this.pb?new Sb(this,a,b):null};
h.matches=function(a){return a instanceof Uf?a.Nb&&this.Nb?a.Nb===this.Nb&&a.rb===this.rb:!0:!1};h.Ue=function(){return null!==this.Nb};function Vf(a,b,c){this.ga=a;this.pb=b;this.rb=c}h=Vf.prototype;h.lf=function(a){a="children_added"===a?"child_added":a;return("children_removed"===a?"child_removed":a)in this.ga};h.Ie=function(a,b){return this.pb?new Sb(this,a,b):null};
h.createEvent=function(a,b){H(null!=a.Wa,"Child events should have a childName.");var c=b.ub().n(a.Wa);return new Rb(a.type,this,new W(a.Ia,c,b.m.g),a.Bd)};h.Rb=function(a){var b=this.rb;if("cancel"===a.be()){H(this.pb,"Raising a cancel event on a listener with no cancel callback");var c=this.pb;return function(){c.call(b,a.error)}}var d=this.ga[a.ed];return function(){d.call(b,a.Jd,a.Bd)}};
h.matches=function(a){if(a instanceof Vf){if(!this.ga||!a.ga)return!0;if(this.rb===a.rb){var b=ra(a.ga);if(b===ra(this.ga)){if(1===b){var b=sa(a.ga),c=sa(this.ga);return c===b&&(!a.ga[b]||!this.ga[c]||a.ga[b]===this.ga[c])}return qa(this.ga,function(b,c){return a.ga[c]===b})}}}return!1};h.Ue=function(){return null!==this.ga};function X(a,b,c,d){this.u=a;this.path=b;this.m=c;this.Kc=d}
function Wf(a){var b=null,c=null;a.ka&&(b=Gd(a));a.na&&(c=Id(a));if(a.g===Cd){if(a.ka){if("[MIN_NAME]"!=Fd(a))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!==typeof b)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.");}if(a.na){if("[MAX_NAME]"!=Hd(a))throw Error("Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().");if("string"!==
typeof c)throw Error("Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.");}}else if(a.g===N){if(null!=b&&!df(b)||null!=c&&!df(c))throw Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).");}else if(H(a.g instanceof Vd||a.g===ae,"unknown index type."),null!=b&&"object"===typeof b||null!=c&&"object"===typeof c)throw Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.");
}function Xf(a){if(a.ka&&a.na&&a.xa&&(!a.xa||""===a.kb))throw Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.");}function Yf(a,b){if(!0===a.Kc)throw Error(b+": You can't combine multiple orderBy calls.");}h=X.prototype;h.ub=function(){x("Query.ref",0,0,arguments.length);return new U(this.u,this.path)};
h.dc=function(a,b,c,d){x("Query.on",2,4,arguments.length);kf("Query.on",a,!1);A("Query.on",2,b,!1);var e=Zf("Query.on",c,d);if("value"===a)$f(this.u,this,new Uf(b,e.cancel||null,e.La||null));else{var f={};f[a]=b;$f(this.u,this,new Vf(f,e.cancel,e.La))}return b};
h.Fc=function(a,b,c){x("Query.off",0,3,arguments.length);kf("Query.off",a,!0);A("Query.off",2,b,!0);bb("Query.off",3,c);var d=null,e=null;"value"===a?d=new Uf(b||null,null,c||null):a&&(b&&(e={},e[a]=b),d=new Vf(e,null,c||null));e=this.u;d=".info"===J(this.path)?e.md.ib(this,d):e.K.ib(this,d);Nb(e.ca,this.path,d)};
h.Zf=function(a,b){function c(k){f&&(f=!1,e.Fc(a,c),b&&b.call(d.La,k),g.resolve(k))}x("Query.once",1,4,arguments.length);kf("Query.once",a,!1);A("Query.once",2,b,!0);var d=Zf("Query.once",arguments[2],arguments[3]),e=this,f=!0,g=new eb;gb(g.ra);this.dc(a,c,function(b){e.Fc(a,c);d.cancel&&d.cancel.call(d.La,b);g.reject(b)});return g.ra};
h.ie=function(a){x("Query.limitToFirst",1,1,arguments.length);if(!ga(a)||Math.floor(a)!==a||0>=a)throw Error("Query.limitToFirst: First argument must be a positive integer.");if(this.m.xa)throw Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new X(this.u,this.path,this.m.ie(a),this.Kc)};
h.je=function(a){x("Query.limitToLast",1,1,arguments.length);if(!ga(a)||Math.floor(a)!==a||0>=a)throw Error("Query.limitToLast: First argument must be a positive integer.");if(this.m.xa)throw Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new X(this.u,this.path,this.m.je(a),this.Kc)};
h.$f=function(a){x("Query.orderByChild",1,1,arguments.length);if("$key"===a)throw Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===a)throw Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===a)throw Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');mf("Query.orderByChild",a);Yf(this,"Query.orderByChild");var b=new L(a);if(b.e())throw Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");
b=new Vd(b);b=ee(this.m,b);Wf(b);return new X(this.u,this.path,b,!0)};h.ag=function(){x("Query.orderByKey",0,0,arguments.length);Yf(this,"Query.orderByKey");var a=ee(this.m,Cd);Wf(a);return new X(this.u,this.path,a,!0)};h.bg=function(){x("Query.orderByPriority",0,0,arguments.length);Yf(this,"Query.orderByPriority");var a=ee(this.m,N);Wf(a);return new X(this.u,this.path,a,!0)};
h.cg=function(){x("Query.orderByValue",0,0,arguments.length);Yf(this,"Query.orderByValue");var a=ee(this.m,ae);Wf(a);return new X(this.u,this.path,a,!0)};h.Kd=function(a,b){x("Query.startAt",0,2,arguments.length);ef("Query.startAt",a,this.path,!0);lf("Query.startAt",b);var c=this.m.Kd(a,b);Xf(c);Wf(c);if(this.m.ka)throw Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");n(a)||(b=a=null);return new X(this.u,this.path,c,this.Kc)};
h.dd=function(a,b){x("Query.endAt",0,2,arguments.length);ef("Query.endAt",a,this.path,!0);lf("Query.endAt",b);var c=this.m.dd(a,b);Xf(c);Wf(c);if(this.m.na)throw Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new X(this.u,this.path,c,this.Kc)};
h.If=function(a,b){x("Query.equalTo",1,2,arguments.length);ef("Query.equalTo",a,this.path,!1);lf("Query.equalTo",b);if(this.m.ka)throw Error("Query.equalTo: Starting point was already set (by another call to endAt or equalTo).");if(this.m.na)throw Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.Kd(a,b).dd(a,b)};
h.toString=function(){x("Query.toString",0,0,arguments.length);for(var a=this.path,b="",c=a.Y;c<a.o.length;c++)""!==a.o[c]&&(b+="/"+encodeURIComponent(String(a.o[c])));return this.u.toString()+(b||"/")};h.ja=function(){var a=Dc(fe(this.m));return"{}"===a?"default":a};
h.isEqual=function(a){x("Query.isEqual",1,1,arguments.length);if(!(a instanceof X))throw Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.");var b=this.u===a.u,c=this.path.Z(a.path),d=this.ja()===a.ja();return b&&c&&d};
function Zf(a,b,c){var d={cancel:null,La:null};if(b&&c)d.cancel=b,A(a,3,d.cancel,!0),d.La=c,bb(a,4,d.La);else if(b)if("object"===typeof b&&null!==b)d.La=b;else if("function"===typeof b)d.cancel=b;else throw Error(z(a,3,!0)+" must either be a cancel callback or a context object.");return d}X.prototype.on=X.prototype.dc;X.prototype.off=X.prototype.Fc;X.prototype.once=X.prototype.Zf;X.prototype.limitToFirst=X.prototype.ie;X.prototype.limitToLast=X.prototype.je;X.prototype.orderByChild=X.prototype.$f;
X.prototype.orderByKey=X.prototype.ag;X.prototype.orderByPriority=X.prototype.bg;X.prototype.orderByValue=X.prototype.cg;X.prototype.startAt=X.prototype.Kd;X.prototype.endAt=X.prototype.dd;X.prototype.equalTo=X.prototype.If;X.prototype.toString=X.prototype.toString;X.prototype.isEqual=X.prototype.isEqual;Ic(X.prototype,"ref",X.prototype.ub);function ag(a,b){this.value=a;this.children=b||bg}var bg=new wf(function(a,b){return a===b?0:a<b?-1:1});function cg(a){var b=Q;t(a,function(a,d){b=b.set(new L(d),a)});return b}h=ag.prototype;h.e=function(){return null===this.value&&this.children.e()};function dg(a,b,c){if(null!=a.value&&c(a.value))return{path:C,value:a.value};if(b.e())return null;var d=J(b);a=a.children.get(d);return null!==a?(b=dg(a,D(b),c),null!=b?{path:(new L(d)).n(b.path),value:b.value}:null):null}
function eg(a,b){return dg(a,b,function(){return!0})}h.subtree=function(a){if(a.e())return this;var b=this.children.get(J(a));return null!==b?b.subtree(D(a)):Q};h.set=function(a,b){if(a.e())return new ag(b,this.children);var c=J(a),d=(this.children.get(c)||Q).set(D(a),b),c=this.children.Na(c,d);return new ag(this.value,c)};
h.remove=function(a){if(a.e())return this.children.e()?Q:new ag(null,this.children);var b=J(a),c=this.children.get(b);return c?(a=c.remove(D(a)),b=a.e()?this.children.remove(b):this.children.Na(b,a),null===this.value&&b.e()?Q:new ag(this.value,b)):this};h.get=function(a){if(a.e())return this.value;var b=this.children.get(J(a));return b?b.get(D(a)):null};
function Bd(a,b,c){if(b.e())return c;var d=J(b);b=Bd(a.children.get(d)||Q,D(b),c);d=b.e()?a.children.remove(d):a.children.Na(d,b);return new ag(a.value,d)}function fg(a,b){return gg(a,C,b)}function gg(a,b,c){var d={};a.children.ha(function(a,f){d[a]=gg(f,b.n(a),c)});return c(b,a.value,d)}function hg(a,b,c){return ig(a,b,C,c)}function ig(a,b,c,d){var e=a.value?d(c,a.value):!1;if(e)return e;if(b.e())return null;e=J(b);return(a=a.children.get(e))?ig(a,D(b),c.n(e),d):null}
function jg(a,b,c){kg(a,b,C,c)}function kg(a,b,c,d){if(b.e())return a;a.value&&d(c,a.value);var e=J(b);return(a=a.children.get(e))?kg(a,D(b),c.n(e),d):Q}function zd(a,b){lg(a,C,b)}function lg(a,b,c){a.children.ha(function(a,e){lg(e,b.n(a),c)});a.value&&c(b,a.value)}function mg(a,b){a.children.ha(function(a,d){d.value&&b(a,d.value)})}var Q=new ag(null);ag.prototype.toString=function(){var a={};zd(this,function(b,c){a[b.toString()]=c.toString()});return B(a)};function ng(a,b,c){this.type=rd;this.source=og;this.path=a;this.Mb=b;this.Gd=c}ng.prototype.Jc=function(a){if(this.path.e()){if(null!=this.Mb.value)return H(this.Mb.children.e(),"affectedTree should not have overlapping affected paths."),this;a=this.Mb.subtree(new L(a));return new ng(C,a,this.Gd)}H(J(this.path)===a,"operationForChild called for unrelated child.");return new ng(D(this.path),this.Mb,this.Gd)};
ng.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" ack write revert="+this.Gd+" affectedTree="+this.Mb+")"};var yb=0,Tc=1,rd=2,Ab=3;function pg(a,b,c,d){this.$d=a;this.Pe=b;this.Fb=c;this.Ae=d;H(!d||b,"Tagged queries must be from server.")}var og=new pg(!0,!1,null,!1),qg=new pg(!1,!0,null,!1);pg.prototype.toString=function(){return this.$d?"user":this.Ae?"server(queryID="+this.Fb+")":"server"};function rg(a){this.W=a}var sg=new rg(new ag(null));function tg(a,b,c){if(b.e())return new rg(new ag(c));var d=eg(a.W,b);if(null!=d){var e=d.path,d=d.value;b=T(e,b);d=d.F(b,c);return new rg(a.W.set(e,d))}a=Bd(a.W,b,new ag(c));return new rg(a)}function ug(a,b,c){var d=a;ab(c,function(a,c){d=tg(d,b.n(a),c)});return d}rg.prototype.Cd=function(a){if(a.e())return sg;a=Bd(this.W,a,Q);return new rg(a)};function vg(a,b){var c=eg(a.W,b);return null!=c?a.W.get(c.path).P(T(c.path,b)):null}
function wg(a){var b=[],c=a.W.value;null!=c?c.J()||c.O(N,function(a,c){b.push(new K(a,c))}):a.W.children.ha(function(a,c){null!=c.value&&b.push(new K(a,c.value))});return b}function xg(a,b){if(b.e())return a;var c=vg(a,b);return null!=c?new rg(new ag(c)):new rg(a.W.subtree(b))}rg.prototype.e=function(){return this.W.e()};rg.prototype.apply=function(a){return yg(C,this.W,a)};
function yg(a,b,c){if(null!=b.value)return c.F(a,b.value);var d=null;b.children.ha(function(b,f){".priority"===b?(H(null!==f.value,"Priority writes must always be leaf nodes"),d=f.value):c=yg(a.n(b),f,c)});c.P(a).e()||null===d||(c=c.F(a.n(".priority"),d));return c};function zg(){this.za={}}h=zg.prototype;h.e=function(){return ya(this.za)};h.bb=function(a,b,c){var d=a.source.Fb;if(null!==d)return d=w(this.za,d),H(null!=d,"SyncTree gave us an op for an invalid query."),d.bb(a,b,c);var e=[];t(this.za,function(d){e=e.concat(d.bb(a,b,c))});return e};h.Lb=function(a,b,c,d,e){var f=a.ja(),g=w(this.za,f);if(!g){var g=c.Aa(e?d:null),k=!1;g?k=!0:(g=d instanceof P?c.oc(d):G,k=!1);g=new Qf(a,new vd(new Xb(g,k,!1),new Xb(d,e,!1)));this.za[f]=g}g.Lb(b);return Tf(g,b)};
h.ib=function(a,b,c){var d=a.ja(),e=[],f=[],g=null!=Ag(this);if("default"===d){var k=this;t(this.za,function(a,d){f=f.concat(a.ib(b,c));a.e()&&(delete k.za[d],S(a.V.m)||e.push(a.V))})}else{var m=w(this.za,d);m&&(f=f.concat(m.ib(b,c)),m.e()&&(delete this.za[d],S(m.V.m)||e.push(m.V)))}g&&null==Ag(this)&&e.push(new U(a.u,a.path));return{hg:e,Kf:f}};function Bg(a){return Ka(ta(a.za),function(a){return!S(a.V.m)})}h.fb=function(a){var b=null;t(this.za,function(c){b=b||c.fb(a)});return b};
function Cg(a,b){if(S(b.m))return Ag(a);var c=b.ja();return w(a.za,c)}function Ag(a){return xa(a.za,function(a){return S(a.V.m)})||null};function Dg(){this.S=sg;this.la=[];this.yc=-1}function Eg(a,b){for(var c=0;c<a.la.length;c++){var d=a.la[c];if(d.Wc===b)return d}return null}h=Dg.prototype;
h.Cd=function(a){var b=Pa(this.la,function(b){return b.Wc===a});H(0<=b,"removeWrite called with nonexistent writeId.");var c=this.la[b];this.la.splice(b,1);for(var d=c.visible,e=!1,f=this.la.length-1;d&&0<=f;){var g=this.la[f];g.visible&&(f>=b&&Fg(g,c.path)?d=!1:c.path.contains(g.path)&&(e=!0));f--}if(d){if(e)this.S=Gg(this.la,Hg,C),this.yc=0<this.la.length?this.la[this.la.length-1].Wc:-1;else if(c.Fa)this.S=this.S.Cd(c.path);else{var k=this;t(c.children,function(a,b){k.S=k.S.Cd(c.path.n(b))})}return!0}return!1};
h.Aa=function(a,b,c,d){if(c||d){var e=xg(this.S,a);return!d&&e.e()?b:d||null!=b||null!=vg(e,C)?(e=Gg(this.la,function(b){return(b.visible||d)&&(!c||!(0<=Ia(c,b.Wc)))&&(b.path.contains(a)||a.contains(b.path))},a),b=b||G,e.apply(b)):null}e=vg(this.S,a);if(null!=e)return e;e=xg(this.S,a);return e.e()?b:null!=b||null!=vg(e,C)?(b=b||G,e.apply(b)):null};
h.oc=function(a,b){var c=G,d=vg(this.S,a);if(d)d.J()||d.O(N,function(a,b){c=c.T(a,b)});else if(b){var e=xg(this.S,a);b.O(N,function(a,b){var d=xg(e,new L(a)).apply(b);c=c.T(a,d)});Ja(wg(e),function(a){c=c.T(a.name,a.R)})}else e=xg(this.S,a),Ja(wg(e),function(a){c=c.T(a.name,a.R)});return c};h.Yc=function(a,b,c,d){H(c||d,"Either existingEventSnap or existingServerSnap must exist");a=a.n(b);if(null!=vg(this.S,a))return null;a=xg(this.S,a);return a.e()?d.P(b):a.apply(d.P(b))};
h.nc=function(a,b,c){a=a.n(b);var d=vg(this.S,a);return null!=d?d:Wb(c,b)?xg(this.S,a).apply(c.j().Q(b)):null};h.ic=function(a){return vg(this.S,a)};h.Sd=function(a,b,c,d,e,f){var g;a=xg(this.S,a);g=vg(a,C);if(null==g)if(null!=b)g=a.apply(b);else return[];g=g.lb(f);if(g.e()||g.J())return[];b=[];a=Md(f);e=e?g.Xb(c,f):g.Vb(c,f);for(f=R(e);f&&b.length<d;)0!==a(f,c)&&b.push(f),f=R(e);return b};
function Fg(a,b){return a.Fa?a.path.contains(b):!!wa(a.children,function(c,d){return a.path.n(d).contains(b)})}function Hg(a){return a.visible}
function Gg(a,b,c){for(var d=sg,e=0;e<a.length;++e){var f=a[e];if(b(f)){var g=f.path;if(f.Fa)c.contains(g)?(g=T(c,g),d=tg(d,g,f.Fa)):g.contains(c)&&(g=T(g,c),d=tg(d,C,f.Fa.P(g)));else if(f.children)if(c.contains(g))g=T(c,g),d=ug(d,g,f.children);else{if(g.contains(c))if(g=T(g,c),g.e())d=ug(d,C,f.children);else if(f=w(f.children,J(g)))f=f.P(D(g)),d=tg(d,C,f)}else throw pc("WriteRecord should have .snap or .children");}}return d}function Ig(a,b){this.Jb=a;this.W=b}h=Ig.prototype;
h.Aa=function(a,b,c){return this.W.Aa(this.Jb,a,b,c)};h.oc=function(a){return this.W.oc(this.Jb,a)};h.Yc=function(a,b,c){return this.W.Yc(this.Jb,a,b,c)};h.ic=function(a){return this.W.ic(this.Jb.n(a))};h.Sd=function(a,b,c,d,e){return this.W.Sd(this.Jb,a,b,c,d,e)};h.nc=function(a,b){return this.W.nc(this.Jb,a,b)};h.n=function(a){return new Ig(this.Jb.n(a),this.W)};function Jg(){this.children={};this.Zc=0;this.value=null}function Kg(a,b,c){this.sd=a?a:"";this.Mc=b?b:null;this.A=c?c:new Jg}function Lg(a,b){for(var c=b instanceof L?b:new L(b),d=a,e;null!==(e=J(c));)d=new Kg(e,d,w(d.A.children,e)||new Jg),c=D(c);return d}h=Kg.prototype;h.Ca=function(){return this.A.value};function Mg(a,b){H("undefined"!==typeof b,"Cannot set value to undefined");a.A.value=b;Ng(a)}h.clear=function(){this.A.value=null;this.A.children={};this.A.Zc=0;Ng(this)};
h.gd=function(){return 0<this.A.Zc};h.e=function(){return null===this.Ca()&&!this.gd()};h.O=function(a){var b=this;t(this.A.children,function(c,d){a(new Kg(d,b,c))})};function Og(a,b,c,d){c&&!d&&b(a);a.O(function(a){Og(a,b,!0,d)});c&&d&&b(a)}function Pg(a,b){for(var c=a.parent();null!==c&&!b(c);)c=c.parent()}h.path=function(){return new L(null===this.Mc?this.sd:this.Mc.path()+"/"+this.sd)};h.name=function(){return this.sd};h.parent=function(){return this.Mc};
function Ng(a){if(null!==a.Mc){var b=a.Mc,c=a.sd,d=a.e(),e=$a(b.A.children,c);d&&e?(delete b.A.children[c],b.A.Zc--,Ng(b)):d||e||(b.A.children[c]=a.A,b.A.Zc++,Ng(b))}};function Qg(a,b,c,d,e,f){this.id=Rg++;this.f=vc("p:"+this.id+":");this.nd={};this.$={};this.pa=[];this.Lc=0;this.Hc=[];this.ma=!1;this.Ra=1E3;this.qd=3E5;this.Eb=b;this.Gc=c;this.qe=d;this.L=a;this.mb=this.Ea=this.Ab=this.ve=null;this.Xc=e;this.Zd=!1;this.fe=0;this.Ee=f||null;this.sb=null;this.Kb=!1;this.Ed={};this.ig=0;this.Oe=!0;this.xc=this.he=null;Sg(this,0);uf.Tb().dc("visible",this.Yf,this);-1===a.host.indexOf("fblocal")&&tf.Tb().dc("online",this.Xf,this)}var Rg=0,Tg=0;h=Qg.prototype;
h.ua=function(a,b,c){var d=++this.ig;a={r:d,a:a,b:b};this.f(B(a));H(this.ma,"sendRequest call when we're not connected not allowed.");this.Ea.ua(a);c&&(this.Ed[d]=c)};h.Xe=function(a,b,c,d){var e=a.ja(),f=a.path.toString();this.f("Listen called for "+f+" "+e);this.$[f]=this.$[f]||{};H(Pc(a.m)||!S(a.m),"listen() called for non-default but complete query");H(!this.$[f][e],"listen() called twice for same path/queryId.");a={G:d,hd:b,eg:a,tag:c};this.$[f][e]=a;this.ma&&Ug(this,a)};
function Ug(a,b){var c=b.eg,d=c.path.toString(),e=c.ja();a.f("Listen on "+d+" for "+e);var f={p:d};b.tag&&(f.q=fe(c.m),f.t=b.tag);f.h=b.hd();a.ua("q",f,function(f){var k=f.d,m=f.s;if(k&&"object"===typeof k&&$a(k,"w")){var l=w(k,"w");ea(l)&&0<=Ia(l,"no_index")&&O("Using an unspecified index. Consider adding "+('".indexOn": "'+c.m.g.toString()+'"')+" at "+c.path.toString()+" to your security rules for better performance")}(a.$[d]&&a.$[d][e])===b&&(a.f("listen response",f),"ok"!==m&&Vg(a,d,e),b.G&&b.G(m,
k))})}h.hf=function(a){this.mb=a;this.f("Auth token refreshed");this.mb?Wg(this):this.ma&&this.ua("unauth",{},function(){});if(a&&40===a.length||Mc(a))this.f("Admin auth credential detected.  Reducing max reconnect time."),this.qd=3E4};function Wg(a){if(a.ma&&a.mb){var b=a.mb,c=Lc(b)?"auth":"gauth",d={cred:b};a.Ee&&(d.authvar=a.Ee);a.ua(c,d,function(c){var d=c.s;c=c.d||"error";a.mb===b&&("ok"===d?a.fe=0:Xg(a,d,c))})}}
h.tf=function(a,b){var c=a.path.toString(),d=a.ja();this.f("Unlisten called for "+c+" "+d);H(Pc(a.m)||!S(a.m),"unlisten() called for non-default but complete query");if(Vg(this,c,d)&&this.ma){var e=fe(a.m);this.f("Unlisten on "+c+" for "+d);c={p:c};b&&(c.q=e,c.t=b);this.ua("n",c)}};h.ne=function(a,b,c){this.ma?Yg(this,"o",a,b,c):this.Hc.push({se:a,action:"o",data:b,G:c})};h.bf=function(a,b,c){this.ma?Yg(this,"om",a,b,c):this.Hc.push({se:a,action:"om",data:b,G:c})};
h.vd=function(a,b){this.ma?Yg(this,"oc",a,null,b):this.Hc.push({se:a,action:"oc",data:null,G:b})};function Yg(a,b,c,d,e){c={p:c,d:d};a.f("onDisconnect "+b,c);a.ua(b,c,function(a){e&&setTimeout(function(){e(a.s,a.d)},Math.floor(0))})}h.put=function(a,b,c,d){Zg(this,"p",a,b,c,d)};h.Ye=function(a,b,c,d){Zg(this,"m",a,b,c,d)};function Zg(a,b,c,d,e,f){d={p:c,d:d};n(f)&&(d.h=f);a.pa.push({action:b,kf:d,G:e});a.Lc++;b=a.pa.length-1;a.ma?$g(a,b):a.f("Buffering put: "+c)}
function $g(a,b){var c=a.pa[b].action,d=a.pa[b].kf,e=a.pa[b].G;a.pa[b].fg=a.ma;a.ua(c,d,function(d){a.f(c+" response",d);delete a.pa[b];a.Lc--;0===a.Lc&&(a.pa=[]);e&&e(d.s,d.d)})}h.ue=function(a){this.ma&&(a={c:a},this.f("reportStats",a),this.ua("s",a,function(a){"ok"!==a.s&&this.f("reportStats","Error sending stats: "+a.d)}))};
h.ud=function(a){if("r"in a){this.f("from server: "+B(a));var b=a.r,c=this.Ed[b];c&&(delete this.Ed[b],c(a.b))}else{if("error"in a)throw"A server-side error has occurred: "+a.error;"a"in a&&(b=a.a,a=a.b,this.f("handleServerMessage",b,a),"d"===b?this.Eb(a.p,a.d,!1,a.t):"m"===b?this.Eb(a.p,a.d,!0,a.t):"c"===b?ah(this,a.p,a.q):"ac"===b?Xg(this,a.s,a.d):"sd"===b?this.ve?this.ve(a):"msg"in a&&"undefined"!==typeof console&&console.log("FIREBASE: "+a.msg.replace("\n","\nFIREBASE: ")):wc("Unrecognized action received from server: "+
B(b)+"\nAre you using the latest client?"))}};h.Ic=function(a,b){this.f("connection ready");this.ma=!0;this.xc=(new Date).getTime();this.qe({serverTimeOffset:a-(new Date).getTime()});this.Ab=b;if(this.Oe){var c={};c["sdk.js."+firebase.SDK_VERSION.replace(/\./g,"-")]=1;nb()?c["framework.cordova"]=1:"object"===typeof navigator&&"ReactNative"===navigator.product&&(c["framework.reactnative"]=1);this.ue(c)}bh(this);this.Oe=!1;this.Gc(!0)};
function Sg(a,b){H(!a.Ea,"Scheduling a connect when we're already connected/ing?");a.sb&&clearTimeout(a.sb);a.sb=setTimeout(function(){a.sb=null;ch(a)},Math.floor(b))}h.Yf=function(a){a&&!this.Kb&&this.Ra===this.qd&&(this.f("Window became visible.  Reducing delay."),this.Ra=1E3,this.Ea||Sg(this,0));this.Kb=a};h.Xf=function(a){a?(this.f("Browser went online."),this.Ra=1E3,this.Ea||Sg(this,0)):(this.f("Browser went offline.  Killing connection."),this.Ea&&this.Ea.close())};
h.cf=function(){this.f("data client disconnected");this.ma=!1;this.Ea=null;for(var a=0;a<this.pa.length;a++){var b=this.pa[a];b&&"h"in b.kf&&b.fg&&(b.G&&b.G("disconnect"),delete this.pa[a],this.Lc--)}0===this.Lc&&(this.pa=[]);this.Ed={};dh(this)&&(this.Kb?this.xc&&(3E4<(new Date).getTime()-this.xc&&(this.Ra=1E3),this.xc=null):(this.f("Window isn't visible.  Delaying reconnect."),this.Ra=this.qd,this.he=(new Date).getTime()),a=Math.max(0,this.Ra-((new Date).getTime()-this.he)),a*=Math.random(),this.f("Trying to reconnect in "+
a+"ms"),Sg(this,a),this.Ra=Math.min(this.qd,1.3*this.Ra));this.Gc(!1)};
function ch(a){if(dh(a)){a.f("Making a connection attempt");a.he=(new Date).getTime();a.xc=null;var b=q(a.ud,a),c=q(a.Ic,a),d=q(a.cf,a),e=a.id+":"+Tg++,f=a.Ab,g=!1,k=null,m=function(){k?k.close():(g=!0,d())};a.Ea={close:m,ua:function(a){H(k,"sendRequest call when we're not connected not allowed.");k.ua(a)}};var l=a.Zd;a.Zd=!1;a.Xc.getToken(l).then(function(l){g?E("getToken() completed but was canceled"):(E("getToken() completed. Creating connection."),a.mb=l&&l.accessToken,k=new De(e,a.L,b,c,d,function(b){O(b+
" ("+a.L.toString()+")");a.$a("server_kill")},f))}).then(null,function(b){a.f("Failed to get token: "+b);g||m()})}}h.$a=function(a){E("Interrupting connection for reason: "+a);this.nd[a]=!0;this.Ea?this.Ea.close():(this.sb&&(clearTimeout(this.sb),this.sb=null),this.ma&&this.cf())};h.hc=function(a){E("Resuming connection for reason: "+a);delete this.nd[a];ya(this.nd)&&(this.Ra=1E3,this.Ea||Sg(this,0))};
function ah(a,b,c){c=c?La(c,function(a){return Dc(a)}).join("$"):"default";(a=Vg(a,b,c))&&a.G&&a.G("permission_denied")}function Vg(a,b,c){b=(new L(b)).toString();var d;n(a.$[b])?(d=a.$[b][c],delete a.$[b][c],0===ra(a.$[b])&&delete a.$[b]):d=void 0;return d}
function Xg(a,b,c){E("Auth token revoked: "+b+"/"+c);a.mb=null;a.Zd=!0;a.Ea.close();"invalid_token"===b&&(a.fe++,3<=a.fe&&(a.Ra=3E4,a=a.Xc,b='Provided authentication credentials for the app named "'+a.lc.name+'" are invalid. This usually indicates your app was not initialized correctly. ',b="credential"in a.lc.options?b+'Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in a.lc.options?
b+'Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':b+'Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',O(b)))}
function bh(a){Wg(a);t(a.$,function(b){t(b,function(b){Ug(a,b)})});for(var b=0;b<a.pa.length;b++)a.pa[b]&&$g(a,b);for(;a.Hc.length;)b=a.Hc.shift(),Yg(a,b.action,b.se,b.data,b.G)}function dh(a){var b;b=tf.Tb().ec;return ya(a.nd)&&b};var Y={Mf:function(){oe=ad=!0}};Y.forceLongPolling=Y.Mf;Y.Nf=function(){pe=!0};Y.forceWebSockets=Y.Nf;Y.Tf=function(){return $c.isAvailable()};Y.isWebSocketsAvailable=Y.Tf;Y.lg=function(a,b){a.u.Qa.ve=b};Y.setSecurityDebugCallback=Y.lg;Y.xe=function(a,b){a.u.xe(b)};Y.stats=Y.xe;Y.ye=function(a,b){a.u.ye(b)};Y.statsIncrementCounter=Y.ye;Y.cd=function(a){return a.u.cd};Y.dataUpdateCount=Y.cd;Y.Sf=function(a,b){a.u.ee=b};Y.interceptServerData=Y.Sf;function eh(a){this.wa=Q;this.hb=new Dg;this.ze={};this.fc={};this.zc=a}function fh(a,b,c,d,e){var f=a.hb,g=e;H(d>f.yc,"Stacking an older write on top of newer ones");n(g)||(g=!0);f.la.push({path:b,Fa:c,Wc:d,visible:g});g&&(f.S=tg(f.S,b,c));f.yc=d;return e?gh(a,new xb(og,b,c)):[]}function hh(a,b,c,d){var e=a.hb;H(d>e.yc,"Stacking an older merge on top of newer ones");e.la.push({path:b,children:c,Wc:d,visible:!0});e.S=ug(e.S,b,c);e.yc=d;c=cg(c);return gh(a,new Sc(og,b,c))}
function ih(a,b,c){c=c||!1;var d=Eg(a.hb,b);if(a.hb.Cd(b)){var e=Q;null!=d.Fa?e=e.set(C,!0):ab(d.children,function(a,b){e=e.set(new L(a),b)});return gh(a,new ng(d.path,e,c))}return[]}function jh(a,b,c){c=cg(c);return gh(a,new Sc(qg,b,c))}function kh(a,b,c,d){d=lh(a,d);if(null!=d){var e=mh(d);d=e.path;e=e.Fb;b=T(d,b);c=new xb(new pg(!1,!0,e,!0),b,c);return nh(a,d,c)}return[]}
function oh(a,b,c,d){if(d=lh(a,d)){var e=mh(d);d=e.path;e=e.Fb;b=T(d,b);c=cg(c);c=new Sc(new pg(!1,!0,e,!0),b,c);return nh(a,d,c)}return[]}
eh.prototype.Lb=function(a,b){var c=a.path,d=null,e=!1;jg(this.wa,c,function(a,b){var f=T(a,c);d=d||b.fb(f);e=e||null!=Ag(b)});var f=this.wa.get(c);f?(e=e||null!=Ag(f),d=d||f.fb(C)):(f=new zg,this.wa=this.wa.set(c,f));var g;null!=d?g=!0:(g=!1,d=G,mg(this.wa.subtree(c),function(a,b){var c=b.fb(C);c&&(d=d.T(a,c))}));var k=null!=Cg(f,a);if(!k&&!S(a.m)){var m=ph(a);H(!(m in this.fc),"View does not exist, but we have a tag");var l=qh++;this.fc[m]=l;this.ze["_"+l]=m}g=f.Lb(a,b,new Ig(c,this.hb),d,g);k||
e||(f=Cg(f,a),g=g.concat(rh(this,a,f)));return g};
eh.prototype.ib=function(a,b,c){var d=a.path,e=this.wa.get(d),f=[];if(e&&("default"===a.ja()||null!=Cg(e,a))){f=e.ib(a,b,c);e.e()&&(this.wa=this.wa.remove(d));e=f.hg;f=f.Kf;b=-1!==Pa(e,function(a){return S(a.m)});var g=hg(this.wa,d,function(a,b){return null!=Ag(b)});if(b&&!g&&(d=this.wa.subtree(d),!d.e()))for(var d=sh(d),k=0;k<d.length;++k){var m=d[k],l=m.V,m=th(this,m);this.zc.we(uh(l),vh(this,l),m.hd,m.G)}if(!g&&0<e.length&&!c)if(b)this.zc.Ld(uh(a),null);else{var r=this;Ja(e,function(a){a.ja();
var b=r.fc[ph(a)];r.zc.Ld(uh(a),b)})}wh(this,e)}return f};eh.prototype.Aa=function(a,b){var c=this.hb,d=hg(this.wa,a,function(b,c){var d=T(b,a);if(d=c.fb(d))return d});return c.Aa(a,d,b,!0)};function sh(a){return fg(a,function(a,c,d){if(c&&null!=Ag(c))return[Ag(c)];var e=[];c&&(e=Bg(c));t(d,function(a){e=e.concat(a)});return e})}function wh(a,b){for(var c=0;c<b.length;++c){var d=b[c];if(!S(d.m)){var d=ph(d),e=a.fc[d];delete a.fc[d];delete a.ze["_"+e]}}}
function uh(a){return S(a.m)&&!Pc(a.m)?a.ub():a}function rh(a,b,c){var d=b.path,e=vh(a,b);c=th(a,c);b=a.zc.we(uh(b),e,c.hd,c.G);d=a.wa.subtree(d);if(e)H(null==Ag(d.value),"If we're adding a query, it shouldn't be shadowed");else for(e=fg(d,function(a,b,c){if(!a.e()&&b&&null!=Ag(b))return[Rf(Ag(b))];var d=[];b&&(d=d.concat(La(Bg(b),function(a){return a.V})));t(c,function(a){d=d.concat(a)});return d}),d=0;d<e.length;++d)c=e[d],a.zc.Ld(uh(c),vh(a,c));return b}
function th(a,b){var c=b.V,d=vh(a,c);return{hd:function(){return(b.w()||G).hash()},G:function(b){if("ok"===b){if(d){var f=c.path;if(b=lh(a,d)){var g=mh(b);b=g.path;g=g.Fb;f=T(b,f);f=new zb(new pg(!1,!0,g,!0),f);b=nh(a,b,f)}else b=[]}else b=gh(a,new zb(qg,c.path));return b}f="Unknown Error";"too_big"===b?f="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==b?f="Client doesn't have permission to access the desired data.":"unavailable"==b&&
(f="The service is unavailable");f=Error(b+" at "+c.path.toString()+": "+f);f.code=b.toUpperCase();return a.ib(c,null,f)}}}function ph(a){return a.path.toString()+"$"+a.ja()}function mh(a){var b=a.indexOf("$");H(-1!==b&&b<a.length-1,"Bad queryKey.");return{Fb:a.substr(b+1),path:new L(a.substr(0,b))}}function lh(a,b){var c=a.ze,d="_"+b;return d in c?c[d]:void 0}function vh(a,b){var c=ph(b);return w(a.fc,c)}var qh=1;
function nh(a,b,c){var d=a.wa.get(b);H(d,"Missing sync point for query tag that we're tracking");return d.bb(c,new Ig(b,a.hb),null)}function gh(a,b){return xh(a,b,a.wa,null,new Ig(C,a.hb))}function xh(a,b,c,d,e){if(b.path.e())return yh(a,b,c,d,e);var f=c.get(C);null==d&&null!=f&&(d=f.fb(C));var g=[],k=J(b.path),m=b.Jc(k);if((c=c.children.get(k))&&m)var l=d?d.Q(k):null,k=e.n(k),g=g.concat(xh(a,m,c,l,k));f&&(g=g.concat(f.bb(b,e,d)));return g}
function yh(a,b,c,d,e){var f=c.get(C);null==d&&null!=f&&(d=f.fb(C));var g=[];c.children.ha(function(c,f){var l=d?d.Q(c):null,r=e.n(c),y=b.Jc(c);y&&(g=g.concat(yh(a,y,f,l,r)))});f&&(g=g.concat(f.bb(b,e,d)));return g};function Ue(a,b,c){this.app=c;var d=new Bb(c);this.L=a;this.Ua=Xc(a);this.Sc=null;this.ca=new Kb;this.td=1;this.Qa=null;if(b||0<=("object"===typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i))this.va=new Nc(this.L,q(this.Eb,this),d),setTimeout(q(this.Gc,this,!0),0);else{b=c.options.databaseAuthVariableOverride||null;if(null!==b){if("object"!==da(b))throw Error("Only objects are supported for option databaseAuthVariableOverride");
try{B(b)}catch(e){throw Error("Invalid authOverride provided: "+e);}}this.va=this.Qa=new Qg(this.L,q(this.Eb,this),q(this.Gc,this),q(this.qe,this),d,b)}var f=this;Cb(d,function(a){f.va.hf(a)});this.og=Yc(a,q(function(){return new Uc(this.Ua,this.va)},this));this.jc=new Kg;this.de=new Db;this.md=new eh({we:function(a,b,c,d){b=[];c=f.de.j(a.path);c.e()||(b=gh(f.md,new xb(qg,a.path,c)),setTimeout(function(){d("ok")},0));return b},Ld:ba});zh(this,"connected",!1);this.ia=new jc;this.Xa=new Te(this);this.cd=
0;this.ee=null;this.K=new eh({we:function(a,b,c,d){f.va.Xe(a,c,b,function(b,c){var e=d(b,c);Pb(f.ca,a.path,e)});return[]},Ld:function(a,b){f.va.tf(a,b)}})}h=Ue.prototype;h.toString=function(){return(this.L.Pc?"https://":"http://")+this.L.host};h.name=function(){return this.L.le};function Ah(a){a=a.de.j(new L(".info/serverTimeOffset")).H()||0;return(new Date).getTime()+a}function Bh(a){a=a={timestamp:Ah(a)};a.timestamp=a.timestamp||(new Date).getTime();return a}
h.Eb=function(a,b,c,d){this.cd++;var e=new L(a);b=this.ee?this.ee(a,b):b;a=[];d?c?(b=pa(b,function(a){return M(a)}),a=oh(this.K,e,b,d)):(b=M(b),a=kh(this.K,e,b,d)):c?(d=pa(b,function(a){return M(a)}),a=jh(this.K,e,d)):(d=M(b),a=gh(this.K,new xb(qg,e,d)));d=e;0<a.length&&(d=Ch(this,e));Pb(this.ca,d,a)};h.Gc=function(a){zh(this,"connected",a);!1===a&&Dh(this)};h.qe=function(a){var b=this;Fc(a,function(a,d){zh(b,d,a)})};
function zh(a,b,c){b=new L("/.info/"+b);c=M(c);var d=a.de;d.Hd=d.Hd.F(b,c);c=gh(a.md,new xb(qg,b,c));Pb(a.ca,b,c)}h.Hb=function(a,b,c,d){this.f("set",{path:a.toString(),value:b,xg:c});var e=Bh(this);b=M(b,c);var e=mc(b,e),f=this.td++,e=fh(this.K,a,e,f,!0);Lb(this.ca,e);var g=this;this.va.put(a.toString(),b.H(!0),function(b,c){var e="ok"===b;e||O("set at "+a+" failed: "+b);e=ih(g.K,f,!e);Pb(g.ca,a,e);Eh(d,b,c)});e=Fh(this,a);Ch(this,e);Pb(this.ca,e,[])};
h.update=function(a,b,c){this.f("update",{path:a.toString(),value:b});var d=!0,e=Bh(this),f={};t(b,function(a,b){d=!1;var c=M(a);f[b]=mc(c,e)});if(d)E("update() called with empty data.  Don't do anything."),Eh(c,"ok");else{var g=this.td++,k=hh(this.K,a,f,g);Lb(this.ca,k);var m=this;this.va.Ye(a.toString(),b,function(b,d){var e="ok"===b;e||O("update at "+a+" failed: "+b);var e=ih(m.K,g,!e),f=a;0<e.length&&(f=Ch(m,a));Pb(m.ca,f,e);Eh(c,b,d)});t(b,function(b,c){var d=Fh(m,a.n(c));Ch(m,d)});Pb(this.ca,
a,[])}};function Dh(a){a.f("onDisconnectEvents");var b=Bh(a),c=[];kc(ic(a.ia,b),C,function(b,e){c=c.concat(gh(a.K,new xb(qg,b,e)));var f=Fh(a,b);Ch(a,f)});a.ia=new jc;Pb(a.ca,C,c)}h.vd=function(a,b){var c=this;this.va.vd(a.toString(),function(d,e){"ok"===d&&$e(c.ia,a);Eh(b,d,e)})};function of(a,b,c,d){var e=M(c);a.va.ne(b.toString(),e.H(!0),function(c,g){"ok"===c&&lc(a.ia,b,e);Eh(d,c,g)})}
function pf(a,b,c,d,e){var f=M(c,d);a.va.ne(b.toString(),f.H(!0),function(c,d){"ok"===c&&lc(a.ia,b,f);Eh(e,c,d)})}function qf(a,b,c,d){var e=!0,f;for(f in c)e=!1;e?(E("onDisconnect().update() called with empty data.  Don't do anything."),Eh(d,"ok")):a.va.bf(b.toString(),c,function(e,f){if("ok"===e)for(var m in c){var l=M(c[m]);lc(a.ia,b.n(m),l)}Eh(d,e,f)})}function $f(a,b,c){c=".info"===J(b.path)?a.md.Lb(b,c):a.K.Lb(b,c);Nb(a.ca,b.path,c)}h.$a=function(){this.Qa&&this.Qa.$a("repo_interrupt")};
h.hc=function(){this.Qa&&this.Qa.hc("repo_interrupt")};h.xe=function(a){if("undefined"!==typeof console){a?(this.Sc||(this.Sc=new Jb(this.Ua)),a=this.Sc.get()):a=this.Ua.get();var b=Ma(ua(a),function(a,b){return Math.max(b.length,a)},0),c;for(c in a){for(var d=a[c],e=c.length;e<b+2;e++)c+=" ";console.log(c+d)}}};h.ye=function(a){Ib(this.Ua,a);this.og.qf[a]=!0};h.f=function(a){var b="";this.Qa&&(b=this.Qa.id+":");E(b,arguments)};
function Eh(a,b,c){a&&rb(function(){if("ok"==b)a(null);else{var d=(b||"error").toUpperCase(),e=d;c&&(e+=": "+c);e=Error(e);e.code=d;a(e)}})};function Gh(a,b,c,d,e){function f(){}a.f("transaction on "+b);var g=new U(a,b);g.dc("value",f);c={path:b,update:c,G:d,status:null,df:oc(),De:e,mf:0,Nd:function(){g.Fc("value",f)},Pd:null,Ba:null,$c:null,ad:null,bd:null};d=a.K.Aa(b,void 0)||G;c.$c=d;d=c.update(d.H());if(n(d)){ff("transaction failed: Data returned ",d,c.path);c.status=1;e=Lg(a.jc,b);var k=e.Ca()||[];k.push(c);Mg(e,k);"object"===typeof d&&null!==d&&$a(d,".priority")?(k=w(d,".priority"),H(df(k),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):
k=(a.K.Aa(b)||G).C().H();e=Bh(a);d=M(d,k);e=mc(d,e);c.ad=d;c.bd=e;c.Ba=a.td++;c=fh(a.K,b,e,c.Ba,c.De);Pb(a.ca,b,c);Hh(a)}else c.Nd(),c.ad=null,c.bd=null,c.G&&(a=new W(c.$c,new U(a,c.path),N),c.G(null,!1,a))}function Hh(a,b){var c=b||a.jc;b||Ih(a,c);if(null!==c.Ca()){var d=Jh(a,c);H(0<d.length,"Sending zero length transaction queue");Na(d,function(a){return 1===a.status})&&Kh(a,c.path(),d)}else c.gd()&&c.O(function(b){Hh(a,b)})}
function Kh(a,b,c){for(var d=La(c,function(a){return a.Ba}),e=a.K.Aa(b,d)||G,d=e,e=e.hash(),f=0;f<c.length;f++){var g=c[f];H(1===g.status,"tryToSendTransactionQueue_: items in queue should all be run.");g.status=2;g.mf++;var k=T(b,g.path),d=d.F(k,g.ad)}d=d.H(!0);a.va.put(b.toString(),d,function(d){a.f("transaction put response",{path:b.toString(),status:d});var e=[];if("ok"===d){d=[];for(f=0;f<c.length;f++){c[f].status=3;e=e.concat(ih(a.K,c[f].Ba));if(c[f].G){var g=c[f].bd,k=new U(a,c[f].path);d.push(q(c[f].G,
null,null,!0,new W(g,k,N)))}c[f].Nd()}Ih(a,Lg(a.jc,b));Hh(a);Pb(a.ca,b,e);for(f=0;f<d.length;f++)rb(d[f])}else{if("datastale"===d)for(f=0;f<c.length;f++)c[f].status=4===c[f].status?5:1;else for(O("transaction at "+b.toString()+" failed: "+d),f=0;f<c.length;f++)c[f].status=5,c[f].Pd=d;Ch(a,b)}},e)}function Ch(a,b){var c=Lh(a,b),d=c.path(),c=Jh(a,c);Mh(a,c,d);return d}
function Mh(a,b,c){if(0!==b.length){for(var d=[],e=[],f=Ka(b,function(a){return 1===a.status}),f=La(f,function(a){return a.Ba}),g=0;g<b.length;g++){var k=b[g],m=T(c,k.path),l=!1,r;H(null!==m,"rerunTransactionsUnderNode_: relativePath should not be null.");if(5===k.status)l=!0,r=k.Pd,e=e.concat(ih(a.K,k.Ba,!0));else if(1===k.status)if(25<=k.mf)l=!0,r="maxretry",e=e.concat(ih(a.K,k.Ba,!0));else{var y=a.K.Aa(k.path,f)||G;k.$c=y;var F=b[g].update(y.H());n(F)?(ff("transaction failed: Data returned ",F,
k.path),m=M(F),"object"===typeof F&&null!=F&&$a(F,".priority")||(m=m.fa(y.C())),y=k.Ba,F=Bh(a),F=mc(m,F),k.ad=m,k.bd=F,k.Ba=a.td++,Qa(f,y),e=e.concat(fh(a.K,k.path,F,k.Ba,k.De)),e=e.concat(ih(a.K,y,!0))):(l=!0,r="nodata",e=e.concat(ih(a.K,k.Ba,!0)))}Pb(a.ca,c,e);e=[];l&&(b[g].status=3,setTimeout(b[g].Nd,Math.floor(0)),b[g].G&&("nodata"===r?(k=new U(a,b[g].path),d.push(q(b[g].G,null,null,!1,new W(b[g].$c,k,N)))):d.push(q(b[g].G,null,Error(r),!1,null))))}Ih(a,a.jc);for(g=0;g<d.length;g++)rb(d[g]);Hh(a)}}
function Lh(a,b){for(var c,d=a.jc;null!==(c=J(b))&&null===d.Ca();)d=Lg(d,c),b=D(b);return d}function Jh(a,b){var c=[];Nh(a,b,c);c.sort(function(a,b){return a.df-b.df});return c}function Nh(a,b,c){var d=b.Ca();if(null!==d)for(var e=0;e<d.length;e++)c.push(d[e]);b.O(function(b){Nh(a,b,c)})}function Ih(a,b){var c=b.Ca();if(c){for(var d=0,e=0;e<c.length;e++)3!==c[e].status&&(c[d]=c[e],d++);c.length=d;Mg(b,0<c.length?c:null)}b.O(function(b){Ih(a,b)})}
function Fh(a,b){var c=Lh(a,b).path(),d=Lg(a.jc,b);Pg(d,function(b){Oh(a,b)});Oh(a,d);Og(d,function(b){Oh(a,b)});return c}
function Oh(a,b){var c=b.Ca();if(null!==c){for(var d=[],e=[],f=-1,g=0;g<c.length;g++)4!==c[g].status&&(2===c[g].status?(H(f===g-1,"All SENT items should be at beginning of queue."),f=g,c[g].status=4,c[g].Pd="set"):(H(1===c[g].status,"Unexpected transaction status in abort"),c[g].Nd(),e=e.concat(ih(a.K,c[g].Ba,!0)),c[g].G&&d.push(q(c[g].G,null,Error("set"),!1,null))));-1===f?Mg(b,null):c.length=f+1;Pb(a.ca,b.path(),e);for(g=0;g<d.length;g++)rb(d[g])}};function Ze(){this.jb={};this.uf=!1}Ze.prototype.$a=function(){for(var a in this.jb)this.jb[a].$a()};Ze.prototype.hc=function(){for(var a in this.jb)this.jb[a].hc()};Ze.prototype.Yd=function(a){this.uf=a};ca(Ze);Ze.prototype.interrupt=Ze.prototype.$a;Ze.prototype.resume=Ze.prototype.hc;var Z={};Z.kc=Qg;Z.DataConnection=Z.kc;Qg.prototype.ng=function(a,b){this.ua("q",{p:a},b)};Z.kc.prototype.simpleListen=Z.kc.prototype.ng;Qg.prototype.Hf=function(a,b){this.ua("echo",{d:a},b)};Z.kc.prototype.echo=Z.kc.prototype.Hf;Qg.prototype.interrupt=Qg.prototype.$a;Z.yf=De;Z.RealTimeConnection=Z.yf;De.prototype.sendRequest=De.prototype.ua;De.prototype.close=De.prototype.close;
Z.Rf=function(a){var b=Qg.prototype.put;Qg.prototype.put=function(c,d,e,f){n(f)&&(f=a());b.call(this,c,d,e,f)};return function(){Qg.prototype.put=b}};Z.hijackHash=Z.Rf;Z.xf=Eb;Z.ConnectionTarget=Z.xf;Z.ja=function(a){return a.ja()};Z.queryIdentifier=Z.ja;Z.Uf=function(a){return a.u.Qa.$};Z.listens=Z.Uf;Z.Yd=function(a){Ze.Tb().Yd(a)};Z.forceRestClient=Z.Yd;Z.Context=Ze;function U(a,b){if(!(a instanceof Ue))throw Error("new Firebase() no longer supported - use app.database().");X.call(this,a,b,ce,!1);this.then=void 0;this["catch"]=void 0}la(U,X);h=U.prototype;h.getKey=function(){x("Firebase.key",0,0,arguments.length);return this.path.e()?null:yd(this.path)};
h.n=function(a){x("Firebase.child",1,1,arguments.length);if(ga(a))a=String(a);else if(!(a instanceof L))if(null===J(this.path)){var b=a;b&&(b=b.replace(/^\/*\.info(\/|$)/,"/"));mf("Firebase.child",b)}else mf("Firebase.child",a);return new U(this.u,this.path.n(a))};h.getParent=function(){x("Firebase.parent",0,0,arguments.length);var a=this.path.parent();return null===a?null:new U(this.u,a)};
h.Of=function(){x("Firebase.ref",0,0,arguments.length);for(var a=this;null!==a.getParent();)a=a.getParent();return a};h.Gf=function(){return this.u.Xa};h.set=function(a,b){x("Firebase.set",1,2,arguments.length);nf("Firebase.set",this.path);ef("Firebase.set",a,this.path,!1);A("Firebase.set",2,b,!0);var c=new eb;this.u.Hb(this.path,a,null,fb(c,b));return c.ra};
h.update=function(a,b){x("Firebase.update",1,2,arguments.length);nf("Firebase.update",this.path);if(ea(a)){for(var c={},d=0;d<a.length;++d)c[""+d]=a[d];a=c;O("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}hf("Firebase.update",a,this.path);A("Firebase.update",2,b,!0);c=new eb;this.u.update(this.path,a,fb(c,b));return c.ra};
h.Hb=function(a,b,c){x("Firebase.setWithPriority",2,3,arguments.length);nf("Firebase.setWithPriority",this.path);ef("Firebase.setWithPriority",a,this.path,!1);jf("Firebase.setWithPriority",2,b);A("Firebase.setWithPriority",3,c,!0);if(".length"===this.getKey()||".keys"===this.getKey())throw"Firebase.setWithPriority failed: "+this.getKey()+" is a read-only object.";var d=new eb;this.u.Hb(this.path,a,b,fb(d,c));return d.ra};
h.remove=function(a){x("Firebase.remove",0,1,arguments.length);nf("Firebase.remove",this.path);A("Firebase.remove",1,a,!0);return this.set(null,a)};
h.transaction=function(a,b,c){x("Firebase.transaction",1,3,arguments.length);nf("Firebase.transaction",this.path);A("Firebase.transaction",1,a,!1);A("Firebase.transaction",2,b,!0);if(n(c)&&"boolean"!=typeof c)throw Error(z("Firebase.transaction",3,!0)+"must be a boolean.");if(".length"===this.getKey()||".keys"===this.getKey())throw"Firebase.transaction failed: "+this.getKey()+" is a read-only object.";"undefined"===typeof c&&(c=!0);var d=new eb;ha(b)&&gb(d.ra);Gh(this.u,this.path,a,function(a,c,g){a?
d.reject(a):d.resolve(new mb(c,g));ha(b)&&b(a,c,g)},c);return d.ra};h.kg=function(a,b){x("Firebase.setPriority",1,2,arguments.length);nf("Firebase.setPriority",this.path);jf("Firebase.setPriority",1,a);A("Firebase.setPriority",2,b,!0);var c=new eb;this.u.Hb(this.path.n(".priority"),a,null,fb(c,b));return c.ra};
h.push=function(a,b){x("Firebase.push",0,2,arguments.length);nf("Firebase.push",this.path);ef("Firebase.push",a,this.path,!0);A("Firebase.push",2,b,!0);var c=Ah(this.u),d=vf(c),c=this.n(d);if(null!=a){var e=this,f=c.set(a,b).then(function(){return e.n(d)});c.then=q(f.then,f);c["catch"]=q(f.then,f,void 0);ha(b)&&gb(f)}return c};h.gb=function(){nf("Firebase.onDisconnect",this.path);return new V(this.u,this.path)};U.prototype.child=U.prototype.n;U.prototype.set=U.prototype.set;U.prototype.update=U.prototype.update;
U.prototype.setWithPriority=U.prototype.Hb;U.prototype.remove=U.prototype.remove;U.prototype.transaction=U.prototype.transaction;U.prototype.setPriority=U.prototype.kg;U.prototype.push=U.prototype.push;U.prototype.onDisconnect=U.prototype.gb;Ic(U.prototype,"database",U.prototype.Gf);Ic(U.prototype,"key",U.prototype.getKey);Ic(U.prototype,"parent",U.prototype.getParent);Ic(U.prototype,"root",U.prototype.Of);if("undefined"===typeof firebase)throw Error("Cannot install Firebase Database - be sure to load firebase-app.js first.");
try{var Ph=firebase.INTERNAL.registerService("database",function(a){var b=Ze.Tb(),c=a.options.databaseURL;n(c)||xc("Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.intializeApp().");var d=yc(c),c=d.gc;Ye("Invalid Firebase Database URL",d);d.path.e()||xc("Database URL must point to the root of a Firebase Database (not including a child path).");(d=w(b.jb,a.name))&&xc("FIREBASE INTERNAL ERROR: Database initialized multiple times.");d=new Ue(c,b.uf,
a);b.jb[a.name]=d;return d.Xa},{Reference:U,Query:X,Database:Te,enableLogging:uc,INTERNAL:Y,TEST_ACCESS:Z,ServerValue:We});module.exports=Ph}catch(Qh){xc("Failed to register the Firebase Database Service ("+Qh+")")};
})();