blinksocks/build/blinksocks.js
2017-08-22 11:08:25 +08:00

28 lines
205 KiB
JavaScript

/*!
* Copyright (c) 2016-present, blinksocks. All rights reserved.
*
* name: blinksocks.js
* version: v2.5.4
* hash: d8c9f3dd65e6e83d6b61
*/
module.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(n,'a',n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=36)}([function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(50);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(53);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var a=n(54);Object.keys(a).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});const n=t.CONNECTION_CREATED='connection/created',r=t.CONNECTION_CLOSED='connection/closed',o=t.PRESET_INIT='preset/init',a=t.SOCKET_CONNECT_TO_REMOTE='socket/connect/to/remote',s=t.PROCESSING_FAILED='processing/failed';t.IPreset=class{onNotified(){return!1}beforeOut({buffer:e}){return e}beforeIn({buffer:e}){return e}clientOut({buffer:e}){return e}serverIn({buffer:e}){return e}serverOut({buffer:e}){return e}clientIn({buffer:e}){return e}}},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(88);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(89);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e){e.exports=require('events')},function(e){e.exports=require('fs')},function(e){e.exports=require('crypto')},function(e){e.exports=require('net')},function(e){e.exports=require('util')},function(e){e.exports=require('os')},function(e,t,n){'use strict';var r=n(7),o=n(5),a=n(58),s=n(4),i=n(59).StringDecoder,l=n(11).Stream,d=n(16);t.setLevels=function(e,n,r){this;return n&&Object.keys(n).forEach(function(t){delete e[t]}),e.levels=r||d.npm.levels,e.padLevels&&(e.levelLength=t.longestElement(Object.keys(e.levels))),Object.keys(e.levels).forEach(function(t){return'log'===t?void console.warn('Log level named "log" will clash with the method "log". Consider using a different name.'):void(e[t]=function(){var n=[t].concat(Array.prototype.slice.call(arguments));e.log.apply(e,n)})}),e},t.longestElement=function(e){return Math.max.apply(null,e.map(function(e){return e.length}))},t.clone=function(e){var n={};if(e instanceof Error)return n={message:e.message},Object.getOwnPropertyNames(e).forEach(function(t){n[t]=e[t]}),n;if(!(e instanceof Object))return e;if(e instanceof Date)return new Date(e.getTime());for(var r in e)Array.isArray(e[r])?n[r]=e[r].slice(0):e[r]instanceof Buffer?n[r]=e[r].slice(0):'function'==typeof e[r]?'function'==typeof e[r]&&(n[r]=e[r]):n[r]=e[r]instanceof Object?t.clone(e[r]):e[r];return n},t.log=function(e){var n='function'==typeof e.timestamp?e.timestamp:t.timestamp,o=e.timestamp?n():null,s=void 0===e.showLevel||e.showLevel,i=null===e.meta||void 0===e.meta||e.meta instanceof Error?e.meta||null:t.clone(a.decycle(e.meta)),l;if(e.raw)return'object'!=typeof i&&null!=i&&(i={meta:i}),l=t.clone(i)||{},l.level=e.level,l.message=e.message.stripColors?e.message.stripColors:e.message,JSON.stringify(l);if(e.json||!0===e.logstash){if('object'!=typeof i&&null!=i&&(i={meta:i}),l=t.clone(i)||{},l.level=e.level,l.message=l.message||'',e.label&&(l.label=e.label),e.message&&(l.message=e.message),o&&(l.timestamp=o),!0===e.logstash){var c={};void 0!==l.message&&(c['@message']=l.message,delete l.message),void 0!==l.timestamp&&(c['@timestamp']=l.timestamp,delete l.timestamp),c['@fields']=t.clone(l),l=c}return'function'==typeof e.stringify?e.stringify(l):JSON.stringify(l,function(e,t){return t instanceof Buffer?t.toString('base64'):t})}if('function'==typeof e.formatter)return e.meta=i,e.formatter(t.clone(e))+'';if(l=o?o+' - ':'',s&&(l+='all'===e.colorize||'level'===e.colorize||!0===e.colorize?d.colorize(e.level):e.level),l+=e.align?'\t':'',l+=o||s?': ':'',l+=e.label?'['+e.label+'] ':'',l+='all'===e.colorize||'message'===e.colorize?d.colorize(e.level,e.message):e.message,null!==i&&void 0!==i)if(i&&i instanceof Error&&i.stack&&(i=i.stack),'object'!=typeof i)l+=' '+i;else if(0<Object.keys(i).length)if('function'==typeof e.prettyPrint)l+=' '+e.prettyPrint(i);else if(e.prettyPrint)l+=' \n'+r.inspect(i,!1,e.depth||null,e.colorize);else if(e.humanReadableUnhandledException&&5===Object.keys(i).length&&i.hasOwnProperty('date')&&i.hasOwnProperty('process')&&i.hasOwnProperty('os')&&i.hasOwnProperty('trace')&&i.hasOwnProperty('stack')){var u=i.stack;delete i.stack,delete i.trace,l+=' '+t.serialize(i),u&&(l+='\n'+u.join('\n'))}else l+=' '+t.serialize(i);return l},t.capitalize=function(e){return e&&e[0].toUpperCase()+e.slice(1)},t.hash=function(e){return o.createHash('sha1').update(e).digest('hex')},t.pad=function(e){return 10>e?'0'+e.toString(10):e.toString(10)},t.timestamp=function(){return new Date().toISOString()},t.serialize=function(e,n){if('symbol'==typeof n&&(n=n.toString()),'symbol'==typeof e&&(e=e.toString()),null===e?e='null':void 0===e?e='undefined':!1===e&&(e='false'),'object'!=typeof e)return n?n+'='+e:e;if(e instanceof Buffer)return n?n+'='+e.toString('base64'):e.toString('base64');for(var r='',o=Object.keys(e),a=o.length,s=0;s<a;s++){if(Array.isArray(e[o[s]])){r+=o[s]+'=[';for(var i=0,d=e[o[s]].length;i<d;i++)r+=t.serialize(e[o[s]][i]),i<d-1&&(r+=', ');r+=']'}else r+=e[o[s]]instanceof Date?o[s]+'='+e[o[s]]:t.serialize(e[o[s]],o[s]);s<a-1&&(r+=', ')}return r},t.tailFile=function(e,t){var n=new Buffer(65536),r=new i('utf8'),o=new l,a='',d=0,c=0;return-1===e.start&&delete e.start,o.readable=!0,o.destroy=function(){o.destroyed=!0,o.emit('end'),o.emit('close')},s.open(e.file,'a+','0644',function(i,l){return i?(t?t(i):o.emit('error',i),void o.destroy()):void function u(){return o.destroyed?void s.close(l):s.read(l,n,0,n.length,d,function(s,p){if(s)return t?t(s):o.emit('error',s),void o.destroy();if(!p)return a&&((null==e.start||c>e.start)&&(t?t(null,a):o.emit('line',a)),c++,a=''),setTimeout(u,1e3);var m=r.write(n.slice(0,p));t||o.emit('data',m);for(var m=(a+m).split(/\n+/),g=m.length-1,l=0;l<g;l++)(null==e.start||c>e.start)&&(t?t(null,m[l]):o.emit('line',m[l])),c++;return a=m[g],d+=p,u()})}()}),t?o.destroy:o},t.stringArrayToSet=function(e,t){return'undefined'==typeof t&&(t='Cannot make set from Array with non-string elements'),e.reduce(function(e,n){if(!('string'==typeof n||n instanceof String))throw new Error(t);return e[n]=!0,e},Object.create(null))}},function(e,t,n){'use strict';var r=t;r.version=n(55).version,r.transports=n(56);var o=n(9);r.hash=o.hash,r.clone=o.clone,r.longestElement=o.longestElement,r.exception=n(30),r.config=n(16),r.addColors=r.config.addColors,r.Container=n(80).Container,r.Logger=n(81).Logger,r.Transport=n(15).Transport,r.loggers=new r.Container;var a=new r.Logger({transports:[new r.transports.Console]});o.setLevels(r,null,a.levels),['log','query','stream','add','remove','clear','profile','startTimer','extend','cli','handleExceptions','unhandleExceptions','configure'].forEach(function(e){r[e]=function(){return a[e].apply(a,arguments)}}),r.cli=function(){return r.padLevels=!0,o.setLevels(r,a.levels,r.config.cli.levels),a.setLevels(r.config.cli.levels),r.config.addColors(r.config.cli.colors),a.transports.console&&(a.transports.console.colorize=!0,a.transports.console.timestamp=!1),r},r.setLevels=function(e){o.setLevels(r,a.levels,e),a.setLevels(e)},Object.defineProperty(r,'level',{get:function(){return a.level},set:function(e){a.level=e,Object.keys(a.transports).forEach(function(t){a.transports[t].level=e})}}),['emitErrs','exitOnError','padLevels','levelLength','stripColors'].forEach(function(e){Object.defineProperty(r,e,{get:function(){return a[e]},set:function(t){a[e]=t}})}),Object.defineProperty(r,'default',{get:function(){return{transports:a.transports,exceptionHandlers:a.exceptionHandlers}}})},function(e){e.exports=require('stream')},function(e){e.exports=require('path')},function(e,t,n){'use strict';function r(e){return e?e.toLowerCase():'ipv4'}var o=t,a=n(51).Buffer,s=n(8);o.toBuffer=function(e,t,n){n=~~n;var r;if(this.isV4Format(e))r=t||new a(n+4),e.split(/\./g).map(function(e){r[n++]=255&parseInt(e,10)});else if(this.isV6Format(e)){var o=e.split(':',8),s;for(s=0;s<o.length;s++){var i=this.isV4Format(o[s]),l;i&&(l=this.toBuffer(o[s]),o[s]=l.slice(0,2).toString('hex')),l&&8>++s&&o.splice(s,0,l.slice(2,4).toString('hex'))}if(''===o[0])for(;8>o.length;)o.unshift('0');else if(''===o[o.length-1])for(;8>o.length;)o.push('0');else if(8>o.length){for(s=0;s<o.length&&''!==o[s];s++);var d=[s,1];for(s=9-o.length;0<s;s--)d.push('0');o.splice.apply(o,d)}for(r=t||new a(n+16),s=0;s<o.length;s++){var c=parseInt(o[s],16);r[n++]=255&c>>8,r[n++]=255&c}}if(!r)throw Error('Invalid ip address: '+e);return r},o.toString=function(e,t,n){t=~~t,n=n||e.length-t;var r=[];if(4===n){for(var o=0;o<n;o++)r.push(e[t+o]);r=r.join('.')}else if(16===n){for(var o=0;o<n;o+=2)r.push(e.readUInt16BE(t+o).toString(16));r=r.join(':'),r=r.replace(/(^|:)0(:0)*:0(:|$)/,'$1::$3'),r=r.replace(/:{3,4}/,'::')}return r};var i=/^(\d{1,3}\.){3,3}\d{1,3}$/,l=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;o.isV4Format=function(e){return i.test(e)},o.isV6Format=function(e){return l.test(e)},o.fromPrefixLen=function(e,t){t=32<e?'ipv6':r(t);var s=4;'ipv6'===t&&(s=16);for(var l=new a(s),d=0,i=l.length,n;d<i;++d)n=8,8>e&&(n=e),e-=n,l[d]=255&~(255>>n);return o.toString(l)},o.mask=function(e,t){e=o.toBuffer(e),t=o.toBuffer(t);var n=new a(Math.max(e.length,t.length)),r=0;if(e.length===t.length)for(r=0;r<e.length;r++)n[r]=e[r]&t[r];else if(4===t.length)for(r=0;r<t.length;r++)n[r]=e[e.length-4+r]&t[r];else{for(var r=0;r<n.length-6;r++)n[r]=0;for(n[10]=255,n[11]=255,r=0;r<e.length;r++)n[r+12]=e[r]&t[r+12];r+=12}for(;r<n.length;r++)n[r]=0;return o.toString(n)},o.cidr=function(e){var t=e.split('/'),n=t[0];if(2!==t.length)throw new Error('invalid CIDR subnet: '+n);var r=o.fromPrefixLen(parseInt(t[1],10));return o.mask(n,r)},o.subnet=function(e,t){for(var n=o.toLong(o.mask(e,t)),r=o.toBuffer(t),a=0,s=0;s<r.length;s++)if(255===r[s])a+=8;else for(var i=255&r[s];i;)i=255&i<<1,a++;var l=Math.pow(2,32-a);return{networkAddress:o.fromLong(n),firstAddress:2>=l?o.fromLong(n):o.fromLong(n+1),lastAddress:2>=l?o.fromLong(n+l-1):o.fromLong(n+l-2),broadcastAddress:o.fromLong(n+l-1),subnetMask:t,subnetMaskLength:a,numHosts:2>=l?l:l-2,length:l,contains:function(e){return n===o.toLong(o.mask(e,t))}}},o.cidrSubnet=function(e){var t=e.split('/'),n=t[0];if(2!==t.length)throw new Error('invalid CIDR subnet: '+n);var r=o.fromPrefixLen(parseInt(t[1],10));return o.subnet(n,r)},o.not=function(e){for(var t=o.toBuffer(e),n=0;n<t.length;n++)t[n]=255^t[n];return o.toString(t)},o.or=function(e,t){if(e=o.toBuffer(e),t=o.toBuffer(t),e.length===t.length){for(var n=0;n<e.length;++n)e[n]|=t[n];return o.toString(e)}var r=e,a=t;t.length>e.length&&(r=t,a=e);for(var s=r.length-a.length,n=s;n<r.length;++n)r[n]|=a[n-s];return o.toString(r)},o.isEqual=function(e,n){if(e=o.toBuffer(e),n=o.toBuffer(n),e.length===n.length){for(var r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}if(4===n.length){var a=n;n=e,e=a}for(var r=0;10>r;r++)if(0!==n[r])return!1;var t=n.readUInt16BE(10);if(0!==t&&65535!==t)return!1;for(var r=0;4>r;r++)if(e[r]!==n[r+12])return!1;return!0},o.isPrivate=function(e){return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^f[cd][0-9a-f]{2}:/i.test(e)||/^fe80:/i.test(e)||/^::1$/.test(e)||/^::$/.test(e)},o.isPublic=function(e){return!o.isPrivate(e)},o.isLoopback=function(e){return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(e)||/^fe80::1$/.test(e)||/^::1$/.test(e)||/^::$/.test(e)},o.loopback=function(e){if(e=r(e),'ipv4'!==e&&'ipv6'!==e)throw new Error('family must be ipv4 or ipv6');return'ipv4'===e?'127.0.0.1':'fe80::1'},o.address=function(e,t){var n=s.networkInterfaces(),a;if(t=r(t),e&&'private'!==e&&'public'!==e){var i=n[e].filter(function(e){var n=e.family.toLowerCase();return n===t});return 0===i.length?void 0:i[0].address}var a=Object.keys(n).map(function(r){var a=n[r].filter(function(n){return(n.family=n.family.toLowerCase(),!(n.family!==t||o.isLoopback(n.address)))&&(!e||('public'===e?o.isPrivate(n.address):o.isPublic(n.address)))});return a.length?a[0].address:void 0}).filter(Boolean);return a.length?a[0]:o.loopback(t)},o.toLong=function(e){var t=0;return e.split('.').forEach(function(e){t<<=8,t+=parseInt(e)}),t>>>0},o.fromLong=function(e){return(e>>>24)+'.'+(255&e>>16)+'.'+(255&e>>8)+'.'+(255&e)}},function(e,t,n){'use strict';function r(e){var t=function e(){return o.apply(e,arguments)};return t._styles=e,t.__proto__=m,t}function o(){var e=arguments,t=e.length,n=0!==t&&arguments[0]+'';if(1<t)for(var r=1;r<t;r++)n+=' '+e[r];if(!s.enabled||!n)return n;for(var o=this._styles,a=o.length,i;a--;)i=l[o[a]],n=i.open+n.replace(i.closeRe,i.open)+i.close;return n}function a(e){for(var t in e)(function(t){s[t]=function(n){return s[e[t]](n)}})(t)}var s={};e.exports=s,s.themes={};var l=s.styles=n(61),i=Object.defineProperties;s.supportsColor=n(62),'undefined'==typeof s.enabled&&(s.enabled=s.supportsColor),s.stripColors=s.strip=function(e){return(''+e).replace(/\x1B\[\d+m/g,'')};var d=s.stylize=function(e,t){return l[t].open+e+l[t].close},c=/[|\\{}()[\]^$+*?.]/g,u=function(e){if('string'!=typeof e)throw new TypeError('Expected a string');return e.replace(c,'\\$&')},p=function(){var e={};return l.grey=l.gray,Object.keys(l).forEach(function(t){l[t].closeRe=new RegExp(u(l[t].close),'g'),e[t]={get:function(){return r(this._styles.concat(t))}}}),e}(),m=i(function(){},p);s.setTheme=function(e){if('string'==typeof e)try{return s.themes[e]=!function(){var t=new Error('Cannot find module "."');throw t.code='MODULE_NOT_FOUND',t}(),a(s.themes[e]),s.themes[e]}catch(e){return console.log(e),e}else a(e)};var g=function(e,t){var n=t.split('');return n=n.map(e),n.join('')};for(var f in s.trap=n(64),s.zalgo=n(65),s.maps={},s.maps.america=n(66),s.maps.zebra=n(67),s.maps.rainbow=n(68),s.maps.random=n(69),s.maps)(function(e){s[e]=function(t){return g(s.maps[e],t)}})(f);i(s,function(){var e={};return Object.keys(p).forEach(function(t){e[t]={get:function(){return r([t])}}}),e}())},function(e,t,n){'use strict';var r=n(3),o=n(7),a=t.Transport=function(e){r.EventEmitter.call(this),e=e||{},this.silent=e.silent||!1,this.raw=e.raw||!1,this.name=e.name||this.name,this.formatter=e.formatter,this.level=e.level,this.handleExceptions=e.handleExceptions||!1,this.exceptionsLevel=e.exceptionsLevel||'error',this.humanReadableUnhandledException=e.humanReadableUnhandledException||!1};o.inherits(a,r.EventEmitter),a.prototype.formatQuery=function(e){return e},a.prototype.normalizeQuery=function(e){return e=e||{},e.rows=e.rows||e.limit||10,e.start=e.start||0,e.until=e.until||new Date,'object'!=typeof e.until&&(e.until=new Date(e.until)),e.from=e.from||e.until-86400000,'object'!=typeof e.from&&(e.from=new Date(e.from)),e.order=e.order||'desc',e.fields=e.fields,e},a.prototype.formatResults=function(e){return e},a.prototype.logException=function(e,t,n){function r(){a||(a=!0,o.removeListener('logged',r),o.removeListener('error',r),n())}var o=this,a;return this.silent?n():void(this.once('logged',r),this.once('error',r),this.log(o.exceptionsLevel,e,t,function(){}))}},function(e,t,n){'use strict';function r(e){var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){for(var n=Object.keys(t),r=0;r<n.length;r++)e[n[r]]=t[n[r]]}),e}var o=n(60);o.enabled=!0;var a=t,s=t.allColors={};a.addColors=function(e){r(s,e)},a.colorize=function(e,t){'undefined'==typeof t&&(t=e);var n=t;if(s[e]instanceof Array)for(var r=0,a=s[e].length;r<a;++r)n=o[s[e][r]](n);else if(s[e].match(/\s/)){for(var i=s[e].split(/\s+/),r=0;r<i.length;++r)n=o[i[r]](n);s[e]=i}else n=o[s[e]](n);return n},a.cli=n(70),a.npm=n(71),a.syslog=n(72),a.addColors(a.cli.colors),a.addColors(a.npm.colors),a.addColors(a.syslog.colors)},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0}),t.behaviours=t.behaviourEvents=t.getBehaviourClassByName=t.BEHAVIOUR_EVENT_ON_PRESET_FAILED=void 0;var o=n(83),a=r(o),s=n(84),i=r(s),l=n(85),d=r(l);const c=t.BEHAVIOUR_EVENT_ON_PRESET_FAILED='on-preset-failed',u={"direct-close":a.default,"random-timeout":i.default,redirect:d.default},p=Object.keys(u);t.getBehaviourClassByName=function(e){const t=u[e];if(t===void 0)throw Error(`cannot find behaviour: "${e}"`);return t},t.behaviourEvents=[c],t.behaviours=p},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0}),t.presets=t.getPresetClassByName=void 0;var o=n(86),a=r(o),s=n(103),i=r(s),l=n(104),d=r(l),c=n(105),u=r(c),p=n(106),m=r(p),g=n(107),f=r(g),h=n(108),_=r(h),y=n(109),b=r(y),v=n(110),k=r(v),E=n(111),x=r(E),T=n(112),S=r(T),P=n(114),O=r(P);const R={proxy:a.default,tunnel:i.default,stats:d.default,tracker:u.default,"exp-base-with-padding":m.default,"exp-base-auth-stream":f.default,"ss-base":_.default,"ss-stream-cipher":b.default,"ss-aead-cipher":k.default,"aead-random-cipher":x.default,"obfs-http":S.default,"obfs-tls1.2-ticket":O.default},w=Object.keys(R);t.getPresetClassByName=function(e){const t=R[e];if(t===void 0)throw Error(`cannot find preset: "${e}"`);return t},t.presets=w},function(e,t,n){'use strict';function r(e,t){t=t||{};const n=c?c.level:0;e.level=t.level===void 0?n:t.level,e.enabled='enabled'in t?t.enabled:0<e.level}function o(e){if(!this||!(this instanceof o)||this.template){const t={};return r(t,e),t.template=function(){const e=[].slice.call(arguments);return i.apply(null,[t.template].concat(e))},Object.setPrototypeOf(t,o.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=o,t.template}r(this,e)}function a(e,t){const n=function e(){return s.apply(e,arguments)};n._styles=e;const r=this;return Object.defineProperty(n,'level',{enumerable:!0,get(){return r.level},set(e){r.level=e}}),Object.defineProperty(n,'enabled',{enumerable:!0,get(){return r.enabled},set(e){r.enabled=e}}),n.hasGrey=this.hasGrey||'gray'===t||'grey'===t,n.__proto__=D,n}function s(){const e=arguments,t=e.length;let n=arguments[0]+'';if(0===t)return'';if(1<t)for(let r=1;r<t;r++)n+=' '+e[r];if(!this.enabled||0>=this.level||!n)return n;const r=d.dim.open;p&&this.hasGrey&&(d.dim.open='');var o=!0,a=!1,s;try{for(var i=this._styles.slice().reverse()[Symbol.iterator](),l;!(o=(l=i.next()).done);o=!0){const e=l.value;n=e.open+n.replace(e.closeRe,e.open)+e.close,n=n.replace(/\r?\n/g,`${e.close}$&${e.open}`)}}catch(e){a=!0,s=e}finally{try{!o&&i.return&&i.return()}finally{if(a)throw s}}return d.dim.open=r,n}function i(e,t){if(!Array.isArray(t))return[].slice.call(arguments,1).join(' ');const n=[].slice.call(arguments,2),r=[t.raw[0]];for(let o=1;o<t.length;o++)r.push((n[o-1]+'').replace(/[{}\\]/g,'\\$&')),r.push(t.raw[o]+'');return u(e,r.join(''))}const l=n(37),d=n(38),c=n(42),u=n(44),p='win32'===process.platform&&!(process.env.TERM||'').toLowerCase().startsWith('xterm'),m=['ansi','ansi','ansi256','ansi16m'],g=new Set(['gray']),f=Object.create(null);p&&(d.blue.open='\x1B[94m');var h=!0,_=!1,y;try{for(var b=Object.keys(d)[Symbol.iterator](),v;!(h=(v=b.next()).done);h=!0){const e=v.value;d[e].closeRe=new RegExp(l(d[e].close),'g'),f[e]={get(){const t=d[e];return a.call(this,this._styles?this._styles.concat(t):[t],e)}}}}catch(e){_=!0,y=e}finally{try{!h&&b.return&&b.return()}finally{if(_)throw y}}d.color.closeRe=new RegExp(l(d.color.close),'g');var k=!0,E=!1,x;try{for(var T=Object.keys(d.color.ansi)[Symbol.iterator](),S;!(k=(S=T.next()).done);k=!0){const e=S.value;g.has(e)||(f[e]={get(){const t=this.level;return function(){const n=d.color[m[t]][e].apply(null,arguments),r={open:n,close:d.color.close,closeRe:d.color.closeRe};return a.call(this,this._styles?this._styles.concat(r):[r],e)}}})}}catch(e){E=!0,x=e}finally{try{!k&&T.return&&T.return()}finally{if(E)throw x}}d.bgColor.closeRe=new RegExp(l(d.bgColor.close),'g');var P=!0,O=!1,R;try{for(var w=Object.keys(d.bgColor.ansi)[Symbol.iterator](),C;!(P=(C=w.next()).done);P=!0){const e=C.value;if(g.has(e))continue;const t='bg'+e[0].toUpperCase()+e.slice(1);f[t]={get(){const t=this.level;return function(){const n=d.bgColor[m[t]][e].apply(null,arguments),r={open:n,close:d.bgColor.close,closeRe:d.bgColor.closeRe};return a.call(this,this._styles?this._styles.concat(r):[r],e)}}}}}catch(e){O=!0,R=e}finally{try{!P&&w.return&&w.return()}finally{if(O)throw R}}const D=Object.defineProperties(()=>{},f);Object.defineProperties(o.prototype,f),e.exports=o(),e.exports.supportsColor=c},function(e){'use strict';e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],!e.children&&(e.children=[]),Object.defineProperty(e,'loaded',{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,'id',{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){'use strict';function r(e,t){return d(e[0]-t[0],2)+d(e[1]-t[1],2)+d(e[2]-t[2],2)}var o=Math.round,s=Math.PI,a=Math.floor,i=Math.min,d=Math.pow,c=Math.max,l=n(40),u={};for(var p in l)l.hasOwnProperty(p)&&(u[l[p]]=p);var m=e.exports={rgb:{channels:3,labels:'rgb'},hsl:{channels:3,labels:'hsl'},hsv:{channels:3,labels:'hsv'},hwb:{channels:3,labels:'hwb'},cmyk:{channels:4,labels:'cmyk'},xyz:{channels:3,labels:'xyz'},lab:{channels:3,labels:'lab'},lch:{channels:3,labels:'lch'},hex:{channels:1,labels:['hex']},keyword:{channels:1,labels:['keyword']},ansi16:{channels:1,labels:['ansi16']},ansi256:{channels:1,labels:['ansi256']},hcg:{channels:3,labels:['h','c','g']},apple:{channels:3,labels:['r16','g16','b16']},gray:{channels:1,labels:['gray']}};for(var g in m)if(m.hasOwnProperty(g)){if(!('channels'in m[g]))throw new Error('missing channels property: '+g);if(!('labels'in m[g]))throw new Error('missing channel labels property: '+g);if(m[g].labels.length!==m[g].channels)throw new Error('channel and label counts mismatch: '+g);var f=m[g].channels,h=m[g].labels;delete m[g].channels,delete m[g].labels,Object.defineProperty(m[g],'channels',{value:f}),Object.defineProperty(m[g],'labels',{value:h})}m.rgb.hsl=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255,o=i(t,n,r),a=c(t,n,r),d=a-o,u,p,s;return a===o?u=0:t===a?u=(n-r)/d:n===a?u=2+(r-t)/d:r===a&&(u=4+(t-n)/d),u=i(60*u,360),0>u&&(u+=360),s=(o+a)/2,p=a===o?0:0.5>=s?d/(a+o):d/(2-a-o),[u,100*p,100*s]},m.rgb.hsv=function(e){var t=e[0],n=e[1],r=e[2],o=i(t,n,r),a=c(t,n,r),l=a-o,d,u,s;return u=0===a?0:1e3*(l/a)/10,a===o?d=0:t===a?d=(n-r)/l:n===a?d=2+(r-t)/l:r===a&&(d=4+(t-n)/l),d=i(60*d,360),0>d&&(d+=360),s=1e3*(a/255)/10,[d,u,s]},m.rgb.hwb=function(e){var t=e[0],n=e[1],r=e[2],o=m.rgb.hsl(e)[0],a=1/255*i(t,i(n,r));return r=1-1/255*c(t,c(n,r)),[o,100*a,100*r]},m.rgb.cmyk=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255,o,a,s,l;return l=i(1-t,1-n,1-r),o=(1-t-l)/(1-l)||0,a=(1-n-l)/(1-l)||0,s=(1-r-l)/(1-l)||0,[100*o,100*a,100*s,100*l]},m.rgb.keyword=function(e){var t=u[e];if(t)return t;var n=Infinity,o;for(var a in l)if(l.hasOwnProperty(a)){var s=l[a],i=r(e,s);i<n&&(n=i,o=a)}return o},m.keyword.rgb=function(e){return l[e]},m.rgb.xyz=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255;t=0.04045<t?d((t+0.055)/1.055,2.4):t/12.92,n=0.04045<n?d((n+0.055)/1.055,2.4):n/12.92,r=0.04045<r?d((r+0.055)/1.055,2.4):r/12.92;var o=0.4124*t+0.3576*n+0.1805*r,a=0.2126*t+0.7152*n+0.0722*r,s=0.0193*t+0.1192*n+0.9505*r;return[100*o,100*a,100*s]},m.rgb.lab=function(e){var t=m.rgb.xyz(e),n=t[0],r=t[1],o=t[2],s,i,a;return n/=95.047,r/=100,o/=108.883,n=0.008856<n?d(n,1/3):7.787*n+16/116,r=0.008856<r?d(r,1/3):7.787*r+16/116,o=0.008856<o?d(o,1/3):7.787*o+16/116,s=116*r-16,i=500*(n-r),a=200*(r-o),[s,i,a]},m.hsl.rgb=function(e){var t=e[0]/360,n=e[1]/100,r=e[2]/100,o,a,s,l,d;if(0==n)return d=255*r,[d,d,d];a=0.5>r?r*(1+n):r+n-r*n,o=2*r-a,l=[0,0,0];for(var c=0;3>c;c++)s=t+1/3*-(c-1),0>s&&s++,1<s&&s--,d=1>6*s?o+6*(a-o)*s:1>2*s?a:2>3*s?o+6*((a-o)*(2/3-s)):o,l[c]=255*d;return l},m.hsl.hsv=function(e){var t=e[0],n=e[1]/100,r=e[2]/100,o=n,a=c(r,0.01),s,i;return r*=2,n*=1>=r?r:2-r,o*=1>=a?a:2-a,i=(r+n)/2,s=0==r?2*o/(a+o):2*n/(r+n),[t,100*s,100*i]},m.hsv.rgb=function(e){var n=e[0]/60,r=e[1]/100,o=e[2]/100,s=a(n)%6,i=n-a(n),l=255*o*(1-r),d=255*o*(1-r*i),c=255*o*(1-r*(1-i));return o*=255,0==s?[o,c,l]:1==s?[d,o,l]:2==s?[l,o,c]:3==s?[l,d,o]:4==s?[c,l,o]:5==s?[o,l,d]:void 0},m.hsv.hsl=function(e){var t=e[0],n=e[1]/100,r=e[2]/100,o=c(r,0.01),a,s,i;return i=(2-n)*r,a=(2-n)*o,s=n*o,s/=1>=a?a:2-a,s=s||0,i/=2,[t,100*s,100*i]},m.hwb.rgb=function(e){var t=e[0]/360,o=e[1]/100,s=e[2]/100,l=o+s,d,i,c,u;1<l&&(o/=l,s/=l),d=a(6*t),i=1-s,c=6*t-d,0!=(1&d)&&(c=1-c),u=o+c*(i-o);var n,r,p;switch(d){default:case 6:case 0:n=i,r=u,p=o;break;case 1:n=u,r=i,p=o;break;case 2:n=o,r=i,p=u;break;case 3:n=o,r=u,p=i;break;case 4:n=u,r=o,p=i;break;case 5:n=i,r=o,p=u;}return[255*n,255*r,255*p]},m.cmyk.rgb=function(e){var t=e[0]/100,n=e[1]/100,o=e[2]/100,a=e[3]/100,s,r,l;return s=1-i(1,t*(1-a)+a),r=1-i(1,n*(1-a)+a),l=1-i(1,o*(1-a)+a),[255*s,255*r,255*l]},m.xyz.rgb=function(e){var t=e[0]/100,n=e[1]/100,o=e[2]/100,a,r,s;return a=3.2406*t+-1.5372*n+-0.4986*o,r=-0.9689*t+1.8758*n+0.0415*o,s=0.0557*t+-0.204*n+1.057*o,a=0.0031308<a?1.055*d(a,1/2.4)-0.055:12.92*a,r=0.0031308<r?1.055*d(r,1/2.4)-0.055:12.92*r,s=0.0031308<s?1.055*d(s,1/2.4)-0.055:12.92*s,a=i(c(0,a),1),r=i(c(0,r),1),s=i(c(0,s),1),[255*a,255*r,255*s]},m.xyz.lab=function(e){var t=e[0],n=e[1],r=e[2],o,s,a;return t/=95.047,n/=100,r/=108.883,t=0.008856<t?d(t,1/3):7.787*t+16/116,n=0.008856<n?d(n,1/3):7.787*n+16/116,r=0.008856<r?d(r,1/3):7.787*r+16/116,o=116*n-16,s=500*(t-n),a=200*(n-r),[o,s,a]},m.lab.xyz=function(e){var t=e[0],n=e[1],r=e[2],o,a,s;a=(t+16)/116,o=n/500+a,s=a-r/200;var i=d(a,3),l=d(o,3),c=d(s,3);return a=0.008856<i?i:(a-16/116)/7.787,o=0.008856<l?l:(o-16/116)/7.787,s=0.008856<c?c:(s-16/116)/7.787,o*=95.047,a*=100,s*=108.883,[o,a,s]},m.lab.lch=function(e){var t=e[0],n=e[1],r=e[2],o,a,i;return o=Math.atan2(r,n),a=360*o/2/s,0>a&&(a+=360),i=Math.sqrt(n*n+r*r),[t,i,a]},m.lch.lab=function(e){var t=e[0],n=e[1],r=e[2],o,a,i;return i=2*(r/360)*s,o=n*Math.cos(i),a=n*Math.sin(i),[t,o,a]},m.rgb.ansi16=function(e){var t=e[0],n=e[1],r=e[2],a=1 in arguments?arguments[1]:m.rgb.hsv(e)[2];if(a=o(a/50),0===a)return 30;var s=30+(o(r/255)<<2|o(n/255)<<1|o(t/255));return 2===a&&(s+=60),s},m.hsv.ansi16=function(e){return m.rgb.ansi16(m.hsv.rgb(e),e[2])},m.rgb.ansi256=function(e){var t=e[0],n=e[1],r=e[2];if(t===n&&n===r)return 8>t?16:248<t?231:o(24*((t-8)/247))+232;var a=16+36*o(5*(t/255))+6*o(5*(n/255))+o(5*(r/255));return a},m.ansi16.rgb=function(e){var t=e%10;if(0==t||7==t)return 50<e&&(t+=3.5),t=255*(t/10.5),[t,t,t];var n=0.5*(~~(50<e)+1),o=255*((1&t)*n),r=255*((1&t>>1)*n),a=255*((1&t>>2)*n);return[o,r,a]},m.ansi256.rgb=function(e){if(232<=e){var t=10*(e-232)+8;return[t,t,t]}e-=16;var n=255*(a(e/36)/5),r=255*(a((s=e%36)/6)/5),o=255*(s%6/5),s;return[n,r,o]},m.rgb.hex=function(e){var t=((255&o(e[0]))<<16)+((255&o(e[1]))<<8)+(255&o(e[2])),n=t.toString(16).toUpperCase();return'000000'.substring(n.length)+n},m.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var n=t[0];3===t[0].length&&(n=n.split('').map(function(e){return e+e}).join(''));var r=parseInt(n,16);return[255&r>>16,255&r>>8,255&r]},m.rgb.hcg=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255,o=c(c(t,n),r),a=i(i(t,n),r),s=o-a,l,d;return l=1>s?a/(1-s):0,d=0>=s?0:o===t?(n-r)/s%6:o===n?2+(r-t)/s:4+(t-n)/s+4,d/=6,d%=1,[360*d,100*s,100*l]},m.hsl.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=1,o=0;return r=0.5>n?2*t*n:2*t*(1-n),1>r&&(o=(n-0.5*r)/(1-r)),[e[0],100*r,100*o]},m.hsv.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=t*n,o=0;return 1>r&&(o=(n-r)/(1-r)),[e[0],100*r,100*o]},m.hcg.rgb=function(e){var t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0==n)return[255*r,255*r,255*r];var o=[0,0,0],s=6*(t%1),i=s%1,l=1-i,d=0;switch(a(s)){case 0:o[0]=1,o[1]=i,o[2]=0;break;case 1:o[0]=l,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=i;break;case 3:o[0]=0,o[1]=l,o[2]=1;break;case 4:o[0]=i,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=l;}return d=(1-n)*r,[255*(n*o[0]+d),255*(n*o[1]+d),255*(n*o[2]+d)]},m.hcg.hsv=function(e){var t=e[1]/100,n=e[2]/100,r=t+n*(1-t),o=0;return 0<r&&(o=t/r),[e[0],100*o,100*r]},m.hcg.hsl=function(e){var t=e[1]/100,n=e[2]/100,r=n*(1-t)+0.5*t,o=0;return 0<r&&0.5>r?o=t/(2*r):0.5<=r&&1>r&&(o=t/(2*(1-r))),[e[0],100*o,100*r]},m.hcg.hwb=function(e){var t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],100*(r-t),100*(1-r)]},m.hwb.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=1-n,o=r-t,a=0;return 1>o&&(a=(r-o)/(1-o)),[e[0],100*o,100*a]},m.apple.rgb=function(e){return[255*(e[0]/65535),255*(e[1]/65535),255*(e[2]/65535)]},m.rgb.apple=function(e){return[65535*(e[0]/255),65535*(e[1]/255),65535*(e[2]/255)]},m.gray.rgb=function(e){return[255*(e[0]/100),255*(e[0]/100),255*(e[0]/100)]},m.gray.hsl=m.gray.hsv=function(e){return[0,0,e[0]]},m.gray.hwb=function(e){return[0,100,e[0]]},m.gray.cmyk=function(e){return[0,0,0,e[0]]},m.gray.lab=function(e){return[e[0],0,0]},m.gray.hex=function(e){var t=255&o(255*(e[0]/100)),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return'000000'.substring(n.length)+n},m.rgb.gray=function(e){var t=(e[0]+e[1]+e[2])/3;return[100*(t/255)]}},function(e){e.exports=require('cluster')},function(e){function t(e){throw new Error('Cannot find module \''+e+'\'.')}t.keys=function(){return[]},t.resolve=t,e.exports=t,t.id=23},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.Balancer=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(6),a=function(e){return e&&e.__esModule?e:{default:e}}(o),s=n(0);const l=()=>new Date().getTime();class i{static start(e,t=12e4){if(1>e.length)throw Error('servers cannot be empty');this._servers=e.map((e,t)=>r({id:t},e)),this._pings=this._servers.map(()=>0),this._startQuery(t)}static destroy(){this._stopQuery()}static getFastest(){let e=0;const t=this._pings;for(let n=0;n<t.length;++n){const r=t[n];(0<r&&r<t[e]||0>=t[e])&&(e=n)}return this._servers[e]}static _startQuery(e){1<this._servers.length&&(null!==this._timer&&this._stopQuery(),this._timer=setInterval(()=>this._query(),e),this._query())}static _stopQuery(){clearInterval(this._timer),this._timer=null}static _query(){this._servers.map((e,t)=>{const n=`${e.host}:${e.port}`;s.logger.verbose(`[balancer] querying ${n}`);const r=l(),o=a.default.connect({host:e.host,port:e.port},()=>{const e=l()-r;this._pings[t]=e,s.logger.verbose(`[balancer] ${n} = ${e}ms`),o.end()});o.on('error',()=>{this._pings[t]=-1,s.logger.warn(`[balancer] ${n} lost connection`)})})}}t.Balancer=i,i._servers=[],i._pings=[],i._timer=null},function(e,t,n){'use strict';(function(e){var r;(function(o){function a(e){throw new RangeError(C[e])}function s(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function i(e,t){var n=e.split('@'),r='';1<n.length&&(r=n[0]+'@',e=n[1]),e=e.replace(w,'.');var o=e.split('.'),a=s(o,t).join('.');return r+a}function l(e){for(var t=[],n=0,r=e.length,o,a;n<r;)o=e.charCodeAt(n++),55296<=o&&56319>=o&&n<r?(a=e.charCodeAt(n++),56320==(64512&a)?t.push(((1023&o)<<10)+(1023&a)+65536):(t.push(o),n--)):t.push(o);return t}function d(e){return s(e,function(e){var t='';return 65535<e&&(e-=65536,t+=I(55296|1023&e>>>10),e=56320|1023&e),t+=I(e),t}).join('')}function c(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:b}function u(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function p(e,t,n){var r=0;for(e=n?N(e/T):e>>1,e+=N(e/t);e>D*E>>1;r+=b)e=N(e/D);return N(r+(D+1)*e/(e+x))}function m(e){var r=[],o=e.length,s=0,i=P,n=S,l,u,m,g,f,h,_,k,x,t;for(u=e.lastIndexOf(O),0>u&&(u=0),m=0;m<u;++m)128<=e.charCodeAt(m)&&a('not-basic'),r.push(e.charCodeAt(m));for(g=0<u?u+1:0;g<o;){for(f=s,h=1,_=b;;_+=b){if(g>=o&&a('invalid-input'),k=c(e.charCodeAt(g++)),(k>=b||k>N((y-s)/h))&&a('overflow'),s+=k*h,x=_<=n?v:_>=n+E?E:_-n,k<x)break;t=b-x,h>N(y/t)&&a('overflow'),h*=t}l=r.length+1,n=p(s-f,l,0==f),N(s/l)>y-i&&a('overflow'),i+=N(s/l),s%=l,r.splice(s++,0,i)}return d(r)}function g(e){var r=[],o,n,s,i,d,c,g,m,f,h,t,_,k,x,T;for(e=l(e),_=e.length,o=P,n=0,d=S,c=0;c<_;++c)t=e[c],128>t&&r.push(I(t));for(s=i=r.length,i&&r.push(O);s<_;){for(g=y,c=0;c<_;++c)t=e[c],t>=o&&t<g&&(g=t);for(k=s+1,g-o>N((y-n)/k)&&a('overflow'),n+=(g-o)*k,o=g,c=0;c<_;++c)if(t=e[c],t<o&&++n>y&&a('overflow'),t==o){for(m=n,f=b;;f+=b){if(h=f<=d?v:f>=d+E?E:f-d,m<h)break;T=m-h,x=b-h,r.push(I(u(h+T%x,0))),m=N(T/x)}r.push(I(u(m,0))),d=p(n,k,s==i),n=0,++s}++n,++o}return r.join('')}var f='object'==typeof t&&t&&!t.nodeType&&t,h='object'==typeof e&&e&&!e.nodeType&&e,_='object'==typeof global&&global;(_.global===_||_.window===_||_.self===_)&&(o=_);var y=2147483647,b=36,v=1,E=26,x=38,T=700,S=72,P=128,O='-',k=/^xn--/,R=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:'Overflow: input needs wider integers to process',"not-basic":'Illegal input >= 0x80 (not a basic code point)',"invalid-input":'Invalid input'},D=b-v,N=Math.floor,I=String.fromCharCode,M;M={version:'1.3.2',ucs2:{decode:l,encode:d},decode:m,encode:g,toASCII:function(e){return i(e,function(e){return R.test(e)?'xn--'+g(e):e})},toUnicode:function(e){return i(e,function(e){return k.test(e)?m(e.slice(4).toLowerCase()):e})}};r=function(){return M}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))})(void 0)}).call(t,n(20)(e))},function(e,t,n){'use strict';var r,o;(function(a,s){'object'==typeof e&&e.exports?e.exports=s():(r=s,o='function'==typeof r?r.call(t,n,t,e):r,!(o!==void 0&&(e.exports=o)))})(void 0,function(e){var t=e&&e.IPv6;return{best:function(e){var t=e.toLowerCase(),n=t.split(':'),r=n.length,o=8;''===n[0]&&''===n[1]&&''===n[2]?(n.shift(),n.shift()):''===n[0]&&''===n[1]?n.shift():''===n[r-1]&&''===n[r-2]&&n.pop(),r=n.length,-1!==n[r-1].indexOf('.')&&(o=7);var a;for(a=0;a<r&&''!==n[a];a++);if(a<o)for(n.splice(a,1,'0000');n.length<o;)n.splice(a,0,'0000');for(var s=0,i;s<o;s++){i=n[s].split('');for(var l=0;3>l&&'0'===i[0]&&1<i.length;l++)i.splice(0,1);n[s]=i.join('')}var d=-1,c=0,u=0,p=-1,m=!1;for(s=0;s<o;s++)m?'0'===n[s]?u+=1:(m=!1,u>c&&(d=p,c=u)):'0'===n[s]&&(m=!0,p=s,u=1);u>c&&(d=p,c=u),1<c&&n.splice(d,c,''),r=n.length;var g='';for(''===n[0]&&(g=':'),s=0;s<r&&(g+=n[s],s!==r-1);s++)g+=':';return''===n[r-1]&&(g+=':'),g},noConflict:function(){return e.IPv6===this&&(e.IPv6=t),this}}})},function(e,t,n){'use strict';var r,o;(function(a,s){'object'==typeof e&&e.exports?e.exports=s():(r=s,o='function'==typeof r?r.call(t,n,t,e):r,!(o!==void 0&&(e.exports=o)))})(void 0,function(e){var t=e&&e.SecondLevelDomains,n={list:{ac:' com gov mil net org ',ae:' ac co gov mil name net org pro sch ',af:' com edu gov net org ',al:' com edu gov mil net org ',ao:' co ed gv it og pb ',ar:' com edu gob gov int mil net org tur ',at:' ac co gv or ',au:' asn com csiro edu gov id net org ',ba:' co com edu gov mil net org rs unbi unmo unsa untz unze ',bb:' biz co com edu gov info net org store tv ',bh:' biz cc com edu gov info net org ',bn:' com edu gov net org ',bo:' com edu gob gov int mil net org tv ',br:' adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ',bs:' com edu gov net org ',bz:' du et om ov rg ',ca:' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',ck:' biz co edu gen gov info net org ',cn:' ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ',co:' com edu gov mil net nom org ',cr:' ac c co ed fi go or sa ',cy:' ac biz com ekloges gov ltd name net org parliament press pro tm ',do:' art com edu gob gov mil net org sld web ',dz:' art asso com edu gov net org pol ',ec:' com edu fin gov info med mil net org pro ',eg:' com edu eun gov mil name net org sci ',er:' com edu gov ind mil net org rochest w ',es:' com edu gob nom org ',et:' biz com edu gov info name net org ',fj:' ac biz com info mil name net org pro ',fk:' ac co gov net nom org ',fr:' asso com f gouv nom prd presse tm ',gg:' co net org ',gh:' com edu gov mil org ',gn:' ac com gov net org ',gr:' com edu gov mil net org ',gt:' com edu gob ind mil net org ',gu:' com edu gov net org ',hk:' com edu gov idv net org ',hu:' 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ',id:' ac co go mil net or sch web ',il:' ac co gov idf k12 muni net org ',in:' ac co edu ernet firm gen gov i ind mil net nic org res ',iq:' com edu gov i mil net org ',ir:' ac co dnssec gov i id net org sch ',it:' edu gov ',je:' co net org ',jo:' com edu gov mil name net org sch ',jp:' ac ad co ed go gr lg ne or ',ke:' ac co go info me mobi ne or sc ',kh:' com edu gov mil net org per ',ki:' biz com de edu gov info mob net org tel ',km:' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',kn:' edu gov net org ',kr:' ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ',kw:' com edu gov net org ',ky:' com edu gov net org ',kz:' com edu gov mil net org ',lb:' com edu gov net org ',lk:' assn com edu gov grp hotel int ltd net ngo org sch soc web ',lr:' com edu gov net org ',lv:' asn com conf edu gov id mil net org ',ly:' com edu gov id med net org plc sch ',ma:' ac co gov m net org press ',mc:' asso tm ',me:' ac co edu gov its net org priv ',mg:' com edu gov mil nom org prd tm ',mk:' com edu gov inf name net org pro ',ml:' com edu gov net org presse ',mn:' edu gov org ',mo:' com edu gov net org ',mt:' com edu gov net org ',mv:' aero biz com coop edu gov info int mil museum name net org pro ',mw:' ac co com coop edu gov int museum net org ',mx:' com edu gob net org ',my:' com edu gov mil name net org sch ',nf:' arts com firm info net other per rec store web ',ng:' biz com edu gov mil mobi name net org sch ',ni:' ac co com edu gob mil net nom org ',np:' com edu gov mil net org ',nr:' biz com edu gov info net org ',om:' ac biz co com edu gov med mil museum net org pro sch ',pe:' com edu gob mil net nom org sld ',ph:' com edu gov i mil net ngo org ',pk:' biz com edu fam gob gok gon gop gos gov net org web ',pl:' art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ',pr:' ac biz com edu est gov info isla name net org pro prof ',ps:' com edu gov net org plo sec ',pw:' belau co ed go ne or ',ro:' arts com firm info nom nt org rec store tm www ',rs:' ac co edu gov in org ',sb:' com edu gov net org ',sc:' com edu gov net org ',sh:' co com edu gov net nom org ',sl:' com edu gov net org ',st:' co com consulado edu embaixada gov mil net org principe saotome store ',sv:' com edu gob org red ',sz:' ac co org ',tr:' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',tt:' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',tw:' club com ebiz edu game gov idv mil net org ',mu:' ac co com gov net or org ',mz:' ac co edu gov org ',na:' co com ',nz:' ac co cri geek gen govt health iwi maori mil net org parliament school ',pa:' abo ac com edu gob ing med net nom org sld ',pt:' com edu gov int net nome org publ ',py:' com edu gov mil net org ',qa:' com edu gov mil net org ',re:' asso com nom ',ru:' ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ',rw:' ac co com edu gouv gov int mil net ',sa:' com edu gov med net org pub sch ',sd:' com edu gov info med net org tv ',se:' a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ',sg:' com edu gov idn net org per ',sn:' art com edu gouv org perso univ ',sy:' com edu gov mil net news org ',th:' ac co go in mi net or ',tj:' ac biz co com edu go gov info int mil name net nic org test web ',tn:' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',tz:' ac co go ne or ',ua:' biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ',ug:' ac co go ne or org sc ',uk:' ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ',us:' dni fed isa kids nsn ',uy:' com edu gub mil net org ',ve:' co com edu gob info mil net org web ',vi:' co com k12 net org ',vn:' ac biz com edu gov health info int name net org pro ',ye:' co com gov ltd me net org plc ',yu:' ac co edu gov org ',za:' ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ',zm:' ac co com edu gov net org sch ',com:'ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ',net:'gb jp se uk ',org:'ae',de:'com '},has:function(e){var t=e.lastIndexOf('.');if(0>=t||t>=e.length-1)return!1;var r=e.lastIndexOf('.',t-1);if(0>=r||r>=t-1)return!1;var o=n.list[e.slice(t+1)];return!!o&&0<=o.indexOf(' '+e.slice(r+1,t)+' ')},is:function(e){var t=e.lastIndexOf('.');if(0>=t||t>=e.length-1)return!1;var r=e.lastIndexOf('.',t-1);if(0<=r)return!1;var o=n.list[e.slice(t+1)];return!!o&&0<=o.indexOf(' '+e.slice(0,t)+' ')},get:function(e){var t=e.lastIndexOf('.');if(0>=t||t>=e.length-1)return null;var r=e.lastIndexOf('.',t-1);if(0>=r||r>=t-1)return null;var o=n.list[e.slice(t+1)];return o?0>o.indexOf(' '+e.slice(r+1,t)+' ')?null:e.slice(r+1):null},noConflict:function(){return e.SecondLevelDomains===this&&(e.SecondLevelDomains=t),this}};return n})},function(e,t){'use strict';var n,r;(function(){function o(e){var t=!1;return function(){if(t)throw new Error('Callback was already called.');t=!0,e.apply(i,arguments)}}var a={},s=function(){},i,l;i='object'==typeof window&&this===window?window:'object'==typeof global&&this===global?global:this,null!=i&&(l=i.async),a.noConflict=function(){return i.async=l,a};var d=Object.prototype.toString,c=Array.isArray||function(e){return'[object Array]'===d.call(e)},u=function(e,t){for(var n=-1,r=e.length;++n<r;)t(e[n],n,e)},p=function(e,t){for(var n=-1,r=e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o},m=function(e,t,n){return u(e,function(e,r,o){n=t(n,e,r,o)}),n},g=function(e,t){u(f(e),function(n){t(e[n],n)})},f=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},h=function(e,t){t=t||0;var n=-1,r=e.length;t&&(r-=t,r=0>r?0:r);for(var o=Array(r);++n<r;)o[n]=e[n+t];return o},_;'function'==typeof setImmediate&&(_=setImmediate),'undefined'!=typeof process&&process.nextTick?(a.nextTick=process.nextTick,a.setImmediate=_?function(e){_(e)}:a.nextTick):_?(a.nextTick=function(e){_(e)},a.setImmediate=a.nextTick):(a.nextTick=function(e){setTimeout(e,0)},a.setImmediate=a.nextTick),a.each=function(e,t,n){function r(t){t?(n(t),n=s):(a+=1,a>=e.length&&n())}if(n=n||s,!e.length)return n();var a=0;u(e,function(e){t(e,o(r))})},a.forEach=a.each,a.eachSeries=function(e,t,n){if(n=n||s,!e.length)return n();var r=0;(function o(){t(e[r],function(t){t?(n(t),n=s):(r+=1,r>=e.length?n():o())})})()},a.forEachSeries=a.eachSeries,a.eachLimit=function(e,t,n,r){var o=y(t);o.apply(null,[e,n,r])},a.forEachLimit=a.eachLimit;var y=function(e){return function(t,n,r){if(r=r||s,!t.length||0>=e)return r();var o=0,a=0,i=0;(function l(){if(o>=t.length)return r();for(;i<e&&a<t.length;)a+=1,i+=1,n(t[a-1],function(e){e?(r(e),r=s):(o+=1,i-=1,o>=t.length?r():l())})})()}};a.forEachOf=a.eachOf=function(e,t,n){n=n||function(){};var r=e.length||f(e).length,o=0;return r?void g(e,function(a,s){t(e[s],s,function(e){e?(n(e),n=function(){}):(o+=1,o===r&&n(null))})}):n()},a.forEachOfSeries=a.eachOfSeries=function(e,t,n){n=n||function(){};var r=f(e),o=r.length;if(!o)return n();var s=0;(function i(){var l=!0,d=r[s];t(e[d],d,function(e){e?(n(e),n=function(){}):(s+=1,s>=o?n(null):l?a.nextTick(i):i())}),l=!1})()},a.forEachOfLimit=a.eachOfLimit=function(e,t,n,r){b(t)(e,n,r)};var b=function(e){return function(t,n,r){r=r||function(){};var o=f(t),a=o.length;if(!a||0>=e)return r();var s=0,i=0,l=0;(function d(){if(s>=a)return r();for(;l<e&&i<a;){i+=1,l+=1;var c=o[i-1];n(t[c],c,function(e){e?(r(e),r=function(){}):(s+=1,l-=1,s>=a?r():d())})}})()}},v=function(e){return function(){var t=h(arguments);return e.apply(null,[a.each].concat(t))}},k=function(e,t){return function(){var n=h(arguments);return t.apply(null,[y(e)].concat(n))}},E=function(e){return function(){var t=h(arguments);return e.apply(null,[a.eachSeries].concat(t))}},x=function(e,t,n,r){if(t=p(t,function(e,t){return{index:t,value:e}}),!r)e(t,function(e,t){n(e.value,function(e){t(e)})});else{var o=[];e(t,function(e,t){n(e.value,function(n,r){o[e.index]=r,t(n)})},function(e){r(e,o)})}};a.map=v(x),a.mapSeries=E(x),a.mapLimit=function(e,t,n,r){return T(t)(e,n,r)};var T=function(e){return k(e,x)};a.reduce=function(e,t,n,r){a.eachSeries(e,function(e,r){n(t,e,function(e,n){t=n,r(e)})},function(e){r(e,t)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(e,t,n,r){var o=p(e,function(e){return e}).reverse();a.reduce(o,t,n,r)},a.foldr=a.reduceRight;var S=function(e,t,n,r){var o=[];t=p(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){n(e.value,function(n){n&&o.push(e),t()})},function(){r(p(o.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};a.filter=v(S),a.filterSeries=E(S),a.select=a.filter,a.selectSeries=a.filterSeries;var P=function(e,t,n,r){var o=[];t=p(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){n(e.value,function(n){n||o.push(e),t()})},function(){r(p(o.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};a.reject=v(P),a.rejectSeries=E(P);var O=function(e,t,n,r){e(t,function(e,t){n(e,function(n){n?(r(e),r=s):t()})},function(){r()})};a.detect=v(O),a.detectSeries=E(O),a.some=function(e,t,n){a.each(e,function(e,r){t(e,function(e){e&&(n(!0),n=s),r()})},function(){n(!1)})},a.any=a.some,a.every=function(e,t,n){a.each(e,function(e,r){t(e,function(e){e||(n(!1),n=s),r()})},function(){n(!0)})},a.all=a.every,a.sortBy=function(e,t,n){a.map(e,function(e,n){t(e,function(t,r){t?n(t):n(null,{value:e,criteria:r})})},function(e,t){if(e)return n(e);n(null,p(t.sort(function(e,t){var n=e.criteria,r=t.criteria;return n<r?-1:n>r?1:0}),function(e){return e.value}))})},a.auto=function(e,t){t=t||s;var n=f(e),r=n.length;if(!r)return t();var o={},l=[],i=function(e){l.unshift(e)},d=function(e){for(var t=0;t<l.length;t+=1)if(l[t]===e)return void l.splice(t,1)},p=function(){r--,u(l.slice(0),function(e){e()})};i(function(){if(!r){var e=t;t=s,e(null,o)}}),u(n,function(n){for(var r=c(e[n])?e[n]:[e[n]],l=function(e){var r=h(arguments,1);if(1>=r.length&&(r=r[0]),e){var i={};u(f(o),function(e){i[e]=o[e]}),i[n]=r,t(e,i),t=s}else o[n]=r,a.setImmediate(p)},g=r.slice(0,Math.abs(r.length-1))||[],_=g.length,y;_--;){if(!(y=e[g[_]]))throw new Error('Has inexistant dependency');if(c(y)&&!!~y.indexOf(n))throw new Error('Has cyclic dependencies')}var b=function(){return m(g,function(e,t){return e&&o.hasOwnProperty(t)},!0)&&!o.hasOwnProperty(n)};if(b())r[r.length-1](l,o);else{var v=function e(){b()&&(d(e),r[r.length-1](l,o))};i(v)}})},a.retry=function(e,t,n){var r=5,o=[];'function'==typeof e&&(n=t,t=e,e=r),e=parseInt(e,10)||r;var s=function(r,s){for(var i=function(e,t){return function(n){e(function(e,r){n(!e||t,{err:e,result:r})},s)}};e;)o.push(i(t,!(e-=1)));a.series(o,function(e,t){t=t[t.length-1],(r||n)(t.err,t.result)})};return n?s():s},a.waterfall=function(e,t){if(t=t||s,!c(e)){var n=new Error('First argument to waterfall must be an array of functions');return t(n)}if(!e.length)return t();(function e(n){return function(r){if(r)t.apply(null,arguments),t=s;else{var o=h(arguments,1),i=n.next();i?o.push(e(i)):o.push(t),a.setImmediate(function(){n.apply(null,o)})}}})(a.iterator(e))()};var R=function(e,t,n){if(n=n||s,c(t))e.map(t,function(e,t){e&&e(function(e){var n=h(arguments,1);1>=n.length&&(n=n[0]),t.call(null,e,n)})},n);else{var r={};e.each(f(t),function(e,n){t[e](function(t){var o=h(arguments,1);1>=o.length&&(o=o[0]),r[e]=o,n(t)})},function(e){n(e,r)})}};a.parallel=function(e,t){R({map:a.map,each:a.each},e,t)},a.parallelLimit=function(e,t,n){R({map:T(t),each:y(t)},e,n)},a.series=function(e,t){if(t=t||s,c(e))a.mapSeries(e,function(e,t){e&&e(function(e){var n=h(arguments,1);1>=n.length&&(n=n[0]),t.call(null,e,n)})},t);else{var n={};a.eachSeries(f(e),function(t,r){e[t](function(e){var o=h(arguments,1);1>=o.length&&(o=o[0]),n[t]=o,r(e)})},function(e){t(e,n)})}},a.iterator=function(e){return function t(n){var r=function t(){return e.length&&e[n].apply(null,arguments),t.next()};return r.next=function(){return n<e.length-1?t(n+1):null},r}(0)},a.apply=function(e){var t=h(arguments,1);return function(){return e.apply(null,t.concat(h(arguments)))}};var w=function(e,t,n,o){var a=[];e(t,function(e,t){n(e,function(e,n){a=a.concat(n||[]),t(e)})},function(e){o(e,a)})};a.concat=v(w),a.concatSeries=E(w),a.whilst=function(e,t,n){e()?t(function(r){return r?n(r):void a.whilst(e,t,n)}):n()},a.doWhilst=function(e,t,n){e(function(r){if(r)return n(r);var o=h(arguments,1);t.apply(null,o)?a.doWhilst(e,t,n):n()})},a.until=function(e,t,n){e()?n():t(function(r){return r?n(r):void a.until(e,t,n)})},a.doUntil=function(e,t,n){e(function(r){if(r)return n(r);var o=h(arguments,1);t.apply(null,o)?n():a.doUntil(e,t,n)})},a.queue=function(e,t){function n(e,t,n,r){return e.started||(e.started=!0),c(t)||(t=[t]),0===t.length?a.setImmediate(function(){e.drain&&e.drain()}):void u(t,function(t){var o={data:t,callback:'function'==typeof r?r:null};n?e.tasks.unshift(o):e.tasks.push(o),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),a.setImmediate(e.process)})}if(t===void 0)t=1;else if(0===t)throw new Error('Concurrency must not be zero');var r=0,s={tasks:[],concurrency:t,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(e,t){n(s,e,!1,t)},kill:function(){s.drain=null,s.tasks=[]},unshift:function(e,t){n(s,e,!0,t)},process:function(){if(!s.paused&&r<s.concurrency&&s.tasks.length){var t=s.tasks.shift();s.empty&&0===s.tasks.length&&s.empty(),r+=1;var n=function(){r-=1,t.callback&&t.callback.apply(t,arguments),s.drain&&0===s.tasks.length+r&&s.drain(),s.process()},a=o(n);e(t.data,a)}},length:function(){return s.tasks.length},running:function(){return r},idle:function(){return 0===s.tasks.length+r},pause:function(){!0===s.paused||(s.paused=!0)},resume:function(){if(!1!==s.paused){s.paused=!1;for(var e=Math.min(s.concurrency,s.tasks.length),t=1;t<=e;t++)a.setImmediate(s.process)}}};return s},a.priorityQueue=function(e,t){function n(e,t){return e.priority-t.priority}function r(e,t,n){for(var r=-1,o=e.length-1,a;r<o;)a=r+(o-r+1>>>1),0<=n(t,e[a])?r=a:o=a-1;return r}function o(e,t,o,s){return e.started||(e.started=!0),c(t)||(t=[t]),0===t.length?a.setImmediate(function(){e.drain&&e.drain()}):void u(t,function(t){var i={data:t,priority:o,callback:'function'==typeof s?s:null};e.tasks.splice(r(e.tasks,i,n)+1,0,i),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),a.setImmediate(e.process)})}var s=a.queue(e,t);return s.push=function(e,t,n){o(s,e,t,n)},delete s.unshift,s},a.cargo=function(e,t){var n=!1,r=[],o={tasks:r,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,n){c(e)||(e=[e]),u(e,function(e){r.push({data:e,callback:'function'==typeof n?n:null}),o.drained=!1,o.saturated&&r.length===t&&o.saturated()}),a.setImmediate(o.process)},process:function a(){if(!n){if(0===r.length)return o.drain&&!o.drained&&o.drain(),void(o.drained=!0);var s='number'==typeof t?r.splice(0,t):r.splice(0,r.length),i=p(s,function(e){return e.data});o.empty&&o.empty(),n=!0,e(i,function(){n=!1;var e=arguments;u(s,function(t){t.callback&&t.callback.apply(null,e)}),a()})}},length:function(){return r.length},running:function(){return n}};return o};var C=function(e){return function(t){var n=h(arguments,1);t.apply(null,n.concat([function(t){var n=h(arguments,1);'undefined'!=typeof console&&(t?console.error&&console.error(t):console[e]&&u(n,function(t){console[e](t)}))}]))}};a.log=C('log'),a.dir=C('dir'),a.memoize=function(e,t){var n={},r={};t=t||function(e){return e};var o=function(){var o=h(arguments),s=o.pop(),d=t.apply(null,o);d in n?a.nextTick(function(){s.apply(null,n[d])}):d in r?r[d].push(s):(r[d]=[s],e.apply(null,o.concat([function(){n[d]=h(arguments);var e=r[d];delete r[d];for(var t=0,o=e.length;t<o;t++)e[t].apply(null,arguments)}])))};return o.memo=n,o.unmemoized=e,o},a.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},a.times=function(e,t,n){for(var r=[],o=0;o<e;o++)r.push(o);return a.map(r,t,n)},a.timesSeries=function(e,t,n){for(var r=[],o=0;o<e;o++)r.push(o);return a.mapSeries(r,t,n)},a.seq=function(){var e=arguments;return function(){var t=this,n=h(arguments),r=n.pop();a.reduce(e,n,function(e,n,r){n.apply(t,e.concat([function(){var e=arguments[0],t=h(arguments,1);r(e,t)}]))},function(e,n){r.apply(t,[e].concat(n))})}},a.compose=function(){return a.seq.apply(null,Array.prototype.reverse.call(arguments))};var D=function(e,t){var n=function(){var n=this,r=h(arguments),o=r.pop();return e(t,function(e,t){e.apply(n,r.concat([t]))},o)};if(2<arguments.length){var r=h(arguments,2);return n.apply(this,r)}return n};a.applyEach=v(D),a.applyEachSeries=E(D),a.forever=function(e,t){function n(r){if(r){if(t)return t(r);throw r}e(n)}n()},'undefined'!=typeof e&&e.exports?e.exports=a:(n=[],r=function(){return a}.apply(t,n),!(r!==void 0&&(e.exports=r)))})()},function(e){e.exports=require('zlib')},function(e,t,n){'use strict';var r=n(8),o=n(79),a=t;a.getAllInfo=function(e){return{date:new Date().toString(),process:a.getProcessInfo(),os:a.getOsInfo(),trace:a.getTrace(e),stack:e.stack&&e.stack.split('\n')}},a.getProcessInfo=function(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}},a.getOsInfo=function(){return{loadavg:r.loadavg(),uptime:r.uptime()}},a.getTrace=function(e){var t=e?o.parse(e):o.get();return t.map(function(e){return{column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}})}},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0}),t.Config=t.DEFAULT_BEHAVIOURS=t.DEFAULT_LOG_LEVEL=void 0;var o=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},a=n(32),s=r(a),i=n(4),l=r(i),d=n(12),c=r(d),u=n(8),p=r(u),m=n(6),g=r(m),f=n(10),h=r(f),_=n(82),y=r(_),b=n(17),v=n(18),k=n(0),E=n(33);const x=t.DEFAULT_LOG_LEVEL='info',T=t.DEFAULT_BEHAVIOURS={[b.BEHAVIOUR_EVENT_ON_PRESET_FAILED]:{name:'random-timeout',params:{min:10,max:40}}};t.Config=class{static validate(e){if(!(0,y.default)(e))throw Error('invalid configuration file');if('string'!=typeof e.host||''===e.host)throw Error('\'host\' must be provided and is not empty');if(!(0,k.isValidPort)(e.port))throw Error('\'port\' is invalid');if(void 0!==e.behaviours){if(!(0,y.default)(e.behaviours))throw Error('\'behaviours\' is invalid');const i=Object.keys(e.behaviours);var t=!0,n=!1,r;try{for(var o=i[Symbol.iterator](),a;!(t=(a=o.next()).done);t=!0){const t=a.value;if(!b.behaviourEvents.includes(t))throw Error(`unrecognized behaviour event: "${t}"`);var s=e.behaviours[t];const n=s.name,r=s.params;if('string'!=typeof n)throw Error('\'behaviours[].name\' must be a string');if(''===n)throw Error('\'behaviours[].name\' cannot be empty');if(void 0!==r&&!(0,y.default)(r))throw Error('\'behaviours[].params\' must be an plain object');const o=(0,b.getBehaviourClassByName)(n);delete new o(r||{})}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}}if(void 0!==e.servers){if(!Array.isArray(e.servers))throw Error('\'servers\' must be provided as an array');const t=e.servers.filter((e)=>!0===e.enabled);if(1>t.length)throw Error('\'servers\' must have at least one enabled item');t.forEach(this.validateServer)}else this.validateServer(e);if(void 0!==e.timeout){if('number'!=typeof e.timeout)throw Error('\'timeout\' must be a number');if(1>e.timeout)throw Error('\'timeout\' must be greater than 0');60>e.timeout&&console.warn(`==> [config] 'timeout' is too short, is ${e.timeout}s expected?`)}if(void 0!==e.log_path&&'string'!=typeof e.log_path)throw Error('\'log_path\' must be a string');if(void 0!==e.log_level){const t=['error','warn','info','verbose','debug','silly'];if(!t.includes(e.log_level))throw Error(`'log_level' must be one of [${t.toString()}]`)}if(void 0!==e.workers){if('number'!=typeof e.workers)throw Error('\'workers\' must be a number');if(0>e.workers)throw Error('\'workers\' must be an integer');e.workers>p.default.cpus().length&&console.warn(`==> [config] 'workers' is greater than the number of cpus, is ${e.workers} workers expected?`)}if(void 0!==e.dns){if(!Array.isArray(e.dns))throw Error('\'dns\' must be an array');var i=!0,l=!1,d;try{for(var c=e.dns[Symbol.iterator](),u;!(i=(u=c.next()).done);i=!0){const e=u.value;if(!g.default.isIP(e))throw Error(`"${e}" is not an ip address`)}}catch(e){l=!0,d=e}finally{try{!i&&c.return&&c.return()}finally{if(l)throw d}}}if(void 0!==e.dns_expire){if('number'!=typeof e.dns_expire)throw Error('\'dns_expire\' must be a number');if(0>e.dns_expire)throw Error('\'dns_expire\' must be greater or equal to 0');86400<e.dns_expire&&console.warn(`==> [config] 'dns_expire' is too long, is ${e.dns_expire}s expected?`)}}static validateServer(e){if(e.transport!==void 0){if(!['tcp','tls'].includes(e.transport))throw Error('\'server.transport\' must be "tcp" or "tls"');if('tls'===e.transport){if('string'!=typeof e.tls_cert)throw Error('\'server.tls_key\' must be a string');if(''===e.tls_cert)throw Error('\'server.tls_cert\' cannot be empty')}}if(!(0,k.isValidHostname)(e.host))throw Error('\'server.host\' is invalid');if(!(0,k.isValidPort)(e.port))throw Error('\'server.port\' is invalid');if('string'!=typeof e.key||''===e.key)throw Error('\'server.key\' must be a non-empty string');if(!Array.isArray(e.presets))throw Error('\'server.presets\' must be an array');if(1>e.presets.length)throw Error('\'server.presets\' must contain at least one preset');var t=!0,n=!1,r;try{for(var o=e.presets[Symbol.iterator](),a;!(t=(a=o.next()).done);t=!0){const e=a.value,t=e.name,n=e.params;if('string'!=typeof t)throw Error('\'server.presets[].name\' must be a string');if(''===t)throw Error('\'server.presets[].name\' cannot be empty');if(void 0!==n&&!(0,y.default)(n))throw Error('\'server.presets[].params\' must be an plain object');const r=(0,v.getPresetClassByName)(e.name);delete new r(n||{})}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}}static init(e){this.validate(e),global.__LOCAL_HOST__=e.host,global.__LOCAL_PORT__=e.port,e.servers===void 0?(global.__IS_CLIENT__=!1,global.__IS_SERVER__=!0,this.initServer(e)):(global.__SERVERS__=e.servers.filter((e)=>e.enabled),global.__IS_CLIENT__=!0,global.__IS_SERVER__=!1),global.__TIMEOUT__=e.timeout===void 0?600000:1e3*e.timeout,global.__WORKERS__=e.workers===void 0?0:e.workers,global.__DNS_EXPIRE__=e.dns_expire===void 0?E.DNS_DEFAULT_EXPIRE:1e3*e.dns_expire,global.__ALL_CONFIG__=e,e.dns!==void 0&&0<e.dns.length&&(global.__DNS__=e.dns,s.default.setServers(e.dns));const t=c.default.resolve(process.cwd(),e.log_path||'.');let r=!1;l.default.existsSync(t)?r=l.default.statSync(t).isFile():''!==c.default.extname(t)&&(r=!0),global.__LOG_PATH__=r?t:c.default.join(t,`bs-${__IS_CLIENT__?'client':'server'}.log`),global.__LOG_LEVEL__=e.log_level===void 0?x:e.log_level,k.logger.configure({level:__LOG_LEVEL__,transports:[new h.default.transports.Console({colorize:!0,prettyPrint:!0}),new(n(115))({filename:__LOG_PATH__,level:__LOG_LEVEL__})]});const a=o({},T,e.behaviours===void 0?{}:e.behaviours),i=Object.keys(a);global.__BEHAVIOURS__={};var d=!0,u=!1,p;try{for(var m=i[Symbol.iterator](),g;!(d=(g=m.next()).done);d=!0){const e=g.value,t=(0,b.getBehaviourClassByName)(a[e].name);global.__BEHAVIOURS__[e]=new t(a[e].params||{})}}catch(e){u=!0,p=e}finally{try{!d&&m.return&&m.return()}finally{if(u)throw p}}}static initServer(e){this.validateServer(e),global.__TRANSPORT__=e.transport===void 0?'tcp':e.transport,global.__IS_TLS__='tls'===__TRANSPORT__,__IS_TLS__&&(global.__TLS_CERT__=l.default.readFileSync(c.default.resolve(process.cwd(),e.tls_cert)),__IS_SERVER__&&(global.__TLS_KEY__=l.default.readFileSync(c.default.resolve(process.cwd(),e.tls_key)))),global.__SERVER_HOST__=e.host,global.__SERVER_PORT__=e.port,global.__KEY__=e.key,global.__PRESETS__=e.presets}}},function(e){e.exports=require('dns')},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}Object.defineProperty(t,'__esModule',{value:!0}),t.DNSCache=t.DNS_DEFAULT_EXPIRE=void 0;var a=function(){function e(e,t){var n=[],r=!0,o=!1,a;try{for(var s=e[Symbol.iterator](),i;!(r=(i=s.next()).done)&&(n.push(i.value),!(t&&n.length===t));r=!0);}catch(e){o=!0,a=e}finally{try{!r&&s['return']&&s['return']()}finally{if(o)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),s=n(32),i=r(s),l=n(6),d=r(l);const c=t.DNS_DEFAULT_EXPIRE=3.6e6;class u{constructor({expire:e}={}){this._expire=c,e!==void 0&&(this._expire=e)}_now(){return new Date().getTime()}_lookup(e){return o(function*(){return new Promise(function(t,n){i.default.lookup(e,function(e,r){e?n(e):t(r)})})})()}_put(e,t){if(0<this._expire){const n=this._now()+this._expire;u._pool[e]=[t,n]}}get(e){var t=this;return o(function*(){if(d.default.isIP(e))return e;let n=null;if(u._pool[e]===void 0)n=yield t._lookup(e),t._put(e,n);else{var r=a(u._pool[e],2);const o=r[0],s=r[1];t._now()>=s&&delete u._pool[e],n=o}return n})()}clear(){u._pool={}}}t.DNSCache=u,u._pool={}},function(e){e.exports=require('tls')},function(e,t,n){'use strict';function r(e,t){const n=['clientOut','serverIn','serverOut','clientIn'];if(n.some((e)=>'function'!=typeof t[e]))throw Error(`all methods [${n.toString()}] in ${e} must be implemented`);return!0}Object.defineProperty(t,'__esModule',{value:!0}),t.Middleware=t.MIDDLEWARE_DIRECTION_DOWNWARD=t.MIDDLEWARE_DIRECTION_UPWARD=void 0,t.createMiddleware=function(e,t={}){try{const n=(0,s.getPresetClassByName)(e),o=new n(t);return r(n.name,o),new c(o)}catch(e){console.error(e.message),process.exit(-1)}return null};var o=n(3),a=function(e){return e&&e.__esModule?e:{default:e}}(o),s=n(18),i=n(0);const l=t.MIDDLEWARE_DIRECTION_UPWARD=1,d=t.MIDDLEWARE_DIRECTION_DOWNWARD=-1;class c extends a.default{constructor(e){super(),this._broadcast=null,this._impl=null,this._impl=e}getName(){return(0,i.kebabCase)(this._impl.constructor.name).replace(/(.*)-preset/i,'$1')}subscribe(e){this._broadcast=e}onNotified(e){return this._impl.onNotified(e)}write(e,{buffer:t,direct:n,fail:o}){const a={[l]:'Out',[d]:'In'}[e],s=this._broadcast,i=(e)=>o(this.getName(),e),c=(t)=>{const r={buffer:t,next:(t,r=!1)=>{const o=this.emit(`next_${r?-e:e}`,t);o||n(t,r)},broadcast:s,direct:n,fail:i},o=__IS_CLIENT__?this._impl[`client${a}`](r):this._impl[`server${a}`](r);o instanceof Buffer&&r.next(o)},u=this._impl[`before${a}`]({buffer:t,next:c,broadcast:s,direct:n,fail:i});u instanceof Buffer&&c(u)}}t.Middleware=c},function(e,t,n){'use strict';const r=n(4),o=n(12),a=n(8),s=n(19),i=n(45),l=n(46),d=n(47),c='2.5.4',u=`
Usage: blinksocks [command] [options] ...
Commands:
init generate a pair of json file
Options:
-h, --help output usage information
-v, --version output blinksocks version
-c, --config file with configuration, usually a json file
--list-presets list all built-in presets
--list-behaviours list all built-in behaviours
-m, --minimal generate minimal json files
Examples:
${[['Generate json file with full options','$ blinksocks init'],['Generate json file with minimal options','$ blinksocks init --minimal'],['Start blinksocks client','$ blinksocks --config blinksocks.client.json'],['Start blinksocks server','$ blinksocks --config blinksocks.server.json']].map(([e,t])=>` ${s.gray('-')} ${e}\n ${s.blue(t)}`).join('\n')}
`,p=process.argv;(function(){function e(e){return-1!==n.indexOf(e)}function t(e){const t=n.indexOf(e);return-1===t?void 0:n[t+1]}if(3>p.length)return console.log(u);const n=p.slice(2);if(e('-h')||e('--help'))return console.log(u);if(e('-v')||e('--version'))return console.log(c);if(e('-c')||e('--config')){let e=t('-c')||t('--config');return void 0===e?console.log(s.red('config file must be provided')):(e=o.resolve(process.cwd(),e),r.existsSync(e)?l(e,d):console.log(s.red('config file is not found')))}if(e('--list-presets'))return console.log(d.presets.join(a.EOL));if(e('--list-behaviours'))return console.log(d.behaviours.join(a.EOL));if('init'===n[0]){const t=e('-m')||e('--minimal');return i({isMinimal:t})}console.log(u)})()},function(e){'use strict';var t=/[|\\{}()[\]^$+*?.]/g;e.exports=function(e){if('string'!=typeof e)throw new TypeError('Expected a string');return e.replace(t,'\\$&')}},function(e,t,n){'use strict';(function(e){const t=n(39),r=(e,n)=>function(){const r=e.apply(t,arguments);return`\u001B[${r+n}m`},o=(e,n)=>function(){const r=e.apply(t,arguments);return`\u001B[${38+n};5;${r}m`},a=(e,n)=>function(){const r=e.apply(t,arguments);return`\u001B[${38+n};2;${r[0]};${r[1]};${r[2]}m`};Object.defineProperty(e,'exports',{enumerable:!0,get:function(){const e=new Map,n={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};n.color.grey=n.color.gray;var s=!0,i=!1,l;try{for(var d=Object.keys(n)[Symbol.iterator](),c;!(s=(c=d.next()).done);s=!0){const t=c.value,r=n[t];var u=!0,p=!1,m=void 0;try{for(var g=Object.keys(r)[Symbol.iterator](),f;!(u=(f=g.next()).done);u=!0){const t=f.value,o=r[t];n[t]={open:`\u001B[${o[0]}m`,close:`\u001B[${o[1]}m`},r[t]=n[t],e.set(o[0],o[1])}}catch(e){p=!0,m=e}finally{try{!u&&g.return&&g.return()}finally{if(p)throw m}}Object.defineProperty(n,t,{value:r,enumerable:!1}),Object.defineProperty(n,'codes',{value:e,enumerable:!1})}}catch(e){i=!0,l=e}finally{try{!s&&d.return&&d.return()}finally{if(i)throw l}}const h=(e,t,n)=>[e,t,n];n.color.close='\x1B[39m',n.bgColor.close='\x1B[49m',n.color.ansi={},n.color.ansi256={},n.color.ansi16m={rgb:a(h,0)},n.bgColor.ansi={},n.bgColor.ansi256={},n.bgColor.ansi16m={rgb:a(h,10)};var _=!0,y=!1,b;try{for(var v=Object.keys(t)[Symbol.iterator](),k;!(_=(k=v.next()).done);_=!0){const e=k.value;if('object'!=typeof t[e])continue;const s=t[e];'ansi16'in s&&(n.color.ansi[e]=r(s.ansi16,0),n.bgColor.ansi[e]=r(s.ansi16,10)),'ansi256'in s&&(n.color.ansi256[e]=o(s.ansi256,0),n.bgColor.ansi256[e]=o(s.ansi256,10)),'rgb'in s&&(n.color.ansi16m[e]=a(s.rgb,0),n.bgColor.ansi16m[e]=a(s.rgb,10))}}catch(e){y=!0,b=e}finally{try{!_&&v.return&&v.return()}finally{if(y)throw b}}return n}})}).call(t,n(20)(e))},function(e,t,n){'use strict';function r(e){var t=function(t){return void 0===t||null===t?t:(1<arguments.length&&(t=Array.prototype.slice.call(arguments)),e(t))};return'conversion'in e&&(t.conversion=e.conversion),t}function o(e){var t=function(t){if(void 0===t||null===t)return t;1<arguments.length&&(t=Array.prototype.slice.call(arguments));var n=e(t);if('object'==typeof n)for(var r=n.length,o=0;o<r;o++)n[o]=Math.round(n[o]);return n};return'conversion'in e&&(t.conversion=e.conversion),t}var a=n(21),s=n(41),i={},l=Object.keys(a);l.forEach(function(e){i[e]={},Object.defineProperty(i[e],'channels',{value:a[e].channels}),Object.defineProperty(i[e],'labels',{value:a[e].labels});var t=s(e),n=Object.keys(t);n.forEach(function(n){var a=t[n];i[e][n]=o(a),i[e][n].raw=r(a)})}),e.exports=i},function(e){'use strict';e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},function(e,t,n){'use strict';function r(){for(var e={},t=d.length,n=0;n<t;n++)e[d[n]]={distance:-1,parent:null};return e}function o(e){var t=r(),n=[e];for(t[e].distance=0;n.length;)for(var o=n.pop(),a=Object.keys(l[o]),s=a.length,d=0;d<s;d++){var i=a[d],c=t[i];-1===c.distance&&(c.distance=t[o].distance+1,c.parent=o,n.unshift(i))}return t}function a(e,t){return function(n){return t(e(n))}}function s(e,t){for(var n=[t[e].parent,e],r=l[t[e].parent][e],o=t[e].parent;t[o].parent;)n.unshift(t[o].parent),r=a(l[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}var l=n(21),d=Object.keys(l);e.exports=function(e){for(var t=o(e),n={},r=Object.keys(t),a=r.length,l=0;l<a;l++){var i=r[l],d=t[i];null!==d.parent&&(n[i]=s(i,t))}return n}},function(e,t,n){'use strict';const r=n(8),o=n(43),a=process.env;let s=(()=>{if(o('no-color')||o('no-colors')||o('color=false'))return 0;if(o('color=16m')||o('color=full')||o('color=truecolor'))return 3;if(o('color=256'))return 2;if(o('color')||o('colors')||o('color=true')||o('color=always'))return 1;if(process.stdout&&!process.stdout.isTTY)return 0;if('win32'===process.platform){const e=r.release().split('.');return 8<=+process.versions.node.split('.')[0]&&10<=+e[0]&&10586<=+e[2]?2:1}if('CI'in a)return'TRAVIS'in a||'Travis'===a.CI||'CIRCLECI'in a?1:0;if('TEAMCITY_VERSION'in a)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if('TERM_PROGRAM'in a){const e=parseInt((a.TERM_PROGRAM_VERSION||'').split('.')[0],10);switch(a.TERM_PROGRAM){case'iTerm.app':return 3<=e?3:2;case'Hyper':return 3;case'Apple_Terminal':return 2;}}return /^(screen|xterm)-256(?:color)?/.test(a.TERM)?2:/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(a.TERM)?1:'COLORTERM'in a?1:'dumb'===a.TERM?0:0})();'FORCE_COLOR'in a&&(s=0===parseInt(a.FORCE_COLOR,10)?0:s||1),e.exports=process&&((e)=>{return 0!==e&&{level:e,hasBasic:!0,has256:2<=e,has16m:3<=e}})(s)},function(e){'use strict';e.exports=function(e,t){t=t||process.argv;var n=t.indexOf('--'),r=/^-{1,2}/.test(e)?'':'--',o=t.indexOf(r+e);return-1!==o&&(!(-1!==n)||o<n)}},function(e){'use strict';function t(e){return'u'===e[0]&&5===e.length||'x'===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):d[e]||e}function n(e,n){const r=[],o=n.trim().split(/\s*,\s*/g);let a;var s=!0,d=!1,c;try{for(var u=o[Symbol.iterator](),p;!(s=(p=u.next()).done);s=!0){const n=p.value;if(!isNaN(n))r.push(+n);else if(a=n.match(i))r.push(a[2].replace(l,(e,n,r)=>n?t(n):r));else throw new Error(`Invalid Chalk template style argument: ${n} (in style '${e}')`)}}catch(e){d=!0,c=e}finally{try{!s&&u.return&&u.return()}finally{if(d)throw c}}return r}function r(e){s.lastIndex=0;const t=[];for(let r;null!==(r=s.exec(e));){const e=r[1];if(r[2]){const o=n(e,r[2]);t.push([e].concat(o))}else t.push([e])}return t}function o(e,t){const n={};var r=!0,o=!1,a;try{for(var s=t[Symbol.iterator](),i;!(r=(i=s.next()).done);r=!0){const e=i.value;var l=!0,d=!1,c=void 0;try{for(var u=e.styles[Symbol.iterator](),p;!(l=(p=u.next()).done);l=!0){const t=p.value;n[t[0]]=e.inverse?null:t.slice(1)}}catch(e){d=!0,c=e}finally{try{!l&&u.return&&u.return()}finally{if(d)throw c}}}}catch(e){o=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw a}}let m=e;var g=!0,f=!1,h;try{for(var _=Object.keys(n)[Symbol.iterator](),y;!(g=(y=_.next()).done);g=!0){const e=y.value;if(Array.isArray(n[e])){if(!(e in m))throw new Error(`Unknown Chalk style: ${e}`);m=0<n[e].length?m[e].apply(m,n[e]):m[e]}}}catch(e){f=!0,h=e}finally{try{!g&&_.return&&_.return()}finally{if(f)throw h}}return m}const a=/(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,s=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,i=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,l=/\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi,d={n:'\n',r:'\r',t:'\t',b:'\b',f:'\f',v:'\x0B',0:'\0',"\\":'\\',e:'\x1B',a:'\x07'};e.exports=(e,n)=>{const s=[],i=[];let l=[];if(n.replace(a,(n,a,d,c,u,p)=>{if(a)l.push(t(a));else if(c){const t=l.join('');l=[],i.push(0===s.length?t:o(e,s)(t)),s.push({inverse:d,styles:r(c)})}else if(u){if(0===s.length)throw new Error('Found extraneous } in Chalk template literal');i.push(o(e,s)(l.join(''))),l=[],s.pop()}else l.push(p)}),i.push(l.join('')),0<s.length){const e=`Chalk template literal is missing ${s.length} closing bracket${1===s.length?'':'s'} (\`}\`)`;throw new Error(e)}return i.join('')}},function(e,t,n){'use strict';function r(e,t){const n=e.length,r=i.randomBytes(t).toJSON().data;return r.map((t)=>e[t%n]).join('')}function o(e,t){return e=a(e),t=a(t),Math.floor(i.randomBytes(1)[0]/255*(t-e+1))+e}var a=Math.ceil;const s=n(4),i=n(5);e.exports=function({isMinimal:e}){const t=r('abcdefghjkmnpqrstuvwxyz23456789!@#$%^&*()_+<>?:|{}-=[];,./ABCDEFGHJKLMNPQRSTUVWXYZ',16),n=o(1024,65535),a=o(200,1e3),i={host:'127.0.0.1',port:1080,servers:[{enabled:!0,transport:'tcp',host:'127.0.0.1',port:n,key:t,presets:[{name:'ss-base'},{name:'ss-aead-cipher',params:{method:'aes-256-gcm',info:'ss-subkey'}}],tls_cert:'cert.pem'}],behaviours:{"on-preset-failed":{name:'random-timeout',params:{min:10,max:40}}},dns:[],dns_expire:3600,timeout:a,workers:0,log_path:'bs-client.log',log_level:'info'};e&&(delete i.servers[0].transport,delete i.servers[0].tls_cert,delete i.dns,delete i.dns_expire,delete i.timeout,delete i.workers,delete i.log_path,delete i.log_level);const l={host:'0.0.0.0',port:n,key:t,transport:'tcp',presets:[{name:'ss-base'},{name:'ss-aead-cipher',params:{method:'aes-256-gcm',info:'ss-subkey'}}],behaviours:{"on-preset-failed":{name:'random-timeout',params:{min:10,max:40}}},tls_key:'key.pem',tls_cert:'cert.pem',dns:[],dns_expire:3600,timeout:a,workers:0,log_path:'bs-server.log',log_level:'info'};e&&(delete l.transport,delete l.behaviours,delete l.tls_key,delete l.tls_cert,delete l.dns,delete l.dns_expire,delete l.timeout,delete l.workers,delete l.log_path,delete l.log_level),s.writeFileSync('blinksocks.client.json',JSON.stringify(i,null,' ')),s.writeFileSync('blinksocks.server.json',JSON.stringify(l,null,' ')),console.log('> Generated blinksocks.client.json and blinksocks.server.json'),console.log('> Please check out https://github.com/blinksocks/blinksocks/tree/master/docs/config for explanation to each option')}},function(e,t,n){'use strict';function r(e){let t;try{const r=s.extname(e);if('.js'===r)delete n.c[!function(){var t=new Error('Cannot find module "."');throw t.code='MODULE_NOT_FOUND',t}()],t=!function(){var t=new Error('Cannot find module "."');throw t.code='MODULE_NOT_FOUND',t}(),console.warn(i.yellow.underline('\n>> WARN: using .js configuration will be deprecated in v2.6.x, please use .json instead. <<\n'));else{const n=a.readFileSync(e);t=JSON.parse(n)}}catch(t){throw Error(`fail to load/parse your '${e}': ${t.message}`)}return t}const o=n(22),a=n(4),s=n(12),i=n(19);e.exports=function(e,{Hub:t,Config:n}){try{if(n.init(r(e)),o.isMaster&&0<__WORKERS__){for(let e=0;e<__WORKERS__;++e)o.fork();console.log(`==> [bootstrap] started ${__WORKERS__} workers`)}else{const e=new t;e.on('close',()=>process.exit(0)),e.run(),process.on('SIGINT',()=>e.terminate())}}catch(e){console.error(e),process.exit(-1)}}},function(e,t,n){'use strict';e.exports=n(48)},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(49);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(17);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var a=n(18);Object.keys(a).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(24);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(31);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var a=n(116);Object.keys(a).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t=2,n=k){if(1>t)throw Error('len must be greater than 0');const r=e>parseInt(`0x${'ff'.repeat(t)}`);if(r)throw Error(`Number ${e} is too long to store in a '${t}' length buffer`);const o=Buffer.alloc(t);return n===k?o.writeUIntBE(e,0,t):o.writeUIntLE(e,0,t),o}function a(e,t){return e=d(e),t=d(t),i(m.default.randomBytes(1)[0]/255*(t-e+1))+e}function s(e,t){const n=m.default.createHash(e);return n.update(t),n.digest()}function l(e,t,n){const r=m.default.createHmac(e,t);return r.update(n).digest()}var d=Math.ceil,i=Math.floor;Object.defineProperty(t,'__esModule',{value:!0}),t.BYTE_ORDER_LE=t.BYTE_ORDER_BE=t.ATYP_V6=t.ATYP_DOMAIN=t.ATYP_V4=void 0,t.numberToBuffer=o,t.parseURI=function(e){let t=e,n=null;t.startsWith('http://')&&(t=t.substr(7),n=80),t.startsWith('https://')&&(t=t.substr(8),n=443);const r={};_.default.parseHost(t,r);const a=r.hostname,s=r.port,i=u.default.isIP(a)?u.default.isIPv4(a)?y:v:b;return{type:i,host:u.default.isIP(a)?f.default.toBuffer(a):Buffer.from(a),port:o(s||n||80)}},t.getRandomInt=a,t.getRandomChunks=function(e,t,n){const r=e.length,o=[];let s=0;for(;s<r-1;){const r=a(t,n);o.push(e.slice(s,s+r)),s+=r}return s<r&&o.push(e.slice(s)),o},t.getChunks=function(e,t){const n=e.length,r=[];let o=0;for(;o<n-1;)r.push(e.slice(o,o+t)),o+=t;return o<n&&r.push(e.slice(o)),r},t.getUTC=function(){const e=i(new Date().getTime()/1e3);return o(e,4,k)},t.hexStringToBuffer=function(e){return Buffer.from(e,'hex')},t.isValidHostname=function(e){return!('string'!=typeof e)&&(1>e.length||253<e.length?!1:!1!==/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i.test(e)&&!1!==/^[^.]{1,63}(\.[^.]{1,63})*$/.test(e))},t.isValidPort=function(e){return!('number'!=typeof e)&&(0>e||65535<e?!1:!0)},t.hash=s,t.hmac=l,t.EVP_BytesToKey=function(e,t,n){let r=Buffer.from(e),o=0;const a=[];for(;Buffer.concat(a).length<t+n;)0<o&&(r=Buffer.concat([a[o-1],Buffer.from(e)])),a.push(s('md5',r)),o+=1;return Buffer.concat(a).slice(0,t)},t.HKDF=function(e,n,r,o,a){const s=l(e,n,r);let c=Buffer.alloc(0),t=Buffer.alloc(0);for(let u=0;u<d(a/s.length);++u)c=l(e,s,Buffer.concat([c,o,Buffer.alloc(1,u+1)])),t=Buffer.concat([t,c]);return t.slice(0,a)},t.Xor=function(e,t){if(e.length===t.length){const n=[];for(let r=0;r<e.length;++r)n[r]=e[r]^t[r];return e instanceof Buffer?Buffer.from(n):n}return null},t.kebabCase=function(e){const t=[];for(let n=0;n<e.length;++n){const r=e[n];'A'<=r&&'Z'>=r?(0<n&&t.push('-'),t.push(r.toLowerCase())):t.push(r)}return t.join('')};var c=n(6),u=r(c),p=n(5),m=r(p),g=n(13),f=r(g),h=n(52),_=r(h);const y=t.ATYP_V4=1,b=t.ATYP_DOMAIN=3,v=t.ATYP_V6=4,k=t.BYTE_ORDER_BE=0,E=t.BYTE_ORDER_LE=1},function(e){e.exports=require('buffer')},function(e,t,n){'use strict';var r=Math.max,o,a,s;(function(r,i){'object'==typeof e&&e.exports?e.exports=i(n(25),n(26),n(27)):(a=[n(25),n(26),n(27)],o=i,s='function'==typeof o?o.apply(t,a):o,!(s!==void 0&&(e.exports=s)))})(void 0,function(e,t,n,o){function a(e,t){var n=1<=arguments.length,r=2<=arguments.length;if(!(this instanceof a))return n?r?new a(e,t):new a(e):new a;if(void 0===e){if(n)throw new TypeError('undefined is not a valid argument for URI');e='undefined'==typeof location?'':location.href+''}if(null===e&&n)throw new TypeError('null is not a valid argument for URI');return this.href(e),void 0===t?this:this.absoluteTo(t)}function s(e){return /^[0-9]+$/.test(e)}function i(e){return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g,'\\$1')}function l(e){return void 0===e?'Undefined':(Object.prototype.toString.call(e)+'').slice(8,-1)}function d(e){return'Array'===l(e)}function c(e,t){var n={},r,o;if('RegExp'===l(t))n=null;else if(d(t))for(r=0,o=t.length;r<o;r++)n[t[r]]=!0;else n[t]=!0;for(r=0,o=e.length;r<o;r++){var a=n&&void 0!==n[e[r]]||!n&&t.test(e[r]);a&&(e.splice(r,1),o--,r--)}return e}function u(e,t){var n,r;if(d(t)){for(n=0,r=t.length;n<r;n++)if(!u(e,t[n]))return!1;return!0}var o=l(t);for(n=0,r=e.length;n<r;n++)if('RegExp'===o){if('string'==typeof e[n]&&e[n].match(t))return!0;}else if(e[n]===t)return!0;return!1}function m(e,t){if(!d(e)||!d(t))return!1;if(e.length!==t.length)return!1;e.sort(),t.sort();for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function g(e){var t=/^\/+|\/+$/g;return e.replace(t,'')}function f(e){return escape(e)}function h(e){return encodeURIComponent(e).replace(/[!'()*]/g,f).replace(/\*/g,'%2A')}function _(e){return function(t,n){return void 0===t?this._parts[e]||'':(this._parts[e]=t||null,this.build(!n),this)}}function y(e,t){return function(n,r){return void 0===n?this._parts[e]||'':(null!==n&&(n+='',n.charAt(0)===t&&(n=n.substring(1))),this._parts[e]=n,this.build(!r),this)}}var b=o&&o.URI;a.version='1.18.12';var v=a.prototype,p=Object.prototype.hasOwnProperty;a._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:a.duplicateQueryParameters,escapeQuerySpace:a.escapeQuerySpace}},a.duplicateQueryParameters=!1,a.escapeQuerySpace=!0,a.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,a.idn_expression=/[^a-z0-9\._-]/i,a.punycode_expression=/(xn--)/i,a.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,a.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,a.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig,a.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},a.defaultPorts={http:'80',https:'443',ftp:'21',gopher:'70',ws:'80',wss:'443'},a.hostProtocols=['http','https'],a.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,a.domAttributes={a:'href',blockquote:'cite',link:'href',base:'href',script:'src',form:'action',img:'src',area:'href',iframe:'src',embed:'src',source:'src',track:'src',input:'src',audio:'src',video:'src'},a.getDomAttribute=function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();return'input'===t&&'image'!==e.type?void 0:a.domAttributes[t]}},a.encode=h,a.decode=decodeURIComponent,a.iso8859=function(){a.encode=escape,a.decode=unescape},a.unicode=function(){a.encode=h,a.decode=decodeURIComponent},a.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":'$',"%26":'&',"%2B":'+',"%2C":',',"%3B":';',"%3D":'=',"%3A":':',"%40":'@'}},decode:{expression:/[\/\?#]/g,map:{"/":'%2F',"?":'%3F',"#":'%23'}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":':',"%2F":'/',"%3F":'?',"%23":'#',"%5B":'[',"%5D":']',"%40":'@',"%21":'!',"%24":'$',"%26":'&',"%27":'\'',"%28":'(',"%29":')',"%2A":'*',"%2B":'+',"%2C":',',"%3B":';',"%3D":'='}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":'!',"%24":'$',"%27":'\'',"%28":'(',"%29":')',"%2A":'*',"%2B":'+',"%2C":',',"%3B":';',"%3D":'=',"%40":'@'}},decode:{expression:/[\/\?#:]/g,map:{"/":'%2F',"?":'%3F',"#":'%23',":":'%3A'}}}},a.encodeQuery=function(e,t){var n=a.encode(e+'');return void 0===t&&(t=a.escapeQuerySpace),t?n.replace(/%20/g,'+'):n},a.decodeQuery=function(e,t){e+='',void 0===t&&(t=a.escapeQuerySpace);try{return a.decode(t?e.replace(/\+/g,'%20'):e)}catch(t){return e}};var k={encode:'encode',decode:'decode'},E=function(e,t){return function(n){try{return a[t](n+'').replace(a.characters[e][t].expression,function(n){return a.characters[e][t].map[n]})}catch(t){return n}}},x;for(x in k)a[x+'PathSegment']=E('pathname',k[x]),a[x+'UrnPathSegment']=E('urnpath',k[x]);var T=function(e,t,n){return function(r){var o=n?function(e){return a[t](a[n](e))}:a[t];for(var s=(r+'').split(e),l=0,i=s.length;l<i;l++)s[l]=o(s[l]);return s.join(e)}};a.decodePath=T('/','decodePathSegment'),a.decodeUrnPath=T(':','decodeUrnPathSegment'),a.recodePath=T('/','encodePathSegment','decode'),a.recodeUrnPath=T(':','encodeUrnPathSegment','decode'),a.encodeReserved=E('reserved','encode'),a.parse=function(e,t){var n;return t||(t={}),n=e.indexOf('#'),-1<n&&(t.fragment=e.substring(n+1)||null,e=e.substring(0,n)),n=e.indexOf('?'),-1<n&&(t.query=e.substring(n+1)||null,e=e.substring(0,n)),'//'===e.substring(0,2)?(t.protocol=null,e=e.substring(2),e=a.parseAuthority(e,t)):(n=e.indexOf(':'),-1<n&&(t.protocol=e.substring(0,n)||null,t.protocol&&!t.protocol.match(a.protocol_expression)?t.protocol=void 0:'//'===e.substring(n+1,n+3)?(e=e.substring(n+3),e=a.parseAuthority(e,t)):(e=e.substring(n+1),t.urn=!0))),t.path=e,t},a.parseHost=function(e,n){e=e.replace(/\\/g,'/');var r=e.indexOf('/'),o,s;if(-1===r&&(r=e.length),'['===e.charAt(0))o=e.indexOf(']'),n.hostname=e.substring(1,o)||null,n.port=e.substring(o+2,r)||null,'/'===n.port&&(n.port=null);else{var t=e.indexOf(':'),i=e.indexOf('/'),l=e.indexOf(':',t+1);-1!==l&&(-1===i||l<i)?(n.hostname=e.substring(0,r)||null,n.port=null):(s=e.substring(0,r).split(':'),n.hostname=s[0]||null,n.port=s[1]||null)}return n.hostname&&'/'!==e.substring(r).charAt(0)&&(r++,e='/'+e),a.ensureValidHostname(n.hostname,n.protocol),n.port&&a.ensureValidPort(n.port),e.substring(r)||'/'},a.parseAuthority=function(e,t){return e=a.parseUserinfo(e,t),a.parseHost(e,t)},a.parseUserinfo=function(e,n){var r=e.indexOf('/'),o=e.lastIndexOf('@',-1<r?r:e.length-1),s;return-1<o&&(-1===r||o<r)?(s=e.substring(0,o).split(':'),n.username=s[0]?a.decode(s[0]):null,s.shift(),n.password=s[0]?a.decode(s.join(':')):null,e=e.substring(o+1)):(n.username=null,n.password=null),e},a.parseQuery=function(e,t){if(!e)return{};if(e=e.replace(/&+/g,'&').replace(/^\?*&*|&+$/g,''),!e)return{};for(var n={},r=e.split('&'),o=r.length,s=0,i,l,d;s<o;s++)i=r[s].split('='),l=a.decodeQuery(i.shift(),t),d=i.length?a.decodeQuery(i.join('='),t):null,p.call(n,l)?(('string'==typeof n[l]||null===n[l])&&(n[l]=[n[l]]),n[l].push(d)):n[l]=d;return n},a.build=function(e){var n='';return e.protocol&&(n+=e.protocol+':'),!e.urn&&(n||e.hostname)&&(n+='//'),n+=a.buildAuthority(e)||'','string'==typeof e.path&&('/'!==e.path.charAt(0)&&'string'==typeof e.hostname&&(n+='/'),n+=e.path),'string'==typeof e.query&&e.query&&(n+='?'+e.query),'string'==typeof e.fragment&&e.fragment&&(n+='#'+e.fragment),n},a.buildHost=function(e){var n='';return e.hostname?(n+=a.ip6_expression.test(e.hostname)?'['+e.hostname+']':e.hostname,e.port&&(n+=':'+e.port),n):''},a.buildAuthority=function(e){return a.buildUserinfo(e)+a.buildHost(e)},a.buildUserinfo=function(e){var n='';return e.username&&(n+=a.encode(e.username)),e.password&&(n+=':'+a.encode(e.password)),n&&(n+='@'),n},a.buildQuery=function(e,n,r){var o='',t,s,l,i;for(s in e)if(p.call(e,s)&&s)if(d(e[s]))for(t={},l=0,i=e[s].length;l<i;l++)void 0!==e[s][l]&&void 0===t[e[s][l]+'']&&(o+='&'+a.buildQueryParameter(s,e[s][l],r),!0!==n&&(t[e[s][l]+'']=!0));else void 0!==e[s]&&(o+='&'+a.buildQueryParameter(s,e[s],r));return o.substring(1)},a.buildQueryParameter=function(e,t,n){return a.encodeQuery(e,n)+(null===t?'':'='+a.encodeQuery(t,n))},a.addQuery=function(e,t,n){if('object'==typeof t)for(var r in t)p.call(t,r)&&a.addQuery(e,r,t[r]);else if('string'==typeof t){if(void 0===e[t])return void(e[t]=n);'string'==typeof e[t]&&(e[t]=[e[t]]),d(n)||(n=[n]),e[t]=(e[t]||[]).concat(n)}else throw new TypeError('URI.addQuery() accepts an object, string as the name parameter')},a.removeQuery=function(e,t,n){var r,o,s;if(d(t))for(r=0,o=t.length;r<o;r++)e[t[r]]=void 0;else if('RegExp'===l(t))for(s in e)t.test(s)&&(e[s]=void 0);else if('object'==typeof t)for(s in t)p.call(t,s)&&a.removeQuery(e,s,t[s]);else if('string'==typeof t)void 0===n?e[t]=void 0:'RegExp'===l(n)?!d(e[t])&&n.test(e[t])?e[t]=void 0:e[t]=c(e[t],n):e[t]!==n+''||d(n)&&1!==n.length?d(e[t])&&(e[t]=c(e[t],n)):e[t]=void 0;else throw new TypeError('URI.removeQuery() accepts an object, string, RegExp as the first parameter')},a.hasQuery=function(e,t,n,r){switch(l(t)){case'String':break;case'RegExp':for(var o in e)if(p.call(e,o)&&t.test(o)&&(void 0===n||a.hasQuery(e,o,n)))return!0;return!1;case'Object':for(var s in t)if(p.call(t,s)&&!a.hasQuery(e,s,t[s]))return!1;return!0;default:throw new TypeError('URI.hasQuery() accepts a string, regular expression or object as the name parameter');}switch(l(n)){case'Undefined':return t in e;case'Boolean':var i=d(e[t])?!!e[t].length:!!e[t];return n===i;case'Function':return!!n(e[t],t,e);case'Array':if(!d(e[t]))return!1;var c=r?u:m;return c(e[t],n);case'RegExp':return d(e[t])?!!r&&u(e[t],n):!!(e[t]&&e[t].match(n));case'Number':n+='';case'String':return d(e[t])?!!r&&u(e[t],n):e[t]===n;default:throw new TypeError('URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter');}},a.joinPaths=function(){for(var e=[],t=[],n=0,r=0,o;r<arguments.length;r++){o=new a(arguments[r]),e.push(o);for(var i=o.segment(),l=0;l<i.length;l++)'string'==typeof i[l]&&t.push(i[l]),i[l]&&n++}if(!t.length||!n)return new a('');var s=new a('').segment(t);return(''===e[0].path()||'/'===e[0].path().slice(0,1))&&s.path('/'+s.path()),s.normalize()},a.commonPath=function(e,t){var n=Math.min(e.length,t.length),r;for(r=0;r<n;r++)if(e.charAt(r)!==t.charAt(r)){r--;break}return 1>r?e.charAt(0)===t.charAt(0)&&'/'===e.charAt(0)?'/':'':(('/'!==e.charAt(r)||'/'!==t.charAt(r))&&(r=e.substring(0,r).lastIndexOf('/')),e.substring(0,r+1))},a.withinString=function(e,t,n){n||(n={});var o=n.start||a.findUri.start,s=n.end||a.findUri.end,i=n.trim||a.findUri.trim,l=n.parens||a.findUri.parens,d=/[a-z0-9-]=["']?$/i;for(o.lastIndex=0;;){var c=o.exec(e);if(!c)break;var u=c.index;if(n.ignoreHtml){var p=e.slice(r(u-3,0),u);if(p&&d.test(p))continue}for(var m=u+e.slice(u).search(s),g=e.slice(u,m),f=-1,h,_;h=l.exec(g),!!h;)_=h.index+h[0].length,f=r(f,_);if((g=-1<f?g.slice(0,f)+g.slice(f).replace(i,''):g.replace(i,''),!(g.length<=c[0].length))&&!(n.ignore&&n.ignore.test(g))){m=u+g.length;var y=t(g,u,m,e);if(void 0===y){o.lastIndex=m;continue}y+='',e=e.slice(0,u)+y+e.slice(m),o.lastIndex=u+y.length}}return o.lastIndex=0,e},a.ensureValidHostname=function(t,n){var r=!1;if(!!n&&(r=u(a.hostProtocols,n)),r&&!!!t)throw new TypeError('Hostname cannot be empty, if protocol is '+n);else if(t&&t.match(a.invalid_hostname_characters)){if(!e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(e.toASCII(t).match(a.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]')}},a.ensureValidPort=function(e){if(e){var t=+e;if(!(s(t)&&0<t&&65536>t))throw new TypeError('Port "'+e+'" is not a valid port')}},a.noConflict=function(e){if(e){var t={URI:this.noConflict()};return o.URITemplate&&'function'==typeof o.URITemplate.noConflict&&(t.URITemplate=o.URITemplate.noConflict()),o.IPv6&&'function'==typeof o.IPv6.noConflict&&(t.IPv6=o.IPv6.noConflict()),o.SecondLevelDomains&&'function'==typeof o.SecondLevelDomains.noConflict&&(t.SecondLevelDomains=o.SecondLevelDomains.noConflict()),t}return o.URI===this&&(o.URI=b),this},v.build=function(e){return!0===e?this._deferred_build=!0:(void 0===e||this._deferred_build)&&(this._string=a.build(this._parts),this._deferred_build=!1),this},v.clone=function(){return new a(this)},v.valueOf=v.toString=function(){return this.build(!1)._string},v.protocol=_('protocol'),v.username=_('username'),v.password=_('password'),v.hostname=_('hostname'),v.port=_('port'),v.query=y('query','?'),v.fragment=y('fragment','#'),v.search=function(e,n){var r=this.query(e,n);return'string'==typeof r&&r.length?'?'+r:r},v.hash=function(e,n){var r=this.fragment(e,n);return'string'==typeof r&&r.length?'#'+r:r},v.pathname=function(e,t){if(void 0===e||!0===e){var n=this._parts.path||(this._parts.hostname?'/':'');return e?(this._parts.urn?a.decodeUrnPath:a.decodePath)(n):n}return this._parts.path=this._parts.urn?e?a.recodeUrnPath(e):'':e?a.recodePath(e):'/',this.build(!t),this},v.path=v.pathname,v.href=function(e,t){if(void 0===e)return this.toString();this._string='',this._parts=a._parts();var n=e instanceof a,r='object'==typeof e&&(e.hostname||e.path||e.pathname);if(e.nodeName){var o=a.getDomAttribute(e);e=e[o]||'',r=!1}if(!n&&r&&void 0!==e.pathname&&(e=e.toString()),'string'==typeof e||e instanceof String)this._parts=a.parse(e+'',this._parts);else if(n||r){var s=n?e._parts:e;for(var i in s)p.call(this._parts,i)&&(this._parts[i]=s[i])}else throw new TypeError('invalid input');return this.build(!t),this},v.is=function(e){var t=!1,r=!1,o=!1,s=!1,i=!1,l=!1,d=!1,c=!this._parts.urn;switch(this._parts.hostname&&(c=!1,r=a.ip4_expression.test(this._parts.hostname),o=a.ip6_expression.test(this._parts.hostname),t=r||o,s=!t,i=s&&n&&n.has(this._parts.hostname),l=s&&a.idn_expression.test(this._parts.hostname),d=s&&a.punycode_expression.test(this._parts.hostname)),e.toLowerCase()){case'relative':return c;case'absolute':return!c;case'domain':case'name':return s;case'sld':return i;case'ip':return t;case'ip4':case'ipv4':case'inet4':return r;case'ip6':case'ipv6':case'inet6':return o;case'idn':return l;case'url':return!this._parts.urn;case'urn':return!!this._parts.urn;case'punycode':return d;}return null};var S=v.protocol,P=v.port,O=v.hostname;v.protocol=function(e,t){if(void 0!==e&&e&&(e=e.replace(/:(\/\/)?$/,''),!e.match(a.protocol_expression)))throw new TypeError('Protocol "'+e+'" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]');return S.call(this,e,t)},v.scheme=v.protocol,v.port=function(e,t){return this._parts.urn?void 0===e?'':this:(void 0!==e&&(0===e&&(e=null),e&&(e+='',':'===e.charAt(0)&&(e=e.substring(1)),a.ensureValidPort(e))),P.call(this,e,t))},v.hostname=function(e,t){if(this._parts.urn)return void 0===e?'':this;if(void 0!==e){var n={},r=a.parseHost(e,n);if('/'!==r)throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');e=n.hostname,a.ensureValidHostname(e,this._parts.protocol)}return O.call(this,e,t)},v.origin=function(e,t){if(this._parts.urn)return void 0===e?'':this;if(void 0===e){var n=this.protocol(),r=this.authority();return r?(n?n+'://':'')+this.authority():''}var o=a(e);return this.protocol(o.protocol()).authority(o.authority()).build(!t),this},v.host=function(e,t){if(this._parts.urn)return void 0===e?'':this;if(void 0===e)return this._parts.hostname?a.buildHost(this._parts):'';var n=a.parseHost(e,this._parts);if('/'!==n)throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},v.authority=function(e,t){if(this._parts.urn)return void 0===e?'':this;if(void 0===e)return this._parts.hostname?a.buildAuthority(this._parts):'';var n=a.parseAuthority(e,this._parts);if('/'!==n)throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},v.userinfo=function(e,n){if(this._parts.urn)return void 0===e?'':this;if(void 0===e){var r=a.buildUserinfo(this._parts);return r?r.substring(0,r.length-1):r}return'@'!==e[e.length-1]&&(e+='@'),a.parseUserinfo(e,this._parts),this.build(!n),this},v.resource=function(e,t){var n;return void 0===e?this.path()+this.search()+this.hash():(n=a.parse(e),this._parts.path=n.path,this._parts.query=n.query,this._parts.fragment=n.fragment,this.build(!t),this)},v.subdomain=function(t,n){if(this._parts.urn)return void 0===t?'':this;if(void 0===t){if(!this._parts.hostname||this.is('IP'))return'';var r=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,r)||''}var o=this._parts.hostname.length-this.domain().length,e=this._parts.hostname.substring(0,o),s=new RegExp('^'+i(e));if(t&&'.'!==t.charAt(t.length-1)&&(t+='.'),-1!==t.indexOf(':'))throw new TypeError('Domains cannot contain colons');return t&&a.ensureValidHostname(t,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(s,t),this.build(!n),this},v.domain=function(e,n){if(this._parts.urn)return void 0===e?'':this;if('boolean'==typeof e&&(n=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is('IP'))return'';var r=this._parts.hostname.match(/\./g);if(r&&2>r.length)return this._parts.hostname;var t=this._parts.hostname.length-this.tld(n).length-1;return t=this._parts.hostname.lastIndexOf('.',t-1)+1,this._parts.hostname.substring(t)||''}if(!e)throw new TypeError('cannot set domain empty');if(-1!==e.indexOf(':'))throw new TypeError('Domains cannot contain colons');if(a.ensureValidHostname(e,this._parts.protocol),!this._parts.hostname||this.is('IP'))this._parts.hostname=e;else{var o=new RegExp(i(this.domain())+'$');this._parts.hostname=this._parts.hostname.replace(o,e)}return this.build(!n),this},v.tld=function(e,t){if(this._parts.urn)return void 0===e?'':this;if('boolean'==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is('IP'))return'';var r=this._parts.hostname.lastIndexOf('.'),o=this._parts.hostname.substring(r+1);return!0!==t&&n&&n.list[o.toLowerCase()]?n.get(this._parts.hostname)||o:o}var a;if(!e)throw new TypeError('cannot set TLD empty');else if(e.match(/[^a-zA-Z0-9-]/)){if(n&&n.is(e))a=new RegExp(i(this.tld())+'$'),this._parts.hostname=this._parts.hostname.replace(a,e);else throw new TypeError('TLD "'+e+'" contains characters other than [A-Z0-9]');}else if(!this._parts.hostname||this.is('IP'))throw new ReferenceError('cannot set TLD on non-domain host');else a=new RegExp(i(this.tld())+'$'),this._parts.hostname=this._parts.hostname.replace(a,e);return this.build(!t),this},v.directory=function(t,n){if(this._parts.urn)return void 0===t?'':this;if(void 0===t||!0===t){if(!this._parts.path&&!this._parts.hostname)return'';if('/'===this._parts.path)return'/';var r=this._parts.path.length-this.filename().length-1,o=this._parts.path.substring(0,r)||(this._parts.hostname?'/':'');return t?a.decodePath(o):o}var s=this._parts.path.length-this.filename().length,e=this._parts.path.substring(0,s),l=new RegExp('^'+i(e));return this.is('relative')||(!t&&(t='/'),'/'!==t.charAt(0)&&(t='/'+t)),t&&'/'!==t.charAt(t.length-1)&&(t+='/'),t=a.recodePath(t),this._parts.path=this._parts.path.replace(l,t),this.build(!n),this},v.filename=function(e,t){if(this._parts.urn)return void 0===e?'':this;if('string'!=typeof e){if(!this._parts.path||'/'===this._parts.path)return'';var n=this._parts.path.lastIndexOf('/'),r=this._parts.path.substring(n+1);return e?a.decodePathSegment(r):r}var o=!1;'/'===e.charAt(0)&&(e=e.substring(1)),e.match(/\.?\//)&&(o=!0);var s=new RegExp(i(this.filename())+'$');return e=a.recodePath(e),this._parts.path=this._parts.path.replace(s,e),o?this.normalizePath(t):this.build(!t),this},v.suffix=function(e,t){if(this._parts.urn)return void 0===e?'':this;if(void 0===e||!0===e){if(!this._parts.path||'/'===this._parts.path)return'';var n=this.filename(),r=n.lastIndexOf('.'),o,s;return-1===r?'':(o=n.substring(r+1),s=/^[a-z0-9%]+$/i.test(o)?o:'',e?a.decodePathSegment(s):s)}'.'===e.charAt(0)&&(e=e.substring(1));var l=this.suffix(),d;if(!l){if(!e)return this;this._parts.path+='.'+a.recodePath(e)}else d=e?new RegExp(i(l)+'$'):new RegExp(i('.'+l)+'$');return d&&(e=a.recodePath(e),this._parts.path=this._parts.path.replace(d,e)),this.build(!t),this},v.segment=function(e,t,n){var o=this._parts.urn?':':'/',a=this.path(),s='/'===a.substring(0,1),c=a.split(o);if(void 0!==e&&'number'!=typeof e&&(n=t,t=e,e=void 0),void 0!==e&&'number'!=typeof e)throw new Error('Bad segment "'+e+'", must be 0-based integer');if(s&&c.shift(),0>e&&(e=r(c.length+e,0)),void 0===t)return void 0===e?c:c[e];if(null!==e&&void 0!==c[e])t?c[e]=g(t):c.splice(e,1);else if(d(t)){c=[];for(var u=0,i=t.length;u<i;u++)(t[u].length||c.length&&c[c.length-1].length)&&(c.length&&!c[c.length-1].length&&c.pop(),c.push(g(t[u])))}else(t||'string'==typeof t)&&(t=g(t),''===c[c.length-1]?c[c.length-1]=t:c.push(t));return s&&c.unshift(''),this.path(c.join(o),n)},v.segmentCoded=function(e,t,n){var r,o,s;if('number'!=typeof e&&(n=t,t=e,e=void 0),void 0===t){if(r=this.segment(e,t,n),!d(r))r=void 0===r?void 0:a.decode(r);else for(o=0,s=r.length;o<s;o++)r[o]=a.decode(r[o]);return r}if(!d(t))t='string'==typeof t||t instanceof String?a.encode(t):t;else for(o=0,s=t.length;o<s;o++)t[o]=a.encode(t[o]);return this.segment(e,t,n)};var R=v.query;return v.query=function(e,t){if(!0===e)return a.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if('function'==typeof e){var n=a.parseQuery(this._parts.query,this._parts.escapeQuerySpace),r=e.call(this,n);return this._parts.query=a.buildQuery(r||n,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!t),this}return void 0!==e&&'string'!=typeof e?(this._parts.query=a.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!t),this):R.call(this,e,t)},v.setQuery=function(e,t,n){var r=a.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if('string'==typeof e||e instanceof String)r[e]=void 0===t?null:t;else if('object'==typeof e)for(var o in e)p.call(e,o)&&(r[o]=e[o]);else throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');return this._parts.query=a.buildQuery(r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),'string'!=typeof e&&(n=t),this.build(!n),this},v.addQuery=function(e,t,n){var r=a.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return a.addQuery(r,e,void 0===t?null:t),this._parts.query=a.buildQuery(r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),'string'!=typeof e&&(n=t),this.build(!n),this},v.removeQuery=function(e,t,n){var r=a.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return a.removeQuery(r,e,t),this._parts.query=a.buildQuery(r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),'string'!=typeof e&&(n=t),this.build(!n),this},v.hasQuery=function(e,t,n){var r=a.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return a.hasQuery(r,e,t,n)},v.setSearch=v.setQuery,v.addSearch=v.addQuery,v.removeSearch=v.removeQuery,v.hasSearch=v.hasQuery,v.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},v.normalizeProtocol=function(e){return'string'==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!e)),this},v.normalizeHostname=function(n){return this._parts.hostname&&(this.is('IDN')&&e?this._parts.hostname=e.toASCII(this._parts.hostname):this.is('IPv6')&&t&&(this._parts.hostname=t.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!n)),this},v.normalizePort=function(e){return'string'==typeof this._parts.protocol&&this._parts.port===a.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!e)),this},v.normalizePath=function(e){var t=this._parts.path;if(!t)return this;if(this._parts.urn)return this._parts.path=a.recodeUrnPath(this._parts.path),this.build(!e),this;if('/'===this._parts.path)return this;t=a.recodePath(t);var n='',r,o,s;for('/'!==t.charAt(0)&&(r=!0,t='/'+t),('/..'===t.slice(-3)||'/.'===t.slice(-2))&&(t+='/'),t=t.replace(/(\/(\.\/)+)|(\/\.$)/g,'/').replace(/\/{2,}/g,'/'),r&&(n=t.substring(1).match(/^(\.\.\/)+/)||'',n&&(n=n[0]));o=t.search(/\/\.\.(\/|$)/),-1!==o;){if(0===o){t=t.substring(3);continue}s=t.substring(0,o).lastIndexOf('/'),-1===s&&(s=o),t=t.substring(0,s)+t.substring(o+3)}return r&&this.is('relative')&&(t=n+t.substring(1)),this._parts.path=t,this.build(!e),this},v.normalizePathname=v.normalizePath,v.normalizeQuery=function(e){return'string'==typeof this._parts.query&&(this._parts.query.length?this.query(a.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!e)),this},v.normalizeFragment=function(e){return this._parts.fragment||(this._parts.fragment=null,this.build(!e)),this},v.normalizeSearch=v.normalizeQuery,v.normalizeHash=v.normalizeFragment,v.iso8859=function(){var t=a.encode,e=a.decode;a.encode=escape,a.decode=decodeURIComponent;try{this.normalize()}finally{a.encode=t,a.decode=e}return this},v.unicode=function(){var t=a.encode,e=a.decode;a.encode=h,a.decode=unescape;try{this.normalize()}finally{a.encode=t,a.decode=e}return this},v.readable=function(){var n=this.clone();n.username('').password('').normalize();var r='';if(n._parts.protocol&&(r+=n._parts.protocol+'://'),n._parts.hostname&&(n.is('punycode')&&e?(r+=e.toUnicode(n._parts.hostname),n._parts.port&&(r+=':'+n._parts.port)):r+=n.host()),n._parts.hostname&&n._parts.path&&'/'!==n._parts.path.charAt(0)&&(r+='/'),r+=n.path(!0),n._parts.query){for(var t='',o=0,s=n._parts.query.split('&'),i=s.length,l;o<i;o++)l=(s[o]||'').split('='),t+='&'+a.decodeQuery(l[0],this._parts.escapeQuerySpace).replace(/&/g,'%26'),void 0!==l[1]&&(t+='='+a.decodeQuery(l[1],this._parts.escapeQuerySpace).replace(/&/g,'%26'));r+='?'+t.substring(1)}return r+=a.decodeQuery(n.hash(),!0),r},v.absoluteTo=function(e){var t=this.clone(),n=['protocol','username','password','hostname','port'],r,o,s;if(this._parts.urn)throw new Error('URNs do not have any generally defined hierarchical components');if(e instanceof a||(e=new a(e)),t._parts.protocol)return t;if(t._parts.protocol=e._parts.protocol,this._parts.hostname)return t;for(o=0;s=n[o];o++)t._parts[s]=e._parts[s];return t._parts.path?('..'===t._parts.path.substring(-2)&&(t._parts.path+='/'),'/'!==t.path().charAt(0)&&(r=e.directory(),r=r?r:0===e.path().indexOf('/')?'/':'',t._parts.path=(r?r+'/':'')+t._parts.path,t.normalizePath())):(t._parts.path=e._parts.path,!t._parts.query&&(t._parts.query=e._parts.query)),t.build(),t},v.relativeTo=function(e){var t=this.clone().normalize(),n,r,o,s,i;if(t._parts.urn)throw new Error('URNs do not have any generally defined hierarchical components');if(e=new a(e).normalize(),n=t._parts,r=e._parts,s=t.path(),i=e.path(),'/'!==s.charAt(0))throw new Error('URI is already relative');if('/'!==i.charAt(0))throw new Error('Cannot calculate a URI relative to another relative URI');if(n.protocol===r.protocol&&(n.protocol=null),n.username!==r.username||n.password!==r.password)return t.build();if(null!==n.protocol||null!==n.username||null!==n.password)return t.build();if(n.hostname===r.hostname&&n.port===r.port)n.hostname=null,n.port=null;else return t.build();if(s===i)return n.path='',t.build();if(o=a.commonPath(s,i),!o)return t.build();var l=r.path.substring(o.length).replace(/[^\/]*$/,'').replace(/.*?\//g,'../');return n.path=l+n.path.substring(o.length)||'./',t.build()},v.equals=function(e){var t=this.clone(),n=new a(e),r={},o={},s={},i,l,c;if(t.normalize(),n.normalize(),t.toString()===n.toString())return!0;if(i=t.query(),l=n.query(),t.query(''),n.query(''),t.toString()!==n.toString())return!1;if(i.length!==l.length)return!1;for(c in r=a.parseQuery(i,this._parts.escapeQuerySpace),o=a.parseQuery(l,this._parts.escapeQuerySpace),r)if(p.call(r,c)){if(!d(r[c])){if(r[c]!==o[c])return!1;}else if(!m(r[c],o[c]))return!1;s[c]=!0}for(c in o)if(p.call(o,c)&&!s[c])return!1;return!0},v.duplicateQueryParameters=function(e){return this._parts.duplicateQueryParameters=!!e,this},v.escapeQuerySpace=function(e){return this._parts.escapeQuerySpace=!!e,this},a})},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.AdvancedBuffer=void 0;var r=n(3),o=function(e){return e&&e.__esModule?e:{default:e}}(r);class a extends o.default{constructor(e={}){if(super(),this._buffer=Buffer.alloc(0),this._getPacketLength=null,this._nextLength=0,'function'!=typeof e.getPacketLength)throw Error('options.getPacketLength should be a function');this._getPacketLength=e.getPacketLength}put(e,...t){if(!(e instanceof Buffer))throw Error('chunk must be a Buffer');this._buffer=this._digest(Buffer.concat([this._buffer,e]),...t)}final(){return this._buffer}_digest(e,...t){const n=this._nextLength||this._getPacketLength(e,...t);return 0===n||'undefined'==typeof n?e:-1===n?Buffer.alloc(0):n instanceof Buffer?this._digest(n,...t):e.length===n?(this.emit('data',e,...t),this._nextLength=0,Buffer.alloc(0)):e.length<n?(this._nextLength=n,e):e.length>n?(this.emit('data',e.slice(0,n),...t),this._nextLength=0,this._digest(e.slice(n),...t)):void 0}}t.AdvancedBuffer=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.logger=void 0;var r=n(10),o=function(e){return e&&e.__esModule?e:{default:e}}(r);t.logger=new o.default.Logger},function(e){e.exports={name:'winston',description:'A multi-transport async logging library for Node.js',version:'2.3.1',author:'Charlie Robbins <charlie.robbins@gmail.com>',maintainers:['Jarrett Cruger <jcrugzz@gmail.com>','Alberto Pose <albertopose@gmail.com>'],repository:{type:'git',url:'https://github.com/winstonjs/winston.git'},keywords:['winston','logging','sysadmin','tools'],dependencies:{async:'~1.0.0',colors:'1.0.x',cycle:'1.0.x',eyes:'0.1.x',isstream:'0.1.x',"stack-trace":'0.0.x'},devDependencies:{"cross-spawn-async":'^2.0.0',hock:'1.x.x',"std-mocks":'~1.0.0',vows:'0.7.x'},main:'./lib/winston',scripts:{test:'vows --spec --isolate'},engines:{node:'>= 0.10.0'},license:'MIT'}},function(e,t,n){'use strict';Object.defineProperty(t,'Console',{configurable:!0,enumerable:!0,get:function(){return n(57).Console}}),Object.defineProperty(t,'File',{configurable:!0,enumerable:!0,get:function(){return n(73).File}}),Object.defineProperty(t,'Http',{configurable:!0,enumerable:!0,get:function(){return n(75).Http}}),Object.defineProperty(t,'Memory',{configurable:!0,enumerable:!0,get:function(){return n(78).Memory}})},function(e,t,n){'use strict';var r=n(3),o=n(8),a=n(7),s=n(9),i=n(15).Transport,l=t.Console=function(e){i.call(this,e),e=e||{},this.json=e.json||!1,this.colorize=e.colorize||!1,this.prettyPrint=e.prettyPrint||!1,this.timestamp='undefined'!=typeof e.timestamp&&e.timestamp,this.showLevel=!(e.showLevel!==void 0)||e.showLevel,this.label=e.label||null,this.logstash=e.logstash||!1,this.depth=e.depth||null,this.align=e.align||!1,this.stderrLevels=function(e,t){var n='Cannot have non-string elements in stderrLevels Array';if(t){if(e)throw new Error('Cannot set debugStdout and stderrLevels together');return s.stringArrayToSet(['error'],n)}if(!e)return s.stringArrayToSet(['error','debug'],n);if(!Array.isArray(e))throw new Error('Cannot set stderrLevels to type other than Array');return s.stringArrayToSet(e,n)}(e.stderrLevels,e.debugStdout),this.eol=e.eol||o.EOL,this.json&&(this.stringify=e.stringify||function(e){return JSON.stringify(e,null,2)})};a.inherits(l,i),l.prototype.name='console',l.prototype.log=function(e,t,n,r){if(this.silent)return r(null,!0);var o=this,a;a=s.log({colorize:this.colorize,json:this.json,level:e,message:t,meta:n,stringify:this.stringify,timestamp:this.timestamp,showLevel:this.showLevel,prettyPrint:this.prettyPrint,raw:this.raw,label:this.label,logstash:this.logstash,depth:this.depth,formatter:this.formatter,align:this.align,humanReadableUnhandledException:this.humanReadableUnhandledException}),this.stderrLevels[e]?process.stderr.write(a+this.eol):process.stdout.write(a+this.eol),o.emit('logged'),r(null,!0)}},function(e,t,n){'use strict';var r=t;r.decycle=function(e){var t=[],n=[];return function e(r,o){var a,s,i;if('object'==typeof r&&null!==r&&!(r instanceof Boolean)&&!(r instanceof Date)&&!(r instanceof Number)&&!(r instanceof RegExp)&&!(r instanceof String)){for(a=0;a<t.length;a+=1)if(t[a]===r)return{$ref:n[a]};if(t.push(r),n.push(o),'[object Array]'===Object.prototype.toString.apply(r))for(i=[],a=0;a<r.length;a+=1)i[a]=e(r[a],o+'['+a+']');else for(s in i={},r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=e(r[s],o+'['+JSON.stringify(s)+']'));return i}return r}(e,'$')},r.retrocycle=function(e){var t=/^\$(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/;return function e(n){var r,o,a,s;if(n&&'object'==typeof n)if('[object Array]'===Object.prototype.toString.apply(n))for(r=0;r<n.length;r+=1)o=n[r],o&&'object'==typeof o&&(s=o.$ref,'string'==typeof s&&t.test(s)?n[r]=eval(s):e(o));else for(a in n)'object'==typeof n[a]&&(o=n[a],o&&(s=o.$ref,'string'==typeof s&&t.test(s)?n[a]=eval(s):e(o)))}(e),e}},function(e){e.exports=require('string_decoder')},function(e,t,n){'use strict';var r=n(14);e.exports=r},function(e){'use strict';var t={};e.exports=t;var n={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(n).forEach(function(e){var r=n[e],o=t[e]=[];o.open='\x1B['+r[0]+'m',o.close='\x1B['+r[1]+'m'})},function(e){'use strict';var t=process.argv;e.exports=function(){return-1!==t.indexOf('--no-color')||-1!==t.indexOf('--color=false')?!1:-1!==t.indexOf('--color')||-1!==t.indexOf('--color=true')||-1!==t.indexOf('--color=always')||(process.stdout&&!process.stdout.isTTY?!1:!('win32'!==process.platform)||!!('COLORTERM'in process.env)||'dumb'!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM))}()},function(e){function t(e){throw new Error('Cannot find module \''+e+'\'.')}t.keys=function(){return[]},t.resolve=t,e.exports=t,t.id=63},function(e){'use strict';e.exports=function(e){var t='';e=e||'Run the trap, drop the bass',e=e.split('');var n={a:['@','\u0104','\u023A','\u0245','\u0394','\u039B','\u0414'],b:['\xDF','\u0181','\u0243','\u026E','\u03B2','\u0E3F'],c:['\xA9','\u023B','\u03FE'],d:['\xD0','\u018A','\u0500','\u0501','\u0502','\u0503'],e:['\xCB','\u0115','\u018E','\u0258','\u03A3','\u03BE','\u04BC','\u0A6C'],f:['\u04FA'],g:['\u0262'],h:['\u0126','\u0195','\u04A2','\u04BA','\u04C7','\u050A'],i:['\u0F0F'],j:['\u0134'],k:['\u0138','\u04A0','\u04C3','\u051E'],l:['\u0139'],m:['\u028D','\u04CD','\u04CE','\u0520','\u0521','\u0D69'],n:['\xD1','\u014B','\u019D','\u0376','\u03A0','\u048A'],o:['\xD8','\xF5','\xF8','\u01FE','\u0298','\u047A','\u05DD','\u06DD','\u0E4F'],p:['\u01F7','\u048E'],q:['\u09CD'],r:['\xAE','\u01A6','\u0210','\u024C','\u0280','\u042F'],s:['\xA7','\u03DE','\u03DF','\u03E8'],t:['\u0141','\u0166','\u0373'],u:['\u01B1','\u054D'],v:['\u05D8'],w:['\u0428','\u0460','\u047C','\u0D70'],x:['\u04B2','\u04FE','\u04FC','\u04FD'],y:['\xA5','\u04B0','\u04CB'],z:['\u01B5','\u0240']};return e.forEach(function(e){e=e.toLowerCase();var r=n[e]||[' '],o=Math.floor(Math.random()*r.length);t+='undefined'==typeof n[e]?e:n[e][o]}),t}},function(e){'use strict';e.exports=function(e){function t(e){var t=Math.floor(Math.random()*e);return t}function n(e){var t=!1;return o.filter(function(n){t=n===e}),t}e=e||' he is here ';var r={up:['\u030D','\u030E','\u0304','\u0305','\u033F','\u0311','\u0306','\u0310','\u0352','\u0357','\u0351','\u0307','\u0308','\u030A','\u0342','\u0313','\u0308','\u034A','\u034B','\u034C','\u0303','\u0302','\u030C','\u0350','\u0300','\u0301','\u030B','\u030F','\u0312','\u0313','\u0314','\u033D','\u0309','\u0363','\u0364','\u0365','\u0366','\u0367','\u0368','\u0369','\u036A','\u036B','\u036C','\u036D','\u036E','\u036F','\u033E','\u035B','\u0346','\u031A'],down:['\u0316','\u0317','\u0318','\u0319','\u031C','\u031D','\u031E','\u031F','\u0320','\u0324','\u0325','\u0326','\u0329','\u032A','\u032B','\u032C','\u032D','\u032E','\u032F','\u0330','\u0331','\u0332','\u0333','\u0339','\u033A','\u033B','\u033C','\u0345','\u0347','\u0348','\u0349','\u034D','\u034E','\u0353','\u0354','\u0355','\u0356','\u0359','\u035A','\u0323'],mid:['\u0315','\u031B','\u0300','\u0301','\u0358','\u0321','\u0322','\u0327','\u0328','\u0334','\u0335','\u0336','\u035C','\u035D','\u035E','\u035F','\u0360','\u0362','\u0338','\u0337','\u0361',' \u0489']},o=[].concat(r.up,r.down,r.mid),a={};return function(e,o){var a='',s,c;for(c in o=o||{},o.up=o.up||!0,o.mid=o.mid||!0,o.down=o.down||!0,o.size=o.size||'maxi',e=e.split(''),e)if(!n(c)){switch(a+=e[c],s={up:0,down:0,mid:0},o.size){case'mini':s.up=t(8),s.min=t(2),s.down=t(8);break;case'maxi':s.up=t(16)+3,s.min=t(4)+1,s.down=t(64)+3;break;default:s.up=t(8)+1,s.mid=t(6)/2,s.down=t(8)+1;}var l=['up','mid','down'];for(var u in l)for(var d=l[u],p=0;p<=s[d];p++)o[d]&&(a+=r[d][t(r[d].length)])}return a}(e)}},function(e,t,n){'use strict';var r=n(14);e.exports=function(){return function(e,t){if(' '===e)return e;switch(t%3){case 0:return r.red(e);case 1:return r.white(e);case 2:return r.blue(e);}}}()},function(e,t,n){'use strict';var r=n(14);e.exports=function(e,t){return 0==t%2?e:r.inverse(e)}},function(e,t,n){'use strict';var r=n(14);e.exports=function(){var e=['red','yellow','green','blue','magenta'];return function(t,n){return' '===t?t:r[e[n++%e.length]](t)}}()},function(e,t,n){'use strict';var r=n(14);e.exports=function(){var e=['underline','inverse','grey','yellow','red','green','blue','white','cyan','magenta'];return function(t){return' '===t?t:r[e[Math.round(Math.random()*(e.length-1))]](t)}}()},function(e,t){'use strict';var n=t;n.levels={error:0,warn:1,help:2,data:3,info:4,debug:5,prompt:6,verbose:7,input:8,silly:9},n.colors={error:'red',warn:'yellow',help:'cyan',data:'grey',info:'green',debug:'blue',prompt:'grey',verbose:'cyan',input:'grey',silly:'magenta'}},function(e,t){'use strict';var n=t;n.levels={error:0,warn:1,info:2,verbose:3,debug:4,silly:5},n.colors={error:'red',warn:'yellow',info:'green',verbose:'cyan',debug:'blue',silly:'magenta'}},function(e,t){'use strict';var n=t;n.levels={emerg:0,alert:1,crit:2,error:3,warning:4,notice:5,info:6,debug:7},n.colors={emerg:'red',alert:'yellow',crit:'red',error:'red',warning:'red',notice:'yellow',info:'green',debug:'blue'}},function(e,t,n){'use strict';var r=n(3),o=n(4),a=n(12),s=n(7),i=n(28),l=n(29),d=n(9),c=n(15).Transport,u=n(74).isWritable,p=n(11).Stream,m=n(8),g=t.File=function(e){function t(t){Array.prototype.slice.call(arguments,1).forEach(function(n){if(e[n])throw new Error('Cannot set '+n+' and '+t+'together')})}var n=this;if(c.call(this,e),e.filename||e.dirname)t('filename or dirname','stream'),this._basename=this.filename=e.filename?a.basename(e.filename):'winston.log',this.dirname=e.dirname||a.dirname(e.filename),this.options=e.options||{flags:'a'},this.options.highWaterMark=this.options.highWaterMark||24;else if(e.stream)t('stream','filename','maxsize'),this._stream=e.stream,this._isStreams2=u(this._stream),this._stream.on('error',function(e){n.emit('error',e)}),this._stream.setMaxListeners(Infinity);else throw new Error('Cannot log to file without filename or stream.');this.json=!1!==e.json,this.logstash=e.logstash||!1,this.colorize=e.colorize||!1,this.maxsize=e.maxsize||null,this.rotationFormat=e.rotationFormat||!1,this.zippedArchive=e.zippedArchive||!1,this.maxFiles=e.maxFiles||null,this.prettyPrint=e.prettyPrint||!1,this.label=e.label||null,this.timestamp=null==e.timestamp||e.timestamp,this.eol=e.eol||m.EOL,this.tailable=e.tailable||!1,this.depth=e.depth||null,this.showLevel=void 0===e.showLevel||e.showLevel,this.maxRetries=e.maxRetries||2,this.json&&(this.stringify=e.stringify),this._size=0,this._created=0,this._buffer=[],this._draining=!1,this._opening=!1,this._failures=0,this._archive=null};s.inherits(g,c),g.prototype.name='file',g.prototype.log=function(e,t,n,r){if(this.silent)return r(null,!0);if(this._failures>=this.maxRetries)return r(new Error('Transport is in a failed state.'));var o=this;'string'!=typeof t&&(t=''+t);var a=d.log({level:e,message:t,meta:n,json:this.json,logstash:this.logstash,colorize:this.colorize,prettyPrint:this.prettyPrint,timestamp:this.timestamp,showLevel:this.showLevel,stringify:this.stringify,label:this.label,depth:this.depth,formatter:this.formatter,humanReadableUnhandledException:this.humanReadableUnhandledException});'string'==typeof a&&(a+=this.eol),this.filename?this.open(function(e){return e?o._buffer.push([a,r]):void(o._write(a,r),o._size+=a.length,o._lazyDrain())}):(this._write(a,r),this._size+=a.length,this._lazyDrain())},g.prototype._write=function(e,t){if(this._isStreams2)return this._stream.write(e),t&&process.nextTick(function(){t(null,!0)});var n=this._stream.write(e);return t?!1===n?this._stream.once('drain',function(){t(null,!0)}):void process.nextTick(function(){t(null,!0)}):void 0},g.prototype.query=function(e,t){function n(e,t){try{var n=JSON.parse(e);s(n)&&r(n)}catch(n){t||u.emit('error',n)}}function r(t){if(e.rows&&l.length>=e.rows&&'desc'!=e.order)return void(u.readable&&u.destroy());if(e.fields){var n={};e.fields.forEach(function(e){n[e]=t[e]}),t=n}'desc'===e.order&&l.length>=e.rows&&l.shift(),l.push(t)}function s(t){if(t&&'object'==typeof t){var n=new Date(t.timestamp);return e.from&&n<e.from||e.until&&n>e.until?void 0:!0}}'function'==typeof e&&(t=e,e={});var i=a.join(this.dirname,this.filename),e=this.normalizeQuery(e),d='',l=[],c=0,u=o.createReadStream(i,{encoding:'utf8'});u.on('error',function(e){return u.readable&&u.destroy(),t?'ENOENT'===e.code?t(null,l):t(e):void 0}),u.on('data',function(t){for(var t=(d+t).split(/\n+/),r=t.length-1,o=0;o<r;o++)(!e.start||c>=e.start)&&n(t[o]),c++;d=t[r]}),u.on('close',function(){d&&n(d,!0),'desc'===e.order&&(l=l.reverse()),t&&t(null,l)})},g.prototype.stream=function(e){var t=a.join(this.dirname,this.filename),e=e||{},n=new p,r={file:t,start:e.start};return n.destroy=d.tailFile(r,function(e,t){if(e)return n.emit('error',e);try{n.emit('data',t),t=JSON.parse(t),n.emit('log',t)}catch(t){n.emit('error',t)}}),n},g.prototype.open=function(e){if(this.opening)return e(!0);return!this._stream||this.maxsize&&this._size>=this.maxsize?(e(!0),this._createStream()):void(this._archive=this.zippedArchive?this._stream.path:null,e())},g.prototype.close=function(){var e=this;this._stream&&(this._stream.end(),this._stream.destroySoon(),this._stream.once('finish',function(){e.emit('flush'),e.emit('closed')}))},g.prototype.flush=function(){var e=this;return this._buffer.length?void(this._buffer.forEach(function(t){var n=t[0],r=t[1];process.nextTick(function(){e._write(n,r),e._size+=n.length})}),e._buffer.length=0,e._stream.once('drain',function(){e.emit('flush'),e.emit('logged')})):e.emit('flush')},g.prototype._createStream=function(){var e=this;this.opening=!0,function t(n){function r(t){e._stream&&(e._stream.end(),e._stream.destroySoon()),e._size=t,e.filename=n,e._stream=o.createWriteStream(i,e.options),e._isStreams2=u(e._stream),e._stream.on('error',function(t){e._failures<e.maxRetries?(e._createStream(),e._failures++):e.emit('error',t)}),e._stream.setMaxListeners(Infinity),e.once('flush',function(){e.flush(),e.opening=!1,e.emit('open',i)}),e.flush(),s()}function s(){if(e._archive){var t=l.createGzip(),n=o.createReadStream(e._archive+''),r=o.createWriteStream(e._archive+'.gz');n.pipe(t).pipe(r),o.unlink(e._archive+''),e._archive=''}}var i=a.join(e.dirname,n);o.stat(i,function(n,o){return n?'ENOENT'===n.code?r(0):e.emit('error',n):!o||e.maxsize&&o.size>=e.maxsize?e._incFile(function(){t(e._getFile())}):void r(o.size)})}(this._getFile())},g.prototype._incFile=function(e){var t=a.extname(this._basename),n=a.basename(this._basename,t);this.tailable?this._checkMaxFilesTailable(t,n,e):(this._created+=1,this._checkMaxFilesIncrementing(t,n,e))},g.prototype._getFile=function(){var e=a.extname(this._basename),t=a.basename(this._basename,e);return!this.tailable&&this._created?t+(this.rotationFormat?this.rotationFormat():this._created)+e:t+e},g.prototype._checkMaxFilesIncrementing=function(e,t,n){var r=this,s,i;return r.zippedArchive&&(r._archive=a.join(r.dirname,t+(1===r._created?'':r._created-1)+e)),!r.maxFiles||r._created<r.maxFiles?n():void(s=r._created-r.maxFiles,i=a.join(r.dirname,t+(0===s?'':s)+e+(r.zippedArchive?'.gz':'')),o.unlink(i,n))},g.prototype._checkMaxFilesTailable=function(e,t,n){var r=[],s=this;if(this.maxFiles){for(var l=this.maxFiles-1;0<l;l--)r.push(function(n){return function(r){var i=a.join(s.dirname,t+(n-1)+e+(s.zippedArchive?'.gz':''));o.exists(i,function(l){return l?void o.rename(i,a.join(s.dirname,t+n+e+(s.zippedArchive?'.gz':'')),r):r(null)})}}(l));s.zippedArchive&&(s._archive=a.join(s.dirname,t+1+e)),i.series(r,function(){o.rename(a.join(s.dirname,t+e),a.join(s.dirname,t+1+e),n)})}},g.prototype._lazyDrain=function(){var e=this;!this._draining&&this._stream&&(this._draining=!0,this._stream.once('drain',function(){this._draining=!1,e.emit('logged')}))}},function(e,t,n){'use strict';function r(e){return e instanceof s.Stream}function o(e){return r(e)&&'function'==typeof e._read&&'object'==typeof e._readableState}function a(e){return r(e)&&'function'==typeof e._write&&'object'==typeof e._writableState}var s=n(11);e.exports=r,e.exports.isReadable=o,e.exports.isWritable=a,e.exports.isDuplex=function(e){return o(e)&&a(e)}},function(e,t,n){'use strict';var r=n(7),o=n(10),a=n(76),s=n(77),i=n(11).Stream,l=n(15).Transport,d=t.Http=function(e){l.call(this,e),e=e||{},this.name='http',this.ssl=!!e.ssl,this.host=e.host||'localhost',this.port=e.port,this.auth=e.auth,this.path=e.path||'',this.agent=e.agent,this.port||(this.port=this.ssl?443:80)};r.inherits(d,o.Transport),d.prototype.name='http',d.prototype._request=function(e,t){e=e||{};var n=e.auth||this.auth,r=e.path||this.path||'',o;delete e.auth,delete e.path,o=(this.ssl?s:a).request({host:this.host,port:this.port,path:'/'+r.replace(/^\//,''),method:'POST',headers:{"Content-Type":'application/json'},agent:this.agent,auth:n?n.username+':'+n.password:''}),o.on('error',t),o.on('response',function(e){var n='';e.on('data',function(e){n+=e}),e.on('end',function(){t(null,e,n)}),e.resume()}),o.end(new Buffer(JSON.stringify(e),'utf8'))},d.prototype.log=function(e,t,n,r){var o=this;'function'==typeof n&&(r=n,n={});var a={method:'collect',params:{level:e,message:t,meta:n}};n&&(n.path&&(a.path=n.path,delete n.path),n.auth&&(a.auth=n.auth,delete n.auth)),this._request(a,function(e,t){return t&&200!==t.statusCode&&(e=new Error('HTTP Status Code: '+t.statusCode)),e?r(e):void(o.emit('logged'),r&&r(null,!0))})},d.prototype.query=function(e,t){'function'==typeof e&&(t=e,e={});var n=this,e=this.normalizeQuery(e);e={method:'query',params:e},e.params.path&&(e.path=e.params.path,delete e.params.path),e.params.auth&&(e.auth=e.params.auth,delete e.params.auth),this._request(e,function(e,n,r){if(n&&200!==n.statusCode&&(e=new Error('HTTP Status Code: '+n.statusCode)),e)return t(e);if('string'==typeof r)try{r=JSON.parse(r)}catch(n){return t(n)}t(null,r)})},d.prototype.stream=function(e){e=e||{};var t=this,n=new i,r,o;return n.destroy=function(){r.destroy()},e={method:'stream',params:e},e.params.path&&(e.path=e.params.path,delete e.params.path),e.params.auth&&(e.auth=e.params.auth,delete e.params.auth),r=this._request(e),o='',r.on('data',function(e){for(var e=(o+e).split(/\n+/),t=e.length-1,r=0;r<t;r++)try{n.emit('log',JSON.parse(e[r]))}catch(t){n.emit('error',t)}o=e[t]}),r.on('error',function(e){n.emit('error',e)}),n}},function(e){e.exports=require('http')},function(e){e.exports=require('https')},function(e,t,n){'use strict';var r=n(3),o=n(7),a=n(9),s=n(15).Transport,i=t.Memory=function(e){s.call(this,e),e=e||{},this.errorOutput=[],this.writeOutput=[],this.json=e.json||!1,this.colorize=e.colorize||!1,this.prettyPrint=e.prettyPrint||!1,this.timestamp='undefined'!=typeof e.timestamp&&e.timestamp,this.showLevel=!(e.showLevel!==void 0)||e.showLevel,this.label=e.label||null,this.depth=e.depth||null,this.json&&(this.stringify=e.stringify||function(e){return JSON.stringify(e,null,2)})};o.inherits(i,s),i.prototype.name='memory',i.prototype.log=function(e,t,n,r){if(this.silent)return r(null,!0);var o=this,s;s=a.log({colorize:this.colorize,json:this.json,level:e,message:t,meta:n,stringify:this.stringify,timestamp:this.timestamp,prettyPrint:this.prettyPrint,raw:this.raw,label:this.label,depth:this.depth,formatter:this.formatter,humanReadableUnhandledException:this.humanReadableUnhandledException}),'error'===e||'debug'===e?this.errorOutput.push(s):this.writeOutput.push(s),o.emit('logged'),r(null,!0)},i.prototype.clearLogs=function(){this.errorOutput=[],this.writeOutput=[]}},function(e,t){'use strict';function n(e){for(var t in e)this[t]=e[t]}t.get=function(e){var n=Error.stackTraceLimit;Error.stackTraceLimit=Infinity;var r={},o=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t},Error.captureStackTrace(r,e||t.get);var a=r.stack;return Error.prepareStackTrace=o,Error.stackTraceLimit=n,a},t.parse=function(e){if(!e.stack)return[];var t=this,n=e.stack.split('\n').slice(1);return n.map(function(e){if(e.match(/^\s*[-]{4,}$/))return t._createParsedCallSite({fileName:e,lineNumber:null,functionName:null,typeName:null,methodName:null,columnNumber:null,native:null});var n=e.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/);if(n){var r=null,o=null,a=null,s=null,i=null,l='native'===n[5];if(n[1]){a=n[1];var d=a.lastIndexOf('.');if('.'==a[d-1]&&d--,0<d){r=a.substr(0,d),o=a.substr(d+1);var c=r.indexOf('.Module');0<c&&(a=a.substr(c+1),r=r.substr(0,c))}s=null}o&&(s=r,i=o),'<anonymous>'===o&&(i=null,a=null);var u={fileName:n[2]||null,lineNumber:parseInt(n[3],10)||null,functionName:a,typeName:s,methodName:i,columnNumber:parseInt(n[4],10)||null,native:l};return t._createParsedCallSite(u)}}).filter(function(e){return!!e})};['this','typeName','functionName','methodName','fileName','lineNumber','columnNumber','function','evalOrigin'].forEach(function(e){n.prototype[e]=null,n.prototype['get'+e[0].toUpperCase()+e.substr(1)]=function(){return this[e]}}),['topLevel','eval','native','constructor'].forEach(function(e){n.prototype[e]=!1,n.prototype['is'+e[0].toUpperCase()+e.substr(1)]=function(){return this[e]}}),t._createParsedCallSite=function(e){return new n(e)}},function(e,t,n){'use strict';var r=n(9),o=n(10),a=n(7)._extend,s=t.Container=function(e){this.loggers={},this.options=e||{},this.default={transports:[new o.transports.Console({level:'silly',colorize:!1})]}};s.prototype.get=s.prototype.add=function(e,t){var n=this,s;return this.loggers[e]||(t=a({},t||this.options||this.default),s=t.transports||this.options.transports,t.transports=s?s.slice():[],0===t.transports.length&&(!t||!t.console)&&t.transports.push(this.default.transports[0]),Object.keys(t).forEach(function(n){if('transports'!==n){var a=r.capitalize(n);if(!o.transports[a])throw new Error('Cannot add unknown transport: '+a);var s=t[n];s.id=e,t.transports.push(new o.transports[a](s))}}),t.id=e,this.loggers[e]=new o.Logger(t),this.loggers[e].on('close',function(){n._delete(e)})),this.loggers[e]},s.prototype.has=function(e){return!!this.loggers[e]},s.prototype.close=function(e){function t(e){n.loggers[e]&&(n.loggers[e].close(),n._delete(e))}var n=this;return e?t(e):Object.keys(this.loggers).forEach(function(e){t(e)})},s.prototype._delete=function(e){delete this.loggers[e]}},function(e,t,n){'use strict';function r(e){this.logger=e,this.start=Date.now()}var o=n(3),a=n(7),s=n(28),i=n(16),l=n(9),d=n(30),c=n(11).Stream,u=/%[sdj%]/g,p=t.Logger=function(e){o.EventEmitter.call(this),this.configure(e)};a.inherits(p,o.EventEmitter),p.prototype.configure=function(e){var t=this;Array.isArray(this._names)&&this._names.length&&this.clear(),e=e||{},this.transports={},this._names=[],e.transports&&e.transports.forEach(function(e){t.add(e,null,!0)}),this.padLevels=e.padLevels||!1,this.setLevels(e.levels),e.colors&&i.addColors(e.colors),this.id=e.id||null,this.level=e.level||'info',this.emitErrs=e.emitErrs||!1,this.stripColors=e.stripColors||!1,this.exitOnError=!('undefined'!=typeof e.exitOnError)||e.exitOnError,this.exceptionHandlers={},this.profilers={},['rewriters','filters'].forEach(function(n){t[n]=Array.isArray(e[n])?e[n]:[]}),e.exceptionHandlers&&this.handleExceptions(e.exceptionHandlers)},p.prototype.log=function(e){function t(e){i?i(e):o.emitErrs&&o.emit('error',e)}function n(t){if(i){if(t)return i(t);i(null,e,f,d)}i=null,t||o.emit('logged',e,f,d)}for(var r=Array.prototype.slice.call(arguments,1),o=this;null===r[r.length-1];)r.pop();var i='function'==typeof r[r.length-1]?r.pop():null;if(0===this._names.length)return t(new Error('Cannot log with no transports.'));if('undefined'==typeof o.levels[e])return t(new Error('Unknown log level: '+e));var l=this._names.filter(function(t){var n=o.transports[t];return n.level&&o.levels[n.level]>=o.levels[e]||!n.level&&o.levels[o.level]>=o.levels[e]});if(!l.length)return void(i&&i());var d={},c=!1,p=r&&r[0]&&r[0].match&&null!==r[0].match(u),m=p?r[0].match(u):[],g=m.filter(function(e){return'%%'===e}),f;if(0<r.length-1-(m.length-g.length)||1===r.length){d=r[r.length-1]||r;var h=Object.prototype.toString.call(d);c='[object Object]'===h||'[object Error]'===h||'[object Array]'===h,d=c?r.pop():{}}if(f=a.format.apply(null,r),this.padLevels&&(f=Array(this.levelLength-e.length+1).join(' ')+f),this.rewriters.forEach(function(t){d=t(e,f,d,o)}),this.filters.forEach(function(t){var n=t(e,f,d,o);'string'==typeof n?f=n:(f=n.msg,d=n.meta)}),this.stripColors){var _=/\u001b\[(\d+(;\d+)*)?m/g;f=(''+f).replace(_,'')}return s.forEach(l,function(t,r){var a=o.transports[t];a.log(e,f,d,function(t){return t?(t.transport=a,n(t),r()):void(o.emit('logging',a,e,f,d),r())})},n),this},p.prototype.query=function(e,t){function n(t,n){e.query&&(e.query=t.formatQuery(a)),t.query(e,function(r,o){return r?n(r):void n(null,t.formatResults(o,e.format))})}'function'==typeof e&&(t=e,e={});var r=this,e=e||{},o={},a=l.clone(e.query)||{},i;return e.transport?(e.transport=e.transport.toLowerCase(),n(this.transports[e.transport],t)):void(i=this._names.map(function(e){return r.transports[e]}).filter(function(e){return!!e.query}),s.forEach(i,function(e,t){n(e,function(n,r){t&&(r=n||r,r&&(o[e.name]=r),t()),t=null})},function(){t(null,o)}))},p.prototype.stream=function(e){var t=this,e=e||{},n=new c,r=[],o;if(e.transport){var a=this.transports[e.transport];if(delete e.transport,a&&a.stream)return a.stream(e)}return n._streams=r,n.destroy=function(){for(var e=r.length;e--;)r[e].destroy()},o=this._names.map(function(e){return t.transports[e]}).filter(function(e){return!!e.stream}),o.forEach(function(t){var o=t.stream(e);o&&(r.push(o),o.on('log',function(e){e.transport=e.transport||[],e.transport.push(t.name),n.emit('log',e)}),o.on('error',function(e){e.transport=e.transport||[],e.transport.push(t.name),n.emit('error',e)}))}),n},p.prototype.close=function(){var e=this;this._names.forEach(function(t){var n=e.transports[t];n&&n.close&&n.close()}),this.emit('close')},p.prototype.handleExceptions=function(){var e=Array.prototype.slice.call(arguments),t=[],n=this;e.forEach(function(e){Array.isArray(e)?t=t.concat(e):t.push(e)}),this.exceptionHandlers=this.exceptionHandlers||{},t.forEach(function(e){n.exceptionHandlers[e.name]=e}),this._hnames=Object.keys(n.exceptionHandlers),this.catchExceptions||(this.catchExceptions=this._uncaughtException.bind(this),process.on('uncaughtException',this.catchExceptions))},p.prototype.unhandleExceptions=function(){var e=this;this.catchExceptions&&(Object.keys(this.exceptionHandlers).forEach(function(t){var n=e.exceptionHandlers[t];n.close&&n.close()}),this.exceptionHandlers={},Object.keys(this.transports).forEach(function(t){var n=e.transports[t];n.handleExceptions&&(n.handleExceptions=!1)}),process.removeListener('uncaughtException',this.catchExceptions),this.catchExceptions=!1)},p.prototype.add=function(e,t,n){var r=n?e:new e(t);if(!r.name&&!r.log)throw new Error('Unknown transport with no log() method');else if(this.transports[r.name])throw new Error('Transport already attached: '+r.name+', assign a different name');return this.transports[r.name]=r,this._names=Object.keys(this.transports),r._onError=this._onError.bind(this,r),n||r.on('error',r._onError),r.handleExceptions&&!this.catchExceptions&&this.handleExceptions(),this},p.prototype.clear=function(){Object.keys(this.transports).forEach(function(e){this.remove({name:e})},this)},p.prototype.remove=function(e){var t='string'==typeof e?e:e.name||e.prototype.name;if(!this.transports[t])throw new Error('Transport '+t+' not attached to this instance');var n=this.transports[t];return delete this.transports[t],this._names=Object.keys(this.transports),n.close&&n.close(),n._onError&&n.removeListener('error',n._onError),this},p.prototype.startTimer=function(){return new r(this)},p.prototype.profile=function(e){var t=Date.now(),n,r,o,a,s;return this.profilers[e]?(n=this.profilers[e],delete this.profilers[e],r=Array.prototype.slice.call(arguments),s='function'==typeof r[r.length-1]?r.pop():null,a='object'==typeof r[r.length-1]?r.pop():{},o=2===r.length?r[1]:e,a.durationMs=t-n,this.info(o,a,s)):(this.profilers[e]=t,this)},p.prototype.setLevels=function(e){return l.setLevels(this,this.levels,e)},p.prototype.cli=function(){return this.padLevels=!0,this.setLevels(i.cli.levels),i.addColors(i.cli.colors),this.transports.console&&(this.transports.console.colorize=this.transports.console.colorize||!0,this.transports.console.timestamp=this.transports.console.timestamp||!1),this},p.prototype._uncaughtException=function(e){function t(){l&&!r&&(clearTimeout(i),r=!0,process.exit(1))}var n=this,r=!1,o=d.getAllInfo(e),a=this._getExceptionHandlers(),i,l;return l='function'==typeof this.exitOnError?this.exitOnError(e):this.exitOnError,a&&0!==a.length?void(s.forEach(a,function(t,n){t.logException('uncaughtException: '+(e.message||e),o,n,e)},t),l&&(i=setTimeout(t,3e3))):t()},p.prototype._getExceptionHandlers=function(){var e=this;return this._hnames.map(function(t){return e.exceptionHandlers[t]}).concat(this._names.map(function(t){return e.transports[t].handleExceptions&&e.transports[t]})).filter(Boolean)},p.prototype._onError=function(e,t){this.emitErrs&&this.emit('error',t,e)},r.prototype.done=function(e){var t=Array.prototype.slice.call(arguments),n='function'==typeof t[t.length-1]?t.pop():null,r='object'==typeof t[t.length-1]?t.pop():{};return r.duration=Date.now()-this.start+'ms',this.logger.info(e,r,n)}},function(e){'use strict';function t(e){var t=!1;if(null!=e&&'function'!=typeof e.toString)try{t=!!(e+'')}catch(t){}return t}function n(e){return!!e&&'object'==typeof e}var r=Function.prototype,o=Object.prototype,a=r.toString,s=o.hasOwnProperty,i=a.call(Object),l=o.toString,d=function(e,t){return function(n){return e(t(n))}}(Object.getPrototypeOf,Object);e.exports=function(e){if(!n(e)||l.call(e)!='[object Object]'||t(e))return!1;var r=d(e);if(null===r)return!0;var o=s.call(r,'constructor')&&r.constructor;return'function'==typeof o&&o instanceof o&&a.call(o)==i}},function(e,t,n){'use strict';function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}Object.defineProperty(t,'__esModule',{value:!0});var o=n(0);t.default=class{run({remoteHost:e,remotePort:t,onClose:n}){return r(function*(){o.logger.warn(`[behaviour] [${e}:${t}] connection closed`),n()})()}}},function(e,t,n){'use strict';function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}var o=Number.isInteger;Object.defineProperty(t,'__esModule',{value:!0});var a=n(0);const s=10,i=40;t.default=class{constructor({min:e,max:t}){if(this.min=s,this.max=i,void 0!==e){if(!o(e))throw Error('\'min\' must be an integer');if(0>e)throw Error('\'min\' must be greater than 0')}if(void 0!==t){if(!o(t))throw Error('\'max\' must be an integer');if(0>t)throw Error('\'max\' must be greater than 0')}if(void 0!==e&&void 0!==t&&e>t)throw Error('\'max\' must be greater than or equal to \'min\'');this.min=void 0===e?s:e,this.max=void 0===t?i:t}run({remoteHost:e,remotePort:t,onClose:n}){var o=this;return r(function*(){const r=(0,a.getRandomInt)(o.min,o.max);return a.logger.warn(`[behaviour] [${e}:${t}] connection will be closed in ${r}s...`),new Promise(function(e){setTimeout(function(){n(),e()},1e3*r)})})()}}},function(e,t,n){'use strict';function r(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}Object.defineProperty(t,'__esModule',{value:!0});var o=n(0);t.default=class{constructor({host:e,port:t}){if(this._host='',this._port='',!(0,o.isValidHostname)(e))throw Error('\'host\' is invalid');if(!(0,o.isValidPort)(t))throw Error('\'port\' is invalid');this._host=e,this._port=t}run({action:e,remoteHost:t,remotePort:n,connect:a,setPresets:s}){var i=this;return r(function*(){const r=e.payload.orgData;var l=[i._host,i._port];const d=l[0],c=l[1];o.logger.warn(`[behaviour] [${t}:${n}] connection is redirecting to ${d}:${c}`),s(function(){return[{name:'tracker'}]});const u=yield a({host:d,port:c});u&&u.writable&&u.write(r)})()}}},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(13),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(1),s=n(87);class i extends a.IPreset{constructor(...e){var t;return t=super(...e),this._proxy=null,t}handleProxy({buffer:e,next:t,broadcast:n}){if(null===this._proxy&&(this._proxy=new s.Proxifier({onHandshakeDone:(e,r)=>{var i=[e.type===s.ATYP_DOMAIN?e.host.toString():o.default.toString(e.host),e.port.readUInt16BE(0)];const l=i[0],d=i[1];n({type:a.SOCKET_CONNECT_TO_REMOTE,payload:{host:l,port:d,onConnected:()=>r(t)}})}})),!this._proxy.isDone()){this._proxy.makeHandshake((e)=>t(e,!0),e)}else return e}clientOut(e){return this.handleProxy(e)}serverIn(e){return this.handleProxy(e)}}t.default=i},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(2);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(90);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});t.Message=class{static parse(){return null}toBuffer(){return Buffer.from([])}}},function(e,t){'use strict';Object.defineProperty(t,'__esModule',{value:!0});const n=t.NOOP=0,r=t.SOCKS_VERSION_V4=4,o=t.SOCKS_VERSION_V5=5,a=t.METHOD_NO_AUTH=0,s=t.REQUEST_COMMAND_CONNECT=1,i=t.REQUEST_COMMAND_BIND=2,l=t.REQUEST_COMMAND_UDP=3,d=t.ATYP_V4=1,c=t.ATYP_DOMAIN=3,u=t.ATYP_V6=4,p=t.REPLY_GRANTED=90,m=t.REPLY_SUCCEEDED=0,g=t.REPLY_COMMAND_NOT_SUPPORTED=7,f=t.REPLY_UNASSIGNED=255},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0}),t.Proxifier=void 0;var o=n(6),a=r(o),s=n(13),i=r(s),l=n(0),d=n(91),c=n(97),u=n(100),p=n(2);t.Proxifier=class{constructor(e){this._socksTcpReady=!1,this._socksUdpReady=!1,this._httpReady=!1,this.onHandshakeDone=e.onHandshakeDone}isDone(){return this._socksTcpReady||this._socksUdpReady||this._httpReady}makeHandshake(e,t){this._trySocksHandshake(e,t),this.isDone()||this._tryHttpHandshake(e,t)}_trySocksHandshake(e,t){this.isDone()||this._trySocks5Handshake(e,t),this.isDone()||this._trySocks4Handshake(e,t)}_trySocks4Handshake(e,t){const n=c.RequestMessage.parse(t);if(null!==n){const t=n.CMD,r=n.DSTIP,o=n.DSTADDR,a=n.DSTPORT;if(t===p.REQUEST_COMMAND_CONNECT){const t={type:0<o.length?p.ATYP_DOMAIN:p.ATYP_V4,host:0<o.length?o:r,port:a};this.onHandshakeDone(t,()=>{const t=new c.ReplyMessage({CMD:p.REPLY_GRANTED});e(t.toBuffer()),this._socksTcpReady=!0})}}}_trySocks5Handshake(e,t){const n=d.IdentifierMessage.parse(t);if(null!==n){const t=new d.SelectMessage;return void e(t.toBuffer())}const r=d.RequestMessage.parse(t);if(null!==r){const t=r.CMD;switch(t){case p.REQUEST_COMMAND_UDP:case p.REQUEST_COMMAND_CONNECT:{const n={type:r.ATYP,host:r.DSTADDR,port:r.DSTPORT};this.onHandshakeDone(n,()=>{const n=new d.ReplyMessage({REP:p.REPLY_SUCCEEDED});e(n.toBuffer()),t===p.REQUEST_COMMAND_CONNECT?this._socksTcpReady=!0:this._socksUdpReady=!0});break}default:{const t=new d.ReplyMessage({REP:p.REPLY_COMMAND_NOT_SUPPORTED});e(t.toBuffer());break}}}}_tryHttpHandshake(e,t){const n=u.HttpRequestMessage.parse(t);if(null!==n){const r=n.METHOD,o=n.URI,s=n.HOST,d=r.toString();let c={};if('CONNECT'===d)c=(0,l.parseURI)(o.toString());else{let e=null,t=s.toString();a.default.isIP(t)?(e=a.default.isIPv4(t)?p.ATYP_V4:p.ATYP_V6,t=i.default.toBuffer(t)):(e=p.ATYP_DOMAIN,t=s),c={type:e,host:t,port:Buffer.from([0,80])}}this.onHandshakeDone(c,(n)=>{if('CONNECT'===d){const t=new u.ConnectReplyMessage;e(t.toBuffer())}else n(t);this._httpReady=!0})}}}},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(92);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(93);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var a=n(94);Object.keys(a).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var s=n(95);Object.keys(s).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var i=n(96);Object.keys(i).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.IdentifierMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.SOCKS_VERSION_V5,NMETHODS:1,METHODS:[o.METHOD_NO_AUTH]},e);this.VER=t.VER,this.NMETHODS=t.NMETHODS,this.METHODS=t.METHODS}static parse(e){return 3>e.length?null:e[0]===o.SOCKS_VERSION_V5?1>e[1]?null:e.slice(2).length===e[1]?new a({VER:e[0],NMETHODS:e[1],METHODS:e.slice(2)}):null:null}toBuffer(){return Buffer.from([this.VER,this.NMETHODS,...this.METHODS])}}t.IdentifierMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.SelectMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.SOCKS_VERSION_V5,METHOD:o.METHOD_NO_AUTH},e);this.VER=t.VER,this.METHOD=t.METHOD}toBuffer(){return Buffer.from([this.VER,this.METHOD])}}t.SelectMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.RequestMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.SOCKS_VERSION_V5,CMD:o.REQUEST_COMMAND_CONNECT,RSV:o.NOOP,ATYP:o.ATYP_V4,DSTADDR:[o.NOOP],DSTPORT:[o.NOOP,o.NOOP]},e);this.VER=t.VER,this.CMD=t.CMD,this.RSV=t.RSV,this.ATYP=t.ATYP,this.DSTADDR=t.DSTADDR,this.DSTPORT=t.DSTPORT}static parse(e){if(9>e.length)return null;if(e[0]!==o.SOCKS_VERSION_V5)return null;const t=[o.REQUEST_COMMAND_CONNECT,o.REQUEST_COMMAND_BIND,o.REQUEST_COMMAND_UDP];if(!t.includes(e[1]))return null;if(e[2]!==o.NOOP)return null;const n=[o.ATYP_V4,o.ATYP_DOMAIN,o.ATYP_V6];if(!n.includes(e[3]))return null;let r=null;switch(e[3]){case o.ATYP_DOMAIN:r=e.slice(5,5+e[4]);break;case o.ATYP_V6:r=e.slice(4,20);break;default:r=e.slice(4,8);}return new a({VER:e[0],CMD:e[1],RSV:e[2],ATYP:e[3],DSTADDR:r,DSTPORT:e.slice(-2)})}}t.RequestMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.ReplyMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.SOCKS_VERSION_V5,REP:o.REPLY_UNASSIGNED,RSV:o.NOOP,ATYP:o.ATYP_V4,BNDADDR:[o.NOOP,o.NOOP,o.NOOP,o.NOOP],BNDPORT:[o.NOOP,o.NOOP]},e);this.VER=t.VER,this.REP=t.REP,this.RSV=t.RSV,this.ATYP=t.ATYP,this.BNDADDR=t.BNDADDR,this.BNDPORT=t.BNDPORT}toBuffer(){return Buffer.from([this.VER,this.REP,this.RSV,this.ATYP,...this.BNDADDR,...this.BNDPORT])}}t.ReplyMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.UdpRequestMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({RSV:[o.NOOP,o.NOOP],FRAG:o.NOOP,ATYP:o.ATYP_V4,DSTADDR:[o.NOOP],DSTPORT:[o.NOOP,o.NOOP],DATA:[o.NOOP]},e);this.RSV=t.RSV,this.FRAG=t.FRAG,this.ATYP=t.ATYP,this.DSTADDR=t.DSTADDR,this.DSTPORT=t.DSTPORT,this.DATA=t.DATA}static parse(e){if(7>e.length)return null;if(e[0]!==o.NOOP||e[1]!==o.NOOP)return null;const t=[o.ATYP_V4,o.ATYP_DOMAIN,o.ATYP_V6];if(!t.includes(e[3]))return null;let n=null,r=null;switch(e[3]){case o.ATYP_DOMAIN:n=e.slice(5,5+e[4]),r=e.slice(5+e[4],7+e[4]);break;case o.ATYP_V6:n=e.slice(4,20),r=e.slice(20,22);break;default:n=e.slice(4,8),r=e.slice(8,10);}return new a({RSV:[o.NOOP,o.NOOP],FRAG:e[2],ATYP:e[3],DSTADDR:n,DSTPORT:r,DATA:e.slice(6+n.length)})}}t.UdpRequestMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(98);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(99);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.RequestMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.SOCKS_VERSION_V4,CMD:o.REQUEST_COMMAND_CONNECT,DSTPORT:[o.NOOP,o.NOOP],DSTIP:[o.NOOP,o.NOOP,o.NOOP,o.NOOP],USERID:[o.NOOP],DSTADDR:[o.NOOP]},e);this.VER=t.VER,this.CMD=t.CMD,this.DSTPORT=t.DSTPORT,this.DSTIP=t.DSTIP,this.USERID=t.USERID,this.DSTADDR=t.DSTADDR}static parse(e){if(9>e.length)return null;if(e[0]!==o.SOCKS_VERSION_V4)return null;const t=[o.REQUEST_COMMAND_CONNECT,o.REQUEST_COMMAND_BIND];if(!t.includes(e[1]))return null;if(e[e.length-1]!==o.NOOP)return null;const n=e.slice(4,8);let r=[],s=[];if(n[0]===o.NOOP&&n[1]===o.NOOP&&n[2]===o.NOOP&&n[3]!==o.NOOP){const t=e.slice(8),n=[];let a=[];var i=!0,l=!1,d;try{for(var c=t[Symbol.iterator](),u;!(i=(u=c.next()).done);i=!0){const e=u.value;e===o.NOOP?(n.push(a),a=[]):a.push(e)}}catch(e){l=!0,d=e}finally{try{!i&&c.return&&c.return()}finally{if(l)throw d}}if(2!==n.length||1>n[1].length)return null;r=n[0],s=Buffer.from(n[1])}return new a({VER:e[0],CMD:e[1],DSTPORT:e.slice(2,4),DSTIP:n,USERID:r,DSTADDR:s})}}t.RequestMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.ReplyMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e){super();const t=r({VER:o.NOOP,CMD:o.REPLY_GRANTED,DSTPORT:[o.NOOP,o.NOOP],DSTIP:[o.NOOP,o.NOOP,o.NOOP,o.NOOP]},e);this.VER=t.VER,this.CMD=t.CMD,this.DSTPORT=t.DSTPORT,this.DSTIP=t.DSTIP}toBuffer(){return Buffer.from([this.VER,this.CMD,...this.DSTPORT,...this.DSTIP])}}t.ReplyMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(101);Object.keys(r).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(102);Object.keys(o).forEach(function(e){'default'===e||'__esModule'===e||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.HttpRequestMessage=void 0;var r=function(){function e(e,t){var n=[],r=!0,o=!1,a;try{for(var s=e[Symbol.iterator](),i;!(r=(i=s.next()).done)&&(n.push(i.value),!(t&&n.length===t));r=!0);}catch(e){o=!0,a=e}finally{try{!r&&s['return']&&s['return']()}finally{if(o)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),o=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},a=n(2);class s extends a.Message{constructor(e={}){super();const t=o({},e);this.METHOD=t.METHOD,this.URI=t.URI,this.VERSION=t.VERSION,this.HOST=t.HOST}static parse(e){if(20>e.length)return null;const t=e.toString(),n=t.split('\r\n');if(4>n.length)return null;var o=n[0].split(' '),a=r(o,3);const i=a[0],l=a[1],d=a[2];if(['OPTIONS','GET','HEAD','POST','PUT','DELETE','TRACE','CONNECT'].includes(i)){const e=n.slice(1,-2);var c=!0,u=!1,p;try{for(var m=e[Symbol.iterator](),g;!(c=(g=m.next()).done);c=!0){const e=g.value;if(e.startsWith('Host: ')){const t=e.split(' ')[1];return new s({METHOD:Buffer.from(i),URI:Buffer.from(l),VERSION:Buffer.from(d),HOST:Buffer.from(t)})}}}catch(e){u=!0,p=e}finally{try{!c&&m.return&&m.return()}finally{if(u)throw p}}}return null}}t.HttpRequestMessage=s},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.ConnectReplyMessage=void 0;var r=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},o=n(2);class a extends o.Message{constructor(e={}){super();const t=r({VERSION:Buffer.from('HTTP/1.1'),STATUS:Buffer.from('200'),PHRASE:Buffer.from('Connection established')},e);this.VERSION=t.VERSION,this.STATUS=t.STATUS,this.PHRASE=t.PHRASE}toBuffer(){return Buffer.from([...this.VERSION,32,...this.STATUS,32,...this.PHRASE,13,10,13,10])}}t.ConnectReplyMessage=a},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(1),o=n(0);class a extends r.IPreset{constructor({host:e,port:t}){if(super(),this._host=null,this._port=null,this._isTunnelReady=!1,this._isBroadCasting=!1,this._staging=Buffer.alloc(0),'undefined'!=typeof e&&!(0,o.isValidHostname)(e))throw Error('host is invalid');if('undefined'!=typeof t&&!(0,o.isValidPort)(t))throw Error('port is invalid');e&&t&&(this._host=e,this._port=t)}handleTunnel({buffer:e,next:t,broadcast:n}){return this._isTunnelReady?e:void(this._isBroadCasting?this._staging=Buffer.concat([this._staging,e]):(this._isBroadCasting=!0,n({type:r.SOCKET_CONNECT_TO_REMOTE,payload:{host:this._host,port:this._port,onConnected:()=>{t(Buffer.concat([e,this._staging])),this._isTunnelReady=!0,this._isBroadCasting=!1,this._staging=null}}})))}clientOut(e){return this.handleTunnel(e)}serverIn(e){return this.handleTunnel(e)}}t.default=a},function(e,t,n){'use strict';var r=Math.max;Object.defineProperty(t,'__esModule',{value:!0});var o=Object.assign||function(e){for(var t=1,n;t<arguments.length;t++)for(var r in n=arguments[t],n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},a=n(4),s=function(e){return e&&e.__esModule?e:{default:e}}(a),i=n(1);const l=()=>new Date().getTime(),d=30,c=60;class u extends i.IPreset{constructor(e){var t=Number.isSafeInteger;super(),this.sampleInterval=d,this.saveInterval=c;const n=o({sample_interval:d,save_interval:c},e);if('string'!=typeof n.save_to||1>n.save_to.length)throw Error('\'save_to\' must be provided as a non-empty string');if('undefined'==typeof n.sample_interval)throw Error('\'sample_interval\' must be provided as an integer');if('number'!=typeof n.sample_interval)throw Error('\'sample_interval\' must be a number');if(!t(n.sample_interval))throw Error('\'sample_interval\' must be an integer');if(1>n.sample_interval)throw Error('\'sample_interval\' must be greater than 0');if('undefined'==typeof n.save_interval)throw Error('\'save_interval\' must be provided as an integer');if('number'!=typeof n.save_interval)throw Error('\'save_interval\' must be a number');if(!t(n.save_interval))throw Error('\'save_interval\' must be an integer');if(1>n.save_interval)throw Error('\'save_interval\' must be greater than 0');u.saveTo=n.save_to,this.sampleInterval=n.sample_interval,this.saveInterval=n.save_interval,null===u.sampleTimer&&(u.sampleTimer=setInterval(this.sample.bind(this),1e3*n.sample_interval)),null===u.saveTimer&&(u.saveTimer=setInterval(u.save,1e3*n.save_interval)),u.isHookExit||(process.on('SIGINT',u.save),u.isHookExit=!0),u.maxConnections+=1}static save(){const e=u.startedAt,t=l(),n=t-e,r=n/1e3,o=u.totalInPackets+u.totalOutPackets,a=u.totalIn+u.totalOut,i={sample:{from:e,to:t,duration:n},summary:{totalErrors:u.totalErrors,totalOut:u.totalOut,totalIn:u.totalIn,totalOutPackets:u.totalOutPackets,totalInPackets:u.totalInPackets,totalBytes:a,totalPackets:o,maxOutSpeed:u.maxOutSpeed,maxInSpeed:u.maxInSpeed,maxConnections:u.maxConnections-2},instant:{outSpeed:u.instantOutSpeed,inSpeed:u.instantInSpeed,errorRate:0<o.length?u.totalErrors/o:0,outBytesRate:u.totalOut/r,outPacketsRate:u.totalOutPackets/r,inBytesRate:u.totalIn/r,inPacketsRate:u.totalInPackets/r,totalBytesRate:a/r,totalPacketsRate:o/r},process:{upTime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage()}};s.default.writeFileSync(u.saveTo,JSON.stringify(i,null,' '))}sample(){u.instantOutSpeed=u.tmpOut/this.sampleInterval,u.instantInSpeed=u.tmpIn/this.sampleInterval,u.maxOutSpeed=r(u.maxOutSpeed,u.instantOutSpeed),u.maxInSpeed=r(u.maxInSpeed,u.instantInSpeed),u.tmpOut=0,u.tmpIn=0}onNotified(e){e.type===i.PROCESSING_FAILED&&(u.totalErrors+=1)}beforeOut({buffer:e}){return u.totalOut+=e.length,u.totalOutPackets+=1,u.tmpOut+=e.length,e}beforeIn({buffer:e}){return u.totalIn+=e.length,u.totalInPackets+=1,u.tmpIn+=e.length,e}}t.default=u,u.saveTo='',u.sampleTimer=null,u.saveTimer=null,u.isHookExit=!1,u.startedAt=l(),u.totalOut=0,u.totalIn=0,u.totalOutPackets=0,u.totalInPackets=0,u.totalErrors=0,u.maxConnections=0,u.instantOutSpeed=0,u.instantInSpeed=0,u.maxOutSpeed=0,u.maxInSpeed=0,u.tmpOut=0,u.tmpIn=0},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(1),o=n(0);const a='u',s='d';class i extends r.IPreset{constructor(...e){var t;return t=super(...e),this._tracks=[],t}onNotified({type:e,payload:t}){switch(e){case r.CONNECTION_CREATED:case r.SOCKET_CONNECT_TO_REMOTE:const n=t.host,o=t.port;this._tracks.push(`${n}:${o}`);break;case r.CONNECTION_CLOSED:this.dump(),this._tracks=[];break;default:}}beforeOut({buffer:e}){return this._tracks.push(a),this._tracks.push(e.length),e}beforeIn({buffer:e}){return this._tracks.push(s),this._tracks.push(e.length),e}dump(){let e=[],t=0,n=0,r=0,i=0,l='';var d=!0,c=!1,u;try{for(var p=this._tracks[Symbol.iterator](),m;!(d=(m=p.next()).done);d=!0){const o=m.value;if(o===a||o===s){if(l===o)continue;l=o}Number.isInteger(o)&&(l===s&&(t+=1,n+=o),l===a&&(r+=1,i+=o)),e.push(o)}}catch(e){c=!0,u=e}finally{try{!d&&p.return&&p.return()}finally{if(c)throw u}}const g=20;e.length>40&&(e=e.slice(0,g).concat([' ... ']).concat(e.slice(-g)));const f=__IS_CLIENT__?`out/in = ${r}/${t}, ${i}b/${n}b`:`in/out = ${t}/${r}, ${n}b/${i}b`;o.logger.info(`[tracker] summary(${f}) abstract(${e.join(' ')})`)}}t.default=i},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0});var o=n(6),a=r(o),s=n(13),i=r(s),l=n(0),d=n(1);class c extends d.IPreset{constructor({salt:e}){if(super(),this._isHandshakeDone=!1,this._isBroadCasting=!1,this._staging=Buffer.alloc(0),this._host=null,this._port=null,this._padding=null,'string'!=typeof e||''===e)throw Error('\'salt\' must be set to a non-empty string');this._padding=(0,l.hash)('sha256',e).slice(0,15)}onNotified(e){if(__IS_CLIENT__&&e.type===d.SOCKET_CONNECT_TO_REMOTE){var t=e.payload;const n=t.host,r=t.port;this._host=Buffer.from(n),this._port=(0,l.numberToBuffer)(r)}}clientOut({buffer:e}){return this._isHandshakeDone?e:(this._isHandshakeDone=!0,Buffer.concat([(0,l.numberToBuffer)(this._host.length,1),this._padding,this._host,this._port,e]))}serverIn({buffer:e,next:t,broadcast:n,fail:r}){if(!this._isHandshakeDone){if(this._isBroadCasting)return void(this._staging=Buffer.concat([this._staging,e]));if(20>e.length)return r(`unexpected buffer length: ${e.length}, buffer=${e.toString('hex')}`);if(!e.slice(1,16).equals(this._padding))return r(`unexpected padding=${this._padding.toString('hex')}`);const o=e[0];if(e.length<=o+18)return r(`unexpected buffer length: ${e.length}, buffer=${e.toString('hex')}`);let s=e.slice(16,16+o);if((0,l.isValidHostname)(s.toString()))s=s.toString();else if(a.default.isIP(s))s=i.default.toString(s);else return r(`invalid addr: (${s.toString()})`);const c=e.slice(o+16,o+18).readUInt16BE(0),u=e.slice(o+18);this._isBroadCasting=!0,n({type:d.SOCKET_CONNECT_TO_REMOTE,payload:{host:s,port:c,onConnected:()=>{t(Buffer.concat([u,this._staging])),this._isHandshakeDone=!0,this._isBroadCasting=!1,this._staging=null}}})}else return e}}t.default=c},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(5),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(0),s=n(1);const i=16,l=16,d=['aes-128-ctr','aes-192-ctr','aes-256-ctr','aes-128-cfb','aes-192-cfb','aes-256-cfb','camellia-128-cfb','camellia-192-cfb','camellia-256-cfb'];class c extends s.IPreset{constructor({method:e}){if(super(),this._isHandshakeDone=!1,this._isBroadCasting=!1,this._staging=Buffer.alloc(0),this._host=null,this._port=null,this._cipherName='',this._cipher=null,this._decipher=null,'string'!=typeof e||''===e)throw Error('\'method\' must be set');if(!d.includes(e))throw Error(`method '${e}' is not supported.`);this._cipherName=e}onNotified(e){if(__IS_CLIENT__&&e.type===s.SOCKET_CONNECT_TO_REMOTE){var t=e.payload;const n=t.host,r=t.port;this._host=Buffer.from(n),this._port=(0,a.numberToBuffer)(r)}}clientOut({buffer:e}){if(!this._isHandshakeDone){this._isHandshakeDone=!0;const t=o.default.randomBytes(i),n=(0,a.EVP_BytesToKey)(__KEY__,this._cipherName.split('-')[1]/8,i),r=(0,a.Xor)(t,n.slice(0,i));this._cipher=o.default.createCipheriv(this._cipherName,n,t),this._decipher=o.default.createDecipheriv(this._cipherName,n,t);const s=this.encrypt(Buffer.concat([(0,a.numberToBuffer)(this._host.length,1),this._host,this._port,e])),d=(0,a.hmac)('sha1',r,s.slice(0,-e.length)).slice(0,l);return Buffer.concat([t,d,s])}return this.encrypt(e)}serverIn({buffer:e,next:t,broadcast:n,fail:r}){if(!this._isHandshakeDone){if(this._isBroadCasting)return void(this._staging=Buffer.concat([this._staging,e]));if(37>e.length)return r(`unexpected buffer length_1: ${e.length}, buffer=${e.toString('hex')}`);const d=e.slice(0,i),c=(0,a.EVP_BytesToKey)(__KEY__,this._cipherName.split('-')[1]/8,i);this._cipher=o.default.createCipheriv(this._cipherName,c,d),this._decipher=o.default.createDecipheriv(this._cipherName,c,d);const u=this.decrypt(e.slice(32)),p=e.slice(16,32),m=u[0];if(e.length<=35+m)return r(`unexpected buffer length_2: ${e.length}, buffer=${e.toString('hex')}`);const g=(0,a.Xor)(d,c.slice(0,i)),f=(0,a.hmac)('sha1',g,e.slice(32,35+m)).slice(0,l);if(!f.equals(p))return r(`unexpected HMAC-SHA1=${p.toString('hex')} want=${f.toString('hex')}`);const h=u.slice(1,m+1).toString(),_=u.slice(m+1,m+3).readUInt16BE(0),y=u.slice(m+3);this._isBroadCasting=!0,n({type:s.SOCKET_CONNECT_TO_REMOTE,payload:{host:h,port:_,onConnected:()=>{t(Buffer.concat([y,this._staging])),this._isHandshakeDone=!0,this._isBroadCasting=!1,this._staging=null}}})}else return this.decrypt(e)}serverOut({buffer:e}){return this.encrypt(e)}clientIn({buffer:e}){return this.decrypt(e)}encrypt(e){return this._cipher.update(e)}decrypt(e){return this._decipher.update(e)}}t.default=c},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return s.default.isIPv4(e)?u:s.default.isIPv6(e)?p:m}Object.defineProperty(t,'__esModule',{value:!0});var a=n(6),s=r(a),i=n(13),l=r(i),d=n(0),c=n(1);const u=1,p=4,m=3;class g extends c.IPreset{constructor(...e){var t;return t=super(...e),this._isHandshakeDone=!1,this._isBroadCasting=!1,this._staging=Buffer.alloc(0),this._atyp=u,this._host=null,this._port=null,t}onNotified(e){if(__IS_CLIENT__&&e.type===c.SOCKET_CONNECT_TO_REMOTE){var t=e.payload;const n=t.host,r=t.port,a=o(n);this._atyp=a,this._port=(0,d.numberToBuffer)(r),this._host=a===m?Buffer.from(n):l.default.toBuffer(n)}}clientOut({buffer:e}){return this._isHandshakeDone?e:(this._isHandshakeDone=!0,Buffer.from([this._atyp,...(this._atyp===m?(0,d.numberToBuffer)(this._host.length,1):[]),...this._host,...this._port,...e]))}serverIn({buffer:e,next:t,broadcast:n,fail:r}){if(!this._isHandshakeDone){if(this._isBroadCasting)return void(this._staging=Buffer.concat([this._staging,e]));if(7>e.length)return void r(`invalid length: ${e.length}`);const o=e[0];let a=3,s,i;switch(o){case u:s=l.default.toString(e.slice(1,5)),i=e.slice(5,7).readUInt16BE(0),a+=4;break;case p:if(19>e.length)return void r(`invalid length: ${e.length}`);s=l.default.toString(e.slice(1,17)),i=e.slice(17,19).readUInt16BE(0),a+=16;break;case m:const t=e[1];if(e.length<t+4)return void r(`invalid length: ${e.length}`);if(s=e.slice(2,2+t).toString(),!(0,d.isValidHostname)(s))return void r(`addr=${s} is an invalid hostname`);i=e.slice(2+t,4+t).readUInt16BE(0),a+=t+1;break;default:return void r(`invalid atyp: ${o}`);}const g=e.slice(a);this._isBroadCasting=!0,n({type:c.SOCKET_CONNECT_TO_REMOTE,payload:{host:s,port:i,onConnected:()=>{t(Buffer.concat([g,this._staging])),this._isHandshakeDone=!0,this._isBroadCasting=!1,this._staging=null}}})}else return e}}t.default=g},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=n(5),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(0),s=n(1);const i=16,l=['aes-128-ctr','aes-192-ctr','aes-256-ctr','aes-128-cfb','aes-192-cfb','aes-256-cfb','camellia-128-cfb','camellia-192-cfb','camellia-256-cfb'];class d extends s.IPreset{constructor({method:e}){if(super(),this._cipherName='',this._key=null,this._cipher=null,this._decipher=null,'string'!=typeof e||''===e)throw Error('\'method\' must be set');if(!l.includes(e))throw Error(`method '${e}' is not supported.`);this._cipherName=e,global.__KEY__&&(this._key=(0,a.EVP_BytesToKey)(__KEY__,this._cipherName.split('-')[1]/8,i))}beforeOut({buffer:e}){if(!this._cipher){const t=o.default.randomBytes(i);return this._cipher=o.default.createCipheriv(this._cipherName,this._key,t),Buffer.concat([t,this.encrypt(e)])}return this.encrypt(e)}beforeIn({buffer:e,fail:t}){if(!this._decipher){if(e.length<i)return t(`cannot get iv, buffer is too short(${e.length}bytes): ${e.toString('hex')}`);const n=e.slice(0,i);return this._decipher=o.default.createDecipheriv(this._cipherName,this._key,n),this.decrypt(e.slice(i))}return this.decrypt(e)}encrypt(e){return this._cipher.update(e)}decrypt(e){return this._decipher.update(e)}}t.default=d},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=function(){function e(e,t){var n=[],r=!0,o=!1,a;try{for(var s=e[Symbol.iterator](),i;!(r=(i=s.next()).done)&&(n.push(i.value),!(t&&n.length===t));r=!0);}catch(e){o=!0,a=e}finally{try{!r&&s['return']&&s['return']()}finally{if(o)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),o=n(5),a=function(e){return e&&e.__esModule?e:{default:e}}(o),s=n(0),i=n(1);const l=12,d=16,c=['aes-128-gcm','aes-192-gcm','aes-256-gcm'],u='sha1';class p extends i.IPreset{constructor({method:e,info:t}){if(super(),this._cipherName='',this._info=null,this._cipherKey=null,this._decipherKey=null,this._cipherNonce=0,this._decipherNonce=0,this._adBuf=null,'undefined'==typeof e||''===e)throw Error('\'method\' must be set.');if(!c.includes(e))throw Error(`method '${e}' is not supported.`);this._cipherName=e,this._info=Buffer.from(t),this._adBuf=new s.AdvancedBuffer({getPacketLength:this.onReceiving.bind(this)}),this._adBuf.on('data',this.onChunkReceived.bind(this))}beforeOut({buffer:e}){let t=null;if(null===this._cipherKey){const e=this._cipherName.split('-')[1]/8;t=a.default.randomBytes(e),this._cipherKey=(0,s.HKDF)(u,t,(0,s.EVP_BytesToKey)(__KEY__,e,16),this._info,e)}const n=(0,s.getRandomChunks)(e,2048,16383).map((e)=>{const t=(0,s.numberToBuffer)(e.length);var n=this.encrypt(t),o=r(n,2);const a=o[0],i=o[1];var l=this.encrypt(e),d=r(l,2);const c=d[0],u=d[1];return Buffer.concat([a,i,c,u])});return t?Buffer.concat([t,...n]):Buffer.concat(n)}beforeIn({buffer:e,next:t,fail:n}){this._adBuf.put(e,{next:t,fail:n})}onReceiving(e,{fail:t}){if(null===this._decipherKey){const t=this._cipherName.split('-')[1]/8;if(e.length<t)return;const n=e.slice(0,t);return this._decipherKey=(0,s.HKDF)(u,n,(0,s.EVP_BytesToKey)(__KEY__,t,16),this._info,t),e.slice(t)}if(!(e.length<2*d+3)){var n=[e.slice(0,2),e.slice(2,2+d)];const r=n[0],o=n[1],a=this.decrypt(r,o);return null===a?(t(`unexpected DataLen_TAG=${o.toString('hex')} when verify DataLen=${r.toString('hex')}`),-1):2+d+a.readUInt16BE(0)+d}}onChunkReceived(e,{next:t,fail:n}){var r=[e.slice(2+d,-d),e.slice(-d)];const o=r[0],a=r[1],s=this.decrypt(o,a);return null===s?void n(`unexpected Data_TAG=${a.toString('hex')} when verify Data=${o.slice(0,60).toString('hex')}`):void t(s)}encrypt(e){const t=a.default.createCipheriv(this._cipherName,this._cipherKey,(0,s.numberToBuffer)(this._cipherNonce,l,s.BYTE_ORDER_LE)),n=Buffer.concat([t.update(e),t.final()]),r=t.getAuthTag();return this._cipherNonce+=1,[n,r]}decrypt(e,t){const n=a.default.createDecipheriv(this._cipherName,this._decipherKey,(0,s.numberToBuffer)(this._decipherNonce,l,s.BYTE_ORDER_LE));n.setAuthTag(t);try{const t=Buffer.concat([n.update(e),n.final()]);return this._decipherNonce+=1,t}catch(e){return null}}}t.default=p},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0});var r=function(){function e(e,t){var n=[],r=!0,o=!1,a;try{for(var s=e[Symbol.iterator](),i;!(r=(i=s.next()).done)&&(n.push(i.value),!(t&&n.length===t));r=!0);}catch(e){o=!0,a=e}finally{try{!r&&s['return']&&s['return']()}finally{if(o)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),o=n(5),a=function(e){return e&&e.__esModule?e:{default:e}}(o),s=n(0),i=n(1);const l=12,d=16,c=2,u=['aes-128-gcm','aes-192-gcm','aes-256-gcm'],p='sha1';class m extends i.IPreset{constructor({method:e,info:t,factor:n}){if(super(),this._cipherName='',this._info=null,this._factor=c,this._rawKey=null,this._cipherKey=null,this._decipherKey=null,this._cipherNonce=0,this._decipherNonce=0,this._nextExpectDecipherNonce=0,this._adBuf=null,'undefined'==typeof e||''===e)throw Error('\'method\' must be set.');if(!u.includes(e))throw Error(`method '${e}' is not supported.`);if('string'!=typeof t||0>=t.length)throw Error('\'info\' must be a non-empty string.');if('undefined'==typeof n)n=c;else{if(!Number.isInteger(n))throw Error('\'factor\' must be an integer.');if(1>n||10<n)throw Error('\'factor\' must be in [1, 10].')}this._cipherName=e,this._info=Buffer.from(t),this._factor=n,this._rawKey=global.__KEY__?Buffer.from(__KEY__):null,this._adBuf=new s.AdvancedBuffer({getPacketLength:this.onReceiving.bind(this)}),this._adBuf.on('data',this.onChunkReceived.bind(this))}beforeOut({buffer:e}){let t=null;if(null===this._cipherKey){const e=this._cipherName.split('-')[1]/8;t=a.default.randomBytes(e),this._cipherKey=(0,s.HKDF)(p,t,this._rawKey,this._info,e)}const n=(0,s.getRandomChunks)(e,2048,16383).map((e)=>{const t=this.getPaddingLength(this._cipherKey,this._cipherNonce),n=a.default.randomBytes(t),o=(0,s.numberToBuffer)(e.length);var i=this.encrypt(o),l=r(i,2);const d=l[0],c=l[1];var u=this.encrypt(e),p=r(u,2);const m=p[0],g=p[1];return Buffer.concat([n,d,c,m,g])});return t?Buffer.concat([t,...n]):Buffer.concat(n)}beforeIn({buffer:e,next:t,fail:n}){this._adBuf.put(e,{next:t,fail:n})}onReceiving(e,{fail:t}){if(null===this._decipherKey){const t=this._cipherName.split('-')[1]/8;if(e.length<t)return;const n=e.slice(0,t);return this._decipherKey=(0,s.HKDF)(p,n,this._rawKey,this._info,t),e.slice(t)}if(this._decipherNonce===this._nextExpectDecipherNonce){const t=this.getPaddingLength(this._decipherKey,this._decipherNonce);return e.length<t?void 0:(this._nextExpectDecipherNonce+=2,e.slice(t))}if(!(e.length<2*d+3)){var n=[e.slice(0,2),e.slice(2,2+d)];const r=n[0],o=n[1],a=this.decrypt(r,o);return null===a?(t(`unexpected DataLen_TAG=${o.toString('hex')} when verify DataLen=${r.toString('hex')}`),-1):2+d+a.readUInt16BE(0)+d}}onChunkReceived(e,{next:t,fail:n}){var r=[e.slice(2+d,-d),e.slice(-d)];const o=r[0],a=r[1],s=this.decrypt(o,a);return null===s?void n(`unexpected Data_TAG=${a.toString('hex')} when verify Data=${o.slice(0,60).toString('hex')}`):void t(s)}getPaddingLength(e,t){const n=(0,s.numberToBuffer)(t,l,s.BYTE_ORDER_LE),r=a.default.createCipheriv(this._cipherName,e,n);return r.update(n),r.final(),r.getAuthTag()[0]*this._factor}encrypt(e){const t=a.default.createCipheriv(this._cipherName,this._cipherKey,(0,s.numberToBuffer)(this._cipherNonce,l,s.BYTE_ORDER_LE)),n=Buffer.concat([t.update(e),t.final()]),r=t.getAuthTag();return this._cipherNonce+=1,[n,r]}decrypt(e,t){const n=a.default.createDecipheriv(this._cipherName,this._decipherKey,(0,s.numberToBuffer)(this._decipherNonce,l,s.BYTE_ORDER_LE));n.setAuthTag(t);try{const t=Buffer.concat([n.update(e),n.final()]);return this._decipherNonce+=1,t}catch(e){return null}}}t.default=m},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,'__esModule',{value:!0});var o=n(4),a=r(o),s=n(113),i=r(s),l=n(5),d=r(l),c=n(1);class u{static _parse(e,t){if(0<this._fakes.length)return void t(this._fakes);const n=[];let r='';const o=i.default.createInterface({input:a.default.createReadStream(e)});o.on('line',function(e){switch(e[0]){case'=':case'-':''!=r&&(r+='\r\n',n.push(r),r='');break;default:r+=e,r+='\r\n';}}),o.on('close',()=>{for(let e=0;e<n.length;e+=2){const t=n[e],r=n[e+1];this._fakes.push({request:Buffer.from(t),response:Buffer.from(r)})}t(this._fakes)})}static get(e,t){this._parse(e,t)}}u._fakes=[];class p extends c.IPreset{constructor({file:e}){if(super(),this._isHandshakeDone=!1,this._file=null,this._response=null,'undefined'==typeof e)throw Error('\'file\' parameter is required.');this._file=e}clientOut({buffer:e,next:t}){return this._isHandshakeDone?e:void u.get(this._file,(n)=>{const r=d.default.randomBytes(1)[0]%n.length,o=n[r].request;t(Buffer.concat([o,e]))})}serverIn({buffer:e,next:t,fail:n}){return this._isHandshakeDone?e:void u.get(this._file,(r)=>{const o=r.find(({request:t})=>0===e.indexOf(t));'undefined'==typeof o?n('http header mismatch'):(this._response=o.response,t(e.slice(o.request.length)))})}serverOut({buffer:e}){return this._isHandshakeDone?e:(this._isHandshakeDone=!0,Buffer.concat([this._response,e]))}clientIn({buffer:e,next:t,fail:n}){return this._isHandshakeDone?e:void(u.get(this._file,(r)=>{const o=r.find(({response:t})=>0===e.indexOf(t));'undefined'==typeof o?n('http header mismatch'):t(e.slice(o.response.length))}),this._isHandshakeDone=!0)}}t.default=p},function(e){e.exports=require('readline')},function(e,t,n){'use strict';function r(e){const t=(0,s.numberToBuffer)(e.length);return Buffer.concat([(0,s.hexStringToBuffer)('170303'),t,e])}Object.defineProperty(t,'__esModule',{value:!0});var o=n(5),a=function(e){return e&&e.__esModule?e:{default:e}}(o),s=n(0),i=n(1);const l=1,d=2,c=3,u=2048,p=16383;class m extends i.IPreset{constructor({sni:e}){if(super(),this._sni=[],this._stage=l,this._staging=Buffer.alloc(0),this._adBuf=null,'undefined'==typeof e)throw Error('\'sni\' must be set');if(Array.isArray(e)||(e=[e]),e.some((e)=>'string'!=typeof e||1>e.length))throw Error('\'sni\' must be a non-empty string or an array without empty strings');this.onReceiving=this.onReceiving.bind(this),this.onChunkReceived=this.onChunkReceived.bind(this),this._sni=Array.isArray(e)?e:[e],this._adBuf=new s.AdvancedBuffer({getPacketLength:this.onReceiving}),this._adBuf.on('data',this.onChunkReceived)}getRandomSNI(){const e=a.default.randomBytes(1)[0]%this._sni.length;return Buffer.from(this._sni[e])}clientOut({buffer:e,next:t}){if(this._stage===l){this._stage=d,this._staging=e;const n=this.getRandomSNI(),r=[...(0,s.getUTC)(),...a.default.randomBytes(28)],o=[...(0,s.hexStringToBuffer)('20'),...a.default.randomBytes(32)],i=[...(0,s.hexStringToBuffer)('001a'),...(0,s.hexStringToBuffer)('c02b'),...(0,s.hexStringToBuffer)('c02f'),...(0,s.hexStringToBuffer)('c02c'),...(0,s.hexStringToBuffer)('c030'),...(0,s.hexStringToBuffer)('cc14'),...(0,s.hexStringToBuffer)('cc13'),...(0,s.hexStringToBuffer)('c013'),...(0,s.hexStringToBuffer)('c014'),...(0,s.hexStringToBuffer)('009c'),...(0,s.hexStringToBuffer)('009d'),...(0,s.hexStringToBuffer)('002f'),...(0,s.hexStringToBuffer)('0035'),...(0,s.hexStringToBuffer)('000a')],l=[...(0,s.hexStringToBuffer)('0000'),...(0,s.numberToBuffer)(5+n.length),...(0,s.numberToBuffer)(3+n.length),...(0,s.hexStringToBuffer)('00'),...(0,s.numberToBuffer)(n.length),...n],c=(0,s.getRandomInt)(200,400),u=[...(0,s.hexStringToBuffer)('0023'),...(0,s.numberToBuffer)(c),...a.default.randomBytes(c)],p=[...(0,s.hexStringToBuffer)('ff01000100'),...l,...(0,s.hexStringToBuffer)('00170000'),...u,...(0,s.hexStringToBuffer)('000d00140012040308040401050308050501080606010201'),...(0,s.hexStringToBuffer)('000500050100000000'),...(0,s.hexStringToBuffer)('00120000'),...(0,s.hexStringToBuffer)('75500000'),...(0,s.hexStringToBuffer)('000b00020100'),...(0,s.hexStringToBuffer)('000a0006000400170018')],m=[...(0,s.hexStringToBuffer)('0303'),...r,...o,...i,...(0,s.hexStringToBuffer)('01'),...(0,s.hexStringToBuffer)('00'),...(0,s.numberToBuffer)(p.length),...p],g=[...(0,s.hexStringToBuffer)('16'),...(0,s.hexStringToBuffer)('0301'),...(0,s.numberToBuffer)(4+m.length),...(0,s.hexStringToBuffer)('01'),...(0,s.numberToBuffer)(m.length,3)];return t(Buffer.from([...g,...m]))}if(this._stage===d&&(this._staging=Buffer.concat([this._staging,e])),this._stage===c){const t=(0,s.getRandomChunks)(e,u,p).map((e)=>r(e));return Buffer.concat(t)}}serverIn({buffer:e,next:t,fail:n}){if(this._stage===l){if(this._stage=d,200>e.length)return void n(`TLS handshake header is too short, length=${e.length} dump=${e.slice(0,100).toString('hex')}`);if(!e.slice(0,3).equals((0,s.hexStringToBuffer)('160301')))return void n(`invalid TLS handshake header=${e.slice(0,3).toString('hex')}, want=160301, dump=${e.slice(0,100).toString('hex')}`);const r=e.slice(3,5).readUInt16BE(0);if(r!==e.length-5)return void n(`unexpected TLS handshake body length=${e.length-5}, want=${r}, dump=${e.slice(0,100).toString('hex')}`);const o=[...(0,s.getUTC)(),...a.default.randomBytes(28)],i=[...(0,s.hexStringToBuffer)('20'),...a.default.randomBytes(32)],l=[...(0,s.hexStringToBuffer)('ff01000100'),...(0,s.hexStringToBuffer)('00050000'),...(0,s.hexStringToBuffer)('00170000')],c=[...(0,s.hexStringToBuffer)('0303'),...o,...i,...(0,s.hexStringToBuffer)('c02f'),...(0,s.hexStringToBuffer)('00'),...(0,s.numberToBuffer)(l.length),...l],u=[...(0,s.hexStringToBuffer)('16'),...(0,s.hexStringToBuffer)('0303'),...(0,s.numberToBuffer)(4+c.length),...(0,s.hexStringToBuffer)('02'),...(0,s.numberToBuffer)(c.length,3)],p=[...u,...c],m=a.default.randomBytes((0,s.getRandomInt)(200,255)),g=[...(0,s.hexStringToBuffer)('000004b0'),...(0,s.numberToBuffer)(m.length),...m],f=[...(0,s.hexStringToBuffer)('04'),...(0,s.numberToBuffer)(g.length,3),...g],h=[...(0,s.hexStringToBuffer)('160303'),...(0,s.numberToBuffer)(f.length),...f],_=[...(0,s.hexStringToBuffer)('140303000101')],y=(0,s.getRandomInt)(32,40),b=[...(0,s.hexStringToBuffer)('16'),...(0,s.hexStringToBuffer)('0303'),...(0,s.numberToBuffer)(y),...a.default.randomBytes(y)];return t(Buffer.from([...p,...h,..._,...b]),!0)}let r=e;this._stage===d&&(this._stage=c,r=e.slice(43)),this._adBuf.put(r,{next:t,fail:n})}serverOut({buffer:e}){const t=(0,s.getRandomChunks)(e,u,p).map((e)=>r(e));return Buffer.concat(t)}clientIn({buffer:e,next:t,fail:n}){if(this._stage===d){this._stage=c;const e=[...(0,s.hexStringToBuffer)('140303000101')],n=[...(0,s.hexStringToBuffer)('16'),...(0,s.hexStringToBuffer)('0303'),...(0,s.hexStringToBuffer)('0020'),...a.default.randomBytes(32)],o=(0,s.getRandomChunks)(this._staging,u,p).map((e)=>r(e));return this._staging=null,t(Buffer.from([...e,...n,...Buffer.concat(o)]),!0)}this._adBuf.put(e,{next:t,fail:n})}onReceiving(e){return 5>e.length?void 0:5+e.readUInt16BE(3)}onChunkReceived(e,{next:t}){t(e.slice(5))}}t.default=m},function(e,t,n){'use strict';var r=n(4),o=n(12),a=n(7),s=n(9),i=n(10).Transport,l=n(11).Stream,d=n(8),c=n(10),u=n(29),p=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],m=e.exports=function(e){function t(t){Array.prototype.slice.call(arguments,1).forEach(function(n){if(e[n])throw new Error('Cannot set '+n+' and '+t+'together')})}if(i.call(this,e),e.filename||e.dirname)t('filename or dirname','stream'),this._basename=this.filename=e.filename?o.basename(e.filename):'winston.log',this.dirname=e.dirname||o.dirname(e.filename),this.options=e.options||{flags:'a'},this.options.highWaterMark=this.options.highWaterMark||24;else if(e.stream){t('stream','filename','maxsize'),this._stream=e.stream;var n=this;this._stream.on('error',function(e){n.emit('error',e)}),this._stream.setMaxListeners(Infinity)}else throw new Error('Cannot log to file without filename or stream.');this.json=!1!==e.json,this.colorize=e.colorize||!1,this.maxsize=e.maxsize||null,this.logstash=e.logstash||null,this.maxFiles=e.maxFiles||null,this.label=e.label||null,this.prettyPrint=e.prettyPrint||!1,this.showLevel=void 0===e.showLevel||e.showLevel,this.timestamp=void 0===e.timestamp||e.timestamp,this.datePattern=e.datePattern?e.datePattern:'.yyyy-MM-dd',this.depth=e.depth||null,this.eol=e.eol||d.EOL,this.maxRetries=e.maxRetries||2,this.prepend=e.prepend||!1,this.localTime=e.localTime||!1,this.zippedArchive=e.zippedArchive||!1,this.json&&(this.stringify=e.stringify),this._size=0,this._created=0,this._buffer=[],this._draining=!1,this._failures=0,this._archive=!1,this._currentFiles=function(){if(!this.maxsize)try{return r.readdirSync(this.dirname).filter(function(e){return e.includes(this._basename)}.bind(this)).map(function(e){return{name:e,time:r.statSync(o.join(this.dirname,e)).mtime.getTime()}}.bind(this)).sort(function(e,t){return e.time-t.time}).map(function(e){return e.name})}catch(t){}return[]}.bind(this)(),this._year=this._getTime('year'),this._month=this._getTime('month'),this._date=this._getTime('date'),this._hour=this._getTime('hour'),this._minute=this._getTime('minute'),this._weekday=p[this._getTime('day')];var a=/d{1,4}|m{1,4}|yy(?:yy)?|([HhM])\1?/g,s=function(e,t){for(e+='',t=t||2;e.length<t;)e='0'+e;return e};this.getFormattedDate=function(){this._year=this._getTime('year'),this._month=this._getTime('month'),this._date=this._getTime('date'),this._hour=this._getTime('hour'),this._minute=this._getTime('minute'),this._weekday=p[this._getTime('day')];var e={yy:(this._year+'').slice(2),yyyy:this._year,M:this._month+1,MM:s(this._month+1),d:this._date,dd:s(this._date),H:this._hour,HH:s(this._hour),m:this._minute,mm:s(this._minute),ddd:this._weekday};return this.datePattern.replace(a,function(t){return t in e?e[t]:t.slice(1,t.length-1)})}};a.inherits(m,i),c.transports.DailyRotateFile=m,m.prototype.name='dailyRotateFile',m.prototype.log=function(e,t,n,r){if(this.silent)return r(null,!0);if(this._failures>=this.maxRetries)return r(new Error('Transport is in a failed state.'));var o=this,a=s.log({level:e,message:t,meta:n,json:this.json,colorize:this.colorize,logstash:this.logstash,prettyPrint:this.prettyPrint,timestamp:this.timestamp,label:this.label,stringify:this.stringify,showLevel:this.showLevel,depth:this.depth,formatter:this.formatter,humanReadableUnhandledException:this.humanReadableUnhandledException})+this.eol;this._size+=a.length,this.filename?this.open(function(e){return e?o._buffer.push([a,r]):void(o._write(a,r),o._lazyDrain())}):(this._write(a,r),this._lazyDrain())},m.prototype._write=function(e,t){var n=this._stream.write(e);return t?!1===n?this._stream.once('drain',function(){t(null,!0)}):void t(null,!0):void 0},m.prototype.query=function(e,t){function n(e,t){try{var n=JSON.parse(e);s(n)&&a(n)}catch(n){t||u.emit('error',n)}}function a(t){if(e.rows&&l.length>=e.rows)return void(u.readable&&u.destroy());if(e.fields){var n={};e.fields.forEach(function(e){n[e]=t[e]}),t=n}l.push(t)}function s(t){if(t&&'object'==typeof t){var n=new Date(t.timestamp);return e.from&&n<e.from||e.until&&n>e.until?void 0:!0}}'function'==typeof e&&(t=e,e={});var i=o.join(this.dirname,this._getFilename());e=this.normalizeQuery(e);var d='',l=[],c=0,u=r.createReadStream(i,{encoding:'utf8'});u.on('error',function(e){return u.readable&&u.destroy(),t?'ENOENT'===e.code?t(null,l):t(e):void 0}),u.on('data',function(t){t=(d+t).split(/\n+/);for(var r=t.length-1,o=0;o<r;o++)(!e.start||c>=e.start)&&n(t[o]),c++;d=t[r]}),u.on('close',function(){d&&n(d,!0),'desc'===e.order&&(l=l.reverse()),t&&t(null,l)})},m.prototype.stream=function(e){var t=o.join(this.dirname,this._getFilename());e=e||{};var n=new l,r={file:t,start:e.start};return n.destroy=s.tailFile(r,function(e,t){if(e)return n.emit('error',e);try{n.emit('data',t),t=JSON.parse(t),n.emit('log',t)}catch(t){n.emit('error',t)}}),n.resume&&n.resume(),n},m.prototype.open=function(e){if(this.opening)return e(!0);return!this._stream||this.maxsize&&this._size>=this.maxsize||this._filenameHasExpired()?(e(!0),this._createStream()):void e()},m.prototype.close=function(){var e=this;this._stream&&(this._stream.end(),this._stream.destroySoon(),this._stream.once('drain',function(){e.emit('flush'),e.emit('closed')}))},m.prototype.flush=function(){var e=this;this._buffer.forEach(function(t){var n=t[0],r=t[1];process.nextTick(function(){e._write(n,r),e._size+=n.length})}),e._buffer.length=0,e._stream.once('drain',function(){e.emit('flush'),e.emit('logged')})},m.prototype._createStream=function(){var e=this;this.opening=!0,function t(n){function a(t){e._stream&&(e._archive=!!e.zippedArchive&&e._stream.path,e._stream.end(),e._stream.destroySoon()),e._size=t,e.filename=n,e._stream=r.createWriteStream(i,e.options),e._stream.on('error',function(t){e._failures<e.maxRetries?(e._createStream(),e._failures++):e.emit('error',t)}),e._stream.setMaxListeners(Infinity),e.once('flush',function(){e.flush(),e.opening=!1,e.emit('open',i)}),e.flush(),s()}function s(){var t=e._archive;if(e._archive=!1,t&&r.existsSync(t+'')){var n=u.createGzip(),o=r.createReadStream(t+''),a=r.createWriteStream(t+'.gz');o.pipe(n).pipe(a),r.unlinkSync(t+'')}}var i=o.join(e.dirname,n);r.stat(i,function(n,r){return n?'ENOENT'===n.code?a(0):e.emit('error',n):!r||e.maxsize&&r.size>=e.maxsize?t(e._getFile(!0)):e._filenameHasExpired()?(e._year=e._getTime('year'),e._month=e._getTime('month'),e._date=e._getTime('date'),e._hour=e._getTime('hour'),e._minute=e._getTime('minute'),e._weekday=p[e._getTime('day')],e._created=0,t(e._getFile())):void a(r.size)})}(this._getFile())},m.prototype._getFile=function(e){var t=this._getFilename(),n;if(e){if(this.maxFiles&&this._created>=this.maxFiles-1)if(n=this._created-(this.maxFiles-1),0===n)try{r.unlinkSync(o.join(this.dirname,t))}catch(t){}else try{r.unlinkSync(o.join(this.dirname,t+'.'+n))}catch(t){}this._created+=1}else if(!this.maxsize)for(-1===this._currentFiles.indexOf(t)&&this._currentFiles.push(t);this.maxFiles&&this._currentFiles.length>this.maxFiles;){try{r.unlinkSync(o.join(this.dirname,this._currentFiles[0]))}catch(t){}this._currentFiles=this._currentFiles.slice(1)}return this._created?t+'.'+this._created:t},m.prototype._getFilename=function(){var e=this.getFormattedDate();return this.prepend?('.yyyy-MM-dd'===this.datePattern&&(this.datePattern='yyyy-MM-dd.',e=this.getFormattedDate()),e+this._basename):this._basename+e},m.prototype._lazyDrain=function(){var e=this;!this._draining&&this._stream&&(this._draining=!0,this._stream.once('drain',function(){this._draining=!1,e.emit('logged')}))},m.prototype._filenameHasExpired=function(){if(this.datePattern.match(/m/))return this._year<this._getTime('year')||this._month<this._getTime('month')||this._date<this._getTime('date')||this._hour<this._getTime('hour')||this._minute<this._getTime('minute');return this.datePattern.match(/H/)?this._year<this._getTime('year')||this._month<this._getTime('month')||this._date<this._getTime('date')||this._hour<this._getTime('hour'):this.datePattern.match(/d/)?this._year<this._getTime('year')||this._month<this._getTime('month')||this._date<this._getTime('date'):this.datePattern.match(/M/)?this._year<this._getTime('year')||this._month<this._getTime('month'):!!this.datePattern.match(/yy/)&&this._year<this._getTime('year')},m.prototype._getTime=function(e){var t=new Date;if(this.localTime){if('year'===e)return t.getFullYear();if('month'===e)return t.getMonth();if('date'===e)return t.getDate();if('hour'===e)return t.getHours();if('minute'===e)return t.getMinutes();if('day'===e)return t.getDay()}return'year'===e?t.getUTCFullYear():'month'===e?t.getUTCMonth():'date'===e?t.getUTCDate():'hour'===e?t.getUTCHours():'minute'===e?t.getUTCMinutes():'day'===e?t.getUTCDay():void 0}},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}Object.defineProperty(t,'__esModule',{value:!0}),t.Hub=void 0;var a=n(22),s=r(a),i=n(3),l=r(i),d=n(6),c=r(d),u=n(34),p=r(u),m=n(117),g=r(m),f=n(24),h=n(31),_=n(118),y=n(0);class b extends l.default{constructor(e){super(),this._isFirstWorker=!s.default.worker||1>=s.default.worker.id,this._localServer=null,this._fastestServer=null,this._relays=[],this.onConnect=this.onConnect.bind(this),this.onClose=this.onClose.bind(this),e!==void 0&&h.Config.init(e),this._isFirstWorker&&(y.logger.info(`==> [hub] use configuration: ${JSON.stringify(__ALL_CONFIG__)}`),y.logger.info(`==> [hub] running as: ${__IS_SERVER__?'server':'client'}`)),__IS_CLIENT__&&(this._isFirstWorker&&y.logger.info('==> [balancer] started'),f.Balancer.start(__SERVERS__))}run(){var e=this;return o(function*(){const t={host:__LOCAL_HOST__,port:__LOCAL_PORT__};return e._localServer=e.createServer(),e._localServer.on('close',e.onClose),new Promise(function(n){return e._localServer.listen(t,n)})})()}terminate(){this._localServer.close(),this._localServer=null,this._isFirstWorker&&y.logger.info('==> [hub] shutdown'),__IS_CLIENT__&&(f.Balancer.destroy(),this._isFirstWorker&&y.logger.info('==> [balancer] stopped'))}createServer(){if(__IS_SERVER__&&__IS_TLS__){const e=p.default.createServer({key:[__TLS_KEY__],cert:[__TLS_CERT__]});return e.on('secureConnection',this.onConnect),e}const e=c.default.createServer();return e.on('connection',this.onConnect),e}selectServer(){const e=f.Balancer.getFastest();(null===this._fastestServer||e.id!==this._fastestServer.id)&&(this._fastestServer=e,h.Config.initServer(e),y.logger.info(`[balancer] use: ${e.host}:${e.port}`))}onConnect(e){__IS_CLIENT__&&this.selectServer();const t=(0,g.default)(),n=new _.Relay({socket:e});n.id=t,n.on('close',()=>{this._relays=this._relays.filter((e)=>e.id!==t)}),this._relays.push(n),y.logger.info(`[hub] [${e.remoteAddress}:${e.remotePort}] connected`)}onClose(){this._relays.forEach((e)=>e.destroy()),this._relays=null,this._localServer=null,this.emit('close')}}t.Hub=b},function(e){'use strict';function t(e){if('string'==typeof e)return e;if(r(e))return f?f.call(e):'';var t=e+'';return'0'==t&&1/e==-a?'-0':t}function n(e){return!!e&&'object'==typeof e}function r(e){return'symbol'==typeof e||n(e)&&p.call(e)==s}function o(e){return null==e?'':t(e)}var a=1/0,s='[object Symbol]',i='object'==typeof global&&global&&global.Object===Object&&global,l='object'==typeof self&&self&&self.Object===Object&&self,d=i||l||Function('return this')(),c=Object.prototype,u=0,p=c.toString,m=d.Symbol,g=m?m.prototype:void 0,f=g?g.toString:void 0;e.exports=function(e){var t=++u;return o(e)+t}},function(e,t,n){'use strict';function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(o,a){try{var s=t[o](a),i=s.value}catch(e){return void n(e)}return s.done?void e(i):Promise.resolve(i).then(function(e){r('next',e)},function(e){r('throw',e)})}return r('next')})}}Object.defineProperty(t,'__esModule',{value:!0}),t.Relay=void 0;var a=n(3),s=r(a),i=n(6),l=r(i),d=n(34),c=r(d),u=n(0),p=n(119),m=n(33),g=n(35),f=n(1),h=n(17);const _=1048576;class y extends s.default{constructor({socket:e}){super(),this._dnsCache=null,this._isConnectedToDst=!1,this._remoteHost='',this._remotePort='',this._bsocket=null,this._fsocket=null,this._pipe=null,this._presets=[],this.onForward=this.onForward.bind(this),this.onBackward=this.onBackward.bind(this),this.onError=this.onError.bind(this),this.onBackwardSocketDrain=this.onBackwardSocketDrain.bind(this),this.onBackwardSocketTimeout=this.onBackwardSocketTimeout.bind(this),this.onBackwardSocketClose=this.onBackwardSocketClose.bind(this),this.onForwardSocketDrain=this.onForwardSocketDrain.bind(this),this.onForwardSocketTimeout=this.onForwardSocketTimeout.bind(this),this.onForwardSocketClose=this.onForwardSocketClose.bind(this),this.onPipeNotified=this.onPipeNotified.bind(this),this.sendForward=this.sendForward.bind(this),this.sendBackward=this.sendBackward.bind(this),this.connect=this.connect.bind(this),this.setPresets=this.setPresets.bind(this),this.destroy=this.destroy.bind(this),this._dnsCache=new m.DNSCache({expire:__DNS_EXPIRE__}),this._remoteHost=e.remoteAddress,this._remotePort=e.remotePort,this._bsocket=e,this._bsocket.on('error',this.onError),this._bsocket.on('close',this.onBackwardSocketClose),this._bsocket.on('timeout',this.onBackwardSocketTimeout.bind(this,{host:this._remoteHost,port:this._remotePort})),this._bsocket.on('data',this.onForward),this._bsocket.on('drain',this.onBackwardSocketDrain),this._bsocket.setTimeout(__TIMEOUT__);let t=__PRESETS__;__IS_CLIENT__&&!['proxy','tunnel'].includes(t[0].name)&&(t=[{name:'proxy'}].concat(t)),'tracker'!==t[t.length-1].name&&(t=t.concat([{name:'tracker'}])),this._presets=t,this._pipe=this.createPipe(t),this._pipe.onBroadcast({type:f.CONNECTION_CREATED,payload:{host:this._remoteHost,port:this._remotePort}})}get remote(){return`${this._remoteHost}:${this._remotePort}`}get fsocketWritable(){return this._fsocket&&!this._fsocket.destroyed&&this._fsocket.writable}get bsocketWritable(){return this._bsocket&&!this._bsocket.destroyed&&this._bsocket.writable}onError(e){u.logger.warn(`[socket] [${this.remote}] ${e.code||''} - ${e.message}`)}onForward(e){if(this.fsocketWritable||!this._isConnectedToDst){const t=__IS_CLIENT__?g.MIDDLEWARE_DIRECTION_UPWARD:g.MIDDLEWARE_DIRECTION_DOWNWARD;this._pipe.feed(t,e)}this._fsocket&&this._fsocket.bufferSize>=_&&this._bsocket.pause()}onForwardSocketDrain(){this._bsocket&&!this._bsocket.destroyed&&this._bsocket.resume()}onForwardSocketTimeout({host:e,port:t}){u.logger.warn(`[socket] [${e}:${t}] timeout: no I/O on the connection for ${__TIMEOUT__/1e3}s`),this.onForwardSocketClose()}onForwardSocketClose(){this._fsocket&&(this._fsocket.destroy(),this._fsocket=null),this._bsocket&&(1<this._bsocket.bufferSize?(this._bsocket.removeListener('drain',this.onBackwardSocketDrain),this._bsocket.on('drain',this.onBackwardSocketClose)):this.onBackwardSocketClose())}onBackward(e){if(this.bsocketWritable){const t=__IS_CLIENT__?g.MIDDLEWARE_DIRECTION_DOWNWARD:g.MIDDLEWARE_DIRECTION_UPWARD;this._pipe.feed(t,e)}this._bsocket&&this._bsocket.bufferSize>=_&&this._fsocket.pause()}onBackwardSocketDrain(){this._fsocket&&!this._fsocket.destroyed&&this._fsocket.resume()}onBackwardSocketTimeout({host:e,port:t}){u.logger.warn(`[socket] [${e}:${t}] timeout: no I/O on the connection for ${__TIMEOUT__/1e3}s`),this.onBackwardSocketClose()}onBackwardSocketClose(){this._bsocket&&(this._bsocket.destroy(),this._bsocket=null,this._pipe.onBroadcast({type:f.CONNECTION_CLOSED,payload:{host:this._remoteHost,port:this._remotePort}}),this._pipe.destroy(),this._pipe=null,this.emit('close')),this._fsocket&&(1<this._fsocket.bufferSize?(this._fsocket.removeListener('drain',this.onForwardSocketDrain),this._fsocket.on('drain',this.onForwardSocketClose)):this.onForwardSocketClose())}sendForward(e){__IS_CLIENT__?this.fsocketWritable&&this._fsocket.write(e):this.bsocketWritable&&this._bsocket.write(e)}sendBackward(e){__IS_CLIENT__?this.bsocketWritable&&this._bsocket.write(e):this.fsocketWritable&&this._fsocket.write(e)}connect({host:e,port:t}){var n=this;return o(function*(){if(!(0,u.isValidHostname)(e)||!(0,u.isValidPort)(t))return u.logger.warn(`unexpected host=${e} port=${t}`),void n.onBackwardSocketClose();let r=null;try{r=yield n._dnsCache.get(e)}catch(r){u.logger.error(`[socket] [${n.remote}] fail to resolve host ${e}:${t}: ${r.message}`)}return u.logger.info(`[socket] [${n.remote}] connecting to: ${e}(${r}):${t}`),new Promise(function(o){n._fsocket&&!n._fsocket.destroyed&&(n._fsocket.destroy(),n._fsocket=null),n._fsocket=__IS_CLIENT__&&__IS_TLS__?c.default.connect({host:e,port:t,ca:[__TLS_CERT__]},function(){return o(n._fsocket)}):l.default.connect({host:r,port:t},function(){return o(n._fsocket)}),n._fsocket.on('error',n.onError),n._fsocket.on('close',n.onForwardSocketClose),n._fsocket.on('timeout',n.onForwardSocketTimeout.bind(n,{host:e,port:t})),n._fsocket.on('data',n.onBackward),n._fsocket.on('drain',n.onForwardSocketDrain),n._fsocket.setTimeout(__TIMEOUT__)})})()}setPresets(e){this._presets=e(this._presets),this._pipe.removeAllListeners(),this._pipe.destroy(),this._pipe=this.createPipe(this._presets)}createPipe(e){const t=e.map((e)=>(0,g.createMiddleware)(e.name,e.params||{})),n=new p.Pipe({onNotified:this.onPipeNotified});return n.setMiddlewares(g.MIDDLEWARE_DIRECTION_UPWARD,t),n.on(`next_${g.MIDDLEWARE_DIRECTION_UPWARD}`,this.sendForward),n.on(`next_${g.MIDDLEWARE_DIRECTION_DOWNWARD}`,this.sendBackward),n}onPipeNotified(e){var t=this;return o(function*(){switch(e.type){case f.SOCKET_CONNECT_TO_REMOTE:{var n=e.payload;const r=n.host,o=n.port,a=n.onConnected;__IS_SERVER__&&(yield t.connect({host:r,port:o})),__IS_CLIENT__&&(u.logger.info(`[socket] [${t.remote}] request: ${r}:${o}`),yield t.connect({host:__SERVER_HOST__,port:__SERVER_PORT__})),t._isConnectedToDst=!0,'function'==typeof a&&a();break}case f.PROCESSING_FAILED:{const n={remoteHost:t._remoteHost,remotePort:t._remotePort,onClose:t.destroy,connect:t.connect,setPresets:t.setPresets,action:e};var r=e.payload;const o=r.name,a=r.message;u.logger.error(`[socket] [${t.remote}] preset "${o}" fail to process: ${a}`),yield __BEHAVIOURS__[h.BEHAVIOUR_EVENT_ON_PRESET_FAILED].run(n);break}default:}})()}destroy(){this.onForwardSocketClose(),this.onBackwardSocketClose()}}t.Relay=y},function(e,t,n){'use strict';Object.defineProperty(t,'__esModule',{value:!0}),t.Pipe=void 0;var r=n(3),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(35),s=n(1);class i extends o.default{constructor(e={}){super(),this._upstream_middlewares=[],this._downstream_middlewares=[],this._onNotified=()=>0,this._onNotified='undefined'==typeof e.onNotified?()=>0:e.onNotified,this.onBroadcast=this.onBroadcast.bind(this)}onBroadcast(e){const t=this.getMiddlewares(a.MIDDLEWARE_DIRECTION_UPWARD),n=[];var r=!0,o=!1,s;try{for(var i=t[Symbol.iterator](),l;!(r=(l=i.next()).done);r=!0){const t=l.value;n.push(t.onNotified(e))}}catch(e){o=!0,s=e}finally{try{!r&&i.return&&i.return()}finally{if(o)throw s}}n.every((e)=>!1==!!e)&&this._onNotified(e)}setMiddlewares(e,t){var n=!0,r=!1,o;try{for(var i=t[Symbol.iterator](),l;!(n=(l=i.next()).done);n=!0){const e=l.value;e.setMaxListeners(2),e.subscribe(this.onBroadcast)}}catch(e){r=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(r)throw o}}e===a.MIDDLEWARE_DIRECTION_UPWARD?(this._upstream_middlewares=t,this._downstream_middlewares=[].concat(t).reverse()):(this._downstream_middlewares=t,this._upstream_middlewares=[].concat(t).reverse()),this.onBroadcast(e,{type:s.PRESET_INIT,payload:{broadcast:this.onBroadcast}})}getMiddlewares(e){return{[a.MIDDLEWARE_DIRECTION_UPWARD]:this._upstream_middlewares,[a.MIDDLEWARE_DIRECTION_DOWNWARD]:this._downstream_middlewares}[e]}feed(e,t){const n=`next_${e}`,r=this.getMiddlewares(e),o=(t,r=!1)=>this.emit(r?`next_${-e}`:n,t),a=(e,n)=>this.onBroadcast({type:s.PROCESSING_FAILED,payload:{name:e,message:n,orgData:t}}),i=r.reduce((t,r)=>{return 1>t.listenerCount(n)&&t.on(n,(t)=>r.write(e,{buffer:t,direct:o,fail:a})),r});1>i.listenerCount(n)&&i.on(n,o),r[0].write(e,{buffer:t,direct:o,fail:a})}destroy(){this._upstream_middlewares=null,this._downstream_middlewares=null}}t.Pipe=i}]);
//# sourceMappingURL=blinksocks.js.map