Comparing version 0.8.0 to 0.9.0
@@ -1,2 +0,2 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.babble=t()}}(function(){var t;return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e){"use strict";e.exports=t("./lib/babble")},{"./lib/babble":4}],2:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error("id required");this.id=t,this.listeners=[],this.conversations={},this.connect()}var r=t("node-uuid"),i=t("es6-promise").Promise,o=t("./messagers"),s=t("./Conversation"),u=(t("./block/Block"),t("./block/Then"),t("./block/Tell")),a=t("./block/Listen");t("./block/IIf"),n.prototype.connect=function(t){if(this.disconnect(),t||(t=o["default"]()),"function"!=typeof t.connect)throw new Error("messager must contain a function connect(params: {id: string, callback: function}) : string");if("function"!=typeof t.disconnect)throw new Error("messager must contain a function disconnect(token: string)");if("function"!=typeof t.send)throw new Error("messager must contain a function send(params: {id: string, message: *})");var e=null,n=new i(function(t){e=t}),r=t.connect({id:this.id,message:this._onMessage.bind(this),connect:e});return this.disconnect=function(){t.disconnect(r)},this.send=t.send,n},n.prototype._onMessage=function(t){if(t&&"id"in t&&"message"in t){var e=this,n=t.id,r=this.conversations[n];r&&r.length?r.forEach(function(e){e.deliver(t)}):(r||(r=[]),this.conversations[n]=r,this.listeners.forEach(function(i){var o=new s({id:n,self:e.id,other:t.from,context:{from:t.from},send:e.send});return r.push(o),o.deliver(t),e._process(i,o).then(function(){var t=r.indexOf(o);-1!==t&&r.splice(t,1),0===r.length&&delete e.conversations[n]})}))}},n.prototype.disconnect=function(){},n.prototype.send=function(){throw new Error("Cannot send: not connected")},n.prototype.listen=function(t,e){var n=new a;this.listeners.push(n);var r=n;return t&&(r=n.iif(t)),e&&(r=n.then(e)),r},n.prototype.tell=function(t,e){var n=this,i=r.v4(),o=new s({id:i,self:this.id,other:t,context:{from:t},send:n.send});this.conversations[i]=[o];var a=new u(e);return setTimeout(function(){n._process(a,o).then(function(){delete n.conversations[i]})},0),a},n.prototype.ask=function(t,e,n){return this.tell(t,e).listen(n)},n.prototype._process=function(t,e){return new i(function(n){function r(t,i){t.execute(e,i).then(function(t){t.block?r(t.block,t.result):n(e)})}r(t)})},e.exports=n},{"./Conversation":3,"./block/Block":5,"./block/IIf":7,"./block/Listen":8,"./block/Tell":9,"./block/Then":10,"./messagers":11,"es6-promise":33,"node-uuid":43}],3:[function(t,e){function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.id=t&&t.id||r.v4(),this.self=t&&t.self||null,this.other=t&&t.other||null,this.context=t&&t.context||{},this._send=t&&t.send||null,this._inbox=[],this._receivers=[]}var r=t("node-uuid"),i=t("es6-promise").Promise;n.prototype.send=function(t){return this._send(this.other,{id:this.id,from:this.self,to:this.other,message:t})},n.prototype.deliver=function(t){if(this._receivers.length){var e=this._receivers.shift();e(t.message)}else this._inbox.push(t.message)},n.prototype.receive=function(){var t=this;return this._inbox.length?i.resolve(this._inbox.shift()):new i(function(e){t._receivers.push(e)})},e.exports=n},{"es6-promise":33,"node-uuid":43}],4:[function(t,e,n){"use strict";var r=t("./Babbler"),i=t("./block/Tell"),o=t("./block/Listen"),s=t("./block/Then"),u=t("./block/Decision"),a=t("./block/IIf");n.babbler=function(t){return new r(t)},n.tell=function(t){return new i(t)},n.ask=function(t,e){return n.tell(t).listen(e)},n.decide=function(t,e){return new u(t,e)},n.listen=function(t){var e=new o;return t?e.then(t):e},n.then=function(t){return new s(t)},n.iif=function(t,e,n){return new a(t,e,n)},n.Babbler=r,n.block={Block:t("./block/Block"),Then:t("./block/Then"),Decision:t("./block/Decision"),IIf:t("./block/IIf"),Listen:t("./block/Listen"),Tell:t("./block/Tell")},n.messagers=t("./messagers"),n.babblify=function(t,e){var r;if(e&&void 0!==e.id)r=e.id;else{if(void 0===t.id)throw new Error('Id missing. Ensure that either actor has a property "id", or provide an id as a property in second argument params');r=t.id}["ask","tell","listen"].forEach(function(e){if(void 0!==t[e])throw new Error('Conflict: actor already has a property "'+e+'"')});var i=e&&e.send||"send";if("function"!=typeof t[i])throw new Error('Missing function. Function "'+i+'(to, message)" expected on actor or on params');var o=n.babbler(r),s=e&&e.onMessage||"onMessage",u=t.hasOwnProperty(s)?t[s]:null;return t[s]=u?function(e,n){o._onMessage(n),u.call(t,e,n)}:function(t,e){o._onMessage(e)},o.send=function(e,n){setTimeout(function(){t[i](e,n)},0)},t.__babbler__={babbler:o,onMessage:u,onMessageName:s},t.ask=o.ask.bind(o),t.tell=o.tell.bind(o),t.listen=o.listen.bind(o),t},n.unbabblify=function(t){var e=t.__babbler__;return e&&(delete t.__babbler__,delete t.ask,delete t.tell,delete t.listen,delete t[e.onMessageName],e.onMessage&&(t[e.onMessageName]=e.onMessage)),t}},{"./Babbler":2,"./block/Block":5,"./block/Decision":6,"./block/IIf":7,"./block/Listen":8,"./block/Tell":9,"./block/Then":10,"./messagers":11}],5:[function(t,e){"use strict";function n(){this.next=null,this.previous=null}n.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.exports=n},{}],6:[function(t,e){"use strict";function n(t,e){var r,i;if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,i=e):(r=null,i=t),r){if("function"!=typeof r)throw new TypeError("Parameter decision must be a function")}else r=function(t){return t};if(i&&i instanceof Function)throw new TypeError("Parameter choices must be an object");if(this.decision=r,this.choices={},i){var o=this;Object.keys(i).forEach(function(t){o.addChoice(t,i[t])})}}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),n.prototype=Object.create(i.prototype),n.prototype.execute=function(t,e){var n=this,i=this.decision(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){var r=n.choices[t];if(!r)throw new Error('Block with id "'+t+'" not found');return{result:e,block:r}})},n.prototype.addChoice=function(t,e){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(e instanceof i))throw new TypeError("Block expected as choice");if(t in this.choices)throw new Error('Choice with id "'+t+'" already exists');return this.choices[t]=e,this},i.prototype.decide=function(t,e){var r=new n(t,e);return this.then(r)},e.exports=n},{"../util":12,"./Block":5,"./Then":10,"es6-promise":33}],7:[function(t,e){"use strict";function n(t,e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.condition=t instanceof Function?t:t instanceof RegExp?function(e){return t.test(e)}:function(e){return e==t},e&&!(e instanceof i))throw new TypeError("Parameter trueBlock must be a Block");if(r&&!(r instanceof i))throw new TypeError("Parameter falseBlock must be a Block");this.trueBlock=e||null,this.falseBlock=r||null}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n=this,i=this.condition(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){var r=t?n.trueBlock||n.next:n.falseBlock;return{result:e,block:r}})},i.prototype.iif=function(t,e,r){var i=new n(t,e,r);return this.then(i)},e.exports=n},{"../util":12,"./Block":5,"./Then":10,"es6-promise":33}],8:[function(t,e){"use strict";function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}{var r=(t("es6-promise").Promise,t("./Block"));t("./Then")}n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.prototype.execute=function(t){var e=this;return t.receive().then(function(t){return{result:t,block:e.next}})},r.prototype.listen=function(t){var e=new n,r=this.then(e);return t&&(r=r.then(t)),r},e.exports=n},{"./Block":5,"./Then":10,"es6-promise":33}],9:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.message=t}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),t("./Listen"),n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n,i=this;if("function"==typeof this.message){var s=this.message(e,t.context);n=o(s)?s:r.resolve(s)}else n=r.resolve(this.message);return n.then(function(e){var n=t.send(e),s=o(n)?n:r.resolve(n);return s.then(function(){return{result:e,block:i.next}})})},i.prototype.tell=function(t){var e=new n(t);return this.then(e)},i.prototype.ask=function(t,e){return this.tell(t).listen(e)},e.exports=n},{"../util":12,"./Block":5,"./Listen":8,"./Then":10,"es6-promise":33}],10:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n=this,i=this.callback(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){return{result:t,block:n.next}})},i.prototype.then=function(t){if("function"==typeof t&&(t=new n(t)),!(t instanceof i))throw new TypeError("Parameter next must be a Block or function");for(var e=this;e.next;)e=e.next;for(var r=this;r.previous;)r=r.previous;return t.previous=this,e.next=t,r},e.exports=n},{"../util":12,"./Block":5,"es6-promise":33}],11:[function(t,e,n){"use strict";var r=t("es6-promise").Promise;n["pubsub-js"]=function(){var e=t("pubsub-js");return{connect:function(t){var n=e.subscribe(t.id,function(e,n){t.message(n)});return"function"==typeof t.connect&&t.connect(),n},disconnect:function(t){e.unsubscribe(t)},send:function(t,n){e.publish(t,n)}}},n.pubnub=function(e){var n;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");n=window.PUBNUB}else n=t("pubnub");var i=n.init(e);return{connect:function(t){return i.subscribe({channel:t.id,message:t.message,connect:t.connect}),t.id},disconnect:function(t){i.unsubscribe(t)},send:function(t,e){return new r(function(n){i.publish({channel:t,message:e,callback:n})})}}},n["default"]=n["pubsub-js"]},{"es6-promise":33,pubnub:void 0,"pubsub-js":44}],12:[function(t,e,n){n.isPromise=function(t){return t&&"function"==typeof t.then&&"function"==typeof t["catch"]}},{}],13:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=A(t)),i=r.byteLength(t,e);else{if("object"!==o||null===t)throw new Error("First argument needs to be a number, array or string.");"Buffer"===t.type&&L(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}var s;V?s=r._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var u;if(V&&"number"==typeof t.byteLength)s._set(t);else if(j(t))if(r.isBuffer(t))for(u=0;i>u;u++)s[u]=t.readUInt8(u);else for(u=0;i>u;u++)s[u]=(t[u]%256+256)%256;else if("string"===o)s.write(t,0,e);else if("number"===o&&!V&&!n)for(u=0;i>u;u++)s[u]=0;return s}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;R(o%2===0,"Invalid hex string"),r>o/2&&(r=o/2);for(var s=0;r>s;s++){var u=parseInt(e.substr(2*s,2),16);R(!isNaN(u),"Invalid hex string"),t[n+s]=u}return s}function o(t,e,n,r){var i=D(O(e),t,n,r);return i}function s(t,e,n,r){var i=D(P(e),t,n,r);return i}function u(t,e,n,r){return s(t,e,n,r)}function a(t,e,n,r){var i=D(M(e),t,n,r);return i}function c(t,e,n,r){var i=D(C(e),t,n,r);return i}function f(t,e,n){return H.fromByteArray(0===e&&n===t.length?t:t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)t[o]<=127?(r+=N(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+N(i)}function h(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return h(t,e,n)}function d(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=U(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function y(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function b(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function v(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=y(t,e,n,!0),s=32768&o;return s?-1*(65535-o+1):o}}function w(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=b(t,e,n,!0),s=2147483648&o;return s?-1*(4294967295-o+1):o}}function m(t,e,n,r){return r||(R("boolean"==typeof n,"missing or invalid endian"),R(e+3<t.length,"Trying to read beyond buffer length")),J.read(t,e,n,23,4)}function _(t,e,n,r){return r||(R("boolean"==typeof n,"missing or invalid endian"),R(e+7<t.length,"Trying to read beyond buffer length")),J.read(t,e,n,52,8)}function E(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"trying to write beyond buffer length"),F(e,65535));var o=t.length;if(!(n>=o)){for(var s=0,u=Math.min(o-n,2);u>s;s++)t[n+s]=(e&255<<8*(r?s:1-s))>>>8*(r?s:1-s);return n+2}}function B(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"trying to write beyond buffer length"),F(e,4294967295));var o=t.length;if(!(n>=o)){for(var s=0,u=Math.min(o-n,4);u>s;s++)t[n+s]=e>>>8*(r?s:3-s)&255;return n+4}}function k(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to write beyond buffer length"),z(e,32767,-32768));var o=t.length;if(!(n>=o))return e>=0?E(t,e,n,r,i):E(t,65535+e+1,n,r,i),n+2}function I(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to write beyond buffer length"),z(e,2147483647,-2147483648));var o=t.length;if(!(n>=o))return e>=0?B(t,e,n,r,i):B(t,4294967295+e+1,n,r,i),n+4}function x(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to write beyond buffer length"),q(e,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,23,4),n+4}function S(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+7<t.length,"Trying to write beyond buffer length"),q(e,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,52,8),n+8}function A(t){for(t=T(t).replace($,"");t.length%4!==0;)t+="=";return t}function T(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function L(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function j(t){return L(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function U(t){return 16>t?"0"+t.toString(16):t.toString(16)}function O(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}}return e}function P(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e}function C(t){for(var e,n,r,i=[],o=0;o<t.length;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function M(t){return H.toByteArray(t)}function D(t,e,n,r){for(var i=0;r>i&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function N(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function F(t,e){R("number"==typeof t,"cannot write a non-number as a number"),R(t>=0,"specified a negative value for writing an unsigned value"),R(e>=t,"value is larger than maximum value for type"),R(Math.floor(t)===t,"value has a fractional component")}function z(t,e,n){R("number"==typeof t,"cannot write a non-number as a number"),R(e>=t,"value larger than maximum allowed value"),R(t>=n,"value smaller than minimum allowed value"),R(Math.floor(t)===t,"value has a fractional component")}function q(t,e,n){R("number"==typeof t,"cannot write a non-number as a number"),R(e>=t,"value larger than maximum allowed value"),R(t>=n,"value smaller than minimum allowed value")}function R(t,e){if(!t)throw new Error(e||"Failed assertion")}/*! | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.babble=t()}}(function(){var t;return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e){"use strict";e.exports=t("./lib/babble")},{"./lib/babble":4}],2:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!t)throw new Error("id required");this.id=t,this.listeners=[],this.conversations={},this.connect()}var r=t("node-uuid"),i=t("es6-promise").Promise,o=t("./messagebus"),s=t("./Conversation"),u=(t("./block/Block"),t("./block/Then"),t("./block/Tell")),a=t("./block/Listen");t("./block/IIf"),n.prototype.connect=function(t){if(this.disconnect(),t||(t=o["default"]()),"function"!=typeof t.connect)throw new Error("message bus must contain a function connect(params: {id: string, callback: function}) : string");if("function"!=typeof t.disconnect)throw new Error("message bus must contain a function disconnect(token: string)");if("function"!=typeof t.send)throw new Error("message bus must contain a function send(params: {id: string, message: *})");var e=null,n=new i(function(t){e=t}),r=t.connect({id:this.id,message:this._onMessage.bind(this),callback:e});return this.disconnect=function(){t.disconnect(r)},this.send=t.send,n},n.prototype._onMessage=function(t){if(t&&"id"in t&&"message"in t){var e=this,n=t.id,r=this.conversations[n];r&&r.length?r.forEach(function(e){e.deliver(t)}):(r||(r=[]),this.conversations[n]=r,this.listeners.forEach(function(i){var o=new s({id:n,self:e.id,other:t.from,context:{from:t.from},send:e.send});return r.push(o),o.deliver(t),e._process(i,o).then(function(){var t=r.indexOf(o);-1!==t&&r.splice(t,1),0===r.length&&delete e.conversations[n]})}))}},n.prototype.disconnect=function(){},n.prototype.send=function(){throw new Error("Cannot send: not connected")},n.prototype.listen=function(t,e){var n=new a;this.listeners.push(n);var r=n;return t&&(r=n.iif(t)),e&&(r=n.then(e)),r},n.prototype.tell=function(t,e){var n=this,i=r.v4(),o=new s({id:i,self:this.id,other:t,context:{from:t},send:n.send});this.conversations[i]=[o];var a=new u(e);return setTimeout(function(){n._process(a,o).then(function(){delete n.conversations[i]})},0),a},n.prototype.ask=function(t,e,n){return this.tell(t,e).listen(n)},n.prototype._process=function(t,e){return new i(function(n){function r(t,i){t.execute(e,i).then(function(t){t.block?r(t.block,t.result):n(e)})}r(t)})},e.exports=n},{"./Conversation":3,"./block/Block":5,"./block/IIf":7,"./block/Listen":8,"./block/Tell":9,"./block/Then":10,"./messagebus":11,"es6-promise":33,"node-uuid":43}],3:[function(t,e){function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.id=t&&t.id||r.v4(),this.self=t&&t.self||null,this.other=t&&t.other||null,this.context=t&&t.context||{},this._send=t&&t.send||null,this._inbox=[],this._receivers=[]}var r=t("node-uuid"),i=t("es6-promise").Promise;n.prototype.send=function(t){return this._send(this.other,{id:this.id,from:this.self,to:this.other,message:t})},n.prototype.deliver=function(t){if(this._receivers.length){var e=this._receivers.shift();e(t.message)}else this._inbox.push(t.message)},n.prototype.receive=function(){var t=this;return this._inbox.length?i.resolve(this._inbox.shift()):new i(function(e){t._receivers.push(e)})},e.exports=n},{"es6-promise":33,"node-uuid":43}],4:[function(t,e,n){"use strict";var r=t("./Babbler"),i=t("./block/Tell"),o=t("./block/Listen"),s=t("./block/Then"),u=t("./block/Decision"),a=t("./block/IIf");n.babbler=function(t){return new r(t)},n.tell=function(t){return new i(t)},n.ask=function(t,e){return n.tell(t).listen(e)},n.decide=function(t,e){return new u(t,e)},n.listen=function(t){var e=new o;return t?e.then(t):e},n.then=function(t){return new s(t)},n.iif=function(t,e,n){return new a(t,e,n)},n.Babbler=r,n.block={Block:t("./block/Block"),Then:t("./block/Then"),Decision:t("./block/Decision"),IIf:t("./block/IIf"),Listen:t("./block/Listen"),Tell:t("./block/Tell")},n.messagebus=t("./messagebus"),n.babblify=function(t,e){var r;if(e&&void 0!==e.id)r=e.id;else{if(void 0===t.id)throw new Error('Id missing. Ensure that either actor has a property "id", or provide an id as a property in second argument params');r=t.id}["ask","tell","listen"].forEach(function(e){if(void 0!==t[e])throw new Error('Conflict: actor already has a property "'+e+'"')});var i=e&&e.send||"send";if("function"!=typeof t[i])throw new Error('Missing function. Function "'+i+'(to, message)" expected on actor or on params');var o=n.babbler(r),s=e&&e.onMessage||"onMessage",u=t.hasOwnProperty(s)?t[s]:null;return t[s]=u?function(e,n){o._onMessage(n),u.call(t,e,n)}:function(t,e){o._onMessage(e)},o.send=function(e,n){setTimeout(function(){t[i](e,n)},0)},t.__babbler__={babbler:o,onMessage:u,onMessageName:s},t.ask=o.ask.bind(o),t.tell=o.tell.bind(o),t.listen=o.listen.bind(o),t},n.unbabblify=function(t){var e=t.__babbler__;return e&&(delete t.__babbler__,delete t.ask,delete t.tell,delete t.listen,delete t[e.onMessageName],e.onMessage&&(t[e.onMessageName]=e.onMessage)),t}},{"./Babbler":2,"./block/Block":5,"./block/Decision":6,"./block/IIf":7,"./block/Listen":8,"./block/Tell":9,"./block/Then":10,"./messagebus":11}],5:[function(t,e){"use strict";function n(){this.next=null,this.previous=null}n.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.exports=n},{}],6:[function(t,e){"use strict";function n(t,e){var r,i;if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,i=e):(r=null,i=t),r){if("function"!=typeof r)throw new TypeError("Parameter decision must be a function")}else r=function(t){return t};if(i&&i instanceof Function)throw new TypeError("Parameter choices must be an object");if(this.decision=r,this.choices={},i){var o=this;Object.keys(i).forEach(function(t){o.addChoice(t,i[t])})}}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n=this,i=this.decision(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){var r=n.choices[t];if(r||(r=n.choices["default"]),!r)throw new Error('Block with id "'+t+'" not found');return{result:e,block:r}})},n.prototype.addChoice=function(t,e){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(e instanceof i))throw new TypeError("Block expected as choice");if(t in this.choices)throw new Error('Choice with id "'+t+'" already exists');for(var n=e;n&&n.previous;)n=n.previous;return this.choices[t]=n,this},i.prototype.decide=function(t,e){var r=new n(t,e);return this.then(r)},e.exports=n},{"../util":12,"./Block":5,"./Then":10,"es6-promise":33}],7:[function(t,e){"use strict";function n(t,e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.condition=t instanceof Function?t:t instanceof RegExp?function(e){return t.test(e)}:function(e){return e==t},e&&!(e instanceof i))throw new TypeError("Parameter trueBlock must be a Block");if(r&&!(r instanceof i))throw new TypeError("Parameter falseBlock must be a Block");this.trueBlock=e||null,this.falseBlock=r||null}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n=this,i=this.condition(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){var r=t?n.trueBlock||n.next:n.falseBlock;return{result:e,block:r}})},i.prototype.iif=function(t,e,r){var i=new n(t,e,r);return this.then(i)},e.exports=n},{"../util":12,"./Block":5,"./Then":10,"es6-promise":33}],8:[function(t,e){"use strict";function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}{var r=(t("es6-promise").Promise,t("./Block"));t("./Then")}n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.prototype.execute=function(t){var e=this;return t.receive().then(function(t){return{result:t,block:e.next}})},r.prototype.listen=function(t){var e=new n,r=this.then(e);return t&&(r=r.then(t)),r},e.exports=n},{"./Block":5,"./Then":10,"es6-promise":33}],9:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.message=t}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;t("./Then"),t("./Listen"),n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n,i=this;if("function"==typeof this.message){var s=this.message(e,t.context);n=o(s)?s:r.resolve(s)}else n=r.resolve(this.message);return n.then(function(e){var n=t.send(e),s=o(n)?n:r.resolve(n);return s.then(function(){return{result:e,block:i.next}})})},i.prototype.tell=function(t){var e=new n(t);return this.then(e)},i.prototype.ask=function(t,e){return this.tell(t).listen(e)},e.exports=n},{"../util":12,"./Block":5,"./Listen":8,"./Then":10,"es6-promise":33}],10:[function(t,e){"use strict";function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t}var r=t("es6-promise").Promise,i=t("./Block"),o=t("../util").isPromise;n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.execute=function(t,e){var n=this,i=this.callback(e,t.context),s=o(i)?i:r.resolve(i);return s.then(function(t){return{result:t,block:n.next}})},i.prototype.then=function(t){if("function"==typeof t&&(t=new n(t)),!(t instanceof i))throw new TypeError("Parameter next must be a Block or function");return t.previous=this,this.next=t,t},e.exports=n},{"../util":12,"./Block":5,"es6-promise":33}],11:[function(t,e,n){"use strict";var r=t("es6-promise").Promise;n["pubsub-js"]=function(){var e=t("pubsub-js");return{connect:function(t){var n=e.subscribe(t.id,function(e,n){t.message(n)});return"function"==typeof t.callback&&t.callback(),n},disconnect:function(t){e.unsubscribe(t)},send:function(t,n){e.publish(t,n)}}},n.pubnub=function(e){var n;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");n=window.PUBNUB}else n=t("pubnub");var i=n.init(e);return{connect:function(t){return i.subscribe({channel:t.id,message:t.message,connect:t.callback}),t.id},disconnect:function(t){i.unsubscribe(t)},send:function(t,e){return new r(function(n){i.publish({channel:t,message:e,callback:n})})}}},n["default"]=n["pubsub-js"]},{"es6-promise":33,pubnub:void 0,"pubsub-js":44}],12:[function(t,e,n){n.isPromise=function(t){return t&&"function"==typeof t.then&&"function"==typeof t["catch"]}},{}],13:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=A(t)),i=r.byteLength(t,e);else{if("object"!==o||null===t)throw new Error("First argument needs to be a number, array or string.");"Buffer"===t.type&&L(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}var s;V?s=r._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var u;if(V&&"number"==typeof t.byteLength)s._set(t);else if(j(t))if(r.isBuffer(t))for(u=0;i>u;u++)s[u]=t.readUInt8(u);else for(u=0;i>u;u++)s[u]=(t[u]%256+256)%256;else if("string"===o)s.write(t,0,e);else if("number"===o&&!V&&!n)for(u=0;i>u;u++)s[u]=0;return s}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;R(o%2===0,"Invalid hex string"),r>o/2&&(r=o/2);for(var s=0;r>s;s++){var u=parseInt(e.substr(2*s,2),16);R(!isNaN(u),"Invalid hex string"),t[n+s]=u}return s}function o(t,e,n,r){var i=D(O(e),t,n,r);return i}function s(t,e,n,r){var i=D(P(e),t,n,r);return i}function u(t,e,n,r){return s(t,e,n,r)}function a(t,e,n,r){var i=D(M(e),t,n,r);return i}function c(t,e,n,r){var i=D(C(e),t,n,r);return i}function f(t,e,n){return H.fromByteArray(0===e&&n===t.length?t:t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)t[o]<=127?(r+=N(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+N(i)}function h(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return h(t,e,n)}function d(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=U(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function b(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function y(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function v(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=b(t,e,n,!0),s=32768&o;return s?-1*(65535-o+1):o}}function w(t,e,n,r){r||(R("boolean"==typeof n,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=y(t,e,n,!0),s=2147483648&o;return s?-1*(4294967295-o+1):o}}function m(t,e,n,r){return r||(R("boolean"==typeof n,"missing or invalid endian"),R(e+3<t.length,"Trying to read beyond buffer length")),J.read(t,e,n,23,4)}function _(t,e,n,r){return r||(R("boolean"==typeof n,"missing or invalid endian"),R(e+7<t.length,"Trying to read beyond buffer length")),J.read(t,e,n,52,8)}function E(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"trying to write beyond buffer length"),F(e,65535));var o=t.length;if(!(n>=o)){for(var s=0,u=Math.min(o-n,2);u>s;s++)t[n+s]=(e&255<<8*(r?s:1-s))>>>8*(r?s:1-s);return n+2}}function B(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"trying to write beyond buffer length"),F(e,4294967295));var o=t.length;if(!(n>=o)){for(var s=0,u=Math.min(o-n,4);u>s;s++)t[n+s]=e>>>8*(r?s:3-s)&255;return n+4}}function k(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to write beyond buffer length"),z(e,32767,-32768));var o=t.length;if(!(n>=o))return e>=0?E(t,e,n,r,i):E(t,65535+e+1,n,r,i),n+2}function I(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to write beyond buffer length"),z(e,2147483647,-2147483648));var o=t.length;if(!(n>=o))return e>=0?B(t,e,n,r,i):B(t,4294967295+e+1,n,r,i),n+4}function x(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to write beyond buffer length"),q(e,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,23,4),n+4}function S(t,e,n,r,i){i||(R(void 0!==e&&null!==e,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+7<t.length,"Trying to write beyond buffer length"),q(e,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,52,8),n+8}function A(t){for(t=T(t).replace($,"");t.length%4!==0;)t+="=";return t}function T(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function L(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function j(t){return L(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function U(t){return 16>t?"0"+t.toString(16):t.toString(16)}function O(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}}return e}function P(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e}function C(t){for(var e,n,r,i=[],o=0;o<t.length;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function M(t){return H.toByteArray(t)}function D(t,e,n,r){for(var i=0;r>i&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function N(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function F(t,e){R("number"==typeof t,"cannot write a non-number as a number"),R(t>=0,"specified a negative value for writing an unsigned value"),R(e>=t,"value is larger than maximum value for type"),R(Math.floor(t)===t,"value has a fractional component")}function z(t,e,n){R("number"==typeof t,"cannot write a non-number as a number"),R(e>=t,"value larger than maximum allowed value"),R(t>=n,"value smaller than minimum allowed value"),R(Math.floor(t)===t,"value has a fractional component")}function q(t,e,n){R("number"==typeof t,"cannot write a non-number as a number"),R(e>=t,"value larger than maximum allowed value"),R(t>=n,"value smaller than minimum allowed value")}function R(t,e){if(!t)throw new Error(e||"Failed assertion")}/*! | ||
* The buffer module from node.js, for the browser. | ||
@@ -7,3 +7,3 @@ * | ||
*/ | ||
var H=t("base64-js"),J=t("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var V=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(n){return!1}}();r.isEncoding=function(t){switch(String(t).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}},r.isBuffer=function(t){return!(null==t||!t._isBuffer)},r.byteLength=function(t,e){var n;switch(t=t.toString(),e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=O(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=M(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(t,e){if(R(L(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;n<t.length;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;n<t.length;n++){var s=t[n];s.copy(i,o),o+=s.length}return i},r.compare=function(t,e){R(r.isBuffer(t)&&r.isBuffer(e),"Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,s=Math.min(n,i);s>o&&t[o]===e[o];o++);return o!==s&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var f=r;r=e,e=n,n=f}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=String(r||"utf8").toLowerCase();var h;switch(r){case"hex":h=i(this,t,e,n);break;case"utf8":case"utf-8":h=o(this,t,e,n);break;case"ascii":h=s(this,t,e,n);break;case"binary":h=u(this,t,e,n);break;case"base64":h=a(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=c(this,t,e,n);break;default:throw new Error("Unknown encoding")}return h},r.prototype.toString=function(t,e,n){var r=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,n=void 0===n?r.length:Number(n),n===e)return"";var i;switch(t){case"hex":i=d(r,e,n);break;case"utf8":case"utf-8":i=l(r,e,n);break;case"ascii":i=h(r,e,n);break;case"binary":i=p(r,e,n);break;case"base64":i=f(r,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,e,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return R(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return R(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,r){var i=this;if(n||(n=0),r||0===r||(r=this.length),e||(e=0),r!==n&&0!==t.length&&0!==i.length){R(r>=n,"sourceEnd < sourceStart"),R(e>=0&&e<t.length,"targetStart out of bounds"),R(n>=0&&n<i.length,"sourceStart out of bounds"),R(r>=0&&r<=i.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;if(100>o||!V)for(var s=0;o>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+o),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=~~t,e=void 0===e?n:~~e,0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),t>e&&(e=t),V)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(R(void 0!==t&&null!==t,"missing offset"),R(t<this.length,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return y(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return y(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return b(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return b(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(R(void 0!==t&&null!==t,"missing offset"),R(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return v(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return v(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return w(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return w(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return m(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return m(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return _(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return _(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==e&&null!==e,"missing offset"),R(e<this.length,"trying to write beyond buffer length"),F(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return E(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return E(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return B(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return B(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==e&&null!==e,"missing offset"),R(e<this.length,"Trying to write beyond buffer length"),z(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return k(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return k(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return x(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return x(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return S(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return S(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),R(n>=e,"end < start"),n!==e&&0!==this.length){R(e>=0&&e<this.length,"start out of bounds"),R(n>=0&&n<=this.length,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=O(t.toString()),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=U(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(V)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var Y=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=Y.get,t.set=Y.set,t.write=Y.write,t.toString=Y.toString,t.toLocaleString=Y.toString,t.toJSON=Y.toJSON,t.equals=Y.equals,t.compare=Y.compare,t.copy=Y.copy,t.slice=Y.slice,t.readUInt8=Y.readUInt8,t.readUInt16LE=Y.readUInt16LE,t.readUInt16BE=Y.readUInt16BE,t.readUInt32LE=Y.readUInt32LE,t.readUInt32BE=Y.readUInt32BE,t.readInt8=Y.readInt8,t.readInt16LE=Y.readInt16LE,t.readInt16BE=Y.readInt16BE,t.readInt32LE=Y.readInt32LE,t.readInt32BE=Y.readInt32BE,t.readFloatLE=Y.readFloatLE,t.readFloatBE=Y.readFloatBE,t.readDoubleLE=Y.readDoubleLE,t.readDoubleBE=Y.readDoubleBE,t.writeUInt8=Y.writeUInt8,t.writeUInt16LE=Y.writeUInt16LE,t.writeUInt16BE=Y.writeUInt16BE,t.writeUInt32LE=Y.writeUInt32LE,t.writeUInt32BE=Y.writeUInt32BE,t.writeInt8=Y.writeInt8,t.writeInt16LE=Y.writeInt16LE,t.writeInt16BE=Y.writeInt16BE,t.writeInt32LE=Y.writeInt32LE,t.writeInt32BE=Y.writeInt32BE,t.writeFloatLE=Y.writeFloatLE,t.writeFloatBE=Y.writeFloatBE,t.writeDoubleLE=Y.writeDoubleLE,t.writeDoubleBE=Y.writeDoubleBE,t.fill=Y.fill,t.inspect=Y.inspect,t.toArrayBuffer=Y.toArrayBuffer,t};var $=/[^+\/0-9A-z]/g},{"base64-js":14,ieee754:15}],14:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s?62:e===u?63:a>e?-1:a+10>e?e-a+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function n(t){c[l++]=t}var r,i,s,u,a,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;a="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-a),s=a>0?t.length-4:t.length;var l=0;for(r=0,i=0;s>r;r+=4,i+=3)u=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&u)>>16),n((65280&u)>>8),n(255&u);return 2===a?(u=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&u)):1===a&&(u=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(u>>8&255),n(255&u)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,u=t.length%3,a="";for(i=0,s=t.length-u;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],a+=n(o);switch(u){case 1:o=t[t.length-1],a+=e(o>>2),a+=e(o<<4&63),a+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],a+=e(o>>10),a+=e(o>>4&63),a+=e(o<<2&63),a+="="}return a}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),u="/".charCodeAt(0),a="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],15:[function(t,e,n){n.read=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,c=a>>1,f=-7,l=n?i-1:0,h=n?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[e+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===a)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var s,u,a,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(u=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=s+l>=1?h/a:h*Math.pow(2,1-l),e*a>=2&&(s++,a/=2),s+l>=f?(u=0,s=f):s+l>=1?(u=(e*a-1)*Math.pow(2,i),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,c+=i;c>0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},{}],16:[function(t,e){(function(n){function r(t){return function(){var e=[],r={update:function(t,r){return n.isBuffer(t)||(t=new n(t,r)),e.push(t),this},digest:function(r){var i=n.concat(e),o=t(i);return e=null,r?o.toString(r):o}};return r}}var i=t("sha.js"),o=r(t("./md5")),s=r(t("ripemd160"));e.exports=function(t){return"md5"===t?new o:"rmd160"===t?new s:i(t)}}).call(this,t("buffer").Buffer)},{"./md5":20,buffer:13,ripemd160:21,"sha.js":23}],17:[function(t,e){(function(n){function r(t,e){if(!(this instanceof r))return new r(t,e);this._opad=a,this._alg=t,e=this._key=n.isBuffer(e)?e:new n(e),e.length>o?e=i(t).update(e).digest():e.length<o&&(e=n.concat([e,s],o));for(var u=this._ipad=new n(o),a=this._opad=new n(o),c=0;o>c;c++)u[c]=54^e[c],a[c]=92^e[c];this._hash=i(t).update(u)}var i=t("./create-hash"),o=64,s=new n(o);s.fill(0),e.exports=r,r.prototype.update=function(t,e){return this._hash.update(t,e),this},r.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)}}).call(this,t("buffer").Buffer)},{"./create-hash":16,buffer:13}],18:[function(t,e){(function(t){function n(e,n){if(e.length%o!==0){var r=e.length+(o-e.length%o);e=t.concat([e,s],r)}for(var i=[],u=n?e.readInt32BE:e.readInt32LE,a=0;a<e.length;a+=o)i.push(u.call(e,a));return i}function r(e,n,r){for(var i=new t(n),o=r?i.writeInt32BE:i.writeInt32LE,s=0;s<e.length;s++)o.call(i,e[s],4*s,!0);return i}function i(e,i,o,s){t.isBuffer(e)||(e=new t(e));var a=i(n(e,s),e.length*u);return r(a,o,s)}var o=4,s=new t(o);s.fill(0);var u=8;e.exports={hash:i}}).call(this,t("buffer").Buffer)},{buffer:13}],19:[function(t,e,n){(function(e){function r(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var n in t)e(t[n],n)}var o=t("./rng");n.createHash=t("./create-hash"),n.createHmac=t("./create-hmac"),n.randomBytes=function(t,n){if(!n||!n.call)return new e(o(t));try{n.call(this,void 0,new e(o(t)))}catch(r){n(r)}},n.getHashes=function(){return["sha1","sha256","md5","rmd160"]};var s=t("./pbkdf2")(n.createHmac);n.pbkdf2=s.pbkdf2,n.pbkdf2Sync=s.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){n[t]=function(){r("sorry,",t,"is not implemented yet")}})}).call(this,t("buffer").Buffer)},{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,buffer:13}],20:[function(t,e){function n(t,e){t[e>>5]|=128<<e%32,t[(e+64>>>9<<4)+14]=e;for(var n=1732584193,r=-271733879,c=-1732584194,f=271733878,l=0;l<t.length;l+=16){var h=n,p=r,d=c,g=f;n=i(n,r,c,f,t[l+0],7,-680876936),f=i(f,n,r,c,t[l+1],12,-389564586),c=i(c,f,n,r,t[l+2],17,606105819),r=i(r,c,f,n,t[l+3],22,-1044525330),n=i(n,r,c,f,t[l+4],7,-176418897),f=i(f,n,r,c,t[l+5],12,1200080426),c=i(c,f,n,r,t[l+6],17,-1473231341),r=i(r,c,f,n,t[l+7],22,-45705983),n=i(n,r,c,f,t[l+8],7,1770035416),f=i(f,n,r,c,t[l+9],12,-1958414417),c=i(c,f,n,r,t[l+10],17,-42063),r=i(r,c,f,n,t[l+11],22,-1990404162),n=i(n,r,c,f,t[l+12],7,1804603682),f=i(f,n,r,c,t[l+13],12,-40341101),c=i(c,f,n,r,t[l+14],17,-1502002290),r=i(r,c,f,n,t[l+15],22,1236535329),n=o(n,r,c,f,t[l+1],5,-165796510),f=o(f,n,r,c,t[l+6],9,-1069501632),c=o(c,f,n,r,t[l+11],14,643717713),r=o(r,c,f,n,t[l+0],20,-373897302),n=o(n,r,c,f,t[l+5],5,-701558691),f=o(f,n,r,c,t[l+10],9,38016083),c=o(c,f,n,r,t[l+15],14,-660478335),r=o(r,c,f,n,t[l+4],20,-405537848),n=o(n,r,c,f,t[l+9],5,568446438),f=o(f,n,r,c,t[l+14],9,-1019803690),c=o(c,f,n,r,t[l+3],14,-187363961),r=o(r,c,f,n,t[l+8],20,1163531501),n=o(n,r,c,f,t[l+13],5,-1444681467),f=o(f,n,r,c,t[l+2],9,-51403784),c=o(c,f,n,r,t[l+7],14,1735328473),r=o(r,c,f,n,t[l+12],20,-1926607734),n=s(n,r,c,f,t[l+5],4,-378558),f=s(f,n,r,c,t[l+8],11,-2022574463),c=s(c,f,n,r,t[l+11],16,1839030562),r=s(r,c,f,n,t[l+14],23,-35309556),n=s(n,r,c,f,t[l+1],4,-1530992060),f=s(f,n,r,c,t[l+4],11,1272893353),c=s(c,f,n,r,t[l+7],16,-155497632),r=s(r,c,f,n,t[l+10],23,-1094730640),n=s(n,r,c,f,t[l+13],4,681279174),f=s(f,n,r,c,t[l+0],11,-358537222),c=s(c,f,n,r,t[l+3],16,-722521979),r=s(r,c,f,n,t[l+6],23,76029189),n=s(n,r,c,f,t[l+9],4,-640364487),f=s(f,n,r,c,t[l+12],11,-421815835),c=s(c,f,n,r,t[l+15],16,530742520),r=s(r,c,f,n,t[l+2],23,-995338651),n=u(n,r,c,f,t[l+0],6,-198630844),f=u(f,n,r,c,t[l+7],10,1126891415),c=u(c,f,n,r,t[l+14],15,-1416354905),r=u(r,c,f,n,t[l+5],21,-57434055),n=u(n,r,c,f,t[l+12],6,1700485571),f=u(f,n,r,c,t[l+3],10,-1894986606),c=u(c,f,n,r,t[l+10],15,-1051523),r=u(r,c,f,n,t[l+1],21,-2054922799),n=u(n,r,c,f,t[l+8],6,1873313359),f=u(f,n,r,c,t[l+15],10,-30611744),c=u(c,f,n,r,t[l+6],15,-1560198380),r=u(r,c,f,n,t[l+13],21,1309151649),n=u(n,r,c,f,t[l+4],6,-145523070),f=u(f,n,r,c,t[l+11],10,-1120210379),c=u(c,f,n,r,t[l+2],15,718787259),r=u(r,c,f,n,t[l+9],21,-343485551),n=a(n,h),r=a(r,p),c=a(c,d),f=a(f,g)}return Array(n,r,c,f)}function r(t,e,n,r,i,o){return a(c(a(a(e,t),a(r,o)),i),n)}function i(t,e,n,i,o,s,u){return r(e&n|~e&i,t,e,o,s,u)}function o(t,e,n,i,o,s,u){return r(e&i|n&~i,t,e,o,s,u)}function s(t,e,n,i,o,s,u){return r(e^n^i,t,e,o,s,u)}function u(t,e,n,i,o,s,u){return r(n^(e|~i),t,e,o,s,u)}function a(t,e){var n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16);return r<<16|65535&n}function c(t,e){return t<<e|t>>>32-e}var f=t("./helpers");e.exports=function(t){return f.hash(t,n,16)}},{"./helpers":18}],21:[function(t,e){(function(t){function n(t,e,n){return t^e^n}function r(t,e,n){return t&e|~t&n}function i(t,e,n){return(t|~e)^n}function o(t,e,n){return t&n|e&~n}function s(t,e,n){return t^(e|~n)}function u(t,e){return t<<e|t>>>32-e}function a(e){var n=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof e&&(e=new t(e,"utf8"));var r=g(e),i=8*e.length,o=8*e.length;r[i>>>5]|=128<<24-i%32,r[(i+64>>>9<<4)+14]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);for(var s=0;s<r.length;s+=16)b(n,r,s);for(var s=0;5>s;s++){var u=n[s];n[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var a=y(n);return new t(a)}e.exports=a;/** @preserve | ||
var H=t("base64-js"),J=t("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var V=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(n){return!1}}();r.isEncoding=function(t){switch(String(t).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}},r.isBuffer=function(t){return!(null==t||!t._isBuffer)},r.byteLength=function(t,e){var n;switch(t=t.toString(),e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=O(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=M(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(t,e){if(R(L(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;n<t.length;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;n<t.length;n++){var s=t[n];s.copy(i,o),o+=s.length}return i},r.compare=function(t,e){R(r.isBuffer(t)&&r.isBuffer(e),"Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,s=Math.min(n,i);s>o&&t[o]===e[o];o++);return o!==s&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var f=r;r=e,e=n,n=f}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=String(r||"utf8").toLowerCase();var h;switch(r){case"hex":h=i(this,t,e,n);break;case"utf8":case"utf-8":h=o(this,t,e,n);break;case"ascii":h=s(this,t,e,n);break;case"binary":h=u(this,t,e,n);break;case"base64":h=a(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=c(this,t,e,n);break;default:throw new Error("Unknown encoding")}return h},r.prototype.toString=function(t,e,n){var r=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,n=void 0===n?r.length:Number(n),n===e)return"";var i;switch(t){case"hex":i=d(r,e,n);break;case"utf8":case"utf-8":i=l(r,e,n);break;case"ascii":i=h(r,e,n);break;case"binary":i=p(r,e,n);break;case"base64":i=f(r,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,e,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return R(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return R(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,r){var i=this;if(n||(n=0),r||0===r||(r=this.length),e||(e=0),r!==n&&0!==t.length&&0!==i.length){R(r>=n,"sourceEnd < sourceStart"),R(e>=0&&e<t.length,"targetStart out of bounds"),R(n>=0&&n<i.length,"sourceStart out of bounds"),R(r>=0&&r<=i.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;if(100>o||!V)for(var s=0;o>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+o),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=~~t,e=void 0===e?n:~~e,0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),t>e&&(e=t),V)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(R(void 0!==t&&null!==t,"missing offset"),R(t<this.length,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return b(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return b(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return y(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return y(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(R(void 0!==t&&null!==t,"missing offset"),R(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return v(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return v(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return w(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return w(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return m(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return m(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return _(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return _(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==e&&null!==e,"missing offset"),R(e<this.length,"trying to write beyond buffer length"),F(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return E(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return E(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return B(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return B(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==e&&null!==e,"missing offset"),R(e<this.length,"Trying to write beyond buffer length"),z(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return k(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return k(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return x(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return x(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return S(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return S(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),R(n>=e,"end < start"),n!==e&&0!==this.length){R(e>=0&&e<this.length,"start out of bounds"),R(n>=0&&n<=this.length,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=O(t.toString()),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=U(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(V)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var Y=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=Y.get,t.set=Y.set,t.write=Y.write,t.toString=Y.toString,t.toLocaleString=Y.toString,t.toJSON=Y.toJSON,t.equals=Y.equals,t.compare=Y.compare,t.copy=Y.copy,t.slice=Y.slice,t.readUInt8=Y.readUInt8,t.readUInt16LE=Y.readUInt16LE,t.readUInt16BE=Y.readUInt16BE,t.readUInt32LE=Y.readUInt32LE,t.readUInt32BE=Y.readUInt32BE,t.readInt8=Y.readInt8,t.readInt16LE=Y.readInt16LE,t.readInt16BE=Y.readInt16BE,t.readInt32LE=Y.readInt32LE,t.readInt32BE=Y.readInt32BE,t.readFloatLE=Y.readFloatLE,t.readFloatBE=Y.readFloatBE,t.readDoubleLE=Y.readDoubleLE,t.readDoubleBE=Y.readDoubleBE,t.writeUInt8=Y.writeUInt8,t.writeUInt16LE=Y.writeUInt16LE,t.writeUInt16BE=Y.writeUInt16BE,t.writeUInt32LE=Y.writeUInt32LE,t.writeUInt32BE=Y.writeUInt32BE,t.writeInt8=Y.writeInt8,t.writeInt16LE=Y.writeInt16LE,t.writeInt16BE=Y.writeInt16BE,t.writeInt32LE=Y.writeInt32LE,t.writeInt32BE=Y.writeInt32BE,t.writeFloatLE=Y.writeFloatLE,t.writeFloatBE=Y.writeFloatBE,t.writeDoubleLE=Y.writeDoubleLE,t.writeDoubleBE=Y.writeDoubleBE,t.fill=Y.fill,t.inspect=Y.inspect,t.toArrayBuffer=Y.toArrayBuffer,t};var $=/[^+\/0-9A-z]/g},{"base64-js":14,ieee754:15}],14:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s?62:e===u?63:a>e?-1:a+10>e?e-a+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function n(t){c[l++]=t}var r,i,s,u,a,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;a="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-a),s=a>0?t.length-4:t.length;var l=0;for(r=0,i=0;s>r;r+=4,i+=3)u=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&u)>>16),n((65280&u)>>8),n(255&u);return 2===a?(u=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&u)):1===a&&(u=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(u>>8&255),n(255&u)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,u=t.length%3,a="";for(i=0,s=t.length-u;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],a+=n(o);switch(u){case 1:o=t[t.length-1],a+=e(o>>2),a+=e(o<<4&63),a+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],a+=e(o>>10),a+=e(o>>4&63),a+=e(o<<2&63),a+="="}return a}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),u="/".charCodeAt(0),a="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],15:[function(t,e,n){n.read=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,c=a>>1,f=-7,l=n?i-1:0,h=n?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[e+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===a)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var s,u,a,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(u=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=s+l>=1?h/a:h*Math.pow(2,1-l),e*a>=2&&(s++,a/=2),s+l>=f?(u=0,s=f):s+l>=1?(u=(e*a-1)*Math.pow(2,i),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,c+=i;c>0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},{}],16:[function(t,e){(function(n){function r(t){return function(){var e=[],r={update:function(t,r){return n.isBuffer(t)||(t=new n(t,r)),e.push(t),this},digest:function(r){var i=n.concat(e),o=t(i);return e=null,r?o.toString(r):o}};return r}}var i=t("sha.js"),o=r(t("./md5")),s=r(t("ripemd160"));e.exports=function(t){return"md5"===t?new o:"rmd160"===t?new s:i(t)}}).call(this,t("buffer").Buffer)},{"./md5":20,buffer:13,ripemd160:21,"sha.js":23}],17:[function(t,e){(function(n){function r(t,e){if(!(this instanceof r))return new r(t,e);this._opad=a,this._alg=t,e=this._key=n.isBuffer(e)?e:new n(e),e.length>o?e=i(t).update(e).digest():e.length<o&&(e=n.concat([e,s],o));for(var u=this._ipad=new n(o),a=this._opad=new n(o),c=0;o>c;c++)u[c]=54^e[c],a[c]=92^e[c];this._hash=i(t).update(u)}var i=t("./create-hash"),o=64,s=new n(o);s.fill(0),e.exports=r,r.prototype.update=function(t,e){return this._hash.update(t,e),this},r.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)}}).call(this,t("buffer").Buffer)},{"./create-hash":16,buffer:13}],18:[function(t,e){(function(t){function n(e,n){if(e.length%o!==0){var r=e.length+(o-e.length%o);e=t.concat([e,s],r)}for(var i=[],u=n?e.readInt32BE:e.readInt32LE,a=0;a<e.length;a+=o)i.push(u.call(e,a));return i}function r(e,n,r){for(var i=new t(n),o=r?i.writeInt32BE:i.writeInt32LE,s=0;s<e.length;s++)o.call(i,e[s],4*s,!0);return i}function i(e,i,o,s){t.isBuffer(e)||(e=new t(e));var a=i(n(e,s),e.length*u);return r(a,o,s)}var o=4,s=new t(o);s.fill(0);var u=8;e.exports={hash:i}}).call(this,t("buffer").Buffer)},{buffer:13}],19:[function(t,e,n){(function(e){function r(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var n in t)e(t[n],n)}var o=t("./rng");n.createHash=t("./create-hash"),n.createHmac=t("./create-hmac"),n.randomBytes=function(t,n){if(!n||!n.call)return new e(o(t));try{n.call(this,void 0,new e(o(t)))}catch(r){n(r)}},n.getHashes=function(){return["sha1","sha256","md5","rmd160"]};var s=t("./pbkdf2")(n.createHmac);n.pbkdf2=s.pbkdf2,n.pbkdf2Sync=s.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){n[t]=function(){r("sorry,",t,"is not implemented yet")}})}).call(this,t("buffer").Buffer)},{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,buffer:13}],20:[function(t,e){function n(t,e){t[e>>5]|=128<<e%32,t[(e+64>>>9<<4)+14]=e;for(var n=1732584193,r=-271733879,c=-1732584194,f=271733878,l=0;l<t.length;l+=16){var h=n,p=r,d=c,g=f;n=i(n,r,c,f,t[l+0],7,-680876936),f=i(f,n,r,c,t[l+1],12,-389564586),c=i(c,f,n,r,t[l+2],17,606105819),r=i(r,c,f,n,t[l+3],22,-1044525330),n=i(n,r,c,f,t[l+4],7,-176418897),f=i(f,n,r,c,t[l+5],12,1200080426),c=i(c,f,n,r,t[l+6],17,-1473231341),r=i(r,c,f,n,t[l+7],22,-45705983),n=i(n,r,c,f,t[l+8],7,1770035416),f=i(f,n,r,c,t[l+9],12,-1958414417),c=i(c,f,n,r,t[l+10],17,-42063),r=i(r,c,f,n,t[l+11],22,-1990404162),n=i(n,r,c,f,t[l+12],7,1804603682),f=i(f,n,r,c,t[l+13],12,-40341101),c=i(c,f,n,r,t[l+14],17,-1502002290),r=i(r,c,f,n,t[l+15],22,1236535329),n=o(n,r,c,f,t[l+1],5,-165796510),f=o(f,n,r,c,t[l+6],9,-1069501632),c=o(c,f,n,r,t[l+11],14,643717713),r=o(r,c,f,n,t[l+0],20,-373897302),n=o(n,r,c,f,t[l+5],5,-701558691),f=o(f,n,r,c,t[l+10],9,38016083),c=o(c,f,n,r,t[l+15],14,-660478335),r=o(r,c,f,n,t[l+4],20,-405537848),n=o(n,r,c,f,t[l+9],5,568446438),f=o(f,n,r,c,t[l+14],9,-1019803690),c=o(c,f,n,r,t[l+3],14,-187363961),r=o(r,c,f,n,t[l+8],20,1163531501),n=o(n,r,c,f,t[l+13],5,-1444681467),f=o(f,n,r,c,t[l+2],9,-51403784),c=o(c,f,n,r,t[l+7],14,1735328473),r=o(r,c,f,n,t[l+12],20,-1926607734),n=s(n,r,c,f,t[l+5],4,-378558),f=s(f,n,r,c,t[l+8],11,-2022574463),c=s(c,f,n,r,t[l+11],16,1839030562),r=s(r,c,f,n,t[l+14],23,-35309556),n=s(n,r,c,f,t[l+1],4,-1530992060),f=s(f,n,r,c,t[l+4],11,1272893353),c=s(c,f,n,r,t[l+7],16,-155497632),r=s(r,c,f,n,t[l+10],23,-1094730640),n=s(n,r,c,f,t[l+13],4,681279174),f=s(f,n,r,c,t[l+0],11,-358537222),c=s(c,f,n,r,t[l+3],16,-722521979),r=s(r,c,f,n,t[l+6],23,76029189),n=s(n,r,c,f,t[l+9],4,-640364487),f=s(f,n,r,c,t[l+12],11,-421815835),c=s(c,f,n,r,t[l+15],16,530742520),r=s(r,c,f,n,t[l+2],23,-995338651),n=u(n,r,c,f,t[l+0],6,-198630844),f=u(f,n,r,c,t[l+7],10,1126891415),c=u(c,f,n,r,t[l+14],15,-1416354905),r=u(r,c,f,n,t[l+5],21,-57434055),n=u(n,r,c,f,t[l+12],6,1700485571),f=u(f,n,r,c,t[l+3],10,-1894986606),c=u(c,f,n,r,t[l+10],15,-1051523),r=u(r,c,f,n,t[l+1],21,-2054922799),n=u(n,r,c,f,t[l+8],6,1873313359),f=u(f,n,r,c,t[l+15],10,-30611744),c=u(c,f,n,r,t[l+6],15,-1560198380),r=u(r,c,f,n,t[l+13],21,1309151649),n=u(n,r,c,f,t[l+4],6,-145523070),f=u(f,n,r,c,t[l+11],10,-1120210379),c=u(c,f,n,r,t[l+2],15,718787259),r=u(r,c,f,n,t[l+9],21,-343485551),n=a(n,h),r=a(r,p),c=a(c,d),f=a(f,g)}return Array(n,r,c,f)}function r(t,e,n,r,i,o){return a(c(a(a(e,t),a(r,o)),i),n)}function i(t,e,n,i,o,s,u){return r(e&n|~e&i,t,e,o,s,u)}function o(t,e,n,i,o,s,u){return r(e&i|n&~i,t,e,o,s,u)}function s(t,e,n,i,o,s,u){return r(e^n^i,t,e,o,s,u)}function u(t,e,n,i,o,s,u){return r(n^(e|~i),t,e,o,s,u)}function a(t,e){var n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16);return r<<16|65535&n}function c(t,e){return t<<e|t>>>32-e}var f=t("./helpers");e.exports=function(t){return f.hash(t,n,16)}},{"./helpers":18}],21:[function(t,e){(function(t){function n(t,e,n){return t^e^n}function r(t,e,n){return t&e|~t&n}function i(t,e,n){return(t|~e)^n}function o(t,e,n){return t&n|e&~n}function s(t,e,n){return t^(e|~n)}function u(t,e){return t<<e|t>>>32-e}function a(e){var n=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof e&&(e=new t(e,"utf8"));var r=g(e),i=8*e.length,o=8*e.length;r[i>>>5]|=128<<24-i%32,r[(i+64>>>9<<4)+14]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);for(var s=0;s<r.length;s+=16)y(n,r,s);for(var s=0;5>s;s++){var u=n[s];n[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var a=b(n);return new t(a)}e.exports=a;/** @preserve | ||
(c) 2012 by Cédric Mesnil. All rights reserved. | ||
@@ -18,3 +18,3 @@ | ||
*/ | ||
var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],l=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],h=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],p=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0],g=function(t){for(var e=[],n=0,r=0;n<t.length;n++,r+=8)e[r>>>5]|=t[n]<<24-r%32;return e},y=function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},b=function(t,e,a){for(var g=0;16>g;g++){var y=a+g,b=e[y];e[y]=16711935&(b<<8|b>>>24)|4278255360&(b<<24|b>>>8)}var v,w,m,_,E,B,k,I,x,S;B=v=t[0],k=w=t[1],I=m=t[2],x=_=t[3],S=E=t[4];for(var A,g=0;80>g;g+=1)A=v+e[a+c[g]]|0,A+=16>g?n(w,m,_)+p[0]:32>g?r(w,m,_)+p[1]:48>g?i(w,m,_)+p[2]:64>g?o(w,m,_)+p[3]:s(w,m,_)+p[4],A=0|A,A=u(A,l[g]),A=A+E|0,v=E,E=_,_=u(m,10),m=w,w=A,A=B+e[a+f[g]]|0,A+=16>g?s(k,I,x)+d[0]:32>g?o(k,I,x)+d[1]:48>g?i(k,I,x)+d[2]:64>g?r(k,I,x)+d[3]:n(k,I,x)+d[4],A=0|A,A=u(A,h[g]),A=A+S|0,B=S,S=x,x=u(I,10),I=k,k=A;A=t[1]+m+x|0,t[1]=t[2]+_+S|0,t[2]=t[3]+E+B|0,t[3]=t[4]+v+k|0,t[4]=t[0]+w+I|0,t[0]=A}}).call(this,t("buffer").Buffer)},{buffer:13}],22:[function(t,e){var n=t("./util"),r=n.write,i=n.zeroFill;e.exports=function(t){function e(e,n){this._block=new t(e),this._finalSize=n,this._blockSize=e,this._len=0,this._s=0}function o(t,e){return null==e?t.byteLength||t.length:"ascii"==e||"binary"==e?t.length:"hex"==e?t.length/2:"base64"==e?t.length/3:void 0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,n){var i,s=this._blockSize;n||"string"!=typeof e||(n="utf8"),n?("utf-8"===n&&(n="utf8"),("base64"===n||"utf8"===n)&&(e=new t(e,n),n=null),i=o(e,n)):i=e.byteLength||e.length;for(var u=this._len+=i,a=this._s=this._s||0,c=0,f=this._block;u>a;){var l=Math.min(i,c+s-a%s);r(f,e,n,a%s,c,l);var h=l-c;a+=h,c+=h,a%s||this._update(f)}return this._s=a,this},e.prototype.digest=function(t){var e=this._blockSize,r=this._finalSize,o=8*this._len,s=this._block,u=o%(8*e);s[this._len%e]=128,i(this._block,this._len%e+1),u>=8*r&&(this._update(this._block),n.zeroFill(this._block,0)),s.writeInt32BE(o,r+4);var a=this._update(this._block)||this._hash();return null==t?a:a.toString(t)},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},{"./util":26}],23:[function(t,e,n){var n=e.exports=function(t){var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e},r=t("buffer").Buffer,i=t("./hash")(r);n.sha=n.sha1=t("./sha1")(r,i),n.sha256=t("./sha256")(r,i)},{"./hash":22,"./sha1":24,"./sha256":25,buffer:13}],24:[function(t,e){e.exports=function(e,n){function r(){return g.length?g.pop().init():this instanceof r?(this._w=d,n.call(this,64,56),this._h=null,void this.init()):new r}function i(t,e,n,r){return 20>t?e&n|~e&r:40>t?e^n^r:60>t?e&n|e&r|n&r:e^n^r}function o(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function s(t,e){return t+e|0}function u(t,e){return t<<e|t>>>32-e}var a=t("util").inherits;a(r,n);var c=0,f=4,l=8,h=12,p=16,d=new Int32Array(80),g=[];r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,n.prototype.init.call(this),this},r.prototype._POOL=g;new e(1)instanceof DataView;return r.prototype._update=function(){{var t,e,n,r,a,c,f,l,h,p,d=this._block;this._h}t=c=this._a,e=f=this._b,n=l=this._c,r=h=this._d,a=p=this._e;for(var g=this._w,y=0;80>y;y++){var b=g[y]=16>y?d.readInt32BE(4*y):u(g[y-3]^g[y-8]^g[y-14]^g[y-16],1),v=s(s(u(t,5),i(y,e,n,r)),s(s(a,b),o(y)));a=r,r=n,n=u(e,30),e=t,t=v}this._a=s(t,c),this._b=s(e,f),this._c=s(n,l),this._d=s(r,h),this._e=s(a,p)},r.prototype._hash=function(){g.length<100&&g.push(this);var t=new e(20);return t.writeInt32BE(0|this._a,c),t.writeInt32BE(0|this._b,f),t.writeInt32BE(0|this._c,l),t.writeInt32BE(0|this._d,h),t.writeInt32BE(0|this._e,p),t},r}},{util:32}],25:[function(t,e){{var n=t("util").inherits;t("./util")}e.exports=function(t,e){function r(){d.length,this.init(),this._w=p,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function o(t,e){return t>>>e}function s(t,e,n){return t&e^~t&n}function u(t,e,n){return t&e^t&n^e&n}function a(t){return i(t,2)^i(t,13)^i(t,22)}function c(t){return i(t,6)^i(t,11)^i(t,25)}function f(t){return i(t,7)^i(t,18)^o(t,3)}function l(t){return i(t,17)^i(t,19)^o(t,10)}var h=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];n(r,e);var p=new Array(64),d=[];r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this};return r.prototype._update=function(){var t,e,n,r,i,o,p,d,g,y,b=this._block,v=this._w;t=0|this._a,e=0|this._b,n=0|this._c,r=0|this._d,i=0|this._e,o=0|this._f,p=0|this._g,d=0|this._h;for(var w=0;64>w;w++){var m=v[w]=16>w?b.readInt32BE(4*w):l(v[w-2])+v[w-7]+f(v[w-15])+v[w-16];g=d+c(i)+s(i,o,p)+h[w]+m,y=a(t)+u(t,e,n),d=p,p=o,o=i,i=r+g,r=n,n=e,e=t,t=g+y}this._a=t+this._a|0,this._b=e+this._b|0,this._c=n+this._c|0,this._d=r+this._d|0,this._e=i+this._e|0,this._f=o+this._f|0,this._g=p+this._g|0,this._h=d+this._h|0},r.prototype._hash=function(){d.length<10&&d.push(this);var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},r}},{"./util":26,util:32}],26:[function(t,e,n){function r(t,e,n,r,i,o){var s=o-i;if("ascii"===n||"binary"===n)for(var u=0;s>u;u++)t[r+u]=e.charCodeAt(u+i);else if(null==n)for(var u=0;s>u;u++)t[r+u]=e[u+i];else{if("hex"!==n)throw new Error("base64"===n?"base64 encoding not yet supported":n+" encoding not yet supported");for(var u=0;s>u;u++){var a=i+u;t[r+u]=parseInt(e[2*a]+e[2*a+1],16)}}}function i(t,e){for(var n=e;n<t.length;n++)t[n]=0}n.write=r,n.zeroFill=i,n.toString=toString},{}],27:[function(t,e){(function(t){var n=64,r=new t(n);r.fill(0),e.exports=function(e,i){return i=i||{},i.pbkdf2=function(t,e,n,r,o){if("function"!=typeof o)throw new Error("No callback provided to pbkdf2");setTimeout(function(){o(null,i.pbkdf2Sync(t,e,n,r))})},i.pbkdf2Sync=function(i,o,s,u){if("number"!=typeof s)throw new TypeError("Iterations not a number");if(0>s)throw new TypeError("Bad iterations");if("number"!=typeof u)throw new TypeError("Key length not a number");if(0>u)throw new TypeError("Bad key length");var i=t.isBuffer(i)?i:new t(i);i.length>n?i=createHash(alg).update(i).digest():i.length<n&&(i=t.concat([i,r],n));var a,c,f,l=0,h=1,p=new t(4),d=new t(u);for(d.fill(0);u;){c=u>20?20:u,p[0]=h>>24&255,p[1]=h>>16&255,p[2]=h>>8&255,p[3]=255&h,a=e("sha1",i),a.update(o),a.update(p),f=a.digest(),f.copy(d,l,0,c);for(var g=1;s>g;g++){a=e("sha1",i),a.update(f),f=a.digest();for(var y=0;c>y;y++)d[y]^=f[y]}u-=c,h++,l+=c}return d},i}}).call(this,t("buffer").Buffer)},{buffer:13}],28:[function(t,e){(function(t){!function(){e.exports=function(e){var n=new t(e);return crypto.getRandomValues(n),n}}()}).call(this,t("buffer").Buffer)},{buffer:13}],29:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},{}],30:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],31:[function(t,e){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],32:[function(t,e,n){(function(e,r){function i(t,e){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),a(r,t,r.depth)}function o(t,e){var n=i.styles[e];return n?"["+i.colors[n][0]+"m"+t+"["+i.colors[n][1]+"m":t}function s(t){return t}function u(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function a(t,e,r){if(t.customInspect&&e&&x(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return w(i)||(i=a(t,i,r)),i}var o=c(t,e);if(o)return o;var s=Object.keys(e),g=u(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),I(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(x(e)){var y=e.name?": "+e.name:"";return t.stylize("[Function"+y+"]","special")}if(E(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(k(e))return t.stylize(Date.prototype.toString.call(e),"date");if(I(e))return f(e)}var b="",v=!1,m=["{","}"];if(d(e)&&(v=!0,m=["[","]"]),x(e)){var _=e.name?": "+e.name:"";b=" [Function"+_+"]"}if(E(e)&&(b=" "+RegExp.prototype.toString.call(e)),k(e)&&(b=" "+Date.prototype.toUTCString.call(e)),I(e)&&(b=" "+f(e)),0===s.length&&(!v||0==e.length))return m[0]+b+m[1];if(0>r)return E(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var B;return B=v?l(t,e,r,g,s):s.map(function(n){return h(t,e,r,g,n,v)}),t.seen.pop(),p(B,b,m)}function c(t,e){if(_(e))return t.stylize("undefined","undefined");if(w(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return v(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,i){for(var o=[],s=0,u=e.length;u>s;++s)o.push(j(e,String(s))?h(t,e,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(t,e,n,r,i,!0))}),o}function h(t,e,n,r,i,o){var s,u,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?u=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(u=t.stylize("[Setter]","special")),j(r,i)||(s="["+i+"]"),u||(t.seen.indexOf(c.value)<0?(u=y(n)?a(t,c.value,null):a(t,c.value,n-1),u.indexOf("\n")>-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n"))):u=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+u}function p(t,e,n){var r=0,i=t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function y(t){return null===t}function b(t){return null==t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return"symbol"==typeof t}function _(t){return void 0===t}function E(t){return B(t)&&"[object RegExp]"===A(t)}function B(t){return"object"==typeof t&&null!==t}function k(t){return B(t)&&"[object Date]"===A(t)}function I(t){return B(t)&&("[object Error]"===A(t)||t instanceof Error)}function x(t){return"function"==typeof t}function S(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function A(t){return Object.prototype.toString.call(t)}function T(t){return 10>t?"0"+t.toString(10):t.toString(10)}function L(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),C[t.getMonth()],e].join(" ")}function j(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var U=/%[sdj%]/g;n.format=function(t){if(!w(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(i(arguments[n]));return e.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(t).replace(U,function(t){if("%%"===t)return"%";if(n>=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return t}}),u=r[n];o>n;u=r[++n])s+=y(u)||!B(u)?" "+u:" "+i(u);return s},n.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(_(r.process))return function(){return n.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var O,P={};n.debuglog=function(t){if(_(O)&&(O=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!P[t])if(new RegExp("\\b"+t+"\\b","i").test(O)){var r=e.pid;P[t]=function(){var e=n.format.apply(n,arguments);console.error("%s %d: %s",t,r,e)}}else P[t]=function(){};return P[t]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=d,n.isBoolean=g,n.isNull=y,n.isNullOrUndefined=b,n.isNumber=v,n.isString=w,n.isSymbol=m,n.isUndefined=_,n.isRegExp=E,n.isObject=B,n.isDate=k,n.isError=I,n.isFunction=x,n.isPrimitive=S,n.isBuffer=t("./support/isBuffer");var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",L(),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!B(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":31,_process:30,inherits:29}],33:[function(t,e,n){"use strict";var r=t("./promise/promise").Promise,i=t("./promise/polyfill").polyfill;n.Promise=r,n.polyfill=i},{"./promise/polyfill":37,"./promise/promise":38}],34:[function(t,e,n){"use strict";function r(t){var e=this;if(!i(t))throw new TypeError("You must pass an array to all.");return new e(function(e,n){function r(t){return function(e){i(t,e)}}function i(t,n){u[t]=n,0===--a&&e(u)}var s,u=[],a=t.length;0===a&&e([]);for(var c=0;c<t.length;c++)s=t[c],s&&o(s.then)?s.then(r(c),n):i(c,s)})}var i=t("./utils").isArray,o=t("./utils").isFunction;n.all=r},{"./utils":42}],35:[function(t,e,n){(function(t,e){"use strict";function r(){return function(){t.nextTick(s)}}function i(){var t=0,e=new f(s),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function o(){return function(){l.setTimeout(s,1)}}function s(){for(var t=0;t<h.length;t++){var e=h[t],n=e[0],r=e[1];n(r)}h=[]}function u(t,e){var n=h.push([t,e]);1===n&&a()}var a,c="undefined"!=typeof window?window:{},f=c.MutationObserver||c.WebKitMutationObserver,l="undefined"!=typeof e?e:void 0===this?window:this,h=[];a="undefined"!=typeof t&&"[object process]"==={}.toString.call(t)?r():f?i():o(),n.asap=u}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:30}],36:[function(t,e,n){"use strict";function r(t,e){return 2!==arguments.length?i[t]:void(i[t]=e)}var i={instrument:!1};n.config=i,n.configure=r},{}],37:[function(t,e,n){(function(e){"use strict";function r(){var t;t="undefined"!=typeof e?e:"undefined"!=typeof window&&window.document?window:self;var n="Promise"in t&&"resolve"in t.Promise&&"reject"in t.Promise&&"all"in t.Promise&&"race"in t.Promise&&function(){var e;return new t.Promise(function(t){e=t}),o(e)}();n||(t.Promise=i)}var i=t("./promise").Promise,o=t("./utils").isFunction;n.polyfill=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./promise":38,"./utils":42}],38:[function(t,e,n){"use strict";function r(t){if(!y(t))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof r))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],i(t,this)}function i(t,e){function n(t){c(e,t)}function r(t){l(e,t)}try{t(n,r)}catch(i){r(i)}}function o(t,e,n,r){var i,o,s,u,f=y(n);if(f)try{i=n(r),s=!0}catch(h){u=!0,o=h}else i=r,s=!0;a(e,i)||(f&&s?c(e,i):u?l(e,o):t===k?c(e,i):t===I&&l(e,i))}function s(t,e,n,r){var i=t._subscribers,o=i.length;i[o]=e,i[o+k]=n,i[o+I]=r}function u(t,e){for(var n,r,i=t._subscribers,s=t._detail,u=0;u<i.length;u+=3)n=i[u],r=i[u+e],o(e,n,r,s);t._subscribers=null}function a(t,e){var n,r=null;try{if(t===e)throw new TypeError("A promises callback cannot return that same promise.");if(g(e)&&(r=e.then,y(r)))return r.call(e,function(r){return n?!0:(n=!0,void(e!==r?c(t,r):f(t,r)))},function(e){return n?!0:(n=!0,void l(t,e))}),!0}catch(i){return n?!0:(l(t,i),!0)}return!1}function c(t,e){t===e?f(t,e):a(t,e)||f(t,e)}function f(t,e){t._state===E&&(t._state=B,t._detail=e,d.async(h,t))}function l(t,e){t._state===E&&(t._state=B,t._detail=e,d.async(p,t))}function h(t){u(t,t._state=k)}function p(t){u(t,t._state=I)}var d=t("./config").config,g=(t("./config").configure,t("./utils").objectOrFunction),y=t("./utils").isFunction,b=(t("./utils").now,t("./all").all),v=t("./race").race,w=t("./resolve").resolve,m=t("./reject").reject,_=t("./asap").asap;d.async=_;var E=void 0,B=0,k=1,I=2;r.prototype={constructor:r,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(t,e){var n=this,r=new this.constructor(function(){});if(this._state){var i=arguments;d.async(function(){o(n._state,r,i[n._state-1],n._detail)})}else s(this,r,t,e);return r},"catch":function(t){return this.then(null,t)}},r.all=b,r.race=v,r.resolve=w,r.reject=m,n.Promise=r},{"./all":34,"./asap":35,"./config":36,"./race":39,"./reject":40,"./resolve":41,"./utils":42}],39:[function(t,e,n){"use strict";function r(t){var e=this;if(!i(t))throw new TypeError("You must pass an array to race.");return new e(function(e,n){for(var r,i=0;i<t.length;i++)r=t[i],r&&"function"==typeof r.then?r.then(e,n):e(r)})}var i=t("./utils").isArray;n.race=r},{"./utils":42}],40:[function(t,e,n){"use strict";function r(t){var e=this;return new e(function(e,n){n(t)})}n.reject=r},{}],41:[function(t,e,n){"use strict";function r(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=this;return new e(function(e){e(t)})}n.resolve=r},{}],42:[function(t,e,n){"use strict";function r(t){return i(t)||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}var s=Date.now||function(){return(new Date).getTime()};n.objectOrFunction=r,n.isFunction=i,n.isArray=o,n.now=s},{}],43:[function(e,n){(function(r){(function(){function i(t,e,n){var r=e&&n||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>i&&(e[r+i++]=y[t])});16>i;)e[r+i++]=0;return e}function o(t,e){var n=e||0,r=g;return r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]}function s(t,e,n){var r=e&&n||0,i=e||[];t=t||{};var s=null!=t.clockseq?t.clockseq:m,u=null!=t.msecs?t.msecs:(new Date).getTime(),a=null!=t.nsecs?t.nsecs:E+1,c=u-_+(a-E)/1e4;if(0>c&&null==t.clockseq&&(s=s+1&16383),(0>c||u>_)&&null==t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_=u,E=a,m=s,u+=122192928e5;var f=(1e4*(268435455&u)+a)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var l=u/4294967296*1e4&268435455;i[r++]=l>>>8&255,i[r++]=255&l,i[r++]=l>>>24&15|16,i[r++]=l>>>16&255,i[r++]=s>>>8|128,i[r++]=255&s;for(var h=t.node||w,p=0;6>p;p++)i[r+p]=h[p];return e?e:o(i)}function u(t,e,n){var r=e&&n||0;"string"==typeof t&&(e="binary"==t?new d(16):null,t=null),t=t||{};var i=t.random||(t.rng||a)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;16>s;s++)e[r+s]=i[s];return e||o(i)}var a,c=this;if("function"==typeof e)try{var f=e("crypto").randomBytes;a=f&&function(){return f(16)}}catch(l){}if(!a&&c.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);a=function(){return crypto.getRandomValues(h),h}}if(!a){var p=new Array(16);a=function(){for(var t,e=0;16>e;e++)0===(3&e)&&(t=4294967296*Math.random()),p[e]=t>>>((3&e)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,g=[],y={},b=0;256>b;b++)g[b]=(b+256).toString(16).substr(1),y[g[b]]=b;var v=a(),w=[1|v[0],v[1],v[2],v[3],v[4],v[5]],m=16383&(v[6]<<8|v[7]),_=0,E=0,B=u;if(B.v1=s,B.v4=u,B.parse=i,B.unparse=o,B.BufferClass=d,"function"==typeof t&&t.amd)t(function(){return B});else if("undefined"!=typeof n&&n.exports)n.exports=B;else{var k=c.uuid;B.noConflict=function(){return c.uuid=k,B},c.uuid=B}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:13,crypto:19}],44:[function(e,n,r){!function(e,i){"use strict";"object"==typeof r&&n?n.exports=i():"function"==typeof t&&t.amd?t(i):e.PubSub=i()}("object"==typeof window&&window||this,function(){"use strict";function t(t){var e;for(e in t)if(t.hasOwnProperty(e))return!0;return!1}function e(t){return function(){throw t}}function n(t,n,r){try{t(n,r)}catch(i){setTimeout(e(i),0)}}function r(t,e,n){t(e,n)}function i(t,e,i,o){var s,u=c[e],a=o?r:n;if(c.hasOwnProperty(e))for(s in u)u.hasOwnProperty(s)&&a(u[s],t,i)}function o(t,e,n){return function(){var r=String(t),o=r.lastIndexOf(".");for(i(t,t,e,n);-1!==o;)r=r.substr(0,o),o=r.lastIndexOf("."),i(t,r,e)}}function s(e){for(var n=String(e),r=Boolean(c.hasOwnProperty(n)&&t(c[n])),i=n.lastIndexOf(".");!r&&-1!==i;)n=n.substr(0,i),i=n.lastIndexOf("."),r=Boolean(c.hasOwnProperty(n)&&t(c[n]));return r}function u(t,e,n,r){var i=o(t,e,r),u=s(t);return u?(n===!0?i():setTimeout(i,0),!0):!1}var a={},c={},f=-1;return a.publish=function(t,e){return u(t,e,!1,a.immediateExceptions)},a.publishSync=function(t,e){return u(t,e,!0,a.immediateExceptions)},a.subscribe=function(t,e){if("function"!=typeof e)return!1;c.hasOwnProperty(t)||(c[t]={});var n="uid_"+String(++f);return c[t][n]=e,n},a.unsubscribe=function(t){var e,n,r,i="string"==typeof t,o=!1;for(e in c)if(c.hasOwnProperty(e)){if(n=c[e],i&&n[t]){delete n[t],o=t;break}if(!i)for(r in n)n.hasOwnProperty(r)&&n[r]===t&&(delete n[r],o=!0)}return o},a})},{}]},{},[1])(1)}); | ||
var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],l=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],h=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],p=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0],g=function(t){for(var e=[],n=0,r=0;n<t.length;n++,r+=8)e[r>>>5]|=t[n]<<24-r%32;return e},b=function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},y=function(t,e,a){for(var g=0;16>g;g++){var b=a+g,y=e[b];e[b]=16711935&(y<<8|y>>>24)|4278255360&(y<<24|y>>>8)}var v,w,m,_,E,B,k,I,x,S;B=v=t[0],k=w=t[1],I=m=t[2],x=_=t[3],S=E=t[4];for(var A,g=0;80>g;g+=1)A=v+e[a+c[g]]|0,A+=16>g?n(w,m,_)+p[0]:32>g?r(w,m,_)+p[1]:48>g?i(w,m,_)+p[2]:64>g?o(w,m,_)+p[3]:s(w,m,_)+p[4],A=0|A,A=u(A,l[g]),A=A+E|0,v=E,E=_,_=u(m,10),m=w,w=A,A=B+e[a+f[g]]|0,A+=16>g?s(k,I,x)+d[0]:32>g?o(k,I,x)+d[1]:48>g?i(k,I,x)+d[2]:64>g?r(k,I,x)+d[3]:n(k,I,x)+d[4],A=0|A,A=u(A,h[g]),A=A+S|0,B=S,S=x,x=u(I,10),I=k,k=A;A=t[1]+m+x|0,t[1]=t[2]+_+S|0,t[2]=t[3]+E+B|0,t[3]=t[4]+v+k|0,t[4]=t[0]+w+I|0,t[0]=A}}).call(this,t("buffer").Buffer)},{buffer:13}],22:[function(t,e){var n=t("./util"),r=n.write,i=n.zeroFill;e.exports=function(t){function e(e,n){this._block=new t(e),this._finalSize=n,this._blockSize=e,this._len=0,this._s=0}function o(t,e){return null==e?t.byteLength||t.length:"ascii"==e||"binary"==e?t.length:"hex"==e?t.length/2:"base64"==e?t.length/3:void 0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,n){var i,s=this._blockSize;n||"string"!=typeof e||(n="utf8"),n?("utf-8"===n&&(n="utf8"),("base64"===n||"utf8"===n)&&(e=new t(e,n),n=null),i=o(e,n)):i=e.byteLength||e.length;for(var u=this._len+=i,a=this._s=this._s||0,c=0,f=this._block;u>a;){var l=Math.min(i,c+s-a%s);r(f,e,n,a%s,c,l);var h=l-c;a+=h,c+=h,a%s||this._update(f)}return this._s=a,this},e.prototype.digest=function(t){var e=this._blockSize,r=this._finalSize,o=8*this._len,s=this._block,u=o%(8*e);s[this._len%e]=128,i(this._block,this._len%e+1),u>=8*r&&(this._update(this._block),n.zeroFill(this._block,0)),s.writeInt32BE(o,r+4);var a=this._update(this._block)||this._hash();return null==t?a:a.toString(t)},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},{"./util":26}],23:[function(t,e,n){var n=e.exports=function(t){var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e},r=t("buffer").Buffer,i=t("./hash")(r);n.sha=n.sha1=t("./sha1")(r,i),n.sha256=t("./sha256")(r,i)},{"./hash":22,"./sha1":24,"./sha256":25,buffer:13}],24:[function(t,e){e.exports=function(e,n){function r(){return g.length?g.pop().init():this instanceof r?(this._w=d,n.call(this,64,56),this._h=null,void this.init()):new r}function i(t,e,n,r){return 20>t?e&n|~e&r:40>t?e^n^r:60>t?e&n|e&r|n&r:e^n^r}function o(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function s(t,e){return t+e|0}function u(t,e){return t<<e|t>>>32-e}var a=t("util").inherits;a(r,n);var c=0,f=4,l=8,h=12,p=16,d=new Int32Array(80),g=[];r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,n.prototype.init.call(this),this},r.prototype._POOL=g;new e(1)instanceof DataView;return r.prototype._update=function(){{var t,e,n,r,a,c,f,l,h,p,d=this._block;this._h}t=c=this._a,e=f=this._b,n=l=this._c,r=h=this._d,a=p=this._e;for(var g=this._w,b=0;80>b;b++){var y=g[b]=16>b?d.readInt32BE(4*b):u(g[b-3]^g[b-8]^g[b-14]^g[b-16],1),v=s(s(u(t,5),i(b,e,n,r)),s(s(a,y),o(b)));a=r,r=n,n=u(e,30),e=t,t=v}this._a=s(t,c),this._b=s(e,f),this._c=s(n,l),this._d=s(r,h),this._e=s(a,p)},r.prototype._hash=function(){g.length<100&&g.push(this);var t=new e(20);return t.writeInt32BE(0|this._a,c),t.writeInt32BE(0|this._b,f),t.writeInt32BE(0|this._c,l),t.writeInt32BE(0|this._d,h),t.writeInt32BE(0|this._e,p),t},r}},{util:32}],25:[function(t,e){{var n=t("util").inherits;t("./util")}e.exports=function(t,e){function r(){d.length,this.init(),this._w=p,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function o(t,e){return t>>>e}function s(t,e,n){return t&e^~t&n}function u(t,e,n){return t&e^t&n^e&n}function a(t){return i(t,2)^i(t,13)^i(t,22)}function c(t){return i(t,6)^i(t,11)^i(t,25)}function f(t){return i(t,7)^i(t,18)^o(t,3)}function l(t){return i(t,17)^i(t,19)^o(t,10)}var h=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];n(r,e);var p=new Array(64),d=[];r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this};return r.prototype._update=function(){var t,e,n,r,i,o,p,d,g,b,y=this._block,v=this._w;t=0|this._a,e=0|this._b,n=0|this._c,r=0|this._d,i=0|this._e,o=0|this._f,p=0|this._g,d=0|this._h;for(var w=0;64>w;w++){var m=v[w]=16>w?y.readInt32BE(4*w):l(v[w-2])+v[w-7]+f(v[w-15])+v[w-16];g=d+c(i)+s(i,o,p)+h[w]+m,b=a(t)+u(t,e,n),d=p,p=o,o=i,i=r+g,r=n,n=e,e=t,t=g+b}this._a=t+this._a|0,this._b=e+this._b|0,this._c=n+this._c|0,this._d=r+this._d|0,this._e=i+this._e|0,this._f=o+this._f|0,this._g=p+this._g|0,this._h=d+this._h|0},r.prototype._hash=function(){d.length<10&&d.push(this);var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},r}},{"./util":26,util:32}],26:[function(t,e,n){function r(t,e,n,r,i,o){var s=o-i;if("ascii"===n||"binary"===n)for(var u=0;s>u;u++)t[r+u]=e.charCodeAt(u+i);else if(null==n)for(var u=0;s>u;u++)t[r+u]=e[u+i];else{if("hex"!==n)throw new Error("base64"===n?"base64 encoding not yet supported":n+" encoding not yet supported");for(var u=0;s>u;u++){var a=i+u;t[r+u]=parseInt(e[2*a]+e[2*a+1],16)}}}function i(t,e){for(var n=e;n<t.length;n++)t[n]=0}n.write=r,n.zeroFill=i,n.toString=toString},{}],27:[function(t,e){(function(t){var n=64,r=new t(n);r.fill(0),e.exports=function(e,i){return i=i||{},i.pbkdf2=function(t,e,n,r,o){if("function"!=typeof o)throw new Error("No callback provided to pbkdf2");setTimeout(function(){o(null,i.pbkdf2Sync(t,e,n,r))})},i.pbkdf2Sync=function(i,o,s,u){if("number"!=typeof s)throw new TypeError("Iterations not a number");if(0>s)throw new TypeError("Bad iterations");if("number"!=typeof u)throw new TypeError("Key length not a number");if(0>u)throw new TypeError("Bad key length");var i=t.isBuffer(i)?i:new t(i);i.length>n?i=createHash(alg).update(i).digest():i.length<n&&(i=t.concat([i,r],n));var a,c,f,l=0,h=1,p=new t(4),d=new t(u);for(d.fill(0);u;){c=u>20?20:u,p[0]=h>>24&255,p[1]=h>>16&255,p[2]=h>>8&255,p[3]=255&h,a=e("sha1",i),a.update(o),a.update(p),f=a.digest(),f.copy(d,l,0,c);for(var g=1;s>g;g++){a=e("sha1",i),a.update(f),f=a.digest();for(var b=0;c>b;b++)d[b]^=f[b]}u-=c,h++,l+=c}return d},i}}).call(this,t("buffer").Buffer)},{buffer:13}],28:[function(t,e){(function(t){!function(){e.exports=function(e){var n=new t(e);return crypto.getRandomValues(n),n}}()}).call(this,t("buffer").Buffer)},{buffer:13}],29:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},{}],30:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],31:[function(t,e){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],32:[function(t,e,n){(function(e,r){function i(t,e){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),a(r,t,r.depth)}function o(t,e){var n=i.styles[e];return n?"["+i.colors[n][0]+"m"+t+"["+i.colors[n][1]+"m":t}function s(t){return t}function u(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function a(t,e,r){if(t.customInspect&&e&&x(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return w(i)||(i=a(t,i,r)),i}var o=c(t,e);if(o)return o;var s=Object.keys(e),g=u(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),I(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(x(e)){var b=e.name?": "+e.name:"";return t.stylize("[Function"+b+"]","special")}if(E(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(k(e))return t.stylize(Date.prototype.toString.call(e),"date");if(I(e))return f(e)}var y="",v=!1,m=["{","}"];if(d(e)&&(v=!0,m=["[","]"]),x(e)){var _=e.name?": "+e.name:"";y=" [Function"+_+"]"}if(E(e)&&(y=" "+RegExp.prototype.toString.call(e)),k(e)&&(y=" "+Date.prototype.toUTCString.call(e)),I(e)&&(y=" "+f(e)),0===s.length&&(!v||0==e.length))return m[0]+y+m[1];if(0>r)return E(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var B;return B=v?l(t,e,r,g,s):s.map(function(n){return h(t,e,r,g,n,v)}),t.seen.pop(),p(B,y,m)}function c(t,e){if(_(e))return t.stylize("undefined","undefined");if(w(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return v(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,i){for(var o=[],s=0,u=e.length;u>s;++s)o.push(j(e,String(s))?h(t,e,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(t,e,n,r,i,!0))}),o}function h(t,e,n,r,i,o){var s,u,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?u=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(u=t.stylize("[Setter]","special")),j(r,i)||(s="["+i+"]"),u||(t.seen.indexOf(c.value)<0?(u=b(n)?a(t,c.value,null):a(t,c.value,n-1),u.indexOf("\n")>-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n"))):u=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+u}function p(t,e,n){var r=0,i=t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return null==t}function v(t){return"number"==typeof t}function w(t){return"string"==typeof t}function m(t){return"symbol"==typeof t}function _(t){return void 0===t}function E(t){return B(t)&&"[object RegExp]"===A(t)}function B(t){return"object"==typeof t&&null!==t}function k(t){return B(t)&&"[object Date]"===A(t)}function I(t){return B(t)&&("[object Error]"===A(t)||t instanceof Error)}function x(t){return"function"==typeof t}function S(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function A(t){return Object.prototype.toString.call(t)}function T(t){return 10>t?"0"+t.toString(10):t.toString(10)}function L(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),C[t.getMonth()],e].join(" ")}function j(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var U=/%[sdj%]/g;n.format=function(t){if(!w(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(i(arguments[n]));return e.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(t).replace(U,function(t){if("%%"===t)return"%";if(n>=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return t}}),u=r[n];o>n;u=r[++n])s+=b(u)||!B(u)?" "+u:" "+i(u);return s},n.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(_(r.process))return function(){return n.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var O,P={};n.debuglog=function(t){if(_(O)&&(O=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!P[t])if(new RegExp("\\b"+t+"\\b","i").test(O)){var r=e.pid;P[t]=function(){var e=n.format.apply(n,arguments);console.error("%s %d: %s",t,r,e)}}else P[t]=function(){};return P[t]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=d,n.isBoolean=g,n.isNull=b,n.isNullOrUndefined=y,n.isNumber=v,n.isString=w,n.isSymbol=m,n.isUndefined=_,n.isRegExp=E,n.isObject=B,n.isDate=k,n.isError=I,n.isFunction=x,n.isPrimitive=S,n.isBuffer=t("./support/isBuffer");var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",L(),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!B(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":31,_process:30,inherits:29}],33:[function(t,e,n){"use strict";var r=t("./promise/promise").Promise,i=t("./promise/polyfill").polyfill;n.Promise=r,n.polyfill=i},{"./promise/polyfill":37,"./promise/promise":38}],34:[function(t,e,n){"use strict";function r(t){var e=this;if(!i(t))throw new TypeError("You must pass an array to all.");return new e(function(e,n){function r(t){return function(e){i(t,e)}}function i(t,n){u[t]=n,0===--a&&e(u)}var s,u=[],a=t.length;0===a&&e([]);for(var c=0;c<t.length;c++)s=t[c],s&&o(s.then)?s.then(r(c),n):i(c,s)})}var i=t("./utils").isArray,o=t("./utils").isFunction;n.all=r},{"./utils":42}],35:[function(t,e,n){(function(t,e){"use strict";function r(){return function(){t.nextTick(s)}}function i(){var t=0,e=new f(s),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function o(){return function(){l.setTimeout(s,1)}}function s(){for(var t=0;t<h.length;t++){var e=h[t],n=e[0],r=e[1];n(r)}h=[]}function u(t,e){var n=h.push([t,e]);1===n&&a()}var a,c="undefined"!=typeof window?window:{},f=c.MutationObserver||c.WebKitMutationObserver,l="undefined"!=typeof e?e:void 0===this?window:this,h=[];a="undefined"!=typeof t&&"[object process]"==={}.toString.call(t)?r():f?i():o(),n.asap=u}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:30}],36:[function(t,e,n){"use strict";function r(t,e){return 2!==arguments.length?i[t]:void(i[t]=e)}var i={instrument:!1};n.config=i,n.configure=r},{}],37:[function(t,e,n){(function(e){"use strict";function r(){var t;t="undefined"!=typeof e?e:"undefined"!=typeof window&&window.document?window:self;var n="Promise"in t&&"resolve"in t.Promise&&"reject"in t.Promise&&"all"in t.Promise&&"race"in t.Promise&&function(){var e;return new t.Promise(function(t){e=t}),o(e)}();n||(t.Promise=i)}var i=t("./promise").Promise,o=t("./utils").isFunction;n.polyfill=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./promise":38,"./utils":42}],38:[function(t,e,n){"use strict";function r(t){if(!b(t))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof r))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],i(t,this)}function i(t,e){function n(t){c(e,t)}function r(t){l(e,t)}try{t(n,r)}catch(i){r(i)}}function o(t,e,n,r){var i,o,s,u,f=b(n);if(f)try{i=n(r),s=!0}catch(h){u=!0,o=h}else i=r,s=!0;a(e,i)||(f&&s?c(e,i):u?l(e,o):t===k?c(e,i):t===I&&l(e,i))}function s(t,e,n,r){var i=t._subscribers,o=i.length;i[o]=e,i[o+k]=n,i[o+I]=r}function u(t,e){for(var n,r,i=t._subscribers,s=t._detail,u=0;u<i.length;u+=3)n=i[u],r=i[u+e],o(e,n,r,s);t._subscribers=null}function a(t,e){var n,r=null;try{if(t===e)throw new TypeError("A promises callback cannot return that same promise.");if(g(e)&&(r=e.then,b(r)))return r.call(e,function(r){return n?!0:(n=!0,void(e!==r?c(t,r):f(t,r)))},function(e){return n?!0:(n=!0,void l(t,e))}),!0}catch(i){return n?!0:(l(t,i),!0)}return!1}function c(t,e){t===e?f(t,e):a(t,e)||f(t,e)}function f(t,e){t._state===E&&(t._state=B,t._detail=e,d.async(h,t))}function l(t,e){t._state===E&&(t._state=B,t._detail=e,d.async(p,t))}function h(t){u(t,t._state=k)}function p(t){u(t,t._state=I)}var d=t("./config").config,g=(t("./config").configure,t("./utils").objectOrFunction),b=t("./utils").isFunction,y=(t("./utils").now,t("./all").all),v=t("./race").race,w=t("./resolve").resolve,m=t("./reject").reject,_=t("./asap").asap;d.async=_;var E=void 0,B=0,k=1,I=2;r.prototype={constructor:r,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(t,e){var n=this,r=new this.constructor(function(){});if(this._state){var i=arguments;d.async(function(){o(n._state,r,i[n._state-1],n._detail)})}else s(this,r,t,e);return r},"catch":function(t){return this.then(null,t)}},r.all=y,r.race=v,r.resolve=w,r.reject=m,n.Promise=r},{"./all":34,"./asap":35,"./config":36,"./race":39,"./reject":40,"./resolve":41,"./utils":42}],39:[function(t,e,n){"use strict";function r(t){var e=this;if(!i(t))throw new TypeError("You must pass an array to race.");return new e(function(e,n){for(var r,i=0;i<t.length;i++)r=t[i],r&&"function"==typeof r.then?r.then(e,n):e(r)})}var i=t("./utils").isArray;n.race=r},{"./utils":42}],40:[function(t,e,n){"use strict";function r(t){var e=this;return new e(function(e,n){n(t)})}n.reject=r},{}],41:[function(t,e,n){"use strict";function r(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=this;return new e(function(e){e(t)})}n.resolve=r},{}],42:[function(t,e,n){"use strict";function r(t){return i(t)||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}var s=Date.now||function(){return(new Date).getTime()};n.objectOrFunction=r,n.isFunction=i,n.isArray=o,n.now=s},{}],43:[function(e,n){(function(r){(function(){function i(t,e,n){var r=e&&n||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>i&&(e[r+i++]=b[t])});16>i;)e[r+i++]=0;return e}function o(t,e){var n=e||0,r=g;return r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]}function s(t,e,n){var r=e&&n||0,i=e||[];t=t||{};var s=null!=t.clockseq?t.clockseq:m,u=null!=t.msecs?t.msecs:(new Date).getTime(),a=null!=t.nsecs?t.nsecs:E+1,c=u-_+(a-E)/1e4;if(0>c&&null==t.clockseq&&(s=s+1&16383),(0>c||u>_)&&null==t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_=u,E=a,m=s,u+=122192928e5;var f=(1e4*(268435455&u)+a)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var l=u/4294967296*1e4&268435455;i[r++]=l>>>8&255,i[r++]=255&l,i[r++]=l>>>24&15|16,i[r++]=l>>>16&255,i[r++]=s>>>8|128,i[r++]=255&s;for(var h=t.node||w,p=0;6>p;p++)i[r+p]=h[p];return e?e:o(i)}function u(t,e,n){var r=e&&n||0;"string"==typeof t&&(e="binary"==t?new d(16):null,t=null),t=t||{};var i=t.random||(t.rng||a)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;16>s;s++)e[r+s]=i[s];return e||o(i)}var a,c=this;if("function"==typeof e)try{var f=e("crypto").randomBytes;a=f&&function(){return f(16)}}catch(l){}if(!a&&c.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);a=function(){return crypto.getRandomValues(h),h}}if(!a){var p=new Array(16);a=function(){for(var t,e=0;16>e;e++)0===(3&e)&&(t=4294967296*Math.random()),p[e]=t>>>((3&e)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,g=[],b={},y=0;256>y;y++)g[y]=(y+256).toString(16).substr(1),b[g[y]]=y;var v=a(),w=[1|v[0],v[1],v[2],v[3],v[4],v[5]],m=16383&(v[6]<<8|v[7]),_=0,E=0,B=u;if(B.v1=s,B.v4=u,B.parse=i,B.unparse=o,B.BufferClass=d,"function"==typeof t&&t.amd)t(function(){return B});else if("undefined"!=typeof n&&n.exports)n.exports=B;else{var k=c.uuid;B.noConflict=function(){return c.uuid=k,B},c.uuid=B}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:13,crypto:19}],44:[function(e,n,r){!function(e,i){"use strict";"object"==typeof r&&n?n.exports=i():"function"==typeof t&&t.amd?t(i):e.PubSub=i()}("object"==typeof window&&window||this,function(){"use strict";function t(t){var e;for(e in t)if(t.hasOwnProperty(e))return!0;return!1}function e(t){return function(){throw t}}function n(t,n,r){try{t(n,r)}catch(i){setTimeout(e(i),0)}}function r(t,e,n){t(e,n)}function i(t,e,i,o){var s,u=c[e],a=o?r:n;if(c.hasOwnProperty(e))for(s in u)u.hasOwnProperty(s)&&a(u[s],t,i)}function o(t,e,n){return function(){var r=String(t),o=r.lastIndexOf(".");for(i(t,t,e,n);-1!==o;)r=r.substr(0,o),o=r.lastIndexOf("."),i(t,r,e)}}function s(e){for(var n=String(e),r=Boolean(c.hasOwnProperty(n)&&t(c[n])),i=n.lastIndexOf(".");!r&&-1!==i;)n=n.substr(0,i),i=n.lastIndexOf("."),r=Boolean(c.hasOwnProperty(n)&&t(c[n]));return r}function u(t,e,n,r){var i=o(t,e,r),u=s(t);return u?(n===!0?i():setTimeout(i,0),!0):!1}var a={},c={},f=-1;return a.publish=function(t,e){return u(t,e,!1,a.immediateExceptions)},a.publishSync=function(t,e){return u(t,e,!0,a.immediateExceptions)},a.subscribe=function(t,e){if("function"!=typeof e)return!1;c.hasOwnProperty(t)||(c[t]={});var n="uid_"+String(++f);return c[t][n]=e,n},a.unsubscribe=function(t){var e,n,r,i="string"==typeof t,o=!1;for(e in c)if(c.hasOwnProperty(e)){if(n=c[e],i&&n[t]){delete n[t],o=t;break}if(!i)for(r in n)n.hasOwnProperty(r)&&n[r]===t&&(delete n[r],o=!0)}return o},a})},{}]},{},[1])(1)}); | ||
//# sourceMappingURL=./babble.min.map |
@@ -5,3 +5,3 @@ var babble = require('../index'); | ||
// initialize pubnub messaging | ||
var pubnub = babble.messagers.pubnub({ | ||
var pubnub = babble.messagebus.pubnub({ | ||
publish_key: 'demo', // REPLACE THIS WITH YOUR PUBNUB PUBLISH KEY | ||
@@ -8,0 +8,0 @@ subscribe_key: 'demo' // REPLACE THIS WITH YOUR PUBNUB SUBSCRIBE KEY |
@@ -5,2 +5,10 @@ # babble history | ||
## 2014-08-11, version 0.9.0 | ||
- Implemented `'default'` choice in `Decision`. | ||
- Some code simplifications. | ||
- Renamed `messagers` to `messagebus`. | ||
- Documented message bus interface and protocol. | ||
## 2014-08-07, version 0.8.0 | ||
@@ -7,0 +15,0 @@ |
@@ -56,3 +56,2 @@ 'use strict'; | ||
* Create a decision block and chain it to the current block. | ||
* Returns the first block in the chain. | ||
* | ||
@@ -82,2 +81,6 @@ * Syntax: | ||
* | ||
* There is one special id for choices: 'default'. This id is called when either | ||
* the decision function returns an id which does not match any of the available | ||
* choices. | ||
* | ||
* @param {Function | Object} arg1 Can be {function} decision or {Object} choices | ||
@@ -175,4 +178,4 @@ * @param {Object} [arg2] choices | ||
// export messaging interfaces | ||
exports.messagers = require('./messagers'); | ||
// export messagebus interfaces | ||
exports.messagebus = require('./messagebus'); | ||
@@ -179,0 +182,0 @@ /** |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var messagers = require('./messagers'); | ||
var messagebus = require('./messagebus'); | ||
var Conversation = require('./Conversation'); | ||
@@ -38,37 +38,37 @@ var Block = require('./block/Block'); | ||
/** | ||
* Connect to a messaging system | ||
* @param {{connect: function, disconnect: function, send: function}} [messager] | ||
* Connect to a message bus | ||
* @param {{connect: function, disconnect: function, send: function}} [bus] | ||
* A messaging interface. Must have the following functions: | ||
* - connect(params: {id: string, | ||
* message: function, connect: function}) : string | ||
* message: function, callback: function}) : string | ||
* must return a token to disconnects again. | ||
* parameter connect is optional. | ||
* parameter callback is optional. | ||
* - disconnect(token: string) | ||
* disconnect from a messager. | ||
* disconnect from a message bus. | ||
* - send(id: string, message: *) | ||
* send a message | ||
* A number of interfaces is provided under babble.messagers. | ||
* Default interface is babble.messagers['default'] | ||
* A number of interfaces is provided under babble.messagebus. | ||
* Default interface is babble.messagebus['default'] | ||
* @return {Promise.<Babbler>} Returns a Promise which resolves when the | ||
* babbler is connected. | ||
*/ | ||
Babbler.prototype.connect = function (messager) { | ||
Babbler.prototype.connect = function (bus) { | ||
// disconnect (in case we are already connected) | ||
this.disconnect(); | ||
if (!messager) { | ||
messager = messagers['default'](); | ||
if (!bus) { | ||
bus = messagebus['default'](); | ||
} | ||
// validate the messagers fucntions | ||
if (typeof messager.connect !== 'function') { | ||
throw new Error('messager must contain a function ' + | ||
// validate the message bus functions | ||
if (typeof bus.connect !== 'function') { | ||
throw new Error('message bus must contain a function ' + | ||
'connect(params: {id: string, callback: function}) : string'); | ||
} | ||
if (typeof messager.disconnect !== 'function') { | ||
throw new Error('messager must contain a function ' + | ||
if (typeof bus.disconnect !== 'function') { | ||
throw new Error('message bus must contain a function ' + | ||
'disconnect(token: string)'); | ||
} | ||
if (typeof messager.send !== 'function') { | ||
throw new Error('messager must contain a function ' + | ||
if (typeof bus.send !== 'function') { | ||
throw new Error('message bus must contain a function ' + | ||
'send(params: {id: string, message: *})'); | ||
@@ -85,6 +85,6 @@ } | ||
var token = messager.connect({ | ||
var token = bus.connect({ | ||
id: this.id, | ||
message: this._onMessage.bind(this), | ||
connect: _resolve | ||
callback: _resolve | ||
}); | ||
@@ -94,5 +94,5 @@ | ||
this.disconnect = function () { | ||
messager.disconnect(token); | ||
bus.disconnect(token); | ||
}; | ||
this.send = messager.send; | ||
this.send = bus.send; | ||
@@ -99,0 +99,0 @@ // return a promise |
@@ -37,2 +37,6 @@ 'use strict'; | ||
* | ||
* There is one special id for choices: 'default'. This id is called when either | ||
* the decision function returns an id which does not match any of the available | ||
* choices. | ||
* | ||
* @param arg1 | ||
@@ -87,2 +91,3 @@ * @param arg2 | ||
Decision.prototype = Object.create(Block.prototype); | ||
Decision.prototype.constructor = Decision; | ||
@@ -104,2 +109,7 @@ /** | ||
if (!next) { | ||
// there is no match, fall back on the default choice | ||
next = me.choices['default']; | ||
} | ||
if (!next) { | ||
throw new Error('Block with id "' + id + '" not found'); | ||
@@ -116,4 +126,6 @@ } | ||
/** | ||
* Add a choice to the decision block | ||
* @param {String} id | ||
* Add a choice to the decision block. | ||
* The choice can be a new chain of blocks. The first block of the chain | ||
* will be triggered when the this id comes out of the decision function. | ||
* @param {String | 'default'} id | ||
* @param {Block} block | ||
@@ -135,4 +147,10 @@ * @return {Decision} self | ||
this.choices[id] = block; | ||
// find the first block of the chain | ||
var first = block; | ||
while (first && first.previous) { | ||
first = first.previous; | ||
} | ||
this.choices[id] = first; | ||
return this; | ||
@@ -168,2 +186,6 @@ }; | ||
* | ||
* There is one special id for choices: 'default'. This id is called when either | ||
* the decision function returns an id which does not match any of the available | ||
* choices. | ||
* | ||
* @param {Function | Object} arg1 Can be {function} decision or {Object} choices | ||
@@ -170,0 +192,0 @@ * @param {Object} [arg2] choices |
@@ -130,3 +130,3 @@ 'use strict'; | ||
* @param {Block} [falseBlock] | ||
* @returns {Block} | ||
* @returns {Block} Returns the created IIf block | ||
*/ | ||
@@ -133,0 +133,0 @@ Block.prototype.iif = function (condition, trueBlock, falseBlock) { |
@@ -45,3 +45,2 @@ 'use strict'; | ||
* Create a Listen block and chain it to the current block | ||
* Returns the first block in the chain. | ||
* | ||
@@ -53,3 +52,3 @@ * Optionally a callback function can be provided, which is equivalent of | ||
* Must return a result | ||
* @return {Block} first First block in the chain | ||
* @return {Block} Returns the appended block | ||
*/ | ||
@@ -56,0 +55,0 @@ Block.prototype.listen = function (callback) { |
@@ -69,3 +69,2 @@ 'use strict'; | ||
* Create a Tell block and chain it to the current block | ||
* Returns the first block in the chain. | ||
* @param {* | Function} [message] A static message or callback function | ||
@@ -79,3 +78,3 @@ * returning a message dynamically. | ||
* conversation. | ||
* @return {Block} first First block in the chain | ||
* @return {Block} Returns the appended block | ||
*/ | ||
@@ -98,3 +97,3 @@ Block.prototype.tell = function (message) { | ||
* of doing `listen().then(callback)` | ||
* @return {Block} block Last block in the created control flow | ||
* @return {Block} Returns the appended block | ||
*/ | ||
@@ -101,0 +100,0 @@ Block.prototype.ask = function (message, callback) { |
@@ -53,4 +53,3 @@ 'use strict'; | ||
/** | ||
* Chain a block to the current block. The new block is appended to the *last* | ||
* block in the chain, and the function returns the *first* block in the chain. | ||
* Chain a block to the current block. | ||
* | ||
@@ -62,4 +61,4 @@ * When a function is provided, a Then block will be generated which | ||
* | ||
* @param {Block | function} next | ||
* @return {Block} first First block in the chain | ||
* @param {Block | function} next A callback function or Block. | ||
* @return {Block} Returns the appended block | ||
*/ | ||
@@ -76,22 +75,10 @@ Block.prototype.then = function (next) { | ||
// find the last block in the chain | ||
var last = this; | ||
while (last.next) { | ||
last = last.next; | ||
} | ||
// find the first block in the chain. | ||
var first = this; | ||
while (first.previous) { | ||
first = first.previous; | ||
} | ||
// append after the last block | ||
next.previous = this; | ||
last.next = next; | ||
this.next = next; | ||
// return the first block | ||
return first; | ||
// return the appended block | ||
return next; | ||
}; | ||
module.exports = Then; |
{ | ||
"name": "babble", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Dynamic communication flows between message based actors.", | ||
@@ -5,0 +5,0 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)", |
117
README.md
@@ -13,6 +13,6 @@ # Babble | ||
Babble uses customizable messaging to communicate between actors. It comes with | ||
built in support to communicate locally, and has as support for | ||
[pubnub](http://www.pubnub.com/) to connect actors distributed over multiple | ||
devices. | ||
Babblers communicate with each other via a message bus. Babble comes with | ||
built in support for a local message bus, and [pubnub](http://www.pubnub.com/) | ||
to connect actors distributed over multiple devices. Its easy to add support | ||
for other message buses. | ||
@@ -240,8 +240,12 @@ Babble runs in node.js and in the browser. | ||
The function `decision` can also return a Promise resolving with an id for the | ||
next block. | ||
If `decision` is not provided, the next block will be mapped directly from the | ||
`response`. Parameter `choices` is a map with the possible next blocks in the | ||
flow. The next block is selected by the id returned by the `decision` function. | ||
next block. When `decision` is not provided, the next block will be mapped | ||
directly from the `response`, which should be a string in that case. | ||
Parameter `choices` is a map with the possible next blocks in the flow. | ||
The next block is selected by the id returned by the `decision` function. | ||
The returned block is used as next block in the control flow. | ||
When there is no matching choice, the choice `'default'` will be selected | ||
when available. | ||
- `babble.iif(condition: function | RegExp | * [, trueBlock : Block] [, falseBlock : Block]) : Block` | ||
@@ -302,3 +306,3 @@ Create a control flow starting with an `IIf` block. | ||
message bus. The connection can replaced with another message bus using the | ||
function `Babbler.connect(messager)`. | ||
function `Babbler.connect(bus)`. | ||
@@ -311,11 +315,11 @@ A babbler has the following functions: | ||
- `connect([messager: Object]) : Promise.<Babbler>` | ||
Connect to a messaging system. Babble comes with interfaces to support various | ||
messaging systems: `pubnub`, `pubsub-js`, and `default`. These interfaces are | ||
available in the `babble.messagers` namespace. If parameter `messager` is not | ||
provided, babble uses the `default` messaging system, which works locally. | ||
A messaging system can be specified like: | ||
- `connect([bus: Object]) : Promise.<Babbler>` | ||
Connect to a message bus. Babble comes with interfaces to support various | ||
message buses: `pubnub`, `pubsub-js`, and `default`. These interfaces are | ||
available in the `babble.messagebus` namespace. If parameter `bus` is | ||
not provided, babble uses the `default` message bus, which works locally. | ||
A specific message bus interface can be specified like: | ||
```js | ||
babbler.connect(babble.messagers['pubnub']) | ||
babbler.connect(babble.messagebus['pubnub']) | ||
.then(function (babbler) { | ||
@@ -328,5 +332,8 @@ // connected | ||
when the connection is ready. | ||
See section [Message bus](#message_bus) for documentation on the interface | ||
of a message bus. | ||
- `disconnect()` | ||
Disconnect from the connected messaging system. | ||
Disconnect from the connected message bus. | ||
@@ -368,11 +375,9 @@ - `listen([condition: Function | RegExp | * [, callback: Function]]) : Block` | ||
Parameter `message` can be a callback function or an object or value. | ||
Returns the first block in the chain. | ||
- `decide([decision: function, ] choices: Object<String, Block>) : Block` | ||
Append a `Decision` block to the control flow. Returns the first block in the | ||
chain. | ||
Append a `Decision` block to the control flow. | ||
- `iif(condition: function | RegExp | * [, trueBlock : Block] [, falseBlock : Block]) : Block` | ||
Append an `IIf` block to the control flow. Returns the first block in the | ||
chain. When the condition evaluates `true`, `trueBlock` is executed. | ||
Append an `IIf` block to the control flow. | ||
When the condition evaluates `true`, `trueBlock` is executed. | ||
If no `trueBlock` is provided, the next block in the chain will be executed. | ||
@@ -382,9 +387,8 @@ When the condition evaluates `true`, `falseBlock` is executed. | ||
- `listen([callback: Function]) : Block` | ||
Append a `Listen` block to the control flow. Returns the first block in the | ||
chain. Providing a callback function is equivalent of doing | ||
`listen().then(callback)`. | ||
Append a `Listen` block to the control flow. Providing a callback function is | ||
equivalent of doing `listen().then(callback)`. | ||
- `tell(message: * | Function) : Block` | ||
Append a `Tell` block to the control flow. Parameter `message` can be callback | ||
function or an object or value. Returns the first block in the chain. | ||
function or an object or value. | ||
@@ -394,5 +398,60 @@ - `then(block : Block | function) : Block` | ||
provided, it is wrapped into a `Then` block and added to the chain. | ||
Returns the first block in the chain. | ||
## Message bus | ||
Babblers talk to each other via a message bus. This can be any message bus | ||
implementation. Babble comes with support for two message buses: a local | ||
message bus and [pubnub](http://www.pubnub.com/). | ||
### Interface | ||
The function `Babbler.connect(bus)` accepts a message bus interface. This | ||
interface must be an Object with the following functions: | ||
- `connect(params: Object) : string` | ||
The function `connect` will be called by the Babbler with an object having | ||
the following parameters: | ||
- `id` the id of the babbler itself. | ||
- `message` the callback function to deliver messages for this babbler. | ||
This function must be invoked as `message(msg : *)`. | ||
- `callback` an optional callback function which is invoked when the | ||
connection is established. | ||
The `connect` function must return a token which can be used to disconnect | ||
again. | ||
- `disconnect(token: string)` | ||
Disconnect from a message bus. `token` is the token returned by the `connect` | ||
function. | ||
- `send(id: string, message: *)` | ||
Send a message to a babbler. | ||
### Protocol | ||
The messages sent between babblers are JSON objects having the following properties: | ||
- `id: string` | ||
A unique identifier for the conversation, typically a uuid. | ||
This id is generated by the initiator of a conversation, and is sent with | ||
every message between the two babblers during the conversation. | ||
- `from: string` | ||
The id of the sender. | ||
- `to: string` | ||
The id of the receiver. | ||
- `message: *` | ||
The message contents. This is a (serializable) JSON object (often a string). | ||
Example: | ||
```json | ||
{ | ||
"id": "547d1840-2142-11e4-8c21-0800200c9a66", | ||
"from": "babbler1", | ||
"to": "babbler2", | ||
"message": "Hello babbler!" | ||
} | ||
``` | ||
## Build | ||
@@ -424,8 +483,6 @@ | ||
# To do | ||
# Roadmap | ||
- Implement error handling and timeout conditions. | ||
- Implement support for returning promises from callbacks, allowing async | ||
callback functions. | ||
- Store message history in the context. | ||
- Implement conversations with multiple peers at the same time. |
@@ -11,3 +11,3 @@ var assert = require('assert'); | ||
describe('babbler', function() { | ||
describe('babble', function() { | ||
@@ -30,4 +30,4 @@ it('should create a babbler', function() { | ||
var block = babble.ask('what is your name'); | ||
assert.ok(block instanceof Tell); | ||
assert.ok(block.next instanceof Listen); | ||
assert.ok(block instanceof Listen); | ||
assert.ok(block.previous instanceof Tell); | ||
}); | ||
@@ -34,0 +34,0 @@ |
@@ -59,20 +59,36 @@ var assert = require('assert'); | ||
it('should throw an error when decision function returns a non existing id', function () { | ||
assert.throws(function () { | ||
Decision(function () { | ||
return 'non existing id' | ||
}, { | ||
yes: new Block(), | ||
no: new Block() | ||
}) | ||
}, Error); | ||
it('should throw an error when no matching choice', function () { | ||
var decision = new Decision(function () { | ||
return 'non existing id' | ||
}, { | ||
yes: new Block(), | ||
no: new Block() | ||
}); | ||
var conversation = new Conversation(); | ||
return decision.execute(conversation) | ||
.then(function (next) { | ||
assert.ok(false, 'should not succeed') | ||
}) | ||
.catch(function (err) { | ||
assert.equal(err.toString(), 'Error: Block with id "non existing id" not found'); | ||
}) | ||
}); | ||
it('should throw an error when decision function doesn\'t return a string', function () { | ||
assert.throws(function () { | ||
var decision = new Decision(function () { | ||
return 123 | ||
}, {}); | ||
decision.execute(); | ||
}, TypeError); | ||
it('should fallback to default when no matching choice', function () { | ||
var def = new Block(); | ||
var decision = new Decision(function () { | ||
return 'non existing id' | ||
}, { | ||
yes: new Block(), | ||
no: new Block(), | ||
'default': def | ||
}); | ||
var conversation = new Conversation(); | ||
return decision.execute(conversation) | ||
.then(function (next) { | ||
assert.strictEqual(next.result, undefined); | ||
assert.strictEqual(next.block, def); | ||
}); | ||
}); | ||
@@ -79,0 +95,0 @@ |
@@ -73,7 +73,12 @@ var assert = require('assert'); | ||
}; | ||
var listen = block.listen(callback); | ||
var b = block.listen(callback); | ||
assert(block.next instanceof Listen); | ||
assert(listen.next.next instanceof Then); | ||
var listen = block.next; | ||
var then = listen.next; | ||
assert.strictEqual(b, then); | ||
assert(listen instanceof Listen); | ||
assert(then instanceof Then); | ||
assert.strictEqual(then.next, undefined); // TODO: should be null | ||
var conversation = new Conversation(); | ||
@@ -80,0 +85,0 @@ conversation.deliver({message: 'foo'}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
570311
7749
480