diff --git a/js/modules/qbChat.js b/js/modules/qbChat.js index 1ffc061dc..ec01d81bb 100644 --- a/js/modules/qbChat.js +++ b/js/modules/qbChat.js @@ -99,7 +99,7 @@ function ChatProxy(service, webrtcModule, conn) { // if(composing || paused){ if (typeof self.onMessageTypingListener === 'function' && (type === 'chat' || type === 'groupchat' || !delay)){ - self.onMessageTypingListener(composing != null, userId, dialogId); + Utils.safeCallbackCall(self.onMessageTypingListener, composing != null, userId, dialogId); } return true; } @@ -109,11 +109,11 @@ function ChatProxy(service, webrtcModule, conn) { if (marker) { if (delivered) { if (typeof self.onDeliveredStatusListener === 'function' && type === 'chat') { - self.onDeliveredStatusListener(delivered.getAttribute('id'), dialogId, userId); + Utils.safeCallbackCall(self.onDeliveredStatusListener, delivered.getAttribute('id'), dialogId, userId); } } else { if (typeof self.onReadStatusListener === 'function' && type === 'chat') { - self.onReadStatusListener(read.getAttribute('id'), dialogId, userId); + Utils.safeCallbackCall(self.onReadStatusListener, read.getAttribute('id'), dialogId, userId); } } return true; @@ -144,7 +144,7 @@ function ChatProxy(service, webrtcModule, conn) { message.markable = 1; } if (typeof self.onMessageListener === 'function' && (type === 'chat' || type === 'groupchat')){ - self.onMessageListener(userId, message); + Utils.safeCallbackCall(self.onMessageListener, userId, message); } // we must return true to keep the handler alive @@ -159,7 +159,7 @@ function ChatProxy(service, webrtcModule, conn) { if (!type) { if (typeof self.onContactListListener === 'function' && roster[userId] && roster[userId].subscription !== 'none') - self.onContactListListener(userId); + Utils.safeCallbackCall(self.onContactListListener, userId); } else { // subscriptions callbacks @@ -176,7 +176,7 @@ function ChatProxy(service, webrtcModule, conn) { }); } else { if (typeof self.onSubscribeListener === 'function') - self.onSubscribeListener(userId); + Utils.safeCallbackCall(self.onSubscribeListener, userId); } break; case 'subscribed': @@ -191,7 +191,7 @@ function ChatProxy(service, webrtcModule, conn) { ask: null }; if (typeof self.onConfirmSubscribeListener === 'function') - self.onConfirmSubscribeListener(userId); + Utils.safeCallbackCall(self.onConfirmSubscribeListener, userId); } break; case 'unsubscribed': @@ -200,7 +200,7 @@ function ChatProxy(service, webrtcModule, conn) { ask: null }; if (typeof self.onRejectSubscribeListener === 'function') - self.onRejectSubscribeListener(userId); + Utils.safeCallbackCall(self.onRejectSubscribeListener, userId); break; case 'unsubscribe': roster[userId] = { @@ -212,7 +212,7 @@ function ChatProxy(service, webrtcModule, conn) { break; case 'unavailable': if (typeof self.onContactListListener === 'function' && roster[userId] && roster[userId].subscription !== 'none') - self.onContactListListener(userId, type); + Utils.safeCallbackCall(self.onContactListListener, userId, type); break; } @@ -251,7 +251,7 @@ function ChatProxy(service, webrtcModule, conn) { extension: extraParamsParsed.extension }; - self.onSystemMessageListener(message); + Utils.safeCallbackCall(self.onSystemMessageListener, message); } return true; @@ -341,7 +341,7 @@ ChatProxy.prototype = { // fire 'onReconnectListener' if (typeof self.onReconnectListener === 'function'){ - self.onReconnectListener(); + Utils.safeCallbackCall(self.onReconnectListener); } } }); @@ -358,7 +358,7 @@ ChatProxy.prototype = { // fire 'onDisconnectedListener' only once if (!self._isDisconnected && typeof self.onDisconnectedListener === 'function'){ - self.onDisconnectedListener(); + Utils.safeCallbackCall(self.onDisconnectedListener); } self._isDisconnected = true; diff --git a/js/qbUtils.js b/js/qbUtils.js index 9af818085..db1d63a23 100644 --- a/js/qbUtils.js +++ b/js/qbUtils.js @@ -24,6 +24,27 @@ var ObjectId = { }; var Utils = { + safeCallbackCall: function() { + if(!isBrowser) throw unsupported; + + var listenerString = arguments[0].toString(), + listenerName = listenerString.split('(')[0].split(' ')[1], + argumentsCopy = [], + listenerCall; + + for (var i = 0; i < arguments.length; i++) { + argumentsCopy.push(arguments[i]); + } + + listenerCall = argumentsCopy.shift(); + + try { + listenerCall.apply(null, argumentsCopy); + } catch (err) { + console.error('Error in the ' + listenerName + ': ' + err); + } + }, + randomNonce: function() { return Math.floor(Math.random() * 10000); }, diff --git a/quickblox.min.js b/quickblox.min.js index 5c8e053bd..d251aae16 100644 --- a/quickblox.min.js +++ b/quickblox.min.js @@ -1,9 +1,9 @@ /* QuickBlox JavaScript SDK - v1.15.1 - 2015-11-09 */ -!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&&f.onReconnectListener()}})});break;case Strophe.Status.DISCONNECTING:m.QBLog("[ChatProxy]","Status.DISCONNECTING");break;case Strophe.Status.DISCONNECTED:m.QBLog("[ChatProxy]","Status.DISCONNECTED at "+k()),p.reset(),f._isDisconnected||"function"!=typeof f.onDisconnectedListener||f.onDisconnectedListener(),f._isDisconnected=!0,f._isLogout||f.connect(a);break;case Strophe.Status.ATTACHED:m.QBLog("[ChatProxy]","Status.ATTACHED")}})},send:function(a,b){if(!n)throw o;b.id||(b.id=m.getBsonObjectId());var c=this,d=$msg({from:p.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}),p.send(d)},sendSystemMessage:function(a,b){if(!n)throw o;b.id||(b.id=m.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()),p.send(d)},sendIsTypingStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("composing",{xmlns:"http://jabber.org/protocol/chatstates"}),p.send(b)},sendIsStopTypingStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("paused",{xmlns:"http://jabber.org/protocol/chatstates"}),p.send(b)},sendPres:function(a){if(!n)throw o;p.send($pres({from:p.jid,type:a}))},sendDeliveredStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:m.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),p.send(b)},sendReadStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:m.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),p.send(b)},disconnect:function(){if(!n)throw o;u={},this._isLogout=!0,p.flush(),p.disconnect()},addListener:function(a,b){function c(){return b(),a.live!==!1}if(!n)throw o;return p.addHandler(c,null,a.name||null,a.type||null,a.id||null,a.from||null)},deleteListener:function(a){if(!n)throw o;p.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(!n)throw o;return p.send($pres().tree()),!0},_enableCarbons:function(a){if(!n)throw o;var b;b=$iq({from:p.jid,type:"set",id:p.getUniqueId("enableCarbons")}).c("enable",{xmlns:Strophe.NS.CARBONS}),p.sendIQ(b,function(b){a()})}},e.prototype={get:function(a){var b,c,d,e=this,f={};b=$iq({from:p.jid,type:"get",id:p.getUniqueId("getRoster")}).c("query",{xmlns:Strophe.NS.ROSTER}),p.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();t[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();t[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();t[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:p.jid,type:"set",id:p.getUniqueId("removeRosterItem")}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:d,subscription:"remove"}),p.sendIQ(c,function(){delete t[e],"function"==typeof b&&b()})},_sendSubscriptionPresence:function(a){var b;b=$pres({to:a.jid,type:a.type}),p.send(b)}},f.prototype={join:function(a,b){var c,d=this,e=p.getUniqueId("join");u[a]=!0,c=$pres({from:p.jid,to:d.helpers.getRoomJid(a),id:e}).c("x",{xmlns:Strophe.NS.MUC}).c("history",{maxstanzas:0}),"function"==typeof b&&p.addHandler(b,null,"presence",null,e),p.send(c)},leave:function(a,b){var c,d=this,e=d.helpers.getRoomJid(a);delete u[a],c=$pres({from:p.jid,to:e,type:"unavailable"}),"function"==typeof b&&p.addHandler(b,null,"presence","unavailable",null,e),p.send(c)},listOnlineUsers:function(a,b){var c,d=this,e=[];c=$iq({from:p.jid,id:p.getUniqueId("muc_disco_items"),to:a,type:"get"}).c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),p.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={list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),m.QBLog("[DialogProxy]","list",a),this.service.ajax({url:m.getUrl(r),data:a},b)},create:function(a,b){a.occupants_ids instanceof Array&&(a.occupants_ids=a.occupants_ids.join(", ")),m.QBLog("[DialogProxy]","create",a),this.service.ajax({url:m.getUrl(r),type:"POST",data:a},b)},update:function(a,b,c){m.QBLog("[DialogProxy]","update",b),this.service.ajax({url:m.getUrl(r,a),type:"PUT",data:b},c)},"delete":function(a,b,c){m.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:m.getUrl(r,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:m.getUrl(r,a),type:"DELETE",data:b,dataType:"text"},c)}},h.prototype={list:function(a,b){m.QBLog("[MessageProxy]","list",a),this.service.ajax({url:m.getUrl(s),data:a},b)},create:function(a,b){m.QBLog("[MessageProxy]","create",a),this.service.ajax({url:m.getUrl(s),type:"POST",data:a},b)},update:function(a,b,c){m.QBLog("[MessageProxy]","update",a,b),this.service.ajax({url:m.getUrl(s,a),type:"PUT",data:b},c)},"delete":function(a,b,c){m.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:m.getUrl(s,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:m.getUrl(s,a),type:"DELETE",data:b,dataType:"text"},c)},unreadCount:function(a,b){m.QBLog("[MessageProxy]","unreadCount",a),this.service.ajax({url:m.getUrl(s+"/unread"),data:a},b)}},i.prototype={jidOrUserId:function(a){var b;if("string"==typeof a)b=a;else{if("number"!=typeof a)throw o;b=a+"-"+l.creds.appId+"@"+l.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 o;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 a+"-"+b+"@"+l.endpoints.chat},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]},getRoomJid:function(a){if(!n)throw o;return a+"/"+this.getIdFromNode(p.jid)},getIdFromResource:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),parseInt(b.join("/")))},getUniqueId:function(a){if(!n)throw o;return p.getUniqueId(a)},getBsonObjectId:function(){return m.getBsonObjectId()},getUserIdFromRoomJid:function(a){var b=a.toString().split("/");return 0==b.length?null:b[b.length-1]}},b.exports=d},{"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],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://api.quickblox.com/blobs/"+a+"/download?token="+this.service.getSession().token},publicUrl:function(a){return"https://api.quickblox.com/blobs/"+a+"/download"}},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":9,"../qbUtils":13,xml2js:47}],4:[function(a,b,c){function d(a){this.service=a}var e=a("../qbConfig"),f=a("../qbUtils");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;d=new FormData,d.append("field_name",b.field_name),d.append("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)})},updateFile:function(a,b,c){f.QBLog("[DataProxy]","updateFile",a,b);var d;d=new FormData,d.append("field_name",b.field_name),d.append("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":9,"../qbUtils":13}],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":9,"../qbUtils":13}],6:[function(a,b,c){function d(a){this.service=a,this.subscriptions=new e(a),this.events=new f(a)}function e(a){this.service=a}function f(a){this.service=a}var g=a("../qbConfig"),h=a("../qbUtils");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){h.QBLog("[EventsProxy]","list",params),this.service.ajax({url:h.getUrl(g.urls.events)},a)},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)},update:function(a,b){h.QBLog("[EventsProxy]","update",a);var c={event:a};this.service.ajax({url:h.getUrl(g.urls.events,a.id),type:"PUT",data:c},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},{"../qbConfig":9,"../qbUtils":13}],7:[function(a,b,c){function d(a){this.service=a}function e(a){var b=a.field in i?"date":typeof a.value;return a.value instanceof Array&&("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 i?"date":a.field in j?"number":"string";return[a.sort,b,a.field].join(" ")}var g=a("../qbConfig"),h=a("../qbUtils"),i=["created_at","updated_at","last_request_at"],j=["id","external_user_id"],k=g.urls.users+"/password/reset";d.prototype={listUsers:function(a,b){h.QBLog("[UsersProxy]","listUsers",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(k),data:{email:a}},b)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],8:[function(a,b,c){function d(a,b){var c=this;p=b,this.service=a,this.helpers=new e,this._onMessage=function(a){var b=a.getAttribute("from"),d=a.querySelector("extraParams"),e=a.querySelector("delay"),g=c.helpers.getIdFromNode(b),l=c._getExtension(d);l.sessionID;if(e||l.moduleIdentifier!==A)return!0;switch(delete l.moduleIdentifier,l.signalType){case z.CALL:if(f("onCall from "+g),B[g])return f("skip onCallListener, a user already got it"),!0;i(g),null==q&&j(g,c._answerTimeoutCallback),B[g]={sessionID:l.sessionID,sdp:l.sdp},l.callType="1"===l.callType?"video":"audio",delete l.sdp,"function"==typeof c.onCallListener&&c.onCallListener(g,l);break;case z.ACCEPT:f("onAccept from "+g),k(g),m(g),"object"==typeof q&&q.onRemoteSessionCallback(l.sdp,"answer"),delete l.sdp,"function"==typeof c.onAcceptCallListener&&c.onAcceptCallListener(g,l);break;case z.REJECT:f("onReject from "+g),k(g),m(g),c._close(),"function"==typeof c.onRejectCallListener&&c.onRejectCallListener(g,l);break;case z.STOP:f("onStop from "+g),k(g),m(g),h(g),c._close(),"function"==typeof c.onStopCallListener&&c.onStopCallListener(g,l);break;case z.CANDIDATE:"object"==typeof q&&(q.addCandidates(l.iceCandidates),"answer"===q.type&&c._sendCandidate(q.opponentId,q.iceCandidates));break;case z.PARAMETERS_CHANGED:f("onUpdateCall from "+g),"function"==typeof c.onUpdateCallListener&&c.onUpdateCallListener(g,l)}return!0},this._getExtension=function(a){var b,d,e,f,g={},h=[],i=[];if(a){for(var 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 l=0,m=e.length;m>l;l++)d=e[l].textContent,i.push(d)}else a.childNodes[j].childNodes.length>1?g=c._XMLtoJS(g,a.childNodes[j].tagName,a.childNodes[j]):g[a.childNodes[j].tagName]=a.childNodes[j].textContent;h.length>0&&(g.iceCandidates=h),i.length>0&&(g.opponents=i)}return g},this._answerTimeoutCallback=function(a){h(a),c._close(),"function"==typeof c.onSessionStateChangedListener&&c.onSessionStateChangedListener(c.SessionState.CLOSED,a)},this._callTimeoutCallback=function(a){f("User "+a+" not asnwer"),k(a),h(a),c._close(),"function"==typeof c.onUserNotAnswerListener&&c.onUserNotAnswerListener(a)}}function e(){}function f(a){s.debug&&t.QBLog("[QBWebRTC]",a)}function g(){var a=(new Date).toString().split(" ");return a.slice(1,5).join("-")}function h(a){var b=B[a];b&&delete B[a]}function i(a){var b=C[a];b&&(clearTimeout(b),delete C[a])}function j(a,b){var c=1e3*s.webrtc.answerTimeInterval,d=setTimeout(b,c,a);C[a]=d}function k(a){var b=D[a];b&&(clearInterval(b),delete D[a])}function l(a,b){var c=1e3*s.webrtc.dialingTimeInterval,d=setInterval(b,c);D[a]=d}function m(a){var b=E[a];b&&(clearTimeout(b),delete E[a])}function n(a,b){var c=1e3*s.webrtc.answerTimeInterval;f("startCallTimer, answerTimeInterval: "+c);var d=setTimeout(b,c,a);E[a]=d}function o(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})}a("../../lib/strophe/strophe.min");var p,q,r=a("../../lib/download/download.min"),s=a("../qbConfig"),t=a("../qbUtils"),u=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,v=window.RTCSessionDescription||window.mozRTCSessionDescription,w=window.RTCIceCandidate||window.mozRTCIceCandidate,x=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,y=window.URL||window.webkitURL,z={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},A="WebRTCVideoChat",B={},C={},D={},E={};d.prototype.SessionState={ -UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5},d.prototype.getUserMedia=function(a,b){if(!x)throw new Error("getUserMedia() is not supported in your browser");x=x.bind(navigator);var c=this;x({audio:a.audio||!1,video:a.video||!1},function(d){c.localStream=d,a.elemId&&c.attachMediaStream(a.elemId,d,a.options),b(null,d)},function(a){b(a,null)})},d.prototype.attachMediaStream=function(a,b,c){var d=document.getElementById(a);d&&(d.src=y.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.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=o(b,"image/png"),c.name="snapshot_"+g()+".png",c.url=b,c):void 0},d.prototype.filter=function(a,b){var c=document.getElementById(a);c&&(c.style.webkitFilter=b,c.style.filter=b)},d.prototype.mute=function(a){this._switchOffDevice(0,a)},d.prototype.unmute=function(a){this._switchOffDevice(1,a)},d.prototype._switchOffDevice=function(a,b){"audio"===b&&this.localStream.getAudioTracks().length>0&&this.localStream.getAudioTracks().forEach(function(b){b.enabled=!!a}),"video"===b&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach(function(b){b.enabled=!!a})},d.prototype._createPeer=function(a){if(!u)throw new Error("RTCPeerConnection() is not supported in your browser");if(!this.localStream)throw new Error("You don't have an access to the local stream");var b={iceServers:s.iceServers};q=new u(b),q.init(this,a),f("Peer._createPeer: "+q+", sessionID: "+q.sessionID)},d.prototype.call=function(a,b,c){f("Call. userId: "+a+", callType: "+b+", extension: "+JSON.stringify(c)),this._createPeer();var d=this,e=a instanceof Array?a:[a],g=e[0];q.opponentId=g,q.getSessionDescription(function(a,h){if(a)f("getSessionDescription error: "+a);else{k(g);var i=function(){d._sendMessage(g,c,"CALL",b,e)};i(),l(g,i),m(g),n(g,d._callTimeoutCallback)}})},d.prototype.accept=function(a,b){var b=b||{};f("Accept. userId: "+a+", extension: "+JSON.stringify(b)),i(a);var c=B[a];c&&this._createPeer({sessionID:c.sessionID,description:c.sdp});var d=this;q.opponentId=a,q.getSessionDescription(function(c,e){c?f(c):d._sendMessage(a,b,"ACCEPT")})},d.prototype.reject=function(a,b){var b=b||{};f("Reject. userId: "+a+", extension: "+JSON.stringify(b)),i(a),B[a]&&(b.sessionID=B[a].sessionID,delete B[a]),this._sendMessage(a,b,"REJECT")},d.prototype.stop=function(a,b){var b=b||{};f("Stop. userId: "+a+", extension: "+JSON.stringify(b)),i(a),k(a),m(a),this._sendMessage(a,b,"STOP"),this._close(),h(a)},d.prototype.update=function(a,b){var b=b||{};f("Update. userId: "+a+", extension: "+JSON.stringify(b)),this._sendMessage(a,b,"PARAMETERS_CHANGED")},d.prototype.close=function(){Object.keys(C).forEach(function(a){i(a)}),Object.keys(D).forEach(function(a){k(a)}),Object.keys(E).forEach(function(a){m(a)}),this._close(),Object.keys(B).forEach(function(a){h(a)})},d.prototype._close=function(){f("Peer._close"),q&&q.close(),this.localStream&&(this.localStream.stop(),this.localStream=null)},d.prototype._sendCandidate=function(a,b){var c={iceCandidates:b};this._sendMessage(a,c,"CANDIDATE")},d.prototype._sendMessage=function(a,b,c,d,e){var f,g,b=b||{},h=this;b.moduleIdentifier=A,b.signalType=z[c],b.sessionID=q&&q.sessionID||b.sessionID,d&&(b.callType="video"===d?"1":"2"),("CALL"===c||"ACCEPT"===c)&&(b.sdp=q.localDescription.sdp,b.platform="web"),"CALL"===c&&(b.callerID=this.helpers.getIdFromNode(p.jid),b.opponentsIDs=e),g={from:p.jid,to:this.helpers.getUserJid(a,this.service.getSession().application_id),type:"headline",id:t.getBsonObjectId()},f=$msg(g).c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b).forEach(function(a){"iceCandidates"===a?(f=f.c("iceCandidates"),b[a].forEach(function(a){f=f.c("iceCandidate"),Object.keys(a).forEach(function(b){f.c(b).t(a[b]).up()}),f.up()}),f.up()):"opponentsIDs"===a?(f=f.c("opponentsIDs"),b[a].forEach(function(a){f=f.c("opponentID").t(a).up()}),f.up()):"object"==typeof b[a]?h._JStoXML(a,b[a],f):f.c(a).t(b[a]).up()}),p.send(f)},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()},d.prototype._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},u&&(u.prototype.init=function(a,b){this.service=a,this.sessionID=b&&b.sessionID||Date.now(),this.type=b&&b.description?"answer":"offer",this.addStream(this.service.localStream),this.onicecandidate=this.onIceCandidateCallback,this.onaddstream=this.onRemoteStreamCallback,this.onsignalingstatechange=this.onSignalingStateCallback,this.oniceconnectionstatechange=this.onIceConnectionStateCallback,"answer"===this.type&&this.onRemoteSessionCallback(b.description,"offer")},u.prototype.getSessionDescription=function(a){function b(b){q.setLocalDescription(b,function(){a(null,b)},c)}function c(b){a(b,null)}"offer"===q.type?q.createOffer(b,c):q.createAnswer(b,c)},u.prototype.onIceCandidateCallback=function(a){var b=a.candidate;b&&(f("onICECandidate: "+JSON.stringify(b)),q.iceCandidates=q.iceCandidates||[],q.iceCandidates.push({sdpMLineIndex:b.sdpMLineIndex,sdpMid:b.sdpMid,candidate:b.candidate}))},u.prototype.onRemoteSessionCallback=function(a,b){var c=new v({sdp:a,type:b});this.setRemoteDescription(c)},u.prototype.onRemoteStreamCallback=function(a){"function"==typeof q.service.onRemoteStreamListener&&q.service.onRemoteStreamListener(a.stream)},u.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 w(b))},u.prototype.onSignalingStateCallback=function(){q&&"stable"===q.signalingState&&"offer"===q.type&&q.service._sendCandidate(q.opponentId,q.iceCandidates)},u.prototype.onIceConnectionStateCallback=function(){f("onIceConnectionStateCallback: "+q.iceConnectionState);var a=q.iceConnectionState;if("function"==typeof q.service.onSessionStateChangedListener){var b=null;"checking"===a?b=q.service.SessionState.CONNECTING:"connected"===a?b=q.service.SessionState.CONNECTED:"failed"===a?b=q.service.SessionState.FAILED:"disconnected"===a?b=q.service.SessionState.DISCONNECTED:"closed"===a&&(b=q.service.SessionState.CLOSED),null!=b&&q.service.onSessionStateChangedListener(b)}"closed"===a&&(q=null)}),e.prototype={getUserJid:function(a,b){return a+"-"+b+"@"+s.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])}},b.exports=d,Blob.prototype.download=function(){r(this,this.name,this.type)}},{"../../lib/download/download.min":14,"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],9:[function(a,b,c){var d={version:"1.15.1",creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com",turn:"turnserver.quickblox.com",s3Bucket:"qbprod"},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},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"}],webrtc:{answerTimeInterval:60,dialingTimeInterval:5},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.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])}))})},b.exports=d},{}],10:[function(a,b,c){function d(){}var e=a("./qbConfig"),f=(a("./qbUtils"),"undefined"!=typeof window);d.prototype={init:function(b,c,d,g){g&&"object"==typeof g&&e.set(g);var h=a("./qbProxy");this.service=new h;var i=a("./modules/qbAuth"),j=a("./modules/qbUsers"),k=a("./modules/qbChat"),l=a("./modules/qbContent"),m=a("./modules/qbLocation"),n=a("./modules/qbPushNotifications"),o=a("./modules/qbData");if(f){var p=a("./qbStrophe"),q=new p,r=a("./modules/qbWebRTC");this.webrtc=new r(this.service,q||null)}this.auth=new i(this.service),this.users=new j(this.service),this.chat=new k(this.service,this.webrtc||null,q||null),this.content=new l(this.service),this.location=new m(this.service),this.pushnotifications=new n(this.service),this.data=new o(this.service),"string"!=typeof b||c||d?(e.creds.appId=b,e.creds.authKey=c,e.creds.authSecret=d):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 g=new d;g.QuickBlox=d,b.exports=g},{"./modules/qbAuth":1,"./modules/qbChat":2,"./modules/qbContent":3,"./modules/qbData":4,"./modules/qbLocation":5,"./modules/qbPushNotifications":6,"./modules/qbUsers":7,"./modules/qbWebRTC":8,"./qbConfig":9,"./qbProxy":11,"./qbStrophe":12,"./qbUtils":13}],11:[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("://"+e.endpoints.s3Bucket)&&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("://"+e.endpoints.s3Bucket)&&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":9,"./qbUtils":13,request:20}],12:[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("../lib/strophe/strophe.min");var e=a("./qbConfig"),f=a("./qbUtils");b.exports=d},{"../lib/strophe/strophe.min":15,"./qbConfig":9,"./qbUtils":13}],13:[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={randomNonce:function(){return Math.floor(1e4*Math.random())},unixTime:function(){return Math.floor(Date.now()/1e3)},getUrl:function(a,b){var c=b?"/"+b:"";return"https://"+d.endpoints.api+"/"+a+c+d.urls.type},getBsonObjectId:function(){var a=this.unixTime().toString(16),b=(h.increment++).toString(16);return b>16777215&&(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;ag;++g)h[g]=e.charCodeAt(g);return new m([h],{type:c})}function e(a,b){if("download"in k)return k.href=a,k.setAttribute("download",p),k.innerHTML="downloading...",j.body.appendChild(k),setTimeout(function(){k.click(),j.body.removeChild(k),b===!0&&setTimeout(function(){f.URL.revokeObjectURL(k.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g),window.open(a)||confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=j.createElement("iframe");j.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g)),c.src=a,setTimeout(function(){j.body.removeChild(c)},333)}var f=window,g="application/octet-stream",h=c||g,i=a,j=document,k=j.createElement("a"),l=function(a){return String(a)},m=f.Blob||f.MozBlob||f.WebKitBlob||l;m=m.call?m.bind(f):Blob;var n,o,p=b||"download";if("true"===String(this)&&(i=[i,h],h=i[0],i=i[1]),String(i).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(d(i),p):e(i);if(n=i instanceof m?i:new m([i],{type:h}),navigator.msSaveBlob)return navigator.msSaveBlob(n,p);if(f.URL)e(f.URL.createObjectURL(n),!0);else{if("string"==typeof n||n.constructor===l)try{return e("data:"+h+";base64,"+f.btoa(n))}catch(q){return e("data:"+h+","+encodeURIComponent(n))}o=new FileReader,o.onload=function(){e(this.result)},o.readAsDataURL(n)}return!0}b.exports=d},{}],15:[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&&this.xmlInput(c.nodeName===this._proto.strip&&c.childNodes.length?c.childNodes[0]:c),this.rawInput!==h.Connection.prototype.rawInput&&this.rawInput(b?b: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&&this._conn.xmlOutput(d.xmlData.nodeName===this.strip&&d.xmlData.childNodes.length?d.xmlData.childNodes[0]: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(){a.debug(this._requests?"_throttledRequestHandler called with "+this._requests.length+" requests":"_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;cf;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})},{}],17:[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":16,"./hmac":18,"./sha1":19}],18:[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":16}],19:[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":16}],20:[function(a,b,c){},{}],21:[function(a,b,c){arguments[4][20][0].apply(c,arguments)},{dup:20}],22:[function(a,b,c){(function(b){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?(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("is-array");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.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":23,ieee754:24,"is-array":25}],23:[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)},{}],24:[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}},{}],25:[function(a,b,c){var d=Array.isArray,e=Object.prototype.toString;b.exports=d||function(a){return!!a&&"[object Array]"==e.call(a)}},{}],26:[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}},{}],27:[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}},{}],28:[function(a,b,c){b.exports=function(a){return!(null==a||!(a._isBuffer||a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)))}},{}],29:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],30:[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":34,"./_stream_writable":36,_process:30,"core-util-is":37,inherits:27}],33:[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":35,"core-util-is":37,inherits:27}],34:[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":32,_process:30,buffer:22,"core-util-is":37,events:26,inherits:27,isarray:29,stream:42,"string_decoder/":43,util:21}],35:[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:22}],44:[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":30}],45:[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":47}],46:[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)},{}],47:[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,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,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 c="object"==typeof h?f(c.ele(l),h).up():"string"==typeof h&&a.options.cdata&&j(h)?c.ele(l).raw(m(h)).up():c.ele(l,h.toString()).up();return c}}(this),g=d.create(h,this.options.xmldec,this.options.doctype,{headless:this.options.headless}),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;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))},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.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=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;if(l=d.pop(),k=l["#name"],a.options.explicitChildren&&a.options.preserveChildrenOrder||delete l["#name"],l.cdata===!0&&(c=l.cdata,delete l.cdata),p=d[d.length-1],l[b].match(/^\s*$/)&&!c?(e=l[b],delete l[b]):(a.options.trim&&(l[b]=l[b].trim()),a.options.normalize&&(l[b]=l[b].replace(/\s{2,}/g," ").trim()),l[b]=a.options.valueProcessors?h(a.options.valueProcessors,l[b]):l[b],1===Object.keys(l).length&&b in l&&!a.EXPLICIT_CHARKEY&&(l=l[b])),g(l)&&(l=""!==a.options.emptyTag?a.options.emptyTag:e),null!=a.options.validator){q="/"+function(){var a,b,c;for(c=[],a=0,b=d.length;b>a;a++)j=d[a],c.push(j["#name"]);return c}().concat(k).join("/");try{l=a.options.validator(q,p&&p[k],l)}catch(r){f=r,a.emit("error",f)}}if(a.options.explicitChildren&&!a.options.mergeAttrs&&"object"==typeof l)if(a.options.preserveChildrenOrder){if(p){p[a.options.childkey]=p[a.options.childkey]||[],m={};for(i in l)o.call(l,i)&&(m[i]=l[i]);p[a.options.childkey].push(m),delete l["#name"],1===Object.keys(l).length&&b in l&&!a.EXPLICIT_CHARKEY&&(l=l[b])}}else j={},a.options.attrkey in l&&(j[a.options.attrkey]=l[a.options.attrkey],delete l[a.options.attrkey]),!a.options.charsAsChildren&&a.options.charkey in l&&(j[a.options.charkey]=l[a.options.charkey],delete l[a.options.charkey]),Object.getOwnPropertyNames(l).length>0&&(j[a.options.childkey]=l),l=j;return d.length>0?a.assignOrPush(p,k,l):(a.options.explicitRoot&&(n=l,l={},l[k]=n),a.resultObject=l,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;if(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)})),a=a.toString(),""===a.trim())return this.emit("end",null),!0;try{return 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":45,"./processors":46,events:26,sax:48,timers:44,xmlbuilder:65}],48:[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=S.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=B.length;f>e;e++){var g=a[B[e]].length;if(g>b)switch(B[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: "+B[e])}d=Math.max(d,g)}a.bufferCheckPosition=c.MAX_BUFFER_LENGTH-d+a.position}function f(a){for(var b=0,c=B.length;c>b;b++)a[B[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);C.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,E.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)},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!==S.BEGIN&&a.state!==S.BEGIN_WHITESPACE&&a.state!==S.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 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=S.TEXT:a.state=S.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=S.TEXT);if(a.script){if("script"!==a.tagName)return a.script+="",a.tagName="",void(a.state=S.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=S.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=S.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){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="";b.c=d=a.charAt(c++);)switch(b.trackPosition&&(b.position++,"\n"===d?(b.line++,b.column=0):b.column++),b.state){case S.BEGIN:if(b.state=S.BEGIN_WHITESPACE,"\ufeff"===d)continue;case S.BEGIN_WHITESPACE:"<"===d?(b.state=S.OPEN_WAKA,b.startTagPosition=b.position):m(F,d)&&(t(b,"Non-whitespace before first tag."),b.textNode=d,b.state=S.TEXT);continue;case S.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(F,d)||b.sawRoot&&!b.closedRoot||t(b,"Text data outside of root node."),"&"===d?b.state=S.TEXT_ENTITY:b.textNode+=d):(b.state=S.OPEN_WAKA,b.startTagPosition=b.position);continue;case S.SCRIPT:"<"===d?b.state=S.SCRIPT_ENDING:b.script+=d;continue;case S.SCRIPT_ENDING:"/"===d?b.state=S.CLOSE_TAG:(b.script+="<"+d,b.state=S.SCRIPT);continue;case S.OPEN_WAKA:if("!"===d)b.state=S.SGML_DECL,b.sgmlDecl="";else if(l(F,d));else if(l(Q,d))b.state=S.OPEN_TAG,b.tagName=d;else if("/"===d)b.state=S.CLOSE_TAG,b.tagName="";else if("?"===d)b.state=S.PROC_INST,b.procInstName=b.procInstBody="";else{if(t(b,"Unencoded <"),b.startTagPosition+1"===d?(o(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=S.TEXT):l(I,d)?(b.state=S.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case S.SGML_DECL_QUOTED:d===b.q&&(b.state=S.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case S.DOCTYPE:">"===d?(b.state=S.TEXT,o(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,"["===d?b.state=S.DOCTYPE_DTD:l(I,d)&&(b.state=S.DOCTYPE_QUOTED,b.q=d));continue;case S.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=S.DOCTYPE);continue;case S.DOCTYPE_DTD:b.doctype+=d,"]"===d?b.state=S.DOCTYPE:l(I,d)&&(b.state=S.DOCTYPE_DTD_QUOTED,b.q=d);continue;case S.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=S.DOCTYPE_DTD,b.q="");continue;case S.COMMENT:"-"===d?b.state=S.COMMENT_ENDING:b.comment+=d;continue;case S.COMMENT_ENDING:"-"===d?(b.state=S.COMMENT_ENDED,b.comment=q(b.opt,b.comment),b.comment&&o(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=S.COMMENT);continue;case S.COMMENT_ENDED:">"!==d?(t(b,"Malformed comment"),b.comment+="--"+d,b.state=S.COMMENT):b.state=S.TEXT;continue;case S.CDATA:"]"===d?b.state=S.CDATA_ENDING:b.cdata+=d;continue;case S.CDATA_ENDING:"]"===d?b.state=S.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=S.CDATA);continue;case S.CDATA_ENDING_2:">"===d?(b.cdata&&o(b,"oncdata",b.cdata),o(b,"onclosecdata"),b.cdata="",b.state=S.TEXT):"]"===d?b.cdata+="]":(b.cdata+="]]"+d,b.state=S.CDATA);continue;case S.PROC_INST:"?"===d?b.state=S.PROC_INST_ENDING:l(F,d)?b.state=S.PROC_INST_BODY:b.procInstName+=d;continue;case S.PROC_INST_BODY:if(!b.procInstBody&&l(F,d))continue;"?"===d?b.state=S.PROC_INST_ENDING:b.procInstBody+=d;continue;case S.PROC_INST_ENDING:">"===d?(o(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=S.TEXT):(b.procInstBody+="?"+d,b.state=S.PROC_INST_BODY);continue;case S.OPEN_TAG:l(R,d)?b.tagName+=d:(u(b),">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:(m(F,d)&&t(b,"Invalid character in tag name"),b.state=S.ATTRIB));continue;case S.OPEN_TAG_SLASH:">"===d?(x(b,!0),y(b)):(t(b,"Forward-slash in opening tag not followed by >"),b.state=S.ATTRIB);continue;case S.ATTRIB:if(l(F,d))continue;">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:l(Q,d)?(b.attribName=d,b.attribValue="",b.state=S.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case S.ATTRIB_NAME:"="===d?b.state=S.ATTRIB_VALUE:">"===d?(t(b,"Attribute without value"),b.attribValue=b.attribName,w(b),x(b)):l(F,d)?b.state=S.ATTRIB_NAME_SAW_WHITE:l(R,d)?b.attribName+=d:t(b,"Invalid attribute name");continue;case S.ATTRIB_NAME_SAW_WHITE:if("="===d)b.state=S.ATTRIB_VALUE;else{if(l(F,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=S.ATTRIB_NAME):(t(b,"Invalid attribute name"),b.state=S.ATTRIB)}continue;case S.ATTRIB_VALUE:if(l(F,d))continue;l(I,d)?(b.q=d,b.state=S.ATTRIB_VALUE_QUOTED):(t(b,"Unquoted attribute value"),b.state=S.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case S.ATTRIB_VALUE_QUOTED:if(d!==b.q){"&"===d?b.state=S.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}w(b),b.q="",b.state=S.ATTRIB_VALUE_CLOSED;continue;case S.ATTRIB_VALUE_CLOSED:l(F,d)?b.state=S.ATTRIB:">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:l(Q,d)?(t(b,"No whitespace between attributes"),b.attribName=d,b.attribValue="",b.state=S.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case S.ATTRIB_VALUE_UNQUOTED:if(m(K,d)){"&"===d?b.state=S.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}w(b),">"===d?x(b):b.state=S.ATTRIB;continue;case S.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 S.TEXT_ENTITY:case S.ATTRIB_VALUE_ENTITY_Q:case S.ATTRIB_VALUE_ENTITY_U:switch(b.state){case S.TEXT_ENTITY:var h=S.TEXT,i="textNode";break;case S.ATTRIB_VALUE_ENTITY_Q:var h=S.ATTRIB_VALUE_QUOTED,i="attribValue";break;case S.ATTRIB_VALUE_ENTITY_U:var h=S.ATTRIB_VALUE_UNQUOTED,i="attribValue"}";"===d?(b[i]+=z(b),b.entity="",b.state=h):l(J,d)?b.entity+=d:(t(b,"Invalid character entity"),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 B=["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(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),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:A,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){g(this)}};try{var C=a("stream").Stream}catch(D){var C=function(){}}var E=c.EVENTS.filter(function(a){return"error"!==a&&"end"!==a});i.prototype=Object.create(C.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===E.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)}),C.prototype.on.call(c,a,b)};var F="\r\n ",G="0124356789",H="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",I="'\"",J=G+H+"#",K=F+">",L="[CDATA[",M="DOCTYPE",N="http://www.w3.org/XML/1998/namespace",O="http://www.w3.org/2000/xmlns/",P={xml:N,xmlns:O};F=j(F),G=j(G),H=j(H);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-]/;I=j(I),J=j(J),K=j(K);var S=0;c.STATE={BEGIN:S++,BEGIN_WHITESPACE:S++,TEXT:S++,TEXT_ENTITY:S++,OPEN_WAKA:S++,SGML_DECL:S++,SGML_DECL_QUOTED:S++,DOCTYPE:S++,DOCTYPE_QUOTED:S++,DOCTYPE_DTD:S++,DOCTYPE_DTD_QUOTED:S++,COMMENT_STARTING:S++,COMMENT:S++,COMMENT_ENDING:S++,COMMENT_ENDED:S++,CDATA:S++,CDATA_ENDING:S++,CDATA_ENDING_2:S++,PROC_INST:S++,PROC_INST_BODY:S++,PROC_INST_ENDING:S++,OPEN_TAG:S++,OPEN_TAG_SLASH:S++,ATTRIB:S++,ATTRIB_NAME:S++,ATTRIB_NAME_SAW_WHITE:S++,ATTRIB_VALUE:S++,ATTRIB_VALUE_QUOTED:S++,ATTRIB_VALUE_CLOSED:S++,ATTRIB_VALUE_UNQUOTED:S++,ATTRIB_VALUE_ENTITY_Q:S++,ATTRIB_VALUE_ENTITY_U:S++,CLOSE_TAG:S++,CLOSE_TAG_SAW_WHITE:S++,SCRIPT:S++,SCRIPT_ENDING:S++},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 S in c.STATE)c.STATE[c.STATE[S]]=S;S=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?sax={}:c)}).call(this,a("buffer").Buffer)},{buffer:22,stream:42,string_decoder:43}],49:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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/object/create":119}],50:[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":57,"./XMLDocType":58,"./XMLElement":59,"./XMLStringifier":63}],51:[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/object/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":60,"lodash/object/create":119}],52:[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/object/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":60,"lodash/object/create":119}],53:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],54:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],55:[function(a,b,c){(function(){var c,d,e;d=a("lodash/object/create"),e=a("lodash/lang/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.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/lang/isObject":115,"lodash/object/create":119}],56:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],57:[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/object/create"),f=a("lodash/lang/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"),null!=c&&(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.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":60,"lodash/lang/isObject":115,"lodash/object/create":119}],58:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l;k=a("lodash/object/create"),l=a("lodash/lang/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.clone=function(){return k(a.prototype,this)},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":51,"./XMLComment":52,"./XMLDTDAttList":53,"./XMLDTDElement":54,"./XMLDTDEntity":55,"./XMLDTDNotation":56,"./XMLProcessingInstruction":61,"lodash/lang/isObject":115,"lodash/object/create":119}],59:[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/object/create"),j=a("lodash/lang/isObject"),i=a("lodash/lang/isFunction"),h=a("lodash/collection/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":49,"./XMLNode":60,"./XMLProcessingInstruction":61,"lodash/collection/every":67,"lodash/lang/isFunction":113,"lodash/lang/isObject":115,"lodash/object/create":119}],60:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l,m,n={}.hasOwnProperty;m=a("lodash/lang/isObject"),l=a("lodash/lang/isFunction"),k=a("lodash/lang/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.clone=function(){throw new Error("Cannot clone generic XMLNode")},b.prototype.element=function(a,b,c){var d,e,f,g,h,i,j;if(g=null,null==b&&(b={}),b=b.valueOf(),m(b)||(i=[b,c],c=i[0],b=i[1]),null!=a&&(a=a.valueOf()),Array.isArray(a))for(e=0,h=a.length;h>e;e++)d=a[e],g=this.element(d);else if(l(a))g=this.element(a.apply());else if(m(a))for(f in a)n.call(a,f)&&(j=a[f],l(j)&&(j=j.apply()),m(j)&&k(j)&&(j=null),j||this.options.ignoreDecorators||!this.stringify.convertListKey||0!==f.indexOf(this.stringify.convertListKey)?!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===f.indexOf(this.stringify.convertAttKey)?g=this.attribute(f.substr(this.stringify.convertAttKey.length),j):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===f.indexOf(this.stringify.convertPIKey)?g=this.instruction(f.substr(this.stringify.convertPIKey.length),j):m(j)?!this.options.ignoreDecorators&&this.stringify.convertListKey&&0===f.indexOf(this.stringify.convertListKey)&&Array.isArray(j)?g=this.element(j):(g=this.element(f),g.element(j)):g=this.element(f,j):g=this);else g=!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==g)throw new Error("Could not create any elements with: "+a);return g},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":51,"./XMLComment":52,"./XMLDeclaration":57,"./XMLDocType":58,"./XMLElement":59,"./XMLRaw":62,"./XMLText":64,"lodash/lang/isEmpty":112,"lodash/lang/isFunction":113,"lodash/lang/isObject":115}],61:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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/object/create":119}],62:[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/object/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":60,"lodash/object/create":119}],63:[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,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.convertListKey="#list",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){return a.replace(/&/g,"&").replace(//g,">").replace(/\r/g," ")},a.prototype.attEscape=function(a){return a.replace(/&/g,"&").replace(/d;)a=a[b[d++]];return d&&d==f?a:void 0}}var e=a("./toObject");b.exports=d},{"./toObject":108}],81:[function(a,b,c){function d(a,b,c,h,i,j){return a===b?!0:null==a||null==b||!f(a)&&!g(b)?a!==a&&b!==b:e(a,b,d,c,h,i,j)}var e=a("./baseIsEqualDeep"),f=a("../lang/isObject"),g=a("./isObjectLike");b.exports=d},{"../lang/isObject":115,"./baseIsEqualDeep":82,"./isObjectLike":105}],82:[function(a,b,c){function d(a,b,c,d,m,p,q){var r=h(a),s=h(b),t=k,u=k;r||(t=o.call(a),t==j?t=l:t!=l&&(r=i(a))),s||(u=o.call(b),u==j?u=l:u!=l&&(s=i(b)));var v=t==l,w=u==l,x=t==u;if(x&&!r&&!v)return f(a,b,t);if(!m){var y=v&&n.call(a,"__wrapped__"),z=w&&n.call(b,"__wrapped__");if(y||z)return c(y?a.value():a,z?b.value():b,d,m,p,q)}if(!x)return!1;p||(p=[]),q||(q=[]);for(var A=p.length;A--;)if(p[A]==a)return q[A]==b;p.push(a),q.push(b);var B=(r?e:g)(a,b,c,d,m,p,q);return p.pop(),q.pop(),B}var e=a("./equalArrays"),f=a("./equalByTag"),g=a("./equalObjects"),h=a("../lang/isArray"),i=a("../lang/isTypedArray"),j="[object Arguments]",k="[object Array]",l="[object Object]",m=Object.prototype,n=m.hasOwnProperty,o=m.toString;b.exports=d},{"../lang/isArray":111,"../lang/isTypedArray":117,"./equalArrays":94,"./equalByTag":95,"./equalObjects":96}],83:[function(a,b,c){function d(a,b,c){var d=b.length,g=d,h=!c;if(null==a)return!g;for(a=f(a);d--;){var i=b[d];if(h&&i[2]?i[1]!==a[i[0]]:!(i[0]in a))return!1}for(;++db&&(b=-b>e?0:e+b),c=void 0===c||c>e?e:+c||0,0>c&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d2?c[g-2]:void 0,i=g>2?c[2]:void 0,j=g>1?c[g-1]:void 0;for("function"==typeof h?(h=e(h,j,5),g-=2):(h="function"==typeof j?j:void 0,g-=h?1:0),i&&f(c[0],c[1],i)&&(h=3>g?void 0:h,g=1);++dj))return!1;for(;++i-1&&a%1==0&&b>a}var e=/^\d+$/,f=9007199254740991;b.exports=d},{}],102:[function(a,b,c){function d(a,b,c){if(!g(c))return!1;var d=typeof b;if("number"==d?e(c)&&f(b,c.length):"string"==d&&b in c){var h=c[b];return a===a?a===h:h!==h}return!1}var e=a("./isArrayLike"),f=a("./isIndex"),g=a("../lang/isObject");b.exports=d},{"../lang/isObject":115,"./isArrayLike":100,"./isIndex":101}],103:[function(a,b,c){function d(a,b){var c=typeof a;if("string"==c&&h.test(a)||"number"==c)return!0;if(e(a))return!1;var d=!g.test(a);return d||null!=b&&a in f(b)}var e=a("../lang/isArray"),f=a("./toObject"),g=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,h=/^\w*$/;b.exports=d},{"../lang/isArray":111,"./toObject":108}],104:[function(a,b,c){function d(a){return"number"==typeof a&&a>-1&&a%1==0&&e>=a}var e=9007199254740991;b.exports=d},{}],105:[function(a,b,c){function d(a){return!!a&&"object"==typeof a}b.exports=d},{}],106:[function(a,b,c){function d(a){return a===a&&!e(a)}var e=a("../lang/isObject");b.exports=d},{"../lang/isObject":115}],107:[function(a,b,c){function d(a){for(var b=i(a),c=b.length,d=c&&a.length,j=!!d&&h(d)&&(f(a)||e(a)),l=-1,m=[];++l0;++dc;c++)f.muc.join(d[c]);"function"==typeof f.onReconnectListener&&m.safeCallbackCall(f.onReconnectListener)}})});break;case Strophe.Status.DISCONNECTING:m.QBLog("[ChatProxy]","Status.DISCONNECTING");break;case Strophe.Status.DISCONNECTED:m.QBLog("[ChatProxy]","Status.DISCONNECTED at "+k()),p.reset(),f._isDisconnected||"function"!=typeof f.onDisconnectedListener||m.safeCallbackCall(f.onDisconnectedListener),f._isDisconnected=!0,f._isLogout||f.connect(a);break;case Strophe.Status.ATTACHED:m.QBLog("[ChatProxy]","Status.ATTACHED")}})},send:function(a,b){if(!n)throw o;b.id||(b.id=m.getBsonObjectId());var c=this,d=$msg({from:p.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}),p.send(d)},sendSystemMessage:function(a,b){if(!n)throw o;b.id||(b.id=m.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()),p.send(d)},sendIsTypingStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("composing",{xmlns:"http://jabber.org/protocol/chatstates"}),p.send(b)},sendIsStopTypingStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a),type:this.helpers.typeChat(a)});b.c("paused",{xmlns:"http://jabber.org/protocol/chatstates"}),p.send(b)},sendPres:function(a){if(!n)throw o;p.send($pres({from:p.jid,type:a}))},sendDeliveredStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:m.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),p.send(b)},sendReadStatus:function(a){if(!n)throw o;var b=$msg({from:p.jid,to:this.helpers.jidOrUserId(a.userId),type:"chat",id:m.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),p.send(b)},disconnect:function(){if(!n)throw o;u={},this._isLogout=!0,p.flush(),p.disconnect()},addListener:function(a,b){function c(){return b(),a.live!==!1}if(!n)throw o;return p.addHandler(c,null,a.name||null,a.type||null,a.id||null,a.from||null)},deleteListener:function(a){if(!n)throw o;p.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(!n)throw o;return p.send($pres().tree()),!0},_enableCarbons:function(a){if(!n)throw o;var b;b=$iq({from:p.jid,type:"set",id:p.getUniqueId("enableCarbons")}).c("enable",{xmlns:Strophe.NS.CARBONS}),p.sendIQ(b,function(b){a()})}},e.prototype={get:function(a){var b,c,d,e=this,f={};b=$iq({from:p.jid,type:"get",id:p.getUniqueId("getRoster")}).c("query",{xmlns:Strophe.NS.ROSTER}),p.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();t[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();t[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();t[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:p.jid,type:"set",id:p.getUniqueId("removeRosterItem")}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:d,subscription:"remove"}),p.sendIQ(c,function(){delete t[e],"function"==typeof b&&b()})},_sendSubscriptionPresence:function(a){var b;b=$pres({to:a.jid,type:a.type}),p.send(b)}},f.prototype={join:function(a,b){var c,d=this,e=p.getUniqueId("join");u[a]=!0,c=$pres({from:p.jid,to:d.helpers.getRoomJid(a),id:e}).c("x",{xmlns:Strophe.NS.MUC}).c("history",{maxstanzas:0}),"function"==typeof b&&p.addHandler(b,null,"presence",null,e),p.send(c)},leave:function(a,b){var c,d=this,e=d.helpers.getRoomJid(a);delete u[a],c=$pres({from:p.jid,to:e,type:"unavailable"}),"function"==typeof b&&p.addHandler(b,null,"presence","unavailable",null,e),p.send(c)},listOnlineUsers:function(a,b){var c,d=this,e=[];c=$iq({from:p.jid,id:p.getUniqueId("muc_disco_items"),to:a,type:"get"}).c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),p.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={list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),m.QBLog("[DialogProxy]","list",a),this.service.ajax({url:m.getUrl(r),data:a},b)},create:function(a,b){a.occupants_ids instanceof Array&&(a.occupants_ids=a.occupants_ids.join(", ")),m.QBLog("[DialogProxy]","create",a),this.service.ajax({url:m.getUrl(r),type:"POST",data:a},b)},update:function(a,b,c){m.QBLog("[DialogProxy]","update",b),this.service.ajax({url:m.getUrl(r,a),type:"PUT",data:b},c)},"delete":function(a,b,c){m.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:m.getUrl(r,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:m.getUrl(r,a),type:"DELETE",data:b,dataType:"text"},c)}},h.prototype={list:function(a,b){m.QBLog("[MessageProxy]","list",a),this.service.ajax({url:m.getUrl(s),data:a},b)},create:function(a,b){m.QBLog("[MessageProxy]","create",a),this.service.ajax({url:m.getUrl(s),type:"POST",data:a},b)},update:function(a,b,c){m.QBLog("[MessageProxy]","update",a,b),this.service.ajax({url:m.getUrl(s,a),type:"PUT",data:b},c)},"delete":function(a,b,c){m.QBLog("[DialogProxy]","delete",a),2==arguments.length?this.service.ajax({url:m.getUrl(s,a),type:"DELETE",dataType:"text"},b):3==arguments.length&&this.service.ajax({url:m.getUrl(s,a),type:"DELETE",data:b,dataType:"text"},c)},unreadCount:function(a,b){m.QBLog("[MessageProxy]","unreadCount",a),this.service.ajax({url:m.getUrl(s+"/unread"),data:a},b)}},i.prototype={jidOrUserId:function(a){var b;if("string"==typeof a)b=a;else{if("number"!=typeof a)throw o;b=a+"-"+l.creds.appId+"@"+l.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 o;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 a+"-"+b+"@"+l.endpoints.chat},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]},getRoomJid:function(a){if(!n)throw o;return a+"/"+this.getIdFromNode(p.jid)},getIdFromResource:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),parseInt(b.join("/")))},getUniqueId:function(a){if(!n)throw o;return p.getUniqueId(a)},getBsonObjectId:function(){return m.getBsonObjectId()},getUserIdFromRoomJid:function(a){var b=a.toString().split("/");return 0==b.length?null:b[b.length-1]}},b.exports=d},{"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],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://api.quickblox.com/blobs/"+a+"/download?token="+this.service.getSession().token},publicUrl:function(a){return"https://api.quickblox.com/blobs/"+a+"/download"}},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":9,"../qbUtils":13,xml2js:47}],4:[function(a,b,c){function d(a){this.service=a}var e=a("../qbConfig"),f=a("../qbUtils");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;d=new FormData,d.append("field_name",b.field_name),d.append("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)})},updateFile:function(a,b,c){f.QBLog("[DataProxy]","updateFile",a,b);var d;d=new FormData,d.append("field_name",b.field_name),d.append("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":9,"../qbUtils":13}],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":9,"../qbUtils":13}],6:[function(a,b,c){function d(a){this.service=a,this.subscriptions=new e(a),this.events=new f(a),this.base64Encode=function(a){return btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,b){return String.fromCharCode("0x"+b)}))}}function e(a){this.service=a}function f(a){this.service=a}var g=a("../qbConfig"),h=a("../qbUtils");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){h.QBLog("[EventsProxy]","list"),this.service.ajax({url:h.getUrl(g.urls.events)},a)},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)},update:function(a,b){h.QBLog("[EventsProxy]","update",a);var c={event:a};this.service.ajax({url:h.getUrl(g.urls.events,a.id),type:"PUT",data:c},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},{"../qbConfig":9,"../qbUtils":13}],7:[function(a,b,c){function d(a){this.service=a}function e(a){var b=a.field in i?"date":typeof a.value;return a.value instanceof Array&&("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 i?"date":a.field in j?"number":"string";return[a.sort,b,a.field].join(" ")}var g=a("../qbConfig"),h=a("../qbUtils"),i=["created_at","updated_at","last_request_at"],j=["id","external_user_id"],k=g.urls.users+"/password/reset";d.prototype={listUsers:function(a,b){h.QBLog("[UsersProxy]","listUsers",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(k),data:{email:a}},b)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],8:[function(a,b,c){function d(a,b){var c=this;p=b,this.service=a,this.helpers=new e,this._onMessage=function(a){var b=a.getAttribute("from"),d=a.querySelector("extraParams"),e=a.querySelector("delay"),g=c.helpers.getIdFromNode(b),l=c._getExtension(d);l.sessionID;if(e||l.moduleIdentifier!==A)return!0;switch(delete l.moduleIdentifier,l.signalType){case z.CALL:if(f("onCall from "+g),B[g])return f("skip onCallListener, a user already got it"),!0;i(g),null==q&&j(g,c._answerTimeoutCallback),B[g]={sessionID:l.sessionID,sdp:l.sdp},l.callType="1"===l.callType?"video":"audio",delete l.sdp,"function"==typeof c.onCallListener&&c.onCallListener(g,l);break;case z.ACCEPT:f("onAccept from "+g),k(g),m(g),"object"==typeof q&&q.onRemoteSessionCallback(l.sdp,"answer"),delete l.sdp,"function"==typeof c.onAcceptCallListener&&c.onAcceptCallListener(g,l);break;case z.REJECT:f("onReject from "+g),k(g),m(g),c._close(),"function"==typeof c.onRejectCallListener&&c.onRejectCallListener(g,l);break;case z.STOP:f("onStop from "+g),k(g),m(g),h(g),c._close(),"function"==typeof c.onStopCallListener&&c.onStopCallListener(g,l);break;case z.CANDIDATE:"object"==typeof q&&(q.addCandidates(l.iceCandidates),"answer"===q.type&&c._sendCandidate(q.opponentId,q.iceCandidates));break;case z.PARAMETERS_CHANGED:f("onUpdateCall from "+g),"function"==typeof c.onUpdateCallListener&&c.onUpdateCallListener(g,l)}return!0},this._getExtension=function(a){var b,d,e,f,g={},h=[],i=[];if(a){for(var 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 l=0,m=e.length;m>l;l++)d=e[l].textContent,i.push(d)}else a.childNodes[j].childNodes.length>1?g=c._XMLtoJS(g,a.childNodes[j].tagName,a.childNodes[j]):g[a.childNodes[j].tagName]=a.childNodes[j].textContent;h.length>0&&(g.iceCandidates=h),i.length>0&&(g.opponents=i)}return g},this._answerTimeoutCallback=function(a){h(a),c._close(),"function"==typeof c.onSessionStateChangedListener&&c.onSessionStateChangedListener(c.SessionState.CLOSED,a)},this._callTimeoutCallback=function(a){f("User "+a+" not asnwer"),k(a),h(a),c._close(),"function"==typeof c.onUserNotAnswerListener&&c.onUserNotAnswerListener(a)}}function e(){}function f(a){s.debug&&t.QBLog("[QBWebRTC]",a)}function g(){var a=(new Date).toString().split(" ");return a.slice(1,5).join("-")}function h(a){var b=B[a];b&&delete B[a]}function i(a){var b=C[a];b&&(clearTimeout(b),delete C[a])}function j(a,b){var c=1e3*s.webrtc.answerTimeInterval,d=setTimeout(b,c,a);C[a]=d}function k(a){var b=D[a];b&&(clearInterval(b),delete D[a])}function l(a,b){var c=1e3*s.webrtc.dialingTimeInterval,d=setInterval(b,c);D[a]=d}function m(a){var b=E[a];b&&(clearTimeout(b),delete E[a])}function n(a,b){var c=1e3*s.webrtc.answerTimeInterval;f("startCallTimer, answerTimeInterval: "+c);var d=setTimeout(b,c,a);E[a]=d}function o(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})}a("../../lib/strophe/strophe.min");var p,q,r=a("../../lib/download/download.min"),s=a("../qbConfig"),t=a("../qbUtils"),u=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,v=window.RTCSessionDescription||window.mozRTCSessionDescription,w=window.RTCIceCandidate||window.mozRTCIceCandidate,x=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,y=window.URL||window.webkitURL,z={ +CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},A="WebRTCVideoChat",B={},C={},D={},E={};d.prototype.SessionState={UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5},d.prototype.getUserMedia=function(a,b){if(!x)throw new Error("getUserMedia() is not supported in your browser");x=x.bind(navigator);var c=this;x({audio:a.audio||!1,video:a.video||!1},function(d){c.localStream=d,a.elemId&&c.attachMediaStream(a.elemId,d,a.options),b(null,d)},function(a){b(a,null)})},d.prototype.attachMediaStream=function(a,b,c){var d=document.getElementById(a);d&&(d.src=y.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.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=o(b,"image/png"),c.name="snapshot_"+g()+".png",c.url=b,c):void 0},d.prototype.filter=function(a,b){var c=document.getElementById(a);c&&(c.style.webkitFilter=b,c.style.filter=b)},d.prototype.mute=function(a){this._switchOffDevice(0,a)},d.prototype.unmute=function(a){this._switchOffDevice(1,a)},d.prototype._switchOffDevice=function(a,b){"audio"===b&&this.localStream.getAudioTracks().length>0&&this.localStream.getAudioTracks().forEach(function(b){b.enabled=!!a}),"video"===b&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach(function(b){b.enabled=!!a})},d.prototype._createPeer=function(a){if(!u)throw new Error("RTCPeerConnection() is not supported in your browser");if(!this.localStream)throw new Error("You don't have an access to the local stream");var b={iceServers:s.iceServers};q=new u(b),q.init(this,a),f("Peer._createPeer: "+q+", sessionID: "+q.sessionID)},d.prototype.call=function(a,b,c){f("Call. userId: "+a+", callType: "+b+", extension: "+JSON.stringify(c)),this._createPeer();var d=this,e=a instanceof Array?a:[a],g=e[0];q.opponentId=g,q.getSessionDescription(function(a,h){if(a)f("getSessionDescription error: "+a);else{k(g);var i=function(){d._sendMessage(g,c,"CALL",b,e)};i(),l(g,i),m(g),n(g,d._callTimeoutCallback)}})},d.prototype.accept=function(a,b){var b=b||{};f("Accept. userId: "+a+", extension: "+JSON.stringify(b)),i(a);var c=B[a];c&&this._createPeer({sessionID:c.sessionID,description:c.sdp});var d=this;q.opponentId=a,q.getSessionDescription(function(c,e){c?f(c):d._sendMessage(a,b,"ACCEPT")})},d.prototype.reject=function(a,b){var b=b||{};f("Reject. userId: "+a+", extension: "+JSON.stringify(b)),i(a),B[a]&&(b.sessionID=B[a].sessionID,delete B[a]),this._sendMessage(a,b,"REJECT")},d.prototype.stop=function(a,b){var b=b||{};f("Stop. userId: "+a+", extension: "+JSON.stringify(b)),i(a),k(a),m(a),this._sendMessage(a,b,"STOP"),this._close(),h(a)},d.prototype.update=function(a,b){var b=b||{};f("Update. userId: "+a+", extension: "+JSON.stringify(b)),this._sendMessage(a,b,"PARAMETERS_CHANGED")},d.prototype.close=function(){Object.keys(C).forEach(function(a){i(a)}),Object.keys(D).forEach(function(a){k(a)}),Object.keys(E).forEach(function(a){m(a)}),this._close(),Object.keys(B).forEach(function(a){h(a)})},d.prototype._close=function(){f("Peer._close"),q&&q.close(),this.localStream&&(this.localStream.stop(),this.localStream=null)},d.prototype._sendCandidate=function(a,b){var c={iceCandidates:b};this._sendMessage(a,c,"CANDIDATE")},d.prototype._sendMessage=function(a,b,c,d,e){var f,g,b=b||{},h=this;b.moduleIdentifier=A,b.signalType=z[c],b.sessionID=q&&q.sessionID||b.sessionID,d&&(b.callType="video"===d?"1":"2"),("CALL"===c||"ACCEPT"===c)&&(b.sdp=q.localDescription.sdp,b.platform="web"),"CALL"===c&&(b.callerID=this.helpers.getIdFromNode(p.jid),b.opponentsIDs=e),g={from:p.jid,to:this.helpers.getUserJid(a,this.service.getSession().application_id),type:"headline",id:t.getBsonObjectId()},f=$msg(g).c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b).forEach(function(a){"iceCandidates"===a?(f=f.c("iceCandidates"),b[a].forEach(function(a){f=f.c("iceCandidate"),Object.keys(a).forEach(function(b){f.c(b).t(a[b]).up()}),f.up()}),f.up()):"opponentsIDs"===a?(f=f.c("opponentsIDs"),b[a].forEach(function(a){f=f.c("opponentID").t(a).up()}),f.up()):"object"==typeof b[a]?h._JStoXML(a,b[a],f):f.c(a).t(b[a]).up()}),p.send(f)},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()},d.prototype._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},u&&(u.prototype.init=function(a,b){this.service=a,this.sessionID=b&&b.sessionID||Date.now(),this.type=b&&b.description?"answer":"offer",this.addStream(this.service.localStream),this.onicecandidate=this.onIceCandidateCallback,this.onaddstream=this.onRemoteStreamCallback,this.onsignalingstatechange=this.onSignalingStateCallback,this.oniceconnectionstatechange=this.onIceConnectionStateCallback,"answer"===this.type&&this.onRemoteSessionCallback(b.description,"offer")},u.prototype.getSessionDescription=function(a){function b(b){q.setLocalDescription(b,function(){a(null,b)},c)}function c(b){a(b,null)}"offer"===q.type?q.createOffer(b,c):q.createAnswer(b,c)},u.prototype.onIceCandidateCallback=function(a){var b=a.candidate;b&&(f("onICECandidate: "+JSON.stringify(b)),q.iceCandidates=q.iceCandidates||[],q.iceCandidates.push({sdpMLineIndex:b.sdpMLineIndex,sdpMid:b.sdpMid,candidate:b.candidate}))},u.prototype.onRemoteSessionCallback=function(a,b){var c=new v({sdp:a,type:b});this.setRemoteDescription(c)},u.prototype.onRemoteStreamCallback=function(a){"function"==typeof q.service.onRemoteStreamListener&&q.service.onRemoteStreamListener(a.stream)},u.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 w(b))},u.prototype.onSignalingStateCallback=function(){q&&"stable"===q.signalingState&&"offer"===q.type&&q.service._sendCandidate(q.opponentId,q.iceCandidates)},u.prototype.onIceConnectionStateCallback=function(){f("onIceConnectionStateCallback: "+q.iceConnectionState);var a=q.iceConnectionState;if("function"==typeof q.service.onSessionStateChangedListener){var b=null;"checking"===a?b=q.service.SessionState.CONNECTING:"connected"===a?b=q.service.SessionState.CONNECTED:"failed"===a?b=q.service.SessionState.FAILED:"disconnected"===a?b=q.service.SessionState.DISCONNECTED:"closed"===a&&(b=q.service.SessionState.CLOSED),null!=b&&q.service.onSessionStateChangedListener(b)}"closed"===a&&(q=null)}),e.prototype={getUserJid:function(a,b){return a+"-"+b+"@"+s.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])}},b.exports=d,Blob.prototype.download=function(){r(this,this.name,this.type)}},{"../../lib/download/download.min":14,"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],9:[function(a,b,c){var d={version:"1.15.1",creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com",turn:"turnserver.quickblox.com",s3Bucket:"qbprod"},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},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"}],webrtc:{answerTimeInterval:60,dialingTimeInterval:5},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.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])}))})},b.exports=d},{}],10:[function(a,b,c){function d(){}var e=a("./qbConfig"),f=(a("./qbUtils"),"undefined"!=typeof window);d.prototype={init:function(b,c,d,g){g&&"object"==typeof g&&e.set(g);var h=a("./qbProxy");this.service=new h;var i=a("./modules/qbAuth"),j=a("./modules/qbUsers"),k=a("./modules/qbChat"),l=a("./modules/qbContent"),m=a("./modules/qbLocation"),n=a("./modules/qbPushNotifications"),o=a("./modules/qbData");if(f){var p=a("./qbStrophe"),q=new p,r=a("./modules/qbWebRTC");this.webrtc=new r(this.service,q||null)}this.auth=new i(this.service),this.users=new j(this.service),this.chat=new k(this.service,this.webrtc||null,q||null),this.content=new l(this.service),this.location=new m(this.service),this.pushnotifications=new n(this.service),this.data=new o(this.service),"string"!=typeof b||c||d?(e.creds.appId=b,e.creds.authKey=c,e.creds.authSecret=d):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 g=new d;g.QuickBlox=d,b.exports=g},{"./modules/qbAuth":1,"./modules/qbChat":2,"./modules/qbContent":3,"./modules/qbData":4,"./modules/qbLocation":5,"./modules/qbPushNotifications":6,"./modules/qbUsers":7,"./modules/qbWebRTC":8,"./qbConfig":9,"./qbProxy":11,"./qbStrophe":12,"./qbUtils":13}],11:[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("://"+e.endpoints.s3Bucket)&&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("://"+e.endpoints.s3Bucket)&&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":9,"./qbUtils":13,request:20}],12:[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("../lib/strophe/strophe.min");var e=a("./qbConfig"),f=a("./qbUtils");b.exports=d},{"../lib/strophe/strophe.min":15,"./qbConfig":9,"./qbUtils":13}],13:[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;ag;++g)h[g]=e.charCodeAt(g);return new m([h],{type:c})}function e(a,b){if("download"in k)return k.href=a,k.setAttribute("download",p),k.innerHTML="downloading...",j.body.appendChild(k),setTimeout(function(){k.click(),j.body.removeChild(k),b===!0&&setTimeout(function(){f.URL.revokeObjectURL(k.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g),window.open(a)||confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=j.createElement("iframe");j.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g)),c.src=a,setTimeout(function(){j.body.removeChild(c)},333)}var f=window,g="application/octet-stream",h=c||g,i=a,j=document,k=j.createElement("a"),l=function(a){return String(a)},m=f.Blob||f.MozBlob||f.WebKitBlob||l;m=m.call?m.bind(f):Blob;var n,o,p=b||"download";if("true"===String(this)&&(i=[i,h],h=i[0],i=i[1]),String(i).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(d(i),p):e(i);if(n=i instanceof m?i:new m([i],{type:h}),navigator.msSaveBlob)return navigator.msSaveBlob(n,p);if(f.URL)e(f.URL.createObjectURL(n),!0);else{if("string"==typeof n||n.constructor===l)try{return e("data:"+h+";base64,"+f.btoa(n))}catch(q){return e("data:"+h+","+encodeURIComponent(n))}o=new FileReader,o.onload=function(){e(this.result)},o.readAsDataURL(n)}return!0}b.exports=d},{}],15:[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&&this.xmlInput(c.nodeName===this._proto.strip&&c.childNodes.length?c.childNodes[0]:c),this.rawInput!==h.Connection.prototype.rawInput&&this.rawInput(b?b: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&&this._conn.xmlOutput(d.xmlData.nodeName===this.strip&&d.xmlData.childNodes.length?d.xmlData.childNodes[0]: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(){a.debug(this._requests?"_throttledRequestHandler called with "+this._requests.length+" requests":"_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;cf;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})},{}],17:[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":16,"./hmac":18,"./sha1":19}],18:[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":16}],19:[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":16}],20:[function(a,b,c){},{}],21:[function(a,b,c){arguments[4][20][0].apply(c,arguments)},{dup:20}],22:[function(a,b,c){(function(b){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?(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("is-array");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.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":23,ieee754:24,"is-array":25}],23:[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)},{}],24:[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}},{}],25:[function(a,b,c){var d=Array.isArray,e=Object.prototype.toString;b.exports=d||function(a){return!!a&&"[object Array]"==e.call(a)}},{}],26:[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}},{}],27:[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}},{}],28:[function(a,b,c){b.exports=function(a){return!(null==a||!(a._isBuffer||a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)))}},{}],29:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],30:[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":34,"./_stream_writable":36,_process:30,"core-util-is":37,inherits:27}],33:[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":35,"core-util-is":37,inherits:27}],34:[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":32,_process:30,buffer:22,"core-util-is":37,events:26,inherits:27,isarray:29,stream:42,"string_decoder/":43,util:21}],35:[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:22}],44:[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":30}],45:[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":47}],46:[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)},{}],47:[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,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,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 c="object"==typeof h?f(c.ele(l),h).up():"string"==typeof h&&a.options.cdata&&j(h)?c.ele(l).raw(m(h)).up():c.ele(l,h.toString()).up();return c}}(this),g=d.create(h,this.options.xmldec,this.options.doctype,{headless:this.options.headless}),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;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))},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.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=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;if(l=d.pop(),k=l["#name"],a.options.explicitChildren&&a.options.preserveChildrenOrder||delete l["#name"],l.cdata===!0&&(c=l.cdata,delete l.cdata),p=d[d.length-1],l[b].match(/^\s*$/)&&!c?(e=l[b],delete l[b]):(a.options.trim&&(l[b]=l[b].trim()),a.options.normalize&&(l[b]=l[b].replace(/\s{2,}/g," ").trim()),l[b]=a.options.valueProcessors?h(a.options.valueProcessors,l[b]):l[b],1===Object.keys(l).length&&b in l&&!a.EXPLICIT_CHARKEY&&(l=l[b])),g(l)&&(l=""!==a.options.emptyTag?a.options.emptyTag:e),null!=a.options.validator){q="/"+function(){var a,b,c;for(c=[],a=0,b=d.length;b>a;a++)j=d[a],c.push(j["#name"]);return c}().concat(k).join("/");try{l=a.options.validator(q,p&&p[k],l)}catch(r){f=r,a.emit("error",f)}}if(a.options.explicitChildren&&!a.options.mergeAttrs&&"object"==typeof l)if(a.options.preserveChildrenOrder){if(p){p[a.options.childkey]=p[a.options.childkey]||[],m={};for(i in l)o.call(l,i)&&(m[i]=l[i]);p[a.options.childkey].push(m),delete l["#name"],1===Object.keys(l).length&&b in l&&!a.EXPLICIT_CHARKEY&&(l=l[b])}}else j={},a.options.attrkey in l&&(j[a.options.attrkey]=l[a.options.attrkey],delete l[a.options.attrkey]),!a.options.charsAsChildren&&a.options.charkey in l&&(j[a.options.charkey]=l[a.options.charkey],delete l[a.options.charkey]),Object.getOwnPropertyNames(l).length>0&&(j[a.options.childkey]=l),l=j;return d.length>0?a.assignOrPush(p,k,l):(a.options.explicitRoot&&(n=l,l={},l[k]=n),a.resultObject=l,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;if(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)})),a=a.toString(),""===a.trim())return this.emit("end",null),!0;try{return 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":45,"./processors":46,events:26,sax:48,timers:44,xmlbuilder:65}],48:[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=S.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=B.length;f>e;e++){var g=a[B[e]].length;if(g>b)switch(B[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: "+B[e])}d=Math.max(d,g)}a.bufferCheckPosition=c.MAX_BUFFER_LENGTH-d+a.position}function f(a){for(var b=0,c=B.length;c>b;b++)a[B[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);C.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,E.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)},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!==S.BEGIN&&a.state!==S.BEGIN_WHITESPACE&&a.state!==S.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 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=S.TEXT:a.state=S.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=S.TEXT);if(a.script){if("script"!==a.tagName)return a.script+="",a.tagName="",void(a.state=S.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=S.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=S.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){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="";b.c=d=a.charAt(c++);)switch(b.trackPosition&&(b.position++,"\n"===d?(b.line++,b.column=0):b.column++),b.state){case S.BEGIN:if(b.state=S.BEGIN_WHITESPACE,"\ufeff"===d)continue;case S.BEGIN_WHITESPACE:"<"===d?(b.state=S.OPEN_WAKA,b.startTagPosition=b.position):m(F,d)&&(t(b,"Non-whitespace before first tag."),b.textNode=d,b.state=S.TEXT);continue;case S.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(F,d)||b.sawRoot&&!b.closedRoot||t(b,"Text data outside of root node."),"&"===d?b.state=S.TEXT_ENTITY:b.textNode+=d):(b.state=S.OPEN_WAKA,b.startTagPosition=b.position);continue;case S.SCRIPT:"<"===d?b.state=S.SCRIPT_ENDING:b.script+=d;continue;case S.SCRIPT_ENDING:"/"===d?b.state=S.CLOSE_TAG:(b.script+="<"+d,b.state=S.SCRIPT);continue;case S.OPEN_WAKA:if("!"===d)b.state=S.SGML_DECL,b.sgmlDecl="";else if(l(F,d));else if(l(Q,d))b.state=S.OPEN_TAG,b.tagName=d;else if("/"===d)b.state=S.CLOSE_TAG,b.tagName="";else if("?"===d)b.state=S.PROC_INST,b.procInstName=b.procInstBody="";else{if(t(b,"Unencoded <"),b.startTagPosition+1"===d?(o(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=S.TEXT):l(I,d)?(b.state=S.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case S.SGML_DECL_QUOTED:d===b.q&&(b.state=S.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case S.DOCTYPE:">"===d?(b.state=S.TEXT,o(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,"["===d?b.state=S.DOCTYPE_DTD:l(I,d)&&(b.state=S.DOCTYPE_QUOTED,b.q=d));continue;case S.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=S.DOCTYPE);continue;case S.DOCTYPE_DTD:b.doctype+=d,"]"===d?b.state=S.DOCTYPE:l(I,d)&&(b.state=S.DOCTYPE_DTD_QUOTED,b.q=d);continue;case S.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=S.DOCTYPE_DTD,b.q="");continue;case S.COMMENT:"-"===d?b.state=S.COMMENT_ENDING:b.comment+=d;continue;case S.COMMENT_ENDING:"-"===d?(b.state=S.COMMENT_ENDED,b.comment=q(b.opt,b.comment),b.comment&&o(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=S.COMMENT);continue;case S.COMMENT_ENDED:">"!==d?(t(b,"Malformed comment"),b.comment+="--"+d,b.state=S.COMMENT):b.state=S.TEXT;continue;case S.CDATA:"]"===d?b.state=S.CDATA_ENDING:b.cdata+=d;continue;case S.CDATA_ENDING:"]"===d?b.state=S.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=S.CDATA);continue;case S.CDATA_ENDING_2:">"===d?(b.cdata&&o(b,"oncdata",b.cdata),o(b,"onclosecdata"),b.cdata="",b.state=S.TEXT):"]"===d?b.cdata+="]":(b.cdata+="]]"+d,b.state=S.CDATA);continue;case S.PROC_INST:"?"===d?b.state=S.PROC_INST_ENDING:l(F,d)?b.state=S.PROC_INST_BODY:b.procInstName+=d;continue;case S.PROC_INST_BODY:if(!b.procInstBody&&l(F,d))continue;"?"===d?b.state=S.PROC_INST_ENDING:b.procInstBody+=d;continue;case S.PROC_INST_ENDING:">"===d?(o(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=S.TEXT):(b.procInstBody+="?"+d,b.state=S.PROC_INST_BODY);continue;case S.OPEN_TAG:l(R,d)?b.tagName+=d:(u(b),">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:(m(F,d)&&t(b,"Invalid character in tag name"),b.state=S.ATTRIB));continue;case S.OPEN_TAG_SLASH:">"===d?(x(b,!0),y(b)):(t(b,"Forward-slash in opening tag not followed by >"),b.state=S.ATTRIB);continue;case S.ATTRIB:if(l(F,d))continue;">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:l(Q,d)?(b.attribName=d,b.attribValue="",b.state=S.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case S.ATTRIB_NAME:"="===d?b.state=S.ATTRIB_VALUE:">"===d?(t(b,"Attribute without value"),b.attribValue=b.attribName,w(b),x(b)):l(F,d)?b.state=S.ATTRIB_NAME_SAW_WHITE:l(R,d)?b.attribName+=d:t(b,"Invalid attribute name");continue;case S.ATTRIB_NAME_SAW_WHITE:if("="===d)b.state=S.ATTRIB_VALUE;else{if(l(F,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=S.ATTRIB_NAME):(t(b,"Invalid attribute name"),b.state=S.ATTRIB)}continue;case S.ATTRIB_VALUE:if(l(F,d))continue;l(I,d)?(b.q=d,b.state=S.ATTRIB_VALUE_QUOTED):(t(b,"Unquoted attribute value"),b.state=S.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case S.ATTRIB_VALUE_QUOTED:if(d!==b.q){"&"===d?b.state=S.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}w(b),b.q="",b.state=S.ATTRIB_VALUE_CLOSED;continue;case S.ATTRIB_VALUE_CLOSED:l(F,d)?b.state=S.ATTRIB:">"===d?x(b):"/"===d?b.state=S.OPEN_TAG_SLASH:l(Q,d)?(t(b,"No whitespace between attributes"),b.attribName=d,b.attribValue="",b.state=S.ATTRIB_NAME):t(b,"Invalid attribute name");continue;case S.ATTRIB_VALUE_UNQUOTED:if(m(K,d)){"&"===d?b.state=S.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}w(b),">"===d?x(b):b.state=S.ATTRIB;continue;case S.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 S.TEXT_ENTITY:case S.ATTRIB_VALUE_ENTITY_Q:case S.ATTRIB_VALUE_ENTITY_U:switch(b.state){case S.TEXT_ENTITY:var h=S.TEXT,i="textNode";break;case S.ATTRIB_VALUE_ENTITY_Q:var h=S.ATTRIB_VALUE_QUOTED,i="attribValue";break;case S.ATTRIB_VALUE_ENTITY_U:var h=S.ATTRIB_VALUE_UNQUOTED,i="attribValue"}";"===d?(b[i]+=z(b),b.entity="",b.state=h):l(J,d)?b.entity+=d:(t(b,"Invalid character entity"),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 B=["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(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),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:A,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){g(this)}};try{var C=a("stream").Stream}catch(D){var C=function(){}}var E=c.EVENTS.filter(function(a){return"error"!==a&&"end"!==a});i.prototype=Object.create(C.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===E.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)}),C.prototype.on.call(c,a,b)};var F="\r\n ",G="0124356789",H="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",I="'\"",J=G+H+"#",K=F+">",L="[CDATA[",M="DOCTYPE",N="http://www.w3.org/XML/1998/namespace",O="http://www.w3.org/2000/xmlns/",P={xml:N,xmlns:O};F=j(F),G=j(G),H=j(H);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-]/;I=j(I),J=j(J),K=j(K);var S=0;c.STATE={BEGIN:S++,BEGIN_WHITESPACE:S++,TEXT:S++,TEXT_ENTITY:S++,OPEN_WAKA:S++,SGML_DECL:S++,SGML_DECL_QUOTED:S++,DOCTYPE:S++,DOCTYPE_QUOTED:S++,DOCTYPE_DTD:S++,DOCTYPE_DTD_QUOTED:S++,COMMENT_STARTING:S++,COMMENT:S++,COMMENT_ENDING:S++,COMMENT_ENDED:S++,CDATA:S++,CDATA_ENDING:S++,CDATA_ENDING_2:S++,PROC_INST:S++,PROC_INST_BODY:S++,PROC_INST_ENDING:S++,OPEN_TAG:S++,OPEN_TAG_SLASH:S++,ATTRIB:S++,ATTRIB_NAME:S++,ATTRIB_NAME_SAW_WHITE:S++,ATTRIB_VALUE:S++,ATTRIB_VALUE_QUOTED:S++,ATTRIB_VALUE_CLOSED:S++,ATTRIB_VALUE_UNQUOTED:S++,ATTRIB_VALUE_ENTITY_Q:S++,ATTRIB_VALUE_ENTITY_U:S++,CLOSE_TAG:S++,CLOSE_TAG_SAW_WHITE:S++,SCRIPT:S++,SCRIPT_ENDING:S++},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 S in c.STATE)c.STATE[c.STATE[S]]=S;S=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?sax={}:c)}).call(this,a("buffer").Buffer)},{buffer:22,stream:42,string_decoder:43}],49:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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/object/create":119}],50:[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":57,"./XMLDocType":58,"./XMLElement":59,"./XMLStringifier":63}],51:[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/object/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":60,"lodash/object/create":119}],52:[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/object/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":60,"lodash/object/create":119}],53:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],54:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],55:[function(a,b,c){(function(){var c,d,e;d=a("lodash/object/create"),e=a("lodash/lang/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.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/lang/isObject":115,"lodash/object/create":119}],56:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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.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/object/create":119}],57:[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/object/create"),f=a("lodash/lang/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"),null!=c&&(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.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":60,"lodash/lang/isObject":115,"lodash/object/create":119}],58:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l;k=a("lodash/object/create"),l=a("lodash/lang/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.clone=function(){return k(a.prototype,this)},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":51,"./XMLComment":52,"./XMLDTDAttList":53,"./XMLDTDElement":54,"./XMLDTDEntity":55,"./XMLDTDNotation":56,"./XMLProcessingInstruction":61,"lodash/lang/isObject":115,"lodash/object/create":119}],59:[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/object/create"),j=a("lodash/lang/isObject"),i=a("lodash/lang/isFunction"),h=a("lodash/collection/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":49,"./XMLNode":60,"./XMLProcessingInstruction":61,"lodash/collection/every":67,"lodash/lang/isFunction":113,"lodash/lang/isObject":115,"lodash/object/create":119}],60:[function(a,b,c){(function(){var c,d,e,f,g,h,i,j,k,l,m,n={}.hasOwnProperty;m=a("lodash/lang/isObject"),l=a("lodash/lang/isFunction"),k=a("lodash/lang/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.clone=function(){throw new Error("Cannot clone generic XMLNode")},b.prototype.element=function(a,b,c){var d,e,f,g,h,i,j;if(g=null,null==b&&(b={}),b=b.valueOf(),m(b)||(i=[b,c],c=i[0],b=i[1]),null!=a&&(a=a.valueOf()),Array.isArray(a))for(e=0,h=a.length;h>e;e++)d=a[e],g=this.element(d);else if(l(a))g=this.element(a.apply());else if(m(a))for(f in a)n.call(a,f)&&(j=a[f],l(j)&&(j=j.apply()),m(j)&&k(j)&&(j=null),j||this.options.ignoreDecorators||!this.stringify.convertListKey||0!==f.indexOf(this.stringify.convertListKey)?!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===f.indexOf(this.stringify.convertAttKey)?g=this.attribute(f.substr(this.stringify.convertAttKey.length),j):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===f.indexOf(this.stringify.convertPIKey)?g=this.instruction(f.substr(this.stringify.convertPIKey.length),j):m(j)?!this.options.ignoreDecorators&&this.stringify.convertListKey&&0===f.indexOf(this.stringify.convertListKey)&&Array.isArray(j)?g=this.element(j):(g=this.element(f),g.element(j)):g=this.element(f,j):g=this);else g=!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==g)throw new Error("Could not create any elements with: "+a);return g},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":51,"./XMLComment":52,"./XMLDeclaration":57,"./XMLDocType":58,"./XMLElement":59,"./XMLRaw":62,"./XMLText":64,"lodash/lang/isEmpty":112,"lodash/lang/isFunction":113,"lodash/lang/isObject":115}],61:[function(a,b,c){(function(){var c,d;d=a("lodash/object/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/object/create":119}],62:[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/object/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":60,"lodash/object/create":119}],63:[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,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.convertListKey="#list",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){return a.replace(/&/g,"&").replace(//g,">").replace(/\r/g," ")},a.prototype.attEscape=function(a){return a.replace(/&/g,"&").replace(/d;)a=a[b[d++]];return d&&d==f?a:void 0}}var e=a("./toObject");b.exports=d},{"./toObject":108}],81:[function(a,b,c){function d(a,b,c,h,i,j){return a===b?!0:null==a||null==b||!f(a)&&!g(b)?a!==a&&b!==b:e(a,b,d,c,h,i,j)}var e=a("./baseIsEqualDeep"),f=a("../lang/isObject"),g=a("./isObjectLike");b.exports=d},{"../lang/isObject":115,"./baseIsEqualDeep":82,"./isObjectLike":105}],82:[function(a,b,c){function d(a,b,c,d,m,p,q){var r=h(a),s=h(b),t=k,u=k;r||(t=o.call(a),t==j?t=l:t!=l&&(r=i(a))),s||(u=o.call(b),u==j?u=l:u!=l&&(s=i(b)));var v=t==l,w=u==l,x=t==u;if(x&&!r&&!v)return f(a,b,t);if(!m){var y=v&&n.call(a,"__wrapped__"),z=w&&n.call(b,"__wrapped__");if(y||z)return c(y?a.value():a,z?b.value():b,d,m,p,q)}if(!x)return!1;p||(p=[]),q||(q=[]);for(var A=p.length;A--;)if(p[A]==a)return q[A]==b;p.push(a),q.push(b);var B=(r?e:g)(a,b,c,d,m,p,q);return p.pop(),q.pop(),B}var e=a("./equalArrays"),f=a("./equalByTag"),g=a("./equalObjects"),h=a("../lang/isArray"),i=a("../lang/isTypedArray"),j="[object Arguments]",k="[object Array]",l="[object Object]",m=Object.prototype,n=m.hasOwnProperty,o=m.toString;b.exports=d},{"../lang/isArray":111,"../lang/isTypedArray":117,"./equalArrays":94,"./equalByTag":95,"./equalObjects":96}],83:[function(a,b,c){function d(a,b,c){var d=b.length,g=d,h=!c;if(null==a)return!g;for(a=f(a);d--;){var i=b[d];if(h&&i[2]?i[1]!==a[i[0]]:!(i[0]in a))return!1}for(;++db&&(b=-b>e?0:e+b),c=void 0===c||c>e?e:+c||0,0>c&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d2?c[g-2]:void 0,i=g>2?c[2]:void 0,j=g>1?c[g-1]:void 0;for("function"==typeof h?(h=e(h,j,5),g-=2):(h="function"==typeof j?j:void 0,g-=h?1:0),i&&f(c[0],c[1],i)&&(h=3>g?void 0:h,g=1);++dj))return!1;for(;++i-1&&a%1==0&&b>a}var e=/^\d+$/,f=9007199254740991;b.exports=d},{}],102:[function(a,b,c){function d(a,b,c){if(!g(c))return!1;var d=typeof b;if("number"==d?e(c)&&f(b,c.length):"string"==d&&b in c){var h=c[b];return a===a?a===h:h!==h}return!1}var e=a("./isArrayLike"),f=a("./isIndex"),g=a("../lang/isObject");b.exports=d},{"../lang/isObject":115,"./isArrayLike":100,"./isIndex":101}],103:[function(a,b,c){function d(a,b){var c=typeof a;if("string"==c&&h.test(a)||"number"==c)return!0;if(e(a))return!1;var d=!g.test(a);return d||null!=b&&a in f(b)}var e=a("../lang/isArray"),f=a("./toObject"),g=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,h=/^\w*$/;b.exports=d},{"../lang/isArray":111,"./toObject":108}],104:[function(a,b,c){function d(a){return"number"==typeof a&&a>-1&&a%1==0&&e>=a}var e=9007199254740991;b.exports=d},{}],105:[function(a,b,c){function d(a){return!!a&&"object"==typeof a}b.exports=d},{}],106:[function(a,b,c){function d(a){return a===a&&!e(a)}var e=a("../lang/isObject");b.exports=d},{"../lang/isObject":115}],107:[function(a,b,c){function d(a){for(var b=i(a),c=b.length,d=c&&a.length,j=!!d&&h(d)&&(f(a)||e(a)),l=-1,m=[];++l0;++d