<NME> socket.io.min.js
<BEF> /* Socket.IO.min 0.7.0 @author Guillermo Rauch <guillermo@learnboost.com>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com> */
(function(a){var b=a;b.version="0.7.0",b.protocol=1,b.transports=["websocket","htmlfile","xhr-polling","jsonp-polling"],b.j=[],b.sockets={},"object"==typeof module&&"function"==typeof require&&(b.util=require("./util").util,b.JSON=require("./json").JSON,b.parser=require("./parser").parser,b.EventEmitter=process.EventEmitter,b.Transport=require("./transport").Transport,b.transports.forEach(function(a){}),b.Socket=require("./socket").Socket,b.dist=__dirname+"/../dist"),b.connect=function(a,c){var d=b.util.parseUri(a);"undefined"!=typeof document&&(d.host=d.host||document.domain,d.port=d.port||document.location.port);var e=b.util.uniqueUri(d);if(c||!b.sockets[e])var f=new b.Socket({host:d.host,secure:d.protocol=="https://",port:d.port||80});c||(this.sockets[e]=f);return f.of(d.path.length>1?d.path:"")}})("object"==typeof module?module.exports:window.io={}),function(a){var b=a.util={},c=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.parseUri=function(a){var b=c.exec(a||""),e={},f=14;while(f--)e[d[f]]=b[f]||"";return e},b.uniqueUri=function(a){var b=a.protocol,c=a.host,d=a.port;"undefined"!=typeof document?(c=c||document.domain,d=d||document.location.port):c=c||"localhost";return(b||"http")+"://"+c+":"+(d||b&&b==="https"?443:80)};var e=!1;b.load=function(a){if(document.readyState==="complete"||e)return a();b.on(window,"load",a,!1)},b.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,d)};var f="undefined"!=typeof window&&window.XMLHttpRequest&&function(){var a=new XMLHttpRequest;return a.withCredentials!=undefined}();b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||f))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return null},"undefined"!=typeof window&&b.load(function(){e=!0}),b.defer=function(a){if(!b.ua.webkit)return a();b.load(function(){setTimeout(a,100)})},b.merge=function(a,b,c,d){var e=d||[],f=typeof c=="undefined"?2:c,g;for(g in b)b.hasOwnProperty(g)&&this.indexOf(e,g)<0&&(typeof a[g]!="object"||!f?(a[g]=b[g],e.push(b[g])):this.merge(a[g],b[g],f-1,e));return a},b.mixin=function(a,c){b.merge(a.prototype,c.prototype)},b.inherit=function(a,c){a.prototype=new c,b.merge(a,c)},b.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},b.intersect=function(a,c){var d=[],e=a.length>c.length?a:c,f=a.length>c.length?c:a;for(var g=0,h=f.length;g<h;g++)~b.indexOf(e,f[g])&&d.push(f[g]);return d},b.indexOf=function(a,b,c){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b,c);for(var d=a.length,c=c<0?c+d<0?0:c+d:c||0;c<d&&a[c]!==b;c++);return d<=c?-1:c},b.toArray=function(a){var b=[];for(var c=0,d=a.length;c<d;c++)b.push(a[c]);return b},b.ua={},b.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof window?io:module.exports),function(a,b){function c(){}a.EventEmitter=c,c.prototype.on=function(a,c){this.$events||(this.$events={}),this.$events[a]?b.util.isArray(this.$events[a])?this.$events[a].push(c):this.$events[a]=[this.$events[a],c]:this.$events[a]=c;return this},c.prototype.addListener=c.prototype.on,c.prototype.once=function(a,b){function d(){c.removeListener(a,d),b.apply(this,arguments)}var c=this;d.listener=b,this.on(a,d);return this},c.prototype.removeListener=function(a,c){if(this.$events&&this.$events[a]){var d=this.$events[a];if(b.util.isArray(d)){var e=-1;for(var f=0,g=d.length;f<g;f++)if(d[f]===c||d[f].listener&&d[f].listener===c){e=f;break}if(e<0)return this;d.splice(e,1),d.length||delete this.$events[a]}else(d===c||d.listener&&d.listener===c)&&delete this.$events[a]}return this},c.prototype.removeAllListeners=function(a){if(a===undefined){this.$events={};return this}this.$events&&this.$events[a]&&(this.$events[a]=null);return this},c.prototype.listeners=function(a){this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),b.util.isArray(this.$events[a])||(this.$events[a]=[this.$events[a]]);return this.$events[a]},c.prototype.emit=function(a){if(!this.$events)return!1;var c=this.$events[a];if(!c)return!1;var d=Array.prototype.slice.call(arguments,1);if("function"==typeof c)c.apply(this,d);else{if(!b.util.isArray(c))return!1;var e=c.slice();for(var f=0,g=e.length;f<g;f++)e[f].apply(this,d)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i instanceof Date&&(i=date(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function date(a,b){return isFinite(a.valueOf())?a.getUTCFullYear()+"-"+f(a.getUTCMonth()+1)+"-"+f(a.getUTCDate())+"T"+f(a.getUTCHours())+":"+f(a.getUTCMinutes())+":"+f(a.getUTCSeconds())+"Z":null}function f(a){return a<10?"0"+a:a}"use strict";if(nativeJSON&&nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(b&&typeof b!="function"&&(typeof b!="object"||typeof b.length!="number"))throw new Error("JSON.stringify");return str("",{"":a})},JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,JSON),function(a,b){var c=a.parser={},d=c.packets=["disconnect","connect","heartbeat","message","json","event","ack","error"],e=c.reasons=["transport not supported","client not handshaken","unauthorized"],f=c.advice=["reconnect"],g=b.JSON,h=b.util.indexOf;c.encodePacket=function(a){var b=d.indexOf(a.type),c=a.id||"",h=a.endpoint||"",i=a.ack,j=null;switch(a.type){case"error":var k=a.reason?e.indexOf(a.reason):"",l=a.advice?f.indexOf(a.advice):"";if(k!==""||l!=="")j=k+(l!==""?"+"+l:"");break;case"message":a.data!==""&&(j=a.data);break;case"event":var m={name:a.name};a.args&&a.args.length&&(m.args=a.args),j=g.stringify(m);break;case"json":j=g.stringify(a.data);break;case"connect":a.qs&&(j=a.qs);break;case"ack":j=a.ackId+(a.args&&a.args.length?"+"+g.stringify(a.args):"");break;case"heartbeat":case"disconect":}var n=[b,c+(i=="data"?"+":""),h];j!==null&&j!==undefined&&n.push(j);return n.join(":")},c.encodePayload=function(a){var b="";if(a.length==1)return a[0];for(var c=0,d=a.length;c<d;c++){var e=a[c];b+="�"+e.length+"�"+a[c]}return b};var i=/^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;c.decodePacket=function(a){var b=a.match(i);if(!b)return{};var c=b[2]||"",a=b[5]||"",h={type:d[b[1]],endpoint:b[4]||""};c&&(h.id=c,b[3]?h.ack="data":h.ack=!0);switch(h.type){case"error":var b=a.split("+");h.reason=e[b[0]]||"",h.advice=f[b[1]]||"";break;case"message":h.data=a||"";break;case"event":try{var j=g.parse(a);h.name=j.name,h.args=j.args}catch(k){}h.args=h.args||[];break;case"json":try{h.data=g.parse(a)}catch(k){}break;case"connect":h.qs=a||"";break;case"ack":var b=a.match(/^([0-9]+)(\+)?(.*)/);if(b){h.ackId=b[1],h.args=[];if(b[3])try{h.args=b[3]?g.parse(b[3]):[]}catch(k){}}break;case"disconnect":case"heartbeat":}return h},c.decodePayload=function(a){if(a[0]=="�"){var b=[];for(var d=1,e="";d<a.length;d++)a[d]=="�"?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=""):e+=a[d];return b}return[c.decodePacket(a)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a,b){this.socket=a,this.sessid=b}a.Transport=c,b.util.mixin(c,b.EventEmitter),c.prototype.onData=function(a){this.clearCloseTimeout();if(a!==""){var c=b.parser.decodePayload(a);if(c&&c.length)for(var d=0,e=c.length;d<e;d++)this.onPacket(c[d])}return this},c.prototype.onPacket=function(a){if(a.type=="heartbeat")return this.onHeartbeat();if(a.type=="disconnect"&&a.endpoint=="")return this.onDisconnect();this.socket.onPacket(a);return this},c.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}},c.prototype.onDisconnect=function(){this.close&&this.close(),this.clearTimeouts(),this.socket.onDisconnect();return this},c.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},c.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},c.prototype.packet=function(a){this.send(b.parser.encodePacket(a))},c.prototype.onHeartbeat=function(a){this.packet({type:"heartbeat"})},c.prototype.onOpen=function(){this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){this.reopenTimeout=setTimeout(function(){this.open()},this.socket.options["reopen delay"]),this.setCloseTimeout(),this.socket.onClose()},c.prototype.prepareUrl=function(){return this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){!a||(b.Transport.apply(this,arguments),this.sendBuffer=[])}a.XHR=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.get(),this.setCloseTimeout();return this},c.prototype.checkSend=function(){if(!this.posting&&this.sendBuffer.length){var a=b.parser.encodePayload(this.sendBuffer);this.sendBuffer=[],this.post(a)}},c.prototype.send=function(a){b.util.isArray(a)?this.sendBuffer.push.apply(this.sendBuffer,a):this.sendBuffer.push(a),this.checkSend();return this},c.prototype.post=function(a){function c(){b.sendXHR.readyState==4&&(b.sendXHR.onreadystatechange=b.sendXHR.onload=d,b.posting=!1,b.sendXHR.status==200?b.checkSend():b.onClose())}var b=this;this.posting=!0,this.sendXHR=this.request("POST"),window.XDomainRequest&&this.xhr instanceof XDomainRequest?this.sendXHR.onload=c:this.sendXHR.onreadystatechange=c,this.sendXHR.send(a)},c.prototype.onClose=function(){if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=d;try{this.xhr.abort()}catch(a){}this.xhr=null}if(this.sendXHR){this.sendXHR.onreadystatechange=this.sendXHR.onload=d;try{this.sendXHR.abort()}catch(a){}this.sendXHR=null}this.sendBuffer=[],b.Transport.prototype.onClose.call(this)},c.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain());c.open(a||"GET",this.prepareUrl()+"?t"+ +(new Date)),a=="POST"&&(c.setRequestHeader?c.setRequestHeader("Content-type","text/plain"):c.contentType="text/plain");return c},c.prototype.scheme=function(){return this.socket.options.secure?"https://":"http://"},c.check=function(a){try{if(b.util.request(a))return!0}catch(c){}return!1},c.xdomainCheck=function(){return c.check(!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(){b.Transport.XHR.apply(this,arguments),this.name="xhr-polling"}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.open=function(){var a=this;b.util.defer(function(){b.Transport.XHR.prototype.open.call(a)});return!1},c.prototype.get=function(){function b(){a.xhr.readyState==4&&(a.xhr.onreadystatechange=a.xhr.onload=d,a.xhr.status==200?(a.onData(a.xhr.responseText),a.get()):a.onClose())}var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=function(b){a.onError(b)}):this.xhr.onreadystatechange=b,this.xhr.send(null)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){if(!!a){b.Transport["xhr-polling"].apply(this,arguments),this.name="jsonp-polling",this.insertAt=document.getElementsByTagName("script")[0],this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}}a["jsonp-polling"]=c,b.util.inherit(c,b.Transport["xhr-polling"]),c.prototype.post=function(a){function h(){b.iframe&&b.form.removeChild(b.iframe);try{f=document.createElement('<iframe name="'+b.iframeId+'">')}catch(a){f=document.createElement("iframe"),f.name=b.iframeId}f.id=b.iframeId,b.form.appendChild(f),b.iframe=f}function g(){h(),b.posting=!1,b.checkSend()}var b=this;if(!this.form){var c=document.createElement("FORM"),d=document.createElement("TEXTAREA"),e=this.iframeId="socketio_iframe_"+this.index,f;c.className="socketio",c.style.position="absolute",c.style.top="-1000px",c.style.left="-1000px",c.target=e,c.method="POST",c.action=this.prepareUrl()+"?t="+ +(new Date)+"&i="+this.index,d.name="data",c.appendChild(d),this.insertAt.parentNode.insertBefore(c,this.insertAt),document.body.appendChild(c),this.form=c,this.area=d}h(),this.posting=!0,this.area.value=a;try{this.form.submit()}catch(i){}this.iframe.attachEvent?f.onreadystatechange=function(){b.iframe.readyState=="complete"&&g()}:this.iframe.onload=g},c.prototype.get=function(){var a=this,b=document.createElement("SCRIPT");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.prepareUrl()+"/?t="+ +(new Date)+"&i="+this.index,b.onerror=function(){a.onClose()},this.insertAt.parentNode.insertBefore(b,this.insertAt),this.script=b},c.prototype._=function(a){this.onData(a),this.get();return this},c.check=function(){return!0},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.apply(this,arguments),this.name="websocket"}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen()},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose()},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.close=function(){this.websocket.close();return this},c.prototype.onError=function(a){this.socket.onError(a)},c.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},c.prototype.prepareUrl=function(){return this.scheme()+"://"+this.socket.options.host+":"+this.socket.options.port+"/"+this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid},c.check=function(){return!!window.WebSocket},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.XHR.apply(this,arguments),this.name="htmlfile"}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.get=function(){var a=this;this.open(),window.attachEvent("onunload",function(){a.destroy()})},c.prototype.open=function(){this.doc=new ActiveXObject("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.parentWindow.s=this,this.doc.close();var a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe),this.iframe.src=this.prepareUrl()+"/?t="+ +(new Date),this.onOpen()},c.prototype._=function(a,b){this.onData(a);var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,CollectGarbage()}},c.prototype.close=function(){this.destroy();return b.Transport.XHR.prototype.close.call(this)},c.check=function(){if("ActiveXObject"in window)try{var a=new ActiveXObject("htmlfile");return a&&b.Transport.XHR.check()}catch(c){}return!1},c.xdomainCheck=function(){return!1}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(a,b){this.namespace=a,this.name=b}function c(a,b){this.socket=a,this.name=b||"",this.flags={},this.json=new d(this,"json"),this.ackPackets=0,this.acks={}}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.packet=function(a){a.endpoint=this.name,this.socket.packet(a),this.flags={};return this},c.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};"function"==typeof b&&(c.id=++this.ackPackets,c.ack=b.length?"data":!0,this.acks[c.id]=b);return this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};"function"==typeof c&&(d.id=++this.ackPackets,d.ack=c.length?"data":!0,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.onPacket=function(a){function e(){d.packet({type:"ack",args:b.util.toArray(arguments),ackId:a.id})}var c=a.ack=="data",d=this;switch(a.type){case"connect":case"disconnect":this.$emit(a.type);break;case"message":case"json":var f=["message",a.data];c&&f.push(e),this.emit.apply(socket,f);break;case"event":var f=[a.name].concat(a.args);c&&f.push(e),this.$emit.apply(this,f);break;case"ack":this.acks[a.ackId]&&this.acks[a.ackId].apply(this,a.args)}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){this.options={port:80,secure:!1,document:document,resource:"socket.io",transports:b.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0},b.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1;if(this.options["sync disconnect on unload"]){var c=this;b.util.on(window,"beforeunload",function(){c.disconnect(!0)},!1)}this.options["auto connect"]&&this.connect()}a.Socket=c,b.util.mixin(c,b.EventEmitter),c.prototype.of=function(a){this.namespaces||(this.namespaces={}),this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a));return this.namespaces[a]},c.prototype.handshake=function(a){function e(b){b instanceof Error?c.onError(b.message):a.apply(null,b.split(":"))}var c=this,f=this.options.resource+"/"+b.protocol+"/?t="+ +(new Date);if(this.isXDomain()){var g=document.getElementsByTagName("script")[0],h=document.createElement("SCRIPT");h.src=f+"&jsonp="+b.j.length,g.parentNode.insertBefore(h,g),b.j.push(function(a){e(a),h.parentNode.removeChild(h)})}else{var i=b.util.request();i.open("GET",f),i.onreadystatechange=function(){i.readyState==4&&(i.onreadystatechange=d,i.status==200?e(i.responseText):c.onError(i.responseText))},i.send(null)}},c.prototype.getTransport=function(a){var c=a||this.transports,d;for(var e=0,f;f=c[e];e++)if(b.Transport[f]&&b.Transport[f].check()&&(!this.isXDomain()||b.Transport[f].xdomainCheck()))return new b.Transport[f](this,this.sessionid);return null},c.prototype.connect=function(a){if(this.connecting)return this;var c=this;this.handshake(function(d,e,f,g){c.sessionid=d,c.closeTimeout=e,c.heartbeatTimeout=f,c.transports=b.util.intersect(g.split(","),c.options.transports),c.transport=c.getTransport();!c.transport||(c.connecting=!0,c.emit("connecting",c.transport.name),c.transport.open(),c.options.connectTimeout&&(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){if(c.options["try multiple transports"]){c.remainingTransports||(c.remainingTransports=c.transports.slice(0));var a=c.remainingTransports;while(a.length>0&&a.splice(0,1)[0]!=c.transport.name);a.length&&(c.transport=c.getTransport(a),c.connect())}(!c.remainingTransports||c.remainingTransports.length==0)&&c.emit("connect_failed")}c.remainingTransports&&c.remainingTransports.length==0&&delete c.remainingTransports},c.options["connect timeout"])),a&&typeof a=="function"&&c.once("connect",a))});return this},c.prototype.packet=function(a){this.transport.packet(a);return this},c.prototype.disconnect=function(a){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});var c=b.util.request();c.open("GET",this.resource+"/"+b.protocol+"/"+this.sessionid),a&&(c.sync=!0),this.onDisconnect()}return this},c.prototype.isXDomain=function(){var a=window.location.port||80;return this.options.host!==document.domain||this.options.port!=a},c.prototype.onConnect=function(){this.connected=!0,this.connecting=!1,this.emit("connect");for(var a in this.namespaces)this.of(a).$emit("connect")},c.prototype.onOpen=function(){this.open=!0},c.prototype.onClose=function(){this.open=!1},c.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},c.prototype.onError=function(a){this.emit("error",a);for(var b in this.namespaces)this.of(b).$emit("error",a)},c.prototype.onDisconnect=function(a){var b=this.connected;this.connected=!1,this.connecting=!1,this.open=!1;if(b){this.emit("disconnect"),this.transport.clearTimeouts();for(var c in this.namespaces)this.of(c).$emit("disconnect",a);this.options.reconnect&&!this.reconnecting&&this.reconnect()}},c.prototype.reconnect=function(){function e(){if(!!a.reconnecting){if(a.connected)return d();if(a.connecting&&a.reconnecting)return a.reconnectionTimer=setTimeout(e,1e3);a.reconnectionAttempts++>=b?a.redoTransports?(a.emit("reconnect_failed"),d()):(a.on("connect_failed",e),a.options["try multiple transports"]=!0,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay*=2,a.connect(),a.emit("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.emit("reconnect",a.transport.name,a.reconnectionAttempts),a.removeListener("connect_failed",e),a.removeListener("connect",e),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var a=this,b=this.options["max reconnection attempts"],c=this.options["try multiple transports"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(e,this.reconnectionDelay),this.on("connect",e)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports)
 * (c) 2014-2022 Guillermo Rauch
 * Released under the MIT License.
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,n){return u=c()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&a(i,n.prototype),i},u.apply(null,arguments)}function h(t){var e="function"==typeof Map?new Map:void 0;return h=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return u(t,arguments,s(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},h(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function p(t){var e=c();return function(){var n,r=s(t);if(e){var i=s(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return l(this,n)}}function d(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}function y(){return y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=d(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},y.apply(this,arguments)}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function g(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return v(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var m=Object.create(null);m.open="0",m.close="1",m.ping="2",m.pong="3",m.message="4",m.upgrade="5",m.noop="6";var b=Object.create(null);Object.keys(m).forEach((function(t){b[m[t]]=t}));for(var k={type:"error",data:"parser error"},w="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),_="function"==typeof ArrayBuffer,O=function(t,e,n){var r,i=t.type,o=t.data;return w&&o instanceof Blob?e?n(o):E(o,n):_&&(o instanceof ArrayBuffer||(r=o,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer))?e?n(o):E(new Blob([o]),n):n(m[i]+(o||""))},E=function(t,e){var n=new FileReader;return n.onload=function(){var t=n.result.split(",")[1];e("b"+t)},n.readAsDataURL(t)},A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",R="undefined"==typeof Uint8Array?[]:new Uint8Array(256),T=0;T<A.length;T++)R[A.charCodeAt(T)]=T;var C="function"==typeof ArrayBuffer,B=function(t,e){if("string"!=typeof t)return{type:"message",data:N(t,e)};var n=t.charAt(0);return"b"===n?{type:"message",data:S(t.substring(1),e)}:b[n]?t.length>1?{type:b[n],data:t.substring(1)}:{type:b[n]}:k},S=function(t,e){if(C){var n=function(t){var e,n,r,i,o,s=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var u=new ArrayBuffer(s),h=new Uint8Array(u);for(e=0;e<a;e+=4)n=R[t.charCodeAt(e)],r=R[t.charCodeAt(e+1)],i=R[t.charCodeAt(e+2)],o=R[t.charCodeAt(e+3)],h[c++]=n<<2|r>>4,h[c++]=(15&r)<<4|i>>2,h[c++]=(3&i)<<6|63&o;return u}(t);return N(n,e)}return{base64:!0,data:t}},N=function(t,e){return"blob"===e&&t instanceof ArrayBuffer?new Blob([t]):t},x=String.fromCharCode(30);function L(t){if(t)return function(t){for(var e in L.prototype)t[e]=L.prototype[e];return t}(t)}L.prototype.on=L.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},L.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<r.length;i++)if((n=r[i])===e||n.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+t],this},L.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,e)}return this},L.prototype.emitReserved=L.prototype.emit,L.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},L.prototype.hasListeners=function(t){return!!this.listeners(t).length};var P="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function j(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.reduce((function(e,n){return t.hasOwnProperty(n)&&(e[n]=t[n]),e}),{})}var q=setTimeout,I=clearTimeout;function D(t,e){e.useNativeTimers?(t.setTimeoutFn=q.bind(P),t.clearTimeoutFn=I.bind(P)):(t.setTimeoutFn=setTimeout.bind(P),t.clearTimeoutFn=clearTimeout.bind(P))}var F,M=function(t){o(i,t);var n=p(i);function i(t,r,o){var s;return e(this,i),(s=n.call(this,t)).description=r,s.context=o,s.type="TransportError",s}return r(i)}(h(Error)),U=function(t){o(i,t);var n=p(i);function i(t){var r;return e(this,i),(r=n.call(this)).writable=!1,D(f(r),t),r.opts=t,r.query=t.query,r.readyState="",r.socket=t.socket,r}return r(i,[{key:"onError",value:function(t,e,n){return y(s(i.prototype),"emitReserved",this).call(this,"error",new M(t,e,n)),this}},{key:"open",value:function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(t){"open"===this.readyState&&this.write(t)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,y(s(i.prototype),"emitReserved",this).call(this,"open")}},{key:"onData",value:function(t){var e=B(t,this.socket.binaryType);this.onPacket(e)}},{key:"onPacket",value:function(t){y(s(i.prototype),"emitReserved",this).call(this,"packet",t)}},{key:"onClose",value:function(t){this.readyState="closed",y(s(i.prototype),"emitReserved",this).call(this,"close",t)}}]),i}(L),V="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),H={},K=0,Y=0;function z(t){var e="";do{e=V[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function W(){var t=z(+new Date);return t!==F?(K=0,F=t):t+"."+z(K++)}for(;Y<64;Y++)H[V[Y]]=Y;function $(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function J(t){for(var e={},n=t.split("&"),r=0,i=n.length;r<i;r++){var o=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}var X=!1;try{X="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}var G=X;function Q(t){var e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||G))return new XMLHttpRequest}catch(t){}if(!e)try{return new(P[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function Z(){}var tt=null!=new Q({xdomain:!1}).responseType,et=function(t){o(s,t);var n=p(s);function s(t){var r;if(e(this,s),(r=n.call(this,t)).polling=!1,"undefined"!=typeof location){var i="https:"===location.protocol,o=location.port;o||(o=i?"443":"80"),r.xd="undefined"!=typeof location&&t.hostname!==location.hostname||o!==t.port,r.xs=t.secure!==i}var a=t&&t.forceBase64;return r.supportsBinary=tt&&!a,r}return r(s,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(t){var e=this;this.readyState="pausing";var n=function(){e.readyState="paused",t()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(t){var e=this;(function(t,e){for(var n=t.split(x),r=[],i=0;i<n.length;i++){var o=B(n[i],e);if(r.push(o),"error"===o.type)break}return r})(t,this.socket.binaryType).forEach((function(t){if("opening"===e.readyState&&"open"===t.type&&e.onOpen(),"close"===t.type)return e.onClose({description:"transport closed by the server"}),!1;e.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var t=this,e=function(){t.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}},{key:"write",value:function(t){var e=this;this.writable=!1,function(t,e){var n=t.length,r=new Array(n),i=0;t.forEach((function(t,o){O(t,!1,(function(t){r[o]=t,++i===n&&e(r.join(x))}))}))}(t,(function(t){e.doWrite(t,(function(){e.writable=!0,e.emitReserved("drain")}))}))}},{key:"uri",value:function(){var t=this.query||{},e=this.opts.secure?"https":"http",n="";!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=W()),this.supportsBinary||t.sid||(t.b64=1),this.opts.port&&("https"===e&&443!==Number(this.opts.port)||"http"===e&&80!==Number(this.opts.port))&&(n=":"+this.opts.port);var r=$(t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}},{key:"request",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(t,{xd:this.xd,xs:this.xs},this.opts),new nt(this.uri(),t)}},{key:"doWrite",value:function(t,e){var n=this,r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(function(t,e){n.onError("xhr post error",t,e)}))}},{key:"doPoll",value:function(){var t=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(function(e,n){t.onError("xhr poll error",e,n)})),this.pollXhr=e}}]),s}(U),nt=function(t){o(i,t);var n=p(i);function i(t,r){var o;return e(this,i),D(f(o=n.call(this)),r),o.opts=r,o.method=r.method||"GET",o.uri=t,o.async=!1!==r.async,o.data=void 0!==r.data?r.data:null,o.create(),o}return r(i,[{key:"create",value:function(){var t=this,e=j(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;var n=this.xhr=new Q(e);try{n.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(var r in n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}catch(t){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{n.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||1223===n.status?t.onLoad():t.setTimeoutFn((function(){t.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((function(){t.onError(e)}),0)}"undefined"!=typeof document&&(this.index=i.requestsCount++,i.requests[this.index]=this)}},{key:"onError",value:function(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Z,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete i.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}]),i}(L);if(nt.requestsCount=0,nt.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",rt);else if("function"==typeof addEventListener){addEventListener("onpagehide"in P?"pagehide":"unload",rt,!1)}function rt(){for(var t in nt.requests)nt.requests.hasOwnProperty(t)&&nt.requests[t].abort()}var it="function"==typeof Promise&&"function"==typeof Promise.resolve?function(t){return Promise.resolve().then(t)}:function(t,e){return e(t,0)},ot=P.WebSocket||P.MozWebSocket,st="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),at=function(t){o(i,t);var n=p(i);function i(t){var r;return e(this,i),(r=n.call(this,t)).supportsBinary=!t.forceBase64,r}return r(i,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var t=this.uri(),e=this.opts.protocols,n=st?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=st?new ot(t,e,n):e?new ot(t,e):new ot(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=function(e){return t.onClose({description:"websocket connection closed",context:e})},this.ws.onmessage=function(e){return t.onData(e.data)},this.ws.onerror=function(e){return t.onError("websocket error",e)}}},{key:"write",value:function(t){var e=this;this.writable=!1;for(var n=function(n){var r=t[n],i=n===t.length-1;O(r,e.supportsBinary,(function(t){try{e.ws.send(t)}catch(t){}i&&it((function(){e.writable=!0,e.emitReserved("drain")}),e.setTimeoutFn)}))},r=0;r<t.length;r++)n(r)}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var t=this.query||{},e=this.opts.secure?"wss":"ws",n="";this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"===e&&80!==Number(this.opts.port))&&(n=":"+this.opts.port),this.opts.timestampRequests&&(t[this.opts.timestampParam]=W()),this.supportsBinary||(t.b64=1);var r=$(t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}},{key:"check",value:function(){return!!ot}}]),i}(U),ct={websocket:at,polling:et},ut=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ht=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ft(t){var e=t,n=t.indexOf("["),r=t.indexOf("]");-1!=n&&-1!=r&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));for(var i,o,s=ut.exec(t||""),a={},c=14;c--;)a[ht[c]]=s[c]||"";return-1!=n&&-1!=r&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(t,e){var n=/\/{2,9}/g,r=e.replace(n,"/").split("/");"/"!=e.slice(0,1)&&0!==e.length||r.splice(0,1);"/"==e.slice(-1)&&r.splice(r.length-1,1);return r}(0,a.path),a.queryKey=(i=a.query,o={},i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(o[e]=n)})),o),a}var lt=function(n){o(a,n);var s=p(a);function a(n){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(this,a),r=s.call(this),n&&"object"===t(n)&&(o=n,n=null),n?(n=ft(n),o.hostname=n.host,o.secure="https"===n.protocol||"wss"===n.protocol,o.port=n.port,n.query&&(o.query=n.query)):o.host&&(o.hostname=ft(o.host).host),D(f(r),o),r.secure=null!=o.secure?o.secure:"undefined"!=typeof location&&"https:"===location.protocol,o.hostname&&!o.port&&(o.port=r.secure?"443":"80"),r.hostname=o.hostname||("undefined"!=typeof location?location.hostname:"localhost"),r.port=o.port||("undefined"!=typeof location&&location.port?location.port:r.secure?"443":"80"),r.transports=o.transports||["polling","websocket"],r.readyState="",r.writeBuffer=[],r.prevBufferLen=0,r.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},o),r.opts.path=r.opts.path.replace(/\/$/,"")+"/","string"==typeof r.opts.query&&(r.opts.query=J(r.opts.query)),r.id=null,r.upgrades=null,r.pingInterval=null,r.pingTimeout=null,r.pingTimeoutTimer=null,"function"==typeof addEventListener&&(r.opts.closeOnBeforeunload&&(r.beforeunloadEventListener=function(){r.transport&&(r.transport.removeAllListeners(),r.transport.close())},addEventListener("beforeunload",r.beforeunloadEventListener,!1)),"localhost"!==r.hostname&&(r.offlineEventListener=function(){r.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",r.offlineEventListener,!1))),r.open(),r}return r(a,[{key:"createTransport",value:function(t){var e=i({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);var n=i({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new ct[t](n)}},{key:"open",value:function(){var t,e=this;if(this.opts.rememberUpgrade&&a.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){e.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(t){return e.onClose("transport close",t)}))}},{key:"probe",value:function(t){var e=this,n=this.createTransport(t),r=!1;a.priorWebsocketSuccess=!1;var i=function(){r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(function(t){if(!r)if("pong"===t.type&&"probe"===t.data){if(e.upgrading=!0,e.emitReserved("upgrading",n),!n)return;a.priorWebsocketSuccess="websocket"===n.name,e.transport.pause((function(){r||"closed"!==e.readyState&&(f(),e.setTransport(n),n.send([{type:"upgrade"}]),e.emitReserved("upgrade",n),n=null,e.upgrading=!1,e.flush())}))}else{var i=new Error("probe error");i.transport=n.name,e.emitReserved("upgradeError",i)}})))};function o(){r||(r=!0,f(),n.close(),n=null)}var s=function(t){var r=new Error("probe error: "+t);r.transport=n.name,o(),e.emitReserved("upgradeError",r)};function c(){s("transport closed")}function u(){s("socket closed")}function h(t){n&&t.name!==n.name&&o()}var f=function(){n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",c),e.off("close",u),e.off("upgrading",h)};n.once("open",i),n.once("error",s),n.once("close",c),this.once("close",u),this.once("upgrading",h),n.open()}},{key:"onOpen",value:function(){if(this.readyState="open",a.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},{key:"onPacket",value:function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}},{key:"onHandshake",value:function(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var t=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){t.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var t,e=1,n=0;n<this.writeBuffer.length;n++){var r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(t){for(var e=0,n=0,r=0,i=t.length;r<i;r++)(e=t.charCodeAt(r))<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}return this.writeBuffer}},{key:"write",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"send",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"sendPacket",value:function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var i={type:t,data:e,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var t=this,e=function(){t.onClose("forced close"),t.transport.close()},n=function n(){t.off("upgrade",n),t.off("upgradeError",n),e()},r=function(){t.once("upgrade",n),t.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():e()})):this.upgrading?r():e()),this}},{key:"onError",value:function(t){a.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}},{key:"onClose",value:function(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(t){for(var e=[],n=0,r=t.length;n<r;n++)~this.transports.indexOf(t[n])&&e.push(t[n]);return e}}]),a}(L);lt.protocol=4,lt.protocol;var pt="function"==typeof ArrayBuffer,dt=Object.prototype.toString,yt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===dt.call(Blob),vt="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===dt.call(File);function gt(t){return pt&&(t instanceof ArrayBuffer||function(t){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer}(t))||yt&&t instanceof Blob||vt&&t instanceof File}function mt(e,n){if(!e||"object"!==t(e))return!1;if(Array.isArray(e)){for(var r=0,i=e.length;r<i;r++)if(mt(e[r]))return!0;return!1}if(gt(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return mt(e.toJSON(),!0);for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&mt(e[o]))return!0;return!1}function bt(t){var e=[],n=t.data,r=t;return r.data=kt(n,e),r.attachments=e.length,{packet:r,buffers:e}}function kt(e,n){if(!e)return e;if(gt(e)){var r={_placeholder:!0,num:n.length};return n.push(e),r}if(Array.isArray(e)){for(var i=new Array(e.length),o=0;o<e.length;o++)i[o]=kt(e[o],n);return i}if("object"===t(e)&&!(e instanceof Date)){var s={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=kt(e[a],n));return s}return e}function wt(t,e){return t.data=_t(t.data,e),t.attachments=void 0,t}function _t(e,n){if(!e)return e;if(e&&e._placeholder)return n[e.num];if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]=_t(e[r],n);else if("object"===t(e))for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(e[i]=_t(e[i],n));return e}var Ot;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(Ot||(Ot={}));var Et=function(){function t(n){e(this,t),this.replacer=n}return r(t,[{key:"encode",value:function(t){return t.type!==Ot.EVENT&&t.type!==Ot.ACK||!mt(t)?[this.encodeAsString(t)]:(t.type=t.type===Ot.EVENT?Ot.BINARY_EVENT:Ot.BINARY_ACK,this.encodeAsBinary(t))}},{key:"encodeAsString",value:function(t){var e=""+t.type;return t.type!==Ot.BINARY_EVENT&&t.type!==Ot.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}},{key:"encodeAsBinary",value:function(t){var e=bt(t),n=this.encodeAsString(e.packet),r=e.buffers;return r.unshift(n),r}}]),t}(),At=function(n){o(a,n);var i=p(a);function a(t){var n;return e(this,a),(n=i.call(this)).reviver=t,n}return r(a,[{key:"add",value:function(t){var e;if("string"==typeof t)(e=this.decodeString(t)).type===Ot.BINARY_EVENT||e.type===Ot.BINARY_ACK?(this.reconstructor=new Rt(e),0===e.attachments&&y(s(a.prototype),"emitReserved",this).call(this,"decoded",e)):y(s(a.prototype),"emitReserved",this).call(this,"decoded",e);else{if(!gt(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,y(s(a.prototype),"emitReserved",this).call(this,"decoded",e))}}},{key:"decodeString",value:function(t){var e=0,n={type:Number(t.charAt(0))};if(void 0===Ot[n.type])throw new Error("unknown packet type "+n.type);if(n.type===Ot.BINARY_EVENT||n.type===Ot.BINARY_ACK){for(var r=e+1;"-"!==t.charAt(++e)&&e!=t.length;);var i=t.substring(r,e);if(i!=Number(i)||"-"!==t.charAt(e))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===t.charAt(e+1)){for(var o=e+1;++e;){if(","===t.charAt(e))break;if(e===t.length)break}n.nsp=t.substring(o,e)}else n.nsp="/";var s=t.charAt(e+1);if(""!==s&&Number(s)==s){for(var c=e+1;++e;){var u=t.charAt(e);if(null==u||Number(u)!=u){--e;break}if(e===t.length)break}n.id=Number(t.substring(c,e+1))}if(t.charAt(++e)){var h=this.tryParse(t.substr(e));if(!a.isPayloadValid(n.type,h))throw new Error("invalid payload");n.data=h}return n}},{key:"tryParse",value:function(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}},{key:"destroy",value:function(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}],[{key:"isPayloadValid",value:function(e,n){switch(e){case Ot.CONNECT:return"object"===t(n);case Ot.DISCONNECT:return void 0===n;case Ot.CONNECT_ERROR:return"string"==typeof n||"object"===t(n);case Ot.EVENT:case Ot.BINARY_EVENT:return Array.isArray(n)&&n.length>0;case Ot.ACK:case Ot.BINARY_ACK:return Array.isArray(n)}}}]),a}(L),Rt=function(){function t(n){e(this,t),this.packet=n,this.buffers=[],this.reconPack=n}return r(t,[{key:"takeBinaryData",value:function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=wt(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}(),Tt=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Ot},Encoder:Et,Decoder:At});function Ct(t,e,n){return t.on(e,n),function(){t.off(e,n)}}var Bt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),St=function(t){o(i,t);var n=p(i);function i(t,r,o){var s;return e(this,i),(s=n.call(this)).connected=!1,s.receiveBuffer=[],s.sendBuffer=[],s.ids=0,s.acks={},s.flags={},s.io=t,s.nsp=r,o&&o.auth&&(s.auth=o.auth),s.io._autoConnect&&s.open(),s}return r(i,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var t=this.io;this.subs=[Ct(t,"open",this.onopen.bind(this)),Ct(t,"packet",this.onpacket.bind(this)),Ct(t,"error",this.onerror.bind(this)),Ct(t,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.unshift("message"),this.emit.apply(this,e),this}},{key:"emit",value:function(t){if(Bt.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];n.unshift(t);var i={type:Ot.EVENT,data:n,options:{}};if(i.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var o=this.ids++,s=n.pop();this._registerAckCallback(o,s),i.id=o}var a=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable,c=this.flags.volatile&&(!a||!this.connected);return c||(this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}},{key:"_registerAckCallback",value:function(t,e){var n=this,r=this.flags.timeout;if(void 0!==r){var i=this.io.setTimeoutFn((function(){delete n.acks[t];for(var r=0;r<n.sendBuffer.length;r++)n.sendBuffer[r].id===t&&n.sendBuffer.splice(r,1);e.call(n,new Error("operation has timed out"))}),r);this.acks[t]=function(){n.io.clearTimeoutFn(i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];e.apply(n,[null].concat(r))}}else this.acks[t]=e}},{key:"packet",value:function(t){t.nsp=this.nsp,this.io._packet(t)}},{key:"onopen",value:function(){var t=this;"function"==typeof this.auth?this.auth((function(e){t.packet({type:Ot.CONNECT,data:e})})):this.packet({type:Ot.CONNECT,data:this.auth})}},{key:"onerror",value:function(t){this.connected||this.emitReserved("connect_error",t)}},{key:"onclose",value:function(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}},{key:"onpacket",value:function(t){if(t.nsp===this.nsp)switch(t.type){case Ot.CONNECT:if(t.data&&t.data.sid){var e=t.data.sid;this.onconnect(e)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ot.EVENT:case Ot.BINARY_EVENT:this.onevent(t);break;case Ot.ACK:case Ot.BINARY_ACK:this.onack(t);break;case Ot.DISCONNECT:this.ondisconnect();break;case Ot.CONNECT_ERROR:this.destroy();var n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n)}}},{key:"onevent",value:function(t){var e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}},{key:"emitEvent",value:function(t){if(this._anyListeners&&this._anyListeners.length){var e,n=g(this._anyListeners.slice());try{for(n.s();!(e=n.n()).done;){e.value.apply(this,t)}}catch(t){n.e(t)}finally{n.f()}}y(s(i.prototype),"emit",this).apply(this,t)}},{key:"ack",value:function(t){var e=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];e.packet({type:Ot.ACK,id:t,data:i})}}}},{key:"onack",value:function(t){var e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}},{key:"onconnect",value:function(t){this.id=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}},{key:"emitBuffered",value:function(){var t=this;this.receiveBuffer.forEach((function(e){return t.emitEvent(e)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(e){t.notifyOutgoingListeners(e),t.packet(e)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(t){return t()})),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:Ot.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(t){return this.flags.compress=t,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(t){return this.flags.timeout=t,this}},{key:"onAny",value:function(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}},{key:"prependAny",value:function(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}},{key:"offAny",value:function(t){if(!this._anyListeners)return this;if(t){for(var e=this._anyListeners,n=0;n<e.length;n++)if(t===e[n])return e.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}},{key:"prependAnyOutgoing",value:function(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}},{key:"offAnyOutgoing",value:function(t){if(!this._anyOutgoingListeners)return this;if(t){for(var e=this._anyOutgoingListeners,n=0;n<e.length;n++)if(t===e[n])return e.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var e,n=g(this._anyOutgoingListeners.slice());try{for(n.s();!(e=n.n()).done;){e.value.apply(this,t.data)}}catch(t){n.e(t)}finally{n.f()}}}}]),i}(L);function Nt(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Nt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},Nt.prototype.reset=function(){this.attempts=0},Nt.prototype.setMin=function(t){this.ms=t},Nt.prototype.setMax=function(t){this.max=t},Nt.prototype.setJitter=function(t){this.jitter=t};var xt=function(n){o(s,n);var i=p(s);function s(n,r){var o,a;e(this,s),(o=i.call(this)).nsps={},o.subs=[],n&&"object"===t(n)&&(r=n,n=void 0),(r=r||{}).path=r.path||"/socket.io",o.opts=r,D(f(o),r),o.reconnection(!1!==r.reconnection),o.reconnectionAttempts(r.reconnectionAttempts||1/0),o.reconnectionDelay(r.reconnectionDelay||1e3),o.reconnectionDelayMax(r.reconnectionDelayMax||5e3),o.randomizationFactor(null!==(a=r.randomizationFactor)&&void 0!==a?a:.5),o.backoff=new Nt({min:o.reconnectionDelay(),max:o.reconnectionDelayMax(),jitter:o.randomizationFactor()}),o.timeout(null==r.timeout?2e4:r.timeout),o._readyState="closed",o.uri=n;var c=r.parser||Tt;return o.encoder=new c.Encoder,o.decoder=new c.Decoder,o._autoConnect=!1!==r.autoConnect,o._autoConnect&&o.open(),o}return r(s,[{key:"reconnection",value:function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}},{key:"reconnectionAttempts",value:function(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}},{key:"reconnectionDelay",value:function(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}},{key:"randomizationFactor",value:function(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}},{key:"reconnectionDelayMax",value:function(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}},{key:"timeout",value:function(t){return arguments.length?(this._timeout=t,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){var e=this;if(~this._readyState.indexOf("open"))return this;this.engine=new lt(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var i=Ct(n,"open",(function(){r.onopen(),t&&t()})),o=Ct(n,"error",(function(n){r.cleanup(),r._readyState="closed",e.emitReserved("error",n),t?t(n):r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;0===s&&i();var a=this.setTimeoutFn((function(){i(),n.close(),n.emit("error",new Error("timeout"))}),s);this.opts.autoUnref&&a.unref(),this.subs.push((function(){clearTimeout(a)}))}return this.subs.push(i),this.subs.push(o),this}},{key:"connect",value:function(t){return this.open(t)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var t=this.engine;this.subs.push(Ct(t,"ping",this.onping.bind(this)),Ct(t,"data",this.ondata.bind(this)),Ct(t,"error",this.onerror.bind(this)),Ct(t,"close",this.onclose.bind(this)),Ct(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}},{key:"ondecoded",value:function(t){var e=this;it((function(){e.emitReserved("packet",t)}),this.setTimeoutFn)}},{key:"onerror",value:function(t){this.emitReserved("error",t)}},{key:"socket",value:function(t,e){var n=this.nsps[t];return n||(n=new St(this,t,e),this.nsps[t]=n),n}},{key:"_destroy",value:function(t){for(var e=0,n=Object.keys(this.nsps);e<n.length;e++){var r=n[e];if(this.nsps[r].active)return}this._close()}},{key:"_packet",value:function(t){for(var e=this.encoder.encode(t),n=0;n<e.length;n++)this.engine.write(e[n],t.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(t){return t()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var t=this;if(this._reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){e.skipReconnect||(t.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),t.emitReserved("reconnect_error",n)):e.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}},{key:"onreconnect",value:function(){var t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}]),s}(L),Lt={};function Pt(e,n){"object"===t(e)&&(n=e,e=void 0);var r,i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=t;n=n||"undefined"!=typeof location&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==n?n.protocol+"//"+t:"https://"+t),r=ft(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(n=n||{}).path||"/socket.io"),o=i.source,s=i.id,a=i.path,c=Lt[s]&&a in Lt[s].nsps;return n.forceNew||n["force new connection"]||!1===n.multiplex||c?r=new xt(o,n):(Lt[s]||(Lt[s]=new xt(o,n)),r=Lt[s]),i.query&&!n.query&&(n.query=i.queryKey),r.socket(i.path,n)}return i(Pt,{Manager:xt,Socket:St,io:Pt,connect:Pt}),Pt}));
//# sourceMappingURL=socket.io.min.js.map

<MSG> Merge branch 'master' of https://github.com/LearnBoost/Socket.IO into develop

Conflicts:
	dist/socket.io.js

<DFF> @@ -1,2 +1,2 @@
 /* Socket.IO.min 0.7.0 @author Guillermo Rauch <guillermo@learnboost.com>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com> */
-(function(a){var b=a;b.version="0.7.0",b.protocol=1,b.transports=["websocket","htmlfile","xhr-polling","jsonp-polling"],b.j=[],b.sockets={},"object"==typeof module&&"function"==typeof require&&(b.util=require("./util").util,b.JSON=require("./json").JSON,b.parser=require("./parser").parser,b.EventEmitter=process.EventEmitter,b.Transport=require("./transport").Transport,b.transports.forEach(function(a){}),b.Socket=require("./socket").Socket,b.dist=__dirname+"/../dist"),b.connect=function(a,c){var d=b.util.parseUri(a);"undefined"!=typeof document&&(d.host=d.host||document.domain,d.port=d.port||document.location.port);var e=b.util.uniqueUri(d);if(c||!b.sockets[e])var f=new b.Socket({host:d.host,secure:d.protocol=="https://",port:d.port||80});c||(this.sockets[e]=f);return f.of(d.path.length>1?d.path:"")}})("object"==typeof module?module.exports:window.io={}),function(a){var b=a.util={},c=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.parseUri=function(a){var b=c.exec(a||""),e={},f=14;while(f--)e[d[f]]=b[f]||"";return e},b.uniqueUri=function(a){var b=a.protocol,c=a.host,d=a.port;"undefined"!=typeof document?(c=c||document.domain,d=d||document.location.port):c=c||"localhost";return(b||"http")+"://"+c+":"+(d||b&&b==="https"?443:80)};var e=!1;b.load=function(a){if(document.readyState==="complete"||e)return a();b.on(window,"load",a,!1)},b.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,d)};var f="undefined"!=typeof window&&window.XMLHttpRequest&&function(){var a=new XMLHttpRequest;return a.withCredentials!=undefined}();b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||f))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return null},"undefined"!=typeof window&&b.load(function(){e=!0}),b.defer=function(a){if(!b.ua.webkit)return a();b.load(function(){setTimeout(a,100)})},b.merge=function(a,b,c,d){var e=d||[],f=typeof c=="undefined"?2:c,g;for(g in b)b.hasOwnProperty(g)&&this.indexOf(e,g)<0&&(typeof a[g]!="object"||!f?(a[g]=b[g],e.push(b[g])):this.merge(a[g],b[g],f-1,e));return a},b.mixin=function(a,c){b.merge(a.prototype,c.prototype)},b.inherit=function(a,c){a.prototype=new c,b.merge(a,c)},b.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},b.intersect=function(a,c){var d=[],e=a.length>c.length?a:c,f=a.length>c.length?c:a;for(var g=0,h=f.length;g<h;g++)~b.indexOf(e,f[g])&&d.push(f[g]);return d},b.indexOf=function(a,b,c){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b,c);for(var d=a.length,c=c<0?c+d<0?0:c+d:c||0;c<d&&a[c]!==b;c++);return d<=c?-1:c},b.toArray=function(a){var b=[];for(var c=0,d=a.length;c<d;c++)b.push(a[c]);return b},b.ua={},b.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof window?io:module.exports),function(a,b){function c(){}a.EventEmitter=c,c.prototype.on=function(a,c){this.$events||(this.$events={}),this.$events[a]?b.util.isArray(this.$events[a])?this.$events[a].push(c):this.$events[a]=[this.$events[a],c]:this.$events[a]=c;return this},c.prototype.addListener=c.prototype.on,c.prototype.once=function(a,b){function d(){c.removeListener(a,d),b.apply(this,arguments)}var c=this;d.listener=b,this.on(a,d);return this},c.prototype.removeListener=function(a,c){if(this.$events&&this.$events[a]){var d=this.$events[a];if(b.util.isArray(d)){var e=-1;for(var f=0,g=d.length;f<g;f++)if(d[f]===c||d[f].listener&&d[f].listener===c){e=f;break}if(e<0)return this;d.splice(e,1),d.length||delete this.$events[a]}else(d===c||d.listener&&d.listener===c)&&delete this.$events[a]}return this},c.prototype.removeAllListeners=function(a){if(a===undefined){this.$events={};return this}this.$events&&this.$events[a]&&(this.$events[a]=null);return this},c.prototype.listeners=function(a){this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),b.util.isArray(this.$events[a])||(this.$events[a]=[this.$events[a]]);return this.$events[a]},c.prototype.emit=function(a){if(!this.$events)return!1;var c=this.$events[a];if(!c)return!1;var d=Array.prototype.slice.call(arguments,1);if("function"==typeof c)c.apply(this,d);else{if(!b.util.isArray(c))return!1;var e=c.slice();for(var f=0,g=e.length;f<g;f++)e[f].apply(this,d)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i instanceof Date&&(i=date(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function date(a,b){return isFinite(a.valueOf())?a.getUTCFullYear()+"-"+f(a.getUTCMonth()+1)+"-"+f(a.getUTCDate())+"T"+f(a.getUTCHours())+":"+f(a.getUTCMinutes())+":"+f(a.getUTCSeconds())+"Z":null}function f(a){return a<10?"0"+a:a}"use strict";if(nativeJSON&&nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(b&&typeof b!="function"&&(typeof b!="object"||typeof b.length!="number"))throw new Error("JSON.stringify");return str("",{"":a})},JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,JSON),function(a,b){var c=a.parser={},d=c.packets=["disconnect","connect","heartbeat","message","json","event","ack","error"],e=c.reasons=["transport not supported","client not handshaken","unauthorized"],f=c.advice=["reconnect"],g=b.JSON,h=b.util.indexOf;c.encodePacket=function(a){var b=d.indexOf(a.type),c=a.id||"",h=a.endpoint||"",i=a.ack,j=null;switch(a.type){case"error":var k=a.reason?e.indexOf(a.reason):"",l=a.advice?f.indexOf(a.advice):"";if(k!==""||l!=="")j=k+(l!==""?"+"+l:"");break;case"message":a.data!==""&&(j=a.data);break;case"event":var m={name:a.name};a.args&&a.args.length&&(m.args=a.args),j=g.stringify(m);break;case"json":j=g.stringify(a.data);break;case"connect":a.qs&&(j=a.qs);break;case"ack":j=a.ackId+(a.args&&a.args.length?"+"+g.stringify(a.args):"");break;case"heartbeat":case"disconect":}var n=[b,c+(i=="data"?"+":""),h];j!==null&&j!==undefined&&n.push(j);return n.join(":")},c.encodePayload=function(a){var b="";if(a.length==1)return a[0];for(var c=0,d=a.length;c<d;c++){var e=a[c];b+="�"+e.length+"�"+a[c]}return b};var i=/^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;c.decodePacket=function(a){var b=a.match(i);if(!b)return{};var c=b[2]||"",a=b[5]||"",h={type:d[b[1]],endpoint:b[4]||""};c&&(h.id=c,b[3]?h.ack="data":h.ack=!0);switch(h.type){case"error":var b=a.split("+");h.reason=e[b[0]]||"",h.advice=f[b[1]]||"";break;case"message":h.data=a||"";break;case"event":try{var j=g.parse(a);h.name=j.name,h.args=j.args}catch(k){}h.args=h.args||[];break;case"json":try{h.data=g.parse(a)}catch(k){}break;case"connect":h.qs=a||"";break;case"ack":var b=a.match(/^([0-9]+)(\+)?(.*)/);if(b){h.ackId=b[1],h.args=[];if(b[3])try{h.args=b[3]?g.parse(b[3]):[]}catch(k){}}break;case"disconnect":case"heartbeat":}return h},c.decodePayload=function(a){if(a[0]=="�"){var b=[];for(var d=1,e="";d<a.length;d++)a[d]=="�"?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=""):e+=a[d];return b}return[c.decodePacket(a)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a,b){this.socket=a,this.sessid=b}a.Transport=c,b.util.mixin(c,b.EventEmitter),c.prototype.onData=function(a){this.clearCloseTimeout();if(a!==""){var c=b.parser.decodePayload(a);if(c&&c.length)for(var d=0,e=c.length;d<e;d++)this.onPacket(c[d])}return this},c.prototype.onPacket=function(a){if(a.type=="heartbeat")return this.onHeartbeat();if(a.type=="disconnect"&&a.endpoint=="")return this.onDisconnect();this.socket.onPacket(a);return this},c.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}},c.prototype.onDisconnect=function(){this.close&&this.close(),this.clearTimeouts(),this.socket.onDisconnect();return this},c.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},c.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},c.prototype.packet=function(a){this.send(b.parser.encodePacket(a))},c.prototype.onHeartbeat=function(a){this.packet({type:"heartbeat"})},c.prototype.onOpen=function(){this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){this.reopenTimeout=setTimeout(function(){this.open()},this.socket.options["reopen delay"]),this.setCloseTimeout(),this.socket.onClose()},c.prototype.prepareUrl=function(){return this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){!a||(b.Transport.apply(this,arguments),this.sendBuffer=[])}a.XHR=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.get(),this.setCloseTimeout();return this},c.prototype.checkSend=function(){if(!this.posting&&this.sendBuffer.length){var a=b.parser.encodePayload(this.sendBuffer);this.sendBuffer=[],this.post(a)}},c.prototype.send=function(a){b.util.isArray(a)?this.sendBuffer.push.apply(this.sendBuffer,a):this.sendBuffer.push(a),this.checkSend();return this},c.prototype.post=function(a){function c(){b.sendXHR.readyState==4&&(b.sendXHR.onreadystatechange=b.sendXHR.onload=d,b.posting=!1,b.sendXHR.status==200?b.checkSend():b.onClose())}var b=this;this.posting=!0,this.sendXHR=this.request("POST"),window.XDomainRequest&&this.xhr instanceof XDomainRequest?this.sendXHR.onload=c:this.sendXHR.onreadystatechange=c,this.sendXHR.send(a)},c.prototype.onClose=function(){if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=d;try{this.xhr.abort()}catch(a){}this.xhr=null}if(this.sendXHR){this.sendXHR.onreadystatechange=this.sendXHR.onload=d;try{this.sendXHR.abort()}catch(a){}this.sendXHR=null}this.sendBuffer=[],b.Transport.prototype.onClose.call(this)},c.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain());c.open(a||"GET",this.prepareUrl()+"?t"+ +(new Date)),a=="POST"&&(c.setRequestHeader?c.setRequestHeader("Content-type","text/plain"):c.contentType="text/plain");return c},c.prototype.scheme=function(){return this.socket.options.secure?"https://":"http://"},c.check=function(a){try{if(b.util.request(a))return!0}catch(c){}return!1},c.xdomainCheck=function(){return c.check(!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(){b.Transport.XHR.apply(this,arguments),this.name="xhr-polling"}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.open=function(){var a=this;b.util.defer(function(){b.Transport.XHR.prototype.open.call(a)});return!1},c.prototype.get=function(){function b(){a.xhr.readyState==4&&(a.xhr.onreadystatechange=a.xhr.onload=d,a.xhr.status==200?(a.onData(a.xhr.responseText),a.get()):a.onClose())}var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=function(b){a.onError(b)}):this.xhr.onreadystatechange=b,this.xhr.send(null)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){if(!!a){b.Transport["xhr-polling"].apply(this,arguments),this.name="jsonp-polling",this.insertAt=document.getElementsByTagName("script")[0],this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}}a["jsonp-polling"]=c,b.util.inherit(c,b.Transport["xhr-polling"]),c.prototype.post=function(a){function h(){b.iframe&&b.form.removeChild(b.iframe);try{f=document.createElement('<iframe name="'+b.iframeId+'">')}catch(a){f=document.createElement("iframe"),f.name=b.iframeId}f.id=b.iframeId,b.form.appendChild(f),b.iframe=f}function g(){h(),b.posting=!1,b.checkSend()}var b=this;if(!this.form){var c=document.createElement("FORM"),d=document.createElement("TEXTAREA"),e=this.iframeId="socketio_iframe_"+this.index,f;c.className="socketio",c.style.position="absolute",c.style.top="-1000px",c.style.left="-1000px",c.target=e,c.method="POST",c.action=this.prepareUrl()+"?t="+ +(new Date)+"&i="+this.index,d.name="data",c.appendChild(d),this.insertAt.parentNode.insertBefore(c,this.insertAt),document.body.appendChild(c),this.form=c,this.area=d}h(),this.posting=!0,this.area.value=a;try{this.form.submit()}catch(i){}this.iframe.attachEvent?f.onreadystatechange=function(){b.iframe.readyState=="complete"&&g()}:this.iframe.onload=g},c.prototype.get=function(){var a=this,b=document.createElement("SCRIPT");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.prepareUrl()+"/?t="+ +(new Date)+"&i="+this.index,b.onerror=function(){a.onClose()},this.insertAt.parentNode.insertBefore(b,this.insertAt),this.script=b},c.prototype._=function(a){this.onData(a),this.get();return this},c.check=function(){return!0},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.apply(this,arguments),this.name="websocket"}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen()},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose()},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.close=function(){this.websocket.close();return this},c.prototype.onError=function(a){this.socket.onError(a)},c.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},c.prototype.prepareUrl=function(){return this.scheme()+"://"+this.socket.options.host+":"+this.socket.options.port+"/"+this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid},c.check=function(){return!!window.WebSocket},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.XHR.apply(this,arguments),this.name="htmlfile"}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.get=function(){var a=this;this.open(),window.attachEvent("onunload",function(){a.destroy()})},c.prototype.open=function(){this.doc=new ActiveXObject("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.parentWindow.s=this,this.doc.close();var a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe),this.iframe.src=this.prepareUrl()+"/?t="+ +(new Date),this.onOpen()},c.prototype._=function(a,b){this.onData(a);var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,CollectGarbage()}},c.prototype.close=function(){this.destroy();return b.Transport.XHR.prototype.close.call(this)},c.check=function(){if("ActiveXObject"in window)try{var a=new ActiveXObject("htmlfile");return a&&b.Transport.XHR.check()}catch(c){}return!1},c.xdomainCheck=function(){return!1}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(a,b){this.namespace=a,this.name=b}function c(a,b){this.socket=a,this.name=b||"",this.flags={},this.json=new d(this,"json"),this.ackPackets=0,this.acks={}}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.packet=function(a){a.endpoint=this.name,this.socket.packet(a),this.flags={};return this},c.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};"function"==typeof b&&(c.id=++this.ackPackets,c.ack=b.length?"data":!0,this.acks[c.id]=b);return this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};"function"==typeof c&&(d.id=++this.ackPackets,d.ack=c.length?"data":!0,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.onPacket=function(a){function e(){d.packet({type:"ack",args:b.util.toArray(arguments),ackId:a.id})}var c=a.ack=="data",d=this;switch(a.type){case"connect":case"disconnect":this.$emit(a.type);break;case"message":case"json":var f=["message",a.data];c&&f.push(e),this.emit.apply(socket,f);break;case"event":var f=[a.name].concat(a.args);c&&f.push(e),this.$emit.apply(this,f);break;case"ack":this.acks[a.ackId]&&this.acks[a.ackId].apply(this,a.args)}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){this.options={port:80,secure:!1,document:document,resource:"socket.io",transports:b.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0},b.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1;if(this.options["sync disconnect on unload"]){var c=this;b.util.on(window,"beforeunload",function(){c.disconnect(!0)},!1)}this.options["auto connect"]&&this.connect()}a.Socket=c,b.util.mixin(c,b.EventEmitter),c.prototype.of=function(a){this.namespaces||(this.namespaces={}),this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a));return this.namespaces[a]},c.prototype.handshake=function(a){function e(b){b instanceof Error?c.onError(b.message):a.apply(null,b.split(":"))}var c=this,f=this.options.resource+"/"+b.protocol+"/?t="+ +(new Date);if(this.isXDomain()){var g=document.getElementsByTagName("script")[0],h=document.createElement("SCRIPT");h.src=f+"&jsonp="+b.j.length,g.parentNode.insertBefore(h,g),b.j.push(function(a){e(a),h.parentNode.removeChild(h)})}else{var i=b.util.request();i.open("GET",f),i.onreadystatechange=function(){i.readyState==4&&(i.onreadystatechange=d,i.status==200?e(i.responseText):c.onError(i.responseText))},i.send(null)}},c.prototype.getTransport=function(a){var c=a||this.transports,d;for(var e=0,f;f=c[e];e++)if(b.Transport[f]&&b.Transport[f].check()&&(!this.isXDomain()||b.Transport[f].xdomainCheck()))return new b.Transport[f](this,this.sessionid);return null},c.prototype.connect=function(a){if(this.connecting)return this;var c=this;this.handshake(function(d,e,f,g){c.sessionid=d,c.closeTimeout=e,c.heartbeatTimeout=f,c.transports=b.util.intersect(g.split(","),c.options.transports),c.transport=c.getTransport();!c.transport||(c.connecting=!0,c.emit("connecting",c.transport.name),c.transport.open(),c.options.connectTimeout&&(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){if(c.options["try multiple transports"]){c.remainingTransports||(c.remainingTransports=c.transports.slice(0));var a=c.remainingTransports;while(a.length>0&&a.splice(0,1)[0]!=c.transport.name);a.length&&(c.transport=c.getTransport(a),c.connect())}(!c.remainingTransports||c.remainingTransports.length==0)&&c.emit("connect_failed")}c.remainingTransports&&c.remainingTransports.length==0&&delete c.remainingTransports},c.options["connect timeout"])),a&&typeof a=="function"&&c.once("connect",a))});return this},c.prototype.packet=function(a){this.transport.packet(a);return this},c.prototype.disconnect=function(a){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});var c=b.util.request();c.open("GET",this.resource+"/"+b.protocol+"/"+this.sessionid),a&&(c.sync=!0),this.onDisconnect()}return this},c.prototype.isXDomain=function(){var a=window.location.port||80;return this.options.host!==document.domain||this.options.port!=a},c.prototype.onConnect=function(){this.connected=!0,this.connecting=!1,this.emit("connect");for(var a in this.namespaces)this.of(a).$emit("connect")},c.prototype.onOpen=function(){this.open=!0},c.prototype.onClose=function(){this.open=!1},c.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},c.prototype.onError=function(a){this.emit("error",a);for(var b in this.namespaces)this.of(b).$emit("error",a)},c.prototype.onDisconnect=function(a){var b=this.connected;this.connected=!1,this.connecting=!1,this.open=!1;if(b){this.emit("disconnect"),this.transport.clearTimeouts();for(var c in this.namespaces)this.of(c).$emit("disconnect",a);this.options.reconnect&&!this.reconnecting&&this.reconnect()}},c.prototype.reconnect=function(){function e(){if(!!a.reconnecting){if(a.connected)return d();if(a.connecting&&a.reconnecting)return a.reconnectionTimer=setTimeout(e,1e3);a.reconnectionAttempts++>=b?a.redoTransports?(a.emit("reconnect_failed"),d()):(a.on("connect_failed",e),a.options["try multiple transports"]=!0,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay*=2,a.connect(),a.emit("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.emit("reconnect",a.transport.name,a.reconnectionAttempts),a.removeListener("connect_failed",e),a.removeListener("connect",e),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var a=this,b=this.options["max reconnection attempts"],c=this.options["try multiple transports"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(e,this.reconnectionDelay),this.on("connect",e)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports)
\ No newline at end of file
+(function(a){var b=a;b.version="0.7.0",b.protocol=1,b.transports=["websocket","htmlfile","xhr-polling","jsonp-polling"],b.j=[],b.sockets={},"object"==typeof module&&"function"==typeof require&&(b.util=require("./util").util,b.JSON=require("./json").JSON,b.parser=require("./parser").parser,b.EventEmitter=process.EventEmitter,b.Transport=require("./transport").Transport,b.transports.forEach(function(a){}),b.Socket=require("./socket").Socket,b.dist=__dirname+"/../dist"),b.connect=function(a,c){var d=b.util.parseUri(a);"undefined"!=typeof document&&(d.host=d.host||document.domain,d.port=d.port||document.location.port);var e=b.util.uniqueUri(d);if(c||!b.sockets[e])var f=new b.Socket({host:d.host,secure:d.protocol=="https://",port:d.port||80});c||(this.sockets[e]=f);return f.of(d.path.length>1?d.path:"")}})("object"==typeof module?module.exports:window.io={}),function(a){var b=a.util={},c=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.parseUri=function(a){var b=c.exec(a||""),e={},f=14;while(f--)e[d[f]]=b[f]||"";return e},b.uniqueUri=function(a){var b=a.protocol,c=a.host,d=a.port;"undefined"!=typeof document?(c=c||document.domain,d=d||document.location.port):c=c||"localhost";return(b||"http")+"://"+c+":"+(d||b&&b==="https"?443:80)};var e=!1;b.load=function(a){if(document.readyState==="complete"||e)return a();b.on(window,"load",a,!1)},b.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,d)};var f="undefined"!=typeof window&&window.XMLHttpRequest&&function(){var a=new XMLHttpRequest;return a.withCredentials!=undefined}();b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||f))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return null},"undefined"!=typeof window&&b.load(function(){e=!0}),b.defer=function(a){if(!b.ua.webkit)return a();b.load(function(){setTimeout(a,100)})},b.merge=function(a,b,c,d){var e=d||[],f=typeof c=="undefined"?2:c,g;for(g in b)b.hasOwnProperty(g)&&this.indexOf(e,g)<0&&(typeof a[g]!="object"||!f?(a[g]=b[g],e.push(b[g])):this.merge(a[g],b[g],f-1,e));return a},b.mixin=function(a,c){b.merge(a.prototype,c.prototype)},b.inherit=function(a,c){a.prototype=new c,b.merge(a,c)},b.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},b.intersect=function(a,c){var d=[],e=a.length>c.length?a:c,f=a.length>c.length?c:a;for(var g=0,h=f.length;g<h;g++)~b.indexOf(e,f[g])&&d.push(f[g]);return d},b.indexOf=function(a,b,c){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b,c);for(var d=a.length,c=c<0?c+d<0?0:c+d:c||0;c<d&&a[c]!==b;c++);return d<=c?-1:c},b.toArray=function(a){var b=[];for(var c=0,d=a.length;c<d;c++)b.push(a[c]);return b},b.ua={},b.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof window?io:module.exports),function(a,b){function c(){}a.EventEmitter=c,c.prototype.on=function(a,c){this.$events||(this.$events={}),this.$events[a]?b.util.isArray(this.$events[a])?this.$events[a].push(c):this.$events[a]=[this.$events[a],c]:this.$events[a]=c;return this},c.prototype.addListener=c.prototype.on,c.prototype.once=function(a,b){function d(){c.removeListener(a,d),b.apply(this,arguments)}var c=this;d.listener=b,this.on(a,d);return this},c.prototype.removeListener=function(a,c){if(this.$events&&this.$events[a]){var d=this.$events[a];if(b.util.isArray(d)){var e=-1;for(var f=0,g=d.length;f<g;f++)if(d[f]===c||d[f].listener&&d[f].listener===c){e=f;break}if(e<0)return this;d.splice(e,1),d.length||delete this.$events[a]}else(d===c||d.listener&&d.listener===c)&&delete this.$events[a]}return this},c.prototype.removeAllListeners=function(a){if(a===undefined){this.$events={};return this}this.$events&&this.$events[a]&&(this.$events[a]=null);return this},c.prototype.listeners=function(a){this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),b.util.isArray(this.$events[a])||(this.$events[a]=[this.$events[a]]);return this.$events[a]},c.prototype.emit=function(a){if(!this.$events)return!1;var c=this.$events[a];if(!c)return!1;var d=Array.prototype.slice.call(arguments,1);if("function"==typeof c)c.apply(this,d);else{if(!b.util.isArray(c))return!1;var e=c.slice();for(var f=0,g=e.length;f<g;f++)e[f].apply(this,d)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i instanceof Date&&(i=date(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function date(a,b){return isFinite(a.valueOf())?a.getUTCFullYear()+"-"+f(a.getUTCMonth()+1)+"-"+f(a.getUTCDate())+"T"+f(a.getUTCHours())+":"+f(a.getUTCMinutes())+":"+f(a.getUTCSeconds())+"Z":null}function f(a){return a<10?"0"+a:a}"use strict";if(nativeJSON&&nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(b&&typeof b!="function"&&(typeof b!="object"||typeof b.length!="number"))throw new Error("JSON.stringify");return str("",{"":a})},JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,JSON),function(a,b){var c=a.parser={},d=c.packets=["disconnect","connect","heartbeat","message","json","event","ack","error"],e=c.reasons=["transport not supported","client not handshaken","unauthorized"],f=c.advice=["reconnect"],g=b.JSON,h=b.util.indexOf;c.encodePacket=function(a){var b=d.indexOf(a.type),c=a.id||"",h=a.endpoint||"",i=a.ack,j=null;switch(a.type){case"error":var k=a.reason?e.indexOf(a.reason):"",l=a.advice?f.indexOf(a.advice):"";if(k!==""||l!=="")j=k+(l!==""?"+"+l:"");break;case"message":a.data!==""&&(j=a.data);break;case"event":var m={name:a.name};a.args&&a.args.length&&(m.args=a.args),j=g.stringify(m);break;case"json":j=g.stringify(a.data);break;case"connect":a.qs&&(j=a.qs);break;case"ack":j=a.ackId+(a.args&&a.args.length?"+"+g.stringify(a.args):"");break;case"heartbeat":case"disconect":}var n=[b,c+(i=="data"?"+":""),h];j!==null&&j!==undefined&&n.push(j);return n.join(":")},c.encodePayload=function(a){var b="";if(a.length==1)return a[0];for(var c=0,d=a.length;c<d;c++){var e=a[c];b+="�"+e.length+"�"+a[c]}return b};var i=/^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;c.decodePacket=function(a){var b=a.match(i);if(!b)return{};var c=b[2]||"",a=b[5]||"",h={type:d[b[1]],endpoint:b[4]||""};c&&(h.id=c,b[3]?h.ack="data":h.ack=!0);switch(h.type){case"error":var b=a.split("+");h.reason=e[b[0]]||"",h.advice=f[b[1]]||"";break;case"message":h.data=a||"";break;case"event":try{var j=g.parse(a);h.name=j.name,h.args=j.args}catch(k){}h.args=h.args||[];break;case"json":try{h.data=g.parse(a)}catch(k){}break;case"connect":h.qs=a||"";break;case"ack":var b=a.match(/^([0-9]+)(\+)?(.*)/);if(b){h.ackId=b[1],h.args=[];if(b[3])try{h.args=b[3]?g.parse(b[3]):[]}catch(k){}}break;case"disconnect":case"heartbeat":}return h},c.decodePayload=function(a){if(a[0]=="�"){var b=[];for(var d=1,e="";d<a.length;d++)a[d]=="�"?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=""):e+=a[d];return b}return[c.decodePacket(a)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a,b){this.socket=a,this.sessid=b}a.Transport=c,b.util.mixin(c,b.EventEmitter),c.prototype.onData=function(a){this.clearCloseTimeout();if(a!==""){var c=b.parser.decodePayload(a);if(c&&c.length)for(var d=0,e=c.length;d<e;d++)this.onPacket(c[d])}return this},c.prototype.onPacket=function(a){if(a.type=="heartbeat")return this.onHeartbeat();if(a.type=="disconnect"&&a.endpoint=="")return this.onDisconnect();this.socket.onPacket(a);return this},c.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}},c.prototype.onDisconnect=function(){this.close&&this.close(),this.clearTimeouts(),this.socket.onDisconnect();return this},c.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},c.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},c.prototype.packet=function(a){this.send(b.parser.encodePacket(a))},c.prototype.onHeartbeat=function(a){this.packet({type:"heartbeat"})},c.prototype.onOpen=function(){this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){this.reopenTimeout=setTimeout(function(){this.open()},this.socket.options["reopen delay"]),this.setCloseTimeout(),this.socket.onClose()},c.prototype.prepareUrl=function(){return this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){!a||(b.Transport.apply(this,arguments),this.sendBuffer=[])}a.XHR=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.get(),this.onOpen(),this.setCloseTimeout();return this},c.prototype.checkSend=function(){if(!this.posting&&this.sendBuffer.length){var a=b.parser.encodePayload(this.sendBuffer);this.sendBuffer=[],this.post(a)}},c.prototype.send=function(a){b.util.isArray(a)?this.sendBuffer.push.apply(this.sendBuffer,a):this.sendBuffer.push(a),this.checkSend();return this},c.prototype.post=function(a){function c(){b.sendXHR.readyState==4&&(b.sendXHR.onreadystatechange=b.sendXHR.onload=d,b.posting=!1,b.sendXHR.status==200?b.checkSend():b.onClose())}var b=this;this.posting=!0,this.sendXHR=this.request("POST"),window.XDomainRequest&&this.xhr instanceof XDomainRequest?this.sendXHR.onload=c:this.sendXHR.onreadystatechange=c,this.sendXHR.send(a)},c.prototype.onClose=function(){if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=d;try{this.xhr.abort()}catch(a){}this.xhr=null}if(this.sendXHR){this.sendXHR.onreadystatechange=this.sendXHR.onload=d;try{this.sendXHR.abort()}catch(a){}this.sendXHR=null}this.sendBuffer=[],b.Transport.prototype.onClose.call(this)},c.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain());c.open(a||"GET",this.prepareUrl()+"?t"+ +(new Date)),a=="POST"&&(c.setRequestHeader?c.setRequestHeader("Content-type","text/plain"):c.contentType="text/plain");return c},c.prototype.scheme=function(){return this.socket.options.secure?"https://":"http://"},c.check=function(a){try{if(b.util.request(a))return!0}catch(c){}return!1},c.xdomainCheck=function(){return c.check(!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(){b.Transport.XHR.apply(this,arguments),this.name="xhr-polling"}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.open=function(){var a=this;b.util.defer(function(){b.Transport.XHR.prototype.open.call(a)});return!1},c.prototype.get=function(){function b(){a.xhr.readyState==4&&(a.xhr.onreadystatechange=a.xhr.onload=d,a.xhr.status==200?(a.onData(a.xhr.responseText),a.get()):a.onClose())}var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=function(b){a.onError(b)}):this.xhr.onreadystatechange=b,this.xhr.send(null)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){if(!!a){b.Transport["xhr-polling"].apply(this,arguments),this.name="jsonp-polling",this.insertAt=document.getElementsByTagName("script")[0],this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}}a["jsonp-polling"]=c,b.util.inherit(c,b.Transport["xhr-polling"]),c.prototype.post=function(a){function h(){b.iframe&&b.form.removeChild(b.iframe);try{f=document.createElement('<iframe name="'+b.iframeId+'">')}catch(a){f=document.createElement("iframe"),f.name=b.iframeId}f.id=b.iframeId,b.form.appendChild(f),b.iframe=f}function g(){h(),b.posting=!1,b.checkSend()}var b=this;if(!this.form){var c=document.createElement("FORM"),d=document.createElement("TEXTAREA"),e=this.iframeId="socketio_iframe_"+this.index,f;c.className="socketio",c.style.position="absolute",c.style.top="-1000px",c.style.left="-1000px",c.target=e,c.method="POST",c.action=this.prepareUrl()+"?t="+ +(new Date)+"&i="+this.index,d.name="data",c.appendChild(d),this.insertAt.parentNode.insertBefore(c,this.insertAt),document.body.appendChild(c),this.form=c,this.area=d}h(),this.posting=!0,this.area.value=a;try{this.form.submit()}catch(i){}this.iframe.attachEvent?f.onreadystatechange=function(){b.iframe.readyState=="complete"&&g()}:this.iframe.onload=g},c.prototype.get=function(){var a=this,b=document.createElement("SCRIPT");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.prepareUrl()+"/?t="+ +(new Date)+"&i="+this.index,b.onerror=function(){a.onClose()},this.insertAt.parentNode.insertBefore(b,this.insertAt),this.script=b},c.prototype._=function(a){this.onData(a),this.get();return this},c.check=function(){return!0},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.apply(this,arguments),this.name="websocket"}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen()},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose()},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.close=function(){this.websocket.close();return this},c.prototype.onError=function(a){this.socket.onError(a)},c.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},c.prototype.prepareUrl=function(){return this.scheme()+"://"+this.socket.options.host+":"+this.socket.options.port+"/"+this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid},c.check=function(){return!!window.WebSocket},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.XHR.apply(this,arguments),this.name="htmlfile"}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.get=function(){var a=this;this.open(),window.attachEvent("onunload",function(){a.destroy()})},c.prototype.open=function(){this.doc=new ActiveXObject("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.parentWindow.s=this,this.doc.close();var a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe),this.iframe.src=this.prepareUrl()+"/?t="+ +(new Date),this.onOpen()},c.prototype._=function(a,b){this.onData(a);var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,CollectGarbage()}},c.prototype.close=function(){this.destroy();return b.Transport.XHR.prototype.close.call(this)},c.check=function(){if("ActiveXObject"in window)try{var a=new ActiveXObject("htmlfile");return a&&b.Transport.XHR.check()}catch(c){}return!1},c.xdomainCheck=function(){return!1}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(a,b){this.namespace=a,this.name=b}function c(a,b){this.socket=a,this.name=b||"",this.flags={},this.json=new d(this,"json"),this.ackPackets=0,this.acks={}}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.packet=function(a){a.endpoint=this.name,this.socket.packet(a),this.flags={};return this},c.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};"function"==typeof b&&(c.id=++this.ackPackets,c.ack=b.length?"data":!0,this.acks[c.id]=b);return this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};"function"==typeof c&&(d.id=++this.ackPackets,d.ack=c.length?"data":!0,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.onPacket=function(a){function e(){d.packet({type:"ack",args:b.util.toArray(arguments),ackId:a.id})}var c=a.ack=="data",d=this;switch(a.type){case"connect":case"disconnect":this.$emit(a.type);break;case"message":case"json":var f=["message",a.data];c&&f.push(e),this.emit.apply(socket,f);break;case"event":var f=[a.name].concat(a.args);c&&f.push(e),this.$emit.apply(this,f);break;case"ack":this.acks[a.ackId]&&this.acks[a.ackId].apply(this,a.args)}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){this.options={port:80,secure:!1,document:document,resource:"socket.io",transports:b.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0},b.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1,this.namespaces={},this.buffer=[];if(this.options["sync disconnect on unload"]){var c=this;b.util.on(window,"beforeunload",function(){c.disconnect(!0)},!1)}this.options["auto connect"]&&this.connect()}a.Socket=c,b.util.mixin(c,b.EventEmitter),c.prototype.of=function(a){this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a),a!==""&&this.namespaces[a].packet({type:"connect"}));return this.namespaces[a]},c.prototype.handshake=function(a){function e(b){b instanceof Error?c.onError(b.message):a.apply(null,b.split(":"))}var c=this,f=this.options.resource+"/"+b.protocol+"/?t="+ +(new Date);if(this.isXDomain()){var g=document.getElementsByTagName("script")[0],h=document.createElement("SCRIPT");h.src=f+"&jsonp="+b.j.length,g.parentNode.insertBefore(h,g),b.j.push(function(a){e(a),h.parentNode.removeChild(h)})}else{var i=b.util.request();i.open("GET",f),i.onreadystatechange=function(){i.readyState==4&&(i.onreadystatechange=d,i.status==200?e(i.responseText):c.onError(i.responseText))},i.send(null)}},c.prototype.getTransport=function(a){var c=a||this.transports,d;for(var e=0,f;f=c[e];e++)if(b.Transport[f]&&b.Transport[f].check()&&(!this.isXDomain()||b.Transport[f].xdomainCheck()))return new b.Transport[f](this,this.sessionid);return null},c.prototype.connect=function(a){if(this.connecting)return this;var c=this;this.handshake(function(d,e,f,g){c.sessionid=d,c.closeTimeout=e,c.heartbeatTimeout=f,c.transports=b.util.intersect(g.split(","),c.options.transports),c.transport=c.getTransport();!c.transport||(c.connecting=!0,c.emit("connecting",c.transport.name),c.transport.open(),c.options.connectTimeout&&(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){if(c.options["try multiple transports"]){c.remainingTransports||(c.remainingTransports=c.transports.slice(0));var a=c.remainingTransports;while(a.length>0&&a.splice(0,1)[0]!=c.transport.name);a.length&&(c.transport=c.getTransport(a),c.connect())}(!c.remainingTransports||c.remainingTransports.length==0)&&c.emit("connect_failed")}c.remainingTransports&&c.remainingTransports.length==0&&delete c.remainingTransports},c.options["connect timeout"])),a&&typeof a=="function"&&c.once("connect",a))});return this},c.prototype.packet=function(a){this.open?this.transport.packet(a):this.buffer.push(a);return this},c.prototype.disconnect=function(a){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});var c=b.util.request();c.open("GET",this.resource+"/"+b.protocol+"/"+this.sessionid),a&&(c.sync=!0),this.onDisconnect()}return this},c.prototype.isXDomain=function(){var a=window.location.port||80;return this.options.host!==document.domain||this.options.port!=a},c.prototype.onConnect=function(){this.connected=!0,this.connecting=!1,this.emit("connect");for(var a in this.namespaces)this.of(a).$emit("connect")},c.prototype.onOpen=function(){this.open=!0;if(this.buffer.length){for(var a=0,b=this.buffer.length;a<b;a++)this.packet(this.buffer[a]);this.buffer=[]}},c.prototype.onClose=function(){this.open=!1},c.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},c.prototype.onError=function(a){this.emit("error",a);for(var b in this.namespaces)this.of(b).$emit("error",a)},c.prototype.onDisconnect=function(a){var b=this.connected;this.connected=!1,this.connecting=!1,this.open=!1;if(b){this.emit("disconnect"),this.transport.clearTimeouts();for(var c in this.namespaces)this.of(c).$emit("disconnect",a);this.options.reconnect&&!this.reconnecting&&this.reconnect()}},c.prototype.reconnect=function(){function e(){if(!!a.reconnecting){if(a.connected)return d();if(a.connecting&&a.reconnecting)return a.reconnectionTimer=setTimeout(e,1e3);a.reconnectionAttempts++>=b?a.redoTransports?(a.emit("reconnect_failed"),d()):(a.on("connect_failed",e),a.options["try multiple transports"]=!0,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay*=2,a.connect(),a.emit("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.emit("reconnect",a.transport.name,a.reconnectionAttempts),a.removeListener("connect_failed",e),a.removeListener("connect",e),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var a=this,b=this.options["max reconnection attempts"],c=this.options["try multiple transports"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(e,this.reconnectionDelay),this.on("connect",e)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports)
\ No newline at end of file

{'addition_count': 1, 'commit_subject': "Merge branch 'master' of https://github.com/LearnBoost/Socket.IO into develop", 'deletion_count': 1, 'file_extension': '.js', 'lang': 'io', 'license': 'mit', 'repo_name': 'socketio/socket.io-client'}