Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babble

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babble - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

examples/say_hi.js

4

dist/babble.min.js

@@ -1,3 +0,3 @@

!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.babble=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var s=e[a]={exports:{}};t[a][0].call(s.exports,function(n){var e=t[a][1][n];return i(e?e:n)},s,s.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n){n.exports=t("./lib/babble")},{"./lib/babble":3}],2:[function(t,n){function e(t){if(!(this instanceof e))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={}}var r=t("node-uuid"),i=t("./pubsub"),o=(t("./block/Block"),t("./block/Action"),t("./block/Reply")),a=t("./block/Listen");e.prototype.subscribe=function(t,n){if("function"==typeof t&&(n=t,t=null),t||(t=i["default"]()),"function"!=typeof t.subscribe)throw new Error("pubsub must contain a function subscribe(params: {id: string, callback: function}) : function");if("function"!=typeof t.publish)throw new Error("pubsub must contain a function publish(params: {id: string, message: *})");var e=this,r=t.subscribe({id:this.id,message:function(t){var n,r;n=e.conversations[t.id],n?e._run(n,t.message):(r=e.listeners[t.message],r&&(n={id:t.id,peer:t.from,next:r,context:{from:t.from}},e._run(n,t.data)))},connect:n});if("function"!=typeof r)throw new Error("pubsub.subscribe must return a function to unsubscribe");return this.unsubscribe=r,this.publish=t.publish,this},e.prototype.unsubscribe=function(){throw new Error("Cannot unsubscribe: not subscribed")},e.prototype.publish=function(){throw new Error("Cannot publish: not subscribed")},e.prototype.listen=function u(t,n){if("string"!=typeof t)throw new TypeError("Parameter message must be a string");var u=new a(n);return this.listeners[t]=u,u},e.prototype.tell=function(t,n,e){this.publish(t,{from:this.id,to:t,message:n,data:e})},e.prototype.ask=function(t,n,e,i){var o=r.v4();"function"==typeof e&&(i=e,e=void 0);var u=new a(i);return this.conversations[o]={id:o,peer:t,next:u,context:{from:t}},this.publish(t,{id:o,from:this.id,to:t,message:n,data:e}),u},e.prototype._run=function(t,n){delete this.conversations[t.id];var e=t.next;do{var r=e.execute(n,t.context);e instanceof o&&this.publish(t.peer,{id:t.id,from:this.id,to:t.peer,message:r.result}),n=r.result,e=r.block,e instanceof a&&(t.next=e,this.conversations[t.id]=t)}while(e&&!(e instanceof a))},n.exports=e},{"./block/Action":4,"./block/Block":5,"./block/Listen":7,"./block/Reply":8,"./pubsub":9,"node-uuid":20}],3:[function(t,n,e){var r=t("./Babbler"),i=t("./block/Reply"),o=t("./block/Action"),a=t("./block/Decision");e.babbler=function(t){return new r(t)},e.reply=function(t){return new i(t)},e.decide=function(t,n){return new a(t,n)},e.run=function(t){return new o(t)},e.Babbler=r,e.block={Block:t("./block/Block"),Action:t("./block/Action"),Decision:t("./block/Decision"),Listen:t("./block/Listen"),Reply:t("./block/Reply")},e.pubsub=t("./pubsub")},{"./Babbler":2,"./block/Action":4,"./block/Block":5,"./block/Decision":6,"./block/Listen":7,"./block/Reply":8,"./pubsub":9}],4:[function(t,n){function e(t){if(!(this instanceof e))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("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.run=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],5:[function(t,n){function e(){this.next=null,this.previous=null}e.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.prototype.then=function(t){if(!(t instanceof e))throw new TypeError("Parameter next must be a Block");for(var n=this;n.next;)n=n.next;for(var r=this;r.previous;)r=r.previous;return t.previous=this,n.next=t,r},n.exports=e},{}],6:[function(t,n){function e(t,n){var r,i;if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,i=n):(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("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.decision(t,n);if("string"!=typeof e)throw new TypeError("Decision function must return a string containing the id of the next block");var r=this.choices[e];if(!r)throw new Error('Block with id "'+e+'" not found');return{result:t,block:r}},e.prototype.addChoice=function(t,n){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(n instanceof r))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]=n,this},r.prototype.decide=function(t,n){var r=new e(t,n);return this.then(r)},n.exports=e},{"./Block":5}],7:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.listen=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],8:[function(t,n){function e(t){if(!(this instanceof e))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("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.reply=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],9:[function(t,n,e){e["pubsub-js"]=function(){var n=t("pubsub-js");return{subscribe:function(t){var e=n.subscribe(t.id,function(n,e){t.message(e)});return"function"==typeof t.connect&&t.connect(),function(){n.unsubscribe(e)}},publish:function(t,e){n.publish(t,e)}}},e.pubnub=function(n){var e;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");e=window.PUBNUB}else e=t("pubnub");var r=e.init(n);return{subscribe:function(t){return r.subscribe({channel:t.id,message:t.message,connect:t.connect}),function(){r.unsubscribe(t.id)}},publish:function(t,n){r.publish({channel:t,message:n})}}},e["default"]=e["pubsub-js"]},{pubnub:"NaMlu/","pubsub-js":21}],10:[function(t,n){function e(t,n){if(t.length%a!==0){var e=t.length+(a-t.length%a);t=o.concat([t,u],e)}for(var r=[],i=n?t.readInt32BE:t.readInt32LE,f=0;f<t.length;f+=a)r.push(i.call(t,f));return r}function r(t,n,e){for(var r=new o(n),i=e?r.writeInt32BE:r.writeInt32LE,a=0;a<t.length;a++)i.call(r,t[a],4*a,!0);return r}function i(t,n,i,a){o.isBuffer(t)||(t=new o(t));var u=n(e(t,a),t.length*f);return r(u,i,a)}var o=t("buffer").Buffer,a=4,u=new o(a);u.fill(0);var f=8;n.exports={hash:i}},{buffer:17}],11:[function(t,n,e){function r(t,n,e){u.isBuffer(n)||(n=new u(n)),u.isBuffer(e)||(e=new u(e)),n.length>p?n=t(n):n.length<p&&(n=u.concat([n,d],p));for(var r=new u(p),i=new u(p),o=0;p>o;o++)r[o]=54^n[o],i[o]=92^n[o];var a=t(u.concat([r,e]));return t(u.concat([i,a]))}function i(t,n){t=t||"sha1";var e=h[t],i=[],a=0;return e||o("algorithm:",t,"is not yet supported"),{update:function(t){return u.isBuffer(t)||(t=new u(t)),i.push(t),a+=t.length,this},digest:function(t){var o=u.concat(i),a=n?r(e,n,o):e(o);return i=null,t?a.toString(t):a}}}function o(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function a(t,n){for(var e in t)n(t[e],e)}var u=t("buffer").Buffer,f=t("./sha"),s=t("./sha256"),c=t("./rng"),l=t("./md5"),h={sha1:f,sha256:s,md5:l},p=64,d=new u(p);d.fill(0),e.createHash=function(t){return i(t)},e.createHmac=function(t,n){return i(t,n)},e.randomBytes=function(t,n){if(!n||!n.call)return new u(c(t));try{n.call(this,void 0,new u(c(t)))}catch(e){n(e)}},a(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(t){e[t]=function(){o("sorry,",t,"is not implemented yet")}})},{"./md5":12,"./rng":13,"./sha":14,"./sha256":15,buffer:17}],12:[function(t,n){function e(t,n){t[n>>5]|=128<<n%32,t[(n+64>>>9<<4)+14]=n;for(var e=1732584193,r=-271733879,s=-1732584194,c=271733878,l=0;l<t.length;l+=16){var h=e,p=r,d=s,g=c;e=i(e,r,s,c,t[l+0],7,-680876936),c=i(c,e,r,s,t[l+1],12,-389564586),s=i(s,c,e,r,t[l+2],17,606105819),r=i(r,s,c,e,t[l+3],22,-1044525330),e=i(e,r,s,c,t[l+4],7,-176418897),c=i(c,e,r,s,t[l+5],12,1200080426),s=i(s,c,e,r,t[l+6],17,-1473231341),r=i(r,s,c,e,t[l+7],22,-45705983),e=i(e,r,s,c,t[l+8],7,1770035416),c=i(c,e,r,s,t[l+9],12,-1958414417),s=i(s,c,e,r,t[l+10],17,-42063),r=i(r,s,c,e,t[l+11],22,-1990404162),e=i(e,r,s,c,t[l+12],7,1804603682),c=i(c,e,r,s,t[l+13],12,-40341101),s=i(s,c,e,r,t[l+14],17,-1502002290),r=i(r,s,c,e,t[l+15],22,1236535329),e=o(e,r,s,c,t[l+1],5,-165796510),c=o(c,e,r,s,t[l+6],9,-1069501632),s=o(s,c,e,r,t[l+11],14,643717713),r=o(r,s,c,e,t[l+0],20,-373897302),e=o(e,r,s,c,t[l+5],5,-701558691),c=o(c,e,r,s,t[l+10],9,38016083),s=o(s,c,e,r,t[l+15],14,-660478335),r=o(r,s,c,e,t[l+4],20,-405537848),e=o(e,r,s,c,t[l+9],5,568446438),c=o(c,e,r,s,t[l+14],9,-1019803690),s=o(s,c,e,r,t[l+3],14,-187363961),r=o(r,s,c,e,t[l+8],20,1163531501),e=o(e,r,s,c,t[l+13],5,-1444681467),c=o(c,e,r,s,t[l+2],9,-51403784),s=o(s,c,e,r,t[l+7],14,1735328473),r=o(r,s,c,e,t[l+12],20,-1926607734),e=a(e,r,s,c,t[l+5],4,-378558),c=a(c,e,r,s,t[l+8],11,-2022574463),s=a(s,c,e,r,t[l+11],16,1839030562),r=a(r,s,c,e,t[l+14],23,-35309556),e=a(e,r,s,c,t[l+1],4,-1530992060),c=a(c,e,r,s,t[l+4],11,1272893353),s=a(s,c,e,r,t[l+7],16,-155497632),r=a(r,s,c,e,t[l+10],23,-1094730640),e=a(e,r,s,c,t[l+13],4,681279174),c=a(c,e,r,s,t[l+0],11,-358537222),s=a(s,c,e,r,t[l+3],16,-722521979),r=a(r,s,c,e,t[l+6],23,76029189),e=a(e,r,s,c,t[l+9],4,-640364487),c=a(c,e,r,s,t[l+12],11,-421815835),s=a(s,c,e,r,t[l+15],16,530742520),r=a(r,s,c,e,t[l+2],23,-995338651),e=u(e,r,s,c,t[l+0],6,-198630844),c=u(c,e,r,s,t[l+7],10,1126891415),s=u(s,c,e,r,t[l+14],15,-1416354905),r=u(r,s,c,e,t[l+5],21,-57434055),e=u(e,r,s,c,t[l+12],6,1700485571),c=u(c,e,r,s,t[l+3],10,-1894986606),s=u(s,c,e,r,t[l+10],15,-1051523),r=u(r,s,c,e,t[l+1],21,-2054922799),e=u(e,r,s,c,t[l+8],6,1873313359),c=u(c,e,r,s,t[l+15],10,-30611744),s=u(s,c,e,r,t[l+6],15,-1560198380),r=u(r,s,c,e,t[l+13],21,1309151649),e=u(e,r,s,c,t[l+4],6,-145523070),c=u(c,e,r,s,t[l+11],10,-1120210379),s=u(s,c,e,r,t[l+2],15,718787259),r=u(r,s,c,e,t[l+9],21,-343485551),e=f(e,h),r=f(r,p),s=f(s,d),c=f(c,g)}return Array(e,r,s,c)}function r(t,n,e,r,i,o){return f(s(f(f(n,t),f(r,o)),i),e)}function i(t,n,e,i,o,a,u){return r(n&e|~n&i,t,n,o,a,u)}function o(t,n,e,i,o,a,u){return r(n&i|e&~i,t,n,o,a,u)}function a(t,n,e,i,o,a,u){return r(n^e^i,t,n,o,a,u)}function u(t,n,e,i,o,a,u){return r(e^(n|~i),t,n,o,a,u)}function f(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function s(t,n){return t<<n|t>>>32-n}var c=t("./helpers");n.exports=function(t){return c.hash(t,e,16)}},{"./helpers":10}],13:[function(t,n){!function(){var t,e,r=this;t=function(t){for(var n,n,e=new Array(t),r=0;t>r;r++)0==(3&r)&&(n=4294967296*Math.random()),e[r]=n>>>((3&r)<<3)&255;return e},r.crypto&&crypto.getRandomValues&&(e=function(t){var n=new Uint8Array(t);return crypto.getRandomValues(n),n}),n.exports=e||t}()},{}],14:[function(t,n){function e(t,n){t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var e=Array(80),u=1732584193,f=-271733879,s=-1732584194,c=271733878,l=-1009589776,h=0;h<t.length;h+=16){for(var p=u,d=f,g=s,y=c,w=l,b=0;80>b;b++){e[b]=16>b?t[h+b]:a(e[b-3]^e[b-8]^e[b-14]^e[b-16],1);var v=o(o(a(u,5),r(b,f,s,c)),o(o(l,e[b]),i(b)));l=c,c=s,s=a(f,30),f=u,u=v}u=o(u,p),f=o(f,d),s=o(s,g),c=o(c,y),l=o(l,w)}return Array(u,f,s,c,l)}function r(t,n,e,r){return 20>t?n&e|~n&r:40>t?n^e^r:60>t?n&e|n&r|e&r:n^e^r}function i(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function o(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function a(t,n){return t<<n|t>>>32-n}var u=t("./helpers");n.exports=function(t){return u.hash(t,e,20,!0)}},{"./helpers":10}],15:[function(t,n){var e=t("./helpers"),r=function(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e},i=function(t,n){return t>>>n|t<<32-n},o=function(t,n){return t>>>n},a=function(t,n,e){return t&n^~t&e},u=function(t,n,e){return t&n^t&e^n&e},f=function(t){return i(t,2)^i(t,13)^i(t,22)},s=function(t){return i(t,6)^i(t,11)^i(t,25)},c=function(t){return i(t,7)^i(t,18)^o(t,3)},l=function(t){return i(t,17)^i(t,19)^o(t,10)},h=function(t,n){var e,i,o,h,p,d,g,y,w,b,v,m,E=new Array(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),I=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),B=new Array(64);t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var w=0;w<t.length;w+=16){e=I[0],i=I[1],o=I[2],h=I[3],p=I[4],d=I[5],g=I[6],y=I[7];for(var b=0;64>b;b++)B[b]=16>b?t[b+w]:r(r(r(l(B[b-2]),B[b-7]),c(B[b-15])),B[b-16]),v=r(r(r(r(y,s(p)),a(p,d,g)),E[b]),B[b]),m=r(f(e),u(e,i,o)),y=g,g=d,d=p,p=r(h,v),h=o,o=i,i=e,e=r(v,m);I[0]=r(e,I[0]),I[1]=r(i,I[1]),I[2]=r(o,I[2]),I[3]=r(h,I[3]),I[4]=r(p,I[4]),I[5]=r(d,I[5]),I[6]=r(g,I[6]),I[7]=r(y,I[7])}return I};n.exports=function(t){return e.hash(t,h,32,!0)}},{"./helpers":10}],16:[function(t,n){t=function e(n,r,i){function o(u,f){if(!r[u]){if(!n[u]){var s="function"==typeof t&&t;if(!f&&s)return s(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=r[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return o(e?e:t)},c,c.exports,e,n,r,i)}return r[u].exports}for(var a="function"==typeof t&&t,u=0;u<i.length;u++)o(i[u]);return o}({PcZj9L:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;Y?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!Y&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);if(isNaN(f))throw new Error("Invalid hex string");t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=O(D(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=O(N(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=O(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?J.fromByteArray(t):J.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(W("boolean"==typeof e,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+1)return t._dataview.getUint16(n,e);var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getUint16(0,e)}var a;return e?(a=t[n],i>n+1&&(a|=t[n+1]<<8)):(a=t[n]<<8,i>n+1&&(a|=t[n+1])),a}}function g(t,n,e,r){r||(W("boolean"==typeof e,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+3)return t._dataview.getUint32(n,e);for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getUint32(0,e)}var u;return e?(i>n+2&&(u=t[n+2]<<16),i>n+1&&(u|=t[n+1]<<8),u|=t[n],i>n+3&&(u+=t[n+3]<<24>>>0)):(i>n+1&&(u=t[n+1]<<16),i>n+2&&(u|=t[n+2]<<8),i>n+3&&(u|=t[n+3]),u+=t[n]<<24>>>0),u}}function y(t,n,e,r){r||(W("boolean"==typeof e,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+1===i){var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getInt16(0,e)}return t._dataview.getInt16(n,e)}var a=d(t,n,e,!0),u=32768&a;return u?-1*(65535-a+1):a}}function w(t,n,e,r){r||(W("boolean"==typeof e,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+3>=i){for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getInt32(0,e)}return t._dataview.getInt32(n,e)}var u=g(t,n,e,!0),f=2147483648&u;return f?-1*(4294967295-u+1):u}}function b(t,n,e,r){return r||(W("boolean"==typeof e,"missing or invalid endian"),W(n+3<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat32(n,e):X.read(t,n,e,23,4)}function v(t,n,e,r){return r||(W("boolean"==typeof e,"missing or invalid endian"),W(n+7<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat64(n,e):X.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+1<t.length,"trying to write beyond buffer length"),V(n,65535));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setUint16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setUint16(e,n,r);else for(var u=0,f=Math.min(o-e,2);f>u;u++)t[e+u]=(n&255<<8*(r?u:1-u))>>>8*(r?u:1-u)}function E(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+3<t.length,"trying to write beyond buffer length"),V(n,4294967295));var o=t.length;if(!(e>=o)){var a;if(Y)if(e+3>=o){var u=new DataView(new ArrayBuffer(4));for(u.setUint32(0,n,r),a=0;o>a+e;a++)t[a+e]=u.getUint8(a)}else t._dataview.setUint32(e,n,r);else for(a=0,j=Math.min(o-e,4);j>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}}function I(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+1<t.length,"Trying to write beyond buffer length"),R(n,32767,-32768));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setInt16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setInt16(e,n,r);else n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i)}function B(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+3<t.length,"Trying to write beyond buffer length"),R(n,2147483647,-2147483648));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setInt32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setInt32(e,n,r);else n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i)}function A(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+3<t.length,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setFloat32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat32(e,n,r);else X.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(W(void 0!==n&&null!==n,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(e+7<t.length,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(e>=o))if(Y)if(e+7>=o){var a=new DataView(new ArrayBuffer(8));a.setFloat64(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat64(e,n,r);else X.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=H.write,t.toString=H.toString,t.toLocaleString=H.toString,t.toJSON=H.toJSON,t.copy=H.copy,t.slice=H.slice,t.readUInt8=H.readUInt8,t.readUInt16LE=H.readUInt16LE,t.readUInt16BE=H.readUInt16BE,t.readUInt32LE=H.readUInt32LE,t.readUInt32BE=H.readUInt32BE,t.readInt8=H.readInt8,t.readInt16LE=H.readInt16LE,t.readInt16BE=H.readInt16BE,t.readInt32LE=H.readInt32LE,t.readInt32BE=H.readInt32BE,t.readFloatLE=H.readFloatLE,t.readFloatBE=H.readFloatBE,t.readDoubleLE=H.readDoubleLE,t.readDoubleBE=H.readDoubleBE,t.writeUInt8=H.writeUInt8,t.writeUInt16LE=H.writeUInt16LE,t.writeUInt16BE=H.writeUInt16BE,t.writeUInt32LE=H.writeUInt32LE,t.writeUInt32BE=H.writeUInt32BE,t.writeInt8=H.writeInt8,t.writeInt16LE=H.writeInt16LE,t.writeInt16BE=H.writeInt16BE,t.writeInt32LE=H.writeInt32LE,t.writeInt32BE=H.writeInt32BE,t.writeFloatLE=H.writeFloatLE,t.writeFloatBE=H.writeFloatBE,t.writeDoubleLE=H.writeDoubleLE,t.writeDoubleBE=H.writeDoubleBE,t.fill=H.fill,t.inspect=H.inspect,t.toArrayBuffer=L,0!==t.byteLength&&(t._dataview=new DataView(t.buffer,t.byteOffset,t.byteLength)),t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function D(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function N(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return J.toByteArray(t)}function O(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function V(t,n){W("number"==typeof t,"cannot write a non-number as a number"),W(t>=0,"specified a negative value for writing an unsigned value"),W(n>=t,"value is larger than maximum value for type"),W(Math.floor(t)===t,"value has a fractional component")}function R(t,n,e){W("number"==typeof t,"cannot write a non-number as a number"),W(n>=t,"value larger than maximum allowed value"),W(t>=e,"value smaller than minimum allowed value"),W(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){W("number"==typeof t,"cannot write a non-number as a number"),W(n>=t,"value larger than maximum allowed value"),W(t>=e,"value smaller than minimum allowed value")}function W(t,n){if(!t)throw new Error(n||"Failed assertion")}var J=t("base64-js"),X=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192;var Y=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer||"undefined"==typeof DataView)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()}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":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return D(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(!T(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");if(0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){if(e>r)throw new Error("sourceEnd < sourceStart");if(0>n||n>=t.length)throw new Error("targetStart out of bounds");if(0>e||e>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),Y)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(W(void 0!==t&&null!==t,"missing offset"),W(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(W(void 0!==t&&null!==t,"missing offset"),W(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){if(Y)return e._dataview.getInt8(t);var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return y(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return w(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return b(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return b(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==n&&null!==n,"missing offset"),W(n<r.length,"trying to write beyond buffer length"),V(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==n&&null!==n,"missing offset"),W(n<r.length,"Trying to write beyond buffer length"),R(t,127,-128)),n>=r.length||(Y?r._dataview.setInt8(n,t):t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(n>e)throw new Error("end < start");if(e!==n&&0!==this.length){if(0>n||n>=this.length)throw new Error("start out of bounds");if(0>e||e>this.length)throw new Error("end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var H=r.prototype},{"base64-js":3,ieee754:4}],"native-buffer-browserify":[function(t,n){n.exports=t("PcZj9L")},{}],3:[function(t,n){function e(t,n){var e=t.length,r=Number(arguments[1])||0;for(r=0>r?Math.ceil(r):Math.floor(r),0>r&&(r+=e);e>r;r++)if("string"==typeof t&&t.charAt(r)===n||"string"!=typeof t&&t[r]===n)return r;return-1}!function(){"use strict";function t(t){var n,r,o,a,u,f;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(u=e(t,"="),u=u>0?t.length-u:0,f=[],o=u>0?t.length-4:t.length,n=0,r=0;o>n;n+=4,r+=3)a=e(i,t.charAt(n))<<18|e(i,t.charAt(n+1))<<12|e(i,t.charAt(n+2))<<6|e(i,t.charAt(n+3)),f.push((16711680&a)>>16),f.push((65280&a)>>8),f.push(255&a);return 2===u?(a=e(i,t.charAt(n))<<2|e(i,t.charAt(n+1))>>4,f.push(255&a)):1===u&&(a=e(i,t.charAt(n))<<10|e(i,t.charAt(n+1))<<4|e(i,t.charAt(n+2))>>2,f.push(a>>8&255),f.push(255&a)),f}function r(t){function n(t){return i.charAt(t>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t)}var e,r,o,a=t.length%3,u="";for(e=0,o=t.length-a;o>e;e+=3)r=(t[e]<<16)+(t[e+1]<<8)+t[e+2],u+=n(r);switch(a){case 1:r=t[t.length-1],u+=i.charAt(r>>2),u+=i.charAt(r<<4&63),u+="==";break;case 2:r=(t[t.length-2]<<8)+t[t.length-1],u+=i.charAt(r>>10),u+=i.charAt(r>>4&63),u+=i.charAt(r<<2&63),u+="="}return u}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";n.exports.toByteArray=t,n.exports.fromByteArray=r}()},{}],4:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)
},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}]},{},[]),n.exports=t("native-buffer-browserify").Buffer},{}],17:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;r._useTypedArrays?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!r._useTypedArrays&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;q(a%2===0,"Invalid hex string"),i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);q(!isNaN(f),"Invalid hex string"),t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=j(D(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=j(N(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=j(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=O(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+O(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(q("boolean"==typeof e,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(o=t[n],i>n+1&&(o|=t[n+1]<<8)):(o=t[n]<<8,i>n+1&&(o|=t[n+1])),o}}function g(t,n,e,r){r||(q("boolean"==typeof e,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(i>n+2&&(o=t[n+2]<<16),i>n+1&&(o|=t[n+1]<<8),o|=t[n],i>n+3&&(o+=t[n+3]<<24>>>0)):(i>n+1&&(o=t[n+1]<<16),i>n+2&&(o|=t[n+2]<<8),i>n+3&&(o|=t[n+3]),o+=t[n]<<24>>>0),o}}function y(t,n,e,r){r||(q("boolean"==typeof e,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=d(t,n,e,!0),a=32768&o;return a?-1*(65535-o+1):o}}function w(t,n,e,r){r||(q("boolean"==typeof e,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=g(t,n,e,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function b(t,n,e,r){return r||(q("boolean"==typeof e,"missing or invalid endian"),q(n+3<t.length,"Trying to read beyond buffer length")),J.read(t,n,e,23,4)}function v(t,n,e,r){return r||(q("boolean"==typeof e,"missing or invalid endian"),q(n+7<t.length,"Trying to read beyond buffer length")),J.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+1<t.length,"trying to write beyond buffer length"),P(n,65535));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,2);u>a;a++)t[e+a]=(n&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function E(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+3<t.length,"trying to write beyond buffer length"),P(n,4294967295));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,4);u>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}function I(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+1<t.length,"Trying to write beyond buffer length"),V(n,32767,-32768));var o=t.length;e>=o||(n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i))}function B(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+3<t.length,"Trying to write beyond buffer length"),V(n,2147483647,-2147483648));var o=t.length;e>=o||(n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i))}function A(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+3<t.length,"Trying to write beyond buffer length"),R(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;e>=o||J.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(q(void 0!==n&&null!==n,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==e&&null!==e,"missing offset"),q(e+7<t.length,"Trying to write beyond buffer length"),R(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;e>=o||J.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=X.write,t.toString=X.toString,t.toLocaleString=X.toString,t.toJSON=X.toJSON,t.copy=X.copy,t.slice=X.slice,t.readUInt8=X.readUInt8,t.readUInt16LE=X.readUInt16LE,t.readUInt16BE=X.readUInt16BE,t.readUInt32LE=X.readUInt32LE,t.readUInt32BE=X.readUInt32BE,t.readInt8=X.readInt8,t.readInt16LE=X.readInt16LE,t.readInt16BE=X.readInt16BE,t.readInt32LE=X.readInt32LE,t.readInt32BE=X.readInt32BE,t.readFloatLE=X.readFloatLE,t.readFloatBE=X.readFloatBE,t.readDoubleLE=X.readDoubleLE,t.readDoubleBE=X.readDoubleBE,t.writeUInt8=X.writeUInt8,t.writeUInt16LE=X.writeUInt16LE,t.writeUInt16BE=X.writeUInt16BE,t.writeUInt32LE=X.writeUInt32LE,t.writeUInt32BE=X.writeUInt32BE,t.writeInt8=X.writeInt8,t.writeInt16LE=X.writeInt16LE,t.writeInt16BE=X.writeInt16BE,t.writeInt32LE=X.writeInt32LE,t.writeInt32BE=X.writeInt32BE,t.writeFloatLE=X.writeFloatLE,t.writeFloatBE=X.writeFloatBE,t.writeDoubleLE=X.writeDoubleLE,t.writeDoubleBE=X.writeDoubleBE,t.fill=X.fill,t.inspect=X.inspect,t.toArrayBuffer=L,t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function D(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function N(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return W.toByteArray(t)}function j(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function O(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function P(t,n){q("number"==typeof t,"cannot write a non-number as a number"),q(t>=0,"specified a negative value for writing an unsigned value"),q(n>=t,"value is larger than maximum value for type"),q(Math.floor(t)===t,"value has a fractional component")}function V(t,n,e){q("number"==typeof t,"cannot write a non-number as a number"),q(n>=t,"value larger than maximum allowed value"),q(t>=e,"value smaller than minimum allowed value"),q(Math.floor(t)===t,"value has a fractional component")}function R(t,n,e){q("number"==typeof t,"cannot write a non-number as a number"),q(n>=t,"value larger than maximum allowed value"),q(t>=e,"value smaller than minimum allowed value")}function q(t,n){if(!t)throw new Error(n||"Failed assertion")}var W=t("base64-js"),J=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}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":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return D(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(q(T(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){q(r>=e,"sourceEnd < sourceStart"),q(n>=0&&n<t.length,"targetStart out of bounds"),q(e>=0&&e<i.length,"sourceStart out of bounds"),q(r>=0&&r<=i.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),r._useTypedArrays)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(q(void 0!==t&&null!==t,"missing offset"),q(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(q(void 0!==t&&null!==t,"missing offset"),q(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return y(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return w(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return b(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return b(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(q(void 0!==t&&null!==t,"missing value"),q(void 0!==n&&null!==n,"missing offset"),q(n<r.length,"trying to write beyond buffer length"),P(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(q(void 0!==t&&null!==t,"missing value"),q(void 0!==n&&null!==n,"missing offset"),q(n<r.length,"Trying to write beyond buffer length"),V(t,127,-128)),n>=r.length||(t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),q("number"==typeof t&&!isNaN(t),"value is not a number"),q(e>=n,"end < start"),e!==n&&0!==this.length){q(n>=0&&n<this.length,"start out of bounds"),q(e>=0&&e<=this.length,"end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var X=r.prototype},{"base64-js":18,ieee754:19}],18:[function(t,n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function t(t){var n=t.charCodeAt(0);return n===a?62:n===u?63:f>n?-1:f+10>n?n-f+26+26:c+26>n?n-c:s+26>n?n-s+26:void 0}function r(n){function e(t){s[l++]=t}var r,i,a,u,f,s;if(n.length%4>0)throw"Invalid string. Length must be a multiple of 4";var c=n.length;f="="===n.charAt(c-2)?2:"="===n.charAt(c-1)?1:0,s=new o(3*n.length/4-f),a=f>0?n.length-4:n.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=t(n.charAt(r))<<18|t(n.charAt(r+1))<<12|t(n.charAt(r+2))<<6|t(n.charAt(r+3)),e((16711680&u)>>16),e((65280&u)>>8),e(255&u);return 2===f?(u=t(n.charAt(r))<<2|t(n.charAt(r+1))>>4,e(255&u)):1===f&&(u=t(n.charAt(r))<<10|t(n.charAt(r+1))<<4|t(n.charAt(r+2))>>2,e(u>>8&255),e(255&u)),s}function i(t){function n(t){return e.charAt(t)}function r(t){return n(t>>18&63)+n(t>>12&63)+n(t>>6&63)+n(63&t)}var i,o,a,u=t.length%3,f="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],f+=r(o);switch(u){case 1:o=t[t.length-1],f+=n(o>>2),f+=n(o<<4&63),f+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],f+=n(o>>10),f+=n(o>>4&63),f+=n(o<<2&63),f+="="}return f}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a=("0".charCodeAt(0),"+".charCodeAt(0)),u="/".charCodeAt(0),f="0".charCodeAt(0),s="a".charCodeAt(0),c="A".charCodeAt(0);n.exports.toByteArray=r,n.exports.fromByteArray=i}()},{}],19:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}],20:[function(n,e){var r=n("__browserify_Buffer");(function(){function i(t,n,e){var r=n&&e||0,i=0;for(n=n||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>i&&(n[r+i++]=y[t])});16>i;)n[r+i++]=0;return n}function o(t,n){var e=n||0,r=g;return r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]}function a(t,n,e){var r=n&&e||0,i=n||[];t=t||{};var a=null!=t.clockseq?t.clockseq:m,u=null!=t.msecs?t.msecs:(new Date).getTime(),f=null!=t.nsecs?t.nsecs:I+1,s=u-E+(f-I)/1e4;if(0>s&&null==t.clockseq&&(a=a+1&16383),(0>s||u>E)&&null==t.nsecs&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");E=u,I=f,m=a,u+=122192928e5;var c=(1e4*(268435455&u)+f)%4294967296;i[r++]=c>>>24&255,i[r++]=c>>>16&255,i[r++]=c>>>8&255,i[r++]=255&c;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++]=a>>>8|128,i[r++]=255&a;for(var h=t.node||v,p=0;6>p;p++)i[r+p]=h[p];return n?n:o(i)}function u(t,n,e){var r=n&&e||0;"string"==typeof t&&(n="binary"==t?new d(16):null,t=null),t=t||{};var i=t.random||(t.rng||f)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n)for(var a=0;16>a;a++)n[r+a]=i[a];return n||o(i)}var f,s=this;if("function"==typeof n)try{var c=n("crypto").randomBytes;f=c&&function(){return c(16)}}catch(l){}if(!f&&s.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);f=function(){return crypto.getRandomValues(h),h}}if(!f){var p=new Array(16);f=function(){for(var t,n=0;16>n;n++)0===(3&n)&&(t=4294967296*Math.random()),p[n]=t>>>((3&n)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,g=[],y={},w=0;256>w;w++)g[w]=(w+256).toString(16).substr(1),y[g[w]]=w;var b=f(),v=[1|b[0],b[1],b[2],b[3],b[4],b[5]],m=16383&(b[6]<<8|b[7]),E=0,I=0,B=u;if(B.v1=a,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 e&&e.exports)e.exports=B;else{var A=s.uuid;B.noConflict=function(){return s.uuid=A,B},s.uuid=B}}).call(this)},{__browserify_Buffer:16,crypto:11}],21:[function(n,e,r){!function(n,i){"use strict";"object"==typeof r&&e?e.exports=i():"function"==typeof t&&t.amd?t(i):n.PubSub=i()}("object"==typeof window&&window||this,function(){"use strict";function t(t){return function(){throw t}}function n(n,e,r){try{n(e,r)}catch(i){setTimeout(t(i),0)}}function e(t,n,e){t(n,e)}function r(t,r,i,o){var a,u=f[r],s=o?e:n;if(f.hasOwnProperty(r))for(a=0;a<u.length;a++)s(u[a].func,t,i)}function i(t,n,e){return function(){var i=String(t),o=i.lastIndexOf(".");for(r(t,t,n,e);-1!==o;)i=i.substr(0,o),o=i.lastIndexOf("."),r(t,i,n)}}function o(t){for(var n=String(t),e=f.hasOwnProperty(n),r=n.lastIndexOf(".");!e&&-1!==r;)n=n.substr(0,r),r=n.lastIndexOf("."),e=f.hasOwnProperty(n);return e&&f[n].length>0}function a(t,n,e,r){var a=i(t,n,r),u=o(t);return u?(e===!0?a():setTimeout(a,0),!0):!1}var u={},f={},s=-1;return u.publish=function(t,n){return a(t,n,!1,u.immediateExceptions)},u.publishSync=function(t,n){return a(t,n,!0,u.immediateExceptions)},u.subscribe=function(t,n){if("function"!=typeof n)return!1;f.hasOwnProperty(t)||(f[t]=[]);var e=String(++s);return f[t].push({token:e,func:n}),e},u.unsubscribe=function(t){var n,e,r="string"==typeof t,i=r?"token":"func",o=r?t:!0,a=!1;for(n in f)if(f.hasOwnProperty(n))for(e=f[n].length-1;e>=0;e--)if(f[n][e][i]===t&&(f[n].splice(e,1),a=o,r))return a;return a},u})},{}]},{},[1])(1)});
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.babble=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var s=e[a]={exports:{}};t[a][0].call(s.exports,function(n){var e=t[a][1][n];return i(e?e:n)},s,s.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n){n.exports=t("./lib/babble")},{"./lib/babble":3}],2:[function(t,n){function e(t){if(!(this instanceof e))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={}}var r=t("node-uuid"),i=t("./pubsub"),o=(t("./block/Block"),t("./block/Action"),t("./block/Tell")),a=t("./block/Listen");e.prototype.subscribe=function(t,n){if("function"==typeof t&&(n=t,t=null),t||(t=i["default"]()),"function"!=typeof t.subscribe)throw new Error("pubsub must contain a function subscribe(params: {id: string, callback: function}) : function");if("function"!=typeof t.publish)throw new Error("pubsub must contain a function publish(params: {id: string, message: *})");var e=this,r=t.subscribe({id:this.id,message:function(t){var n,r,i=JSON.parse(t.message);n=e.conversations[t.id],n?e._run(n,i):(r=e.listeners[i],r&&(n={id:t.id,peer:t.from,next:r,context:{from:t.from}},e._run(n,i)))},connect:n});if("function"!=typeof r)throw new Error("pubsub.subscribe must return a function to unsubscribe");return this.unsubscribe=r,this.publish=t.publish,this},e.prototype.unsubscribe=function(){throw new Error("Cannot unsubscribe: not subscribed")},e.prototype.publish=function(){throw new Error("Cannot publish: not subscribed")},e.prototype.listen=function u(t,n){if("string"!=typeof t)throw new TypeError("Parameter message must be a string");var u=new a(n);return this.listeners[t]=u,u},e.prototype.tell=function(t,n){var e=r.v4(),i=new o,u={id:e,peer:t,next:i,context:{from:t}},f=this;return i.then=function s(t){return u.next=t,t instanceof a?f.conversations[e]=u:(n=f._run(u,n),t.then=s),t},n=this._run(u,n),i},e.prototype.ask=function(t,n,e){return this.tell(t,n).listen(e)},e.prototype._run=function(t,n){delete this.conversations[t.id];var e=t.next;do{var r=e.execute(n,t.context);n=r.result,e instanceof o&&this.publish(t.peer,{id:t.id,from:this.id,to:t.peer,message:JSON.stringify(n)}),e=r.block,e instanceof a&&(t.next=e,this.conversations[t.id]=t)}while(e&&!(e instanceof a));return n},n.exports=e},{"./block/Action":4,"./block/Block":5,"./block/Listen":7,"./block/Tell":8,"./pubsub":9,"node-uuid":20}],3:[function(t,n,e){var r=t("./Babbler"),i=t("./block/Tell"),o=t("./block/Action"),a=t("./block/Decision");e.babbler=function(t){return new r(t)},e.tell=function(t){var n="function"==typeof t?t:function(){return t};return new i(n)},e.decide=function(t,n){return new a(t,n)},e.run=function(t){return new o(t)},e.Babbler=r,e.block={Block:t("./block/Block"),Action:t("./block/Action"),Decision:t("./block/Decision"),Listen:t("./block/Listen"),Tell:t("./block/Tell")},e.pubsub=t("./pubsub")},{"./Babbler":2,"./block/Action":4,"./block/Block":5,"./block/Decision":6,"./block/Listen":7,"./block/Tell":8,"./pubsub":9}],4:[function(t,n){function e(t){if(!(this instanceof e))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("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.run=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],5:[function(t,n){function e(){this.next=null,this.previous=null}e.prototype.execute=function(){throw new Error("Cannot run an abstract Block")},e.prototype.then=function(t){if(!(t instanceof e))throw new TypeError("Parameter next must be a Block");for(var n=this;n.next;)n=n.next;for(var r=this;r.previous;)r=r.previous;return t.previous=this,n.next=t,r},n.exports=e},{}],6:[function(t,n){function e(t,n){var r,i;if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"==typeof t?(r=t,i=n):(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("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.decision(t,n);if("string"!=typeof e)throw new TypeError("Decision function must return a string containing the id of the next block");var r=this.choices[e];if(!r)throw new Error('Block with id "'+e+'" not found');return{result:t,block:r}},e.prototype.addChoice=function(t,n){if("string"!=typeof t)throw new TypeError("String expected as choice id");if(!(n instanceof r))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]=n,this},r.prototype.decide=function(t,n){var r=new e(t,n);return this.then(r)},n.exports=e},{"./Block":5}],7:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.listen=function(t){var n=new e(t);return this.then(n)},n.exports=e},{"./Block":5}],8:[function(t,n){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if(t&&"function"!=typeof t)throw new TypeError("Parameter callback must be a Function");this.callback=t||function(t){return t}}var r=t("./Block");e.prototype=Object.create(r.prototype),e.prototype.execute=function(t,n){var e=this.callback(t,n);return{result:e,block:this.next}},r.prototype.tell=function(t){var n="function"==typeof t?t:function(){return t},r=new e(n);return this.then(r)},n.exports=e},{"./Block":5}],9:[function(t,n,e){e["pubsub-js"]=function(){var n=t("pubsub-js");return{subscribe:function(t){var e=n.subscribe(t.id,function(n,e){t.message(e)});return"function"==typeof t.connect&&t.connect(),function(){n.unsubscribe(e)}},publish:function(t,e){n.publish(t,e)}}},e.pubnub=function(n){var e;if("undefined"!=typeof window){if("undefined"==typeof window.PUBNUB)throw new Error("Please load pubnub first in the browser");e=window.PUBNUB}else e=t("pubnub");var r=e.init(n);return{subscribe:function(t){return r.subscribe({channel:t.id,message:t.message,connect:t.connect}),function(){r.unsubscribe(t.id)}},publish:function(t,n){r.publish({channel:t,message:n})}}},e["default"]=e["pubsub-js"]},{pubnub:"NaMlu/","pubsub-js":21}],10:[function(t,n){function e(t,n){if(t.length%a!==0){var e=t.length+(a-t.length%a);t=o.concat([t,u],e)}for(var r=[],i=n?t.readInt32BE:t.readInt32LE,f=0;f<t.length;f+=a)r.push(i.call(t,f));return r}function r(t,n,e){for(var r=new o(n),i=e?r.writeInt32BE:r.writeInt32LE,a=0;a<t.length;a++)i.call(r,t[a],4*a,!0);return r}function i(t,n,i,a){o.isBuffer(t)||(t=new o(t));var u=n(e(t,a),t.length*f);return r(u,i,a)}var o=t("buffer").Buffer,a=4,u=new o(a);u.fill(0);var f=8;n.exports={hash:i}},{buffer:17}],11:[function(t,n,e){function r(t,n,e){u.isBuffer(n)||(n=new u(n)),u.isBuffer(e)||(e=new u(e)),n.length>p?n=t(n):n.length<p&&(n=u.concat([n,d],p));for(var r=new u(p),i=new u(p),o=0;p>o;o++)r[o]=54^n[o],i[o]=92^n[o];var a=t(u.concat([r,e]));return t(u.concat([i,a]))}function i(t,n){t=t||"sha1";var e=h[t],i=[],a=0;return e||o("algorithm:",t,"is not yet supported"),{update:function(t){return u.isBuffer(t)||(t=new u(t)),i.push(t),a+=t.length,this},digest:function(t){var o=u.concat(i),a=n?r(e,n,o):e(o);return i=null,t?a.toString(t):a}}}function o(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function a(t,n){for(var e in t)n(t[e],e)}var u=t("buffer").Buffer,f=t("./sha"),s=t("./sha256"),c=t("./rng"),l=t("./md5"),h={sha1:f,sha256:s,md5:l},p=64,d=new u(p);d.fill(0),e.createHash=function(t){return i(t)},e.createHmac=function(t,n){return i(t,n)},e.randomBytes=function(t,n){if(!n||!n.call)return new u(c(t));try{n.call(this,void 0,new u(c(t)))}catch(e){n(e)}},a(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(t){e[t]=function(){o("sorry,",t,"is not implemented yet")}})},{"./md5":12,"./rng":13,"./sha":14,"./sha256":15,buffer:17}],12:[function(t,n){function e(t,n){t[n>>5]|=128<<n%32,t[(n+64>>>9<<4)+14]=n;for(var e=1732584193,r=-271733879,s=-1732584194,c=271733878,l=0;l<t.length;l+=16){var h=e,p=r,d=s,g=c;e=i(e,r,s,c,t[l+0],7,-680876936),c=i(c,e,r,s,t[l+1],12,-389564586),s=i(s,c,e,r,t[l+2],17,606105819),r=i(r,s,c,e,t[l+3],22,-1044525330),e=i(e,r,s,c,t[l+4],7,-176418897),c=i(c,e,r,s,t[l+5],12,1200080426),s=i(s,c,e,r,t[l+6],17,-1473231341),r=i(r,s,c,e,t[l+7],22,-45705983),e=i(e,r,s,c,t[l+8],7,1770035416),c=i(c,e,r,s,t[l+9],12,-1958414417),s=i(s,c,e,r,t[l+10],17,-42063),r=i(r,s,c,e,t[l+11],22,-1990404162),e=i(e,r,s,c,t[l+12],7,1804603682),c=i(c,e,r,s,t[l+13],12,-40341101),s=i(s,c,e,r,t[l+14],17,-1502002290),r=i(r,s,c,e,t[l+15],22,1236535329),e=o(e,r,s,c,t[l+1],5,-165796510),c=o(c,e,r,s,t[l+6],9,-1069501632),s=o(s,c,e,r,t[l+11],14,643717713),r=o(r,s,c,e,t[l+0],20,-373897302),e=o(e,r,s,c,t[l+5],5,-701558691),c=o(c,e,r,s,t[l+10],9,38016083),s=o(s,c,e,r,t[l+15],14,-660478335),r=o(r,s,c,e,t[l+4],20,-405537848),e=o(e,r,s,c,t[l+9],5,568446438),c=o(c,e,r,s,t[l+14],9,-1019803690),s=o(s,c,e,r,t[l+3],14,-187363961),r=o(r,s,c,e,t[l+8],20,1163531501),e=o(e,r,s,c,t[l+13],5,-1444681467),c=o(c,e,r,s,t[l+2],9,-51403784),s=o(s,c,e,r,t[l+7],14,1735328473),r=o(r,s,c,e,t[l+12],20,-1926607734),e=a(e,r,s,c,t[l+5],4,-378558),c=a(c,e,r,s,t[l+8],11,-2022574463),s=a(s,c,e,r,t[l+11],16,1839030562),r=a(r,s,c,e,t[l+14],23,-35309556),e=a(e,r,s,c,t[l+1],4,-1530992060),c=a(c,e,r,s,t[l+4],11,1272893353),s=a(s,c,e,r,t[l+7],16,-155497632),r=a(r,s,c,e,t[l+10],23,-1094730640),e=a(e,r,s,c,t[l+13],4,681279174),c=a(c,e,r,s,t[l+0],11,-358537222),s=a(s,c,e,r,t[l+3],16,-722521979),r=a(r,s,c,e,t[l+6],23,76029189),e=a(e,r,s,c,t[l+9],4,-640364487),c=a(c,e,r,s,t[l+12],11,-421815835),s=a(s,c,e,r,t[l+15],16,530742520),r=a(r,s,c,e,t[l+2],23,-995338651),e=u(e,r,s,c,t[l+0],6,-198630844),c=u(c,e,r,s,t[l+7],10,1126891415),s=u(s,c,e,r,t[l+14],15,-1416354905),r=u(r,s,c,e,t[l+5],21,-57434055),e=u(e,r,s,c,t[l+12],6,1700485571),c=u(c,e,r,s,t[l+3],10,-1894986606),s=u(s,c,e,r,t[l+10],15,-1051523),r=u(r,s,c,e,t[l+1],21,-2054922799),e=u(e,r,s,c,t[l+8],6,1873313359),c=u(c,e,r,s,t[l+15],10,-30611744),s=u(s,c,e,r,t[l+6],15,-1560198380),r=u(r,s,c,e,t[l+13],21,1309151649),e=u(e,r,s,c,t[l+4],6,-145523070),c=u(c,e,r,s,t[l+11],10,-1120210379),s=u(s,c,e,r,t[l+2],15,718787259),r=u(r,s,c,e,t[l+9],21,-343485551),e=f(e,h),r=f(r,p),s=f(s,d),c=f(c,g)}return Array(e,r,s,c)}function r(t,n,e,r,i,o){return f(s(f(f(n,t),f(r,o)),i),e)}function i(t,n,e,i,o,a,u){return r(n&e|~n&i,t,n,o,a,u)}function o(t,n,e,i,o,a,u){return r(n&i|e&~i,t,n,o,a,u)}function a(t,n,e,i,o,a,u){return r(n^e^i,t,n,o,a,u)}function u(t,n,e,i,o,a,u){return r(e^(n|~i),t,n,o,a,u)}function f(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function s(t,n){return t<<n|t>>>32-n}var c=t("./helpers");n.exports=function(t){return c.hash(t,e,16)}},{"./helpers":10}],13:[function(t,n){!function(){var t,e,r=this;t=function(t){for(var n,n,e=new Array(t),r=0;t>r;r++)0==(3&r)&&(n=4294967296*Math.random()),e[r]=n>>>((3&r)<<3)&255;return e},r.crypto&&crypto.getRandomValues&&(e=function(t){var n=new Uint8Array(t);return crypto.getRandomValues(n),n}),n.exports=e||t}()},{}],14:[function(t,n){function e(t,n){t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var e=Array(80),u=1732584193,f=-271733879,s=-1732584194,c=271733878,l=-1009589776,h=0;h<t.length;h+=16){for(var p=u,d=f,g=s,w=c,b=l,y=0;80>y;y++){e[y]=16>y?t[h+y]:a(e[y-3]^e[y-8]^e[y-14]^e[y-16],1);var v=o(o(a(u,5),r(y,f,s,c)),o(o(l,e[y]),i(y)));l=c,c=s,s=a(f,30),f=u,u=v}u=o(u,p),f=o(f,d),s=o(s,g),c=o(c,w),l=o(l,b)}return Array(u,f,s,c,l)}function r(t,n,e,r){return 20>t?n&e|~n&r:40>t?n^e^r:60>t?n&e|n&r|e&r:n^e^r}function i(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function o(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e}function a(t,n){return t<<n|t>>>32-n}var u=t("./helpers");n.exports=function(t){return u.hash(t,e,20,!0)}},{"./helpers":10}],15:[function(t,n){var e=t("./helpers"),r=function(t,n){var e=(65535&t)+(65535&n),r=(t>>16)+(n>>16)+(e>>16);return r<<16|65535&e},i=function(t,n){return t>>>n|t<<32-n},o=function(t,n){return t>>>n},a=function(t,n,e){return t&n^~t&e},u=function(t,n,e){return t&n^t&e^n&e},f=function(t){return i(t,2)^i(t,13)^i(t,22)},s=function(t){return i(t,6)^i(t,11)^i(t,25)},c=function(t){return i(t,7)^i(t,18)^o(t,3)},l=function(t){return i(t,17)^i(t,19)^o(t,10)},h=function(t,n){var e,i,o,h,p,d,g,w,b,y,v,m,E=new Array(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),I=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),B=new Array(64);t[n>>5]|=128<<24-n%32,t[(n+64>>9<<4)+15]=n;for(var b=0;b<t.length;b+=16){e=I[0],i=I[1],o=I[2],h=I[3],p=I[4],d=I[5],g=I[6],w=I[7];for(var y=0;64>y;y++)B[y]=16>y?t[y+b]:r(r(r(l(B[y-2]),B[y-7]),c(B[y-15])),B[y-16]),v=r(r(r(r(w,s(p)),a(p,d,g)),E[y]),B[y]),m=r(f(e),u(e,i,o)),w=g,g=d,d=p,p=r(h,v),h=o,o=i,i=e,e=r(v,m);I[0]=r(e,I[0]),I[1]=r(i,I[1]),I[2]=r(o,I[2]),I[3]=r(h,I[3]),I[4]=r(p,I[4]),I[5]=r(d,I[5]),I[6]=r(g,I[6]),I[7]=r(w,I[7])}return I};n.exports=function(t){return e.hash(t,h,32,!0)}},{"./helpers":10}],16:[function(t,n){t=function e(n,r,i){function o(u,f){if(!r[u]){if(!n[u]){var s="function"==typeof t&&t;if(!f&&s)return s(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=r[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return o(e?e:t)},c,c.exports,e,n,r,i)}return r[u].exports}for(var a="function"==typeof t&&t,u=0;u<i.length;u++)o(i[u]);return o}({PcZj9L:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;Y?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!Y&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);if(isNaN(f))throw new Error("Invalid hex string");t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=O(N(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=O(D(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=O(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+1)return t._dataview.getUint16(n,e);var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getUint16(0,e)}var a;return e?(a=t[n],i>n+1&&(a|=t[n+1]<<8)):(a=t[n]<<8,i>n+1&&(a|=t[n+1])),a}}function g(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(i>n+3)return t._dataview.getUint32(n,e);for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getUint32(0,e)}var u;return e?(i>n+2&&(u=t[n+2]<<16),i>n+1&&(u|=t[n+1]<<8),u|=t[n],i>n+3&&(u+=t[n+3]<<24>>>0)):(i>n+1&&(u=t[n+1]<<16),i>n+2&&(u|=t[n+2]<<8),i>n+3&&(u|=t[n+3]),u+=t[n]<<24>>>0),u}}function w(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+1===i){var o=new DataView(new ArrayBuffer(2));return o.setUint8(0,t[i-1]),o.getInt16(0,e)}return t._dataview.getInt16(n,e)}var a=d(t,n,e,!0),u=32768&a;return u?-1*(65535-a+1):a}}function b(t,n,e,r){r||(R("boolean"==typeof e,"missing or invalid endian"),R(void 0!==n&&null!==n,"missing offset"),R(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){if(Y){if(n+3>=i){for(var o=new DataView(new ArrayBuffer(4)),a=0;i>a+n;a++)o.setUint8(a,t[a+n]);return o.getInt32(0,e)}return t._dataview.getInt32(n,e)}var u=g(t,n,e,!0),f=2147483648&u;return f?-1*(4294967295-u+1):u}}function y(t,n,e,r){return r||(R("boolean"==typeof e,"missing or invalid endian"),R(n+3<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat32(n,e):X.read(t,n,e,23,4)}function v(t,n,e,r){return r||(R("boolean"==typeof e,"missing or invalid endian"),R(n+7<t.length,"Trying to read beyond buffer length")),Y?t._dataview.getFloat64(n,e):X.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"trying to write beyond buffer length"),V(n,65535));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setUint16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setUint16(e,n,r);else for(var u=0,f=Math.min(o-e,2);f>u;u++)t[e+u]=(n&255<<8*(r?u:1-u))>>>8*(r?u:1-u)}function E(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"trying to write beyond buffer length"),V(n,4294967295));var o=t.length;if(!(e>=o)){var a;if(Y)if(e+3>=o){var u=new DataView(new ArrayBuffer(4));for(u.setUint32(0,n,r),a=0;o>a+e;a++)t[a+e]=u.getUint8(a)}else t._dataview.setUint32(e,n,r);else for(a=0,j=Math.min(o-e,4);j>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}}function I(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+1<t.length,"Trying to write beyond buffer length"),q(n,32767,-32768));var o=t.length;if(!(e>=o))if(Y)if(e+1===o){var a=new DataView(new ArrayBuffer(2));a.setInt16(0,n,r),t[e]=a.getUint8(0)}else t._dataview.setInt16(e,n,r);else n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i)}function B(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to write beyond buffer length"),q(n,2147483647,-2147483648));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setInt32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setInt32(e,n,r);else n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i)}function A(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+3<t.length,"Trying to write beyond buffer length"),J(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(e>=o))if(Y)if(e+3>=o){var a=new DataView(new ArrayBuffer(4));a.setFloat32(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat32(e,n,r);else X.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(R(void 0!==n&&null!==n,"missing value"),R("boolean"==typeof r,"missing or invalid endian"),R(void 0!==e&&null!==e,"missing offset"),R(e+7<t.length,"Trying to write beyond buffer length"),J(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(e>=o))if(Y)if(e+7>=o){var a=new DataView(new ArrayBuffer(8));a.setFloat64(0,n,r);for(var u=0;o>u+e;u++)t[u+e]=a.getUint8(u)}else t._dataview.setFloat64(e,n,r);else X.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=H.write,t.toString=H.toString,t.toLocaleString=H.toString,t.toJSON=H.toJSON,t.copy=H.copy,t.slice=H.slice,t.readUInt8=H.readUInt8,t.readUInt16LE=H.readUInt16LE,t.readUInt16BE=H.readUInt16BE,t.readUInt32LE=H.readUInt32LE,t.readUInt32BE=H.readUInt32BE,t.readInt8=H.readInt8,t.readInt16LE=H.readInt16LE,t.readInt16BE=H.readInt16BE,t.readInt32LE=H.readInt32LE,t.readInt32BE=H.readInt32BE,t.readFloatLE=H.readFloatLE,t.readFloatBE=H.readFloatBE,t.readDoubleLE=H.readDoubleLE,t.readDoubleBE=H.readDoubleBE,t.writeUInt8=H.writeUInt8,t.writeUInt16LE=H.writeUInt16LE,t.writeUInt16BE=H.writeUInt16BE,t.writeUInt32LE=H.writeUInt32LE,t.writeUInt32BE=H.writeUInt32BE,t.writeInt8=H.writeInt8,t.writeInt16LE=H.writeInt16LE,t.writeInt16BE=H.writeInt16BE,t.writeInt32LE=H.writeInt32LE,t.writeInt32BE=H.writeInt32BE,t.writeFloatLE=H.writeFloatLE,t.writeFloatBE=H.writeFloatBE,t.writeDoubleLE=H.writeDoubleLE,t.writeDoubleBE=H.writeDoubleBE,t.fill=H.fill,t.inspect=H.inspect,t.toArrayBuffer=L,0!==t.byteLength&&(t._dataview=new DataView(t.buffer,t.byteOffset,t.byteLength)),t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function D(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return W.toByteArray(t)}function O(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function V(t,n){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(n>=t,"value is larger than maximum value for type"),R(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){R("number"==typeof t,"cannot write a non-number as a number"),R(n>=t,"value larger than maximum allowed value"),R(t>=e,"value smaller than minimum allowed value"),R(Math.floor(t)===t,"value has a fractional component")}function J(t,n,e){R("number"==typeof t,"cannot write a non-number as a number"),R(n>=t,"value larger than maximum allowed value"),R(t>=e,"value smaller than minimum allowed value")}function R(t,n){if(!t)throw new Error(n||"Failed assertion")}var W=t("base64-js"),X=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192;var Y=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer||"undefined"==typeof DataView)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()}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":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return N(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(!T(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");if(0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){if(e>r)throw new Error("sourceEnd < sourceStart");if(0>n||n>=t.length)throw new Error("targetStart out of bounds");if(0>e||e>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),Y)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(R(void 0!==t&&null!==t,"missing offset"),R(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(R(void 0!==t&&null!==t,"missing offset"),R(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){if(Y)return e._dataview.getInt8(t);var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return w(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return b(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return b(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return y(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return y(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==n&&null!==n,"missing offset"),R(n<r.length,"trying to write beyond buffer length"),V(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(R(void 0!==t&&null!==t,"missing value"),R(void 0!==n&&null!==n,"missing offset"),R(n<r.length,"Trying to write beyond buffer length"),q(t,127,-128)),n>=r.length||(Y?r._dataview.setInt8(n,t):t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(n>e)throw new Error("end < start");if(e!==n&&0!==this.length){if(0>n||n>=this.length)throw new Error("start out of bounds");if(0>e||e>this.length)throw new Error("end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var H=r.prototype},{"base64-js":3,ieee754:4}],"native-buffer-browserify":[function(t,n){n.exports=t("PcZj9L")},{}],3:[function(t,n){function e(t,n){var e=t.length,r=Number(arguments[1])||0;for(r=0>r?Math.ceil(r):Math.floor(r),0>r&&(r+=e);e>r;r++)if("string"==typeof t&&t.charAt(r)===n||"string"!=typeof t&&t[r]===n)return r;return-1}!function(){"use strict";function t(t){var n,r,o,a,u,f;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(u=e(t,"="),u=u>0?t.length-u:0,f=[],o=u>0?t.length-4:t.length,n=0,r=0;o>n;n+=4,r+=3)a=e(i,t.charAt(n))<<18|e(i,t.charAt(n+1))<<12|e(i,t.charAt(n+2))<<6|e(i,t.charAt(n+3)),f.push((16711680&a)>>16),f.push((65280&a)>>8),f.push(255&a);return 2===u?(a=e(i,t.charAt(n))<<2|e(i,t.charAt(n+1))>>4,f.push(255&a)):1===u&&(a=e(i,t.charAt(n))<<10|e(i,t.charAt(n+1))<<4|e(i,t.charAt(n+2))>>2,f.push(a>>8&255),f.push(255&a)),f}function r(t){function n(t){return i.charAt(t>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t)}var e,r,o,a=t.length%3,u="";for(e=0,o=t.length-a;o>e;e+=3)r=(t[e]<<16)+(t[e+1]<<8)+t[e+2],u+=n(r);switch(a){case 1:r=t[t.length-1],u+=i.charAt(r>>2),u+=i.charAt(r<<4&63),u+="==";break;case 2:r=(t[t.length-2]<<8)+t[t.length-1],u+=i.charAt(r>>10),u+=i.charAt(r>>4&63),u+=i.charAt(r<<2&63),u+="="}return u}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";n.exports.toByteArray=t,n.exports.fromByteArray=r}()},{}],4:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;
else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}]},{},[]),n.exports=t("native-buffer-browserify").Buffer},{}],17:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;if("base64"===n&&"string"===i)for(t=x(t);t.length%4!==0;)t+="=";var o;if("number"===i)o=C(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=C(t.length)}var a;r._useTypedArrays?a=k(new Uint8Array(o)):(a=this,a.length=o);var u;if(r.isBuffer(t))a.set(t);else if(M(t))for(u=0;o>u;u++)a[u]=r.isBuffer(t)?t.readUInt8(u):t[u];else if("string"===i)a.write(t,0,n);else if("number"===i&&!r._useTypedArrays&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,i){e=Number(e)||0;var o=t.length-e;i?(i=Number(i),i>o&&(i=o)):i=o;var a=n.length;J(a%2===0,"Invalid hex string"),i>a/2&&(i=a/2);for(var u=0;i>u;u++){var f=parseInt(n.substr(2*u,2),16);J(!isNaN(f),"Invalid hex string"),t[e+u]=f}return r._charsWritten=2*u,u}function o(t,n,e,i){return r._charsWritten=j(N(n),t,e,i)}function a(t,n,e,i){return r._charsWritten=j(D(n),t,e,i)}function u(t,n,e,r){return a(t,n,e,r)}function f(t,n,e,i){return r._charsWritten=j(F(n),t,e,i)}function s(t,n,e){return 0===n&&e===t.length?R.fromByteArray(t):R.fromByteArray(t.slice(n,e))}function c(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)t[o]<=127?(r+=O(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+O(i)}function l(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function h(t,n,e){return l(t,n,e)}function p(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=_(t[o]);return i}function d(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(o=t[n],i>n+1&&(o|=t[n+1]<<8)):(o=t[n]<<8,i>n+1&&(o|=t[n+1])),o}}function g(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(i>n+2&&(o=t[n+2]<<16),i>n+1&&(o|=t[n+1]<<8),o|=t[n],i>n+3&&(o+=t[n+3]<<24>>>0)):(i>n+1&&(o=t[n+1]<<16),i>n+2&&(o|=t[n+2]<<8),i>n+3&&(o|=t[n+3]),o+=t[n]<<24>>>0),o}}function w(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+1<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=d(t,n,e,!0),a=32768&o;return a?-1*(65535-o+1):o}}function b(t,n,e,r){r||(J("boolean"==typeof e,"missing or invalid endian"),J(void 0!==n&&null!==n,"missing offset"),J(n+3<t.length,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=g(t,n,e,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function y(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+3<t.length,"Trying to read beyond buffer length")),W.read(t,n,e,23,4)}function v(t,n,e,r){return r||(J("boolean"==typeof e,"missing or invalid endian"),J(n+7<t.length,"Trying to read beyond buffer length")),W.read(t,n,e,52,8)}function m(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"trying to write beyond buffer length"),P(n,65535));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,2);u>a;a++)t[e+a]=(n&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function E(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"trying to write beyond buffer length"),P(n,4294967295));var o=t.length;if(!(e>=o))for(var a=0,u=Math.min(o-e,4);u>a;a++)t[e+a]=n>>>8*(r?a:3-a)&255}function I(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+1<t.length,"Trying to write beyond buffer length"),V(n,32767,-32768));var o=t.length;e>=o||(n>=0?m(t,n,e,r,i):m(t,65535+n+1,e,r,i))}function B(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),V(n,2147483647,-2147483648));var o=t.length;e>=o||(n>=0?E(t,n,e,r,i):E(t,4294967295+n+1,e,r,i))}function A(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+3<t.length,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;e>=o||W.write(t,n,e,r,23,4)}function U(t,n,e,r,i){i||(J(void 0!==n&&null!==n,"missing value"),J("boolean"==typeof r,"missing or invalid endian"),J(void 0!==e&&null!==e,"missing offset"),J(e+7<t.length,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;e>=o||W.write(t,n,e,r,52,8)}function L(){return new r(this).buffer}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function k(t){return t._isBuffer=!0,t.write=X.write,t.toString=X.toString,t.toLocaleString=X.toString,t.toJSON=X.toJSON,t.copy=X.copy,t.slice=X.slice,t.readUInt8=X.readUInt8,t.readUInt16LE=X.readUInt16LE,t.readUInt16BE=X.readUInt16BE,t.readUInt32LE=X.readUInt32LE,t.readUInt32BE=X.readUInt32BE,t.readInt8=X.readInt8,t.readInt16LE=X.readInt16LE,t.readInt16BE=X.readInt16BE,t.readInt32LE=X.readInt32LE,t.readInt32BE=X.readInt32BE,t.readFloatLE=X.readFloatLE,t.readFloatBE=X.readFloatBE,t.readDoubleLE=X.readDoubleLE,t.readDoubleBE=X.readDoubleBE,t.writeUInt8=X.writeUInt8,t.writeUInt16LE=X.writeUInt16LE,t.writeUInt16BE=X.writeUInt16BE,t.writeUInt32LE=X.writeUInt32LE,t.writeUInt32BE=X.writeUInt32BE,t.writeInt8=X.writeInt8,t.writeInt16LE=X.writeInt16LE,t.writeInt16BE=X.writeInt16BE,t.writeInt32LE=X.writeInt32LE,t.writeInt32BE=X.writeInt32BE,t.writeFloatLE=X.writeFloatLE,t.writeFloatBE=X.writeFloatBE,t.writeDoubleLE=X.writeDoubleLE,t.writeDoubleBE=X.writeDoubleBE,t.fill=X.fill,t.inspect=X.inspect,t.toArrayBuffer=L,t}function S(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function C(t){return t=~~Math.ceil(+t),0>t?0:t}function T(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function M(t){return T(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function _(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var n=[],e=0;e<t.length;e++)if(t.charCodeAt(e)<=127)n.push(t.charCodeAt(e));else for(var r=encodeURIComponent(t.charAt(e)).substr(1).split("%"),i=0;i<r.length;i++)n.push(parseInt(r[i],16));return n}function D(t){for(var n=[],e=0;e<t.length;e++)n.push(255&t.charCodeAt(e));return n}function F(t){return R.toByteArray(t)}function j(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function O(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function P(t,n){J("number"==typeof t,"cannot write a non-number as a number"),J(t>=0,"specified a negative value for writing an unsigned value"),J(n>=t,"value is larger than maximum value for type"),J(Math.floor(t)===t,"value has a fractional component")}function V(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value"),J(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){J("number"==typeof t,"cannot write a non-number as a number"),J(n>=t,"value larger than maximum allowed value"),J(t>=e,"value smaller than minimum allowed value")}function J(t,n){if(!t)throw new Error(n||"Failed assertion")}var R=t("base64-js"),W=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer)return!1;try{var t=new Uint8Array(0);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}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":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,n){switch(n||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return N(t).length;case"ascii":case"binary":return t.length;case"base64":return F(t).length;default:throw new Error("Unknown encoding")}},r.concat=function(t,n){if(J(T(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if("number"!=typeof n)for(n=0,e=0;e<t.length;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;e<t.length;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var s=r;r=n,n=e,e=s}n=Number(n)||0;var c=this.length-n;switch(e?(e=Number(e),e>c&&(e=c)):e=c,r=String(r||"utf8").toLowerCase()){case"hex":return i(this,t,n,e);case"utf8":case"utf-8":return o(this,t,n,e);case"ascii":return a(this,t,n,e);case"binary":return u(this,t,n,e);case"base64":return f(this,t,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toString=function(t,n,e){var r=this;if(t=String(t||"utf8").toLowerCase(),n=Number(n)||0,e=void 0!==e?Number(e):e=r.length,e===n)return"";switch(t){case"hex":return p(r,n,e);case"utf8":case"utf-8":return c(r,n,e);case"ascii":return l(r,n,e);case"binary":return h(r,n,e);case"base64":return s(r,n,e);default:throw new Error("Unknown encoding")}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(t,n,e,r){var i=this;if(e||(e=0),r||0===r||(r=this.length),n||(n=0),r!==e&&0!==t.length&&0!==i.length){J(r>=e,"sourceEnd < sourceStart"),J(n>=0&&n<t.length,"targetStart out of bounds"),J(e>=0&&e<i.length,"sourceStart out of bounds"),J(r>=0&&r<=i.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);for(var o=0;r-e>o;o++)t[o+n]=this[o+e]}},r.prototype.slice=function(t,n){var e=this.length;if(t=S(t,e,0),n=S(n,e,e),r._useTypedArrays)return k(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,n){var e=this;return n||(J(void 0!==t&&null!==t,"missing offset"),J(t<e.length,"Trying to read beyond buffer length")),t>=e.length?void 0:e[t]},r.prototype.readUInt16LE=function(t,n){return d(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return d(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return g(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return g(this,t,!1,n)},r.prototype.readInt8=function(t,n){var e=this;if(n||(J(void 0!==t&&null!==t,"missing offset"),J(t<e.length,"Trying to read beyond buffer length")),!(t>=e.length)){var r=128&e[t];return r?-1*(255-e[t]+1):e[t]}},r.prototype.readInt16LE=function(t,n){return w(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return w(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return b(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return b(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return y(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return y(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return v(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return v(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){var r=this;e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<r.length,"trying to write beyond buffer length"),P(t,255)),n>=r.length||(r[n]=t)},r.prototype.writeUInt16LE=function(t,n,e){m(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){m(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){E(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){E(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){var r=this;e||(J(void 0!==t&&null!==t,"missing value"),J(void 0!==n&&null!==n,"missing offset"),J(n<r.length,"Trying to write beyond buffer length"),V(t,127,-128)),n>=r.length||(t>=0?r.writeUInt8(t,n,e):r.writeUInt8(255+t+1,n,e))},r.prototype.writeInt16LE=function(t,n,e){I(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){I(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){B(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){B(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){A(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){A(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){U(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){U(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),J("number"==typeof t&&!isNaN(t),"value is not a number"),J(e>=n,"end < start"),e!==n&&0!==this.length){J(n>=0&&n<this.length,"start out of bounds"),J(e>=0&&e<=this.length,"end out of bounds");for(var r=n;e>r;r++)this[r]=t}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=_(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"};var X=r.prototype},{"base64-js":18,ieee754:19}],18:[function(t,n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function t(t){var n=t.charCodeAt(0);return n===a?62:n===u?63:f>n?-1:f+10>n?n-f+26+26:c+26>n?n-c:s+26>n?n-s+26:void 0}function r(n){function e(t){s[l++]=t}var r,i,a,u,f,s;if(n.length%4>0)throw"Invalid string. Length must be a multiple of 4";var c=n.length;f="="===n.charAt(c-2)?2:"="===n.charAt(c-1)?1:0,s=new o(3*n.length/4-f),a=f>0?n.length-4:n.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=t(n.charAt(r))<<18|t(n.charAt(r+1))<<12|t(n.charAt(r+2))<<6|t(n.charAt(r+3)),e((16711680&u)>>16),e((65280&u)>>8),e(255&u);return 2===f?(u=t(n.charAt(r))<<2|t(n.charAt(r+1))>>4,e(255&u)):1===f&&(u=t(n.charAt(r))<<10|t(n.charAt(r+1))<<4|t(n.charAt(r+2))>>2,e(u>>8&255),e(255&u)),s}function i(t){function n(t){return e.charAt(t)}function r(t){return n(t>>18&63)+n(t>>12&63)+n(t>>6&63)+n(63&t)}var i,o,a,u=t.length%3,f="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],f+=r(o);switch(u){case 1:o=t[t.length-1],f+=n(o>>2),f+=n(o<<4&63),f+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],f+=n(o>>10),f+=n(o>>4&63),f+=n(o<<2&63),f+="="}return f}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a=("0".charCodeAt(0),"+".charCodeAt(0)),u="/".charCodeAt(0),f="0".charCodeAt(0),s="a".charCodeAt(0),c="A".charCodeAt(0);n.exports.toByteArray=r,n.exports.fromByteArray=i}()},{}],19:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,f=(1<<u)-1,s=f>>1,c=-7,l=e?i-1:0,h=e?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[n+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[n+l],l+=h,c-=8);if(0===o)o=1-s;else{if(o===f)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=s}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,f,s=8*o-i-1,c=(1<<s)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=c):(a=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-a))<1&&(a--,f*=2),n+=a+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(a++,f/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(n*f-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(a=a<<i|u,s+=i;s>0;t[e+p]=255&a,p+=d,a/=256,s-=8);t[e+p-d]|=128*g}},{}],20:[function(n,e){var r=n("__browserify_Buffer");(function(){function i(t,n,e){var r=n&&e||0,i=0;for(n=n||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>i&&(n[r+i++]=w[t])});16>i;)n[r+i++]=0;return n}function o(t,n){var e=n||0,r=g;return r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+"-"+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]+r[t[e++]]}function a(t,n,e){var r=n&&e||0,i=n||[];t=t||{};var a=null!=t.clockseq?t.clockseq:m,u=null!=t.msecs?t.msecs:(new Date).getTime(),f=null!=t.nsecs?t.nsecs:I+1,s=u-E+(f-I)/1e4;if(0>s&&null==t.clockseq&&(a=a+1&16383),(0>s||u>E)&&null==t.nsecs&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");E=u,I=f,m=a,u+=122192928e5;var c=(1e4*(268435455&u)+f)%4294967296;i[r++]=c>>>24&255,i[r++]=c>>>16&255,i[r++]=c>>>8&255,i[r++]=255&c;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++]=a>>>8|128,i[r++]=255&a;for(var h=t.node||v,p=0;6>p;p++)i[r+p]=h[p];return n?n:o(i)}function u(t,n,e){var r=n&&e||0;"string"==typeof t&&(n="binary"==t?new d(16):null,t=null),t=t||{};var i=t.random||(t.rng||f)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n)for(var a=0;16>a;a++)n[r+a]=i[a];return n||o(i)}var f,s=this;if("function"==typeof n)try{var c=n("crypto").randomBytes;f=c&&function(){return c(16)}}catch(l){}if(!f&&s.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);f=function(){return crypto.getRandomValues(h),h}}if(!f){var p=new Array(16);f=function(){for(var t,n=0;16>n;n++)0===(3&n)&&(t=4294967296*Math.random()),p[n]=t>>>((3&n)<<3)&255;return p}}for(var d="function"==typeof r?r:Array,g=[],w={},b=0;256>b;b++)g[b]=(b+256).toString(16).substr(1),w[g[b]]=b;var y=f(),v=[1|y[0],y[1],y[2],y[3],y[4],y[5]],m=16383&(y[6]<<8|y[7]),E=0,I=0,B=u;if(B.v1=a,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 e&&e.exports)e.exports=B;else{var A=s.uuid;B.noConflict=function(){return s.uuid=A,B},s.uuid=B}}).call(this)},{__browserify_Buffer:16,crypto:11}],21:[function(n,e,r){!function(n,i){"use strict";"object"==typeof r&&e?e.exports=i():"function"==typeof t&&t.amd?t(i):n.PubSub=i()}("object"==typeof window&&window||this,function(){"use strict";function t(t){return function(){throw t}}function n(n,e,r){try{n(e,r)}catch(i){setTimeout(t(i),0)}}function e(t,n,e){t(n,e)}function r(t,r,i,o){var a,u=f[r],s=o?e:n;if(f.hasOwnProperty(r))for(a=0;a<u.length;a++)s(u[a].func,t,i)}function i(t,n,e){return function(){var i=String(t),o=i.lastIndexOf(".");for(r(t,t,n,e);-1!==o;)i=i.substr(0,o),o=i.lastIndexOf("."),r(t,i,n)}}function o(t){for(var n=String(t),e=f.hasOwnProperty(n),r=n.lastIndexOf(".");!e&&-1!==r;)n=n.substr(0,r),r=n.lastIndexOf("."),e=f.hasOwnProperty(n);return e&&f[n].length>0}function a(t,n,e,r){var a=i(t,n,r),u=o(t);return u?(e===!0?a():setTimeout(a,0),!0):!1}var u={},f={},s=-1;return u.publish=function(t,n){return a(t,n,!1,u.immediateExceptions)},u.publishSync=function(t,n){return a(t,n,!0,u.immediateExceptions)},u.subscribe=function(t,n){if("function"!=typeof n)return!1;f.hasOwnProperty(t)||(f[t]=[]);var e=String(++s);return f[t].push({token:e,func:n}),e},u.unsubscribe=function(t){var n,e,r="string"==typeof t,i=r?"token":"func",o=r?t:!0,a=!1;for(n in f)if(f.hasOwnProperty(n))for(e=f[n].length-1;e>=0;e--)if(f[n][e][i]===t&&(f[n].splice(e,1),a=o,r))return a;return a},u})},{}]},{},[1])(1)});
//# sourceMappingURL=./babble.min.map

@@ -55,10 +55,10 @@ var babble = require('../index');

var check = babble.decide(decideIfCorrect);
check.addChoice('higher', babble.reply(higher).listen().then(check));
check.addChoice('lower', babble.reply(lower).listen().then(check));
check.addChoice('right', babble.reply(right));
check.addChoice('higher', babble.tell(higher).listen().then(check));
check.addChoice('lower', babble.tell(lower).listen().then(check));
check.addChoice('right', babble.tell(right));
emma.listen('lets play guess the number')
.decide(decideToPlay, {
start: babble.reply(start).listen().then(check),
deny: babble.reply(deny)
start: babble.tell(start).listen().then(check),
deny: babble.tell(deny)
});

@@ -109,7 +109,7 @@

checkGuess.addChoice('right', babble.run(triumph));
checkGuess.addChoice('wrong', babble.reply(guess).listen().then(checkGuess));
checkGuess.addChoice('wrong', babble.tell(guess).listen().then(checkGuess));
jack.ask('emma', 'lets play guess the number')
.decide(decideToStart, {
start: babble.run(start).reply(guess).listen().then(checkGuess),
start: babble.run(start).tell(guess).listen().then(checkGuess),
cancel: babble.run(whine)

@@ -116,0 +116,0 @@ });

@@ -19,28 +19,13 @@ var babble = require('../index');

function yes() {
return 'yes';
}
function ok () {
return 'ok';
}
function no () {
return 'no';
}
emma.listen('do you have time today?')
.decide(decideIfAvailable, {
yes: babble.reply(yes)
yes: babble.tell('yes')
.listen()
.decide(decideToAgree, {
ok: babble.reply(ok),
no: babble.reply(no)
ok: babble.tell('ok'),
no: babble.tell('no')
}),
no: babble.reply(no)
no: babble.tell('no')
});
function askToMeet () {
return 'can we meet at 15:00?';
}
function noTime () {

@@ -51,3 +36,3 @@ console.log('emma has no time');

function agreesToMeet (response) {
return (response == 'ok') ? 'ok': 'notOk';
return (response == 'ok') ? 'ok': 'no';
}

@@ -65,8 +50,9 @@

.decide({
yes: babble.reply(askToMeet)
yes: babble.tell('can we meet at 15:00?')
.listen()
.decide(agreesToMeet, {
ok: babble.run(agreement),
notOk: babble.run(noAgreement)
no: babble.run(noAgreement)
}),
no: babble.run(noTime)
});

@@ -25,18 +25,25 @@ var babble = require('../index'),

function (err, babblers) {
babblers.emma.listen('ask age')
.reply(function (response) {
return 25;
babblers.emma.listen('hi')
.listen(printMessage)
.decide(function (message, context) {
return (message.indexOf('age') != -1) ? 'age' : 'name';
}, {
'name': babble.tell('hi, my name is emma'),
'age': babble.tell('hi, my age is 27')
});
babblers.emma.listen('tell age')
.run (function (age, context) {
console.log(context.from + ' is ' + age + ' years old');
});
babblers.jack.tell('emma', 'hi')
.tell(function (message, context) {
if (Math.random() > 0.5) {
return 'my name is jack'
} else {
return 'my age is 25';
}
})
.listen(printMessage);
});
babblers.jack.tell('emma', 'tell age', 27);
babblers.jack.ask('emma', 'ask age')
.run (function (age, context) {
console.log(context.from + ' is ' + age + ' years old');
});
});
function printMessage (message, context) {
console.log(context.from + ': ' + message);
return message;
}

@@ -5,2 +5,13 @@ # babble history

## not yet released, version 0.5.0
- Messages can now be of any type, not only string.
- Consistency of API improved.
## 2014-01-10, version 0.4.0
- API changed into a chained API.
## 2014-01-03, version 0.3.1

@@ -7,0 +18,0 @@

var Babbler = require('./Babbler'),
Reply = require('./block/Reply'),
Tell = require('./block/Tell'),
Action = require('./block/Action'),

@@ -17,13 +17,19 @@ Decision = require('./block/Decision');

/**
* Create a control flow starting with a reply block
* @param {Function} callback Invoked as callback(message, context),
* where `message` is the output from the previous
* block in the chain, and `context` is an object
* where state can be stored during a conversation.
* The result returned by the function will be
* send back to the sender.
* @return {Reply} reply
* Create a control flow starting with a tell block
* @param {* | Function} [message] A static message or callback function
* returning a message dynamically.
* When `message` is a function, it will be
* invoked as callback(message, context),
* where `message` is the output from the
* previous block in the chain, and `context` is
* an object where state can be stored during a
* conversation.
* @return {Tell} tell
*/
exports.reply = function reply(callback) {
return new Reply(callback);
exports.tell = function tell(message) {
var callback = (typeof message === 'function') ? message : function () {
return message;
};
return new Tell(callback);
};

@@ -88,3 +94,3 @@

Listen: require('./block/Listen'),
Reply: require('./block/Reply')
Tell: require('./block/Tell')
};

@@ -91,0 +97,0 @@

@@ -7,3 +7,3 @@ var uuid = require('node-uuid'),

Action = require('./block/Action'),
Reply = require('./block/Reply'),
Tell = require('./block/Tell'),
Listen = require('./block/Listen');

@@ -71,13 +71,17 @@

id: this.id,
message: function (message) {
var conversation, trigger;
//console.log('message', me.id, message); // TODO: cleanup
message: function (envelope) {
var conversation,
trigger,
message = JSON.parse(envelope.message);
//console.log('message', me.id, envelope); // TODO: cleanup
// check the open conversations
conversation = me.conversations[message.id];
conversation = me.conversations[envelope.id];
if (conversation) {
me._run(conversation, message.message);
me._run(conversation, message);
}
else {
// check the listeners to start a new conversation
trigger = me.listeners[message.message];
trigger = me.listeners[message];
if (trigger) {

@@ -87,11 +91,11 @@ //console.log('message create a new conversation', trigger, trigger.callback); // TODO: cleanup

conversation = {
id: message.id,
peer: message.from,
id: envelope.id,
peer: envelope.from,
next: trigger,
context: {
from: message.from
from: envelope.from
}
};
me._run(conversation, message.data);
me._run(conversation, message);
}

@@ -157,36 +161,15 @@ }

/**
* Send a notification
* Send a message to the other peer
* Creates a block Tell, and runs the block immediately.
* @param {String} id Babbler id
* @param {String} message
* @param {JSON} [data] Data must be serializable
* @param {Function | *} message
* @return {Block} block Last block in the created control flow
*/
Babbler.prototype.tell = function tell (id, message, data) {
this.publish(id, {
from: this.id,
to: id,
message: message,
data: data
});
};
/**
* Send a question, listen for a response
* @param {String} id Babbler id
* @param {String} message
* @param {JSON} [data] Data must be serializable
* @param {Function} [callback] Callback called
* @return {Block} block Start block for the control flow
*/
Babbler.prototype.ask = function ask (id, message, data, callback) {
Babbler.prototype.tell = function tell (id, message) {
var cid = uuid.v4(); // create an id for this conversation
if (typeof data === 'function') {
callback = data;
data = undefined;
}
var block = new Tell();
var block = new Listen(callback);
// create a new conversation
this.conversations[cid] = {
var conversation = {
id: cid,

@@ -200,10 +183,24 @@ peer: id,

this.publish(id, {
id: cid,
from: this.id,
to: id,
message: message,
data: data
});
// override the `then` function, so we can immediately execute chained blocks
// until we encounter a Listen block.
var me = this;
block.then = function then (next) {
conversation.next = next;
if (next instanceof Listen) {
// add to the conversations queue
me.conversations[cid] = conversation;
}
else {
// execute immediately
message = me._run(conversation, message);
next.then = then;
}
return next;
};
// run the Tell block immediately
message = this._run(conversation, message);
return block;

@@ -213,9 +210,24 @@ };

/**
* Send a question, listen for a response.
* Creates two blocks: Tell and Listen, and runs them immediately.
* @param {String} id Babbler id
* @param {* | Function} message
* @param {Function} [callback] Callback called
* @return {Block} block Last block in the created control flow
*/
Babbler.prototype.ask = function ask (id, message, callback) {
return this
.tell(id, message)
.listen(callback);
};
/**
* Run next block for given conversation
* @param {Object} conversation
* @param {*} [message]
* @return {*} message Response returned by the last executed block
* @private
*/
Babbler.prototype._run = function _run (conversation, message) {
//console.log('_run', conversation, message); // TODO: cleanup
// console.log('_run', conversation, message); // TODO: cleanup

@@ -229,4 +241,7 @@ // remove the conversation from the queue

var next = block.execute(message, conversation.context);
message = next.result;
if (block instanceof Reply) {
// TODO: only select result as next message when !== undefined?
if (block instanceof Tell) {
// send a response back to the other peer

@@ -237,8 +252,7 @@ this.publish(conversation.peer, {

to: conversation.peer,
message: next.result
message: JSON.stringify(message)
});
}
message = next.result;
block = next.block;
block = next.block;
//console.log('message', message); // TODO: cleanup

@@ -253,4 +267,6 @@

while (block && !(block instanceof Listen));
return message;
};
module.exports = Babbler;
{
"name": "babble",
"version": "0.4.0",
"version": "0.5.0",
"description": "Dynamic communication flows between message based actors.",

@@ -5,0 +5,0 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",

@@ -6,4 +6,4 @@ # Babble

Babble makes it easy to code communication flows between actors. A conversation
is modeled as a control flow diagram containing blocks `listen`, `ask`, `tell`,
`reply`, `decide`, and `run`. Each block can link to a next block in the
is modeled as a control flow diagram containing blocks `ask`, `tell`, `listen`,
`decide`, and `run`. Each block can link to a next block in the
control flow. Conversations are dynamic: a scenario is build programmatically,

@@ -61,8 +61,7 @@ and the blocks can dynamically determine the next block in the scenario.

emma.listen('ask age')
.reply(function () {
.tell(function () {
return 25;
}));
jack.ask('emma', 'ask age')
.run(function (age, context) {
jack.ask('emma', 'ask age', function (age, context) {
console.log(context.from + ' is ' + age + ' years old');

@@ -79,15 +78,15 @@ }));

### Ask a question
### Say hi
Babble can be used to listen for messages and send a reply. In the following
example, emma listens for two messages: "ask age" and "tell age". In the first
case she will reply telling her age, in the second case she just outputs the
received age. Jack first tells his age, and then asks emma's age, waits for
her to reply, and then output the received age.
example, emma listens for a message "hi", then she will listen to the next
message. Depending on the contents of this second message, she determines how
to respond. Jack says hi to emma, then tells his name or age, and awaits a
response from emma.
This scenario can be represented by the following control flow diagram:
![ask age](https://raw.github.com/josdejong/babble/master/img/ask_age.jpg)
![ask age](https://raw.github.com/josdejong/babble/master/img/say_hi.png)
The scenario is programmed as:
The scenario can be programmed as:

@@ -100,21 +99,28 @@ ```js

emma.listen('ask age')
.reply(function () {
return 25;
});
function printMessage (message, context) {
console.log(context.from + ': ' + message);
return message;
}
emma.listen('tell age')
.run(function (age, context) {
console.log(context.from + ' is ' + age + ' years old');
emma.listen('hi')
.listen(printMessage)
.decide(function (message, context) {
return (message.indexOf('age') != -1) ? 'age' : 'name';
}, {
'name': babble.tell('hi, my name is emma'),
'age': babble.tell('hi, my age is 27')
});
jack.tell('emma', 'tell age', 27);
jack.ask('emma', 'ask age')
.run(function (age, context) {
console.log(context.from + ' is ' + age + ' years old');
});
jack.tell('emma', 'hi')
.tell(function (message, context) {
if (Math.random() > 0.5) {
return 'my name is jack'
} else {
return 'my age is 25';
}
})
.listen(printMessage);
```
### Have a conversation
### Plan a meeting

@@ -127,3 +133,3 @@ The following scenario describes two peers planning a meeting in two steps:

![plan a meeting](https://raw.github.com/josdejong/babble/master/img/plan_a_meeting.jpg)
![plan a meeting](https://raw.github.com/josdejong/babble/master/img/plan_a_meeting.png)

@@ -152,28 +158,13 @@ The scenario can be coded as follows. Note that the implementations of the

function yes() {
return 'yes';
}
function ok () {
return 'ok';
}
function no () {
return 'no';
}
emma.listen('do you have time today?')
.decide(decideIfAvailable, {
yes: babble.reply(yes)
yes: babble.tell('yes')
.listen()
.decide(decideToAgree, {
ok: babble.reply(ok),
no: babble.reply(no)
ok: babble.tell('ok'),
no: babble.tell('no')
}),
no: babble.reply(no)
no: babble.tell('no')
});
function askToMeet () {
return 'can we meet at 15:00?';
}
function noTime () {

@@ -184,3 +175,3 @@ console.log('emma has no time');

function agreesToMeet (response) {
return (response == 'ok') ? 'ok': 'notOk';
return (response == 'ok') ? 'ok': 'no';
}

@@ -198,9 +189,11 @@

.decide({
yes: babble.reply(askToMeet)
yes: babble.tell('can we meet at 15:00?')
.listen()
.decide(agreesToMeet, {
ok: babble.run(agreement),
notOk: babble.run(noAgreement)
no: babble.run(noAgreement)
}),
no: babble.run(noTime)
});
```

@@ -227,7 +220,8 @@

The returned block is used as next block in the control flow.
- `babble.reply(callback: Function) : Block`
Create a flow starting with a Reply block. The provided callback function
- `babble.tell(message: Function | *) : Block`
Create a flow starting with a Tell block. Message can be a static value,
or a callback function returning a message dynamically. The callback function
is called as `callback(response, context)`, where `response` is the latest
received message, and must return a result. The returned result is send to the
connected peer.
received message, and must return a result.
The returned result is send to the connected peer.
- `babble.then(block: Block) : Block`

@@ -246,3 +240,3 @@ Create a flow starting with given block. The provided callback function

- `babble.block.Decision`
- `babble.block.Reply`
- `babble.block.Tell`
- `babble.block.Start`

@@ -278,8 +272,8 @@

- `tell(id: String, message: String [, data: JSON])`
- `tell(id: String, message: Function | *)`
Send a notification to another peer.
- `ask(id: String, message: String [,data: JSON] [, callback: Function]) : Block`
Send a question to another peer. Returns a `start` Block which is executed
When the reply comes in. Other blocks can be chained to the returned block.
- `ask(id: String, message: String [, callback: Function]) : Block`
Send a question to another peer. Other blocks can be chained to the returned
block.

@@ -289,4 +283,4 @@ ### Block

Blocks can be created via the factory functions available in `babble`
(`reply`, `decide`, `run`, `then`, `listen`), or in a Babbler (`listen`, `ask`).
Blocks can be chained together, resulting in a control flow. The results
(`tell`, `decide`, `run`, `then`, `listen`), or in a Babbler (`listen`, `tell`,
`ask`). Blocks can be chained together, resulting in a control flow. The results
returned by blocks are used as input argument for the next block in the chain.

@@ -299,5 +293,5 @@

chain.
- `reply(callback: Function) : Block`
Append a Reply block to the control flow. Returns the first block in the
chain.
- `tell(message: *) : 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.
- `listen([callback: Function]) : Block`

@@ -304,0 +298,0 @@ Append a Listen block to the control flow. Returns the first block in the

@@ -5,3 +5,3 @@ var assert = require('assert'),

Reply = require('../lib/block/Reply'),
Tell = require('../lib/block/Tell'),
Decision = require('../lib/block/Decision'),

@@ -21,5 +21,5 @@ Action = require('../lib/block/Action');

it('should create a flow starting with a reply block', function() {
var block = babble.reply(function () {});
assert.ok(block instanceof Reply);
it('should create a flow starting with a tell block', function() {
var block = babble.tell(function () {});
assert.ok(block instanceof Tell);
});

@@ -36,4 +36,2 @@

});
// TODO: test reply, decide, run
});
var assert = require('assert'),
Babbler = require('../lib/Babbler'),
Block = require('../lib/block/Block'),
Reply = require('../lib/block/Reply'),
Tell = require('../lib/block/Tell'),
Action = require('../lib/block/Action'),

@@ -28,3 +28,3 @@ Decision = require('../lib/block/Decision');

it.skip('should create and destroy a babbler', function() {
it('should create and destroy a babbler', function() {
var susan = new Babbler('susan').subscribe();

@@ -35,3 +35,3 @@ assert.ok(susan instanceof Babbler);

it.skip('should throw an error when creating a babbler with wrong syntax', function() {
it('should throw an error when creating a babbler with wrong syntax', function() {
assert.throws (function () {new Babbler(); });

@@ -41,6 +41,6 @@ assert.throws (function () {Babbler('whoops'); });

describe.skip ('listen', function () {
describe ('listen', function () {
it ('should listen to a message', function () {
emma.listen('test', new Block());
emma.listen('test');

@@ -57,8 +57,7 @@ assert.equal(Object.keys(emma.listeners).length, 1);

describe.skip ('tell', function () {
describe ('tell', function () {
it('should tell a message', function(done) {
emma.listen('test')
.run(function (data) {
assert.equal(data, null);
emma.listen('test', function (response) {
assert.equal(response, 'test');
done();

@@ -70,12 +69,34 @@ });

it('should tell a message with data', function(done) {
emma.listen('test')
.run(function (data) {
assert.deepEqual(data, {a:2, b:3});
it('should tell two messages subsequently', function(done) {
emma.listen('foo')
.listen(function (response) {
assert.deepEqual(response, 'bar');
done();
});
jack.tell('emma', 'test', {a:2, b:3});
jack.tell('emma', 'foo')
.tell('bar');
});
it('should chain some blocks to a Tell block', function(done) {
emma.listen('foo')
.listen(function (response) {
assert.equal(response, 'bar');
})
.tell('bye');
jack.tell('emma', 'foo')
.run(function (response) {
assert.equal(response, 'foo');
return 'bar';
})
.tell(function (response) {
return response;
})
.listen(function (response) {
assert.equal(response, 'bye');
done();
});
});
});

@@ -85,10 +106,10 @@

it('should ask a question and reply', function(done) {
emma.listen('add')
.reply(function (data) {
return data.a + data.b;
it('should send a message and listen for a reply', function(done) {
emma.listen('what is your name?')
.tell(function (message) {
return 'emma';
});
jack.ask('emma', 'add', {a:2, b:3}, function (result) {
assert.equal(result, 5);
jack.ask('emma', 'what is your name?', function (result) {
assert.equal(result, 'emma');
done();

@@ -98,5 +119,7 @@ });

it ('should ask a question, reply, and reply on the reply', function(done) {
emma.listen('count')
.reply(function (count) {
it ('should send a message, listen, and send a reply', function(done) {
emma.listen('count', function () {
return 0;
})
.tell(function (count) {
return count + 1;

@@ -109,4 +132,4 @@ })

jack.ask('emma', 'count', 0)
.reply(function (count) {
jack.ask('emma', 'count')
.tell(function (count) {
return count + 2;

@@ -116,14 +139,36 @@ });

it ('should invoke the callback provided with listen', function(done) {
emma.listen('age', function (response) {
assert.equal(response, 32);
it ('should send an object as reply', function(done) {
emma.listen('test')
.tell(function (response) {
return {a: 2, b: 3}
});
jack.ask('emma', 'test', function (response) {
assert.deepEqual(response, {a: 2, b: 3});
done();
});
});
jack.tell('emma', 'age', 32);
it ('should send an object as reply (2)', function(done) {
emma.listen('test')
.tell({a: 2, b: 3});
jack.ask('emma', 'test', function (response) {
assert.deepEqual(response, {a: 2, b: 3});
done();
});
});
it ('should invoke the callback provided with listener', function(done) {
emma.listen('what is you age?', function (response) {
assert.equal(response, 'what is you age?');
done();
});
jack.tell('emma', 'what is you age?');
});
it ('should invoke the callback provided with ask', function(done) {
emma.listen('age')
.reply(function () {
.tell(function () {
return 32;

@@ -138,18 +183,5 @@ });

it ('should invoke the callback provided with an ask with data', function(done) {
emma.listen('double')
.reply(function (value) {
return value * 2;
});
jack.ask('emma', 'double', 2, function (response) {
assert.equal(response, 4);
done();
});
});
it('should make a decision during a conversation', function(done) {
emma.listen('are you available?')
.reply(function (data) {
assert.strictEqual(data, undefined);
.tell(function (response) {
return 'yes';

@@ -177,3 +209,3 @@ });

})
.reply(function (response) {
.tell(function (response) {
logs.push('log 2');

@@ -198,3 +230,5 @@ assert.strictEqual(response, undefined);

it ('should keep state in the context during the conversation', function(done) {
emma.listen('question')
emma.listen('question', function () {
return 'a';
})
.run(function (response, context) {

@@ -210,3 +244,3 @@ context.a = 1;

}, {
first: new Reply(function (response, context) {
first: new Tell(function (response, context) {
assert.equal(response, 'a');

@@ -228,3 +262,3 @@ assert.equal(context.a, 1);

jack.ask('emma', 'question', 'a')
jack.ask('emma', 'question')
.run(function (response, context) {

@@ -234,3 +268,3 @@ context.a = 1;

})
.reply(function (response, context) {
.tell(function (response, context) {
assert.equal(response, 'b');

@@ -237,0 +271,0 @@ assert.equal(context.a, 1);

# TO DO
- Introduce flow blocks Listen and Send?
- Listen to patterns
- Implement error handling
- Implement support for promises to allow async callback functions
- Store message history in context.
- What to do with initial message and data, whilst subsequent calls only have
message? -> rename this stuff? an initial `event` with optional `message`,
and sequential only a `message`.
- implement conversations with multiple peers at the same time.

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc