diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index daf408341..000000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "lib" -} diff --git a/bower.json b/bower.json index 39144c6af..307976026 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "quickblox", "description": "QuickBlox JavaScript SDK", - "version": "2.0.4", + "version": "2.1.0", "homepage": "http://quickblox.com/developers/Javascript", "main": "quickblox.js", "license": "MIT", diff --git a/js/modules/qbChat.js b/js/modules/qbChat.js index c9726a50c..1f4c06c2c 100644 --- a/js/modules/qbChat.js +++ b/js/modules/qbChat.js @@ -328,7 +328,7 @@ ChatProxy.prototype = { switch (status) { case Strophe.Status.ERROR: - err = getError(422, 'Status.ERROR - An error has occurred'); + err = Utils.getError(422, 'Status.ERROR - An error has occurred'); if (typeof callback === 'function') callback(err, null); break; case Strophe.Status.CONNECTING: @@ -336,14 +336,14 @@ ChatProxy.prototype = { Utils.QBLog('[ChatProxy]', 'Chat Protocol - ' + (config.chatProtocol.active === 1 ? 'BOSH' : 'WebSocket')); break; case Strophe.Status.CONNFAIL: - err = getError(422, 'Status.CONNFAIL - The connection attempt failed'); + err = Utils.getError(422, 'Status.CONNFAIL - The connection attempt failed'); if (typeof callback === 'function') callback(err, null); break; case Strophe.Status.AUTHENTICATING: Utils.QBLog('[ChatProxy]', 'Status.AUTHENTICATING'); break; case Strophe.Status.AUTHFAIL: - err = getError(401, 'Status.AUTHFAIL - The authentication attempt failed'); + err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed'); if (typeof callback === 'function') callback(err, null); break; case Strophe.Status.CONNECTED: @@ -1001,7 +1001,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject, null); }else{ - callback(getError(408), null); + callback(Utils.getError(408), null); } }); }, @@ -1041,7 +1041,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject, null); }else{ - callback(getError(408), null); + callback(Utils.getError(408), null); } }); }, @@ -1105,7 +1105,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject); }else{ - callback(getError(408)); + callback(Utils.getError(408)); } }); }, @@ -1154,7 +1154,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject); }else{ - callback(getError(408)); + callback(Utils.getError(408)); } }); }, @@ -1177,7 +1177,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject); }else{ - callback(getError(408)); + callback(Utils.getError(408)); } }); }, @@ -1200,7 +1200,7 @@ PrivacyListProxy.prototype = { var errorObject = getErrorFromXMLNode(stanzaError); callback(errorObject); }else{ - callback(getError(408)); + callback(Utils.getError(408)); } }); } @@ -1407,7 +1407,7 @@ function getErrorFromXMLNode(stanzaError) { var errorElement = stanzaError.getElementsByTagName('error')[0]; var errorCode = parseInt(errorElement.getAttribute('code')); var errorText = errorElement.getElementsByTagName('text')[0].textContent; - return getError(errorCode, errorText); + return Utils.getError(errorCode, errorText); } function getLocalTime() { diff --git a/js/modules/webrtc/qbRTCPeerConnection.js b/js/modules/webrtc/qbRTCPeerConnection.js index f15bd1490..8cce60cb2 100644 --- a/js/modules/webrtc/qbRTCPeerConnection.js +++ b/js/modules/webrtc/qbRTCPeerConnection.js @@ -45,6 +45,7 @@ RTCPeerConnection.prototype.init = function(delegate, userID, sessionID, type) { /** We use this timer interval to dial a user - produce the call requests each N seconds. */ this.dialingTimer = null; this.answerTimeInterval = 0; + this.statsReportTimer = null; /** timer to detect network blips */ this.reconnectTimer = 0; @@ -54,6 +55,7 @@ RTCPeerConnection.prototype.init = function(delegate, userID, sessionID, type) { RTCPeerConnection.prototype.release = function(){ this._clearDialingTimer(); + this._clearStatsReportTimer(); if(this.signalingState !== 'closed'){ this.close(); @@ -174,16 +176,19 @@ RTCPeerConnection.prototype.onIceCandidateCallback = function(event) { /** handler of remote media stream */ RTCPeerConnection.prototype.onAddRemoteStreamCallback = function(event) { + var self = this; + if (typeof this.delegate._onRemoteStreamListener === 'function'){ this.delegate._onRemoteStreamListener(this.userID, event.stream); } + + self._getStatsWrap(); }; RTCPeerConnection.prototype.onIceConnectionStateCallback = function() { var newIceConnectionState = this.iceConnectionState; - - Helpers.trace("onIceConnectionStateCallback: " + this.iceConnectionState); + Helpers.trace("onIceConnectionStateCallback: " + this.iceConnectionState); /** * read more about all states: @@ -226,6 +231,45 @@ RTCPeerConnection.prototype.onIceConnectionStateCallback = function() { /** * PRIVATE */ + RTCPeerConnection.prototype._clearStatsReportTimer = function(){ + if(this.statsReportTimer){ + clearInterval(this.statsReportTimer); + this.statsReportTimer = null; + } + }; + +RTCPeerConnection.prototype._getStatsWrap = function() { + var self = this, + selector = self.delegate.callType == 1 ? self.getLocalStreams()[0].getVideoTracks()[0] : self.getLocalStreams()[0].getAudioTracks()[0], + statsReportInterval; + + if (!config.webrtc && !config.webrtc.statsReportTimeInterval) { + return; + } + + if (isNaN(+config.webrtc.statsReportTimeInterval)) { + Helpers.traceError('statsReportTimeInterval (' + config.webrtc.statsReportTimeInterval + ') must be integer.'); + return; + } + + statsReportInterval = config.webrtc.statsReportTimeInterval * 1000; + + var _statsReportCallback = function() { + _getStats(self, selector, + function (results) { + self.delegate._onCallStatsReport(self.userID, results); + }, + function errorLog(err) { + Helpers.traceError("_getStats error. " + err.name + ": " + err.message); + } + ); + }; + + Helpers.trace('Stats tracker has been started.'); + + self.statsReportTimer = setInterval(_statsReportCallback, statsReportInterval); + }; + RTCPeerConnection.prototype._clearWaitingReconnectTimer = function() { if(this.waitingReconnectTimeoutCallback){ Helpers.trace('_clearWaitingReconnectTimer'); @@ -292,4 +336,40 @@ RTCPeerConnection.prototype._startDialingTimer = function(extension, withOnNotAn _dialingCallback(extension, withOnNotAnswerCallback, true); }; -module.exports = RTCPeerConnection; \ No newline at end of file +/** + * PRIVATE + */ + function _getStats(peer, selector, successCallback, errorCallback) { + /** + * http://stackoverflow.com/questions/25069419/webrtc-getstat-api-set-up + */ + if (navigator.mozGetUserMedia) { + peer.getStats(selector, + function (res) { + var items = []; + res.forEach(function (result) { + items.push(result); + }); + successCallback(items); + }, + errorCallback + ); + } else { + peer.getStats(function (res) { + var items = []; + res.result().forEach(function (result) { + var item = {}; + result.names().forEach(function (name) { + item[name] = result.stat(name); + }); + item.id = result.id; + item.type = result.type; + item.timestamp = result.timestamp; + items.push(item); + }); + successCallback(items); + }); + } + } + +module.exports = RTCPeerConnection; diff --git a/js/modules/webrtc/qbWebRTCClient.js b/js/modules/webrtc/qbWebRTCClient.js index ee892ca71..15bfaaee4 100644 --- a/js/modules/webrtc/qbWebRTCClient.js +++ b/js/modules/webrtc/qbWebRTCClient.js @@ -80,6 +80,7 @@ WebRTCClient.prototype._createAndStoreSession = function(sessionID, callerID, op newSession.onRemoteStreamListener = this.onRemoteStreamListener; newSession.onSessionConnectionStateChangedListener = this.onSessionConnectionStateChangedListener; newSession.onSessionCloseListener = this.onSessionCloseListener; + newSession.onCallStatsReport = this.onCallStatsReport; this.sessions[newSession.ID] = newSession; return newSession; diff --git a/js/modules/webrtc/qbWebRTCSession.js b/js/modules/webrtc/qbWebRTCSession.js index 0fa8b10ce..0557035fb 100644 --- a/js/modules/webrtc/qbWebRTCSession.js +++ b/js/modules/webrtc/qbWebRTCSession.js @@ -9,6 +9,7 @@ * - onRemoteStreamListener(session, userID, stream) * - onSessionConnectionStateChangedListener(session, userID, connectionState) * - onSessionCloseListener(session) + * - onCallStatsReport(session, userId, stats) */ var config = require('../../qbConfig'); @@ -360,6 +361,24 @@ WebRTCSession.prototype.stop = function(extension) { self._close(); }; +/** + * [function close connection with user] + * @param {[type]} userId [id of user] + */ +WebRTCSession.prototype.closeConnection = function(userId) { + var self = this, + peer = this.peerConnections[userId]; + + if(peer) { + peer.release(); + + self._closeSessionIfAllConnectionsClosed(); + } else { + Helpers.traceWarn('Not found connection with user (' + userId + ')'); + } +}; + + /** * Update a call * @param {array} A map with custom parameters @@ -594,6 +613,12 @@ WebRTCSession.prototype._onRemoteStreamListener = function(userID, stream) { } }; +WebRTCSession.prototype._onCallStatsReport = function(userId, stats) { + if (typeof this.onCallStatsReport === 'function'){ + Utils.safeCallbackCall(this.onCallStatsReport, this, userId, stats); + } +}; + WebRTCSession.prototype._onSessionConnectionStateChangedListener = function(userID, connectionState) { var self = this; diff --git a/js/qbConfig.js b/js/qbConfig.js index da7c7c6c9..1abdf8187 100644 --- a/js/qbConfig.js +++ b/js/qbConfig.js @@ -3,10 +3,14 @@ * * Configuration Module * + * NOTE: + * - config.webrtc.statsReportTimeInterval [integer, sec]: + * could add listener onCallStatsReport(session, userId, bytesReceived) if + * want to get stats (bytesReceived) about peer every X sec; */ var config = { - version: '2.0.4', + version: '2.1.0', creds: { appId: '', authKey: '', @@ -26,6 +30,7 @@ var config = { answerTimeInterval: 60, dialingTimeInterval: 5, disconnectTimeInterval: 30, + statsReportTimeInterval: 10, iceServers: [ { 'url': 'stun:stun.l.google.com:19302' diff --git a/package.json b/package.json index d8453d447..73f5ec52e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "quickblox", "description": "QuickBlox JavaScript SDK", - "version": "2.0.4", + "version": "2.1.0", "homepage": "http://quickblox.com/developers/Javascript", "main": "js/qbMain.js", "license": [ @@ -44,7 +44,7 @@ "crypto-js": "3.1.2-2", "jquery": "^2.2.0", "request": "^2.48.0", - "strophe": "^1.2.3", + "strophe": "~1.2.4", "xml2js": "^0.4.13" }, "devDependencies": { diff --git a/quickblox.min.js b/quickblox.min.js index 1f30eddcd..43b252def 100644 --- a/quickblox.min.js +++ b/quickblox.min.js @@ -1,10 +1,10 @@ -/* QuickBlox JavaScript SDK - v2.0.4 - 2016-02-01 */ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.QB=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc;c++)f.muc.join(d[c]);"function"==typeof f.onReconnectListener&&n.safeCallbackCall(f.onReconnectListener)}})});break;case Strophe.Status.DISCONNECTING:n.QBLog("[ChatProxy]","Status.DISCONNECTING");break;case Strophe.Status.DISCONNECTED:n.QBLog("[ChatProxy]","Status.DISCONNECTED at "+l()),q.reset(),f._isDisconnected||"function"!=typeof f.onDisconnectedListener||n.safeCallbackCall(f.onDisconnectedListener),f._isDisconnected=!0,f._isLogout||f.connect(a);break;case Strophe.Status.ATTACHED:n.QBLog("[ChatProxy]","Status.ATTACHED")}})},send:function(a,b){if(!o)throw p;b.id||(b.id=n.getBsonObjectId());var c=this,d=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:b.type,id:b.id});b.body&&d.c("body",{xmlns:Strophe.NS.CLIENT}).t(b.body).up(),b.extension&&(d.c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b.extension).forEach(function(a){"attachments"===a?b.extension[a].forEach(function(a){d.c("attachment",a).up()}):"object"==typeof b.extension[a]?c._JStoXML(a,b.extension[a],d):d.c(a).t(b.extension[a]).up()}),d.up()),b.markable&&d.c("markable",{xmlns:Strophe.NS.CHAT_MARKERS}),q.send(d)},sendSystemMessage:function(a,b){if(!o)throw p;b.id||(b.id=n.getBsonObjectId());var c=this,d=$msg({id:b.id,type:"headline",to:this.helpers.jidOrUserId(a)});b.extension&&(d.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("moduleIdentifier").t("SystemNotifications").up(),Object.keys(b.extension).forEach(function(a){"object"==typeof b.extension[a]?c._JStoXML(a,b.extension[a],d):d.c(a).t(b.extension[a]).up()}),d.up()),q.send(d)},sendIsTypingStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("composing",{xmlns:Strophe.NS.CHAT_STATES}),q.send(b)},sendIsStopTypingStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("paused",{xmlns:Strophe.NS.CHAT_STATES}),q.send(b)},sendPres:function(a){if(!o)throw p;q.send($pres({from:q.jid,type:a}))},sendDeliveredStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:n.getBsonObjectId()});b.c("received",{xmlns:Strophe.NS.CHAT_MARKERS,id:a.messageId}).up(),b.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("dialog_id").t(a.dialogId),q.send(b)},sendReadStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:n.getBsonObjectId()});b.c("displayed",{xmlns:Strophe.NS.CHAT_MARKERS,id:a.messageId}).up(),b.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("dialog_id").t(a.dialogId),q.send(b)},disconnect:function(){if(!o)throw p;v={},this._isLogout=!0,q.flush(),q.disconnect()},addListener:function(a,b){function c(){return b(),a.live!==!1}if(!o)throw p;return q.addHandler(c,null,a.name||null,a.type||null,a.id||null,a.from||null)},deleteListener:function(a){if(!o)throw p;q.deleteHandler(a)},_JStoXML:function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},_XMLtoJS:function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a},_parseExtraParams:function(a){if(!a)return null;for(var b,c={},d=[],e=0,f=a.childNodes.length;f>e;e++)if("attachment"===a.childNodes[e].tagName){for(var g={},h=a.childNodes[e].attributes,i=0,j=h.length;j>i;i++)"id"===h[i].name||"size"===h[i].name?g[h[i].name]=parseInt(h[i].value):g[h[i].name]=h[i].value;d.push(g)}else if("dialog_id"===a.childNodes[e].tagName)b=a.childNodes[e].textContent,c.dialog_id=b;else if(a.childNodes[e].childNodes.length>1){var k=a.childNodes[e].textContent.length;if(k>4096){for(var l="",i=0;i0&&(c.attachments=d),c.moduleIdentifier&&delete c.moduleIdentifier,{extension:c,dialogId:b}},_autoSendPresence:function(){if(!o)throw p;return q.send($pres().tree()),!0},_enableCarbons:function(a){if(!o)throw p;var b;b=$iq({from:q.jid,type:"set",id:q.getUniqueId("enableCarbons")}).c("enable",{xmlns:Strophe.NS.CARBONS}),q.sendIQ(b,function(b){a()})}},e.prototype={get:function(a){var b,c,d,e=this,f={};b=$iq({from:q.jid,type:"get",id:q.getUniqueId("getRoster")}).c("query",{xmlns:Strophe.NS.ROSTER}),q.sendIQ(b,function(b){c=b.getElementsByTagName("item");for(var g=0,h=c.length;h>g;g++)d=e.helpers.getIdFromNode(c[g].getAttribute("jid")).toString(),f[d]={subscription:c[g].getAttribute("subscription"),ask:c[g].getAttribute("ask")||null};a(f)})},add:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"none",ask:"subscribe"},c._sendSubscriptionPresence({jid:d,type:"subscribe"}),"function"==typeof b&&b()},confirm:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"from",ask:"subscribe"},c._sendSubscriptionPresence({jid:d,type:"subscribed"}),c._sendSubscriptionPresence({jid:d,type:"subscribe"}),"function"==typeof b&&b()},reject:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"none",ask:null},c._sendSubscriptionPresence({jid:d,type:"unsubscribed"}),"function"==typeof b&&b()},remove:function(a,b){var c,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();c=$iq({from:q.jid,type:"set",id:q.getUniqueId("removeRosterItem")}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:d,subscription:"remove"}),q.sendIQ(c,function(){delete u[e],"function"==typeof b&&b()})},_sendSubscriptionPresence:function(a){var b;b=$pres({to:a.jid,type:a.type}),q.send(b)}},f.prototype={join:function(a,b){var c,d=this,e=q.getUniqueId("join");v[a]=!0,c=$pres({from:q.jid,to:d.helpers.getRoomJid(a),id:e}).c("x",{xmlns:Strophe.NS.MUC}).c("history",{maxstanzas:0}),"function"==typeof b&&q.addHandler(b,null,"presence",null,e),q.send(c)},leave:function(a,b){var c,d=this,e=d.helpers.getRoomJid(a);delete v[a],c=$pres({from:q.jid,to:e,type:"unavailable"}),"function"==typeof b&&q.addHandler(b,null,"presence","unavailable",null,e),q.send(c)},listOnlineUsers:function(a,b){var c,d=this,e=[];c=$iq({from:q.jid,id:q.getUniqueId("muc_disco_items"),to:a,type:"get"}).c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),q.sendIQ(c,function(a){for(var c,f=a.getElementsByTagName("item"),g=0,h=f.length;h>g;g++)c=d.helpers.getUserIdFromRoomJid(f[g].getAttribute("jid")),e.push(c);b(e)})}},g.prototype={getNames:function(a){var b=$iq({from:q.jid,type:"get",id:q.getUniqueId("getNames")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST});q.sendIQ(b,function(b){for(var c=[],d={},e=b.getElementsByTagName("default"),f=b.getElementsByTagName("active"),g=b.getElementsByTagName("list"),h=e[0].getAttribute("name"),i=f[0].getAttribute("name"),j=0,k=g.length;k>j;j++)c.push(g[j].getAttribute("name"));d={"default":h,active:i,names:c},a(null,d)},function(b){if(b){var c=k(b);a(c,null)}else a(getError(408),null)})},getList:function(a,b){var c,d,e,f,g=this,h=[],i={};c=$iq({from:q.jid,type:"get",id:q.getUniqueId("getlist")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a}),q.sendIQ(c,function(c){d=c.getElementsByTagName("item");for(var j=0,k=d.length;k>j;j+=2)e=d[j].getAttribute("value"),f=g.helpers.getIdFromNode(e),h.push({user_id:f,action:d[j].getAttribute("action")});i={name:a,items:h},b(null,i)},function(a){if(a){var c=k(a);b(c,null)}else b(getError(408),null)})},create:function(a,b){var c,d,e,f,g,h=this,i={},j=[];c=$iq({from:q.jid,type:"set",id:q.getUniqueId("edit")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a.name}),$(a.items).each(function(a,b){i[b.user_id]=b.action}),j=Object.keys(i);for(var l=0,m=0,n=j.length;n>l;l++,m+=2)d=j[l],f=i[d],e=h.helpers.jidOrUserId(parseInt(d,10)),g=h.helpers.getUserNickWithMucDomain(d),c.c("item",{type:"jid",value:e,action:f,order:m+1}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up(),c.c("item",{type:"jid",value:g,action:f,order:m+2}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up();q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(getError(408))})},update:function(a,b){var c=this;c.getList(a.name,function(d,e){if(d)b(d,null);else{var f=JSON.parse(JSON.stringify(a)),g=e.items,h=f.items,i={};f.items=$.merge(g,h),i=f,c.create(i,function(a,c){d?b(a,null):b(null,c)})}})},"delete":function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("remove")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(getError(408))})},setAsDefault:function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("default")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("default",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(getError(408))})},setAsActive:function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("active")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("active",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(getError(408))})}},h.prototype={list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),n.QBLog("[DialogProxy]","list",a),this.service.ajax({url:n.getUrl(s),data:a},b)},create:function(a,b){a.occupants_ids instanceof Array&&(a.occupants_ids=a.occupants_ids.join(", ")),n.QBLog("[DialogProxy]","create",a),this.service.ajax({url:n.getUrl(s),type:"POST",data:a},b)},update:function(a,b,c){n.QBLog("[DialogProxy]","update",b),this.service.ajax({url:n.getUrl(s,a),type:"PUT",data:b},c)},"delete":function(a,b,c){n.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:n.getUrl(s,a),type:"DELETE"},b):3==arguments.length&&this.service.ajax({url:n.getUrl(s,a),type:"DELETE",data:b},c)}},i.prototype={list:function(a,b){n.QBLog("[MessageProxy]","list",a),this.service.ajax({url:n.getUrl(t),data:a},b)},create:function(a,b){n.QBLog("[MessageProxy]","create",a),this.service.ajax({url:n.getUrl(t),type:"POST",data:a},b)},update:function(a,b,c){n.QBLog("[MessageProxy]","update",a,b),this.service.ajax({url:n.getUrl(t,a),type:"PUT",data:b},c)},"delete":function(a,b,c){n.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:n.getUrl(t,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:n.getUrl(t,a),type:"DELETE",data:b,dataType:"text"},c)},unreadCount:function(a,b){n.QBLog("[MessageProxy]","unreadCount",a),this.service.ajax({url:n.getUrl(t+"/unread"),data:a},b)}},j.prototype={jidOrUserId:function(a){var b;if("string"==typeof a)b=a;else{if("number"!=typeof a)throw p;b=a+"-"+m.creds.appId+"@"+m.endpoints.chat}return b},typeChat:function(a){var b;if("string"==typeof a)b=a.indexOf("muc")>-1?"groupchat":"chat";else{if("number"!=typeof a)throw p;b="chat"}return b},getRecipientId:function(a,b){var c=null;return a.forEach(function(a,d,e){a!=b&&(c=a)}),c},getUserJid:function(a,b){return b?a+"-"+b+"@"+m.endpoints.chat:a+"-"+m.creds.appId+"@"+m.endpoints.chat},getUserNickWithMucDomain:function(a){return m.endpoints.muc+"/"+a},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])},getDialogIdFromNode:function(a){return a.indexOf("@")<0?null:a.split("@")[0].split("_")[1]},getRoomJidFromDialogId:function(a){return m.creds.appId+"_"+a+"@"+m.endpoints.muc},getRoomJid:function(a){if(!o)throw p;return a+"/"+this.getIdFromNode(q.jid)},getIdFromResource:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),parseInt(b.join("/")))},getUniqueId:function(a){if(!o)throw p;return q.getUniqueId(a)},getBsonObjectId:function(){return n.getBsonObjectId()},getUserIdFromRoomJid:function(a){var b=a.toString().split("/");return 0==b.length?null:b[b.length-1]}},b.exports=d},{"../qbConfig":15,"../qbUtils":19,strophe:51}],3:[function(a,b,c){function d(a){this.service=a}function e(a){for(var b=e.options,c=b.parser[b.strictMode?"strict":"loose"].exec(a),d={},f=14;f--;)d[b.key[f]]=c[f]||"";return d[b.q.name]={},d[b.key[12]].replace(b.q.parser,function(a,c,e){c&&(d[b.q.name][c]=e)}),d}var f=a("../qbConfig"),g=a("../qbUtils"),h="undefined"!=typeof window;if(!h)var i=a("xml2js");var j=f.urls.blobs+"/tagged";d.prototype={create:function(a,b){g.QBLog("[ContentProxy]","create",a),this.service.ajax({url:g.getUrl(f.urls.blobs),data:{blob:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.blob)})},list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a=null),g.QBLog("[ContentProxy]","list",a),this.service.ajax({url:g.getUrl(f.urls.blobs),data:a,type:"GET"},function(a,c){a?b(a,null):b(a,c)})},"delete":function(a,b){g.QBLog("[ContentProxy]","delete"),this.service.ajax({url:g.getUrl(f.urls.blobs,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},createAndUpload:function(a,b){var c,d,f,i,j,k={},l=this,m=JSON.parse(JSON.stringify(a));m.file.data="...",g.QBLog("[ContentProxy]","createAndUpload",m),c=a.file,d=a.name||c.name,f=a.type||c.type,i=a.size||c.size,k.name=d,k.content_type=f,a["public"]&&(k["public"]=a["public"]),a.tag_list&&(k.tag_list=a.tag_list),this.create(k,function(a,d){if(a)b(a,null);else{var f,g=e(d.blob_object_access.params),k={url:"https://"+g.host};f=h?new FormData:{},j=d.id,Object.keys(g.queryKey).forEach(function(a){h?f.append(a,decodeURIComponent(g.queryKey[a])):f[a]=decodeURIComponent(g.queryKey[a])}),h?f.append("file",c,d.name):f.file=c,k.data=f,l.upload(k,function(a,c){a?b(a,null):(h?d.path=c.Location.replace("http://","https://"):d.path=c.PostResponse.Location,l.markUploaded({id:j,size:i},function(a,c){a?b(a,null):b(null,d)}))})}})},upload:function(a,b){g.QBLog("[ContentProxy]","upload"),this.service.ajax({url:a.url,data:a.data,dataType:"xml",contentType:!1,processData:!1,type:"POST"},function(a,c){if(a)b(a,null);else if(h){var d,e,f={},g=c.documentElement,j=g.childNodes;for(d=0,e=j.length;e>d;d++)f[j[d].nodeName]=j[d].childNodes[0].nodeValue;b(null,f)}else{var k=i.parseString;k(c,function(a,c){c&&b(null,c)})}})},taggedForCurrentUser:function(a){g.QBLog("[ContentProxy]","taggedForCurrentUser"),this.service.ajax({url:g.getUrl(j)},function(b,c){b?a(b,null):a(null,c)})},markUploaded:function(a,b){g.QBLog("[ContentProxy]","markUploaded",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a.id+"/complete"),type:"PUT",data:{size:a.size},dataType:"text"},function(a,c){a?b(a,null):b(null,c)})},getInfo:function(a,b){g.QBLog("[ContentProxy]","getInfo",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFile:function(a,b){g.QBLog("[ContentProxy]","getFile",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFileUrl:function(a,b){g.QBLog("[ContentProxy]","getFileUrl",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a+"/getblobobjectbyid"),type:"POST"},function(a,c){a?b(a,null):b(null,c.blob_object_access.params)})},update:function(a,b){g.QBLog("[ContentProxy]","update",a);var c={};c.blob={},"undefined"!=typeof a.name&&(c.blob.name=a.name),this.service.ajax({url:g.getUrl(f.urls.blobs,a.id),data:c},function(a,c){a?b(a,null):b(null,c)})},privateUrl:function(a){return"https://"+f.endpoints.api+"/blobs/"+a+"?token="+this.service.getSession().token},publicUrl:function(a){return"https://"+f.endpoints.api+"/blobs/"+a}},b.exports=d,e.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},{"../qbConfig":15,"../qbUtils":19,xml2js:54}],4:[function(a,b,c){function d(a){this.service=a}var e=a("../qbConfig"),f=a("../qbUtils"),g="undefined"!=typeof window;d.prototype={create:function(a,b,c){f.QBLog("[DataProxy]","create",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},list:function(a,b,c){"undefined"==typeof c&&"function"==typeof b&&(c=b,b=null),f.QBLog("[DataProxy]","list",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b},function(a,b){a?c(a,null):c(a,b)})},update:function(a,b,c){f.QBLog("[DataProxy]","update",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b._id),data:b,type:"PUT"},function(a,b){a?c(a,null):c(a,b)})},"delete":function(a,b,c){f.QBLog("[DataProxy]","delete",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b),type:"DELETE",dataType:"text"},function(a,b){a?c(a,null):c(a,!0)})},uploadFile:function(a,b,c){f.QBLog("[DataProxy]","uploadFile",a,b);var d;g?(d=new FormData,d.append("field_name",b.field_name),d.append("file",b.file)):(d={},d.field_name=b.field_name,d.file=b.file),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:d,contentType:!1,processData:!1,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},downloadFile:function(a,b,c){f.QBLog("[DataProxy]","downloadFile",a,b);var d=f.getUrl(e.urls.data,a+"/"+b.id+"/file");d+="?field_name="+b.field_name+"&token="+this.service.getSession().token,c(null,d)},deleteFile:function(a,b,c){f.QBLog("[DataProxy]","deleteFile",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:{field_name:b.field_name},dataType:"text",type:"DELETE"},function(a,b){a?c(a,null):c(a,!0)})}},b.exports=d},{"../qbConfig":15,"../qbUtils":19}],5:[function(a,b,c){function d(a){this.service=a,this.geodata=new e(a)}function e(a){this.service=a}var f=a("../qbConfig"),g=a("../qbUtils"),h=f.urls.geodata+"/find";e.prototype={create:function(a,b){g.QBLog("[GeoProxy]","create",a),this.service.ajax({url:g.getUrl(f.urls.geodata),data:{geo_data:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},update:function(a,b){var c,d=["longitude","latitude","status"],e={};for(c in a)a.hasOwnProperty(c)&&d.indexOf(c)>0&&(e[c]=a[c]);g.QBLog("[GeoProxy]","update",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a.id),data:{geo_data:e},type:"PUT"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},get:function(a,b){g.QBLog("[GeoProxy]","get",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a)},function(a,c){a?b(a,null):b(null,c.geo_datum)})},list:function(a,b){"function"==typeof a&&(b=a,a=void 0),g.QBLog("[GeoProxy]","find",a),this.service.ajax({url:g.getUrl(h),data:a},b)},"delete":function(a,b){g.QBLog("[GeoProxy]","delete",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},purge:function(a,b){g.QBLog("[GeoProxy]","purge",a),this.service.ajax({url:g.getUrl(f.urls.geodata),data:{days:a},type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},b.exports=d},{"../qbConfig":15,"../qbUtils":19}],6:[function(a,b,c){(function(c){function d(a){this.service=a,this.subscriptions=new e(a),this.events=new f(a),this.base64Encode=function(a){return i?btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode("0x"+b)})):new c(a).toString("base64")}}function e(a){this.service=a}function f(a){this.service=a}var g=a("../qbConfig"),h=a("../qbUtils"),i="undefined"!=typeof window;e.prototype={create:function(a,b){h.QBLog("[SubscriptionsProxy]","create",a),this.service.ajax({url:h.getUrl(g.urls.subscriptions),type:"POST",data:a},b)},list:function(a){h.QBLog("[SubscriptionsProxy]","list"),this.service.ajax({url:h.getUrl(g.urls.subscriptions)},a)},"delete":function(a,b){h.QBLog("[SubscriptionsProxy]","delete",a),this.service.ajax({url:h.getUrl(g.urls.subscriptions,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},f.prototype={create:function(a,b){h.QBLog("[EventsProxy]","create",a);var c={event:a};this.service.ajax({url:h.getUrl(g.urls.events),type:"POST",data:c},b)},list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a=null),h.QBLog("[EventsProxy]","list",a),this.service.ajax({url:h.getUrl(g.urls.events),data:a},b)},get:function(a,b){h.QBLog("[EventsProxy]","get",a),this.service.ajax({url:h.getUrl(g.urls.events,a)},b)},status:function(a,b){h.QBLog("[EventsProxy]","status",a),this.service.ajax({url:h.getUrl(g.urls.events,a+"/status")},b)},"delete":function(a,b){h.QBLog("[EventsProxy]","delete",a),this.service.ajax({url:h.getUrl(g.urls.events,a),type:"DELETE"},b)}},b.exports=d}).call(this,a("buffer").Buffer)},{"../qbConfig":15,"../qbUtils":19,buffer:26}],7:[function(a,b,c){function d(a){this.service=a}function e(a){var b=a.field in j?"date":typeof a.value;return(a.value instanceof Array||i.isArray(a.value))&&("object"==b&&(b=typeof a.value[0]),a.value=a.value.toString()),[b,a.field,a.param,a.value].join(" ")}function f(a){var b=a.field in j?"date":a.field in k?"number":"string";return[a.sort,b,a.field].join(" ")}var g=a("../qbConfig"),h=a("../qbUtils"),i=a("util"),j=["created_at","updated_at","last_request_at"],k=["id","external_user_id"],l=g.urls.users+"/password/reset";d.prototype={listUsers:function(a,b){h.QBLog("[UsersProxy]","listUsers",arguments.length>1?a:"");var c,d={},i=[];"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),a.filter&&(a.filter instanceof Array?a.filter.forEach(function(a){c=e(a),i.push(c)}):(c=e(a.filter),i.push(c)),d.filter=i),a.order&&(d.order=f(a.order)),a.page&&(d.page=a.page),a.per_page&&(d.per_page=a.per_page),this.service.ajax({url:h.getUrl(g.urls.users),data:d},b)},get:function(a,b){h.QBLog("[UsersProxy]","get",a);var c;"number"==typeof a?(c=a,a={}):a.login?c="by_login":a.full_name?c="by_full_name":a.facebook_id?c="by_facebook_id":a.twitter_id?c="by_twitter_id":a.email?c="by_email":a.tags?c="by_tags":a.external&&(c="external/"+a.external,a={}),this.service.ajax({url:h.getUrl(g.urls.users,c),data:a},function(a,c){a?b(a,null):b(null,c.user||c)})},create:function(a,b){h.QBLog("[UsersProxy]","create",a),this.service.ajax({url:h.getUrl(g.urls.users),type:"POST",data:{user:a}},function(a,c){a?b(a,null):b(null,c.user)})},update:function(a,b,c){h.QBLog("[UsersProxy]","update",a,b),this.service.ajax({url:h.getUrl(g.urls.users,a),type:"PUT",data:{user:b}},function(a,b){a?c(a,null):c(null,b.user)})},"delete":function(a,b){h.QBLog("[UsersProxy]","delete",a);var c;"number"==typeof a?c=a:a.external&&(c="external/"+a.external),this.service.ajax({url:h.getUrl(g.urls.users,c),type:"DELETE",dataType:"text"},b)},resetPassword:function(a,b){h.QBLog("[UsersProxy]","resetPassword",a),this.service.ajax({url:h.getUrl(l),data:{email:a}},b)}},b.exports=d},{"../qbConfig":15,"../qbUtils":19,util:50}],8:[function(a,b,c){var d=a("../../qbConfig"),e=a("./qbWebRTCHelpers"),f=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,g=window.RTCSessionDescription||window.mozRTCSessionDescription,h=window.RTCIceCandidate||window.mozRTCIceCandidate; -f.State={NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},f.prototype.init=function(a,b,c,d){e.trace("RTCPeerConnection init. userID: "+b+", sessionID: "+c+", type: "+d),this.delegate=a,this.sessionID=c,this.userID=b,this.type=d,this.remoteSDP=null,this.state=f.State.NEW,this.onicecandidate=this.onIceCandidateCallback,this.onaddstream=this.onAddRemoteStreamCallback,this.onsignalingstatechange=this.onSignalingStateCallback,this.oniceconnectionstatechange=this.onIceConnectionStateCallback,this.dialingTimer=null,this.answerTimeInterval=0,this.reconnectTimer=0,this.iceCandidates=[]},f.prototype.release=function(){this._clearDialingTimer(),"closed"!==this.signalingState&&this.close()},f.prototype.updateRemoteSDP=function(a){if(!a)throw new Error("sdp string can't be empty.");this.remoteSDP=a},f.prototype.getRemoteSDP=function(){return this.remoteSDP},f.prototype.setRemoteSessionDescription=function(a,b,c){function d(){c(null)}function e(a){c(a)}var f=new g({sdp:b,type:a});this.setRemoteDescription(f,d,e)},f.prototype.addLocalStream=function(a){if(!a)throw new Error("'RTCPeerConnection.addStream' error: stream is 'null'.");this.addStream(a)},f.prototype.getAndSetLocalSessionDescription=function(a){function b(b){d.setLocalDescription(b,function(){a(null)},c)}function c(b){a(b)}var d=this;d.state=f.State.CONNECTING,"offer"===d.type?d.createOffer(b,c):d.createAnswer(b,c)},f.prototype.addCandidates=function(a){for(var b,c=0,d=a.length;d>c;c++)b={sdpMLineIndex:a[c].sdpMLineIndex,sdpMid:a[c].sdpMid,candidate:a[c].candidate},this.addIceCandidate(new h(b),function(){},function(a){e.traceError("Error on 'addIceCandidate': "+a)})},f.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", type: "+this.type+", state: "+this.state},f.prototype.onSignalingStateCallback=function(){"stable"===this.signalingState&&this.iceCandidates.length>0&&(this.delegate.processIceCandidates(this,this.iceCandidates),this.iceCandidates.length=0)},f.prototype.onIceCandidateCallback=function(a){var b=a.candidate;if(b){var c={sdpMLineIndex:b.sdpMLineIndex,sdpMid:b.sdpMid,candidate:b.candidate};"stable"===this.signalingState?this.delegate.processIceCandidates(this,[c]):this.iceCandidates.push(c)}},f.prototype.onAddRemoteStreamCallback=function(a){"function"==typeof this.delegate._onRemoteStreamListener&&this.delegate._onRemoteStreamListener(this.userID,a.stream)},f.prototype.onIceConnectionStateCallback=function(){var a=this.iceConnectionState;if(e.trace("onIceConnectionStateCallback: "+this.iceConnectionState),"function"==typeof this.delegate._onSessionConnectionStateChangedListener){var b=null;"checking"===a?(this.state=f.State.CHECKING,b=e.SessionConnectionState.CONNECTING):"connected"===a?(this._clearWaitingReconnectTimer(),this.state=f.State.CONNECTED,b=e.SessionConnectionState.CONNECTED):"completed"===a?(this._clearWaitingReconnectTimer(),this.state=f.State.COMPLETED,b=e.SessionConnectionState.COMPLETED):"failed"===a?(this.state=f.State.FAILED,b=e.SessionConnectionState.FAILED):"disconnected"===a?(this._startWaitingReconnectTimer(),this.state=f.State.DISCONNECTED,b=e.SessionConnectionState.DISCONNECTED):"closed"===a&&(this.state=f.State.CLOSED,b=e.SessionConnectionState.CLOSED),b&&this.delegate._onSessionConnectionStateChangedListener(this.userID,b)}},f.prototype._clearWaitingReconnectTimer=function(){this.waitingReconnectTimeoutCallback&&(e.trace("_clearWaitingReconnectTimer"),clearTimeout(this.waitingReconnectTimeoutCallback),this.waitingReconnectTimeoutCallback=null)},f.prototype._startWaitingReconnectTimer=function(){var a=this,b=1e3*d.webrtc.disconnectTimeInterval,c=function(){e.trace("waitingReconnectTimeoutCallback"),clearTimeout(a.waitingReconnectTimeoutCallback),a.release(),a.delegate._closeSessionIfAllConnectionsClosed()};e.trace("_startWaitingReconnectTimer, timeout: "+b),a.waitingReconnectTimeoutCallback=setTimeout(c,b)},f.prototype._clearDialingTimer=function(){this.dialingTimer&&(e.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},f.prototype._startDialingTimer=function(a,b){var c=this,f=1e3*d.webrtc.dialingTimeInterval;e.trace("_startDialingTimer, dialingTimeInterval: "+f);var g=function(a,b,f){f||(c.answerTimeInterval+=1e3*d.webrtc.dialingTimeInterval),e.trace("_dialingCallback, answerTimeInterval: "+c.answerTimeInterval),c.answerTimeInterval>=1e3*d.webrtc.answerTimeInterval?(c._clearDialingTimer(),b&&c.delegate.processOnNotAnswer(c)):c.delegate.processCall(c,a)};c.dialingTimer=setInterval(g,f,a,b,!1),g(a,b,!0)},b.exports=f},{"../../qbConfig":15,"./qbWebRTCHelpers":10}],9:[function(a,b,c){function d(a,b){return d.__instance?d.__instance:this===window?new d:(d.__instance=this,this.connection=b,this.signalingProcessor=new h(a,this,b),this.signalingProvider=new i(a,b),this.SessionConnectionState=j.SessionConnectionState,this.CallType=j.CallType,this.PeerConnectionState=k.State,void(this.sessions={}))}function e(a,b){var c=!1,d=b.sort();return a.length&&a.forEach(function(a){var b=a.sort();c=b.length==d.length&&b.every(function(a,b){return a===d[b]})}),c}function f(a){var b=[];return Object.keys(a).length>0&&Object.keys(a).forEach(function(c,d,e){var f=a[c];(f.state===g.State.NEW||f.state===g.State.ACTIVE)&&b.push(f.opponentsIDs)}),b}var g=a("./qbWebRTCSession"),h=a("./qbWebRTCSignalingProcessor"),i=a("./qbWebRTCSignalingProvider"),j=a("./qbWebRTCHelpers"),k=a("./qbRTCPeerConnection"),l=a("./qbWebRTCSignalingConstants"),m=a("../../qbUtils");d.prototype.sessions={},d.prototype.createNewSession=function(a,b,c){var d=f(this.sessions),g=c||j.getIdFromNode(this.connection.jid),h=!1,i=b||2;if(!a)throw new Error("Can't create a session without the opponentsIDs.");if(h=e(d,a))throw new Error("Can't create a session with the same opponentsIDs. There is a session already in NEW or ACTIVE state.");return this._createAndStoreSession(null,g,a,i)},d.prototype._createAndStoreSession=function(a,b,c,d){var e=new g(a,b,c,d,this.signalingProvider,j.getIdFromNode(this.connection.jid));return e.onUserNotAnswerListener=this.onUserNotAnswerListener,e.onRemoteStreamListener=this.onRemoteStreamListener,e.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,e.onSessionCloseListener=this.onSessionCloseListener,this.sessions[e.ID]=e,e},d.prototype.clearSession=function(a){delete d.sessions[a]},d.prototype.isExistNewOrActiveSessionExceptSessionID=function(a){var b=this,c=!1;return Object.keys(b.sessions).length>0&&Object.keys(b.sessions).forEach(function(d,e,f){var h=b.sessions[d];(h.state===g.State.NEW||h.state===g.State.ACTIVE)&&h.ID!==a&&(c=!0)}),c},d.prototype._onCallListener=function(a,b,c){if(j.trace("onCall. UserID:"+a+". SessionID: "+b),this.isExistNewOrActiveSessionExceptSessionID(b))j.trace("User with id "+a+" is busy at the moment."),delete c.sdp,delete c.platform,c.sessionID=b,this.signalingProvider.sendMessage(a,c,l.SignalingType.REJECT);else{var d=this.sessions[b];if(!d){d=this._createAndStoreSession(b,c.callerID,c.opponentsIDs,c.callType);var e=JSON.parse(JSON.stringify(c));this._cleanupExtension(e),"function"==typeof this.onCallListener&&m.safeCallbackCall(this.onCallListener,d,e)}d.processOnCall(a,c)}},d.prototype._onAcceptListener=function(a,b,c){var d=this.sessions[b];if(j.trace("onAccept. UserID:"+a+". SessionID: "+b),d)if(d.state===g.State.ACTIVE){var e=JSON.parse(JSON.stringify(c));this._cleanupExtension(e),"function"==typeof this.onAcceptCallListener&&m.safeCallbackCall(this.onAcceptCallListener,d,a,e),d.processOnAccept(a,c)}else j.traceWarning("Ignore 'onAccept', the session( "+b+" ) has invalid state.");else j.traceError("Ignore 'onAccept', there is no information about session "+b+" by some reason.")},d.prototype._onRejectListener=function(a,b,c){var d=this,e=d.sessions[b];if(j.trace("onReject. UserID:"+a+". SessionID: "+b),e){var f=JSON.parse(JSON.stringify(c));d._cleanupExtension(f),"function"==typeof this.onRejectCallListener&&m.safeCallbackCall(d.onRejectCallListener,e,a,f),e.processOnReject(a,c)}else j.traceError("Ignore 'onReject', there is no information about session "+b+" by some reason.")},d.prototype._onStopListener=function(a,b,c){j.trace("onStop. UserID:"+a+". SessionID: "+b);var d=this.sessions[b],e=JSON.parse(JSON.stringify(c));!d||d.state!==g.State.ACTIVE&&d.state!==g.State.NEW?j.traceError("Ignore 'onStop', there is no information about session "+b+" by some reason."):(this._cleanupExtension(e),"function"==typeof this.onStopCallListener&&m.safeCallbackCall(this.onStopCallListener,d,a,e),d.processOnStop(a,c))},d.prototype._onIceCandidatesListener=function(a,b,c){var d=this.sessions[b];j.trace("onIceCandidates. UserID:"+a+". SessionID: "+b+". ICE candidates count: "+c.iceCandidates.length),d?d.state===g.State.ACTIVE?d.processOnIceCandidates(a,c):j.traceWarning("Ignore 'OnIceCandidates', the session ( "+b+" ) has invalid state."):j.traceError("Ignore 'OnIceCandidates', there is no information about session "+b+" by some reason.")},d.prototype._onUpdateListener=function(a,b,c){var d=this.sessions[b];j.trace("onUpdate. UserID:"+a+". SessionID: "+b+". Extension: "+JSON.stringify(c)),"function"==typeof this.onUpdateCallListener&&m.safeCallbackCall(this.onUpdateCallListener,d,a,c)},d.prototype._cleanupExtension=function(a){delete a.platform,delete a.sdp,delete a.opponentsIDs,delete a.callerID,delete a.callType},b.exports=d},{"../../qbUtils":19,"./qbRTCPeerConnection":8,"./qbWebRTCHelpers":10,"./qbWebRTCSession":11,"./qbWebRTCSignalingConstants":12,"./qbWebRTCSignalingProcessor":13,"./qbWebRTCSignalingProvider":14}],10:[function(a,b,c){var d=a("../../qbConfig"),e={};e={getUserJid:function(a,b){return a+"-"+b+"@"+d.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])},trace:function(a){d.debug&&console.log("[QBWebRTC]:",a)},traceWarning:function(a){d.debug&&console.warn("[QBWebRTC]:",a)},traceError:function(a){d.debug&&console.error("[QBWebRTC]:",a)},getLocalTime:function(){var a=(new Date).toString().split(" ");return a.slice(1,5).join("-")},dataURItoBlob:function(a,b){for(var c=[],d=window.atob(a.split(",")[1]),e=0,f=d.length;f>e;e++)c.push(d.charCodeAt(e));return new Blob([new Uint8Array(c)],{type:b})}},e.SessionConnectionState={UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},e.CallType={VIDEO:1,AUDIO:2},b.exports=e},{"../../qbConfig":15}],11:[function(a,b,c){function d(a,b,c,f,g,h){this.ID=a?a:e(),this.state=d.State.NEW,this.initiatorID=parseInt(b),this.opponentsIDs=c,this.callType=parseInt(f),this.peerConnections={},this.localStream=null,this.signalingProvider=g,this.currentUserID=h,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0}function e(){var a=(new Date).getTime(),b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"==b?c:3&c|8).toString(16)});return b}function f(a){try{return JSON.parse(JSON.stringify(a).replace(/null/g,'""'))}catch(b){return{}}}function g(a){var b=JSON.parse(JSON.stringify(a));return Object.keys(b).forEach(function(a,c,d){b[c].hasOwnProperty("url")?b[c].urls=b[c].url:b[c].url=b[c].urls}),b}var h=a("../../qbConfig"),i=a("./qbRTCPeerConnection"),j=a("../../qbUtils"),k=a("./qbWebRTCHelpers"),l=a("./qbWebRTCSignalingConstants");d.State={NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5},d.prototype.getUserMedia=function(a,b){var c=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;if(!c)throw new Error("getUserMedia() is not supported in your browser");c=c.bind(navigator);var d=this;c({audio:a.audio||!1,video:a.video||!1},function(c){d.localStream=c,a.elemId&&d.attachMediaStream(a.elemId,c,a.options),b(null,c)},function(a){b(a,null)})},d.prototype.attachMediaStream=function(a,b,c){var d=document.getElementById(a);if(!d)throw new Error("Unable to attach media stream, element "+a+" is undefined");var e=window.URL||window.webkitURL;d.src=e.createObjectURL(b),c&&c.muted&&(d.muted=!0),c&&c.mirror&&(d.style.webkitTransform="scaleX(-1)",d.style.transform="scaleX(-1)"),d.play()},d.prototype.connectionStateForUser=function(a){var b=this.peerConnections[a];return b?b.state:null},d.prototype.detachMediaStream=function(a){var b=document.getElementById(a);b&&(b.pause(),b.src="")},d.prototype.call=function(a,b){var c=this,e=f(a),g=window.navigator.onLine,h=null;k.trace("Call, extension: "+JSON.stringify(e)),g?(c.state=d.State.ACTIVE,c.opponentsIDs.forEach(function(a,b,d){c._callInternal(a,e,!0)})):(c.state=d.State.CLOSED,h=j.getError(408,"Call.ERROR - ERR_INTERNET_DISCONNECTED")),"function"==typeof b&&b(h)},d.prototype._callInternal=function(a,b,c){var d=this._createPeer(a,"offer");d.addLocalStream(this.localStream),this.peerConnections[a]=d,d.getAndSetLocalSessionDescription(function(a){a?k.trace("getAndSetLocalSessionDescription error: "+a):(k.trace("getAndSetLocalSessionDescription success"),d._startDialingTimer(b,c))})},d.prototype.accept=function(a){var b=this,c=f(a);if(k.trace("Accept, extension: "+JSON.stringify(c)),b.state===d.State.ACTIVE)return void k.traceError("Can't accept, the session is already active, return.");if(b.state===d.State.CLOSED)return k.traceError("Can't accept, the session is already closed, return."),void b.stop({});b.state=d.State.ACTIVE,b.acceptCallTime=new Date,b._clearAnswerTimer(),b._acceptInternal(b.initiatorID,c);var e=b._uniqueOpponentsIDsWithoutInitiator();if(e.length>0){var g=(b.acceptCallTime-b.startCallTime)/1e3;b._startWaitingOfferOrAnswerTimer(g),e.forEach(function(a,c,d){b.currentUserID>a&&b._callInternal(a,{},!0)})}},d.prototype._acceptInternal=function(a,b){var c=this,d=this.peerConnections[a];d?(d.addLocalStream(this.localStream),d.setRemoteSessionDescription("offer",d.getRemoteSDP(),function(e){e?k.traceError("'setRemoteSessionDescription' error: "+e):(k.trace("'setRemoteSessionDescription' success"),d.getAndSetLocalSessionDescription(function(e){e?k.trace("getAndSetLocalSessionDescription error: "+e):(b.sessionID=c.ID,b.callType=c.callType,b.callerID=c.initiatorID,b.opponentsIDs=c.opponentsIDs,b.sdp=d.localDescription.sdp,c.signalingProvider.sendMessage(a,b,l.SignalingType.ACCEPT))}))})):k.traceError("Can't accept the call, there is no information about peer connection by some reason.")},d.prototype.reject=function(a){var b=this,c=f(a),e=Object.keys(b.peerConnections).length;if(k.trace("Reject, extension: "+JSON.stringify(c)),b.state=d.State.REJECTED,b._clearAnswerTimer(),c.sessionID=b.ID,c.callType=b.callType,c.callerID=b.initiatorID,c.opponentsIDs=b.opponentsIDs,e>0)for(var g in b.peerConnections){var h=b.peerConnections[g];b.signalingProvider.sendMessage(h.userID,c,l.SignalingType.REJECT)}b._close()},d.prototype.stop=function(a){var b=this,c=f(a),e=Object.keys(b.peerConnections).length;if(k.trace("Stop, extension: "+JSON.stringify(c)),b.state=d.State.HUNGUP,b._clearAnswerTimer(),c.sessionID=b.ID,c.callType=b.callType,c.callerID=b.initiatorID,c.opponentsIDs=b.opponentsIDs,e>0)for(var g in b.peerConnections){var h=b.peerConnections[g];b.signalingProvider.sendMessage(h.userID,c,l.SignalingType.STOP)}b._close()},d.prototype.update=function(a){var b=this,c={};if(k.trace("Update, extension: "+JSON.stringify(a)),null==a)return void k.trace("extension is null, no parameters to update");c=f(a),c.sessionID=this.ID;for(var d in b.peerConnections){var e=b.peerConnections[d];b.signalingProvider.sendMessage(e.userID,c,l.SignalingType.PARAMETERS_CHANGED)}},d.prototype.mute=function(a){this._muteStream(0,a)},d.prototype.unmute=function(a){this._muteStream(1,a)},d.snapshot=function(a){var b,c,d=document.getElementById(a),e=document.createElement("canvas"),f=e.getContext("2d");return d?(e.width=d.clientWidth,e.height=d.clientHeight,"scaleX(-1)"===d.style.transform&&(f.translate(e.width,0),f.scale(-1,1)),f.drawImage(d,0,0,d.clientWidth,d.clientHeight),b=e.toDataURL(),c=k.dataURItoBlob(b,"image/png"),c.name="snapshot_"+getLocalTime()+".png",c.url=b,c):void 0},d.filter=function(a,b){var c=document.getElementById(a);c&&(c.style.webkitFilter=b,c.style.filter=b)},d.prototype.processOnCall=function(a,b){var c=this,e=c._uniqueOpponentsIDs();e.forEach(function(e,f,g){var h=c.peerConnections[e];if(h)e==a&&(h.updateRemoteSDP(b.sdp),a!=c.initiatorID&&c.state===d.State.ACTIVE&&c._acceptInternal(a,{}));else{var i;i=e!=a&&c.currentUserID>e?c._createPeer(e,"offer"):c._createPeer(e,"answer"),c.peerConnections[e]=i,e==a&&(i.updateRemoteSDP(b.sdp),c._startAnswerTimer())}})},d.prototype.processOnAccept=function(a,b){var c=this.peerConnections[a];c?(c._clearDialingTimer(),c.setRemoteSessionDescription("answer",b.sdp,function(a){a?k.traceError("'setRemoteSessionDescription' error: "+a):k.trace("'setRemoteSessionDescription' success")})):k.traceError("Ignore 'OnAccept', there is no information about peer connection by some reason.")},d.prototype.processOnReject=function(a,b){var c=this.peerConnections[a];this._clearWaitingOfferOrAnswerTimer(),c?c.release():k.traceError("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnStop=function(a,b){var c=this;if(this._clearAnswerTimer(),a===c.initiatorID)Object.keys(c.peerConnections).length?Object.keys(c.peerConnections).forEach(function(a){c.peerConnections[a].release()}):k.traceError("Ignore 'OnStop', there is no information about peer connections by some reason.");else{var d=c.peerConnections[a];d?d.release():k.traceError("Ignore 'OnStop', there is no information about peer connection by some reason.")}this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnIceCandidates=function(a,b){var c=this.peerConnections[a];c?c.addCandidates(b.iceCandidates):k.traceError("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")},d.prototype.processCall=function(a,b){var b=b||{};b.sessionID=this.ID,b.callType=this.callType,b.callerID=this.initiatorID,b.opponentsIDs=this.opponentsIDs,b.sdp=a.localDescription.sdp,this.signalingProvider.sendMessage(a.userID,b,l.SignalingType.CALL)},d.prototype.processIceCandidates=function(a,b){var c={};c.sessionID=this.ID,c.callType=this.callType,c.callerID=this.initiatorID,c.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(a.userID,b,c)},d.prototype.processOnNotAnswer=function(a){k.trace("Answer timeout callback for session "+this.ID+" for user "+a.userID),this._clearWaitingOfferOrAnswerTimer(),a.release(),"function"==typeof this.onUserNotAnswerListener&&j.safeCallbackCall(this.onUserNotAnswerListener,this,a.userID),this._closeSessionIfAllConnectionsClosed()},d.prototype._onRemoteStreamListener=function(a,b){"function"==typeof this.onRemoteStreamListener&&j.safeCallbackCall(this.onRemoteStreamListener,this,a,b)},d.prototype._onSessionConnectionStateChangedListener=function(a,b){var c=this;"function"==typeof c.onSessionConnectionStateChangedListener&&j.safeCallbackCall(c.onSessionConnectionStateChangedListener,c,a,b)},d.prototype._createPeer=function(a,b){if(!i)throw new Error("_createPeer error: RTCPeerConnection() is not supported in your browser");this.startCallTime=new Date;var c={iceServers:g(h.webrtc.iceServers)};k.trace("_createPeer, iceServers: "+JSON.stringify(c));var d=new i(c);return d.init(this,a,this.ID,b),d},d.prototype._close=function(){k.trace("_close");for(var a in this.peerConnections){var b=this.peerConnections[a];b.release()}this._closeLocalMediaStream(),this.state=d.State.CLOSED,"function"==typeof this.onSessionCloseListener&&j.safeCallbackCall(this.onSessionCloseListener,this)},d.prototype._closeSessionIfAllConnectionsClosed=function(){var a=!0;for(var b in this.peerConnections){var c=this.peerConnections[b];if("closed"!==c.signalingState){a=!1;break}}k.trace("All peer connections closed: "+a),a&&(this._closeLocalMediaStream(),"function"==typeof this.onSessionCloseListener&&this.onSessionCloseListener(this),this.state=d.State.CLOSED)},d.prototype._closeLocalMediaStream=function(){this.localStream&&(this.localStream.getAudioTracks().forEach(function(a){a.stop()}),this.localStream.getVideoTracks().forEach(function(a){a.stop()}),this.localStream=null)},d.prototype._muteStream=function(a,b){return"audio"===b&&this.localStream.getAudioTracks().length>0?void this.localStream.getAudioTracks().forEach(function(b){b.enabled=!!a}):"video"===b&&this.localStream.getVideoTracks().length>0?void this.localStream.getVideoTracks().forEach(function(b){b.enabled=!!a}):void 0},d.prototype._clearAnswerTimer=function(){this.answerTimer&&(k.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)},d.prototype._startAnswerTimer=function(){k.trace("_startAnswerTimer");var a=this,b=function(){k.trace("_answerTimeoutCallback"),"function"==typeof a.onSessionCloseListener&&a._close(),a.answerTimer=null},c=1e3*h.webrtc.answerTimeInterval;this.answerTimer=setTimeout(b,c)},d.prototype._clearWaitingOfferOrAnswerTimer=function(){this.waitingOfferOrAnswerTimer&&(k.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)},d.prototype._startWaitingOfferOrAnswerTimer=function(a){var b=this,c=h.webrtc.answerTimeInterval-a<0?1:h.webrtc.answerTimeInterval-a,d=function(){k.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(b.peerConnections).length>0&&Object.keys(b.peerConnections).forEach(function(a){var c=b.peerConnections[a];(c.state===i.State.CONNECTING||c.state===i.State.NEW)&&b.processOnNotAnswer(c)}),b.waitingOfferOrAnswerTimer=null};k.trace("_startWaitingOfferOrAnswerTimer, timeout: "+c),this.waitingOfferOrAnswerTimer=setTimeout(d,1e3*c)},d.prototype._uniqueOpponentsIDs=function(){var a=this,b=[];return this.initiatorID!==this.currentUserID&&b.push(this.initiatorID),this.opponentsIDs.forEach(function(c,d,e){c!=a.currentUserID&&b.push(parseInt(c))}),b},d.prototype._uniqueOpponentsIDsWithoutInitiator=function(){var a=this,b=[];return this.opponentsIDs.forEach(function(c,d,e){c!=a.currentUserID&&b.push(parseInt(c))}),b},d.prototype.toString=function(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType},b.exports=d},{"../../qbConfig":15,"../../qbUtils":19,"./qbRTCPeerConnection":8,"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12}],12:[function(a,b,c){function d(){}d.MODULE_ID="WebRTCVideoChat",d.SignalingType={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},b.exports=d},{}],13:[function(a,b,c){function d(a,b,c){var d=this;d.service=a,d.delegate=b,d.connection=c,this._onMessage=function(a){var b=a.getAttribute("from"),c=a.querySelector("extraParams"),g=a.querySelector("delay"),h=e.getIdFromNode(b),i=d._getExtension(c);if(g||i.moduleIdentifier!==f.MODULE_ID)return!0;var j=i.sessionID,k=i.signalType;switch(delete i.moduleIdentifier,delete i.sessionID,delete i.signalType,k){case f.SignalingType.CALL:"function"==typeof d.delegate._onCallListener&&d.delegate._onCallListener(h,j,i);break;case f.SignalingType.ACCEPT:"function"==typeof d.delegate._onAcceptListener&&d.delegate._onAcceptListener(h,j,i);break;case f.SignalingType.REJECT:"function"==typeof d.delegate._onRejectListener&&d.delegate._onRejectListener(h,j,i);break;case f.SignalingType.STOP:"function"==typeof d.delegate._onStopListener&&d.delegate._onStopListener(h,j,i);break;case f.SignalingType.CANDIDATE:"function"==typeof d.delegate._onIceCandidatesListener&&d.delegate._onIceCandidatesListener(h,j,i);break;case f.SignalingType.PARAMETERS_CHANGED:"function"==typeof d.delegate._onUpdateListener&&d.delegate._onUpdateListener(h,j,i)}return!0},this._getExtension=function(a){if(!a)return null;for(var b,c,e,f,g={},h=[],i=[],j=0,k=a.childNodes.length;k>j;j++)if("iceCandidates"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var l=0,m=e.length;m>l;l++){b={},f=e[l].childNodes;for(var n=0,o=f.length;o>n;n++)b[f[n].tagName]=f[n].textContent;h.push(b)}}else if("opponentsIDs"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var p=0,q=e.length;q>p;p++)c=e[p].textContent,i.push(parseInt(c))}else if(a.childNodes[j].childNodes.length>1){var r=a.childNodes[j].textContent.length;if(r>4096){for(var s="",t=0;t0&&(g.iceCandidates=h),i.length>0&&(g.opponentsIDs=i),g},this._XMLtoJS=function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a}}a("strophe");var e=a("./qbWebRTCHelpers"),f=a("./qbWebRTCSignalingConstants");b.exports=d},{"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12,strophe:51}],14:[function(a,b,c){function d(a,b){this.service=a,this.connection=b}a("strophe");var e=a("./qbWebRTCHelpers"),f=a("./qbWebRTCSignalingConstants"),g=a("../../qbUtils"),h=a("../../qbConfig");d.prototype.sendCandidate=function(a,b,c){var d=c||{};d.iceCandidates=b,this.sendMessage(a,d,f.SignalingType.CANDIDATE)},d.prototype.sendMessage=function(a,b,c){var d,i,j=b||{},k=this;j.moduleIdentifier=f.MODULE_ID,j.signalType=c,j.platform="web",i={to:e.getUserJid(a,h.creds.appId),type:"headline",id:g.getBsonObjectId()},d=$msg(i).c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(j).forEach(function(a){"iceCandidates"===a?(d=d.c("iceCandidates"),j[a].forEach(function(a){d=d.c("iceCandidate"),Object.keys(a).forEach(function(b){d.c(b).t(a[b]).up()}),d.up()}),d.up()):"opponentsIDs"===a?(d=d.c("opponentsIDs"),j[a].forEach(function(a){d=d.c("opponentID").t(a).up()}),d.up()):"object"==typeof j[a]?k._JStoXML(a,j[a],d):d.c(a).t(j[a]).up()}),this.connection.send(d)},d.prototype._JStoXML=function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},b.exports=d},{"../../qbConfig":15,"../../qbUtils":19,"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12,strophe:51}],15:[function(a,b,c){var d={version:"2.0.4",creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com"},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},webrtc:{answerTimeInterval:60,dialingTimeInterval:5,disconnectTimeInterval:30,iceServers:[{url:"stun:stun.l.google.com:19302"},{url:"stun:turn.quickblox.com",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnsingapor.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnsingapore.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnireland.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnireland.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"}]},urls:{session:"session",login:"login",users:"users",chat:"chat",blobs:"blobs",geodata:"geodata",pushtokens:"push_tokens",subscriptions:"subscriptions",events:"events",data:"data",type:".json"},on:{sessionExpired:null},timeout:null,debug:{mode:0,file:null},addISOTime:!1};d.set=function(a){"object"==typeof a.endpoints&&a.endpoints.chat&&(d.endpoints.muc="muc."+a.endpoints.chat,d.chatProtocol.bosh="https://"+a.endpoints.chat+":5281",d.chatProtocol.websocket="wss://"+a.endpoints.chat+":5291"),Object.keys(a).forEach(function(b){"set"!==b&&d.hasOwnProperty(b)&&("object"!=typeof a[b]?d[b]=a[b]:Object.keys(a[b]).forEach(function(c){d[b].hasOwnProperty(c)&&(d[b][c]=a[b][c])})),"iceServers"===b&&(d.webrtc.iceServers=a[b])})},b.exports=d},{}],16:[function(a,b,c){function d(){}var e=a("./qbConfig"),f=a("./qbUtils"),g="undefined"!=typeof window;d.prototype={init:function(b,c,d,h){h&&"object"==typeof h&&e.set(h);var i=a("./qbProxy");this.service=new i;var j,k=a("./modules/qbAuth"),l=a("./modules/qbUsers"),m=a("./modules/qbChat"),n=a("./modules/qbContent"),o=a("./modules/qbLocation"),p=a("./modules/qbPushNotifications"),q=a("./modules/qbData");if(g){var r=a("./qbStrophe");if(j=new r,f.isWebRTCAvailble()){var s=a("./modules/webrtc/qbWebRTCClient");this.webrtc=new s(this.service,j||null)}else this.webrtc=!1}else this.webrtc=!1;this.auth=new k(this.service),this.users=new l(this.service),this.chat=new m(this.service,this.webrtc?this.webrtc.signalingProcessor:null,j||null),this.content=new n(this.service),this.location=new o(this.service),this.pushnotifications=new p(this.service),this.data=new q(this.service),"string"!=typeof b||c&&"number"!=typeof c||d?(e.creds.appId=b,e.creds.authKey=c,e.creds.authSecret=d):("number"==typeof c&&(e.creds.appId=c),this.service.setSession({token:b}))},getSession:function(a){this.auth.getSession(a)},createSession:function(a,b){this.auth.createSession(a,b)},destroySession:function(a){this.auth.destroySession(a)},login:function(a,b){this.auth.login(a,b)},logout:function(a){this.auth.logout(a)}};var h=new d;h.QuickBlox=d,b.exports=h},{"./modules/qbAuth":1,"./modules/qbChat":2,"./modules/qbContent":3,"./modules/qbData":4,"./modules/qbLocation":5,"./modules/qbPushNotifications":6,"./modules/qbUsers":7,"./modules/webrtc/qbWebRTCClient":9,"./qbConfig":15,"./qbProxy":17,"./qbStrophe":18,"./qbUtils":19}],17:[function(a,b,c){function d(){this.qbInst={config:e,session:null}}var e=a("./qbConfig"),f=a("./qbUtils"),g=e.version,h="undefined"!=typeof window;if(!h)var i=a("request");var j=h&&window.jQuery&&window.jQuery.ajax||h&&window.Zepto&&window.Zepto.ajax;if(h&&!j)throw new Error("Quickblox requires jQuery or Zepto");d.prototype={setSession:function(a){this.qbInst.session=a},getSession:function(){return this.qbInst.session},handleResponse:function(a,b,c,d){!a||"function"!=typeof e.on.sessionExpired||"Unauthorized"!==a.message&&"401 Unauthorized"!==a.status?a?c(a,null):(e.addISOTime&&(b=f.injectISOTimes(b)),c(null,b)):e.on.sessionExpired(function(){c(a,b)},d)},ajax:function(a,b){var c;a.data&&a.data.file?(c=JSON.parse(JSON.stringify(a)),c.data.file="..."):c=a,f.QBLog("[ServiceProxy]","Request: ",a.type||"GET",{data:JSON.stringify(c)});var d=this,k=function(c){c&&d.setSession(c),d.ajax(a,b)},l={url:a.url,type:a.type||"GET",dataType:a.dataType||"json",data:a.data||" ",timeout:e.timeout,beforeSend:function(a,b){-1===b.url.indexOf("s3.amazonaws.com")&&d.qbInst.session&&d.qbInst.session.token&&(a.setRequestHeader("QB-Token",d.qbInst.session.token),a.setRequestHeader("QB-SDK","JS "+g+" - Client"))},success:function(c,g,h){f.QBLog("[ServiceProxy]","Response: ",{data:JSON.stringify(c)}),-1===a.url.indexOf(e.urls.session)?d.handleResponse(null,c,b,k):b(null,c)},error:function(c,g,h){f.QBLog("[ServiceProxy]","ajax error",c.status,h,c.responseText);var i={code:c.status,status:g,message:h,detail:c.responseText};-1===a.url.indexOf(e.urls.session)?d.handleResponse(i,null,b,k):b(i,null)}};if(!h)var m="json"===l.dataType,n=-1===a.url.indexOf("s3.amazonaws.com")&&d.qbInst&&d.qbInst.session&&d.qbInst.session.token||!1,o={url:l.url,method:l.type,timeout:e.timeout,json:m?l.data:null,headers:n?{"QB-Token":d.qbInst.session.token,"QB-SDK":"JS "+g+" - Server"}:null},p=function(a,c,f){if(a||200!==c.statusCode&&201!==c.statusCode&&202!==c.statusCode){var g;try{g={code:c&&c.statusCode||a&&a.code,status:c&&c.headers&&c.headers.status||"error",message:f||a&&a.errno, -detail:f&&f.errors||a&&a.syscall}}catch(h){g=a}-1===o.url.indexOf(e.urls.session)?d.handleResponse(g,null,b,k):b(g,null)}else-1===o.url.indexOf(e.urls.session)?d.handleResponse(null,f,b,k):b(null,f)};if(("boolean"==typeof a.contentType||"string"==typeof a.contentType)&&(l.contentType=a.contentType),"boolean"==typeof a.processData&&(l.processData=a.processData),h)j(l);else{var q=i(o,p);if(!m){var r=q.form();Object.keys(l.data).forEach(function(a,b,c){r.append(a,l.data[a])})}}}},b.exports=d},{"./qbConfig":15,"./qbUtils":19,request:24}],18:[function(a,b,c){function d(){var a=1===e.chatProtocol.active?e.chatProtocol.bosh:e.chatProtocol.websocket,b=new Strophe.Connection(a);return 1===e.chatProtocol.active?(b.xmlInput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)f.QBLog("[QBChat]","RECV:",a.childNodes[b])},b.xmlOutput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)f.QBLog("[QBChat]","SENT:",a.childNodes[b])}):(b.xmlInput=function(a){f.QBLog("[QBChat]","RECV:",a)},b.xmlOutput=function(a){f.QBLog("[QBChat]","SENT:",a)}),b}a("strophe");var e=a("./qbConfig"),f=a("./qbUtils");b.exports=d},{"./qbConfig":15,"./qbUtils":19,strophe:51}],19:[function(a,b,c){var d=a("./qbConfig"),e="undefined"!=typeof window,f="This function isn't supported outside of the browser (...yet)";if(!e)var g=a("fs");var h={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0},i={safeCallbackCall:function(){if(!e)throw f;for(var a,b=arguments[0].toString(),c=b.split("(")[0].split(" ")[1],d=[],g=0;g16777215&&(h.increment=0),"00000000".substr(0,8-a.length)+a+"000000".substr(0,6-h.machine.length)+h.machine+"0000".substr(0,4-h.pid.length)+h.pid+"000000".substr(0,6-b.length)+b},injectISOTimes:function(a){if(a.created_at)"number"==typeof a.created_at&&(a.iso_created_at=new Date(1e3*a.created_at).toISOString()),"number"==typeof a.updated_at&&(a.iso_updated_at=new Date(1e3*a.updated_at).toISOString());else if(a.items)for(var b=0,c=a.items.length;c>b;++b)"number"==typeof a.items[b].created_at&&(a.items[b].iso_created_at=new Date(1e3*a.items[b].created_at).toISOString()),"number"==typeof a.items[b].updated_at&&(a.items[b].iso_updated_at=new Date(1e3*a.items[b].updated_at).toISOString());return a},QBLog:function(){if(this.loggers)for(var a=0;af;f++){var g=255&c[f>>>2]>>>24-8*(f%4);b[d+f>>>2]|=g<<24-8*((d+f)%4)}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(0|4294967296*a.random());return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}});var l=c.algo={};return c}(Math);return a})},{}],21:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core"),b("./sha1"),b("./hmac")):"function"==typeof a&&a.amd?a(["./core","./sha1","./hmac"],f):f(e.CryptoJS)}(this,function(a){return a.HmacSHA1})},{"./core":20,"./hmac":22,"./sha1":23}],22:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){!function(){var b=a,c=b.lib,d=c.Base,e=b.enc,f=e.Utf8,g=b.algo;g.HMAC=d.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=f.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),g=this._iKey=b.clone(),h=e.words,i=g.words,j=0;c>j;j++)h[j]^=1549556828,i[j]^=909522486;e.sigBytes=g.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher,c=b.finalize(a);b.reset();var d=b.finalize(this._oKey.clone().concat(c));return d}})}()})},{"./core":20}],23:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){return function(){var b=a,c=b.lib,d=c.WordArray,e=c.Hasher,f=b.algo,g=[],h=f.SHA1=e.extend({_doReset:function(){this._hash=new d.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=0|c[0]+d,c[1]=0|c[1]+e,c[2]=0|c[2]+f,c[3]=0|c[3]+h,c[4]=0|c[4]+i},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA1=e._createHelper(h),b.HmacSHA1=e._createHmacHelper(h)}(),a.SHA1})},{"./core":20}],24:[function(a,b,c){},{}],25:[function(a,b,c){arguments[4][24][0].apply(c,arguments)},{dup:24}],26:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,0>b?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;b>c;c++)a[c]=0;return a}function h(a,b,c){("string"!=typeof c||""===c)&&(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;d>e;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),0>b&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;c>e;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(c>=e+h){var i,j,k,l;switch(h){case 1:128>f&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(55296>l||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&1114112>l&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if($>=b)return String.fromCharCode.apply(String,a);for(var c="",d=0;b>d;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;fa)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||g>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return 16>a?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(1114112>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);g>e&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),d>c?-1:c>d?1:0},f.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),""},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(0>c||0>b)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,void 0);for(var g=0;e>g;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=0>a?1:0;for(this[b]=255&a;++f>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=0>a?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&c>d&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>d)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-bc&&d>b)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(1e3>g||!f.TYPED_ARRAY_SUPPORT)for(e=0;g>e;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":27,ieee754:28,isarray:29}],27:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],28:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],29:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],30:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b; -throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;d>i;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(0>d)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],31:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],32:[function(a,b,c){b.exports=function(a){return!(null==a||!(a._isBuffer||a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)))}},{}],33:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],34:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l1)for(var c=1;cc;c++)b(a[c],c)}b.exports=d;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=a("core-util-is");h.inherits=a("inherits");var i=a("./_stream_readable"),j=a("./_stream_writable");h.inherits(d,i),f(g(j.prototype),function(a){d.prototype[a]||(d.prototype[a]=j.prototype[a])})}).call(this,a("_process"))},{"./_stream_readable":38,"./_stream_writable":40,_process:34,"core-util-is":41,inherits:31}],37:[function(a,b,c){function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./_stream_transform"),f=a("core-util-is");f.inherits=a("inherits"),f.inherits(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./_stream_transform":39,"core-util-is":41,inherits:31}],38:[function(a,b,c){(function(c){function d(b,c){var d=a("./_stream_duplex");b=b||{};var e=b.highWaterMark,f=b.objectMode?16:16384;this.highWaterMark=e||0===e?e:f,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!b.objectMode,c instanceof d&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.defaultEncoding=b.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(C||(C=a("string_decoder/").StringDecoder),this.decoder=new C(b.encoding),this.encoding=b.encoding)}function e(b){a("./_stream_duplex");return this instanceof e?(this._readableState=new d(b,this),this.readable=!0,void A.call(this)):new e(b)}function f(a,b,c,d,e){var f=j(b,c);if(f)a.emit("error",f);else if(B.isNullOrUndefined(c))b.reading=!1,b.ended||k(a,b);else if(b.objectMode||c&&c.length>0)if(b.ended&&!e){var h=new Error("stream.push() after EOF");a.emit("error",h)}else if(b.endEmitted&&e){var h=new Error("stream.unshift() after end event");a.emit("error",h)}else!b.decoder||e||d||(c=b.decoder.write(c)),e||(b.reading=!1),b.flowing&&0===b.length&&!b.sync?(a.emit("data",c),a.read(0)):(b.length+=b.objectMode?1:c.length,e?b.buffer.unshift(c):b.buffer.push(c),b.needReadable&&l(a)),n(a,b);else e||(b.reading=!1);return g(b)}function g(a){return!a.ended&&(a.needReadable||a.length=E)a=E;else{a--;for(var b=1;32>b;b<<=1)a|=a>>b;a++}return a}function i(a,b){return 0===b.length&&b.ended?0:b.objectMode?0===a?0:1:isNaN(a)||B.isNull(a)?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:0>=a?0:(a>b.highWaterMark&&(b.highWaterMark=h(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}function j(a,b){var c=null;return B.isBuffer(b)||B.isString(b)||B.isNullOrUndefined(b)||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function k(a,b){if(b.decoder&&!b.ended){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,l(a)}function l(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(D("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?c.nextTick(function(){m(a)}):m(a))}function m(a){D("emit readable"),a.emit("readable"),s(a)}function n(a,b){b.readingMore||(b.readingMore=!0,c.nextTick(function(){o(a,b)}))}function o(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length=e)c=f?d.join(""):y.concat(d,e),d.length=0;else if(aj&&a>i;j++){var h=d[0],l=Math.min(a-i,h.length);f?c+=h.slice(0,l):h.copy(c,i,0,l),l0)throw new Error("endReadable called on non-empty stream");b.endEmitted||(b.ended=!0,c.nextTick(function(){b.endEmitted||0!==b.length||(b.endEmitted=!0,a.readable=!1,a.emit("end"))}))}function v(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}function w(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}b.exports=e;var x=a("isarray"),y=a("buffer").Buffer;e.ReadableState=d;var z=a("events").EventEmitter;z.listenerCount||(z.listenerCount=function(a,b){return a.listeners(b).length});var A=a("stream"),B=a("core-util-is");B.inherits=a("inherits");var C,D=a("util");D=D&&D.debuglog?D.debuglog("stream"):function(){},B.inherits(e,A),e.prototype.push=function(a,b){var c=this._readableState;return B.isString(a)&&!c.objectMode&&(b=b||c.defaultEncoding,b!==c.encoding&&(a=new y(a,b),b="")),f(this,c,a,b,!1)},e.prototype.unshift=function(a){var b=this._readableState;return f(this,b,a,"",!0)},e.prototype.setEncoding=function(b){return C||(C=a("string_decoder/").StringDecoder),this._readableState.decoder=new C(b),this._readableState.encoding=b,this};var E=8388608;e.prototype.read=function(a){D("read",a);var b=this._readableState,c=a;if((!B.isNumber(a)||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return D("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?u(this):l(this),null;if(a=i(a,b),0===a&&b.ended)return 0===b.length&&u(this),null;var d=b.needReadable;D("need readable",d),(0===b.length||b.length-a0?t(a,b):null,B.isNull(e)&&(b.needReadable=!0,a=0),b.length-=a,0!==b.length||b.ended||(b.needReadable=!0),c!==a&&b.ended&&0===b.length&&u(this),B.isNull(e)||this.emit("data",e),e},e.prototype._read=function(a){this.emit("error",new Error("not implemented"))},e.prototype.pipe=function(a,b){function d(a){D("onunpipe"),a===l&&f()}function e(){D("onend"),a.end()}function f(){D("cleanup"),a.removeListener("close",i),a.removeListener("finish",j),a.removeListener("drain",q),a.removeListener("error",h),a.removeListener("unpipe",d),l.removeListener("end",e),l.removeListener("end",f),l.removeListener("data",g),!m.awaitDrain||a._writableState&&!a._writableState.needDrain||q()}function g(b){D("ondata");var c=a.write(b);!1===c&&(D("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,l.pause())}function h(b){D("onerror",b),k(),a.removeListener("error",h),0===z.listenerCount(a,"error")&&a.emit("error",b)}function i(){a.removeListener("finish",j),k()}function j(){D("onfinish"),a.removeListener("close",i),k()}function k(){D("unpipe"),l.unpipe(a)}var l=this,m=this._readableState;switch(m.pipesCount){case 0:m.pipes=a;break;case 1:m.pipes=[m.pipes,a];break;default:m.pipes.push(a)}m.pipesCount+=1,D("pipe count=%d opts=%j",m.pipesCount,b);var n=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,o=n?e:f;m.endEmitted?c.nextTick(o):l.once("end",o),a.on("unpipe",d);var q=p(l);return a.on("drain",q),l.on("data",g),a._events&&a._events.error?x(a._events.error)?a._events.error.unshift(h):a._events.error=[h,a._events.error]:a.on("error",h),a.once("close",i),a.once("finish",j),a.emit("pipe",l),m.flowing||(D("pipe resume"),l.resume()),a},e.prototype.unpipe=function(a){var b=this._readableState;if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,a&&a.emit("unpipe",this),this);if(!a){var c=b.pipes,d=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var e=0;d>e;e++)c[e].emit("unpipe",this);return this}var e=w(b.pipes,a);return-1===e?this:(b.pipes.splice(e,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this),this)},e.prototype.on=function(a,b){var d=A.prototype.on.call(this,a,b);if("data"===a&&!1!==this._readableState.flowing&&this.resume(),"readable"===a&&this.readable){var e=this._readableState;if(!e.readableListening)if(e.readableListening=!0,e.emittedReadable=!1,e.needReadable=!0,e.reading)e.length&&l(this,e);else{var f=this;c.nextTick(function(){D("readable nexttick read 0"),f.read(0)})}}return d},e.prototype.addListener=e.prototype.on,e.prototype.resume=function(){var a=this._readableState;return a.flowing||(D("resume"),a.flowing=!0,a.reading||(D("resume read 0"),this.read(0)),q(this,a)),this},e.prototype.pause=function(){return D("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(D("pause"),this._readableState.flowing=!1,this.emit("pause")),this},e.prototype.wrap=function(a){var b=this._readableState,c=!1,d=this;a.on("end",function(){if(D("wrapped end"),b.decoder&&!b.ended){var a=b.decoder.end();a&&a.length&&d.push(a)}d.push(null)}),a.on("data",function(e){if(D("wrapped data"),b.decoder&&(e=b.decoder.write(e)),e&&(b.objectMode||e.length)){var f=d.push(e);f||(c=!0,a.pause())}});for(var e in a)B.isFunction(a[e])&&B.isUndefined(this[e])&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));var f=["error","close","destroy","pause","resume"];return v(f,function(b){a.on(b,d.emit.bind(d,b))}),d._read=function(b){D("wrapped _read",b),c&&(c=!1,a.resume())},d},e._fromList=t}).call(this,a("_process"))},{"./_stream_duplex":36,_process:34,buffer:26,"core-util-is":41,events:30,inherits:31,isarray:33,stream:46,"string_decoder/":47,util:25}],39:[function(a,b,c){function d(a,b){this.afterTransform=function(a,c){return e(b,a,c)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function e(a,b,c){var d=a._transformState;d.transforming=!1;var e=d.writecb;if(!e)return a.emit("error",new Error("no writecb in Transform class"));d.writechunk=null,d.writecb=null,i.isNullOrUndefined(c)||a.push(c),e&&e(b);var f=a._readableState;f.reading=!1,(f.needReadable||f.length1){for(var c=[],d=0;d=this.charLength-this.charReceived?this.charLength-this.charReceived:a.length;if(a.copy(this.charBuffer,this.charReceived,0,c),this.charReceived+=c,this.charReceived=55296&&56319>=d)){if(this.charReceived=this.charLength=0,0===a.length)return b;break}this.charLength+=this.surrogateSize,b=""}this.detectIncompleteChar(a);var e=a.length;this.charLength&&(a.copy(this.charBuffer,0,a.length-this.charReceived,e),e-=this.charReceived),b+=a.toString(this.encoding,0,e);var e=b.length-1,d=b.charCodeAt(e);if(d>=55296&&56319>=d){var f=this.surrogateSize;return this.charLength+=f,this.charReceived+=f,this.charBuffer.copy(this.charBuffer,f,0,f),a.copy(this.charBuffer,0,0,f),b.substring(0,e)}return b},j.prototype.detectIncompleteChar=function(a){for(var b=a.length>=3?3:a.length;b>0;b--){var c=a[a.length-b];if(1==b&&c>>5==6){this.charLength=2;break}if(2>=b&&c>>4==14){this.charLength=3;break}if(3>=b&&c>>3==30){this.charLength=4;break}}this.charReceived=b},j.prototype.end=function(a){var b="";if(a&&a.length&&(b=this.write(a)),this.charReceived){var c=this.charReceived,d=this.charBuffer,e=this.encoding;b+=d.slice(0,c).toString(e)}return b}},{buffer:26}],48:[function(a,b,c){function d(a,b){this._id=a,this._clearFn=b}var e=a("process/browser.js").nextTick,f=Function.prototype.apply,g=Array.prototype.slice,h={},i=0;c.setTimeout=function(){return new d(f.call(setTimeout,window,arguments),clearTimeout)},c.setInterval=function(){return new d(f.call(setInterval,window,arguments),clearInterval)},c.clearTimeout=c.clearInterval=function(a){a.close()},d.prototype.unref=d.prototype.ref=function(){},d.prototype.close=function(){this._clearFn.call(window,this._id)},c.enroll=function(a,b){clearTimeout(a._idleTimeoutId),a._idleTimeout=b},c.unenroll=function(a){clearTimeout(a._idleTimeoutId),a._idleTimeout=-1},c._unrefActive=c.active=function(a){clearTimeout(a._idleTimeoutId);var b=a._idleTimeout;b>=0&&(a._idleTimeoutId=setTimeout(function(){a._onTimeout&&a._onTimeout()},b))},c.setImmediate="function"==typeof setImmediate?setImmediate:function(a){var b=i++,d=arguments.length<2?!1:g.call(arguments,1);return h[b]=!0,e(function(){h[b]&&(d?a.apply(null,d):a.call(null),c.clearImmediate(b))}),b},c.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(a){delete h[a]}},{"process/browser.js":34}],49:[function(a,b,c){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],50:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a,b){return a}function h(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(m(a,b,c,d,String(g),!0)):f.push("");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){ -if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":49,_process:34,inherits:31}],51:[function(b,c,d){!function(b){return function(b,c){"function"==typeof a&&a.amd?a("strophe-base64",function(){return c()}):b.Base64=c()}(this,function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b={encode:function(b){var c,d,e,f,g,h,i,j="",k=0;do c=b.charCodeAt(k++),d=b.charCodeAt(k++),e=b.charCodeAt(k++),f=c>>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?(g=(3&c)<<4,h=i=64):isNaN(e)&&(i=64),j=j+a.charAt(f)+a.charAt(g)+a.charAt(h)+a.charAt(i);while(k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!=h&&(j+=String.fromCharCode(d)),64!=i&&(j+=String.fromCharCode(e));while(k>5]|=128<<24-d%32,a[(d+64>>9<<4)+15]=d;var g,h,i,j,k,l,m,n,o=new Array(80),p=1732584193,q=-271733879,r=-1732584194,s=271733878,t=-1009589776;for(g=0;gh;h++)16>h?o[h]=a[g+h]:o[h]=f(o[h-3]^o[h-8]^o[h-14]^o[h-16],1),i=e(e(f(p,5),b(h,q,r,s)),e(e(t,o[h]),c(h))),t=s,s=r,r=f(q,30),q=p,p=i;p=e(p,j),q=e(q,k),r=e(r,l),s=e(s,m),t=e(t,n)}return[p,q,r,s,t]}function b(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d}function c(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function d(b,c){var d=g(b);d.length>16&&(d=a(d,8*b.length));for(var e=new Array(16),f=new Array(16),h=0;16>h;h++)e[h]=909522486^d[h],f[h]=1549556828^d[h];var i=a(e.concat(g(c)),512+8*c.length);return a(f.concat(i),672)}function e(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function f(a,b){return a<>>32-b}function g(a){for(var b=[],c=255,d=0;d<8*a.length;d+=8)b[d>>5]|=(a.charCodeAt(d/8)&c)<<24-d%32;return b}function h(a){for(var b="",c=255,d=0;d<32*a.length;d+=8)b+=String.fromCharCode(a[d>>5]>>>24-d%32&c);return b}function i(a){for(var b,c,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="",f=0;f<4*a.length;f+=3)for(b=(a[f>>2]>>8*(3-f%4)&255)<<16|(a[f+1>>2]>>8*(3-(f+1)%4)&255)<<8|a[f+2>>2]>>8*(3-(f+2)%4)&255,c=0;4>c;c++)e+=8*f+6*c>32*a.length?"=":d.charAt(b>>6*(3-c)&63);return e}return{b64_hmac_sha1:function(a,b){return i(d(a,b))},b64_sha1:function(b){return i(a(g(b),8*b.length))},binb2str:h,core_hmac_sha1:d,str_hmac_sha1:function(a,b){return h(d(a,b))},str_sha1:function(b){return h(a(g(b),8*b.length))}}}),function(b,c){"function"==typeof a&&a.amd?a("strophe-md5",function(){return c()}):b.MD5=c()}(this,function(a){var b=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},c=function(a,b){return a<>>32-b},d=function(a){for(var b=[],c=0;c<8*a.length;c+=8)b[c>>5]|=(255&a.charCodeAt(c/8))<>5]>>>c%32&255);return b},f=function(a){for(var b="0123456789abcdef",c="",d=0;d<4*a.length;d++)c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},g=function(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)},h=function(a,b,c,d,e,f,h){return g(b&c|~b&d,a,b,e,f,h)},i=function(a,b,c,d,e,f,h){return g(b&d|c&~d,a,b,e,f,h)},j=function(a,b,c,d,e,f,h){return g(b^c^d,a,b,e,f,h)},k=function(a,b,c,d,e,f,h){return g(c^(b|~d),a,b,e,f,h)},l=function(a,c){a[c>>5]|=128<>>9<<4)+14]=c;for(var d,e,f,g,l=1732584193,m=-271733879,n=-1732584194,o=271733878,p=0;pc?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),function(b,c){if("function"==typeof a&&a.amd)a("strophe-core",["strophe-sha1","strophe-base64","strophe-md5","strophe-polyfill"],function(){return c.apply(this,arguments)});else{var d=c(b.SHA1,b.Base64,b.MD5);window.Strophe=d.Strophe,window.$build=d.$build,window.$iq=d.$iq,window.$msg=d.$msg,window.$pres=d.$pres,window.SHA1=d.SHA1,window.Base64=d.Base64,window.MD5=d.MD5,window.b64_hmac_sha1=d.SHA1.b64_hmac_sha1,window.b64_sha1=d.SHA1.b64_sha1,window.str_hmac_sha1=d.SHA1.str_hmac_sha1,window.str_sha1=d.SHA1.str_sha1}}(this,function(a,b,c){function d(a,b){return new h.Builder(a,b)}function e(a){return new h.Builder("message",a)}function f(a){return new h.Builder("iq",a)}function g(a){return new h.Builder("presence",a)}var h;return h={VERSION:"1.2.2",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},XHTML:{tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"],validTag:function(a){for(var b=0;b0)for(var c=0;c/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,""")},xmlunescape:function(a){return a=a.replace(/\&/g,"&"),a=a.replace(/</g,"<"),a=a.replace(/>/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,'"')},xmlTextNode:function(a){return h.xmlGenerator().createTextNode(a)},xmlHtmlNode:function(a){var b;if(window.DOMParser){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a);return b},getText:function(a){if(!a)return null;var b="";0===a.childNodes.length&&a.nodeType==h.ElementType.TEXT&&(b+=a.nodeValue);for(var c=0;c0&&(g=i.join("; "),c.setAttribute(f,g))}else c.setAttribute(f,g);for(b=0;b/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(a){return"string"!=typeof a?a:a.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(a){return a.indexOf("@")<0?null:a.split("@")[0]},getDomainFromJid:function(a){var b=h.getBareJidFromJid(a);if(b.indexOf("@")<0)return b;var c=b.split("@");return c.splice(0,1),c.join("@")},getResourceFromJid:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),b.join("/"))},getBareJidFromJid:function(a){return a?a.split("/")[0]:null},log:function(a,b){},debug:function(a){this.log(this.LogLevel.DEBUG,a)},info:function(a){this.log(this.LogLevel.INFO,a)},warn:function(a){this.log(this.LogLevel.WARN,a)},error:function(a){this.log(this.LogLevel.ERROR,a)},fatal:function(a){this.log(this.LogLevel.FATAL,a)},serialize:function(a){var b;if(!a)return null;"function"==typeof a.tree&&(a=a.tree());var c,d,e=a.nodeName;for(a.getAttribute("_realname")&&(e=a.getAttribute("_realname")),b="<"+e,c=0;c/g,">").replace(/0){for(b+=">",c=0;c"}b+=""}else b+="/>";return b},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(a,b){h._connectionPlugins[a]=b}},h.Builder=function(a,b){("presence"==a||"message"==a||"iq"==a)&&(b&&!b.xmlns?b.xmlns=h.NS.CLIENT:b||(b={xmlns:h.NS.CLIENT})),this.nodeTree=h.xmlElement(a,b),this.node=this.nodeTree},h.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return h.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},attrs:function(a){for(var b in a)a.hasOwnProperty(b)&&(void 0===a[b]?this.node.removeAttribute(b):this.node.setAttribute(b,a[b]));return this},c:function(a,b,c){var d=h.xmlElement(a,b,c);return this.node.appendChild(d),"string"!=typeof c&&(this.node=d),this},cnode:function(a){var b,c=h.xmlGenerator();try{b=void 0!==c.importNode}catch(d){b=!1}var e=b?c.importNode(a,!0):h.copyElement(a);return this.node.appendChild(e),this.node=e,this},t:function(a){var b=h.xmlTextNode(a);return this.node.appendChild(b),this},h:function(a){var b=document.createElement("body");b.innerHTML=a;for(var c=h.createHtml(b);c.childNodes.length>0;)this.node.appendChild(c.childNodes[0]);return this}},h.Handler=function(a,b,c,d,e,f,g){this.handler=a,this.ns=b,this.name=c,this.type=d,this.id=e,this.options=g||{matchBare:!1},this.options.matchBare||(this.options.matchBare=!1),this.options.matchBare?this.from=f?h.getBareJidFromJid(f):null:this.from=f,this.user=!0},h.Handler.prototype={isMatch:function(a){var b,c=null;if(c=this.options.matchBare?h.getBareJidFromJid(a.getAttribute("from")):a.getAttribute("from"),b=!1,this.ns){var d=this;h.forEachChild(a,null,function(a){a.getAttribute("xmlns")==d.ns&&(b=!0)}),b=b||a.getAttribute("xmlns")==this.ns}else b=!0;var e=a.getAttribute("type");return!b||this.name&&!h.isTagEqual(a,this.name)||this.type&&(Array.isArray(this.type)?-1==this.type.indexOf(e):e!=this.type)||this.id&&a.getAttribute("id")!=this.id||this.from&&c!=this.from?!1:!0},run:function(a){var b=null;try{b=this.handler(a)}catch(c){throw c.sourceURL?h.fatal("error: "+this.handler+" "+c.sourceURL+":"+c.line+" - "+c.name+": "+c.message):c.fileName?("undefined"!=typeof console&&(console.trace(),console.error(this.handler," - error - ",c,c.message)),h.fatal("error: "+this.handler+" "+c.fileName+":"+c.lineNumber+" - "+c.name+": "+c.message)):h.fatal("error: "+c.message+"\n"+c.stack),c}return b},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},h.TimedHandler=function(a,b){this.period=a,this.handler=b,this.lastCalled=(new Date).getTime(),this.user=!0},h.TimedHandler.prototype={run:function(){return this.lastCalled=(new Date).getTime(),this.handler()},reset:function(){this.lastCalled=(new Date).getTime()},toString:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}},h.Connection=function(a,b){this.service=a,this.options=b||{};var c=this.options.protocol||"";0===a.indexOf("ws:")||0===a.indexOf("wss:")||0===c.indexOf("ws")?this._proto=new h.Websocket(this):this._proto=new h.Bosh(this),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._authentication={},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var d in h._connectionPlugins)if(h._connectionPlugins.hasOwnProperty(d)){var e=h._connectionPlugins[d],f=function(){};f.prototype=e,this[d]=new f,this[d].init(this)}},h.Connection.prototype={reset:function(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._authentication={},this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0},pause:function(){this.paused=!0},resume:function(){this.paused=!1},getUniqueId:function(a){return"string"==typeof a||"number"==typeof a?++this._uniqueId+":"+a:++this._uniqueId+""},connect:function(a,b,c,d,e,f,g){this.jid=a,this.authzid=h.getBareJidFromJid(this.jid),this.authcid=g||h.getNodeFromJid(this.jid),this.pass=b,this.servtype="xmpp",this.connect_callback=c,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=h.getDomainFromJid(this.jid),this._changeConnectStatus(h.Status.CONNECTING,null),this._proto._connect(d,e,f)},attach:function(a,b,c,d,e,f,g){if(!(this._proto instanceof h.Bosh))throw{name:"StropheSessionError",message:'The "attach" method can only be used with a BOSH connection.'};this._proto._attach(a,b,c,d,e,f,g)},restore:function(a,b,c,d,e){if(!this._sessionCachingSupported())throw{name:"StropheSessionError",message:'The "restore" method can only be used with a BOSH connection.'};this._proto._restore(a,b,c,d,e)},_sessionCachingSupported:function(){if(this._proto instanceof h.Bosh){if(!JSON)return!1;try{window.sessionStorage.setItem("_strophe_","_strophe_"),window.sessionStorage.removeItem("_strophe_")}catch(a){return!1}return!0}return!1},xmlInput:function(a){},xmlOutput:function(a){},rawInput:function(a){},rawOutput:function(a){},send:function(a){if(null!==a){if("function"==typeof a.sort)for(var b=0;b=0&&this.addHandlers.splice(b,1)},disconnect:function(a){if(this._changeConnectStatus(h.Status.DISCONNECTING,a),h.info("Disconnect was called because: "+a),this.connected){var b=!1;this.disconnecting=!0,this.authenticated&&(b=g({xmlns:h.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(b)}else h.info("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests()},_changeConnectStatus:function(a,b){for(var c in h._connectionPlugins)if(h._connectionPlugins.hasOwnProperty(c)){var d=this[c];if(d.statusChanged)try{d.statusChanged(a,b)}catch(e){h.error(""+c+" plugin caused an exception changing status: "+e)}}if(this.connect_callback)try{this.connect_callback(a,b)}catch(f){h.error("User connection callback caused an exception: "+f)}},_doDisconnect:function(a){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),h.info("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(h.Status.DISCONNECTED,a),this.connected=!1},_dataRecv:function(a,b){h.info("_dataRecv called");var c=this._proto._reqToData(a);if(null!==c){this.xmlInput!==h.Connection.prototype.xmlInput&&(c.nodeName===this._proto.strip&&c.childNodes.length?this.xmlInput(c.childNodes[0]):this.xmlInput(c)),this.rawInput!==h.Connection.prototype.rawInput&&(b?this.rawInput(b):this.rawInput(h.serialize(c)));for(var d,e;this.removeHandlers.length>0;)e=this.removeHandlers.pop(),d=this.handlers.indexOf(e),d>=0&&this.handlers.splice(d,1);for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();var f,g,i=c.getAttribute("type");if(null!==i&&"terminate"==i){if(this.disconnecting)return;return f=c.getAttribute("condition"),g=c.getElementsByTagName("conflict"),null!==f?("remote-stream-error"==f&&g.length>0&&(f="conflict"),this._changeConnectStatus(h.Status.CONNFAIL,f)):this._changeConnectStatus(h.Status.CONNFAIL,"unknown"),void this._doDisconnect(f)}var j=this;h.forEachChild(c,null,function(a){var b,c;for(c=j.handlers,j.handlers=[],b=0;b0:d.getElementsByTagName("stream:features").length>0||d.getElementsByTagName("features").length>0;var g,i,j=d.getElementsByTagName("mechanism"),k=[],l=!1;if(!f)return void this._proto._no_auth_received(b);if(j.length>0)for(g=0;g0,(l=this._authentication.legacy_auth||k.length>0)?void(this.do_authentication!==!1&&this.authenticate(k)):void this._proto._no_auth_received(b)}}},authenticate:function(a){var c;for(c=0;ca[e].prototype.priority&&(e=g);if(e!=c){var i=a[c];a[c]=a[e],a[e]=i}}var j=!1;for(c=0;c0&&(b="conflict"),this._changeConnectStatus(h.Status.AUTHFAIL,b),!1}var d,e=a.getElementsByTagName("bind");return e.length>0?(d=e[0].getElementsByTagName("jid"),void(d.length>0&&(this.jid=h.getText(d[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(f({type:"set",id:"_session_auth_2"}).c("session",{xmlns:h.NS.SESSION -}).tree())):(this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null))))):(h.info("SASL binding failed."),this._changeConnectStatus(h.Status.AUTHFAIL,null),!1)},_sasl_session_cb:function(a){if("result"==a.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null);else if("error"==a.getAttribute("type"))return h.info("Session creation failed."),this._changeConnectStatus(h.Status.AUTHFAIL,null),!1;return!1},_sasl_failure_cb:function(a){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(h.Status.AUTHFAIL,null),!1},_auth2_cb:function(a){return"result"==a.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null)):"error"==a.getAttribute("type")&&(this._changeConnectStatus(h.Status.AUTHFAIL,null),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(a,b){var c=new h.TimedHandler(a,b);return c.user=!1,this.addTimeds.push(c),c},_addSysHandler:function(a,b,c,d,e){var f=new h.Handler(a,b,c,d,e);return f.user=!1,this.addHandlers.push(f),f},_onDisconnectTimeout:function(){return h.info("_onDisconnectTimeout was called"),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1},_onIdle:function(){for(var a,b,c,d;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;)b=this.removeTimeds.pop(),a=this.timedHandlers.indexOf(b),a>=0&&this.timedHandlers.splice(a,1);var e=(new Date).getTime();for(d=[],a=0;a=c-e?b.run()&&d.push(b):d.push(b));this.timedHandlers=d,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(this._onIdle.bind(this),100))}},h.SASLMechanism=function(a,b,c){this.name=a,this.isClientFirst=b,this.priority=c},h.SASLMechanism.prototype={test:function(a){return!0},onStart:function(a){this._connection=a},onChallenge:function(a,b){throw new Error("You should implement challenge handling!")},onFailure:function(){this._connection=null},onSuccess:function(){this._connection=null}},h.SASLAnonymous=function(){},h.SASLAnonymous.prototype=new h.SASLMechanism("ANONYMOUS",!1,10),h.SASLAnonymous.test=function(a){return null===a.authcid},h.Connection.prototype.mechanisms[h.SASLAnonymous.prototype.name]=h.SASLAnonymous,h.SASLPlain=function(){},h.SASLPlain.prototype=new h.SASLMechanism("PLAIN",!0,20),h.SASLPlain.test=function(a){return null!==a.authcid},h.SASLPlain.prototype.onChallenge=function(a){var b=a.authzid;return b+="\x00",b+=a.authcid,b+="\x00",b+=a.pass},h.Connection.prototype.mechanisms[h.SASLPlain.prototype.name]=h.SASLPlain,h.SASLSHA1=function(){},h.SASLSHA1.prototype=new h.SASLMechanism("SCRAM-SHA-1",!0,40),h.SASLSHA1.test=function(a){return null!==a.authcid},h.SASLSHA1.prototype.onChallenge=function(d,e,f){var g=f||c.hexdigest(1234567890*Math.random()),h="n="+d.authcid;return h+=",r=",h+=g,d._sasl_data.cnonce=g,d._sasl_data["client-first-message-bare"]=h,h="n,,"+h,this.onChallenge=function(c,d){for(var e,f,g,h,i,j,k,l,m,n,o,p="c=biws,",q=c._sasl_data["client-first-message-bare"]+","+d+",",r=c._sasl_data.cnonce,s=/([a-z]+)=([^,]+)(,|$)/;d.match(s);){var t=d.match(s);switch(d=d.replace(t[0],""),t[1]){case"r":e=t[2];break;case"s":f=t[2];break;case"i":g=t[2]}}if(e.substr(0,r.length)!==r)return c._sasl_data={},c._sasl_failure_cb();for(p+="r="+e,q+=p,f=b.decode(f),f+="\x00\x00\x00",h=j=a.core_hmac_sha1(c.pass,f),k=1;g>k;k++){for(i=a.core_hmac_sha1(c.pass,a.binb2str(j)),l=0;5>l;l++)h[l]^=i[l];j=i}for(h=a.binb2str(h),m=a.core_hmac_sha1(h,"Client Key"),n=a.str_hmac_sha1(h,"Server Key"),o=a.core_hmac_sha1(a.str_sha1(a.binb2str(m)),q),c._sasl_data["server-signature"]=a.b64_hmac_sha1(n,q),l=0;5>l;l++)m[l]^=o[l];return p+=",p="+b.encode(a.binb2str(m))}.bind(this),h},h.Connection.prototype.mechanisms[h.SASLSHA1.prototype.name]=h.SASLSHA1,h.SASLMD5=function(){},h.SASLMD5.prototype=new h.SASLMechanism("DIGEST-MD5",!1,30),h.SASLMD5.test=function(a){return null!==a.authcid},h.SASLMD5.prototype._quote=function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},h.SASLMD5.prototype.onChallenge=function(a,b,d){for(var e,f=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,g=d||c.hexdigest(""+1234567890*Math.random()),h="",i=null,j="",k="";b.match(f);)switch(e=b.match(f),b=b.replace(e[0],""),e[2]=e[2].replace(/^"(.+)"$/,"$1"),e[1]){case"realm":h=e[2];break;case"nonce":j=e[2];break;case"qop":k=e[2];break;case"host":i=e[2]}var l=a.servtype+"/"+a.domain;null!==i&&(l=l+"/"+i);var m=c.hash(a.authcid+":"+h+":"+this._connection.pass)+":"+j+":"+g,n="AUTHENTICATE:"+l,o="";return o+="charset=utf-8,",o+="username="+this._quote(a.authcid)+",",o+="realm="+this._quote(h)+",",o+="nonce="+this._quote(j)+",",o+="nc=00000001,",o+="cnonce="+this._quote(g)+",",o+="digest-uri="+this._quote(l)+",",o+="response="+c.hexdigest(c.hexdigest(m)+":"+j+":00000001:"+g+":auth:"+c.hexdigest(n))+",",o+="qop=auth",this.onChallenge=function(){return""}.bind(this),o},h.Connection.prototype.mechanisms[h.SASLMD5.prototype.name]=h.SASLMD5,{Strophe:h,$build:d,$msg:e,$iq:f,$pres:g,SHA1:a,Base64:b,MD5:c}}),function(b,c){return"function"==typeof a&&a.amd?void a("strophe-bosh",["strophe-core"],function(a){return c(a.Strophe,a.$build)}):c(Strophe,$build)}(this,function(a,b){return a.Request=function(b,c,d,e){this.id=++a._requestId,this.xmlData=b,this.data=a.serialize(b),this.origFunc=c,this.func=c,this.rid=d,this.date=NaN,this.sends=e||0,this.abort=!1,this.dead=null,this.age=function(){if(!this.date)return 0;var a=new Date;return(a-this.date)/1e3},this.timeDead=function(){if(!this.dead)return 0;var a=new Date;return(a-this.dead)/1e3},this.xhr=this._newXHR()},a.Request.prototype={getResponse:function(){var b=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(b=this.xhr.responseXML.documentElement,"parsererror"==b.tagName)throw a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)),"parsererror"}else this.xhr.responseText&&(a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)));return b},_newXHR:function(){var a=null;return window.XMLHttpRequest?(a=new XMLHttpRequest,a.overrideMimeType&&a.overrideMimeType("text/xml; charset=utf-8")):window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP")),a.onreadystatechange=this.func.bind(null,this),a}},a.Bosh=function(a){this._conn=a,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this._requests=[]},a.Bosh.prototype={strip:null,_buildBody:function(){var c=b("body",{rid:this.rid++,xmlns:a.NS.HTTPBIND});return null!==this.sid&&c.attrs({sid:this.sid}),this._conn.options.keepalive&&this._cacheSession(),c},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,window.sessionStorage.removeItem("strophe-bosh-session")},_connect:function(b,c,d){this.wait=b||this.wait,this.hold=c||this.hold,this.errors=0;var e=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":a.NS.BOSH});d&&e.attrs({route:d});var f=this._conn._connect_cb;this._requests.push(new a.Request(e.tree(),this._onRequestStateChange.bind(this,f.bind(this._conn)),e.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(b,c,d,e,f,g,h){this._conn.jid=b,this.sid=c,this.rid=d,this._conn.connect_callback=e,this._conn.domain=a.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=f||this.wait,this.hold=g||this.hold,this.window=h||this.window,this._conn._changeConnectStatus(a.Status.ATTACHED,null)},_restore:function(b,c,d,e,f){var g=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!("undefined"!=typeof g&&null!==g&&g.rid&&g.sid&&g.jid)||"undefined"!=typeof b&&a.getBareJidFromJid(g.jid)!=a.getBareJidFromJid(b))throw{name:"StropheSessionError",message:"_restore: no restoreable session."};this._conn.restored=!0,this._attach(g.jid,g.sid,g.rid,c,d,e,f)},_cacheSession:function(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&window.sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):window.sessionStorage.removeItem("strophe-bosh-session")},_connect_cb:function(b){var c,d,e=b.getAttribute("type");if(null!==e&&"terminate"==e)return c=b.getAttribute("condition"),a.error("BOSH-Connection failed: "+c),d=b.getElementsByTagName("conflict"),null!==c?("remote-stream-error"==c&&d.length>0&&(c="conflict"),this._conn._changeConnectStatus(a.Status.CONNFAIL,c)):this._conn._changeConnectStatus(a.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(c),a.Status.CONNFAIL;this.sid||(this.sid=b.getAttribute("sid"));var f=b.getAttribute("requests");f&&(this.window=parseInt(f,10));var g=b.getAttribute("hold");g&&(this.hold=parseInt(g,10));var h=b.getAttribute("wait");h&&(this.wait=parseInt(h,10))},_disconnect:function(a){this._sendTerminate(a)},_doDisconnect:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),window.sessionStorage.removeItem("strophe-bosh-session")},_emptyQueue:function(){return 0===this._requests.length},_hitError:function(b){this.errors++,a.warn("request errored, status: "+b+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()},_no_auth_received:function(b){b=b?b.bind(this._conn):this._conn._connect_cb.bind(this._conn);var c=this._buildBody();this._requests.push(new a.Request(c.tree(),this._onRequestStateChange.bind(this,b.bind(this._conn)),c.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout:function(){this._abortAllRequests()},_abortAllRequests:function(){for(var a;this._requests.length>0;)a=this._requests.pop(),a.abort=!0,a.xhr.abort(),a.xhr.onreadystatechange=function(){}},_onIdle:function(){var b=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===b.length&&!this._conn.disconnecting&&(a.info("no requests during idle cycle, sending blank request"),b.push(null)),!this._conn.paused){if(this._requests.length<2&&b.length>0){for(var c=this._buildBody(),d=0;d0){var e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(a.TIMEOUT*this.wait)&&(a.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(a.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_onRequestStateChange:function(b,c){if(a.debug("request id "+c.id+"."+c.sends+" state changed to "+c.xhr.readyState),c.abort)return void(c.abort=!1);var d;if(4==c.xhr.readyState){d=0;try{d=c.xhr.status}catch(e){}if("undefined"==typeof d&&(d=0),this.disconnecting&&d>=400)return void this._hitError(d);var f=this._requests[0]==c,g=this._requests[1]==c;(d>0&&500>d||c.sends>5)&&(this._removeRequest(c),a.debug("request id "+c.id+" should now be removed")),200==d?((g||f&&this._requests.length>0&&this._requests[0].age()>Math.floor(a.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),a.debug("request id "+c.id+"."+c.sends+" got 200"),b(c),this.errors=0):(a.error("request id "+c.id+"."+c.sends+" error "+d+" happened"),(0===d||d>=400&&600>d||d>=12e3)&&(this._hitError(d),d>=400&&500>d&&(this._conn._changeConnectStatus(a.Status.DISCONNECTING,null),this._conn._doDisconnect()))),d>0&&500>d||c.sends>5||this._throttledRequestHandler()}},_processRequest:function(b){var c=this,d=this._requests[b],e=-1;try{4==d.xhr.readyState&&(e=d.xhr.status)}catch(f){a.error("caught an error in _requests["+b+"], reqStatus: "+e)}if("undefined"==typeof e&&(e=-1),d.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();var g=d.age(),h=!isNaN(g)&&g>Math.floor(a.TIMEOUT*this.wait),i=null!==d.dead&&d.timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait),j=4==d.xhr.readyState&&(1>e||e>=500);if((h||i||j)&&(i&&a.error("Request "+this._requests[b].id+" timed out (secondary), restarting"),d.abort=!0,d.xhr.abort(),d.xhr.onreadystatechange=function(){},this._requests[b]=new a.Request(d.xmlData,d.origFunc,d.rid,d.sends),d=this._requests[b]),0===d.xhr.readyState){a.debug("request id "+d.id+"."+d.sends+" posting");try{d.xhr.open("POST",this._conn.service,this._conn.options.sync?!1:!0),d.xhr.setRequestHeader("Content-Type","text/xml; charset=utf-8")}catch(k){return a.error("XHR open failed."),this._conn.connected||this._conn._changeConnectStatus(a.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var l=function(){if(d.date=new Date,c._conn.options.customHeaders){var a=c._conn.options.customHeaders;for(var b in a)a.hasOwnProperty(b)&&d.xhr.setRequestHeader(b,a[b])}d.xhr.send(d.data)};if(d.sends>1){var m=1e3*Math.min(Math.floor(a.TIMEOUT*this.wait),Math.pow(d.sends,3));setTimeout(l,m)}else l();d.sends++,this._conn.xmlOutput!==a.Connection.prototype.xmlOutput&&(d.xmlData.nodeName===this.strip&&d.xmlData.childNodes.length?this._conn.xmlOutput(d.xmlData.childNodes[0]):this._conn.xmlOutput(d.xmlData)),this._conn.rawOutput!==a.Connection.prototype.rawOutput&&this._conn.rawOutput(d.data)}else a.debug("_processRequest: "+(0===b?"first":"second")+" request has readyState of "+d.xhr.readyState)},_removeRequest:function(b){a.debug("removing request");var c;for(c=this._requests.length-1;c>=0;c--)b==this._requests[c]&&this._requests.splice(c,1);b.xhr.onreadystatechange=function(){},this._throttledRequestHandler()},_restartRequest:function(a){var b=this._requests[a];null===b.dead&&(b.dead=new Date),this._processRequest(a)},_reqToData:function(a){try{return a.getResponse()}catch(b){if("parsererror"!=b)throw b;this._conn.disconnect("strophe-parsererror")}},_sendTerminate:function(b){a.info("_sendTerminate was called");var c=this._buildBody().attrs({type:"terminate"});b&&c.cnode(b.tree());var d=new a.Request(c.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),c.tree().getAttribute("rid"));this._requests.push(d),this._throttledRequestHandler()},_send:function(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(this._conn._onIdle.bind(this._conn),100)},_sendRestart:function(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)},_throttledRequestHandler:function(){this._requests?a.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):a.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid): "+d);var e=b.getAttribute("version");return"string"!=typeof e?c="Missing version in ":"1.0"!==e&&(c="Wrong version in : "+e),c?(this._conn._changeConnectStatus(a.Status.CONNFAIL,c),this._conn._doDisconnect(),!1):!0},_connect_cb_wrapper:function(b){if(0===b.data.indexOf("\s*)*/,"");if(""===c)return;var d=(new DOMParser).parseFromString(c,"text/xml").documentElement;this._conn.xmlInput(d),this._conn.rawInput(b.data),this._handleStreamStart(d)&&this._connect_cb(d)}else if(0===b.data.indexOf(" tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){a.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(a){return""+a+""},_closeSocket:function(){if(this.socket)try{this.socket.close()}catch(a){}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(){this._conn.connected&&!this._conn.disconnecting?(a.error("Websocket closed unexcectedly"),this._conn._doDisconnect()):a.info("Websocket closed")},_no_auth_received:function(b){a.error("Server did not send any auth methods"),this._conn._changeConnectStatus(a.Status.CONNFAIL,"Server did not send any auth methods"),b&&(b=b.bind(this._conn))(),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(b){a.error("Websocket error "+b),this._conn._changeConnectStatus(a.Status.CONNFAIL,"The WebSocket connection could not be established was disconnected."),this._disconnect()},_onIdle:function(){var b=this._conn._data;if(b.length>0&&!this._conn.paused){for(var c=0;cc;c++)e=a[c],b=e(b);return b},j=function(a){return a.indexOf("&")>=0||a.indexOf(">")>=0||a.indexOf("<")>=0},m=function(a){return""},e=function(a){return a.replace("]]>","]]]]>")},c.processors=i,c.defaults={.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:"\n"},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}},c.ValidationError=function(a){function b(a){this.message=a}return n(b,a),b}(Error),c.Builder=function(){function a(a){var b,d,e;this.options={},d=c.defaults[.2];for(b in d)o.call(d,b)&&(e=d[b],this.options[b]=e);for(b in a)o.call(a,b)&&(e=a[b],this.options[b]=e)}return a.prototype.buildObject=function(a){var b,e,f,g,h;return b=this.options.attrkey,e=this.options.charkey,1===Object.keys(a).length&&this.options.rootName===c.defaults[.2].rootName?(h=Object.keys(a)[0],a=a[h]):h=this.options.rootName,f=function(a){return function(c,d){var g,h,i,k,l,n;if("object"!=typeof d)a.options.cdata&&j(d)?c.raw(m(d)):c.txt(d);else for(l in d)if(o.call(d,l))if(h=d[l],l===b){if("object"==typeof h)for(g in h)n=h[g],c=c.att(g,n)}else if(l===e)c=a.options.cdata&&j(h)?c.raw(m(h)):c.txt(h);else if(Array.isArray(h))for(k in h)o.call(h,k)&&(i=h[k],c="string"==typeof i?a.options.cdata&&j(i)?c.ele(l).raw(m(i)).up():c.ele(l,i).up():f(c.ele(l),i).up());else"object"==typeof h?c=f(c.ele(l),h).up():"string"==typeof h&&a.options.cdata&&j(h)?c=c.ele(l).raw(m(h)).up():(null==h&&(h=""),c=c.ele(l,h.toString()).up());return c}}(this),g=d.create(h,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),f(g,a).end(this.options.renderOpts)},a}(),c.Parser=function(a){function d(a){this.parseString=p(this.parseString,this),this.reset=p(this.reset,this),this.assignOrPush=p(this.assignOrPush,this),this.processAsync=p(this.processAsync,this);var b,d,e;if(!(this instanceof c.Parser))return new c.Parser(a);this.options={},d=c.defaults[.2];for(b in d)o.call(d,b)&&(e=d[b],this.options[b]=e);for(b in a)o.call(a,b)&&(e=a[b],this.options[b]=e);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(i.normalize)),this.reset()}return n(d,a),d.prototype.processAsync=function(){var a,b,c;try{return this.remaining.length<=this.options.chunkSize?(a=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(a),this.saxParser.close()):(a=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(a),l(this.processAsync))}catch(c){if(b=c,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(b)}},d.prototype.assignOrPush=function(a,b,c){return b in a?(a[b]instanceof Array||(a[b]=[a[b]]),a[b].push(c)):this.options.explicitArray?a[b]=[c]:a[b]=c},d.prototype.reset=function(){var a,b,c,d;return this.removeAllListeners(),this.saxParser=k.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(a){return function(b){return a.saxParser.resume(),a.saxParser.errThrown?void 0:(a.saxParser.errThrown=!0,a.emit("error",b))}}(this),this.saxParser.onend=function(a){return function(){return a.saxParser.ended?void 0:(a.saxParser.ended=!0,a.emit("end",a.resultObject))}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,d=[],a=this.options.attrkey,b=this.options.charkey,this.saxParser.onopentag=function(c){return function(e){var f,g,i,j,k;if(i={},i[b]="",!c.options.ignoreAttrs){k=e.attributes;for(f in k)o.call(k,f)&&(a in i||c.options.mergeAttrs||(i[a]={}),g=c.options.attrValueProcessors?h(c.options.attrValueProcessors,e.attributes[f]):e.attributes[f],j=c.options.attrNameProcessors?h(c.options.attrNameProcessors,f):f,c.options.mergeAttrs?c.assignOrPush(i,j,g):i[a][j]=g)}return i["#name"]=c.options.tagNameProcessors?h(c.options.tagNameProcessors,e.name):e.name,c.options.xmlns&&(i[c.options.xmlnskey]={uri:e.uri,local:e.local}),d.push(i)}}(this),this.saxParser.onclosetag=function(a){return function(){var c,e,f,i,j,k,l,m,n,p,q,r;if(m=d.pop(),l=m["#name"],a.options.explicitChildren&&a.options.preserveChildrenOrder||delete m["#name"],m.cdata===!0&&(c=m.cdata,delete m.cdata),q=d[d.length-1],m[b].match(/^\s*$/)&&!c?(e=m[b],delete m[b]):(a.options.trim&&(m[b]=m[b].trim()),a.options.normalize&&(m[b]=m[b].replace(/\s{2,}/g," ").trim()),m[b]=a.options.valueProcessors?h(a.options.valueProcessors,m[b]):m[b],1===Object.keys(m).length&&b in m&&!a.EXPLICIT_CHARKEY&&(m=m[b])),g(m)&&(m=""!==a.options.emptyTag?a.options.emptyTag:e),null!=a.options.validator){r="/"+function(){var a,b,c;for(c=[],a=0,b=d.length;b>a;a++)k=d[a],c.push(k["#name"]);return c}().concat(l).join("/");try{m=a.options.validator(r,q&&q[l],m)}catch(i){f=i,a.emit("error",f)}}if(a.options.explicitChildren&&!a.options.mergeAttrs&&"object"==typeof m)if(a.options.preserveChildrenOrder){if(q){q[a.options.childkey]=q[a.options.childkey]||[],n={};for(j in m)o.call(m,j)&&(n[j]=m[j]);q[a.options.childkey].push(n),delete m["#name"],1===Object.keys(m).length&&b in m&&!a.EXPLICIT_CHARKEY&&(m=m[b])}}else k={},a.options.attrkey in m&&(k[a.options.attrkey]=m[a.options.attrkey],delete m[a.options.attrkey]),!a.options.charsAsChildren&&a.options.charkey in m&&(k[a.options.charkey]=m[a.options.charkey],delete m[a.options.charkey]),Object.getOwnPropertyNames(m).length>0&&(k[a.options.childkey]=m),m=k;return d.length>0?a.assignOrPush(q,l,m):(a.options.explicitRoot&&(p=m,m={},m[l]=p),a.resultObject=m,a.saxParser.ended=!0,a.emit("end",a.resultObject))}}(this),c=function(a){return function(c){var e,f;return f=d[d.length-1],f?(f[b]+=c,a.options.explicitChildren&&a.options.preserveChildrenOrder&&a.options.charsAsChildren&&""!==c.replace(/\\n/g,"").trim()&&(f[a.options.childkey]=f[a.options.childkey]||[],e={"#name":"__text__"},e[b]=c,f[a.options.childkey].push(e)),f):void 0}}(this),this.saxParser.ontext=c,this.saxParser.oncdata=function(a){return function(a){var b;return b=c(a),b?b.cdata=!0:void 0}}(this)},d.prototype.parseString=function(a,c){var d,e;null!=c&&"function"==typeof c&&(this.on("end",function(a){return this.reset(),c(null,a)}),this.on("error",function(a){return this.reset(),c(a)}));try{return a=a.toString(),""===a.trim()?(this.emit("end",null),!0):(a=b.stripBOM(a),this.options.async?(this.remaining=a,l(this.processAsync),this.saxParser):this.saxParser.write(a).close())}catch(e){if(d=e,!this.saxParser.errThrown&&!this.saxParser.ended)return this.emit("error",d),this.saxParser.errThrown=!0;if(this.saxParser.ended)throw d}},d}(f.EventEmitter),c.parseString=function(a,b,d){var e,f,g;return null!=d?("function"==typeof d&&(e=d),"object"==typeof b&&(f=b)):("function"==typeof b&&(e=b),f={}),g=new c.Parser(f),g.parseString(a,e)}}).call(this)},{"./bom":52,"./processors":53,events:30,sax:55,timers:48,xmlbuilder:72}],55:[function(a,b,c){(function(b){!function(c){function d(a,b){if(!(this instanceof d))return new d(a,b);var e=this;f(e),e.q=e.c="",e.bufferCheckPosition=c.MAX_BUFFER_LENGTH,e.opt=b||{},e.opt.lowercase=e.opt.lowercase||e.opt.lowercasetags,e.looseCase=e.opt.lowercase?"toLowerCase":"toUpperCase",e.tags=[],e.closed=e.closedRoot=e.sawRoot=!1,e.tag=e.error=null,e.strict=!!a,e.noscript=!(!a&&!e.opt.noscript),e.state=U.BEGIN,e.strictEntities=e.opt.strictEntities,e.ENTITIES=e.strictEntities?Object.create(c.XML_ENTITIES):Object.create(c.ENTITIES),e.attribList=[],e.opt.xmlns&&(e.ns=Object.create(P)),e.trackPosition=e.opt.position!==!1,e.trackPosition&&(e.position=e.line=e.column=0),n(e,"onready")}function e(a){for(var b=Math.max(c.MAX_BUFFER_LENGTH,10),d=0,e=0,f=C.length;f>e;e++){var g=a[C[e]].length;if(g>b)switch(C[e]){case"textNode":p(a);break;case"cdata":o(a,"oncdata",a.cdata),a.cdata="";break;case"script":o(a,"onscript",a.script),a.script="";break;default:r(a,"Max buffer length exceeded: "+C[e])}d=Math.max(d,g)}var h=c.MAX_BUFFER_LENGTH-d;a.bufferCheckPosition=h+a.position}function f(a){for(var b=0,c=C.length;c>b;b++)a[C[b]]=""}function g(a){p(a),""!==a.cdata&&(o(a,"oncdata",a.cdata),a.cdata=""),""!==a.script&&(o(a,"onscript",a.script),a.script="")}function h(a,b){return new i(a,b)}function i(a,b){if(!(this instanceof i))return new i(a,b);D.apply(this),this._parser=new d(a,b),this.writable=!0,this.readable=!0;var c=this;this._parser.onend=function(){c.emit("end")},this._parser.onerror=function(a){c.emit("error",a),c._parser.error=null},this._decoder=null,F.forEach(function(a){Object.defineProperty(c,"on"+a,{get:function(){return c._parser["on"+a]},set:function(b){return b?void c.on(a,b):(c.removeAllListeners(a),c._parser["on"+a]=b,b)},enumerable:!0,configurable:!1})})}function j(a){return a.split("").reduce(function(a,b){return a[b]=!0,a},{})}function k(a){return"[object RegExp]"===Object.prototype.toString.call(a); -}function l(a,b){return k(a)?!!b.match(a):a[b]}function m(a,b){return!l(a,b)}function n(a,b,c){a[b]&&a[b](c)}function o(a,b,c){a.textNode&&p(a),n(a,b,c)}function p(a){a.textNode=q(a.opt,a.textNode),a.textNode&&n(a,"ontext",a.textNode),a.textNode=""}function q(a,b){return a.trim&&(b=b.trim()),a.normalize&&(b=b.replace(/\s+/g," ")),b}function r(a,b){return p(a),a.trackPosition&&(b+="\nLine: "+a.line+"\nColumn: "+a.column+"\nChar: "+a.c),b=new Error(b),a.error=b,n(a,"onerror",b),a}function s(a){return a.sawRoot&&!a.closedRoot&&t(a,"Unclosed root tag"),a.state!==U.BEGIN&&a.state!==U.BEGIN_WHITESPACE&&a.state!==U.TEXT&&r(a,"Unexpected end"),p(a),a.c="",a.closed=!0,n(a,"onend"),d.call(a,a.strict,a.opt),a}function t(a,b){if("object"!=typeof a||!(a instanceof d))throw new Error("bad call to strictFail");a.strict&&r(a,b)}function u(a){a.strict||(a.tagName=a.tagName[a.looseCase]());var b=a.tags[a.tags.length-1]||a,c=a.tag={name:a.tagName,attributes:{}};a.opt.xmlns&&(c.ns=b.ns),a.attribList.length=0}function v(a,b){var c=a.indexOf(":"),d=0>c?["",a]:a.split(":"),e=d[0],f=d[1];return b&&"xmlns"===a&&(e="xmlns",f=""),{prefix:e,local:f}}function w(a){if(a.strict||(a.attribName=a.attribName[a.looseCase]()),-1!==a.attribList.indexOf(a.attribName)||a.tag.attributes.hasOwnProperty(a.attribName))return void(a.attribName=a.attribValue="");if(a.opt.xmlns){var b=v(a.attribName,!0),c=b.prefix,d=b.local;if("xmlns"===c)if("xml"===d&&a.attribValue!==N)t(a,"xml: prefix must be bound to "+N+"\nActual: "+a.attribValue);else if("xmlns"===d&&a.attribValue!==O)t(a,"xmlns: prefix must be bound to "+O+"\nActual: "+a.attribValue);else{var e=a.tag,f=a.tags[a.tags.length-1]||a;e.ns===f.ns&&(e.ns=Object.create(f.ns)),e.ns[d]=a.attribValue}a.attribList.push([a.attribName,a.attribValue])}else a.tag.attributes[a.attribName]=a.attribValue,o(a,"onattribute",{name:a.attribName,value:a.attribValue});a.attribName=a.attribValue=""}function x(a,b){if(a.opt.xmlns){var c=a.tag,d=v(a.tagName);c.prefix=d.prefix,c.local=d.local,c.uri=c.ns[d.prefix]||"",c.prefix&&!c.uri&&(t(a,"Unbound namespace prefix: "+JSON.stringify(a.tagName)),c.uri=d.prefix);var e=a.tags[a.tags.length-1]||a;c.ns&&e.ns!==c.ns&&Object.keys(c.ns).forEach(function(b){o(a,"onopennamespace",{prefix:b,uri:c.ns[b]})});for(var f=0,g=a.attribList.length;g>f;f++){var h=a.attribList[f],i=h[0],j=h[1],k=v(i,!0),l=k.prefix,m=k.local,n=""===l?"":c.ns[l]||"",p={name:i,value:j,prefix:l,local:m,uri:n};l&&"xmlns"!==l&&!n&&(t(a,"Unbound namespace prefix: "+JSON.stringify(l)),p.uri=l),a.tag.attributes[i]=p,o(a,"onattribute",p)}a.attribList.length=0}a.tag.isSelfClosing=!!b,a.sawRoot=!0,a.tags.push(a.tag),o(a,"onopentag",a.tag),b||(a.noscript||"script"!==a.tagName.toLowerCase()?a.state=U.TEXT:a.state=U.SCRIPT,a.tag=null,a.tagName=""),a.attribName=a.attribValue="",a.attribList.length=0}function y(a){if(!a.tagName)return t(a,"Weird empty close tag."),a.textNode+="",void(a.state=U.TEXT);if(a.script){if("script"!==a.tagName)return a.script+="",a.tagName="",void(a.state=U.SCRIPT);o(a,"onscript",a.script),a.script=""}var b=a.tags.length,c=a.tagName;a.strict||(c=c[a.looseCase]());for(var d=c;b--;){var e=a.tags[b];if(e.name===d)break;t(a,"Unexpected close tag")}if(0>b)return t(a,"Unmatched closing tag: "+a.tagName),a.textNode+="",void(a.state=U.TEXT);a.tagName=c;for(var f=a.tags.length;f-- >b;){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,o(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];o(a,"onclosenamespace",{prefix:b,uri:c})})}0===b&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=U.TEXT}function z(a){var b,c=a.entity,d=c.toLowerCase(),e="";return a.ENTITIES[c]?a.ENTITIES[c]:a.ENTITIES[d]?a.ENTITIES[d]:(c=d,"#"===c.charAt(0)&&("x"===c.charAt(1)?(c=c.slice(2),b=parseInt(c,16),e=b.toString(16)):(c=c.slice(1),b=parseInt(c,10),e=b.toString(10))),c=c.replace(/^0+/,""),e.toLowerCase()!==c?(t(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCodePoint(b))}function A(a,b){"<"===b?(a.state=U.OPEN_WAKA,a.startTagPosition=a.position):m(G,b)&&(t(a,"Non-whitespace before first tag."),a.textNode=b,a.state=U.TEXT)}function B(a){var b=this;if(this.error)throw this.error;if(b.closed)return r(b,"Cannot write after close. Assign an onready handler.");if(null===a)return s(b);for(var c=0,d="";;){if(d=a.charAt(c++),b.c=d,!d)break;switch(b.trackPosition&&(b.position++,"\n"===d?(b.line++,b.column=0):b.column++),b.state){case U.BEGIN:if(b.state=U.BEGIN_WHITESPACE,"\ufeff"===d)continue;A(b,d);continue;case U.BEGIN_WHITESPACE:A(b,d);continue;case U.TEXT:if(b.sawRoot&&!b.closedRoot){for(var f=c-1;d&&"<"!==d&&"&"!==d;)d=a.charAt(c++),d&&b.trackPosition&&(b.position++,"\n"===d?(b.line++,b.column=0):b.column++);b.textNode+=a.substring(f,c-1)}"<"!==d||b.sawRoot&&b.closedRoot&&!b.strict?(!m(G,d)||b.sawRoot&&!b.closedRoot||t(b,"Text data outside of root node."),"&"===d?b.state=U.TEXT_ENTITY:b.textNode+=d):(b.state=U.OPEN_WAKA,b.startTagPosition=b.position);continue;case U.SCRIPT:"<"===d?b.state=U.SCRIPT_ENDING:b.script+=d;continue;case U.SCRIPT_ENDING:"/"===d?b.state=U.CLOSE_TAG:(b.script+="<"+d,b.state=U.SCRIPT);continue;case U.OPEN_WAKA:if("!"===d)b.state=U.SGML_DECL,b.sgmlDecl="";else if(l(G,d));else if(l(Q,d))b.state=U.OPEN_TAG,b.tagName=d;else if("/"===d)b.state=U.CLOSE_TAG,b.tagName="";else if("?"===d)b.state=U.PROC_INST,b.procInstName=b.procInstBody="";else{if(t(b,"Unencoded <"),b.startTagPosition+1"===d?(o(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=U.TEXT):l(J,d)?(b.state=U.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case U.SGML_DECL_QUOTED:d===b.q&&(b.state=U.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case U.DOCTYPE:">"===d?(b.state=U.TEXT,o(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,"["===d?b.state=U.DOCTYPE_DTD:l(J,d)&&(b.state=U.DOCTYPE_QUOTED,b.q=d));continue;case U.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=U.DOCTYPE);continue;case U.DOCTYPE_DTD:b.doctype+=d,"]"===d?b.state=U.DOCTYPE:l(J,d)&&(b.state=U.DOCTYPE_DTD_QUOTED,b.q=d);continue;case U.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=U.DOCTYPE_DTD,b.q="");continue;case U.COMMENT:"-"===d?b.state=U.COMMENT_ENDING:b.comment+=d;continue;case U.COMMENT_ENDING:"-"===d?(b.state=U.COMMENT_ENDED,b.comment=q(b.opt,b.comment),b.comment&&o(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=U.COMMENT);continue;case U.COMMENT_ENDED:">"!==d?(t(b,"Malformed comment"),b.comment+="--"+d,b.state=U.COMMENT):b.state=U.TEXT;continue;case U.CDATA:"]"===d?b.state=U.CDATA_ENDING:b.cdata+=d;continue;case U.CDATA_ENDING:"]"===d?b.state=U.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=U.CDATA);continue;case U.CDATA_ENDING_2:">"===d?(b.cdata&&o(b,"oncdata",b.cdata),o(b,"onclosecdata"),b.cdata="",b.state=U.TEXT):"]"===d?b.cdata+="]":(b.cdata+="]]"+d,b.state=U.CDATA);continue;case U.PROC_INST:"?"===d?b.state=U.PROC_INST_ENDING:l(G,d)?b.state=U.PROC_INST_BODY:b.procInstName+=d;continue;case U.PROC_INST_BODY:if(!b.procInstBody&&l(G,d))continue;"?"===d?b.state=U.PROC_INST_ENDING:b.procInstBody+=d;continue;case U.PROC_INST_ENDING:">"===d?(o(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=U.TEXT):(b.procInstBody+="?"+d,b.state=U.PROC_INST_BODY);continue;case U.OPEN_TAG:l(R,d)?b.tagName+=d:(u(b),">"===d?x(b):"/"===d?b.state=U.OPEN_TAG_SLASH:(m(G,d)&&t(b,"Invalid character in tag name"),b.state=U.ATTRIB));continue;case U.OPEN_TAG_SLASH:">"===d?(x(b,!0),y(b)):(t(b,"Forward-slash in opening tag not followed by >"),b.state=U.ATTRIB);continue;case U.ATTRIB:if(l(G,d))continue;">"===d?x(b):"/"===d?b.state=U.OPEN_TAG_SLASH:l(Q,d)?(b.attribName=d,b.attribValue="",b.state=U.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case U.ATTRIB_NAME:"="===d?b.state=U.ATTRIB_VALUE:">"===d?(t(b,"Attribute without value"),b.attribValue=b.attribName,w(b),x(b)):l(G,d)?b.state=U.ATTRIB_NAME_SAW_WHITE:l(R,d)?b.attribName+=d:t(b,"Invalid attribute name");continue;case U.ATTRIB_NAME_SAW_WHITE:if("="===d)b.state=U.ATTRIB_VALUE;else{if(l(G,d))continue;t(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",o(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",">"===d?x(b):l(Q,d)?(b.attribName=d,b.state=U.ATTRIB_NAME):(t(b,"Invalid attribute name"),b.state=U.ATTRIB)}continue;case U.ATTRIB_VALUE:if(l(G,d))continue;l(J,d)?(b.q=d,b.state=U.ATTRIB_VALUE_QUOTED):(t(b,"Unquoted attribute value"),b.state=U.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case U.ATTRIB_VALUE_QUOTED:if(d!==b.q){"&"===d?b.state=U.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}w(b),b.q="",b.state=U.ATTRIB_VALUE_CLOSED;continue;case U.ATTRIB_VALUE_CLOSED:l(G,d)?b.state=U.ATTRIB:">"===d?x(b):"/"===d?b.state=U.OPEN_TAG_SLASH:l(Q,d)?(t(b,"No whitespace between attributes"),b.attribName=d,b.attribValue="",b.state=U.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case U.ATTRIB_VALUE_UNQUOTED:if(m(K,d)){"&"===d?b.state=U.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}w(b),">"===d?x(b):b.state=U.ATTRIB;continue;case U.CLOSE_TAG:if(b.tagName)">"===d?y(b):l(R,d)?b.tagName+=d:b.script?(b.script+=""===d?y(b):t(b,"Invalid characters in closing tag");continue;case U.TEXT_ENTITY:case U.ATTRIB_VALUE_ENTITY_Q:case U.ATTRIB_VALUE_ENTITY_U:var h,i;switch(b.state){case U.TEXT_ENTITY:h=U.TEXT,i="textNode";break;case U.ATTRIB_VALUE_ENTITY_Q:h=U.ATTRIB_VALUE_QUOTED,i="attribValue";break;case U.ATTRIB_VALUE_ENTITY_U:h=U.ATTRIB_VALUE_UNQUOTED,i="attribValue"}";"===d?(b[i]+=z(b),b.entity="",b.state=h):l(b.entity.length?T:S,d)?b.entity+=d:(t(b,"Invalid character in entity name"),b[i]+="&"+b.entity+d,b.entity="",b.state=h);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}c.parser=function(a,b){return new d(a,b)},c.SAXParser=d,c.SAXStream=i,c.createStream=h,c.MAX_BUFFER_LENGTH=65536;var C=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];c.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){}b.prototype=a;var c=new b;return c}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){s(this)},write:B,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){g(this)}};var D;try{D=a("stream").Stream}catch(E){D=function(){}}var F=c.EVENTS.filter(function(a){return"error"!==a&&"end"!==a});i.prototype=Object.create(D.prototype,{constructor:{value:i}}),i.prototype.write=function(c){if("function"==typeof b&&"function"==typeof b.isBuffer&&b.isBuffer(c)){if(!this._decoder){var d=a("string_decoder").StringDecoder;this._decoder=new d("utf8")}c=this._decoder.write(c)}return this._parser.write(c.toString()),this.emit("data",c),!0},i.prototype.end=function(a){return a&&a.length&&this.write(a),this._parser.end(),!0},i.prototype.on=function(a,b){var c=this;return c._parser["on"+a]||-1===F.indexOf(a)||(c._parser["on"+a]=function(){var b=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),D.prototype.on.call(c,a,b)};var G="\r\n ",H="0124356789",I="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",J="'\"",K=G+">",L="[CDATA[",M="DOCTYPE",N="http://www.w3.org/XML/1998/namespace",O="http://www.w3.org/2000/xmlns/",P={xml:N,xmlns:O};G=j(G),H=j(H),I=j(I);var Q=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,R=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/,S=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,T=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/;J=j(J),K=j(K);var U=0;c.STATE={BEGIN:U++,BEGIN_WHITESPACE:U++,TEXT:U++,TEXT_ENTITY:U++,OPEN_WAKA:U++,SGML_DECL:U++,SGML_DECL_QUOTED:U++,DOCTYPE:U++,DOCTYPE_QUOTED:U++,DOCTYPE_DTD:U++,DOCTYPE_DTD_QUOTED:U++,COMMENT_STARTING:U++,COMMENT:U++,COMMENT_ENDING:U++,COMMENT_ENDED:U++,CDATA:U++,CDATA_ENDING:U++,CDATA_ENDING_2:U++,PROC_INST:U++,PROC_INST_BODY:U++,PROC_INST_ENDING:U++,OPEN_TAG:U++,OPEN_TAG_SLASH:U++,ATTRIB:U++,ATTRIB_NAME:U++,ATTRIB_NAME_SAW_WHITE:U++,ATTRIB_VALUE:U++,ATTRIB_VALUE_QUOTED:U++,ATTRIB_VALUE_CLOSED:U++,ATTRIB_VALUE_UNQUOTED:U++,ATTRIB_VALUE_ENTITY_Q:U++,ATTRIB_VALUE_ENTITY_U:U++,CLOSE_TAG:U++,CLOSE_TAG_SAW_WHITE:U++,SCRIPT:U++,SCRIPT_ENDING:U++},c.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},c.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(c.ENTITIES).forEach(function(a){var b=c.ENTITIES[a],d="number"==typeof b?String.fromCharCode(b):b;c.ENTITIES[a]=d});for(var V in c.STATE)c.STATE[c.STATE[V]]=V;U=c.STATE,String.fromCodePoint||!function(){var a=String.fromCharCode,b=Math.floor,c=function(){var c,d,e=16384,f=[],g=-1,h=arguments.length;if(!h)return"";for(var i="";++gj||j>1114111||b(j)!==j)throw RangeError("Invalid code point: "+j);65535>=j?f.push(j):(j-=65536,c=(j>>10)+55296,d=j%1024+56320,f.push(c,d)),(g+1===h||f.length>e)&&(i+=a.apply(null,f),f.length=0)}return i};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:c,configurable:!0,writable:!0}):String.fromCodePoint=c}()}("undefined"==typeof c?this.sax={}:c)}).call(this,a("buffer").Buffer)},{buffer:26,stream:46,string_decoder:47}],56:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing attribute name of element "+a.name);if(null==c)throw new Error("Missing attribute value for attribute "+b+" of element "+a.name);this.name=this.stringify.attName(b),this.value=this.stringify.attValue(c)}return a.prototype.clone=function(){return d(a.prototype,this)},a.prototype.toString=function(a,b){return" "+this.name+'="'+this.value+'"'},a}()}).call(this)},{"lodash/create":74}],57:[function(a,b,c){(function(){var c,d,e,f,g;g=a("./XMLStringifier"),d=a("./XMLDeclaration"),e=a("./XMLDocType"),f=a("./XMLElement"),b.exports=c=function(){function a(a,b){var c,d;if(null==a)throw new Error("Root element needs a name");null==b&&(b={}),this.options=b,this.stringify=new g(b),d=new f(this,"doc"),c=d.element(a),c.isRoot=!0,c.documentObject=this,this.rootObject=c,b.headless||(c.declaration(b),(null!=b.pubID||null!=b.sysID)&&c.doctype(b))}return a.prototype.root=function(){return this.rootObject},a.prototype.end=function(a){return this.toString(a)},a.prototype.toString=function(a){var b,c,d,e,f,g,h,i;return e=(null!=a?a.pretty:void 0)||!1,b=null!=(g=null!=a?a.indent:void 0)?g:" ",d=null!=(h=null!=a?a.offset:void 0)?h:0,c=null!=(i=null!=a?a.newline:void 0)?i:"\n",f="",null!=this.xmldec&&(f+=this.xmldec.toString(a)),null!=this.doctype&&(f+=this.doctype.toString(a)),f+=this.rootObject.toString(a),e&&f.slice(-c.length)===c&&(f=f.slice(0,-c.length)),f},a}()}).call(this)},{"./XMLDeclaration":64,"./XMLDocType":65,"./XMLElement":66,"./XMLStringifier":70}],58:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing CDATA text");this.text=this.stringify.cdata(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":67,"lodash/create":74}],59:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing comment text");this.text=this.stringify.comment(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":67,"lodash/create":74}],60:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c,d,e,f){if(this.stringify=a.stringify,null==b)throw new Error("Missing DTD element name");if(null==c)throw new Error("Missing DTD attribute name");if(!d)throw new Error("Missing DTD attribute type");if(!e)throw new Error("Missing DTD attribute default");if(0!==e.indexOf("#")&&(e="#"+e),!e.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");if(f&&!e.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT");this.elementName=this.stringify.eleName(b),this.attributeName=this.stringify.attName(c),this.attributeType=this.stringify.dtdAttType(d),this.defaultValue=this.stringify.dtdAttDefault(f),this.defaultValueType=e}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":74}],61:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing DTD element name");c||(c="(#PCDATA)"),Array.isArray(c)&&(c="("+c.join(",")+")"),this.name=this.stringify.eleName(b),this.value=this.stringify.dtdElementValue(c)}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":74}],62:[function(a,b,c){(function(){var c,d,e;d=a("lodash/create"),e=a("lodash/isObject"),b.exports=c=function(){function a(a,b,c,d){if(this.stringify=a.stringify,null==c)throw new Error("Missing entity name");if(null==d)throw new Error("Missing entity value");if(this.pe=!!b,this.name=this.stringify.eleName(c),e(d)){if(!d.pubID&&!d.sysID)throw new Error("Public and/or system identifiers are required for an external entity");if(d.pubID&&!d.sysID)throw new Error("System identifier is required for a public external entity");if(null!=d.pubID&&(this.pubID=this.stringify.dtdPubID(d.pubID)),null!=d.sysID&&(this.sysID=this.stringify.dtdSysID(d.sysID)),null!=d.nData&&(this.nData=this.stringify.dtdNData(d.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity")}else this.value=this.stringify.dtdEntityValue(d)}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":74,"lodash/isObject":168}],63:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing notation name");if(!c.pubID&&!c.sysID)throw new Error("Public or system identifiers are required for an external entity");this.name=this.stringify.eleName(b),null!=c.pubID&&(this.pubID=this.stringify.dtdPubID(c.pubID)),null!=c.sysID&&(this.sysID=this.stringify.dtdSysID(c.sysID))}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":74}],64:[function(a,b,c){(function(){var c,d,e,f,g=function(a,b){function c(){this.constructor=a}for(var d in b)h.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},h={}.hasOwnProperty;e=a("lodash/create"),f=a("lodash/isObject"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c,d,e){var g;b.__super__.constructor.call(this,a),f(c)&&(g=c,c=g.version,d=g.encoding,e=g.standalone),c||(c="1.0"),this.version=this.stringify.xmlVersion(c),null!=d&&(this.encoding=this.stringify.xmlEncoding(d)),null!=e&&(this.standalone=this.stringify.xmlStandalone(e))}return g(b,a),b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":67,"lodash/create":74,"lodash/isObject":168}],65:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l;k=a("lodash/create"),l=a("lodash/isObject"),c=a("./XMLCData"),d=a("./XMLComment"),e=a("./XMLDTDAttList"),g=a("./XMLDTDEntity"),f=a("./XMLDTDElement"),h=a("./XMLDTDNotation"),j=a("./XMLProcessingInstruction"),b.exports=i=function(){function a(a,b,c){var d,e;this.documentObject=a,this.stringify=this.documentObject.stringify,this.children=[],l(b)&&(d=b,b=d.pubID,c=d.sysID),null==c&&(e=[b,c],c=e[0],b=e[1]),null!=b&&(this.pubID=this.stringify.dtdPubID(b)),null!=c&&(this.sysID=this.stringify.dtdSysID(c))}return a.prototype.element=function(a,b){var c;return c=new f(this,a,b),this.children.push(c),this},a.prototype.attList=function(a,b,c,d,f){var g;return g=new e(this,a,b,c,d,f),this.children.push(g),this},a.prototype.entity=function(a,b){var c;return c=new g(this,!1,a,b),this.children.push(c),this},a.prototype.pEntity=function(a,b){var c;return c=new g(this,!0,a,b),this.children.push(c),this},a.prototype.notation=function(a,b){var c;return c=new h(this,a,b),this.children.push(c),this},a.prototype.cdata=function(a){var b;return b=new c(this,a),this.children.push(b),this},a.prototype.comment=function(a){var b;return b=new d(this,a),this.children.push(b),this},a.prototype.instruction=function(a,b){var c;return c=new j(this,a,b),this.children.push(c),this},a.prototype.root=function(){return this.documentObject.root()},a.prototype.document=function(){return this.documentObject},a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;if(i=(null!=a?a.pretty:void 0)||!1,e=null!=(k=null!=a?a.indent:void 0)?k:" ",h=null!=(l=null!=a?a.offset:void 0)?l:0,g=null!=(m=null!=a?a.newline:void 0)?m:"\n",b||(b=0),o=new Array(b+h+1).join(e),j="",i&&(j+=o),j+="0){for(j+=" [",i&&(j+=g),n=this.children,d=0,f=n.length;f>d;d++)c=n[d],j+=c.toString(a,b+1);j+="]"}return j+=">",i&&(j+=g),j},a.prototype.ele=function(a,b){return this.element(a,b)},a.prototype.att=function(a,b,c,d,e){return this.attList(a,b,c,d,e)},a.prototype.ent=function(a,b){return this.entity(a,b)},a.prototype.pent=function(a,b){return this.pEntity(a,b)},a.prototype.not=function(a,b){return this.notation(a,b)},a.prototype.dat=function(a){return this.cdata(a)},a.prototype.com=function(a){return this.comment(a)},a.prototype.ins=function(a,b){return this.instruction(a,b)},a.prototype.up=function(){return this.root()},a.prototype.doc=function(){return this.document()},a}()}).call(this)},{"./XMLCData":58,"./XMLComment":59,"./XMLDTDAttList":60,"./XMLDTDElement":61,"./XMLDTDEntity":62,"./XMLDTDNotation":63,"./XMLProcessingInstruction":68,"lodash/create":74,"lodash/isObject":168}],66:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k=function(a,b){function c(){this.constructor=a}for(var d in b)l.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l={}.hasOwnProperty;g=a("lodash/create"),j=a("lodash/isObject"),i=a("lodash/isFunction"),h=a("lodash/every"),e=a("./XMLNode"),c=a("./XMLAttribute"),f=a("./XMLProcessingInstruction"),b.exports=d=function(a){function b(a,c,d){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing element name");this.name=this.stringify.eleName(c),this.children=[],this.instructions=[],this.attributes={},null!=d&&this.attribute(d)}return k(b,a),b.prototype.clone=function(){var a,c,d,e,f,h,i,j;d=g(b.prototype,this),d.isRoot&&(d.documentObject=null),d.attributes={},i=this.attributes;for(c in i)l.call(i,c)&&(a=i[c],d.attributes[c]=a.clone());for(d.instructions=[],j=this.instructions,e=0,f=j.length;f>e;e++)h=j[e],d.instructions.push(h.clone());return d.children=[],this.children.forEach(function(a){var b;return b=a.clone(),b.parent=d,d.children.push(b)}),d},b.prototype.attribute=function(a,b){var d,e;if(null!=a&&(a=a.valueOf()),j(a))for(d in a)l.call(a,d)&&(e=a[d],this.attribute(d,e));else i(b)&&(b=b.apply()),this.options.skipNullAttributes&&null==b||(this.attributes[a]=new c(this,a,b));return this},b.prototype.removeAttribute=function(a){var b,c,d;if(null==a)throw new Error("Missing attribute name");if(a=a.valueOf(),Array.isArray(a))for(c=0,d=a.length;d>c;c++)b=a[c],delete this.attributes[b];else delete this.attributes[a];return this},b.prototype.instruction=function(a,b){var c,d,e,g,h;if(null!=a&&(a=a.valueOf()),null!=b&&(b=b.valueOf()),Array.isArray(a))for(c=0,h=a.length;h>c;c++)d=a[c],this.instruction(d);else if(j(a))for(d in a)l.call(a,d)&&(e=a[d],this.instruction(d,e));else i(b)&&(b=b.apply()),g=new f(this,a,b),this.instructions.push(g);return this},b.prototype.toString=function(a,b){var c,d,e,f,g,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x;for(p=(null!=a?a.pretty:void 0)||!1,f=null!=(r=null!=a?a.indent:void 0)?r:" ",o=null!=(s=null!=a?a.offset:void 0)?s:0,n=null!=(t=null!=a?a.newline:void 0)?t:"\n",b||(b=0),x=new Array(b+o+1).join(f),q="",u=this.instructions,e=0,j=u.length;j>e;e++)g=u[e],q+=g.toString(a,b);p&&(q+=x),q+="<"+this.name,v=this.attributes;for(m in v)l.call(v,m)&&(c=v[m],q+=c.toString(a));if(0===this.children.length||h(this.children,function(a){return""===a.value}))q+="/>",p&&(q+=n);else if(p&&1===this.children.length&&null!=this.children[0].value)q+=">",q+=this.children[0].value,q+="",q+=n;else{for(q+=">",p&&(q+=n),w=this.children,i=0,k=w.length;k>i;i++)d=w[i],q+=d.toString(a,b+1);p&&(q+=x),q+="",p&&(q+=n)}return q},b.prototype.att=function(a,b){return this.attribute(a,b)},b.prototype.ins=function(a,b){return this.instruction(a,b)},b.prototype.a=function(a,b){ -return this.attribute(a,b)},b.prototype.i=function(a,b){return this.instruction(a,b)},b}(e)}).call(this)},{"./XMLAttribute":56,"./XMLNode":67,"./XMLProcessingInstruction":68,"lodash/create":74,"lodash/every":76,"lodash/isFunction":165,"lodash/isObject":168}],67:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l,m,n={}.hasOwnProperty;m=a("lodash/isObject"),l=a("lodash/isFunction"),k=a("lodash/isEmpty"),g=null,c=null,d=null,e=null,f=null,i=null,j=null,b.exports=h=function(){function b(b){this.parent=b,this.options=this.parent.options,this.stringify=this.parent.stringify,null===g&&(g=a("./XMLElement"),c=a("./XMLCData"),d=a("./XMLComment"),e=a("./XMLDeclaration"),f=a("./XMLDocType"),i=a("./XMLRaw"),j=a("./XMLText"))}return b.prototype.element=function(a,b,c){var d,e,f,g,h,i,j,o,p,q;if(i=null,null==b&&(b={}),b=b.valueOf(),m(b)||(p=[b,c],c=p[0],b=p[1]),null!=a&&(a=a.valueOf()),Array.isArray(a))for(f=0,j=a.length;j>f;f++)e=a[f],i=this.element(e);else if(l(a))i=this.element(a.apply());else if(m(a)){for(h in a)if(n.call(a,h))if(q=a[h],l(q)&&(q=q.apply()),m(q)&&k(q)&&(q=null),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===h.indexOf(this.stringify.convertAttKey))i=this.attribute(h.substr(this.stringify.convertAttKey.length),q);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===h.indexOf(this.stringify.convertPIKey))i=this.instruction(h.substr(this.stringify.convertPIKey.length),q);else if(!this.options.separateArrayItems&&Array.isArray(q))for(g=0,o=q.length;o>g;g++)e=q[g],d={},d[h]=e,i=this.element(d);else m(q)?(i=this.element(h),i.element(q)):i=this.element(h,q)}else i=!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?this.text(c):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===a.indexOf(this.stringify.convertCDataKey)?this.cdata(c):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===a.indexOf(this.stringify.convertCommentKey)?this.comment(c):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===a.indexOf(this.stringify.convertRawKey)?this.raw(c):this.node(a,b,c);if(null==i)throw new Error("Could not create any elements with: "+a);return i},b.prototype.insertBefore=function(a,b,c){var d,e,f;if(this.isRoot)throw new Error("Cannot insert elements at root level");return e=this.parent.children.indexOf(this),f=this.parent.children.splice(e),d=this.parent.element(a,b,c),Array.prototype.push.apply(this.parent.children,f),d},b.prototype.insertAfter=function(a,b,c){var d,e,f;if(this.isRoot)throw new Error("Cannot insert elements at root level");return e=this.parent.children.indexOf(this),f=this.parent.children.splice(e+1),d=this.parent.element(a,b,c),Array.prototype.push.apply(this.parent.children,f),d},b.prototype.remove=function(){var a,b;if(this.isRoot)throw new Error("Cannot remove the root element");return a=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[a,a-a+1].concat(b=[])),b,this.parent},b.prototype.node=function(a,b,c){var d,e;return null!=a&&(a=a.valueOf()),null==b&&(b={}),b=b.valueOf(),m(b)||(e=[b,c],c=e[0],b=e[1]),d=new g(this,a,b),null!=c&&d.text(c),this.children.push(d),d},b.prototype.text=function(a){var b;return b=new j(this,a),this.children.push(b),this},b.prototype.cdata=function(a){var b;return b=new c(this,a),this.children.push(b),this},b.prototype.comment=function(a){var b;return b=new d(this,a),this.children.push(b),this},b.prototype.raw=function(a){var b;return b=new i(this,a),this.children.push(b),this},b.prototype.declaration=function(a,b,c){var d,f;return d=this.document(),f=new e(d,a,b,c),d.xmldec=f,d.root()},b.prototype.doctype=function(a,b){var c,d;return c=this.document(),d=new f(c,a,b),c.doctype=d,d},b.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},b.prototype.root=function(){var a;if(this.isRoot)return this;for(a=this.parent;!a.isRoot;)a=a.parent;return a},b.prototype.document=function(){return this.root().documentObject},b.prototype.end=function(a){return this.document().toString(a)},b.prototype.prev=function(){var a;if(this.isRoot)throw new Error("Root node has no siblings");if(a=this.parent.children.indexOf(this),1>a)throw new Error("Already at the first node");return this.parent.children[a-1]},b.prototype.next=function(){var a;if(this.isRoot)throw new Error("Root node has no siblings");if(a=this.parent.children.indexOf(this),-1===a||a===this.parent.children.length-1)throw new Error("Already at the last node");return this.parent.children[a+1]},b.prototype.importXMLBuilder=function(a){var b;return b=a.root().clone(),b.parent=this,b.isRoot=!1,this.children.push(b),this},b.prototype.ele=function(a,b,c){return this.element(a,b,c)},b.prototype.nod=function(a,b,c){return this.node(a,b,c)},b.prototype.txt=function(a){return this.text(a)},b.prototype.dat=function(a){return this.cdata(a)},b.prototype.com=function(a){return this.comment(a)},b.prototype.doc=function(){return this.document()},b.prototype.dec=function(a,b,c){return this.declaration(a,b,c)},b.prototype.dtd=function(a,b){return this.doctype(a,b)},b.prototype.e=function(a,b,c){return this.element(a,b,c)},b.prototype.n=function(a,b,c){return this.node(a,b,c)},b.prototype.t=function(a){return this.text(a)},b.prototype.d=function(a){return this.cdata(a)},b.prototype.c=function(a){return this.comment(a)},b.prototype.r=function(a){return this.raw(a)},b.prototype.u=function(){return this.up()},b}()}).call(this)},{"./XMLCData":58,"./XMLComment":59,"./XMLDeclaration":64,"./XMLDocType":65,"./XMLElement":66,"./XMLRaw":69,"./XMLText":71,"lodash/isEmpty":164,"lodash/isFunction":165,"lodash/isObject":168}],68:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing instruction target");this.target=this.stringify.insTarget(b),c&&(this.value=this.stringify.insValue(c))}return a.prototype.clone=function(){return d(a.prototype,this)},a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":74}],69:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),c=a("./XMLNode"),b.exports=d=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing raw text");this.value=this.stringify.raw(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+=this.value,f&&(g+=d),g},b}(c)}).call(this)},{"./XMLNode":67,"lodash/create":74}],70:[function(a,b,c){(function(){var a,c=function(a,b){return function(){return a.apply(b,arguments)}},d={}.hasOwnProperty;b.exports=a=function(){function a(a){this.assertLegalChar=c(this.assertLegalChar,this);var b,e,f;this.allowSurrogateChars=null!=a?a.allowSurrogateChars:void 0,this.noDoubleEncoding=null!=a?a.noDoubleEncoding:void 0,e=(null!=a?a.stringify:void 0)||{};for(b in e)d.call(e,b)&&(f=e[b],this[b]=f)}return a.prototype.eleName=function(a){return a=""+a||"",this.assertLegalChar(a)},a.prototype.eleText=function(a){return a=""+a||"",this.assertLegalChar(this.elEscape(a))},a.prototype.cdata=function(a){if(a=""+a||"",a.match(/]]>/))throw new Error("Invalid CDATA text: "+a);return this.assertLegalChar(a)},a.prototype.comment=function(a){if(a=""+a||"",a.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+a);return this.assertLegalChar(a)},a.prototype.raw=function(a){return""+a||""},a.prototype.attName=function(a){return""+a||""},a.prototype.attValue=function(a){return a=""+a||"",this.attEscape(a)},a.prototype.insTarget=function(a){return""+a||""},a.prototype.insValue=function(a){if(a=""+a||"",a.match(/\?>/))throw new Error("Invalid processing instruction value: "+a);return a},a.prototype.xmlVersion=function(a){if(a=""+a||"",!a.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+a);return a},a.prototype.xmlEncoding=function(a){if(a=""+a||"",!a.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/))throw new Error("Invalid encoding: "+a);return a},a.prototype.xmlStandalone=function(a){return a?"yes":"no"},a.prototype.dtdPubID=function(a){return""+a||""},a.prototype.dtdSysID=function(a){return""+a||""},a.prototype.dtdElementValue=function(a){return""+a||""},a.prototype.dtdAttType=function(a){return""+a||""},a.prototype.dtdAttDefault=function(a){return null!=a?""+a||"":a},a.prototype.dtdEntityValue=function(a){return""+a||""},a.prototype.dtdNData=function(a){return""+a||""},a.prototype.convertAttKey="@",a.prototype.convertPIKey="?",a.prototype.convertTextKey="#text",a.prototype.convertCDataKey="#cdata",a.prototype.convertCommentKey="#comment",a.prototype.convertRawKey="#raw",a.prototype.assertLegalChar=function(a){var b,c;if(b=this.allowSurrogateChars?/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/:/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/,c=a.match(b))throw new Error("Invalid character ("+c+") in string: "+a+" at index "+c.index);return a},a.prototype.elEscape=function(a){var b;return b=this.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(b,"&").replace(//g,">").replace(/\r/g," ")},a.prototype.attEscape=function(a){var b;return b=this.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(b,"&").replace(/c)return!1;var d=a.length-1;return c==d?a.pop():g.call(a,c,1),!0}var e=a("./assocIndexOf"),f=c.Array.prototype,g=f.splice;b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./assocIndexOf":95}],93:[function(a,b,c){function d(a,b){var c=e(a,b);return 0>c?void 0:a[c][1]}var e=a("./assocIndexOf");b.exports=d},{"./assocIndexOf":95}],94:[function(a,b,c){function d(a,b){return e(a,b)>-1}var e=a("./assocIndexOf");b.exports=d},{"./assocIndexOf":95}],95:[function(a,b,c){function d(a,b){for(var c=a.length;c--;)if(e(a[c][0],b))return c;return-1}var e=a("../eq");b.exports=d},{"../eq":75}],96:[function(a,b,c){function d(a,b,c){var d=e(a,b);0>d?a.push([b,c]):a[d][1]=c}var e=a("./assocIndexOf");b.exports=d},{"./assocIndexOf":95}],97:[function(a,b,c){function d(a,b){return a&&e(b,f(b),a)}var e=a("./copyObject"),f=a("../keys");b.exports=d},{"../keys":173,"./copyObject":119}],98:[function(a,b,c){var d=a("../isObject"),e=function(){function a(){}return function(b){if(d(b)){a.prototype=b;var c=new a;a.prototype=void 0}return c||{}}}();b.exports=e},{"../isObject":168}],99:[function(a,b,c){var d=a("./baseForOwn"),e=a("./createBaseEach"),f=e(d);b.exports=f},{"./baseForOwn":102,"./createBaseEach":122}],100:[function(a,b,c){function d(a,b){var c=!0;return e(a,function(a,d,e){return c=!!b(a,d,e)}),c}var e=a("./baseEach");b.exports=d},{"./baseEach":99}],101:[function(a,b,c){var d=a("./createBaseFor"),e=d();b.exports=e},{"./createBaseFor":123}],102:[function(a,b,c){function d(a,b){return a&&e(a,b,f)}var e=a("./baseFor"),f=a("../keys");b.exports=d},{"../keys":173,"./baseFor":101}],103:[function(a,b,c){function d(a,b){b=f(b,a)?[b+""]:e(b);for(var c=0,d=b.length;null!=a&&d>c;)a=a[b[c++]];return c&&c==d?a:void 0}var e=a("./baseToPath"),f=a("./isKey");b.exports=d},{"./baseToPath":118,"./isKey":140}],104:[function(a,b,c){(function(a){function c(a,b){return e.call(a,b)||"object"==typeof a&&b in a&&null===f(a)}var d=a.Object.prototype,e=d.hasOwnProperty,f=Object.getPrototypeOf;b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],105:[function(a,b,c){function d(a,b){return b in Object(a)}b.exports=d},{}],106:[function(a,b,c){function d(a,b,c,h,i){return a===b?!0:null==a||null==b||!f(a)&&!g(b)?a!==a&&b!==b:e(a,b,d,c,h,i)}var e=a("./baseIsEqualDeep"),f=a("../isObject"),g=a("../isObjectLike");b.exports=d},{"../isObject":168,"../isObjectLike":169,"./baseIsEqualDeep":107}],107:[function(a,b,c){(function(c){function d(a,b,c,d,q,s){var t=j(a),u=j(b),v=o,w=o;t||(v=i(a),v==n?v=p:v!=p&&(t=l(a))),u||(w=i(b),w==n?w=p:w!=p&&(u=l(b)));var x=v==p&&!k(a),y=w==p&&!k(b),z=v==w;if(z&&!t&&!x)return g(a,b,v,c,d,q);var A=q&m;if(!A){var B=x&&r.call(a,"__wrapped__"),C=y&&r.call(b,"__wrapped__");if(B||C)return c(B?a.value():a,C?b.value():b,d,q,s)}return z?(s||(s=new e),(t?f:h)(a,b,c,d,q,s)):!1}var e=a("./Stack"),f=a("./equalArrays"),g=a("./equalByTag"),h=a("./equalObjects"),i=a("./getTag"),j=a("../isArray"),k=a("./isHostObject"),l=a("../isTypedArray"),m=2,n="[object Arguments]",o="[object Array]",p="[object Object]",q=c.Object.prototype,r=q.hasOwnProperty;b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../isArray":161,"../isTypedArray":172,"./Stack":84,"./equalArrays":124,"./equalByTag":125,"./equalObjects":126,"./getTag":130,"./isHostObject":137}],108:[function(a,b,c){function d(a,b,c,d){var i=c.length,j=i,k=!d;if(null==a)return!j;for(a=Object(a);i--;){var l=c[i];if(k&&l[2]?l[1]!==a[l[0]]:!(l[0]in a))return!1}for(;++ib&&(b=-b>e?0:e+b),c=c>e?e:c,0>c&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d1?c[f-1]:void 0,h=f>2?c[2]:void 0;for(g="function"==typeof g?(f--,g):void 0,h&&e(c[0],c[1],h)&&(g=3>f?void 0:g,f=1),b=Object(b);++dm))return!1;var o=i.get(a);if(o)return o==b;var p=!0;for(i.set(a,b);++j-1&&a%1==0&&b>a}var e=9007199254740991,f=/^(?:0|[1-9]\d*)$/;b.exports=d},{}],139:[function(a,b,c){function d(a,b,c){if(!h(c))return!1;var d=typeof b;return("number"==d?f(c)&&g(b,c.length):"string"==d&&b in c)?e(c[b],a):!1}var e=a("../eq"),f=a("../isArrayLike"),g=a("./isIndex"),h=a("../isObject");b.exports=d},{"../eq":75,"../isArrayLike":162,"../isObject":168,"./isIndex":138}],140:[function(a,b,c){function d(a,b){return"number"==typeof a?!0:!e(a)&&(g.test(a)||!f.test(a)||null!=b&&a in Object(b))}var e=a("../isArray"),f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/;b.exports=d},{"../isArray":161}],141:[function(a,b,c){function d(a){var b=typeof a;return"number"==b||"boolean"==b||"string"==b&&"__proto__"!==a||null==a}b.exports=d},{}],142:[function(a,b,c){(function(a){function c(a){var b=a&&a.constructor,c="function"==typeof b&&b.prototype||d;return a===c}var d=a.Object.prototype;b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],143:[function(a,b,c){function d(a){return a===a&&!e(a)}var e=a("../isObject");b.exports=d},{"../isObject":168}],144:[function(a,b,c){function d(){this.__data__={hash:new e,map:f?new f:[],string:new e}}var e=a("./Hash"),f=a("./Map");b.exports=d},{"./Hash":80,"./Map":81}],145:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map["delete"](a):f(b.map,a)}var e=a("./Map"),f=a("./assocDelete"),g=a("./hashDelete"),h=a("./isKeyable");b.exports=d},{"./Map":81,"./assocDelete":92,"./hashDelete":132,"./isKeyable":141}],146:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map.get(a):f(b.map,a)}var e=a("./Map"),f=a("./assocGet"),g=a("./hashGet"),h=a("./isKeyable");b.exports=d},{"./Map":81,"./assocGet":93,"./hashGet":133,"./isKeyable":141}],147:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map.has(a):f(b.map,a)}var e=a("./Map"),f=a("./assocHas"),g=a("./hashHas"),h=a("./isKeyable");b.exports=d},{"./Map":81,"./assocHas":94,"./hashHas":134,"./isKeyable":141}],148:[function(a,b,c){function d(a,b){var c=this.__data__;return h(a)?g("string"==typeof a?c.string:c.hash,a,b):e?c.map.set(a,b):f(c.map,a,b),this}var e=a("./Map"),f=a("./assocSet"),g=a("./hashSet"),h=a("./isKeyable");b.exports=d},{"./Map":81,"./assocSet":96,"./hashSet":135,"./isKeyable":141}],149:[function(a,b,c){function d(a){var b=-1,c=Array(a.size);return a.forEach(function(a,d){c[++b]=[d,a]}),c}b.exports=d},{}],150:[function(a,b,c){var d=a("./getNative"),e=d(Object,"create");b.exports=e},{"./getNative":129}],151:[function(a,b,c){function d(a,b){return 1==b.length?a:f(a,e(b,0,-1))}var e=a("./baseSlice"),f=a("../get");b.exports=d},{"../get":77,"./baseSlice":115}],152:[function(a,b,c){function d(a){var b=-1,c=Array(a.size);return a.forEach(function(a){c[++b]=a}),c}b.exports=d},{}],153:[function(a,b,c){function d(){this.__data__={array:[],map:null}}b.exports=d},{}],154:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map["delete"](a)}var e=a("./assocDelete");b.exports=d},{"./assocDelete":92}],155:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map.get(a)}var e=a("./assocGet");b.exports=d},{"./assocGet":93}],156:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map.has(a)}var e=a("./assocHas");b.exports=d},{"./assocHas":94}],157:[function(a,b,c){function d(a,b){var c=this.__data__,d=c.array;d&&(d.length-1&&a%1==0&&e>=a}var e=9007199254740991;b.exports=d},{}],167:[function(a,b,c){(function(c){function d(a){return null==a?!1:e(a)?m.test(k.call(a)):g(a)&&(f(a)?m:i).test(a)}var e=a("./isFunction"),f=a("./internal/isHostObject"),g=a("./isObjectLike"),h=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,j=c.Object.prototype,k=c.Function.prototype.toString,l=j.hasOwnProperty,m=RegExp("^"+k.call(l).replace(h,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./internal/isHostObject":137,"./isFunction":165,"./isObjectLike":169}],168:[function(a,b,c){function d(a){var b=typeof a;return!!a&&("object"==b||"function"==b)}b.exports=d},{}],169:[function(a,b,c){function d(a){return!!a&&"object"==typeof a}b.exports=d},{}],170:[function(a,b,c){(function(c){function d(a){return"string"==typeof a||!e(a)&&f(a)&&i.call(a)==g}var e=a("./isArray"),f=a("./isObjectLike"),g="[object String]",h=c.Object.prototype,i=h.toString;b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./isArray":161,"./isObjectLike":169}],171:[function(a,b,c){(function(c){function d(a){return"symbol"==typeof a||e(a)&&h.call(a)==f}var e=a("./isObjectLike"),f="[object Symbol]",g=c.Object.prototype,h=g.toString;b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./isObjectLike":169}],172:[function(a,b,c){(function(c){function d(a){return f(a)&&e(a.length)&&!!D[F.call(a)]}var e=a("./isLength"),f=a("./isObjectLike"),g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Error]",l="[object Function]",m="[object Map]",n="[object Number]",o="[object Object]",p="[object RegExp]",q="[object Set]",r="[object String]",s="[object WeakMap]",t="[object ArrayBuffer]",u="[object Float32Array]",v="[object Float64Array]",w="[object Int8Array]",x="[object Int16Array]",y="[object Int32Array]",z="[object Uint8Array]",A="[object Uint8ClampedArray]",B="[object Uint16Array]",C="[object Uint32Array]",D={};D[u]=D[v]=D[w]=D[x]=D[y]=D[z]=D[A]=D[B]=D[C]=!0,D[g]=D[h]=D[t]=D[i]=D[j]=D[k]=D[l]=D[m]=D[n]=D[o]=D[p]=D[q]=D[r]=D[s]=!1;var E=c.Object.prototype,F=E.toString;b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./isLength":166,"./isObjectLike":169}],173:[function(a,b,c){function d(a){var b=j(a);if(!b&&!h(a))return f(a);var c=g(a),d=!!c,k=c||[],l=k.length;for(var m in a)!e(a,m)||d&&("length"==m||i(m,l))||b&&"constructor"==m||k.push(m);return k}var e=a("./internal/baseHas"),f=a("./internal/baseKeys"),g=a("./internal/indexKeys"),h=a("./isArrayLike"),i=a("./internal/isIndex"),j=a("./internal/isPrototype");b.exports=d},{"./internal/baseHas":104,"./internal/baseKeys":110,"./internal/indexKeys":136,"./internal/isIndex":138,"./internal/isPrototype":142,"./isArrayLike":162}],174:[function(a,b,c){function d(a){var b=a?a.length:0;return b?a[b-1]:void 0}b.exports=d},{}],175:[function(a,b,c){function d(a){return g(a)?e(a):f(a)}var e=a("./internal/baseProperty"),f=a("./internal/basePropertyDeep"),g=a("./internal/isKey");b.exports=d},{"./internal/baseProperty":113,"./internal/basePropertyDeep":114,"./internal/isKey":140}],176:[function(a,b,c){function d(a,b){if("function"!=typeof a)throw new TypeError(g);return b=h(void 0===b?a.length-1:f(b),0),function(){for(var c=arguments,d=-1,f=h(c.length-b,0),g=Array(f);++da?-1:1;return b*g}var c=a%1;return a===a?c?a-c:a:0}var e=a("./toNumber"),f=1/0,g=1.7976931348623157e308;b.exports=d},{"./toNumber":179}],179:[function(a,b,c){function d(a){if(f(a)){var b=e(a.valueOf)?a.valueOf():a;a=f(b)?b+"":b}if("string"!=typeof a)return 0===a?a:+a;a=a.replace(h,"");var c=j.test(a);return c||k.test(a)?l(a.slice(2),c?2:8):i.test(a)?g:+a}var e=a("./isFunction"),f=a("./isObject"),g=NaN,h=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,k=/^0o[0-7]+$/i,l=parseInt;b.exports=d},{"./isFunction":165,"./isObject":168}],180:[function(a,b,c){function d(a){return e(a,f(a))}var e=a("./internal/baseToPairs"),f=a("./keys");b.exports=d},{"./internal/baseToPairs":117,"./keys":173}],181:[function(a,b,c){function d(a){if("string"==typeof a)return a;if(null==a)return"";if(f(a))return e?i.call(a):"";var b=a+"";return"0"==b&&1/a==-g?"-0":b}var e=a("./internal/Symbol"),f=a("./isSymbol"),g=1/0,h=e?e.prototype:void 0,i=e?h.toString:void 0;b.exports=d},{"./internal/Symbol":85,"./isSymbol":171}]},{},[16])(16)}); \ No newline at end of file +/* QuickBlox JavaScript SDK - v2.1.0 - 2016-03-04 */ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.QB=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gc;c++)f.muc.join(d[c]);"function"==typeof f.onReconnectListener&&n.safeCallbackCall(f.onReconnectListener)}})});break;case Strophe.Status.DISCONNECTING:n.QBLog("[ChatProxy]","Status.DISCONNECTING");break;case Strophe.Status.DISCONNECTED:n.QBLog("[ChatProxy]","Status.DISCONNECTED at "+l()),q.reset(),f._isDisconnected||"function"!=typeof f.onDisconnectedListener||n.safeCallbackCall(f.onDisconnectedListener),f._isDisconnected=!0,f._isLogout||f.connect(a);break;case Strophe.Status.ATTACHED:n.QBLog("[ChatProxy]","Status.ATTACHED")}})},send:function(a,b){if(!o)throw p;b.id||(b.id=n.getBsonObjectId());var c=this,d=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:b.type,id:b.id});b.body&&d.c("body",{xmlns:Strophe.NS.CLIENT}).t(b.body).up(),b.extension&&(d.c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b.extension).forEach(function(a){"attachments"===a?b.extension[a].forEach(function(a){d.c("attachment",a).up()}):"object"==typeof b.extension[a]?c._JStoXML(a,b.extension[a],d):d.c(a).t(b.extension[a]).up()}),d.up()),b.markable&&d.c("markable",{xmlns:Strophe.NS.CHAT_MARKERS}),q.send(d)},sendSystemMessage:function(a,b){if(!o)throw p;b.id||(b.id=n.getBsonObjectId());var c=this,d=$msg({id:b.id,type:"headline",to:this.helpers.jidOrUserId(a)});b.extension&&(d.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("moduleIdentifier").t("SystemNotifications").up(),Object.keys(b.extension).forEach(function(a){"object"==typeof b.extension[a]?c._JStoXML(a,b.extension[a],d):d.c(a).t(b.extension[a]).up()}),d.up()),q.send(d)},sendIsTypingStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("composing",{xmlns:Strophe.NS.CHAT_STATES}),q.send(b)},sendIsStopTypingStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("paused",{xmlns:Strophe.NS.CHAT_STATES}),q.send(b)},sendPres:function(a){if(!o)throw p;q.send($pres({from:q.jid,type:a}))},sendDeliveredStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:n.getBsonObjectId()});b.c("received",{xmlns:Strophe.NS.CHAT_MARKERS,id:a.messageId}).up(),b.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("dialog_id").t(a.dialogId),q.send(b)},sendReadStatus:function(a){if(!o)throw p;var b=$msg({from:q.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:n.getBsonObjectId()});b.c("displayed",{xmlns:Strophe.NS.CHAT_MARKERS,id:a.messageId}).up(),b.c("extraParams",{xmlns:Strophe.NS.CLIENT}).c("dialog_id").t(a.dialogId),q.send(b)},disconnect:function(){if(!o)throw p;v={},this._isLogout=!0,q.flush(),q.disconnect()},addListener:function(a,b){function c(){return b(),a.live!==!1}if(!o)throw p;return q.addHandler(c,null,a.name||null,a.type||null,a.id||null,a.from||null)},deleteListener:function(a){if(!o)throw p;q.deleteHandler(a)},_JStoXML:function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},_XMLtoJS:function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a},_parseExtraParams:function(a){if(!a)return null;for(var b,c={},d=[],e=0,f=a.childNodes.length;f>e;e++)if("attachment"===a.childNodes[e].tagName){for(var g={},h=a.childNodes[e].attributes,i=0,j=h.length;j>i;i++)"id"===h[i].name||"size"===h[i].name?g[h[i].name]=parseInt(h[i].value):g[h[i].name]=h[i].value;d.push(g)}else if("dialog_id"===a.childNodes[e].tagName)b=a.childNodes[e].textContent,c.dialog_id=b;else if(a.childNodes[e].childNodes.length>1){var k=a.childNodes[e].textContent.length;if(k>4096){for(var l="",i=0;i0&&(c.attachments=d),c.moduleIdentifier&&delete c.moduleIdentifier,{extension:c,dialogId:b}},_autoSendPresence:function(){if(!o)throw p;return q.send($pres().tree()),!0},_enableCarbons:function(a){if(!o)throw p;var b;b=$iq({from:q.jid,type:"set",id:q.getUniqueId("enableCarbons")}).c("enable",{xmlns:Strophe.NS.CARBONS}),q.sendIQ(b,function(b){a()})}},e.prototype={get:function(a){var b,c,d,e=this,f={};b=$iq({from:q.jid,type:"get",id:q.getUniqueId("getRoster")}).c("query",{xmlns:Strophe.NS.ROSTER}),q.sendIQ(b,function(b){c=b.getElementsByTagName("item");for(var g=0,h=c.length;h>g;g++)d=e.helpers.getIdFromNode(c[g].getAttribute("jid")).toString(),f[d]={subscription:c[g].getAttribute("subscription"),ask:c[g].getAttribute("ask")||null};a(f)})},add:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"none",ask:"subscribe"},c._sendSubscriptionPresence({jid:d,type:"subscribe"}),"function"==typeof b&&b()},confirm:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"from",ask:"subscribe"},c._sendSubscriptionPresence({jid:d,type:"subscribed"}),c._sendSubscriptionPresence({jid:d,type:"subscribe"}),"function"==typeof b&&b()},reject:function(a,b){var c=this,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();u[e]={subscription:"none",ask:null},c._sendSubscriptionPresence({jid:d,type:"unsubscribed"}),"function"==typeof b&&b()},remove:function(a,b){var c,d=this.helpers.jidOrUserId(a),e=this.helpers.getIdFromNode(d).toString();c=$iq({from:q.jid,type:"set",id:q.getUniqueId("removeRosterItem")}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:d,subscription:"remove"}),q.sendIQ(c,function(){delete u[e],"function"==typeof b&&b()})},_sendSubscriptionPresence:function(a){var b;b=$pres({to:a.jid,type:a.type}),q.send(b)}},f.prototype={join:function(a,b){var c,d=this,e=q.getUniqueId("join");v[a]=!0,c=$pres({from:q.jid,to:d.helpers.getRoomJid(a),id:e}).c("x",{xmlns:Strophe.NS.MUC}).c("history",{maxstanzas:0}),"function"==typeof b&&q.addHandler(b,null,"presence",null,e),q.send(c)},leave:function(a,b){var c,d=this,e=d.helpers.getRoomJid(a);delete v[a],c=$pres({from:q.jid,to:e,type:"unavailable"}),"function"==typeof b&&q.addHandler(b,null,"presence","unavailable",null,e),q.send(c)},listOnlineUsers:function(a,b){var c,d=this,e=[];c=$iq({from:q.jid,id:q.getUniqueId("muc_disco_items"),to:a,type:"get"}).c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),q.sendIQ(c,function(a){for(var c,f=a.getElementsByTagName("item"),g=0,h=f.length;h>g;g++)c=d.helpers.getUserIdFromRoomJid(f[g].getAttribute("jid")),e.push(c);b(e)})}},g.prototype={getNames:function(a){var b=$iq({from:q.jid,type:"get",id:q.getUniqueId("getNames")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST});q.sendIQ(b,function(b){for(var c=[],d={},e=b.getElementsByTagName("default"),f=b.getElementsByTagName("active"),g=b.getElementsByTagName("list"),h=e[0].getAttribute("name"),i=f[0].getAttribute("name"),j=0,k=g.length;k>j;j++)c.push(g[j].getAttribute("name"));d={"default":h,active:i,names:c},a(null,d)},function(b){if(b){var c=k(b);a(c,null)}else a(n.getError(408),null)})},getList:function(a,b){var c,d,e,f,g=this,h=[],i={};c=$iq({from:q.jid,type:"get",id:q.getUniqueId("getlist")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a}),q.sendIQ(c,function(c){d=c.getElementsByTagName("item");for(var j=0,k=d.length;k>j;j+=2)e=d[j].getAttribute("value"),f=g.helpers.getIdFromNode(e),h.push({user_id:f,action:d[j].getAttribute("action")});i={name:a,items:h},b(null,i)},function(a){if(a){var c=k(a);b(c,null)}else b(n.getError(408),null)})},create:function(a,b){var c,d,e,f,g,h=this,i={},j=[];c=$iq({from:q.jid,type:"set",id:q.getUniqueId("edit")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a.name}),$(a.items).each(function(a,b){i[b.user_id]=b.action}),j=Object.keys(i);for(var l=0,m=0,o=j.length;o>l;l++,m+=2)d=j[l],f=i[d],e=h.helpers.jidOrUserId(parseInt(d,10)),g=h.helpers.getUserNickWithMucDomain(d),c.c("item",{type:"jid",value:e,action:f,order:m+1}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up(),c.c("item",{type:"jid",value:g,action:f,order:m+2}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up();q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(n.getError(408))})},update:function(a,b){var c=this;c.getList(a.name,function(d,e){if(d)b(d,null);else{var f=JSON.parse(JSON.stringify(a)),g=e.items,h=f.items,i={};f.items=$.merge(g,h),i=f,c.create(i,function(a,c){d?b(a,null):b(null,c)})}})},"delete":function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("remove")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(n.getError(408))})},setAsDefault:function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("default")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("default",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(n.getError(408))})},setAsActive:function(a,b){var c=$iq({from:q.jid,type:"set",id:q.getUniqueId("active")}).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("active",{name:a?a:""});q.sendIQ(c,function(a){b(null)},function(a){if(a){var c=k(a);b(c)}else b(n.getError(408))})}},h.prototype={list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),n.QBLog("[DialogProxy]","list",a),this.service.ajax({url:n.getUrl(s),data:a},b)},create:function(a,b){a.occupants_ids instanceof Array&&(a.occupants_ids=a.occupants_ids.join(", ")),n.QBLog("[DialogProxy]","create",a),this.service.ajax({url:n.getUrl(s),type:"POST",data:a},b)},update:function(a,b,c){n.QBLog("[DialogProxy]","update",b),this.service.ajax({url:n.getUrl(s,a),type:"PUT",data:b},c)},"delete":function(a,b,c){n.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:n.getUrl(s,a),type:"DELETE"},b):3==arguments.length&&this.service.ajax({url:n.getUrl(s,a),type:"DELETE",data:b},c)}},i.prototype={list:function(a,b){n.QBLog("[MessageProxy]","list",a),this.service.ajax({url:n.getUrl(t),data:a},b)},create:function(a,b){n.QBLog("[MessageProxy]","create",a),this.service.ajax({url:n.getUrl(t),type:"POST",data:a},b)},update:function(a,b,c){n.QBLog("[MessageProxy]","update",a,b),this.service.ajax({url:n.getUrl(t,a),type:"PUT",data:b},c)},"delete":function(a,b,c){n.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:n.getUrl(t,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:n.getUrl(t,a),type:"DELETE",data:b,dataType:"text"},c)},unreadCount:function(a,b){n.QBLog("[MessageProxy]","unreadCount",a),this.service.ajax({url:n.getUrl(t+"/unread"),data:a},b)}},j.prototype={jidOrUserId:function(a){var b;if("string"==typeof a)b=a;else{if("number"!=typeof a)throw p;b=a+"-"+m.creds.appId+"@"+m.endpoints.chat}return b},typeChat:function(a){var b;if("string"==typeof a)b=a.indexOf("muc")>-1?"groupchat":"chat";else{if("number"!=typeof a)throw p;b="chat"}return b},getRecipientId:function(a,b){var c=null;return a.forEach(function(a,d,e){a!=b&&(c=a)}),c},getUserJid:function(a,b){return b?a+"-"+b+"@"+m.endpoints.chat:a+"-"+m.creds.appId+"@"+m.endpoints.chat},getUserNickWithMucDomain:function(a){return m.endpoints.muc+"/"+a},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])},getDialogIdFromNode:function(a){return a.indexOf("@")<0?null:a.split("@")[0].split("_")[1]},getRoomJidFromDialogId:function(a){return m.creds.appId+"_"+a+"@"+m.endpoints.muc},getRoomJid:function(a){if(!o)throw p;return a+"/"+this.getIdFromNode(q.jid)},getIdFromResource:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),parseInt(b.join("/")))},getUniqueId:function(a){if(!o)throw p;return q.getUniqueId(a)},getBsonObjectId:function(){return n.getBsonObjectId()},getUserIdFromRoomJid:function(a){var b=a.toString().split("/");return 0==b.length?null:b[b.length-1]}},b.exports=d},{"../qbConfig":15,"../qbUtils":19,strophe:159}],3:[function(a,b,c){function d(a){this.service=a}function e(a){for(var b=e.options,c=b.parser[b.strictMode?"strict":"loose"].exec(a),d={},f=14;f--;)d[b.key[f]]=c[f]||"";return d[b.q.name]={},d[b.key[12]].replace(b.q.parser,function(a,c,e){c&&(d[b.q.name][c]=e)}),d}var f=a("../qbConfig"),g=a("../qbUtils"),h="undefined"!=typeof window;if(!h)var i=a("xml2js");var j=f.urls.blobs+"/tagged";d.prototype={create:function(a,b){g.QBLog("[ContentProxy]","create",a),this.service.ajax({url:g.getUrl(f.urls.blobs),data:{blob:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.blob)})},list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a=null),g.QBLog("[ContentProxy]","list",a),this.service.ajax({url:g.getUrl(f.urls.blobs),data:a,type:"GET"},function(a,c){a?b(a,null):b(a,c)})},"delete":function(a,b){g.QBLog("[ContentProxy]","delete"),this.service.ajax({url:g.getUrl(f.urls.blobs,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},createAndUpload:function(a,b){var c,d,f,i,j,k={},l=this,m=JSON.parse(JSON.stringify(a));m.file.data="...",g.QBLog("[ContentProxy]","createAndUpload",m),c=a.file,d=a.name||c.name,f=a.type||c.type,i=a.size||c.size,k.name=d,k.content_type=f,a["public"]&&(k["public"]=a["public"]),a.tag_list&&(k.tag_list=a.tag_list),this.create(k,function(a,d){if(a)b(a,null);else{var f,g=e(d.blob_object_access.params),k={url:"https://"+g.host};f=h?new FormData:{},j=d.id,Object.keys(g.queryKey).forEach(function(a){h?f.append(a,decodeURIComponent(g.queryKey[a])):f[a]=decodeURIComponent(g.queryKey[a])}),h?f.append("file",c,d.name):f.file=c,k.data=f,l.upload(k,function(a,c){a?b(a,null):(h?d.path=c.Location.replace("http://","https://"):d.path=c.PostResponse.Location,l.markUploaded({id:j,size:i},function(a,c){a?b(a,null):b(null,d)}))})}})},upload:function(a,b){g.QBLog("[ContentProxy]","upload"),this.service.ajax({url:a.url,data:a.data,dataType:"xml",contentType:!1,processData:!1,type:"POST"},function(a,c){if(a)b(a,null);else if(h){var d,e,f={},g=c.documentElement,j=g.childNodes;for(d=0,e=j.length;e>d;d++)f[j[d].nodeName]=j[d].childNodes[0].nodeValue;b(null,f)}else{var k=i.parseString;k(c,function(a,c){c&&b(null,c)})}})},taggedForCurrentUser:function(a){g.QBLog("[ContentProxy]","taggedForCurrentUser"),this.service.ajax({url:g.getUrl(j)},function(b,c){b?a(b,null):a(null,c)})},markUploaded:function(a,b){g.QBLog("[ContentProxy]","markUploaded",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a.id+"/complete"),type:"PUT",data:{size:a.size},dataType:"text"},function(a,c){a?b(a,null):b(null,c)})},getInfo:function(a,b){g.QBLog("[ContentProxy]","getInfo",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFile:function(a,b){g.QBLog("[ContentProxy]","getFile",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFileUrl:function(a,b){g.QBLog("[ContentProxy]","getFileUrl",a),this.service.ajax({url:g.getUrl(f.urls.blobs,a+"/getblobobjectbyid"),type:"POST"},function(a,c){a?b(a,null):b(null,c.blob_object_access.params)})},update:function(a,b){g.QBLog("[ContentProxy]","update",a);var c={};c.blob={},"undefined"!=typeof a.name&&(c.blob.name=a.name),this.service.ajax({url:g.getUrl(f.urls.blobs,a.id),data:c},function(a,c){a?b(a,null):b(null,c)})},privateUrl:function(a){return"https://"+f.endpoints.api+"/blobs/"+a+"?token="+this.service.getSession().token},publicUrl:function(a){return"https://"+f.endpoints.api+"/blobs/"+a}},b.exports=d,e.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},{"../qbConfig":15,"../qbUtils":19,xml2js:165}],4:[function(a,b,c){function d(a){this.service=a}var e=a("../qbConfig"),f=a("../qbUtils"),g="undefined"!=typeof window;d.prototype={create:function(a,b,c){f.QBLog("[DataProxy]","create",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},list:function(a,b,c){"undefined"==typeof c&&"function"==typeof b&&(c=b,b=null),f.QBLog("[DataProxy]","list",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b},function(a,b){a?c(a,null):c(a,b)})},update:function(a,b,c){f.QBLog("[DataProxy]","update",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b._id),data:b,type:"PUT"},function(a,b){a?c(a,null):c(a,b)})},"delete":function(a,b,c){f.QBLog("[DataProxy]","delete",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b),type:"DELETE",dataType:"text"},function(a,b){a?c(a,null):c(a,!0)})},uploadFile:function(a,b,c){f.QBLog("[DataProxy]","uploadFile",a,b);var d;g?(d=new FormData,d.append("field_name",b.field_name),d.append("file",b.file)):(d={},d.field_name=b.field_name,d.file=b.file),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:d,contentType:!1,processData:!1,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},downloadFile:function(a,b,c){f.QBLog("[DataProxy]","downloadFile",a,b);var d=f.getUrl(e.urls.data,a+"/"+b.id+"/file");d+="?field_name="+b.field_name+"&token="+this.service.getSession().token,c(null,d)},deleteFile:function(a,b,c){f.QBLog("[DataProxy]","deleteFile",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:{field_name:b.field_name},dataType:"text",type:"DELETE"},function(a,b){a?c(a,null):c(a,!0)})}},b.exports=d},{"../qbConfig":15,"../qbUtils":19}],5:[function(a,b,c){function d(a){this.service=a,this.geodata=new e(a)}function e(a){this.service=a}var f=a("../qbConfig"),g=a("../qbUtils"),h=f.urls.geodata+"/find";e.prototype={create:function(a,b){g.QBLog("[GeoProxy]","create",a),this.service.ajax({url:g.getUrl(f.urls.geodata),data:{geo_data:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},update:function(a,b){var c,d=["longitude","latitude","status"],e={};for(c in a)a.hasOwnProperty(c)&&d.indexOf(c)>0&&(e[c]=a[c]);g.QBLog("[GeoProxy]","update",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a.id),data:{geo_data:e},type:"PUT"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},get:function(a,b){g.QBLog("[GeoProxy]","get",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a)},function(a,c){a?b(a,null):b(null,c.geo_datum)})},list:function(a,b){"function"==typeof a&&(b=a,a=void 0),g.QBLog("[GeoProxy]","find",a),this.service.ajax({url:g.getUrl(h),data:a},b)},"delete":function(a,b){g.QBLog("[GeoProxy]","delete",a),this.service.ajax({url:g.getUrl(f.urls.geodata,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},purge:function(a,b){g.QBLog("[GeoProxy]","purge",a),this.service.ajax({url:g.getUrl(f.urls.geodata),data:{days:a},type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},b.exports=d},{"../qbConfig":15,"../qbUtils":19}],6:[function(a,b,c){(function(c){function d(a){this.service=a,this.subscriptions=new e(a),this.events=new f(a),this.base64Encode=function(a){return i?btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode("0x"+b)})):new c(a).toString("base64")}}function e(a){this.service=a}function f(a){this.service=a}var g=a("../qbConfig"),h=a("../qbUtils"),i="undefined"!=typeof window;e.prototype={create:function(a,b){h.QBLog("[SubscriptionsProxy]","create",a),this.service.ajax({url:h.getUrl(g.urls.subscriptions),type:"POST",data:a},b)},list:function(a){h.QBLog("[SubscriptionsProxy]","list"),this.service.ajax({url:h.getUrl(g.urls.subscriptions)},a)},"delete":function(a,b){h.QBLog("[SubscriptionsProxy]","delete",a),this.service.ajax({url:h.getUrl(g.urls.subscriptions,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},f.prototype={create:function(a,b){h.QBLog("[EventsProxy]","create",a);var c={event:a};this.service.ajax({url:h.getUrl(g.urls.events),type:"POST",data:c},b)},list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a=null),h.QBLog("[EventsProxy]","list",a),this.service.ajax({url:h.getUrl(g.urls.events),data:a},b)},get:function(a,b){h.QBLog("[EventsProxy]","get",a),this.service.ajax({url:h.getUrl(g.urls.events,a)},b)},status:function(a,b){h.QBLog("[EventsProxy]","status",a),this.service.ajax({url:h.getUrl(g.urls.events,a+"/status")},b)},"delete":function(a,b){h.QBLog("[EventsProxy]","delete",a),this.service.ajax({url:h.getUrl(g.urls.events,a),type:"DELETE"},b)}},b.exports=d}).call(this,a("buffer").Buffer)},{"../qbConfig":15,"../qbUtils":19,buffer:23}],7:[function(a,b,c){function d(a){this.service=a}function e(a){var b=a.field in j?"date":typeof a.value;return(a.value instanceof Array||i.isArray(a.value))&&("object"==b&&(b=typeof a.value[0]),a.value=a.value.toString()),[b,a.field,a.param,a.value].join(" ")}function f(a){var b=a.field in j?"date":a.field in k?"number":"string";return[a.sort,b,a.field].join(" ")}var g=a("../qbConfig"),h=a("../qbUtils"),i=a("util"),j=["created_at","updated_at","last_request_at"],k=["id","external_user_id"],l=g.urls.users+"/password/reset";d.prototype={listUsers:function(a,b){h.QBLog("[UsersProxy]","listUsers",arguments.length>1?a:"");var c,d={},i=[];"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),a.filter&&(a.filter instanceof Array?a.filter.forEach(function(a){c=e(a),i.push(c)}):(c=e(a.filter),i.push(c)),d.filter=i),a.order&&(d.order=f(a.order)),a.page&&(d.page=a.page),a.per_page&&(d.per_page=a.per_page),this.service.ajax({url:h.getUrl(g.urls.users),data:d},b)},get:function(a,b){h.QBLog("[UsersProxy]","get",a);var c;"number"==typeof a?(c=a,a={}):a.login?c="by_login":a.full_name?c="by_full_name":a.facebook_id?c="by_facebook_id":a.twitter_id?c="by_twitter_id":a.email?c="by_email":a.tags?c="by_tags":a.external&&(c="external/"+a.external,a={}),this.service.ajax({url:h.getUrl(g.urls.users,c),data:a},function(a,c){a?b(a,null):b(null,c.user||c)})},create:function(a,b){h.QBLog("[UsersProxy]","create",a),this.service.ajax({url:h.getUrl(g.urls.users),type:"POST",data:{user:a}},function(a,c){a?b(a,null):b(null,c.user)})},update:function(a,b,c){h.QBLog("[UsersProxy]","update",a,b),this.service.ajax({url:h.getUrl(g.urls.users,a),type:"PUT",data:{user:b}},function(a,b){a?c(a,null):c(null,b.user)})},"delete":function(a,b){h.QBLog("[UsersProxy]","delete",a);var c;"number"==typeof a?c=a:a.external&&(c="external/"+a.external),this.service.ajax({url:h.getUrl(g.urls.users,c),type:"DELETE",dataType:"text"},b)},resetPassword:function(a,b){h.QBLog("[UsersProxy]","resetPassword",a),this.service.ajax({url:h.getUrl(l),data:{email:a}},b)}},b.exports=d},{"../qbConfig":15,"../qbUtils":19,util:162}],8:[function(a,b,c){function d(a,b,c,d){navigator.mozGetUserMedia?a.getStats(b,function(a){var b=[];a.forEach(function(a){b.push(a)}),c(b)},d):a.getStats(function(a){var b=[];a.result().forEach(function(a){var c={};a.names().forEach(function(b){c[b]=a.stat(b); +}),c.id=a.id,c.type=a.type,c.timestamp=a.timestamp,b.push(c)}),c(b)})}var e=a("../../qbConfig"),f=a("./qbWebRTCHelpers"),g=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,h=window.RTCSessionDescription||window.mozRTCSessionDescription,i=window.RTCIceCandidate||window.mozRTCIceCandidate;g.State={NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},g.prototype.init=function(a,b,c,d){f.trace("RTCPeerConnection init. userID: "+b+", sessionID: "+c+", type: "+d),this.delegate=a,this.sessionID=c,this.userID=b,this.type=d,this.remoteSDP=null,this.state=g.State.NEW,this.onicecandidate=this.onIceCandidateCallback,this.onaddstream=this.onAddRemoteStreamCallback,this.onsignalingstatechange=this.onSignalingStateCallback,this.oniceconnectionstatechange=this.onIceConnectionStateCallback,this.dialingTimer=null,this.answerTimeInterval=0,this.statsReportTimer=null,this.reconnectTimer=0,this.iceCandidates=[]},g.prototype.release=function(){this._clearDialingTimer(),this._clearStatsReportTimer(),"closed"!==this.signalingState&&this.close()},g.prototype.updateRemoteSDP=function(a){if(!a)throw new Error("sdp string can't be empty.");this.remoteSDP=a},g.prototype.getRemoteSDP=function(){return this.remoteSDP},g.prototype.setRemoteSessionDescription=function(a,b,c){function d(){c(null)}function e(a){c(a)}var f=new h({sdp:b,type:a});this.setRemoteDescription(f,d,e)},g.prototype.addLocalStream=function(a){if(!a)throw new Error("'RTCPeerConnection.addStream' error: stream is 'null'.");this.addStream(a)},g.prototype.getAndSetLocalSessionDescription=function(a){function b(b){d.setLocalDescription(b,function(){a(null)},c)}function c(b){a(b)}var d=this;d.state=g.State.CONNECTING,"offer"===d.type?d.createOffer(b,c):d.createAnswer(b,c)},g.prototype.addCandidates=function(a){for(var b,c=0,d=a.length;d>c;c++)b={sdpMLineIndex:a[c].sdpMLineIndex,sdpMid:a[c].sdpMid,candidate:a[c].candidate},this.addIceCandidate(new i(b),function(){},function(a){f.traceError("Error on 'addIceCandidate': "+a)})},g.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", type: "+this.type+", state: "+this.state},g.prototype.onSignalingStateCallback=function(){"stable"===this.signalingState&&this.iceCandidates.length>0&&(this.delegate.processIceCandidates(this,this.iceCandidates),this.iceCandidates.length=0)},g.prototype.onIceCandidateCallback=function(a){var b=a.candidate;if(b){var c={sdpMLineIndex:b.sdpMLineIndex,sdpMid:b.sdpMid,candidate:b.candidate};"stable"===this.signalingState?this.delegate.processIceCandidates(this,[c]):this.iceCandidates.push(c)}},g.prototype.onAddRemoteStreamCallback=function(a){var b=this;"function"==typeof this.delegate._onRemoteStreamListener&&this.delegate._onRemoteStreamListener(this.userID,a.stream),b._getStatsWrap()},g.prototype.onIceConnectionStateCallback=function(){var a=this.iceConnectionState;if(f.trace("onIceConnectionStateCallback: "+this.iceConnectionState),"function"==typeof this.delegate._onSessionConnectionStateChangedListener){var b=null;"checking"===a?(this.state=g.State.CHECKING,b=f.SessionConnectionState.CONNECTING):"connected"===a?(this._clearWaitingReconnectTimer(),this.state=g.State.CONNECTED,b=f.SessionConnectionState.CONNECTED):"completed"===a?(this._clearWaitingReconnectTimer(),this.state=g.State.COMPLETED,b=f.SessionConnectionState.COMPLETED):"failed"===a?(this.state=g.State.FAILED,b=f.SessionConnectionState.FAILED):"disconnected"===a?(this._startWaitingReconnectTimer(),this.state=g.State.DISCONNECTED,b=f.SessionConnectionState.DISCONNECTED):"closed"===a&&(this.state=g.State.CLOSED,b=f.SessionConnectionState.CLOSED),b&&this.delegate._onSessionConnectionStateChangedListener(this.userID,b)}},g.prototype._clearStatsReportTimer=function(){this.statsReportTimer&&(clearInterval(this.statsReportTimer),this.statsReportTimer=null)},g.prototype._getStatsWrap=function(){var a,b=this,c=1==b.delegate.callType?b.getLocalStreams()[0].getVideoTracks()[0]:b.getLocalStreams()[0].getAudioTracks()[0];if(e.webrtc||e.webrtc.statsReportTimeInterval){if(isNaN(+e.webrtc.statsReportTimeInterval))return void f.traceError("statsReportTimeInterval ("+e.webrtc.statsReportTimeInterval+") must be integer.");a=1e3*e.webrtc.statsReportTimeInterval;var g=function(){d(b,c,function(a){b.delegate._onCallStatsReport(b.userID,a)},function(a){f.traceError("_getStats error. "+a.name+": "+a.message)})};f.trace("Stats tracker has been started."),b.statsReportTimer=setInterval(g,a)}},g.prototype._clearWaitingReconnectTimer=function(){this.waitingReconnectTimeoutCallback&&(f.trace("_clearWaitingReconnectTimer"),clearTimeout(this.waitingReconnectTimeoutCallback),this.waitingReconnectTimeoutCallback=null)},g.prototype._startWaitingReconnectTimer=function(){var a=this,b=1e3*e.webrtc.disconnectTimeInterval,c=function(){f.trace("waitingReconnectTimeoutCallback"),clearTimeout(a.waitingReconnectTimeoutCallback),a.release(),a.delegate._closeSessionIfAllConnectionsClosed()};f.trace("_startWaitingReconnectTimer, timeout: "+b),a.waitingReconnectTimeoutCallback=setTimeout(c,b)},g.prototype._clearDialingTimer=function(){this.dialingTimer&&(f.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},g.prototype._startDialingTimer=function(a,b){var c=this,d=1e3*e.webrtc.dialingTimeInterval;f.trace("_startDialingTimer, dialingTimeInterval: "+d);var g=function(a,b,d){d||(c.answerTimeInterval+=1e3*e.webrtc.dialingTimeInterval),f.trace("_dialingCallback, answerTimeInterval: "+c.answerTimeInterval),c.answerTimeInterval>=1e3*e.webrtc.answerTimeInterval?(c._clearDialingTimer(),b&&c.delegate.processOnNotAnswer(c)):c.delegate.processCall(c,a)};c.dialingTimer=setInterval(g,d,a,b,!1),g(a,b,!0)},b.exports=g},{"../../qbConfig":15,"./qbWebRTCHelpers":10}],9:[function(a,b,c){function d(a,b){return d.__instance?d.__instance:this===window?new d:(d.__instance=this,this.connection=b,this.signalingProcessor=new h(a,this,b),this.signalingProvider=new i(a,b),this.SessionConnectionState=j.SessionConnectionState,this.CallType=j.CallType,this.PeerConnectionState=k.State,void(this.sessions={}))}function e(a,b){var c=!1,d=b.sort();return a.length&&a.forEach(function(a){var b=a.sort();c=b.length==d.length&&b.every(function(a,b){return a===d[b]})}),c}function f(a){var b=[];return Object.keys(a).length>0&&Object.keys(a).forEach(function(c,d,e){var f=a[c];(f.state===g.State.NEW||f.state===g.State.ACTIVE)&&b.push(f.opponentsIDs)}),b}var g=a("./qbWebRTCSession"),h=a("./qbWebRTCSignalingProcessor"),i=a("./qbWebRTCSignalingProvider"),j=a("./qbWebRTCHelpers"),k=a("./qbRTCPeerConnection"),l=a("./qbWebRTCSignalingConstants"),m=a("../../qbUtils");d.prototype.sessions={},d.prototype.createNewSession=function(a,b,c){var d=f(this.sessions),g=c||j.getIdFromNode(this.connection.jid),h=!1,i=b||2;if(!a)throw new Error("Can't create a session without the opponentsIDs.");if(h=e(d,a))throw new Error("Can't create a session with the same opponentsIDs. There is a session already in NEW or ACTIVE state.");return this._createAndStoreSession(null,g,a,i)},d.prototype._createAndStoreSession=function(a,b,c,d){var e=new g(a,b,c,d,this.signalingProvider,j.getIdFromNode(this.connection.jid));return e.onUserNotAnswerListener=this.onUserNotAnswerListener,e.onRemoteStreamListener=this.onRemoteStreamListener,e.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,e.onSessionCloseListener=this.onSessionCloseListener,e.onCallStatsReport=this.onCallStatsReport,this.sessions[e.ID]=e,e},d.prototype.clearSession=function(a){delete d.sessions[a]},d.prototype.isExistNewOrActiveSessionExceptSessionID=function(a){var b=this,c=!1;return Object.keys(b.sessions).length>0&&Object.keys(b.sessions).forEach(function(d,e,f){var h=b.sessions[d];(h.state===g.State.NEW||h.state===g.State.ACTIVE)&&h.ID!==a&&(c=!0)}),c},d.prototype._onCallListener=function(a,b,c){if(j.trace("onCall. UserID:"+a+". SessionID: "+b),this.isExistNewOrActiveSessionExceptSessionID(b))j.trace("User with id "+a+" is busy at the moment."),delete c.sdp,delete c.platform,c.sessionID=b,this.signalingProvider.sendMessage(a,c,l.SignalingType.REJECT);else{var d=this.sessions[b];if(!d){d=this._createAndStoreSession(b,c.callerID,c.opponentsIDs,c.callType);var e=JSON.parse(JSON.stringify(c));this._cleanupExtension(e),"function"==typeof this.onCallListener&&m.safeCallbackCall(this.onCallListener,d,e)}d.processOnCall(a,c)}},d.prototype._onAcceptListener=function(a,b,c){var d=this.sessions[b];if(j.trace("onAccept. UserID:"+a+". SessionID: "+b),d)if(d.state===g.State.ACTIVE){var e=JSON.parse(JSON.stringify(c));this._cleanupExtension(e),"function"==typeof this.onAcceptCallListener&&m.safeCallbackCall(this.onAcceptCallListener,d,a,e),d.processOnAccept(a,c)}else j.traceWarning("Ignore 'onAccept', the session( "+b+" ) has invalid state.");else j.traceError("Ignore 'onAccept', there is no information about session "+b+" by some reason.")},d.prototype._onRejectListener=function(a,b,c){var d=this,e=d.sessions[b];if(j.trace("onReject. UserID:"+a+". SessionID: "+b),e){var f=JSON.parse(JSON.stringify(c));d._cleanupExtension(f),"function"==typeof this.onRejectCallListener&&m.safeCallbackCall(d.onRejectCallListener,e,a,f),e.processOnReject(a,c)}else j.traceError("Ignore 'onReject', there is no information about session "+b+" by some reason.")},d.prototype._onStopListener=function(a,b,c){j.trace("onStop. UserID:"+a+". SessionID: "+b);var d=this.sessions[b],e=JSON.parse(JSON.stringify(c));!d||d.state!==g.State.ACTIVE&&d.state!==g.State.NEW?j.traceError("Ignore 'onStop', there is no information about session "+b+" by some reason."):(this._cleanupExtension(e),"function"==typeof this.onStopCallListener&&m.safeCallbackCall(this.onStopCallListener,d,a,e),d.processOnStop(a,c))},d.prototype._onIceCandidatesListener=function(a,b,c){var d=this.sessions[b];j.trace("onIceCandidates. UserID:"+a+". SessionID: "+b+". ICE candidates count: "+c.iceCandidates.length),d?d.state===g.State.ACTIVE?d.processOnIceCandidates(a,c):j.traceWarning("Ignore 'OnIceCandidates', the session ( "+b+" ) has invalid state."):j.traceError("Ignore 'OnIceCandidates', there is no information about session "+b+" by some reason.")},d.prototype._onUpdateListener=function(a,b,c){var d=this.sessions[b];j.trace("onUpdate. UserID:"+a+". SessionID: "+b+". Extension: "+JSON.stringify(c)),"function"==typeof this.onUpdateCallListener&&m.safeCallbackCall(this.onUpdateCallListener,d,a,c)},d.prototype._cleanupExtension=function(a){delete a.platform,delete a.sdp,delete a.opponentsIDs,delete a.callerID,delete a.callType},b.exports=d},{"../../qbUtils":19,"./qbRTCPeerConnection":8,"./qbWebRTCHelpers":10,"./qbWebRTCSession":11,"./qbWebRTCSignalingConstants":12,"./qbWebRTCSignalingProcessor":13,"./qbWebRTCSignalingProvider":14}],10:[function(a,b,c){var d=a("../../qbConfig"),e={};e={getUserJid:function(a,b){return a+"-"+b+"@"+d.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])},trace:function(a){d.debug&&console.log("[QBWebRTC]:",a)},traceWarning:function(a){d.debug&&console.warn("[QBWebRTC]:",a)},traceError:function(a){d.debug&&console.error("[QBWebRTC]:",a)},getLocalTime:function(){var a=(new Date).toString().split(" ");return a.slice(1,5).join("-")},dataURItoBlob:function(a,b){for(var c=[],d=window.atob(a.split(",")[1]),e=0,f=d.length;f>e;e++)c.push(d.charCodeAt(e));return new Blob([new Uint8Array(c)],{type:b})}},e.SessionConnectionState={UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},e.CallType={VIDEO:1,AUDIO:2},b.exports=e},{"../../qbConfig":15}],11:[function(a,b,c){function d(a,b,c,f,g,h){this.ID=a?a:e(),this.state=d.State.NEW,this.initiatorID=parseInt(b),this.opponentsIDs=c,this.callType=parseInt(f),this.peerConnections={},this.localStream=null,this.signalingProvider=g,this.currentUserID=h,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0}function e(){var a=(new Date).getTime(),b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var c=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"==b?c:3&c|8).toString(16)});return b}function f(a){try{return JSON.parse(JSON.stringify(a).replace(/null/g,'""'))}catch(b){return{}}}function g(a){var b=JSON.parse(JSON.stringify(a));return Object.keys(b).forEach(function(a,c,d){b[c].hasOwnProperty("url")?b[c].urls=b[c].url:b[c].url=b[c].urls}),b}var h=a("../../qbConfig"),i=a("./qbRTCPeerConnection"),j=a("../../qbUtils"),k=a("./qbWebRTCHelpers"),l=a("./qbWebRTCSignalingConstants");d.State={NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5},d.prototype.getUserMedia=function(a,b){var c=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;if(!c)throw new Error("getUserMedia() is not supported in your browser");c=c.bind(navigator);var d=this;c({audio:a.audio||!1,video:a.video||!1},function(c){d.localStream=c,a.elemId&&d.attachMediaStream(a.elemId,c,a.options),b(null,c)},function(a){b(a,null)})},d.prototype.attachMediaStream=function(a,b,c){var d=document.getElementById(a);if(!d)throw new Error("Unable to attach media stream, element "+a+" is undefined");var e=window.URL||window.webkitURL;d.src=e.createObjectURL(b),c&&c.muted&&(d.muted=!0),c&&c.mirror&&(d.style.webkitTransform="scaleX(-1)",d.style.transform="scaleX(-1)"),d.play()},d.prototype.connectionStateForUser=function(a){var b=this.peerConnections[a];return b?b.state:null},d.prototype.detachMediaStream=function(a){var b=document.getElementById(a);b&&(b.pause(),b.src="")},d.prototype.call=function(a,b){var c=this,e=f(a),g=window.navigator.onLine,h=null;k.trace("Call, extension: "+JSON.stringify(e)),g?(c.state=d.State.ACTIVE,c.opponentsIDs.forEach(function(a,b,d){c._callInternal(a,e,!0)})):(c.state=d.State.CLOSED,h=j.getError(408,"Call.ERROR - ERR_INTERNET_DISCONNECTED")),"function"==typeof b&&b(h)},d.prototype._callInternal=function(a,b,c){var d=this._createPeer(a,"offer");d.addLocalStream(this.localStream),this.peerConnections[a]=d,d.getAndSetLocalSessionDescription(function(a){a?k.trace("getAndSetLocalSessionDescription error: "+a):(k.trace("getAndSetLocalSessionDescription success"),d._startDialingTimer(b,c))})},d.prototype.accept=function(a){var b=this,c=f(a);if(k.trace("Accept, extension: "+JSON.stringify(c)),b.state===d.State.ACTIVE)return void k.traceError("Can't accept, the session is already active, return.");if(b.state===d.State.CLOSED)return k.traceError("Can't accept, the session is already closed, return."),void b.stop({});b.state=d.State.ACTIVE,b.acceptCallTime=new Date,b._clearAnswerTimer(),b._acceptInternal(b.initiatorID,c);var e=b._uniqueOpponentsIDsWithoutInitiator();if(e.length>0){var g=(b.acceptCallTime-b.startCallTime)/1e3;b._startWaitingOfferOrAnswerTimer(g),e.forEach(function(a,c,d){b.currentUserID>a&&b._callInternal(a,{},!0)})}},d.prototype._acceptInternal=function(a,b){var c=this,d=this.peerConnections[a];d?(d.addLocalStream(this.localStream),d.setRemoteSessionDescription("offer",d.getRemoteSDP(),function(e){e?k.traceError("'setRemoteSessionDescription' error: "+e):(k.trace("'setRemoteSessionDescription' success"),d.getAndSetLocalSessionDescription(function(e){e?k.trace("getAndSetLocalSessionDescription error: "+e):(b.sessionID=c.ID,b.callType=c.callType,b.callerID=c.initiatorID,b.opponentsIDs=c.opponentsIDs,b.sdp=d.localDescription.sdp,c.signalingProvider.sendMessage(a,b,l.SignalingType.ACCEPT))}))})):k.traceError("Can't accept the call, there is no information about peer connection by some reason.")},d.prototype.reject=function(a){var b=this,c=f(a),e=Object.keys(b.peerConnections).length;if(k.trace("Reject, extension: "+JSON.stringify(c)),b.state=d.State.REJECTED,b._clearAnswerTimer(),c.sessionID=b.ID,c.callType=b.callType,c.callerID=b.initiatorID,c.opponentsIDs=b.opponentsIDs,e>0)for(var g in b.peerConnections){var h=b.peerConnections[g];b.signalingProvider.sendMessage(h.userID,c,l.SignalingType.REJECT)}b._close()},d.prototype.stop=function(a){var b=this,c=f(a),e=Object.keys(b.peerConnections).length;if(k.trace("Stop, extension: "+JSON.stringify(c)),b.state=d.State.HUNGUP,b._clearAnswerTimer(),c.sessionID=b.ID,c.callType=b.callType,c.callerID=b.initiatorID,c.opponentsIDs=b.opponentsIDs,e>0)for(var g in b.peerConnections){var h=b.peerConnections[g];b.signalingProvider.sendMessage(h.userID,c,l.SignalingType.STOP)}b._close()},d.prototype.closeConnection=function(a){var b=this,c=this.peerConnections[a];c?(c.release(),b._closeSessionIfAllConnectionsClosed()):k.traceWarn("Not found connection with user ("+a+")")},d.prototype.update=function(a){var b=this,c={};if(k.trace("Update, extension: "+JSON.stringify(a)),null==a)return void k.trace("extension is null, no parameters to update");c=f(a),c.sessionID=this.ID;for(var d in b.peerConnections){var e=b.peerConnections[d];b.signalingProvider.sendMessage(e.userID,c,l.SignalingType.PARAMETERS_CHANGED)}},d.prototype.mute=function(a){this._muteStream(0,a)},d.prototype.unmute=function(a){this._muteStream(1,a)},d.snapshot=function(a){var b,c,d=document.getElementById(a),e=document.createElement("canvas"),f=e.getContext("2d");return d?(e.width=d.clientWidth,e.height=d.clientHeight,"scaleX(-1)"===d.style.transform&&(f.translate(e.width,0),f.scale(-1,1)),f.drawImage(d,0,0,d.clientWidth,d.clientHeight),b=e.toDataURL(),c=k.dataURItoBlob(b,"image/png"),c.name="snapshot_"+getLocalTime()+".png",c.url=b,c):void 0},d.filter=function(a,b){var c=document.getElementById(a);c&&(c.style.webkitFilter=b,c.style.filter=b)},d.prototype.processOnCall=function(a,b){var c=this,e=c._uniqueOpponentsIDs();e.forEach(function(e,f,g){var h=c.peerConnections[e];if(h)e==a&&(h.updateRemoteSDP(b.sdp),a!=c.initiatorID&&c.state===d.State.ACTIVE&&c._acceptInternal(a,{}));else{var i;i=e!=a&&c.currentUserID>e?c._createPeer(e,"offer"):c._createPeer(e,"answer"),c.peerConnections[e]=i,e==a&&(i.updateRemoteSDP(b.sdp),c._startAnswerTimer())}})},d.prototype.processOnAccept=function(a,b){var c=this.peerConnections[a];c?(c._clearDialingTimer(),c.setRemoteSessionDescription("answer",b.sdp,function(a){a?k.traceError("'setRemoteSessionDescription' error: "+a):k.trace("'setRemoteSessionDescription' success")})):k.traceError("Ignore 'OnAccept', there is no information about peer connection by some reason.")},d.prototype.processOnReject=function(a,b){var c=this.peerConnections[a];this._clearWaitingOfferOrAnswerTimer(),c?c.release():k.traceError("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnStop=function(a,b){var c=this;if(this._clearAnswerTimer(),a===c.initiatorID)Object.keys(c.peerConnections).length?Object.keys(c.peerConnections).forEach(function(a){c.peerConnections[a].release()}):k.traceError("Ignore 'OnStop', there is no information about peer connections by some reason.");else{var d=c.peerConnections[a];d?d.release():k.traceError("Ignore 'OnStop', there is no information about peer connection by some reason.")}this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnIceCandidates=function(a,b){var c=this.peerConnections[a];c?c.addCandidates(b.iceCandidates):k.traceError("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")},d.prototype.processCall=function(a,b){var b=b||{};b.sessionID=this.ID,b.callType=this.callType,b.callerID=this.initiatorID,b.opponentsIDs=this.opponentsIDs,b.sdp=a.localDescription.sdp,this.signalingProvider.sendMessage(a.userID,b,l.SignalingType.CALL)},d.prototype.processIceCandidates=function(a,b){var c={};c.sessionID=this.ID,c.callType=this.callType,c.callerID=this.initiatorID,c.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(a.userID,b,c)},d.prototype.processOnNotAnswer=function(a){k.trace("Answer timeout callback for session "+this.ID+" for user "+a.userID),this._clearWaitingOfferOrAnswerTimer(),a.release(),"function"==typeof this.onUserNotAnswerListener&&j.safeCallbackCall(this.onUserNotAnswerListener,this,a.userID),this._closeSessionIfAllConnectionsClosed()},d.prototype._onRemoteStreamListener=function(a,b){"function"==typeof this.onRemoteStreamListener&&j.safeCallbackCall(this.onRemoteStreamListener,this,a,b)},d.prototype._onCallStatsReport=function(a,b){"function"==typeof this.onCallStatsReport&&j.safeCallbackCall(this.onCallStatsReport,this,a,b)},d.prototype._onSessionConnectionStateChangedListener=function(a,b){var c=this;"function"==typeof c.onSessionConnectionStateChangedListener&&j.safeCallbackCall(c.onSessionConnectionStateChangedListener,c,a,b)},d.prototype._createPeer=function(a,b){if(!i)throw new Error("_createPeer error: RTCPeerConnection() is not supported in your browser");this.startCallTime=new Date;var c={iceServers:g(h.webrtc.iceServers)};k.trace("_createPeer, iceServers: "+JSON.stringify(c));var d=new i(c);return d.init(this,a,this.ID,b),d},d.prototype._close=function(){k.trace("_close");for(var a in this.peerConnections){var b=this.peerConnections[a];b.release()}this._closeLocalMediaStream(),this.state=d.State.CLOSED,"function"==typeof this.onSessionCloseListener&&j.safeCallbackCall(this.onSessionCloseListener,this)},d.prototype._closeSessionIfAllConnectionsClosed=function(){var a=!0;for(var b in this.peerConnections){var c=this.peerConnections[b];if("closed"!==c.signalingState){a=!1;break}}k.trace("All peer connections closed: "+a),a&&(this._closeLocalMediaStream(),"function"==typeof this.onSessionCloseListener&&this.onSessionCloseListener(this),this.state=d.State.CLOSED)},d.prototype._closeLocalMediaStream=function(){this.localStream&&(this.localStream.getAudioTracks().forEach(function(a){a.stop()}),this.localStream.getVideoTracks().forEach(function(a){a.stop()}),this.localStream=null)},d.prototype._muteStream=function(a,b){return"audio"===b&&this.localStream.getAudioTracks().length>0?void this.localStream.getAudioTracks().forEach(function(b){b.enabled=!!a}):"video"===b&&this.localStream.getVideoTracks().length>0?void this.localStream.getVideoTracks().forEach(function(b){b.enabled=!!a}):void 0},d.prototype._clearAnswerTimer=function(){this.answerTimer&&(k.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)},d.prototype._startAnswerTimer=function(){k.trace("_startAnswerTimer");var a=this,b=function(){k.trace("_answerTimeoutCallback"),"function"==typeof a.onSessionCloseListener&&a._close(),a.answerTimer=null},c=1e3*h.webrtc.answerTimeInterval;this.answerTimer=setTimeout(b,c)},d.prototype._clearWaitingOfferOrAnswerTimer=function(){this.waitingOfferOrAnswerTimer&&(k.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)},d.prototype._startWaitingOfferOrAnswerTimer=function(a){var b=this,c=h.webrtc.answerTimeInterval-a<0?1:h.webrtc.answerTimeInterval-a,d=function(){k.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(b.peerConnections).length>0&&Object.keys(b.peerConnections).forEach(function(a){var c=b.peerConnections[a];(c.state===i.State.CONNECTING||c.state===i.State.NEW)&&b.processOnNotAnswer(c)}),b.waitingOfferOrAnswerTimer=null};k.trace("_startWaitingOfferOrAnswerTimer, timeout: "+c),this.waitingOfferOrAnswerTimer=setTimeout(d,1e3*c)},d.prototype._uniqueOpponentsIDs=function(){var a=this,b=[];return this.initiatorID!==this.currentUserID&&b.push(this.initiatorID),this.opponentsIDs.forEach(function(c,d,e){c!=a.currentUserID&&b.push(parseInt(c))}),b},d.prototype._uniqueOpponentsIDsWithoutInitiator=function(){var a=this,b=[];return this.opponentsIDs.forEach(function(c,d,e){c!=a.currentUserID&&b.push(parseInt(c))}),b},d.prototype.toString=function(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType},b.exports=d},{"../../qbConfig":15,"../../qbUtils":19,"./qbRTCPeerConnection":8,"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12}],12:[function(a,b,c){function d(){}d.MODULE_ID="WebRTCVideoChat",d.SignalingType={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},b.exports=d},{}],13:[function(a,b,c){function d(a,b,c){var d=this;d.service=a,d.delegate=b,d.connection=c,this._onMessage=function(a){var b=a.getAttribute("from"),c=a.querySelector("extraParams"),g=a.querySelector("delay"),h=e.getIdFromNode(b),i=d._getExtension(c);if(g||i.moduleIdentifier!==f.MODULE_ID)return!0;var j=i.sessionID,k=i.signalType;switch(delete i.moduleIdentifier,delete i.sessionID,delete i.signalType,k){case f.SignalingType.CALL:"function"==typeof d.delegate._onCallListener&&d.delegate._onCallListener(h,j,i);break;case f.SignalingType.ACCEPT:"function"==typeof d.delegate._onAcceptListener&&d.delegate._onAcceptListener(h,j,i);break;case f.SignalingType.REJECT:"function"==typeof d.delegate._onRejectListener&&d.delegate._onRejectListener(h,j,i);break;case f.SignalingType.STOP:"function"==typeof d.delegate._onStopListener&&d.delegate._onStopListener(h,j,i);break;case f.SignalingType.CANDIDATE:"function"==typeof d.delegate._onIceCandidatesListener&&d.delegate._onIceCandidatesListener(h,j,i);break;case f.SignalingType.PARAMETERS_CHANGED:"function"==typeof d.delegate._onUpdateListener&&d.delegate._onUpdateListener(h,j,i)}return!0},this._getExtension=function(a){if(!a)return null;for(var b,c,e,f,g={},h=[],i=[],j=0,k=a.childNodes.length;k>j;j++)if("iceCandidates"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var l=0,m=e.length;m>l;l++){b={},f=e[l].childNodes;for(var n=0,o=f.length;o>n;n++)b[f[n].tagName]=f[n].textContent;h.push(b)}}else if("opponentsIDs"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var p=0,q=e.length;q>p;p++)c=e[p].textContent,i.push(parseInt(c))}else if(a.childNodes[j].childNodes.length>1){var r=a.childNodes[j].textContent.length;if(r>4096){for(var s="",t=0;t0&&(g.iceCandidates=h),i.length>0&&(g.opponentsIDs=i),g},this._XMLtoJS=function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a}}a("strophe");var e=a("./qbWebRTCHelpers"),f=a("./qbWebRTCSignalingConstants");b.exports=d},{"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12,strophe:159}],14:[function(a,b,c){function d(a,b){this.service=a,this.connection=b}a("strophe");var e=a("./qbWebRTCHelpers"),f=a("./qbWebRTCSignalingConstants"),g=a("../../qbUtils"),h=a("../../qbConfig");d.prototype.sendCandidate=function(a,b,c){var d=c||{};d.iceCandidates=b,this.sendMessage(a,d,f.SignalingType.CANDIDATE)},d.prototype.sendMessage=function(a,b,c){var d,i,j=b||{},k=this;j.moduleIdentifier=f.MODULE_ID,j.signalType=c,j.platform="web",i={to:e.getUserJid(a,h.creds.appId),type:"headline",id:g.getBsonObjectId()},d=$msg(i).c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(j).forEach(function(a){"iceCandidates"===a?(d=d.c("iceCandidates"),j[a].forEach(function(a){d=d.c("iceCandidate"),Object.keys(a).forEach(function(b){d.c(b).t(a[b]).up()}),d.up()}),d.up()):"opponentsIDs"===a?(d=d.c("opponentsIDs"),j[a].forEach(function(a){d=d.c("opponentID").t(a).up()}),d.up()):"object"==typeof j[a]?k._JStoXML(a,j[a],d):d.c(a).t(j[a]).up()}),this.connection.send(d)},d.prototype._JStoXML=function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},b.exports=d},{"../../qbConfig":15,"../../qbUtils":19,"./qbWebRTCHelpers":10,"./qbWebRTCSignalingConstants":12,strophe:159}],15:[function(a,b,c){var d={version:"2.1.0",creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com"},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},webrtc:{answerTimeInterval:60,dialingTimeInterval:5,disconnectTimeInterval:30,statsReportTimeInterval:10,iceServers:[{url:"stun:stun.l.google.com:19302"},{url:"stun:turn.quickblox.com",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnsingapor.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnsingapore.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnireland.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turnireland.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"}]},urls:{session:"session",login:"login",users:"users",chat:"chat",blobs:"blobs",geodata:"geodata",pushtokens:"push_tokens",subscriptions:"subscriptions",events:"events",data:"data",type:".json"},on:{sessionExpired:null},timeout:null,debug:{mode:0,file:null},addISOTime:!1};d.set=function(a){"object"==typeof a.endpoints&&a.endpoints.chat&&(d.endpoints.muc="muc."+a.endpoints.chat,d.chatProtocol.bosh="https://"+a.endpoints.chat+":5281",d.chatProtocol.websocket="wss://"+a.endpoints.chat+":5291"),Object.keys(a).forEach(function(b){"set"!==b&&d.hasOwnProperty(b)&&("object"!=typeof a[b]?d[b]=a[b]:Object.keys(a[b]).forEach(function(c){d[b].hasOwnProperty(c)&&(d[b][c]=a[b][c])})),"iceServers"===b&&(d.webrtc.iceServers=a[b])})},b.exports=d},{}],16:[function(a,b,c){function d(){}var e=a("./qbConfig"),f=a("./qbUtils"),g="undefined"!=typeof window;d.prototype={init:function(b,c,d,h){h&&"object"==typeof h&&e.set(h);var i=a("./qbProxy");this.service=new i;var j,k=a("./modules/qbAuth"),l=a("./modules/qbUsers"),m=a("./modules/qbChat"),n=a("./modules/qbContent"),o=a("./modules/qbLocation"),p=a("./modules/qbPushNotifications"),q=a("./modules/qbData");if(g){var r=a("./qbStrophe");if(j=new r,f.isWebRTCAvailble()){var s=a("./modules/webrtc/qbWebRTCClient");this.webrtc=new s(this.service,j||null)}else this.webrtc=!1}else this.webrtc=!1;this.auth=new k(this.service),this.users=new l(this.service),this.chat=new m(this.service,this.webrtc?this.webrtc.signalingProcessor:null,j||null),this.content=new n(this.service),this.location=new o(this.service),this.pushnotifications=new p(this.service),this.data=new q(this.service),"string"!=typeof b||c&&"number"!=typeof c||d?(e.creds.appId=b,e.creds.authKey=c,e.creds.authSecret=d):("number"==typeof c&&(e.creds.appId=c),this.service.setSession({token:b}))},getSession:function(a){this.auth.getSession(a)},createSession:function(a,b){this.auth.createSession(a,b)},destroySession:function(a){this.auth.destroySession(a)},login:function(a,b){this.auth.login(a,b)},logout:function(a){this.auth.logout(a)}};var h=new d;h.QuickBlox=d,b.exports=h},{"./modules/qbAuth":1,"./modules/qbChat":2,"./modules/qbContent":3,"./modules/qbData":4,"./modules/qbLocation":5,"./modules/qbPushNotifications":6,"./modules/qbUsers":7,"./modules/webrtc/qbWebRTCClient":9,"./qbConfig":15,"./qbProxy":17,"./qbStrophe":18,"./qbUtils":19}],17:[function(a,b,c){function d(){this.qbInst={config:e,session:null}}var e=a("./qbConfig"),f=a("./qbUtils"),g=e.version,h="undefined"!=typeof window;if(!h)var i=a("request");var j=h&&window.jQuery&&window.jQuery.ajax||h&&window.Zepto&&window.Zepto.ajax;if(h&&!j)throw new Error("Quickblox requires jQuery or Zepto");d.prototype={setSession:function(a){this.qbInst.session=a},getSession:function(){return this.qbInst.session},handleResponse:function(a,b,c,d){!a||"function"!=typeof e.on.sessionExpired||"Unauthorized"!==a.message&&"401 Unauthorized"!==a.status?a?c(a,null):(e.addISOTime&&(b=f.injectISOTimes(b)), +c(null,b)):e.on.sessionExpired(function(){c(a,b)},d)},ajax:function(a,b){var c;a.data&&a.data.file?(c=JSON.parse(JSON.stringify(a)),c.data.file="..."):c=a,f.QBLog("[ServiceProxy]","Request: ",a.type||"GET",{data:JSON.stringify(c)});var d=this,k=function(c){c&&d.setSession(c),d.ajax(a,b)},l={url:a.url,type:a.type||"GET",dataType:a.dataType||"json",data:a.data||" ",timeout:e.timeout,beforeSend:function(a,b){-1===b.url.indexOf("s3.amazonaws.com")&&d.qbInst.session&&d.qbInst.session.token&&(a.setRequestHeader("QB-Token",d.qbInst.session.token),a.setRequestHeader("QB-SDK","JS "+g+" - Client"))},success:function(c,g,h){f.QBLog("[ServiceProxy]","Response: ",{data:JSON.stringify(c)}),-1===a.url.indexOf(e.urls.session)?d.handleResponse(null,c,b,k):b(null,c)},error:function(c,g,h){f.QBLog("[ServiceProxy]","ajax error",c.status,h,c.responseText);var i={code:c.status,status:g,message:h,detail:c.responseText};-1===a.url.indexOf(e.urls.session)?d.handleResponse(i,null,b,k):b(i,null)}};if(!h)var m="json"===l.dataType,n=-1===a.url.indexOf("s3.amazonaws.com")&&d.qbInst&&d.qbInst.session&&d.qbInst.session.token||!1,o={url:l.url,method:l.type,timeout:e.timeout,json:m?l.data:null,headers:n?{"QB-Token":d.qbInst.session.token,"QB-SDK":"JS "+g+" - Server"}:null},p=function(a,c,f){if(a||200!==c.statusCode&&201!==c.statusCode&&202!==c.statusCode){var g;try{g={code:c&&c.statusCode||a&&a.code,status:c&&c.headers&&c.headers.status||"error",message:f||a&&a.errno,detail:f&&f.errors||a&&a.syscall}}catch(h){g=a}-1===o.url.indexOf(e.urls.session)?d.handleResponse(g,null,b,k):b(g,null)}else-1===o.url.indexOf(e.urls.session)?d.handleResponse(null,f,b,k):b(null,f)};if(("boolean"==typeof a.contentType||"string"==typeof a.contentType)&&(l.contentType=a.contentType),"boolean"==typeof a.processData&&(l.processData=a.processData),h)j(l);else{var q=i(o,p);if(!m){var r=q.form();Object.keys(l.data).forEach(function(a,b,c){r.append(a,l.data[a])})}}}},b.exports=d},{"./qbConfig":15,"./qbUtils":19,request:22}],18:[function(a,b,c){function d(){var a=1===e.chatProtocol.active?e.chatProtocol.bosh:e.chatProtocol.websocket,b=new Strophe.Connection(a);return 1===e.chatProtocol.active?(b.xmlInput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)f.QBLog("[QBChat]","RECV:",a.childNodes[b])},b.xmlOutput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)f.QBLog("[QBChat]","SENT:",a.childNodes[b])}):(b.xmlInput=function(a){f.QBLog("[QBChat]","RECV:",a)},b.xmlOutput=function(a){f.QBLog("[QBChat]","SENT:",a)}),b}a("strophe");var e=a("./qbConfig"),f=a("./qbUtils");b.exports=d},{"./qbConfig":15,"./qbUtils":19,strophe:159}],19:[function(a,b,c){var d=a("./qbConfig"),e="undefined"!=typeof window,f="This function isn't supported outside of the browser (...yet)";if(!e)var g=a("fs");var h={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0},i={safeCallbackCall:function(){if(!e)throw f;for(var a,b=arguments[0].toString(),c=b.split("(")[0].split(" ")[1],d=[],g=0;g16777215&&(h.increment=0),"00000000".substr(0,8-a.length)+a+"000000".substr(0,6-h.machine.length)+h.machine+"0000".substr(0,4-h.pid.length)+h.pid+"000000".substr(0,6-b.length)+b},injectISOTimes:function(a){if(a.created_at)"number"==typeof a.created_at&&(a.iso_created_at=new Date(1e3*a.created_at).toISOString()),"number"==typeof a.updated_at&&(a.iso_updated_at=new Date(1e3*a.updated_at).toISOString());else if(a.items)for(var b=0,c=a.items.length;c>b;++b)"number"==typeof a.items[b].created_at&&(a.items[b].iso_created_at=new Date(1e3*a.items[b].created_at).toISOString()),"number"==typeof a.items[b].updated_at&&(a.items[b].iso_updated_at=new Date(1e3*a.items[b].updated_at).toISOString());return a},QBLog:function(){if(this.loggers)for(var a=0;ab?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],21:[function(a,b,c){},{}],22:[function(a,b,c){arguments[4][21][0].apply(c,arguments)},{dup:21}],23:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,0>b?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;b>c;c++)a[c]=0;return a}function h(a,b,c){("string"!=typeof c||""===c)&&(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;d>e;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),0>b&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;c>e;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(c>=e+h){var i,j,k,l;switch(h){case 1:128>f&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(55296>l||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&1114112>l&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if($>=b)return String.fromCharCode.apply(String,a);for(var c="",d=0;b>d;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;fa)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||g>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return 16>a?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(1114112>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);g>e&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),d>c?-1:c>d?1:0},f.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),""},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(0>c||0>b)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,void 0);for(var g=0;e>g;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=0>a?1:0;for(this[b]=255&a;++f>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=0>a?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&c>d&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>d)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-bc&&d>b)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(1e3>g||!f.TYPED_ARRAY_SUPPORT)for(e=0;g>e;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":20,ieee754:31,isarray:24}],24:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],25:[function(a,b,c){(function(a){function b(a){return Array.isArray?Array.isArray(a):"[object Array]"===q(a)}function d(a){return"boolean"==typeof a}function e(a){return null===a}function f(a){return null==a}function g(a){return"number"==typeof a}function h(a){return"string"==typeof a}function i(a){return"symbol"==typeof a}function j(a){return void 0===a}function k(a){return"[object RegExp]"===q(a)}function l(a){return"object"==typeof a&&null!==a}function m(a){return"[object Date]"===q(a)}function n(a){return"[object Error]"===q(a)||a instanceof Error}function o(a){return"function"==typeof a}function p(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function q(a){return Object.prototype.toString.call(a)}c.isArray=b,c.isBoolean=d,c.isNull=e,c.isNullOrUndefined=f,c.isNumber=g,c.isString=h,c.isSymbol=i,c.isUndefined=j,c.isRegExp=k,c.isObject=l,c.isDate=m,c.isError=n,c.isFunction=o,c.isPrimitive=p,c.isBuffer=a.isBuffer}).call(this,{isBuffer:a("../../is-buffer/index.js")})},{"../../is-buffer/index.js":33}],26:[function(b,c,d){!function(b,e){"object"==typeof d?c.exports=d=e():"function"==typeof a&&a.amd?a([],e):b.CryptoJS=e()}(this,function(){var a=a||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)}),c.init.prototype=c,c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,e=a.sigBytes;if(this.clamp(),d%4)for(var f=0;e>f;f++){var g=255&c[f>>>2]>>>24-8*(f%4);b[d+f>>>2]|=g<<24-8*((d+f)%4)}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(0|4294967296*a.random());return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}});var l=c.algo={};return c}(Math);return a})},{}],27:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core"),b("./sha1"),b("./hmac")):"function"==typeof a&&a.amd?a(["./core","./sha1","./hmac"],f):f(e.CryptoJS)}(this,function(a){return a.HmacSHA1})},{"./core":26,"./hmac":28,"./sha1":29}],28:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){!function(){var b=a,c=b.lib,d=c.Base,e=b.enc,f=e.Utf8,g=b.algo;g.HMAC=d.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=f.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),g=this._iKey=b.clone(),h=e.words,i=g.words,j=0;c>j;j++)h[j]^=1549556828,i[j]^=909522486;e.sigBytes=g.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher,c=b.finalize(a);b.reset();var d=b.finalize(this._oKey.clone().concat(c));return d}})}()})},{"./core":26}],29:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){return function(){var b=a,c=b.lib,d=c.WordArray,e=c.Hasher,f=b.algo,g=[],h=f.SHA1=e.extend({ +_doReset:function(){this._hash=new d.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=0|c[0]+d,c[1]=0|c[1]+e,c[2]=0|c[2]+f,c[3]=0|c[3]+h,c[4]=0|c[4]+i},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA1=e._createHelper(h),b.HmacSHA1=e._createHmacHelper(h)}(),a.SHA1})},{"./core":26}],30:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;d>i;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(0>d)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],31:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],32:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],33:[function(a,b,c){b.exports=function(a){return!(null==a||!(a._isBuffer||a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)))}},{}],34:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],35:[function(a,b,c){function d(){}var e=a("./_nativeCreate"),f=Object.prototype;d.prototype=e?e(null):f,b.exports=d},{"./_nativeCreate":107}],36:[function(a,b,c){var d=a("./_getNative"),e=a("./_root"),f=d(e,"Map");b.exports=f},{"./_getNative":86,"./_root":109}],37:[function(a,b,c){function d(a){var b=-1,c=a?a.length:0;for(this.clear();++bc)return!1;var d=a.length-1;return c==d?a.pop():g.call(a,c,1),!0}var e=a("./_assocIndexOf"),f=Array.prototype,g=f.splice;b.exports=d},{"./_assocIndexOf":51}],49:[function(a,b,c){function d(a,b){var c=e(a,b);return 0>c?void 0:a[c][1]}var e=a("./_assocIndexOf");b.exports=d},{"./_assocIndexOf":51}],50:[function(a,b,c){function d(a,b){return e(a,b)>-1}var e=a("./_assocIndexOf");b.exports=d},{"./_assocIndexOf":51}],51:[function(a,b,c){function d(a,b){for(var c=a.length;c--;)if(e(a[c][0],b))return c;return-1}var e=a("./eq");b.exports=d},{"./eq":119}],52:[function(a,b,c){function d(a,b,c){var d=e(a,b);0>d?a.push([b,c]):a[d][1]=c}var e=a("./_assocIndexOf");b.exports=d},{"./_assocIndexOf":51}],53:[function(a,b,c){function d(a,b){return a&&e(b,f(b),a)}var e=a("./_copyObject"),f=a("./keys");b.exports=d},{"./_copyObject":76,"./keys":137}],54:[function(a,b,c){function d(a){return e(a)?a:f(a)}var e=a("./isArray"),f=a("./_stringToPath");b.exports=d},{"./_stringToPath":116,"./isArray":125}],55:[function(a,b,c){function d(a){return e(a)?f(a):{}}var e=a("./isObject"),f=Object.create;b.exports=d},{"./isObject":132}],56:[function(a,b,c){var d=a("./_baseForOwn"),e=a("./_createBaseEach"),f=e(d);b.exports=f},{"./_baseForOwn":59,"./_createBaseEach":79}],57:[function(a,b,c){function d(a,b){var c=!0;return e(a,function(a,d,e){return c=!!b(a,d,e)}),c}var e=a("./_baseEach");b.exports=d},{"./_baseEach":56}],58:[function(a,b,c){var d=a("./_createBaseFor"),e=d();b.exports=e},{"./_createBaseFor":80}],59:[function(a,b,c){function d(a,b){return a&&e(a,b,f)}var e=a("./_baseFor"),f=a("./keys");b.exports=d},{"./_baseFor":58,"./keys":137}],60:[function(a,b,c){function d(a,b){b=f(b,a)?[b+""]:e(b);for(var c=0,d=b.length;null!=a&&d>c;)a=a[b[c++]];return c&&c==d?a:void 0}var e=a("./_baseCastPath"),f=a("./_isKey");b.exports=d},{"./_baseCastPath":54,"./_isKey":97}],61:[function(a,b,c){function d(a,b){return f.call(a,b)||"object"==typeof a&&b in a&&null===g(a)}var e=Object.prototype,f=e.hasOwnProperty,g=Object.getPrototypeOf;b.exports=d},{}],62:[function(a,b,c){function d(a,b){return b in Object(a)}b.exports=d},{}],63:[function(a,b,c){function d(a,b,c,h,i){return a===b?!0:null==a||null==b||!f(a)&&!g(b)?a!==a&&b!==b:e(a,b,d,c,h,i)}var e=a("./_baseIsEqualDeep"),f=a("./isObject"),g=a("./isObjectLike");b.exports=d},{"./_baseIsEqualDeep":64,"./isObject":132,"./isObjectLike":133}],64:[function(a,b,c){function d(a,b,c,d,q,s){var t=j(a),u=j(b),v=o,w=o;t||(v=i(a),v==n?v=p:v!=p&&(t=l(a))),u||(w=i(b),w==n?w=p:w!=p&&(u=l(b)));var x=v==p&&!k(a),y=w==p&&!k(b),z=v==w;if(z&&!t&&!x)return g(a,b,v,c,d,q);var A=q&m;if(!A){var B=x&&r.call(a,"__wrapped__"),C=y&&r.call(b,"__wrapped__");if(B||C)return c(B?a.value():a,C?b.value():b,d,q,s)}return z?(s||(s=new e),(t?f:h)(a,b,c,d,q,s)):!1}var e=a("./_Stack"),f=a("./_equalArrays"),g=a("./_equalByTag"),h=a("./_equalObjects"),i=a("./_getTag"),j=a("./isArray"),k=a("./_isHostObject"),l=a("./isTypedArray"),m=2,n="[object Arguments]",o="[object Array]",p="[object Object]",q=Object.prototype,r=q.hasOwnProperty;b.exports=d},{"./_Stack":39,"./_equalArrays":81,"./_equalByTag":82,"./_equalObjects":83,"./_getTag":87,"./_isHostObject":94,"./isArray":125,"./isTypedArray":136}],65:[function(a,b,c){function d(a,b,c,d){var i=c.length,j=i,k=!d;if(null==a)return!j;for(a=Object(a);i--;){var l=c[i];if(k&&l[2]?l[1]!==a[l[0]]:!(l[0]in a))return!1}for(;++ib&&(b=-b>e?0:e+b),c=c>e?e:c,0>c&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d1?c[f-1]:void 0,h=f>2?c[2]:void 0;for(g="function"==typeof g?(f--,g):void 0,h&&e(c[0],c[1],h)&&(g=3>f?void 0:g,f=1),b=Object(b);++dm))return!1;var o=i.get(a);if(o)return o==b;var p=!0;for(i.set(a,b);++j-1&&a%1==0&&b>a}var e=9007199254740991,f=/^(?:0|[1-9]\d*)$/;b.exports=d},{}],96:[function(a,b,c){function d(a,b,c){if(!h(c))return!1;var d=typeof b;return("number"==d?f(c)&&g(b,c.length):"string"==d&&b in c)?e(c[b],a):!1}var e=a("./eq"),f=a("./isArrayLike"),g=a("./_isIndex"),h=a("./isObject");b.exports=d},{"./_isIndex":95,"./eq":119,"./isArrayLike":126,"./isObject":132}],97:[function(a,b,c){function d(a,b){return"number"==typeof a?!0:!e(a)&&(g.test(a)||!f.test(a)||null!=b&&a in Object(b))}var e=a("./isArray"),f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/;b.exports=d},{"./isArray":125}],98:[function(a,b,c){function d(a){var b=typeof a;return"number"==b||"boolean"==b||"string"==b&&"__proto__"!=a||null==a}b.exports=d},{}],99:[function(a,b,c){function d(a){var b=a&&a.constructor,c="function"==typeof b&&b.prototype||e;return a===c}var e=Object.prototype;b.exports=d},{}],100:[function(a,b,c){function d(a){return a===a&&!e(a)}var e=a("./isObject");b.exports=d},{"./isObject":132}],101:[function(a,b,c){function d(){this.__data__={hash:new e,map:f?new f:[],string:new e}}var e=a("./_Hash"),f=a("./_Map");b.exports=d},{"./_Hash":35,"./_Map":36}],102:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map["delete"](a):f(b.map,a)}var e=a("./_Map"),f=a("./_assocDelete"),g=a("./_hashDelete"),h=a("./_isKeyable");b.exports=d},{"./_Map":36,"./_assocDelete":48,"./_hashDelete":89,"./_isKeyable":98}],103:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map.get(a):f(b.map,a)}var e=a("./_Map"),f=a("./_assocGet"),g=a("./_hashGet"),h=a("./_isKeyable");b.exports=d},{"./_Map":36,"./_assocGet":49,"./_hashGet":90,"./_isKeyable":98}],104:[function(a,b,c){function d(a){var b=this.__data__;return h(a)?g("string"==typeof a?b.string:b.hash,a):e?b.map.has(a):f(b.map,a)}var e=a("./_Map"),f=a("./_assocHas"),g=a("./_hashHas"),h=a("./_isKeyable");b.exports=d},{"./_Map":36,"./_assocHas":50,"./_hashHas":91,"./_isKeyable":98}],105:[function(a,b,c){function d(a,b){var c=this.__data__;return h(a)?g("string"==typeof a?c.string:c.hash,a,b):e?c.map.set(a,b):f(c.map,a,b),this}var e=a("./_Map"),f=a("./_assocSet"),g=a("./_hashSet"),h=a("./_isKeyable");b.exports=d},{"./_Map":36,"./_assocSet":52,"./_hashSet":92,"./_isKeyable":98}],106:[function(a,b,c){function d(a){var b=-1,c=Array(a.size);return a.forEach(function(a,d){c[++b]=[d,a]}),c}b.exports=d},{}],107:[function(a,b,c){var d=a("./_getNative"),e=d(Object,"create");b.exports=e},{"./_getNative":86}],108:[function(a,b,c){function d(a,b){return 1==b.length?a:f(a,e(b,0,-1))}var e=a("./_baseSlice"),f=a("./get");b.exports=d},{"./_baseSlice":72,"./get":121}],109:[function(a,b,c){(function(d){var e=a("./_checkGlobal"),f={"function":!0,object:!0},g=f[typeof c]&&c&&!c.nodeType?c:void 0,h=f[typeof b]&&b&&!b.nodeType?b:void 0,i=e(g&&h&&"object"==typeof d&&d),j=e(f[typeof self]&&self),k=e(f[typeof window]&&window),l=e(f[typeof this]&&this),m=i||k!==(l&&l.window)&&k||j||l||Function("return this")();b.exports=m}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_checkGlobal":75}],110:[function(a,b,c){function d(a){var b=-1,c=Array(a.size);return a.forEach(function(a){c[++b]=a}),c}b.exports=d},{}],111:[function(a,b,c){function d(){this.__data__={array:[],map:null}}b.exports=d},{}],112:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map["delete"](a)}var e=a("./_assocDelete");b.exports=d},{"./_assocDelete":48}],113:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map.get(a)}var e=a("./_assocGet");b.exports=d},{"./_assocGet":49}],114:[function(a,b,c){function d(a){var b=this.__data__,c=b.array;return c?e(c,a):b.map.has(a)}var e=a("./_assocHas");b.exports=d},{"./_assocHas":50}],115:[function(a,b,c){function d(a,b){var c=this.__data__,d=c.array;d&&(d.length-1&&a%1==0&&e>=a}var e=9007199254740991;b.exports=d},{}],131:[function(a,b,c){function d(a){return null==a?!1:e(a)?m.test(k.call(a)):g(a)&&(f(a)?m:i).test(a)}var e=a("./isFunction"),f=a("./_isHostObject"),g=a("./isObjectLike"),h=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,j=Object.prototype,k=Function.prototype.toString,l=j.hasOwnProperty,m=RegExp("^"+k.call(l).replace(h,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");b.exports=d},{"./_isHostObject":94,"./isFunction":129,"./isObjectLike":133}],132:[function(a,b,c){function d(a){var b=typeof a;return!!a&&("object"==b||"function"==b)}b.exports=d},{}],133:[function(a,b,c){function d(a){return!!a&&"object"==typeof a}b.exports=d},{}],134:[function(a,b,c){function d(a){return"string"==typeof a||!e(a)&&f(a)&&i.call(a)==g}var e=a("./isArray"),f=a("./isObjectLike"),g="[object String]",h=Object.prototype,i=h.toString;b.exports=d},{"./isArray":125,"./isObjectLike":133}],135:[function(a,b,c){function d(a){return"symbol"==typeof a||e(a)&&h.call(a)==f}var e=a("./isObjectLike"),f="[object Symbol]",g=Object.prototype,h=g.toString;b.exports=d},{"./isObjectLike":133}],136:[function(a,b,c){function d(a){return f(a)&&e(a.length)&&!!D[F.call(a)]}var e=a("./isLength"),f=a("./isObjectLike"),g="[object Arguments]",h="[object Array]",i="[object Boolean]",j="[object Date]",k="[object Error]",l="[object Function]",m="[object Map]",n="[object Number]",o="[object Object]",p="[object RegExp]",q="[object Set]",r="[object String]",s="[object WeakMap]",t="[object ArrayBuffer]",u="[object Float32Array]",v="[object Float64Array]",w="[object Int8Array]",x="[object Int16Array]",y="[object Int32Array]",z="[object Uint8Array]",A="[object Uint8ClampedArray]",B="[object Uint16Array]",C="[object Uint32Array]",D={};D[u]=D[v]=D[w]=D[x]=D[y]=D[z]=D[A]=D[B]=D[C]=!0,D[g]=D[h]=D[t]=D[i]=D[j]=D[k]=D[l]=D[m]=D[n]=D[o]=D[p]=D[q]=D[r]=D[s]=!1;var E=Object.prototype,F=E.toString;b.exports=d},{"./isLength":130,"./isObjectLike":133}],137:[function(a,b,c){function d(a){var b=j(a);if(!b&&!h(a))return f(a);var c=g(a),d=!!c,k=c||[],l=k.length;for(var m in a)!e(a,m)||d&&("length"==m||i(m,l))||b&&"constructor"==m||k.push(m);return k}var e=a("./_baseHas"),f=a("./_baseKeys"),g=a("./_indexKeys"),h=a("./isArrayLike"),i=a("./_isIndex"),j=a("./_isPrototype");b.exports=d},{"./_baseHas":61,"./_baseKeys":67,"./_indexKeys":93,"./_isIndex":95,"./_isPrototype":99,"./isArrayLike":126}],138:[function(a,b,c){function d(a){var b=a?a.length:0;return b?a[b-1]:void 0}b.exports=d},{}],139:[function(a,b,c){function d(a){return g(a)?e(a):f(a)}var e=a("./_baseProperty"),f=a("./_basePropertyDeep"),g=a("./_isKey");b.exports=d},{"./_baseProperty":70,"./_basePropertyDeep":71,"./_isKey":97}],140:[function(a,b,c){function d(a,b){if("function"!=typeof a)throw new TypeError(g);return b=h(void 0===b?a.length-1:f(b),0),function(){for(var c=arguments,d=-1,f=h(c.length-b,0),g=Array(f);++da?-1:1;return b*g}var c=a%1;return a===a?c?a-c:a:0}var e=a("./toNumber"),f=1/0,g=1.7976931348623157e308;b.exports=d},{"./toNumber":142}],142:[function(a,b,c){function d(a){if(f(a)){var b=e(a.valueOf)?a.valueOf():a;a=f(b)?b+"":b}if("string"!=typeof a)return 0===a?a:+a;a=a.replace(h,"");var c=j.test(a);return c||k.test(a)?l(a.slice(2),c?2:8):i.test(a)?g:+a}var e=a("./isFunction"),f=a("./isObject"),g=NaN,h=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,k=/^0o[0-7]+$/i,l=parseInt;b.exports=d},{"./isFunction":129,"./isObject":132}],143:[function(a,b,c){function d(a){return e(a,f(a))}var e=a("./_baseToPairs"),f=a("./keys");b.exports=d},{"./_baseToPairs":74,"./keys":137}],144:[function(a,b,c){function d(a){if("string"==typeof a)return a;if(null==a)return"";if(f(a))return e?i.call(a):"";var b=a+"";return"0"==b&&1/a==-g?"-0":b}var e=a("./_Symbol"),f=a("./isSymbol"),g=1/0,h=e?e.prototype:void 0,i=e?h.toString:void 0;b.exports=d},{"./_Symbol":40,"./isSymbol":135}],145:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l1)for(var c=1;ce;e++){var g=a[D[e]].length;if(g>b)switch(D[e]){case"textNode":p(a);break;case"cdata":o(a,"oncdata",a.cdata),a.cdata="";break;case"script":o(a,"onscript",a.script),a.script="";break;default:r(a,"Max buffer length exceeded: "+D[e])}d=Math.max(d,g)}var h=c.MAX_BUFFER_LENGTH-d;a.bufferCheckPosition=h+a.position}function f(a){for(var b=0,c=D.length;c>b;b++)a[D[b]]=""}function g(a){p(a),""!==a.cdata&&(o(a,"oncdata",a.cdata),a.cdata=""),""!==a.script&&(o(a,"onscript",a.script),a.script="")}function h(a,b){return new i(a,b)}function i(a,b){if(!(this instanceof i))return new i(a,b);E.apply(this),this._parser=new d(a,b),this.writable=!0,this.readable=!0;var c=this;this._parser.onend=function(){c.emit("end")},this._parser.onerror=function(a){c.emit("error",a),c._parser.error=null},this._decoder=null,G.forEach(function(a){Object.defineProperty(c,"on"+a,{get:function(){return c._parser["on"+a]},set:function(b){return b?void c.on(a,b):(c.removeAllListeners(a),c._parser["on"+a]=b,b)},enumerable:!0,configurable:!1})})}function j(a){return a.split("").reduce(function(a,b){return a[b]=!0,a},{})}function k(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function l(a,b){return k(a)?!!b.match(a):a[b]}function m(a,b){return!l(a,b)}function n(a,b,c){a[b]&&a[b](c)}function o(a,b,c){a.textNode&&p(a),n(a,b,c)}function p(a){a.textNode=q(a.opt,a.textNode),a.textNode&&n(a,"ontext",a.textNode),a.textNode=""}function q(a,b){return a.trim&&(b=b.trim()),a.normalize&&(b=b.replace(/\s+/g," ")),b}function r(a,b){return p(a),a.trackPosition&&(b+="\nLine: "+a.line+"\nColumn: "+a.column+"\nChar: "+a.c),b=new Error(b),a.error=b,n(a,"onerror",b),a}function s(a){return a.sawRoot&&!a.closedRoot&&t(a,"Unclosed root tag"),a.state!==V.BEGIN&&a.state!==V.BEGIN_WHITESPACE&&a.state!==V.TEXT&&r(a,"Unexpected end"),p(a),a.c="",a.closed=!0,n(a,"onend"),d.call(a,a.strict,a.opt),a}function t(a,b){if("object"!=typeof a||!(a instanceof d))throw new Error("bad call to strictFail");a.strict&&r(a,b)}function u(a){a.strict||(a.tagName=a.tagName[a.looseCase]());var b=a.tags[a.tags.length-1]||a,c=a.tag={name:a.tagName,attributes:{}};a.opt.xmlns&&(c.ns=b.ns),a.attribList.length=0}function v(a,b){var c=a.indexOf(":"),d=0>c?["",a]:a.split(":"),e=d[0],f=d[1];return b&&"xmlns"===a&&(e="xmlns",f=""),{prefix:e,local:f}}function w(a){if(a.strict||(a.attribName=a.attribName[a.looseCase]()),-1!==a.attribList.indexOf(a.attribName)||a.tag.attributes.hasOwnProperty(a.attribName))return void(a.attribName=a.attribValue="");if(a.opt.xmlns){var b=v(a.attribName,!0),c=b.prefix,d=b.local;if("xmlns"===c)if("xml"===d&&a.attribValue!==O)t(a,"xml: prefix must be bound to "+O+"\nActual: "+a.attribValue);else if("xmlns"===d&&a.attribValue!==P)t(a,"xmlns: prefix must be bound to "+P+"\nActual: "+a.attribValue);else{var e=a.tag,f=a.tags[a.tags.length-1]||a;e.ns===f.ns&&(e.ns=Object.create(f.ns)),e.ns[d]=a.attribValue}a.attribList.push([a.attribName,a.attribValue])}else a.tag.attributes[a.attribName]=a.attribValue,o(a,"onattribute",{name:a.attribName,value:a.attribValue});a.attribName=a.attribValue=""}function x(a,b){if(a.opt.xmlns){var c=a.tag,d=v(a.tagName);c.prefix=d.prefix,c.local=d.local,c.uri=c.ns[d.prefix]||"",c.prefix&&!c.uri&&(t(a,"Unbound namespace prefix: "+JSON.stringify(a.tagName)),c.uri=d.prefix);var e=a.tags[a.tags.length-1]||a;c.ns&&e.ns!==c.ns&&Object.keys(c.ns).forEach(function(b){o(a,"onopennamespace",{prefix:b,uri:c.ns[b]})});for(var f=0,g=a.attribList.length;g>f;f++){var h=a.attribList[f],i=h[0],j=h[1],k=v(i,!0),l=k.prefix,m=k.local,n=""===l?"":c.ns[l]||"",p={name:i,value:j,prefix:l,local:m,uri:n};l&&"xmlns"!==l&&!n&&(t(a,"Unbound namespace prefix: "+JSON.stringify(l)),p.uri=l),a.tag.attributes[i]=p,o(a,"onattribute",p)}a.attribList.length=0}a.tag.isSelfClosing=!!b,a.sawRoot=!0,a.tags.push(a.tag),o(a,"onopentag",a.tag),b||(a.noscript||"script"!==a.tagName.toLowerCase()?a.state=V.TEXT:a.state=V.SCRIPT,a.tag=null,a.tagName=""),a.attribName=a.attribValue="",a.attribList.length=0}function y(a){if(!a.tagName)return t(a,"Weird empty close tag."),a.textNode+="",void(a.state=V.TEXT);if(a.script){if("script"!==a.tagName)return a.script+="",a.tagName="",void(a.state=V.SCRIPT);o(a,"onscript",a.script),a.script=""}var b=a.tags.length,c=a.tagName;a.strict||(c=c[a.looseCase]());for(var d=c;b--;){var e=a.tags[b];if(e.name===d)break;t(a,"Unexpected close tag")}if(0>b)return t(a,"Unmatched closing tag: "+a.tagName),a.textNode+="",void(a.state=V.TEXT);a.tagName=c;for(var f=a.tags.length;f-- >b;){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,o(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];o(a,"onclosenamespace",{prefix:b,uri:c})})}0===b&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=V.TEXT}function z(a){var b,c=a.entity,d=c.toLowerCase(),e="";return a.ENTITIES[c]?a.ENTITIES[c]:a.ENTITIES[d]?a.ENTITIES[d]:(c=d,"#"===c.charAt(0)&&("x"===c.charAt(1)?(c=c.slice(2),b=parseInt(c,16),e=b.toString(16)):(c=c.slice(1),b=parseInt(c,10),e=b.toString(10))),c=c.replace(/^0+/,""),e.toLowerCase()!==c?(t(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCodePoint(b))}function A(a,b){"<"===b?(a.state=V.OPEN_WAKA,a.startTagPosition=a.position):m(H,b)&&(t(a,"Non-whitespace before first tag."),a.textNode=b,a.state=V.TEXT)}function B(a,b){var c="";return b"===d?(o(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=V.TEXT):l(K,d)?(b.state=V.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case V.SGML_DECL_QUOTED:d===b.q&&(b.state=V.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case V.DOCTYPE:">"===d?(b.state=V.TEXT,o(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,"["===d?b.state=V.DOCTYPE_DTD:l(K,d)&&(b.state=V.DOCTYPE_QUOTED,b.q=d));continue;case V.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=V.DOCTYPE);continue;case V.DOCTYPE_DTD:b.doctype+=d,"]"===d?b.state=V.DOCTYPE:l(K,d)&&(b.state=V.DOCTYPE_DTD_QUOTED,b.q=d);continue;case V.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=V.DOCTYPE_DTD,b.q="");continue;case V.COMMENT:"-"===d?b.state=V.COMMENT_ENDING:b.comment+=d;continue;case V.COMMENT_ENDING:"-"===d?(b.state=V.COMMENT_ENDED,b.comment=q(b.opt,b.comment),b.comment&&o(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=V.COMMENT);continue;case V.COMMENT_ENDED:">"!==d?(t(b,"Malformed comment"),b.comment+="--"+d,b.state=V.COMMENT):b.state=V.TEXT;continue;case V.CDATA:"]"===d?b.state=V.CDATA_ENDING:b.cdata+=d;continue;case V.CDATA_ENDING:"]"===d?b.state=V.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=V.CDATA);continue;case V.CDATA_ENDING_2:">"===d?(b.cdata&&o(b,"oncdata",b.cdata),o(b,"onclosecdata"),b.cdata="",b.state=V.TEXT):"]"===d?b.cdata+="]":(b.cdata+="]]"+d,b.state=V.CDATA);continue;case V.PROC_INST:"?"===d?b.state=V.PROC_INST_ENDING:l(H,d)?b.state=V.PROC_INST_BODY:b.procInstName+=d;continue;case V.PROC_INST_BODY:if(!b.procInstBody&&l(H,d))continue;"?"===d?b.state=V.PROC_INST_ENDING:b.procInstBody+=d;continue;case V.PROC_INST_ENDING:">"===d?(o(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=V.TEXT):(b.procInstBody+="?"+d,b.state=V.PROC_INST_BODY);continue;case V.OPEN_TAG:l(S,d)?b.tagName+=d:(u(b),">"===d?x(b):"/"===d?b.state=V.OPEN_TAG_SLASH:(m(H,d)&&t(b,"Invalid character in tag name"),b.state=V.ATTRIB));continue;case V.OPEN_TAG_SLASH:">"===d?(x(b,!0),y(b)):(t(b,"Forward-slash in opening tag not followed by >"),b.state=V.ATTRIB);continue;case V.ATTRIB:if(l(H,d))continue;">"===d?x(b):"/"===d?b.state=V.OPEN_TAG_SLASH:l(R,d)?(b.attribName=d,b.attribValue="",b.state=V.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case V.ATTRIB_NAME:"="===d?b.state=V.ATTRIB_VALUE:">"===d?(t(b,"Attribute without value"),b.attribValue=b.attribName,w(b),x(b)):l(H,d)?b.state=V.ATTRIB_NAME_SAW_WHITE:l(S,d)?b.attribName+=d:t(b,"Invalid attribute name");continue;case V.ATTRIB_NAME_SAW_WHITE:if("="===d)b.state=V.ATTRIB_VALUE;else{if(l(H,d))continue;t(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",o(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",">"===d?x(b):l(R,d)?(b.attribName=d,b.state=V.ATTRIB_NAME):(t(b,"Invalid attribute name"),b.state=V.ATTRIB)}continue;case V.ATTRIB_VALUE:if(l(H,d))continue;l(K,d)?(b.q=d,b.state=V.ATTRIB_VALUE_QUOTED):(t(b,"Unquoted attribute value"),b.state=V.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case V.ATTRIB_VALUE_QUOTED:if(d!==b.q){"&"===d?b.state=V.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}w(b),b.q="",b.state=V.ATTRIB_VALUE_CLOSED;continue;case V.ATTRIB_VALUE_CLOSED:l(H,d)?b.state=V.ATTRIB:">"===d?x(b):"/"===d?b.state=V.OPEN_TAG_SLASH:l(R,d)?(t(b,"No whitespace between attributes"),b.attribName=d,b.attribValue="",b.state=V.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case V.ATTRIB_VALUE_UNQUOTED:if(m(L,d)){"&"===d?b.state=V.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}w(b),">"===d?x(b):b.state=V.ATTRIB;continue;case V.CLOSE_TAG:if(b.tagName)">"===d?y(b):l(S,d)?b.tagName+=d:b.script?(b.script+=""===d?y(b):t(b,"Invalid characters in closing tag");continue;case V.TEXT_ENTITY:case V.ATTRIB_VALUE_ENTITY_Q:case V.ATTRIB_VALUE_ENTITY_U:var h,i;switch(b.state){case V.TEXT_ENTITY:h=V.TEXT,i="textNode";break;case V.ATTRIB_VALUE_ENTITY_Q:h=V.ATTRIB_VALUE_QUOTED,i="attribValue";break;case V.ATTRIB_VALUE_ENTITY_U:h=V.ATTRIB_VALUE_UNQUOTED,i="attribValue"}";"===d?(b[i]+=z(b),b.entity="",b.state=h):l(b.entity.length?U:T,d)?b.entity+=d:(t(b,"Invalid character in entity name"),b[i]+="&"+b.entity+d,b.entity="",b.state=h);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}c.parser=function(a,b){return new d(a,b)},c.SAXParser=d,c.SAXStream=i,c.createStream=h,c.MAX_BUFFER_LENGTH=65536;var D=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];c.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){}b.prototype=a;var c=new b;return c}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){s(this)},write:C,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){g(this)}};var E;try{E=a("stream").Stream}catch(F){E=function(){}}var G=c.EVENTS.filter(function(a){return"error"!==a&&"end"!==a});i.prototype=Object.create(E.prototype,{constructor:{value:i}}),i.prototype.write=function(c){if("function"==typeof b&&"function"==typeof b.isBuffer&&b.isBuffer(c)){if(!this._decoder){var d=a("string_decoder").StringDecoder;this._decoder=new d("utf8")}c=this._decoder.write(c)}return this._parser.write(c.toString()),this.emit("data",c),!0},i.prototype.end=function(a){return a&&a.length&&this.write(a),this._parser.end(),!0},i.prototype.on=function(a,b){var c=this;return c._parser["on"+a]||-1===G.indexOf(a)||(c._parser["on"+a]=function(){var b=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),E.prototype.on.call(c,a,b)};var H="\r\n ",I="0124356789",J="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",K="'\"",L=H+">",M="[CDATA[",N="DOCTYPE",O="http://www.w3.org/XML/1998/namespace",P="http://www.w3.org/2000/xmlns/",Q={xml:O,xmlns:P};H=j(H),I=j(I),J=j(J);var R=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,S=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/,T=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,U=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/;K=j(K),L=j(L);var V=0;c.STATE={BEGIN:V++,BEGIN_WHITESPACE:V++,TEXT:V++,TEXT_ENTITY:V++,OPEN_WAKA:V++,SGML_DECL:V++,SGML_DECL_QUOTED:V++,DOCTYPE:V++,DOCTYPE_QUOTED:V++,DOCTYPE_DTD:V++,DOCTYPE_DTD_QUOTED:V++,COMMENT_STARTING:V++,COMMENT:V++,COMMENT_ENDING:V++,COMMENT_ENDED:V++,CDATA:V++,CDATA_ENDING:V++,CDATA_ENDING_2:V++,PROC_INST:V++,PROC_INST_BODY:V++,PROC_INST_ENDING:V++,OPEN_TAG:V++,OPEN_TAG_SLASH:V++,ATTRIB:V++,ATTRIB_NAME:V++,ATTRIB_NAME_SAW_WHITE:V++,ATTRIB_VALUE:V++,ATTRIB_VALUE_QUOTED:V++,ATTRIB_VALUE_CLOSED:V++,ATTRIB_VALUE_UNQUOTED:V++,ATTRIB_VALUE_ENTITY_Q:V++,ATTRIB_VALUE_ENTITY_U:V++,CLOSE_TAG:V++,CLOSE_TAG_SAW_WHITE:V++,SCRIPT:V++,SCRIPT_ENDING:V++},c.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},c.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(c.ENTITIES).forEach(function(a){var b=c.ENTITIES[a],d="number"==typeof b?String.fromCharCode(b):b;c.ENTITIES[a]=d});for(var W in c.STATE)c.STATE[c.STATE[W]]=W;V=c.STATE,String.fromCodePoint||!function(){var a=String.fromCharCode,b=Math.floor,c=function(){var c,d,e=16384,f=[],g=-1,h=arguments.length;if(!h)return"";for(var i="";++gj||j>1114111||b(j)!==j)throw RangeError("Invalid code point: "+j);65535>=j?f.push(j):(j-=65536,c=(j>>10)+55296,d=j%1024+56320,f.push(c,d)),(g+1===h||f.length>e)&&(i+=a.apply(null,f),f.length=0)}return i};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:c,configurable:!0,writable:!0}):String.fromCodePoint=c}()}("undefined"==typeof c?this.sax={}:c)}).call(this,a("buffer").Buffer)},{buffer:23,stream:147,string_decoder:158}],147:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("readable-stream/readable.js"),d.Writable=a("readable-stream/writable.js"),d.Duplex=a("readable-stream/duplex.js"),d.Transform=a("readable-stream/transform.js"),d.PassThrough=a("readable-stream/passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{events:30,inherits:32,"readable-stream/duplex.js":148,"readable-stream/passthrough.js":154,"readable-stream/readable.js":155,"readable-stream/transform.js":156,"readable-stream/writable.js":157}],148:[function(a,b,c){b.exports=a("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":149}],149:[function(a,b,c){(function(c){function d(a){return this instanceof d?(i.call(this,a),j.call(this,a),a&&a.readable===!1&&(this.readable=!1),a&&a.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,a&&a.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",e)):new d(a)}function e(){this.allowHalfOpen||this._writableState.ended||c.nextTick(this.end.bind(this))}function f(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}b.exports=d;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},h=a("core-util-is");h.inherits=a("inherits");var i=a("./_stream_readable"),j=a("./_stream_writable");h.inherits(d,i),f(g(j.prototype),function(a){d.prototype[a]||(d.prototype[a]=j.prototype[a])})}).call(this,a("_process"))},{"./_stream_readable":151,"./_stream_writable":153,_process:145,"core-util-is":25,inherits:32}],150:[function(a,b,c){function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./_stream_transform"),f=a("core-util-is");f.inherits=a("inherits"),f.inherits(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./_stream_transform":152,"core-util-is":25,inherits:32}],151:[function(a,b,c){(function(c){function d(b,c){var d=a("./_stream_duplex");b=b||{};var e=b.highWaterMark,f=b.objectMode?16:16384;this.highWaterMark=e||0===e?e:f,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!b.objectMode,c instanceof d&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.defaultEncoding=b.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(C||(C=a("string_decoder/").StringDecoder),this.decoder=new C(b.encoding),this.encoding=b.encoding)}function e(b){a("./_stream_duplex");return this instanceof e?(this._readableState=new d(b,this),this.readable=!0,void A.call(this)):new e(b)}function f(a,b,c,d,e){var f=j(b,c);if(f)a.emit("error",f);else if(B.isNullOrUndefined(c))b.reading=!1,b.ended||k(a,b);else if(b.objectMode||c&&c.length>0)if(b.ended&&!e){var h=new Error("stream.push() after EOF");a.emit("error",h)}else if(b.endEmitted&&e){var h=new Error("stream.unshift() after end event");a.emit("error",h)}else!b.decoder||e||d||(c=b.decoder.write(c)),e||(b.reading=!1),b.flowing&&0===b.length&&!b.sync?(a.emit("data",c),a.read(0)):(b.length+=b.objectMode?1:c.length,e?b.buffer.unshift(c):b.buffer.push(c),b.needReadable&&l(a)),n(a,b);else e||(b.reading=!1);return g(b)}function g(a){return!a.ended&&(a.needReadable||a.length=E)a=E;else{a--;for(var b=1;32>b;b<<=1)a|=a>>b;a++}return a}function i(a,b){return 0===b.length&&b.ended?0:b.objectMode?0===a?0:1:isNaN(a)||B.isNull(a)?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:0>=a?0:(a>b.highWaterMark&&(b.highWaterMark=h(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}function j(a,b){var c=null;return B.isBuffer(b)||B.isString(b)||B.isNullOrUndefined(b)||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function k(a,b){if(b.decoder&&!b.ended){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,l(a)}function l(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(D("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?c.nextTick(function(){m(a)}):m(a))}function m(a){D("emit readable"),a.emit("readable"),s(a)}function n(a,b){b.readingMore||(b.readingMore=!0,c.nextTick(function(){o(a,b)}))}function o(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length=e)c=f?d.join(""):y.concat(d,e),d.length=0;else if(aj&&a>i;j++){var h=d[0],l=Math.min(a-i,h.length);f?c+=h.slice(0,l):h.copy(c,i,0,l),l0)throw new Error("endReadable called on non-empty stream");b.endEmitted||(b.ended=!0,c.nextTick(function(){b.endEmitted||0!==b.length||(b.endEmitted=!0,a.readable=!1,a.emit("end"))}))}function v(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)}function w(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1}b.exports=e;var x=a("isarray"),y=a("buffer").Buffer;e.ReadableState=d;var z=a("events").EventEmitter;z.listenerCount||(z.listenerCount=function(a,b){return a.listeners(b).length});var A=a("stream"),B=a("core-util-is");B.inherits=a("inherits");var C,D=a("util");D=D&&D.debuglog?D.debuglog("stream"):function(){},B.inherits(e,A),e.prototype.push=function(a,b){var c=this._readableState;return B.isString(a)&&!c.objectMode&&(b=b||c.defaultEncoding,b!==c.encoding&&(a=new y(a,b),b="")),f(this,c,a,b,!1)},e.prototype.unshift=function(a){var b=this._readableState;return f(this,b,a,"",!0)},e.prototype.setEncoding=function(b){return C||(C=a("string_decoder/").StringDecoder),this._readableState.decoder=new C(b),this._readableState.encoding=b,this};var E=8388608;e.prototype.read=function(a){D("read",a);var b=this._readableState,c=a;if((!B.isNumber(a)||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return D("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?u(this):l(this),null;if(a=i(a,b),0===a&&b.ended)return 0===b.length&&u(this),null;var d=b.needReadable;D("need readable",d),(0===b.length||b.length-a0?t(a,b):null,B.isNull(e)&&(b.needReadable=!0,a=0),b.length-=a,0!==b.length||b.ended||(b.needReadable=!0),c!==a&&b.ended&&0===b.length&&u(this),B.isNull(e)||this.emit("data",e),e},e.prototype._read=function(a){this.emit("error",new Error("not implemented"))},e.prototype.pipe=function(a,b){function d(a){D("onunpipe"),a===l&&f()}function e(){D("onend"),a.end()}function f(){D("cleanup"),a.removeListener("close",i),a.removeListener("finish",j),a.removeListener("drain",q),a.removeListener("error",h),a.removeListener("unpipe",d),l.removeListener("end",e),l.removeListener("end",f),l.removeListener("data",g),!m.awaitDrain||a._writableState&&!a._writableState.needDrain||q()}function g(b){D("ondata");var c=a.write(b);!1===c&&(D("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,l.pause())}function h(b){D("onerror",b),k(),a.removeListener("error",h),0===z.listenerCount(a,"error")&&a.emit("error",b)}function i(){a.removeListener("finish",j),k()}function j(){D("onfinish"),a.removeListener("close",i),k()}function k(){D("unpipe"),l.unpipe(a)}var l=this,m=this._readableState;switch(m.pipesCount){case 0:m.pipes=a;break;case 1:m.pipes=[m.pipes,a];break;default:m.pipes.push(a)}m.pipesCount+=1,D("pipe count=%d opts=%j",m.pipesCount,b);var n=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,o=n?e:f;m.endEmitted?c.nextTick(o):l.once("end",o),a.on("unpipe",d);var q=p(l);return a.on("drain",q),l.on("data",g),a._events&&a._events.error?x(a._events.error)?a._events.error.unshift(h):a._events.error=[h,a._events.error]:a.on("error",h),a.once("close",i),a.once("finish",j),a.emit("pipe",l),m.flowing||(D("pipe resume"),l.resume()),a},e.prototype.unpipe=function(a){var b=this._readableState;if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,a&&a.emit("unpipe",this),this);if(!a){var c=b.pipes,d=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var e=0;d>e;e++)c[e].emit("unpipe",this);return this}var e=w(b.pipes,a);return-1===e?this:(b.pipes.splice(e,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this),this)},e.prototype.on=function(a,b){var d=A.prototype.on.call(this,a,b);if("data"===a&&!1!==this._readableState.flowing&&this.resume(),"readable"===a&&this.readable){var e=this._readableState;if(!e.readableListening)if(e.readableListening=!0,e.emittedReadable=!1,e.needReadable=!0,e.reading)e.length&&l(this,e);else{var f=this;c.nextTick(function(){D("readable nexttick read 0"),f.read(0)})}}return d},e.prototype.addListener=e.prototype.on,e.prototype.resume=function(){var a=this._readableState;return a.flowing||(D("resume"),a.flowing=!0,a.reading||(D("resume read 0"),this.read(0)),q(this,a)),this},e.prototype.pause=function(){return D("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(D("pause"),this._readableState.flowing=!1,this.emit("pause")),this},e.prototype.wrap=function(a){var b=this._readableState,c=!1,d=this;a.on("end",function(){if(D("wrapped end"),b.decoder&&!b.ended){var a=b.decoder.end();a&&a.length&&d.push(a)}d.push(null)}),a.on("data",function(e){if(D("wrapped data"),b.decoder&&(e=b.decoder.write(e)),e&&(b.objectMode||e.length)){var f=d.push(e);f||(c=!0,a.pause())}});for(var e in a)B.isFunction(a[e])&&B.isUndefined(this[e])&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));var f=["error","close","destroy","pause","resume"];return v(f,function(b){a.on(b,d.emit.bind(d,b))}),d._read=function(b){D("wrapped _read",b),c&&(c=!1,a.resume())},d},e._fromList=t}).call(this,a("_process"))},{"./_stream_duplex":149,_process:145,buffer:23,"core-util-is":25,events:30,inherits:32,isarray:34,stream:147,"string_decoder/":158,util:21}],152:[function(a,b,c){function d(a,b){this.afterTransform=function(a,c){return e(b,a,c)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function e(a,b,c){var d=a._transformState;d.transforming=!1;var e=d.writecb;if(!e)return a.emit("error",new Error("no writecb in Transform class"));d.writechunk=null,d.writecb=null,i.isNullOrUndefined(c)||a.push(c),e&&e(b);var f=a._readableState;f.reading=!1,(f.needReadable||f.length1){for(var c=[],d=0;d=this.charLength-this.charReceived?this.charLength-this.charReceived:a.length;if(a.copy(this.charBuffer,this.charReceived,0,c),this.charReceived+=c,this.charReceived=55296&&56319>=d)){if(this.charReceived=this.charLength=0,0===a.length)return b;break}this.charLength+=this.surrogateSize,b=""}this.detectIncompleteChar(a);var e=a.length;this.charLength&&(a.copy(this.charBuffer,0,a.length-this.charReceived,e),e-=this.charReceived),b+=a.toString(this.encoding,0,e);var e=b.length-1,d=b.charCodeAt(e);if(d>=55296&&56319>=d){var f=this.surrogateSize;return this.charLength+=f,this.charReceived+=f,this.charBuffer.copy(this.charBuffer,f,0,f),a.copy(this.charBuffer,0,0,f),b.substring(0,e)}return b},j.prototype.detectIncompleteChar=function(a){for(var b=a.length>=3?3:a.length;b>0;b--){var c=a[a.length-b];if(1==b&&c>>5==6){this.charLength=2;break}if(2>=b&&c>>4==14){this.charLength=3;break}if(3>=b&&c>>3==30){this.charLength=4;break}}this.charReceived=b},j.prototype.end=function(a){var b="";if(a&&a.length&&(b=this.write(a)),this.charReceived){var c=this.charReceived,d=this.charBuffer,e=this.encoding;b+=d.slice(0,c).toString(e)}return b}},{buffer:23}],159:[function(b,c,d){!function(c){if(function(b,c){"function"==typeof a&&a.amd?a("strophe-base64",function(){return c()}):b.Base64=c()}(this,function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b={encode:function(b){var c,d,e,f,g,h,i,j="",k=0;do c=b.charCodeAt(k++),d=b.charCodeAt(k++),e=b.charCodeAt(k++),f=c>>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?(g=(3&c)<<4,h=i=64):isNaN(e)&&(i=64),j=j+a.charAt(f)+a.charAt(g)+a.charAt(h)+a.charAt(i);while(k>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!=h&&(j+=String.fromCharCode(d)),64!=i&&(j+=String.fromCharCode(e));while(k>5]|=128<<24-d%32,a[(d+64>>9<<4)+15]=d;var g,h,i,j,k,l,m,n,o=new Array(80),p=1732584193,q=-271733879,r=-1732584194,s=271733878,t=-1009589776;for(g=0;gh;h++)16>h?o[h]=a[g+h]:o[h]=f(o[h-3]^o[h-8]^o[h-14]^o[h-16],1),i=e(e(f(p,5),b(h,q,r,s)),e(e(t,o[h]),c(h))),t=s,s=r,r=f(q,30),q=p,p=i;p=e(p,j),q=e(q,k),r=e(r,l),s=e(s,m),t=e(t,n)}return[p,q,r,s,t]}function b(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d}function c(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function d(b,c){var d=g(b);d.length>16&&(d=a(d,8*b.length));for(var e=new Array(16),f=new Array(16),h=0;16>h;h++)e[h]=909522486^d[h],f[h]=1549556828^d[h];var i=a(e.concat(g(c)),512+8*c.length);return a(f.concat(i),672)}function e(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function f(a,b){return a<>>32-b}function g(a){for(var b=[],c=255,d=0;d<8*a.length;d+=8)b[d>>5]|=(a.charCodeAt(d/8)&c)<<24-d%32;return b}function h(a){for(var b="",c=255,d=0;d<32*a.length;d+=8)b+=String.fromCharCode(a[d>>5]>>>24-d%32&c);return b}function i(a){for(var b,c,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="",f=0;f<4*a.length;f+=3)for(b=(a[f>>2]>>8*(3-f%4)&255)<<16|(a[f+1>>2]>>8*(3-(f+1)%4)&255)<<8|a[f+2>>2]>>8*(3-(f+2)%4)&255,c=0;4>c;c++)e+=8*f+6*c>32*a.length?"=":d.charAt(b>>6*(3-c)&63);return e}return{b64_hmac_sha1:function(a,b){return i(d(a,b))},b64_sha1:function(b){return i(a(g(b),8*b.length))},binb2str:h,core_hmac_sha1:d,str_hmac_sha1:function(a,b){return h(d(a,b))},str_sha1:function(b){return h(a(g(b),8*b.length))}}}),function(b,c){"function"==typeof a&&a.amd?a("strophe-md5",function(){return c()}):b.MD5=c()}(this,function(a){var b=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},c=function(a,b){return a<>>32-b},d=function(a){for(var b=[],c=0;c<8*a.length;c+=8)b[c>>5]|=(255&a.charCodeAt(c/8))<>5]>>>c%32&255);return b},f=function(a){for(var b="0123456789abcdef",c="",d=0;d<4*a.length;d++)c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},g=function(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)},h=function(a,b,c,d,e,f,h){return g(b&c|~b&d,a,b,e,f,h)},i=function(a,b,c,d,e,f,h){return g(b&d|c&~d,a,b,e,f,h)},j=function(a,b,c,d,e,f,h){return g(b^c^d,a,b,e,f,h)},k=function(a,b,c,d,e,f,h){return g(c^(b|~d),a,b,e,f,h)},l=function(a,c){a[c>>5]|=128<>>9<<4)+14]=c;for(var d,e,f,g,l=1732584193,m=-271733879,n=-1732584194,o=271733878,p=0;pb;b++)c=a.charCodeAt(b),c>=0&&127>=c?d+=a.charAt(b):c>2047?(d+=String.fromCharCode(224|c>>12&15),d+=String.fromCharCode(128|c>>6&63),d+=String.fromCharCode(128|c>>0&63)):(d+=String.fromCharCode(192|c>>6&31),d+=String.fromCharCode(128|c>>0&63));return d}};return a}),function(b,c){return"function"==typeof a&&a.amd?void a("strophe-polyfill",[],function(){return c()}):c()}(this,function(){Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=Array.prototype.slice,d=Array.prototype.concat,e=c.call(arguments,1);return function(){return b.apply(a?a:this,d.call(e,c.call(arguments,0)))}}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1})}),function(b,c){if("function"==typeof a&&a.amd)a("strophe-core",["strophe-sha1","strophe-base64","strophe-md5","strophe-utils","strophe-polyfill"],function(){return c.apply(this,arguments)});else{var d=c(b.SHA1,b.Base64,b.MD5,b.stropheUtils);window.Strophe=d.Strophe,window.$build=d.$build,window.$iq=d.$iq,window.$msg=d.$msg,window.$pres=d.$pres,window.SHA1=d.SHA1,window.Base64=d.Base64,window.MD5=d.MD5,window.b64_hmac_sha1=d.SHA1.b64_hmac_sha1,window.b64_sha1=d.SHA1.b64_sha1,window.str_hmac_sha1=d.SHA1.str_hmac_sha1,window.str_sha1=d.SHA1.str_sha1}}(this,function(a,b,c,d){function e(a,b){return new i.Builder(a,b)}function f(a){return new i.Builder("message",a)}function g(a){return new i.Builder("iq",a)}function h(a){return new i.Builder("presence",a)}var i;return i={VERSION:"1.2.4",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},XHTML:{tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"],validTag:function(a){for(var b=0;b0)for(var c=0;c/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,""")},xmlunescape:function(a){return a=a.replace(/\&/g,"&"),a=a.replace(/</g,"<"),a=a.replace(/>/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,'"')},xmlTextNode:function(a){return i.xmlGenerator().createTextNode(a)},xmlHtmlNode:function(a){var b;if(window.DOMParser){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a);return b},getText:function(a){if(!a)return null;var b="";0===a.childNodes.length&&a.nodeType==i.ElementType.TEXT&&(b+=a.nodeValue);for(var c=0;c0&&(g=h.join("; "),c.setAttribute(f,g))}else c.setAttribute(f,g);for(b=0;b/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(a){return"string"!=typeof a?a:a.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(a){return a.indexOf("@")<0?null:a.split("@")[0]},getDomainFromJid:function(a){var b=i.getBareJidFromJid(a);if(b.indexOf("@")<0)return b;var c=b.split("@");return c.splice(0,1),c.join("@")},getResourceFromJid:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),b.join("/"))},getBareJidFromJid:function(a){return a?a.split("/")[0]:null},log:function(a,b){},debug:function(a){this.log(this.LogLevel.DEBUG,a)},info:function(a){this.log(this.LogLevel.INFO,a)},warn:function(a){this.log(this.LogLevel.WARN,a)},error:function(a){this.log(this.LogLevel.ERROR,a)},fatal:function(a){this.log(this.LogLevel.FATAL,a)},serialize:function(a){var b;if(!a)return null;"function"==typeof a.tree&&(a=a.tree());var c,d,e=a.nodeName;for(a.getAttribute("_realname")&&(e=a.getAttribute("_realname")),b="<"+e,c=0;c/g,">").replace(/0){for(b+=">",c=0;c"}b+=""}else b+="/>";return b},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(a,b){i._connectionPlugins[a]=b}},i.Builder=function(a,b){("presence"==a||"message"==a||"iq"==a)&&(b&&!b.xmlns?b.xmlns=i.NS.CLIENT:b||(b={xmlns:i.NS.CLIENT})),this.nodeTree=i.xmlElement(a,b),this.node=this.nodeTree},i.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return i.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},attrs:function(a){for(var b in a)a.hasOwnProperty(b)&&(void 0===a[b]?this.node.removeAttribute(b):this.node.setAttribute(b,a[b]));return this},c:function(a,b,c){var d=i.xmlElement(a,b,c);return this.node.appendChild(d),"string"!=typeof c&&(this.node=d),this},cnode:function(a){var b,c=i.xmlGenerator();try{b=void 0!==c.importNode}catch(d){b=!1}var e=b?c.importNode(a,!0):i.copyElement(a);return this.node.appendChild(e),this.node=e,this},t:function(a){var b=i.xmlTextNode(a);return this.node.appendChild(b),this},h:function(a){var b=document.createElement("body");b.innerHTML=a;for(var c=i.createHtml(b);c.childNodes.length>0;)this.node.appendChild(c.childNodes[0]);return this}},i.Handler=function(a,b,c,d,e,f,g){this.handler=a,this.ns=b,this.name=c,this.type=d,this.id=e,this.options=g||{matchBare:!1},this.options.matchBare||(this.options.matchBare=!1),this.options.matchBare?this.from=f?i.getBareJidFromJid(f):null:this.from=f,this.user=!0},i.Handler.prototype={isMatch:function(a){var b,c=null;if(c=this.options.matchBare?i.getBareJidFromJid(a.getAttribute("from")):a.getAttribute("from"),b=!1,this.ns){var d=this;i.forEachChild(a,null,function(a){a.getAttribute("xmlns")==d.ns&&(b=!0)}),b=b||a.getAttribute("xmlns")==this.ns}else b=!0;var e=a.getAttribute("type");return!b||this.name&&!i.isTagEqual(a,this.name)||this.type&&(Array.isArray(this.type)?-1==this.type.indexOf(e):e!=this.type)||this.id&&a.getAttribute("id")!=this.id||this.from&&c!=this.from?!1:!0},run:function(a){var b=null;try{b=this.handler(a)}catch(c){throw c.sourceURL?i.fatal("error: "+this.handler+" "+c.sourceURL+":"+c.line+" - "+c.name+": "+c.message):c.fileName?("undefined"!=typeof console&&(console.trace(),console.error(this.handler," - error - ",c,c.message)),i.fatal("error: "+this.handler+" "+c.fileName+":"+c.lineNumber+" - "+c.name+": "+c.message)):i.fatal("error: "+c.message+"\n"+c.stack),c}return b},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},i.TimedHandler=function(a,b){this.period=a,this.handler=b,this.lastCalled=(new Date).getTime(),this.user=!0},i.TimedHandler.prototype={run:function(){return this.lastCalled=(new Date).getTime(),this.handler()},reset:function(){this.lastCalled=(new Date).getTime()},toString:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}},i.Connection=function(a,b){this.service=a,this.options=b||{};var c=this.options.protocol||"";0===a.indexOf("ws:")||0===a.indexOf("wss:")||0===c.indexOf("ws")?this._proto=new i.Websocket(this):this._proto=new i.Bosh(this),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._authentication={},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var d in i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(d)){var e=i._connectionPlugins[d],f=function(){};f.prototype=e,this[d]=new f,this[d].init(this)}},i.Connection.prototype={reset:function(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._authentication={},this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0},pause:function(){this.paused=!0},resume:function(){this.paused=!1},getUniqueId:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)});return"string"==typeof a||"number"==typeof a?b+":"+a:b+""},connect:function(a,b,c,d,e,f,g){this.jid=a,this.authzid=i.getBareJidFromJid(this.jid),this.authcid=g||i.getNodeFromJid(this.jid),this.pass=b,this.servtype="xmpp",this.connect_callback=c,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=i.getDomainFromJid(this.jid),this._changeConnectStatus(i.Status.CONNECTING,null),this._proto._connect(d,e,f)},attach:function(a,b,c,d,e,f,g){if(!(this._proto instanceof i.Bosh))throw{name:"StropheSessionError",message:'The "attach" method can only be used with a BOSH connection.'};this._proto._attach(a,b,c,d,e,f,g)},restore:function(a,b,c,d,e){if(!this._sessionCachingSupported())throw{name:"StropheSessionError",message:'The "restore" method can only be used with a BOSH connection.'};this._proto._restore(a,b,c,d,e)},_sessionCachingSupported:function(){if(this._proto instanceof i.Bosh){if(!JSON)return!1;try{window.sessionStorage.setItem("_strophe_","_strophe_"),window.sessionStorage.removeItem("_strophe_")}catch(a){return!1}return!0}return!1},xmlInput:function(a){},xmlOutput:function(a){},rawInput:function(a){},rawOutput:function(a){},nextValidRid:function(a){},send:function(a){if(null!==a){if("function"==typeof a.sort)for(var b=0;b=0&&this.addHandlers.splice(b,1)},disconnect:function(a){if(this._changeConnectStatus(i.Status.DISCONNECTING,a),i.info("Disconnect was called because: "+a),this.connected){var b=!1;this.disconnecting=!0,this.authenticated&&(b=h({xmlns:i.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(b)}else i.info("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests()},_changeConnectStatus:function(a,b){for(var c in i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(c)){var d=this[c];if(d.statusChanged)try{d.statusChanged(a,b)}catch(e){i.error(""+c+" plugin caused an exception changing status: "+e)}}if(this.connect_callback)try{this.connect_callback(a,b)}catch(f){i.error("User connection callback caused an exception: "+f)}},_doDisconnect:function(a){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),i.info("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(i.Status.DISCONNECTED,a), +this.connected=!1},_dataRecv:function(a,b){i.info("_dataRecv called");var c=this._proto._reqToData(a);if(null!==c){this.xmlInput!==i.Connection.prototype.xmlInput&&(c.nodeName===this._proto.strip&&c.childNodes.length?this.xmlInput(c.childNodes[0]):this.xmlInput(c)),this.rawInput!==i.Connection.prototype.rawInput&&(b?this.rawInput(b):this.rawInput(i.serialize(c)));for(var d,e;this.removeHandlers.length>0;)e=this.removeHandlers.pop(),d=this.handlers.indexOf(e),d>=0&&this.handlers.splice(d,1);for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();var f,g,h=c.getAttribute("type");if(null!==h&&"terminate"==h){if(this.disconnecting)return;return f=c.getAttribute("condition"),g=c.getElementsByTagName("conflict"),null!==f?("remote-stream-error"==f&&g.length>0&&(f="conflict"),this._changeConnectStatus(i.Status.CONNFAIL,f)):this._changeConnectStatus(i.Status.CONNFAIL,"unknown"),void this._doDisconnect(f)}var j=this;i.forEachChild(c,null,function(a){var b,c;for(c=j.handlers,j.handlers=[],b=0;b0:d.getElementsByTagName("stream:features").length>0||d.getElementsByTagName("features").length>0;var h,j,k=d.getElementsByTagName("mechanism"),l=[],m=!1;if(!g)return void this._proto._no_auth_received(b);if(k.length>0)for(h=0;h0,(m=this._authentication.legacy_auth||l.length>0)?void(this.do_authentication!==!1&&this.authenticate(l)):void this._proto._no_auth_received(b)}}},authenticate:function(a){var c;for(c=0;ca[d].prototype.priority&&(d=f);if(d!=c){var h=a[c];a[c]=a[d],a[d]=h}}var j=!1;for(c=0;c0&&(b="conflict"),this._changeConnectStatus(i.Status.AUTHFAIL,b),!1}var d,e=a.getElementsByTagName("bind");return e.length>0?(d=e[0].getElementsByTagName("jid"),void(d.length>0&&(this.jid=i.getText(d[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(g({type:"set",id:"_session_auth_2"}).c("session",{xmlns:i.NS.SESSION}).tree())):(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null))))):(i.info("SASL binding failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1)},_sasl_session_cb:function(a){if("result"==a.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null);else if("error"==a.getAttribute("type"))return i.info("Session creation failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1;return!1},_sasl_failure_cb:function(a){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1},_auth2_cb:function(a){return"result"==a.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null)):"error"==a.getAttribute("type")&&(this._changeConnectStatus(i.Status.AUTHFAIL,null),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(a,b){var c=new i.TimedHandler(a,b);return c.user=!1,this.addTimeds.push(c),c},_addSysHandler:function(a,b,c,d,e){var f=new i.Handler(a,b,c,d,e);return f.user=!1,this.addHandlers.push(f),f},_onDisconnectTimeout:function(){return i.info("_onDisconnectTimeout was called"),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1},_onIdle:function(){for(var a,b,c,d;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;)b=this.removeTimeds.pop(),a=this.timedHandlers.indexOf(b),a>=0&&this.timedHandlers.splice(a,1);var e=(new Date).getTime();for(d=[],a=0;a=c-e?b.run()&&d.push(b):d.push(b));this.timedHandlers=d,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(this._onIdle.bind(this),100))}},i.SASLMechanism=function(a,b,c){this.name=a,this.isClientFirst=b,this.priority=c},i.SASLMechanism.prototype={test:function(a){return!0},onStart:function(a){this._connection=a},onChallenge:function(a,b){throw new Error("You should implement challenge handling!")},onFailure:function(){this._connection=null},onSuccess:function(){this._connection=null}},i.SASLAnonymous=function(){},i.SASLAnonymous.prototype=new i.SASLMechanism("ANONYMOUS",!1,10),i.SASLAnonymous.test=function(a){return null===a.authcid},i.Connection.prototype.mechanisms[i.SASLAnonymous.prototype.name]=i.SASLAnonymous,i.SASLPlain=function(){},i.SASLPlain.prototype=new i.SASLMechanism("PLAIN",!0,20),i.SASLPlain.test=function(a){return null!==a.authcid},i.SASLPlain.prototype.onChallenge=function(a){var b=a.authzid;return b+="\x00",b+=a.authcid,b+="\x00",b+=a.pass,d.utf16to8(b)},i.Connection.prototype.mechanisms[i.SASLPlain.prototype.name]=i.SASLPlain,i.SASLSHA1=function(){},i.SASLSHA1.prototype=new i.SASLMechanism("SCRAM-SHA-1",!0,40),i.SASLSHA1.test=function(a){return null!==a.authcid},i.SASLSHA1.prototype.onChallenge=function(e,f,g){var h=g||c.hexdigest(1234567890*Math.random()),i="n="+d.utf16to8(e.authcid);return i+=",r=",i+=h,e._sasl_data.cnonce=h,e._sasl_data["client-first-message-bare"]=i,i="n,,"+i,this.onChallenge=function(c,e){for(var f,g,h,i,j,k,l,m,n,o,p,q,r="c=biws,",s=c._sasl_data["client-first-message-bare"]+","+e+",",t=c._sasl_data.cnonce,u=/([a-z]+)=([^,]+)(,|$)/;e.match(u);){var v=e.match(u);switch(e=e.replace(v[0],""),v[1]){case"r":f=v[2];break;case"s":g=v[2];break;case"i":h=v[2]}}if(f.substr(0,t.length)!==t)return c._sasl_data={},c._sasl_failure_cb();for(r+="r="+f,s+=r,g=b.decode(g),g+="\x00\x00\x00",n=d.utf16to8(c.pass),i=k=a.core_hmac_sha1(n,g),l=1;h>l;l++){for(j=a.core_hmac_sha1(n,a.binb2str(k)),m=0;5>m;m++)i[m]^=j[m];k=j}for(i=a.binb2str(i),o=a.core_hmac_sha1(i,"Client Key"),p=a.str_hmac_sha1(i,"Server Key"),q=a.core_hmac_sha1(a.str_sha1(a.binb2str(o)),s),c._sasl_data["server-signature"]=a.b64_hmac_sha1(p,s),m=0;5>m;m++)o[m]^=q[m];return r+=",p="+b.encode(a.binb2str(o))}.bind(this),i},i.Connection.prototype.mechanisms[i.SASLSHA1.prototype.name]=i.SASLSHA1,i.SASLMD5=function(){},i.SASLMD5.prototype=new i.SASLMechanism("DIGEST-MD5",!1,30),i.SASLMD5.test=function(a){return null!==a.authcid},i.SASLMD5.prototype._quote=function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},i.SASLMD5.prototype.onChallenge=function(a,b,e){for(var f,g=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,h=e||c.hexdigest(""+1234567890*Math.random()),i="",j=null,k="",l="";b.match(g);)switch(f=b.match(g),b=b.replace(f[0],""),f[2]=f[2].replace(/^"(.+)"$/,"$1"),f[1]){case"realm":i=f[2];break;case"nonce":k=f[2];break;case"qop":l=f[2];break;case"host":j=f[2]}var m=a.servtype+"/"+a.domain;null!==j&&(m=m+"/"+j);var n=d.utf16to8(a.authcid+":"+i+":"+this._connection.pass),o=c.hash(n)+":"+k+":"+h,p="AUTHENTICATE:"+m,q="";return q+="charset=utf-8,",q+="username="+this._quote(d.utf16to8(a.authcid))+",",q+="realm="+this._quote(i)+",",q+="nonce="+this._quote(k)+",",q+="nc=00000001,",q+="cnonce="+this._quote(h)+",",q+="digest-uri="+this._quote(m)+",",q+="response="+c.hexdigest(c.hexdigest(o)+":"+k+":00000001:"+h+":auth:"+c.hexdigest(p))+",",q+="qop=auth",this.onChallenge=function(){return""}.bind(this),q},i.Connection.prototype.mechanisms[i.SASLMD5.prototype.name]=i.SASLMD5,{Strophe:i,$build:e,$msg:f,$iq:g,$pres:h,SHA1:a,Base64:b,MD5:c}}),function(b,c){return"function"==typeof a&&a.amd?void a("strophe-bosh",["strophe-core"],function(a){return c(a.Strophe,a.$build)}):c(Strophe,$build)}(this,function(a,b){return a.Request=function(b,c,d,e){this.id=++a._requestId,this.xmlData=b,this.data=a.serialize(b),this.origFunc=c,this.func=c,this.rid=d,this.date=NaN,this.sends=e||0,this.abort=!1,this.dead=null,this.age=function(){if(!this.date)return 0;var a=new Date;return(a-this.date)/1e3},this.timeDead=function(){if(!this.dead)return 0;var a=new Date;return(a-this.dead)/1e3},this.xhr=this._newXHR()},a.Request.prototype={getResponse:function(){var b=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(b=this.xhr.responseXML.documentElement,"parsererror"==b.tagName)throw a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)),"parsererror"}else if(this.xhr.responseText)throw a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),"badformat";return b},_newXHR:function(){var a=null;return window.XMLHttpRequest?(a=new XMLHttpRequest,a.overrideMimeType&&a.overrideMimeType("text/xml; charset=utf-8")):window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP")),a.onreadystatechange=this.func.bind(null,this),a}},a.Bosh=function(a){this._conn=a,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this._requests=[]},a.Bosh.prototype={strip:null,_buildBody:function(){var c=b("body",{rid:this.rid++,xmlns:a.NS.HTTPBIND});return null!==this.sid&&c.attrs({sid:this.sid}),this._conn.options.keepalive&&this._cacheSession(),c},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_connect:function(b,c,d){this.wait=b||this.wait,this.hold=c||this.hold,this.errors=0;var e=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":a.NS.BOSH});d&&e.attrs({route:d});var f=this._conn._connect_cb;this._requests.push(new a.Request(e.tree(),this._onRequestStateChange.bind(this,f.bind(this._conn)),e.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(b,c,d,e,f,g,h){this._conn.jid=b,this.sid=c,this.rid=d,this._conn.connect_callback=e,this._conn.domain=a.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=f||this.wait,this.hold=g||this.hold,this.window=h||this.window,this._conn._changeConnectStatus(a.Status.ATTACHED,null)},_restore:function(b,c,d,e,f){var g=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!("undefined"!=typeof g&&null!==g&&g.rid&&g.sid&&g.jid)||"undefined"!=typeof b&&"null"!==b&&a.getBareJidFromJid(g.jid)!=a.getBareJidFromJid(b))throw{name:"StropheSessionError",message:"_restore: no restoreable session."};this._conn.restored=!0,this._attach(g.jid,g.sid,g.rid,c,d,e,f)},_cacheSession:function(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&window.sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):window.sessionStorage.removeItem("strophe-bosh-session")},_connect_cb:function(b){var c,d,e=b.getAttribute("type");if(null!==e&&"terminate"==e)return c=b.getAttribute("condition"),a.error("BOSH-Connection failed: "+c),d=b.getElementsByTagName("conflict"),null!==c?("remote-stream-error"==c&&d.length>0&&(c="conflict"),this._conn._changeConnectStatus(a.Status.CONNFAIL,c)):this._conn._changeConnectStatus(a.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(c),a.Status.CONNFAIL;this.sid||(this.sid=b.getAttribute("sid"));var f=b.getAttribute("requests");f&&(this.window=parseInt(f,10));var g=b.getAttribute("hold");g&&(this.hold=parseInt(g,10));var h=b.getAttribute("wait");h&&(this.wait=parseInt(h,10))},_disconnect:function(a){this._sendTerminate(a)},_doDisconnect:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_emptyQueue:function(){return 0===this._requests.length},_hitError:function(b){this.errors++,a.warn("request errored, status: "+b+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()},_no_auth_received:function(b){b=b?b.bind(this._conn):this._conn._connect_cb.bind(this._conn);var c=this._buildBody();this._requests.push(new a.Request(c.tree(),this._onRequestStateChange.bind(this,b.bind(this._conn)),c.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout:function(){this._abortAllRequests()},_abortAllRequests:function(){for(var a;this._requests.length>0;)a=this._requests.pop(),a.abort=!0,a.xhr.abort(),a.xhr.onreadystatechange=function(){}},_onIdle:function(){var b=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===b.length&&!this._conn.disconnecting&&(a.info("no requests during idle cycle, sending blank request"),b.push(null)),!this._conn.paused){if(this._requests.length<2&&b.length>0){for(var c=this._buildBody(),d=0;d0){var e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(a.TIMEOUT*this.wait)&&(a.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(a.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_onRequestStateChange:function(b,c){if(a.debug("request id "+c.id+"."+c.sends+" state changed to "+c.xhr.readyState),c.abort)return void(c.abort=!1);var d;if(4==c.xhr.readyState){d=0;try{d=c.xhr.status}catch(e){}if("undefined"==typeof d&&(d=0),this.disconnecting&&d>=400)return void this._hitError(d);var f=this._requests[0]==c,g=this._requests[1]==c;(d>0&&500>d||c.sends>5)&&(this._removeRequest(c),a.debug("request id "+c.id+" should now be removed")),200==d?((g||f&&this._requests.length>0&&this._requests[0].age()>Math.floor(a.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(c.rid)+1),a.debug("request id "+c.id+"."+c.sends+" got 200"),b(c),this.errors=0):(a.error("request id "+c.id+"."+c.sends+" error "+d+" happened"),(0===d||d>=400&&600>d||d>=12e3)&&(this._hitError(d),d>=400&&500>d&&(this._conn._changeConnectStatus(a.Status.DISCONNECTING,null),this._conn._doDisconnect()))),d>0&&500>d||c.sends>5||this._throttledRequestHandler()}},_processRequest:function(b){var c=this,d=this._requests[b],e=-1;try{4==d.xhr.readyState&&(e=d.xhr.status)}catch(f){a.error("caught an error in _requests["+b+"], reqStatus: "+e)}if("undefined"==typeof e&&(e=-1),d.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();var g=d.age(),h=!isNaN(g)&&g>Math.floor(a.TIMEOUT*this.wait),i=null!==d.dead&&d.timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait),j=4==d.xhr.readyState&&(1>e||e>=500);if((h||i||j)&&(i&&a.error("Request "+this._requests[b].id+" timed out (secondary), restarting"),d.abort=!0,d.xhr.abort(),d.xhr.onreadystatechange=function(){},this._requests[b]=new a.Request(d.xmlData,d.origFunc,d.rid,d.sends),d=this._requests[b]),0===d.xhr.readyState){a.debug("request id "+d.id+"."+d.sends+" posting");try{d.xhr.open("POST",this._conn.service,this._conn.options.sync?!1:!0),d.xhr.setRequestHeader("Content-Type","text/xml; charset=utf-8")}catch(k){return a.error("XHR open failed."),this._conn.connected||this._conn._changeConnectStatus(a.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var l=function(){if(d.date=new Date,c._conn.options.customHeaders){var a=c._conn.options.customHeaders;for(var b in a)a.hasOwnProperty(b)&&d.xhr.setRequestHeader(b,a[b])}d.xhr.send(d.data)};if(d.sends>1){var m=1e3*Math.min(Math.floor(a.TIMEOUT*this.wait),Math.pow(d.sends,3));setTimeout(l,m)}else l();d.sends++,this._conn.xmlOutput!==a.Connection.prototype.xmlOutput&&(d.xmlData.nodeName===this.strip&&d.xmlData.childNodes.length?this._conn.xmlOutput(d.xmlData.childNodes[0]):this._conn.xmlOutput(d.xmlData)),this._conn.rawOutput!==a.Connection.prototype.rawOutput&&this._conn.rawOutput(d.data)}else a.debug("_processRequest: "+(0===b?"first":"second")+" request has readyState of "+d.xhr.readyState)},_removeRequest:function(b){a.debug("removing request");var c;for(c=this._requests.length-1;c>=0;c--)b==this._requests[c]&&this._requests.splice(c,1);b.xhr.onreadystatechange=function(){},this._throttledRequestHandler()},_restartRequest:function(a){var b=this._requests[a];null===b.dead&&(b.dead=new Date),this._processRequest(a)},_reqToData:function(a){try{return a.getResponse()}catch(b){if("parsererror"!=b)throw b;this._conn.disconnect("strophe-parsererror")}},_sendTerminate:function(b){a.info("_sendTerminate was called");var c=this._buildBody().attrs({type:"terminate"});b&&c.cnode(b.tree());var d=new a.Request(c.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),c.tree().getAttribute("rid"));this._requests.push(d),this._throttledRequestHandler()},_send:function(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(this._conn._onIdle.bind(this._conn),100)},_sendRestart:function(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)},_throttledRequestHandler:function(){this._requests?a.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):a.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid): "+d);var e=b.getAttribute("version");return"string"!=typeof e?c="Missing version in ":"1.0"!==e&&(c="Wrong version in : "+e),c?(this._conn._changeConnectStatus(a.Status.CONNFAIL,c),this._conn._doDisconnect(),!1):!0},_connect_cb_wrapper:function(b){if(0===b.data.indexOf("\s*)*/,"");if(""===c)return;var d=(new DOMParser).parseFromString(c,"text/xml").documentElement;this._conn.xmlInput(d),this._conn.rawInput(b.data),this._handleStreamStart(d)&&this._connect_cb(d)}else if(0===b.data.indexOf(" tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){a.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(a){return""+a+""},_closeSocket:function(){if(this.socket)try{this.socket.close()}catch(a){}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(){this._conn.connected&&!this._conn.disconnecting?(a.error("Websocket closed unexcectedly"),this._conn._doDisconnect()):a.info("Websocket closed")},_no_auth_received:function(b){a.error("Server did not send any auth methods"),this._conn._changeConnectStatus(a.Status.CONNFAIL,"Server did not send any auth methods"),b&&(b=b.bind(this._conn))(),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(b){a.error("Websocket error "+b),this._conn._changeConnectStatus(a.Status.CONNFAIL,"The WebSocket connection could not be established was disconnected."),this._disconnect()},_onIdle:function(){var b=this._conn._data;if(b.length>0&&!this._conn.paused){for(var c=0;c=0&&(a._idleTimeoutId=setTimeout(function(){a._onTimeout&&a._onTimeout()},b))},c.setImmediate="function"==typeof setImmediate?setImmediate:function(a){var b=i++,d=arguments.length<2?!1:g.call(arguments,1);return h[b]=!0,e(function(){h[b]&&(d?a.apply(null,d):a.call(null),c.clearImmediate(b))}),b},c.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(a){delete h[a]}},{"process/browser.js":145}],161:[function(a,b,c){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],162:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a,b){return a}function h(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(m(a,b,c,d,String(g),!0)):f.push("");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")), +F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":161,_process:145,inherits:32}],163:[function(a,b,c){(function(){"use strict";var b;b=a("../lib/xml2js"),c.stripBOM=function(a){return"\ufeff"===a[0]?a.substring(1):a}}).call(this)},{"../lib/xml2js":165}],164:[function(a,b,c){(function(){"use strict";var a;a=new RegExp(/(?!xmlns)^.*:/),c.normalize=function(a){return a.toLowerCase()},c.firstCharLowerCase=function(a){return a.charAt(0).toLowerCase()+a.slice(1)},c.stripPrefix=function(b){return b.replace(a,"")},c.parseNumbers=function(a){return isNaN(a)||(a=a%1===0?parseInt(a,10):parseFloat(a)),a},c.parseBooleans=function(a){return/^(?:true|false)$/i.test(a)&&(a="true"===a.toLowerCase()),a}}).call(this)},{}],165:[function(a,b,c){(function(){"use strict";var b,d,e,f,g,h,i,j,k,l,m,n=function(a,b){function c(){this.constructor=a}for(var d in b)o.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},o={}.hasOwnProperty,p=function(a,b){return function(){return a.apply(b,arguments)}};k=a("sax"),f=a("events"),d=a("xmlbuilder"),b=a("./bom"),i=a("./processors"),l=a("timers").setImmediate,g=function(a){return"object"==typeof a&&null!=a&&0===Object.keys(a).length},h=function(a,b){var c,d,e;for(c=0,d=a.length;d>c;c++)e=a[c],b=e(b);return b},j=function(a){return a.indexOf("&")>=0||a.indexOf(">")>=0||a.indexOf("<")>=0},m=function(a){return""},e=function(a){return a.replace("]]>","]]]]>")},c.processors=i,c.defaults={.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:"\n"},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}},c.ValidationError=function(a){function b(a){this.message=a}return n(b,a),b}(Error),c.Builder=function(){function a(a){var b,d,e;this.options={},d=c.defaults[.2];for(b in d)o.call(d,b)&&(e=d[b],this.options[b]=e);for(b in a)o.call(a,b)&&(e=a[b],this.options[b]=e)}return a.prototype.buildObject=function(a){var b,e,f,g,h;return b=this.options.attrkey,e=this.options.charkey,1===Object.keys(a).length&&this.options.rootName===c.defaults[.2].rootName?(h=Object.keys(a)[0],a=a[h]):h=this.options.rootName,f=function(a){return function(c,d){var g,h,i,k,l,n;if("object"!=typeof d)a.options.cdata&&j(d)?c.raw(m(d)):c.txt(d);else for(l in d)if(o.call(d,l))if(h=d[l],l===b){if("object"==typeof h)for(g in h)n=h[g],c=c.att(g,n)}else if(l===e)c=a.options.cdata&&j(h)?c.raw(m(h)):c.txt(h);else if(Array.isArray(h))for(k in h)o.call(h,k)&&(i=h[k],c="string"==typeof i?a.options.cdata&&j(i)?c.ele(l).raw(m(i)).up():c.ele(l,i).up():f(c.ele(l),i).up());else"object"==typeof h?c=f(c.ele(l),h).up():"string"==typeof h&&a.options.cdata&&j(h)?c=c.ele(l).raw(m(h)).up():(null==h&&(h=""),c=c.ele(l,h.toString()).up());return c}}(this),g=d.create(h,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),f(g,a).end(this.options.renderOpts)},a}(),c.Parser=function(a){function d(a){this.parseString=p(this.parseString,this),this.reset=p(this.reset,this),this.assignOrPush=p(this.assignOrPush,this),this.processAsync=p(this.processAsync,this);var b,d,e;if(!(this instanceof c.Parser))return new c.Parser(a);this.options={},d=c.defaults[.2];for(b in d)o.call(d,b)&&(e=d[b],this.options[b]=e);for(b in a)o.call(a,b)&&(e=a[b],this.options[b]=e);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(i.normalize)),this.reset()}return n(d,a),d.prototype.processAsync=function(){var a,b,c;try{return this.remaining.length<=this.options.chunkSize?(a=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(a),this.saxParser.close()):(a=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(a),l(this.processAsync))}catch(c){if(b=c,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(b)}},d.prototype.assignOrPush=function(a,b,c){return b in a?(a[b]instanceof Array||(a[b]=[a[b]]),a[b].push(c)):this.options.explicitArray?a[b]=[c]:a[b]=c},d.prototype.reset=function(){var a,b,c,d;return this.removeAllListeners(),this.saxParser=k.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(a){return function(b){return a.saxParser.resume(),a.saxParser.errThrown?void 0:(a.saxParser.errThrown=!0,a.emit("error",b))}}(this),this.saxParser.onend=function(a){return function(){return a.saxParser.ended?void 0:(a.saxParser.ended=!0,a.emit("end",a.resultObject))}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,d=[],a=this.options.attrkey,b=this.options.charkey,this.saxParser.onopentag=function(c){return function(e){var f,g,i,j,k;if(i={},i[b]="",!c.options.ignoreAttrs){k=e.attributes;for(f in k)o.call(k,f)&&(a in i||c.options.mergeAttrs||(i[a]={}),g=c.options.attrValueProcessors?h(c.options.attrValueProcessors,e.attributes[f]):e.attributes[f],j=c.options.attrNameProcessors?h(c.options.attrNameProcessors,f):f,c.options.mergeAttrs?c.assignOrPush(i,j,g):i[a][j]=g)}return i["#name"]=c.options.tagNameProcessors?h(c.options.tagNameProcessors,e.name):e.name,c.options.xmlns&&(i[c.options.xmlnskey]={uri:e.uri,local:e.local}),d.push(i)}}(this),this.saxParser.onclosetag=function(a){return function(){var c,e,f,i,j,k,l,m,n,p,q,r;if(m=d.pop(),l=m["#name"],a.options.explicitChildren&&a.options.preserveChildrenOrder||delete m["#name"],m.cdata===!0&&(c=m.cdata,delete m.cdata),q=d[d.length-1],m[b].match(/^\s*$/)&&!c?(e=m[b],delete m[b]):(a.options.trim&&(m[b]=m[b].trim()),a.options.normalize&&(m[b]=m[b].replace(/\s{2,}/g," ").trim()),m[b]=a.options.valueProcessors?h(a.options.valueProcessors,m[b]):m[b],1===Object.keys(m).length&&b in m&&!a.EXPLICIT_CHARKEY&&(m=m[b])),g(m)&&(m=""!==a.options.emptyTag?a.options.emptyTag:e),null!=a.options.validator){r="/"+function(){var a,b,c;for(c=[],a=0,b=d.length;b>a;a++)k=d[a],c.push(k["#name"]);return c}().concat(l).join("/");try{m=a.options.validator(r,q&&q[l],m)}catch(i){f=i,a.emit("error",f)}}if(a.options.explicitChildren&&!a.options.mergeAttrs&&"object"==typeof m)if(a.options.preserveChildrenOrder){if(q){q[a.options.childkey]=q[a.options.childkey]||[],n={};for(j in m)o.call(m,j)&&(n[j]=m[j]);q[a.options.childkey].push(n),delete m["#name"],1===Object.keys(m).length&&b in m&&!a.EXPLICIT_CHARKEY&&(m=m[b])}}else k={},a.options.attrkey in m&&(k[a.options.attrkey]=m[a.options.attrkey],delete m[a.options.attrkey]),!a.options.charsAsChildren&&a.options.charkey in m&&(k[a.options.charkey]=m[a.options.charkey],delete m[a.options.charkey]),Object.getOwnPropertyNames(m).length>0&&(k[a.options.childkey]=m),m=k;return d.length>0?a.assignOrPush(q,l,m):(a.options.explicitRoot&&(p=m,m={},m[l]=p),a.resultObject=m,a.saxParser.ended=!0,a.emit("end",a.resultObject))}}(this),c=function(a){return function(c){var e,f;return f=d[d.length-1],f?(f[b]+=c,a.options.explicitChildren&&a.options.preserveChildrenOrder&&a.options.charsAsChildren&&""!==c.replace(/\\n/g,"").trim()&&(f[a.options.childkey]=f[a.options.childkey]||[],e={"#name":"__text__"},e[b]=c,f[a.options.childkey].push(e)),f):void 0}}(this),this.saxParser.ontext=c,this.saxParser.oncdata=function(a){return function(a){var b;return b=c(a),b?b.cdata=!0:void 0}}(this)},d.prototype.parseString=function(a,c){var d,e;null!=c&&"function"==typeof c&&(this.on("end",function(a){return this.reset(),c(null,a)}),this.on("error",function(a){return this.reset(),c(a)}));try{return a=a.toString(),""===a.trim()?(this.emit("end",null),!0):(a=b.stripBOM(a),this.options.async?(this.remaining=a,l(this.processAsync),this.saxParser):this.saxParser.write(a).close())}catch(e){if(d=e,!this.saxParser.errThrown&&!this.saxParser.ended)return this.emit("error",d),this.saxParser.errThrown=!0;if(this.saxParser.ended)throw d}},d}(f.EventEmitter),c.parseString=function(a,b,d){var e,f,g;return null!=d?("function"==typeof d&&(e=d),"object"==typeof b&&(f=b)):("function"==typeof b&&(e=b),f={}),g=new c.Parser(f),g.parseString(a,e)}}).call(this)},{"./bom":163,"./processors":164,events:30,sax:146,timers:160,xmlbuilder:182}],166:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing attribute name of element "+a.name);if(null==c)throw new Error("Missing attribute value for attribute "+b+" of element "+a.name);this.name=this.stringify.attName(b),this.value=this.stringify.attValue(c)}return a.prototype.clone=function(){return d(a.prototype,this)},a.prototype.toString=function(a,b){return" "+this.name+'="'+this.value+'"'},a}()}).call(this)},{"lodash/create":118}],167:[function(a,b,c){(function(){var c,d,e,f,g;g=a("./XMLStringifier"),d=a("./XMLDeclaration"),e=a("./XMLDocType"),f=a("./XMLElement"),b.exports=c=function(){function a(a,b){var c,d;if(null==a)throw new Error("Root element needs a name");null==b&&(b={}),this.options=b,this.stringify=new g(b),d=new f(this,"doc"),c=d.element(a),c.isRoot=!0,c.documentObject=this,this.rootObject=c,b.headless||(c.declaration(b),(null!=b.pubID||null!=b.sysID)&&c.doctype(b))}return a.prototype.root=function(){return this.rootObject},a.prototype.end=function(a){return this.toString(a)},a.prototype.toString=function(a){var b,c,d,e,f,g,h,i;return e=(null!=a?a.pretty:void 0)||!1,b=null!=(g=null!=a?a.indent:void 0)?g:" ",d=null!=(h=null!=a?a.offset:void 0)?h:0,c=null!=(i=null!=a?a.newline:void 0)?i:"\n",f="",null!=this.xmldec&&(f+=this.xmldec.toString(a)),null!=this.doctype&&(f+=this.doctype.toString(a)),f+=this.rootObject.toString(a),e&&f.slice(-c.length)===c&&(f=f.slice(0,-c.length)),f},a}()}).call(this)},{"./XMLDeclaration":174,"./XMLDocType":175,"./XMLElement":176,"./XMLStringifier":180}],168:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing CDATA text");this.text=this.stringify.cdata(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":177,"lodash/create":118}],169:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing comment text");this.text=this.stringify.comment(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":177,"lodash/create":118}],170:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c,d,e,f){if(this.stringify=a.stringify,null==b)throw new Error("Missing DTD element name");if(null==c)throw new Error("Missing DTD attribute name");if(!d)throw new Error("Missing DTD attribute type");if(!e)throw new Error("Missing DTD attribute default");if(0!==e.indexOf("#")&&(e="#"+e),!e.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");if(f&&!e.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT");this.elementName=this.stringify.eleName(b),this.attributeName=this.stringify.attName(c),this.attributeType=this.stringify.dtdAttType(d),this.defaultValue=this.stringify.dtdAttDefault(f),this.defaultValueType=e}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":118}],171:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing DTD element name");c||(c="(#PCDATA)"),Array.isArray(c)&&(c="("+c.join(",")+")"),this.name=this.stringify.eleName(b),this.value=this.stringify.dtdElementValue(c)}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":118}],172:[function(a,b,c){(function(){var c,d,e;d=a("lodash/create"),e=a("lodash/isObject"),b.exports=c=function(){function a(a,b,c,d){if(this.stringify=a.stringify,null==c)throw new Error("Missing entity name");if(null==d)throw new Error("Missing entity value");if(this.pe=!!b,this.name=this.stringify.eleName(c),e(d)){if(!d.pubID&&!d.sysID)throw new Error("Public and/or system identifiers are required for an external entity");if(d.pubID&&!d.sysID)throw new Error("System identifier is required for a public external entity");if(null!=d.pubID&&(this.pubID=this.stringify.dtdPubID(d.pubID)),null!=d.sysID&&(this.sysID=this.stringify.dtdSysID(d.sysID)),null!=d.nData&&(this.nData=this.stringify.dtdNData(d.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity")}else this.value=this.stringify.dtdEntityValue(d)}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":118,"lodash/isObject":132}],173:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing notation name");if(!c.pubID&&!c.sysID)throw new Error("Public or system identifiers are required for an external entity");this.name=this.stringify.eleName(b),null!=c.pubID&&(this.pubID=this.stringify.dtdPubID(c.pubID)),null!=c.sysID&&(this.sysID=this.stringify.dtdSysID(c.sysID))}return a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":118}],174:[function(a,b,c){(function(){var c,d,e,f,g=function(a,b){function c(){this.constructor=a}for(var d in b)h.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},h={}.hasOwnProperty;e=a("lodash/create"),f=a("lodash/isObject"),d=a("./XMLNode"),b.exports=c=function(a){function b(a,c,d,e){var g;b.__super__.constructor.call(this,a),f(c)&&(g=c,c=g.version,d=g.encoding,e=g.standalone),c||(c="1.0"),this.version=this.stringify.xmlVersion(c),null!=d&&(this.encoding=this.stringify.xmlEncoding(d)),null!=e&&(this.standalone=this.stringify.xmlStandalone(e))}return g(b,a),b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},b}(d)}).call(this)},{"./XMLNode":177,"lodash/create":118,"lodash/isObject":132}],175:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l;k=a("lodash/create"),l=a("lodash/isObject"),c=a("./XMLCData"),d=a("./XMLComment"),e=a("./XMLDTDAttList"),g=a("./XMLDTDEntity"),f=a("./XMLDTDElement"),h=a("./XMLDTDNotation"),j=a("./XMLProcessingInstruction"),b.exports=i=function(){function a(a,b,c){var d,e;this.documentObject=a,this.stringify=this.documentObject.stringify,this.children=[],l(b)&&(d=b,b=d.pubID,c=d.sysID),null==c&&(e=[b,c],c=e[0],b=e[1]),null!=b&&(this.pubID=this.stringify.dtdPubID(b)),null!=c&&(this.sysID=this.stringify.dtdSysID(c))}return a.prototype.element=function(a,b){var c;return c=new f(this,a,b),this.children.push(c),this},a.prototype.attList=function(a,b,c,d,f){var g;return g=new e(this,a,b,c,d,f),this.children.push(g),this},a.prototype.entity=function(a,b){var c;return c=new g(this,!1,a,b),this.children.push(c),this},a.prototype.pEntity=function(a,b){var c;return c=new g(this,!0,a,b),this.children.push(c),this},a.prototype.notation=function(a,b){var c;return c=new h(this,a,b),this.children.push(c),this},a.prototype.cdata=function(a){var b;return b=new c(this,a),this.children.push(b),this},a.prototype.comment=function(a){var b;return b=new d(this,a),this.children.push(b),this},a.prototype.instruction=function(a,b){var c;return c=new j(this,a,b),this.children.push(c),this},a.prototype.root=function(){return this.documentObject.root()},a.prototype.document=function(){return this.documentObject},a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;if(i=(null!=a?a.pretty:void 0)||!1,e=null!=(k=null!=a?a.indent:void 0)?k:" ",h=null!=(l=null!=a?a.offset:void 0)?l:0,g=null!=(m=null!=a?a.newline:void 0)?m:"\n",b||(b=0),o=new Array(b+h+1).join(e),j="",i&&(j+=o),j+="0){for(j+=" [",i&&(j+=g),n=this.children,d=0,f=n.length;f>d;d++)c=n[d],j+=c.toString(a,b+1);j+="]"}return j+=">",i&&(j+=g),j},a.prototype.ele=function(a,b){return this.element(a,b)},a.prototype.att=function(a,b,c,d,e){return this.attList(a,b,c,d,e)},a.prototype.ent=function(a,b){return this.entity(a,b)},a.prototype.pent=function(a,b){return this.pEntity(a,b)},a.prototype.not=function(a,b){return this.notation(a,b)},a.prototype.dat=function(a){return this.cdata(a)},a.prototype.com=function(a){return this.comment(a)},a.prototype.ins=function(a,b){return this.instruction(a,b)},a.prototype.up=function(){return this.root()},a.prototype.doc=function(){return this.document()},a}()}).call(this)},{"./XMLCData":168,"./XMLComment":169,"./XMLDTDAttList":170,"./XMLDTDElement":171,"./XMLDTDEntity":172,"./XMLDTDNotation":173,"./XMLProcessingInstruction":178,"lodash/create":118,"lodash/isObject":132}],176:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k=function(a,b){function c(){this.constructor=a}for(var d in b)l.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l={}.hasOwnProperty;g=a("lodash/create"),j=a("lodash/isObject"),i=a("lodash/isFunction"),h=a("lodash/every"),e=a("./XMLNode"),c=a("./XMLAttribute"),f=a("./XMLProcessingInstruction"),b.exports=d=function(a){function b(a,c,d){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing element name");this.name=this.stringify.eleName(c),this.children=[],this.instructions=[],this.attributes={},null!=d&&this.attribute(d)}return k(b,a),b.prototype.clone=function(){var a,c,d,e,f,h,i,j;d=g(b.prototype,this),d.isRoot&&(d.documentObject=null),d.attributes={},i=this.attributes;for(c in i)l.call(i,c)&&(a=i[c],d.attributes[c]=a.clone());for(d.instructions=[],j=this.instructions,e=0,f=j.length;f>e;e++)h=j[e],d.instructions.push(h.clone());return d.children=[],this.children.forEach(function(a){var b;return b=a.clone(),b.parent=d,d.children.push(b)}),d},b.prototype.attribute=function(a,b){var d,e;if(null!=a&&(a=a.valueOf()),j(a))for(d in a)l.call(a,d)&&(e=a[d],this.attribute(d,e));else i(b)&&(b=b.apply()),this.options.skipNullAttributes&&null==b||(this.attributes[a]=new c(this,a,b));return this},b.prototype.removeAttribute=function(a){var b,c,d;if(null==a)throw new Error("Missing attribute name");if(a=a.valueOf(),Array.isArray(a))for(c=0,d=a.length;d>c;c++)b=a[c],delete this.attributes[b];else delete this.attributes[a];return this},b.prototype.instruction=function(a,b){var c,d,e,g,h;if(null!=a&&(a=a.valueOf()),null!=b&&(b=b.valueOf()),Array.isArray(a))for(c=0,h=a.length;h>c;c++)d=a[c],this.instruction(d);else if(j(a))for(d in a)l.call(a,d)&&(e=a[d],this.instruction(d,e));else i(b)&&(b=b.apply()),g=new f(this,a,b),this.instructions.push(g);return this},b.prototype.toString=function(a,b){var c,d,e,f,g,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x;for(p=(null!=a?a.pretty:void 0)||!1,f=null!=(r=null!=a?a.indent:void 0)?r:" ",o=null!=(s=null!=a?a.offset:void 0)?s:0,n=null!=(t=null!=a?a.newline:void 0)?t:"\n",b||(b=0),x=new Array(b+o+1).join(f),q="",u=this.instructions,e=0,j=u.length;j>e;e++)g=u[e],q+=g.toString(a,b);p&&(q+=x),q+="<"+this.name,v=this.attributes;for(m in v)l.call(v,m)&&(c=v[m],q+=c.toString(a));if(0===this.children.length||h(this.children,function(a){return""===a.value}))q+="/>",p&&(q+=n);else if(p&&1===this.children.length&&null!=this.children[0].value)q+=">",q+=this.children[0].value,q+="",q+=n;else{for(q+=">",p&&(q+=n),w=this.children,i=0,k=w.length;k>i;i++)d=w[i],q+=d.toString(a,b+1);p&&(q+=x),q+="",p&&(q+=n)}return q},b.prototype.att=function(a,b){return this.attribute(a,b)},b.prototype.ins=function(a,b){return this.instruction(a,b)},b.prototype.a=function(a,b){return this.attribute(a,b)},b.prototype.i=function(a,b){return this.instruction(a,b)},b}(e)}).call(this)},{"./XMLAttribute":166,"./XMLNode":177,"./XMLProcessingInstruction":178,"lodash/create":118,"lodash/every":120,"lodash/isFunction":129,"lodash/isObject":132}],177:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l,m,n={}.hasOwnProperty;m=a("lodash/isObject"),l=a("lodash/isFunction"),k=a("lodash/isEmpty"),g=null,c=null,d=null,e=null,f=null,i=null,j=null,b.exports=h=function(){function b(b){this.parent=b,this.options=this.parent.options,this.stringify=this.parent.stringify,null===g&&(g=a("./XMLElement"),c=a("./XMLCData"),d=a("./XMLComment"),e=a("./XMLDeclaration"),f=a("./XMLDocType"),i=a("./XMLRaw"),j=a("./XMLText"))}return b.prototype.element=function(a,b,c){var d,e,f,g,h,i,j,o,p,q;if(i=null,null==b&&(b={}),b=b.valueOf(),m(b)||(p=[b,c],c=p[0],b=p[1]),null!=a&&(a=a.valueOf()),Array.isArray(a))for(f=0,j=a.length;j>f;f++)e=a[f],i=this.element(e);else if(l(a))i=this.element(a.apply());else if(m(a)){for(h in a)if(n.call(a,h))if(q=a[h],l(q)&&(q=q.apply()),m(q)&&k(q)&&(q=null),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===h.indexOf(this.stringify.convertAttKey))i=this.attribute(h.substr(this.stringify.convertAttKey.length),q);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===h.indexOf(this.stringify.convertPIKey))i=this.instruction(h.substr(this.stringify.convertPIKey.length),q);else if(!this.options.separateArrayItems&&Array.isArray(q))for(g=0,o=q.length;o>g;g++)e=q[g],d={},d[h]=e,i=this.element(d);else m(q)?(i=this.element(h),i.element(q)):i=this.element(h,q)}else i=!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?this.text(c):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===a.indexOf(this.stringify.convertCDataKey)?this.cdata(c):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===a.indexOf(this.stringify.convertCommentKey)?this.comment(c):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===a.indexOf(this.stringify.convertRawKey)?this.raw(c):this.node(a,b,c);if(null==i)throw new Error("Could not create any elements with: "+a);return i},b.prototype.insertBefore=function(a,b,c){var d,e,f;if(this.isRoot)throw new Error("Cannot insert elements at root level");return e=this.parent.children.indexOf(this),f=this.parent.children.splice(e),d=this.parent.element(a,b,c),Array.prototype.push.apply(this.parent.children,f),d},b.prototype.insertAfter=function(a,b,c){var d,e,f;if(this.isRoot)throw new Error("Cannot insert elements at root level");return e=this.parent.children.indexOf(this),f=this.parent.children.splice(e+1),d=this.parent.element(a,b,c),Array.prototype.push.apply(this.parent.children,f),d},b.prototype.remove=function(){var a,b;if(this.isRoot)throw new Error("Cannot remove the root element");return a=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[a,a-a+1].concat(b=[])),b,this.parent},b.prototype.node=function(a,b,c){var d,e;return null!=a&&(a=a.valueOf()),null==b&&(b={}),b=b.valueOf(),m(b)||(e=[b,c],c=e[0],b=e[1]),d=new g(this,a,b),null!=c&&d.text(c),this.children.push(d),d},b.prototype.text=function(a){var b;return b=new j(this,a),this.children.push(b),this},b.prototype.cdata=function(a){var b;return b=new c(this,a),this.children.push(b),this},b.prototype.comment=function(a){var b;return b=new d(this,a),this.children.push(b),this},b.prototype.raw=function(a){var b;return b=new i(this,a),this.children.push(b),this},b.prototype.declaration=function(a,b,c){var d,f;return d=this.document(),f=new e(d,a,b,c),d.xmldec=f,d.root()},b.prototype.doctype=function(a,b){var c,d;return c=this.document(),d=new f(c,a,b),c.doctype=d,d},b.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},b.prototype.root=function(){var a;if(this.isRoot)return this;for(a=this.parent;!a.isRoot;)a=a.parent;return a},b.prototype.document=function(){return this.root().documentObject},b.prototype.end=function(a){return this.document().toString(a)},b.prototype.prev=function(){var a;if(this.isRoot)throw new Error("Root node has no siblings");if(a=this.parent.children.indexOf(this),1>a)throw new Error("Already at the first node");return this.parent.children[a-1]},b.prototype.next=function(){var a;if(this.isRoot)throw new Error("Root node has no siblings"); +if(a=this.parent.children.indexOf(this),-1===a||a===this.parent.children.length-1)throw new Error("Already at the last node");return this.parent.children[a+1]},b.prototype.importXMLBuilder=function(a){var b;return b=a.root().clone(),b.parent=this,b.isRoot=!1,this.children.push(b),this},b.prototype.ele=function(a,b,c){return this.element(a,b,c)},b.prototype.nod=function(a,b,c){return this.node(a,b,c)},b.prototype.txt=function(a){return this.text(a)},b.prototype.dat=function(a){return this.cdata(a)},b.prototype.com=function(a){return this.comment(a)},b.prototype.doc=function(){return this.document()},b.prototype.dec=function(a,b,c){return this.declaration(a,b,c)},b.prototype.dtd=function(a,b){return this.doctype(a,b)},b.prototype.e=function(a,b,c){return this.element(a,b,c)},b.prototype.n=function(a,b,c){return this.node(a,b,c)},b.prototype.t=function(a){return this.text(a)},b.prototype.d=function(a){return this.cdata(a)},b.prototype.c=function(a){return this.comment(a)},b.prototype.r=function(a){return this.raw(a)},b.prototype.u=function(){return this.up()},b}()}).call(this)},{"./XMLCData":168,"./XMLComment":169,"./XMLDeclaration":174,"./XMLDocType":175,"./XMLElement":176,"./XMLRaw":179,"./XMLText":181,"lodash/isEmpty":128,"lodash/isFunction":129,"lodash/isObject":132}],178:[function(a,b,c){(function(){var c,d;d=a("lodash/create"),b.exports=c=function(){function a(a,b,c){if(this.stringify=a.stringify,null==b)throw new Error("Missing instruction target");this.target=this.stringify.insTarget(b),c&&(this.value=this.stringify.insValue(c))}return a.prototype.clone=function(){return d(a.prototype,this)},a.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+="",f&&(g+=d),g},a}()}).call(this)},{"lodash/create":118}],179:[function(a,b,c){(function(){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("lodash/create"),c=a("./XMLNode"),b.exports=d=function(a){function b(a,c){if(b.__super__.constructor.call(this,a),null==c)throw new Error("Missing raw text");this.value=this.stringify.raw(c)}return f(b,a),b.prototype.clone=function(){return e(b.prototype,this)},b.prototype.toString=function(a,b){var c,d,e,f,g,h,i,j,k;return f=(null!=a?a.pretty:void 0)||!1,c=null!=(h=null!=a?a.indent:void 0)?h:" ",e=null!=(i=null!=a?a.offset:void 0)?i:0,d=null!=(j=null!=a?a.newline:void 0)?j:"\n",b||(b=0),k=new Array(b+e+1).join(c),g="",f&&(g+=k),g+=this.value,f&&(g+=d),g},b}(c)}).call(this)},{"./XMLNode":177,"lodash/create":118}],180:[function(a,b,c){(function(){var a,c=function(a,b){return function(){return a.apply(b,arguments)}},d={}.hasOwnProperty;b.exports=a=function(){function a(a){this.assertLegalChar=c(this.assertLegalChar,this);var b,e,f;this.allowSurrogateChars=null!=a?a.allowSurrogateChars:void 0,this.noDoubleEncoding=null!=a?a.noDoubleEncoding:void 0,e=(null!=a?a.stringify:void 0)||{};for(b in e)d.call(e,b)&&(f=e[b],this[b]=f)}return a.prototype.eleName=function(a){return a=""+a||"",this.assertLegalChar(a)},a.prototype.eleText=function(a){return a=""+a||"",this.assertLegalChar(this.elEscape(a))},a.prototype.cdata=function(a){if(a=""+a||"",a.match(/]]>/))throw new Error("Invalid CDATA text: "+a);return this.assertLegalChar(a)},a.prototype.comment=function(a){if(a=""+a||"",a.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+a);return this.assertLegalChar(a)},a.prototype.raw=function(a){return""+a||""},a.prototype.attName=function(a){return""+a||""},a.prototype.attValue=function(a){return a=""+a||"",this.attEscape(a)},a.prototype.insTarget=function(a){return""+a||""},a.prototype.insValue=function(a){if(a=""+a||"",a.match(/\?>/))throw new Error("Invalid processing instruction value: "+a);return a},a.prototype.xmlVersion=function(a){if(a=""+a||"",!a.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+a);return a},a.prototype.xmlEncoding=function(a){if(a=""+a||"",!a.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/))throw new Error("Invalid encoding: "+a);return a},a.prototype.xmlStandalone=function(a){return a?"yes":"no"},a.prototype.dtdPubID=function(a){return""+a||""},a.prototype.dtdSysID=function(a){return""+a||""},a.prototype.dtdElementValue=function(a){return""+a||""},a.prototype.dtdAttType=function(a){return""+a||""},a.prototype.dtdAttDefault=function(a){return null!=a?""+a||"":a},a.prototype.dtdEntityValue=function(a){return""+a||""},a.prototype.dtdNData=function(a){return""+a||""},a.prototype.convertAttKey="@",a.prototype.convertPIKey="?",a.prototype.convertTextKey="#text",a.prototype.convertCDataKey="#cdata",a.prototype.convertCommentKey="#comment",a.prototype.convertRawKey="#raw",a.prototype.assertLegalChar=function(a){var b,c;if(b=this.allowSurrogateChars?/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/:/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/,c=a.match(b))throw new Error("Invalid character ("+c+") in string: "+a+" at index "+c.index);return a},a.prototype.elEscape=function(a){var b;return b=this.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(b,"&").replace(//g,">").replace(/\r/g," ")},a.prototype.attEscape=function(a){var b;return b=this.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(b,"&").replace(/ - + diff --git a/samples/webrtc/config.js b/samples/webrtc/config.js index d7f087fac..9be1bf7b3 100644 --- a/samples/webrtc/config.js +++ b/samples/webrtc/config.js @@ -5,7 +5,7 @@ * * Possible options: * https://examples.com?users=prod - * https://examples.com?users=dev + * https://examples.com?users=dev * https://examples.com - for qa by default */ var usersQuery = _getQueryVar('users'); @@ -15,7 +15,8 @@ webrtc: { answerTimeInterval: 30, dialingTimeInterval: 5, - disconnectTimeInterval: 30 + disconnectTimeInterval: 30, + statsReportTimeInterval: 5 } }; @@ -231,4 +232,4 @@ window.CONFIG = CONFIG; window.QBUsers = QBUsers; window.MESSAGES = MESSAGES; -}(window)); \ No newline at end of file +}(window)); diff --git a/samples/webrtc/js/app.js b/samples/webrtc/js/app.js index 41c3dc58a..9e513fae5 100644 --- a/samples/webrtc/js/app.js +++ b/samples/webrtc/js/app.js @@ -3,98 +3,98 @@ /** when DOM is ready */ $(function() { var ui = { - $usersTitle: $('.j-users__title'), - $usersList: $('.j-users__list'), - - $panel: $('.j-pl'), - $callees: $('.j-callees'), - - $btnCall: $('.j-call'), - $btnHangup: $('.j-hangup'), - - $ctrlBtn: $('.j-caller__ctrl'), - filterClassName: '.j-filter', - - modal: { - 'income_call': '#income_call' - }, - - sounds: { - 'call': 'callingSignal', - 'end': 'endCallSignal', - 'rington': 'ringtoneSignal' - }, - setPositionFooter: function() { - var $footer = $('.j-footer'), - invisibleClassName = 'invisible', - footerFixedClassName = 'footer-fixed'; - - if( $(window).outerHeight() > $('.j-wrapper').outerHeight() ) { - $footer.addClass(footerFixedClassName); - } else { - $footer.removeClass(footerFixedClassName); - } - - $footer.removeClass(invisibleClassName); - }, - togglePreloadMain: function(action) { - var $main = $('.j-main'), - preloadClassName = 'main-preload'; + $usersTitle: $('.j-users__title'), + $usersList: $('.j-users__list'), + + $panel: $('.j-pl'), + $callees: $('.j-callees'), + + $btnCall: $('.j-call'), + $btnHangup: $('.j-hangup'), + + $ctrlBtn: $('.j-caller__ctrl'), + filterClassName: '.j-filter', + + modal: { + 'income_call': '#income_call' + }, + + sounds: { + 'call': 'callingSignal', + 'end': 'endCallSignal', + 'rington': 'ringtoneSignal' + }, + setPositionFooter: function() { + var $footer = $('.j-footer'), + invisibleClassName = 'invisible', + footerFixedClassName = 'footer-fixed'; + + if( $(window).outerHeight() > $('.j-wrapper').outerHeight() ) { + $footer.addClass(footerFixedClassName); + } else { + $footer.removeClass(footerFixedClassName); + } - if(action === 'show') { - $main.addClass( preloadClassName ); - } else { - $main.removeClass( preloadClassName ); - } - }, - createUsers: function(users, $node) { - var tpl = _.template( $('#user_tpl').html() ), - usersHTML = ''; + $footer.removeClass(invisibleClassName); + }, + togglePreloadMain: function(action) { + var $main = $('.j-main'), + preloadClassName = 'main-preload'; - $node.empty(); + if(action === 'show') { + $main.addClass( preloadClassName ); + } else { + $main.removeClass( preloadClassName ); + } + }, + createUsers: function(users, $node) { + var tpl = _.template( $('#user_tpl').html() ), + usersHTML = ''; - _.each(users, function(user, i, list) { - usersHTML += tpl(user); - }); + $node.empty(); - $node.append(usersHTML); - }, - showCallBtn: function() { - this.$btnHangup.addClass('hidden'); - this.$btnCall.removeClass('hidden'); - }, - hideCallBtn: function() { - this.$btnHangup.removeClass('hidden'); - this.$btnCall.addClass('hidden'); - }, - toggleRemoteVideoView: function(userID, action) { - var $video = $('#remote_video_' + userID); - - if(!_.isEmpty(app.currentSession) && $video.length){ - if(action === 'show') { - $video.parents('.j-callee').removeClass('callees__callee-wait'); - } else if(action === 'hide') { - $video.parents('.j-callee').addClass('callees__callee-wait'); - } else if(action === 'clear') { - /** detachMediaStream take videoElementId */ - app.currentSession.detachMediaStream('remote_video_' + userID); - $video.removeClass('fw-video-wait'); - } - } - }, - classesNameFilter: 'no aden reyes perpetua inkwell toaster walden hudson gingham mayfair lofi xpro2 _1977 brooklyn', - changeFilter: function(selector, filterName) { - $(selector) - .removeClass(this.classesNameFilter) - .addClass( filterName ); - }, - callTime: 0, - updTimer: function() { - this.callTime += 1000; + _.each(users, function(user, i, list) { + usersHTML += tpl(user); + }); - $('#timer').removeClass('hidden') - .text( new Date(this.callTime).toUTCString().split(/ /)[4] ); - } + $node.append(usersHTML); + }, + showCallBtn: function() { + this.$btnHangup.addClass('hidden'); + this.$btnCall.removeClass('hidden'); + }, + hideCallBtn: function() { + this.$btnHangup.removeClass('hidden'); + this.$btnCall.addClass('hidden'); + }, + toggleRemoteVideoView: function(userID, action) { + var $video = $('#remote_video_' + userID); + + if(!_.isEmpty(app.currentSession) && $video.length){ + if(action === 'show') { + $video.parents('.j-callee').removeClass('callees__callee-wait'); + } else if(action === 'hide') { + $video.parents('.j-callee').addClass('callees__callee-wait'); + } else if(action === 'clear') { + /** detachMediaStream take videoElementId */ + app.currentSession.detachMediaStream('remote_video_' + userID); + $video.removeClass('fw-video-wait'); + } + } + }, + classesNameFilter: 'no aden reyes perpetua inkwell toaster walden hudson gingham mayfair lofi xpro2 _1977 brooklyn', + changeFilter: function(selector, filterName) { + $(selector) + .removeClass(this.classesNameFilter) + .addClass( filterName ); + }, + callTime: 0, + updTimer: function() { + this.callTime += 1000; + + $('#timer').removeClass('hidden') + .text( new Date(this.callTime).toUTCString().split(/ /)[4] ); + } }, app = { caller: {}, @@ -106,7 +106,13 @@ takedCallCallee = [], remoteStreamCounter = 0, authorizationing = false, - callTimer; + callTimer, + network = { + users: {} + }, + is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + + window.app = app; function initializeUI(arg) { var params = arg || {}; @@ -130,6 +136,48 @@ } } + function isBytesReceivedChanges(userId, inboundrtp) { + var res = true, + inbBytesRec = inboundrtp.bytesReceived; + + if(network[userId] === undefined) { + network[userId] = { + 'bytesReceived': inbBytesRec + }; + } else { + if(network[userId].bytesReceived === inbBytesRec) { + res = false; + } else { + network[userId] = { + 'bytesReceived': inbBytesRec + }; + } + } + + return res; + } + + function notifyIfUserLeaveCall(session, userId, reason, title) { + /** It's for p2p call */ + var userInfo = _.findWhere(QBUsers, {id: +userId}), + currentUserInfo = _.findWhere(QBUsers, {id: session.currentUserID}); + + /** It's for p2p call */ + if(session.opponentsIDs.length === 1) { + qbApp.MsgBoard.update( + 'p2p_call_stop', + { + name: userInfo.full_name, + currentName: currentUserInfo.full_name, + reason: reason + } + ); + } + + /** It's for groups call */ + $('.j-callee_status_' + userId).text(title); + } + /** * INITIALIZE */ @@ -450,6 +498,7 @@ * Chat: * - onDisconnectedListener * WebRTC: + * - onCallStatsReport * - onSessionCloseListener * - onUserNotAnswerListener * - onUpdateCallListener @@ -480,6 +529,32 @@ authorizationing = false; }; + QB.webrtc.onCallStatsReport = function onCallStatsReport(session, userId, stats) { + console.group('onCallStatsReport'); + console.log('userId: ' + userId); + // console.log('Stats: ', stats); + console.groupEnd(); + + /** + * Hack for Firefox + * (https://bugzilla.mozilla.org/show_bug.cgi?id=852665) + */ + if(is_firefox) { + var inboundrtp = _.findWhere(stats, {type: 'inboundrtp'}); + + if(!inboundrtp || !isBytesReceivedChanges(userId, inboundrtp)) { + + console.warn("This is Firefox and user " + userId + " has lost his connection."); + + if(!_.isEmpty(app.currentSession)) { + app.currentSession.closeConnection(userId); + + notifyIfUserLeaveCall(session, userId, 'disconnected', 'Disconnected'); + } + } + } + }; + QB.webrtc.onSessionCloseListener = function onSessionCloseListener(session){ console.log('onSessionCloseListener: ' + session); @@ -625,24 +700,7 @@ console.log('Extension: ' + JSON.stringify(extension)); console.groupEnd(); - /** It's for p2p call */ - var userInfo = _.findWhere(QBUsers, {id: userId}), - currentUserInfo = _.findWhere(QBUsers, {id: app.currentSession.currentUserID}); - - /** It's for p2p call */ - if(session.opponentsIDs.length === 1) { - qbApp.MsgBoard.update( - 'p2p_call_stop', - { - name: userInfo.full_name, - currentName: currentUserInfo.full_name, - reason: 'hung up the call' - } - ); - } - - /** It's for groups call */ - $('.j-callee_status_' + userId).text('Hung Up'); + notifyIfUserLeaveCall(session, userId, 'hung up the call', 'Hung Up'); }; QB.webrtc.onRemoteStreamListener = function onRemoteStreamListener(session, userID, stream) { @@ -662,7 +720,7 @@ } if(!callTimer) { - callTimer = setInterval( function(){ ui.updTimer.call(ui) }, 1000); + callTimer = setInterval( function(){ ui.updTimer.call(ui); }, 1000); } }; @@ -737,10 +795,11 @@ if( _.isEmpty(app.currentSession) || isCallEnded ) { if(callTimer) { $('#timer').addClass('hidden'); - clearInterval(callTimer); callTimer = null; ui.callTime = 0; + + network = {}; } } }