@medux/wechat-redux-devtools
Version:
redux devtools for wechat
1 lines • 114 kB
JavaScript
"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var o=function(t,e){if("$"!==e)for(var r=function(t){var e,r=/(?:\.(\w+))|(?:\[(\d+)\])|(?:\["((?:[^\\"]|\\.)*)"\])/g,n=[];for(;e=r.exec(t);)n.push(e[1]||e[2]||e[3]);return n}(e),n=0;n<r.length;n++)e=r[n].toString().replace(/\\"/g,'"'),void 0===t[e]&&n!==r.length-1||(t=t[e]);return t};var i=function(t){var e="";return t.ignoreCase&&(e+="i"),t.global&&(e+="g"),t.multiline&&(e+="m"),e},a=function(t,e){if("function"==typeof e)return e(t);var r=t.toString(),n=r.match(/^[^{]*{|^[^=]*=>/),o=n?n[0]:"<function> ",i="}"===r[r.length-1]?"}":"";return o.replace(/\r\n|\n/g," ").replace(/\s+/g," ")+" /* ... */ "+i},s=function(t,e){var r=t[0],n=t.slice(1);switch(r){case"$":return o(e,t);case"r":var i=n.indexOf(","),a=n.slice(0,i),s=n.slice(i+1);return RegExp(s,a);case"d":return new Date(+n);case"f":var c=function(){throw new Error("can't run jsan parsed function")};return c.toString=function(){return n},c;case"u":return;case"e":var u=new Error(n);return u.stack="Stack is unavailable for jsan parsed errors",u;case"s":return Symbol(n);case"g":return Symbol.for(n);case"m":return new Map(l.parse(n));case"l":return new Set(l.parse(n));case"n":return NaN;case"i":return 1/0;case"y":return-1/0;default:return console.warn("unknown type",t),t}},c="undefined"!=typeof WeakMap?WeakMap:function(){var t=[],e=[];return{set:function(r,n){t.push(r),e.push(n)},get:function(r){for(var n=0;n<t.length;n++)if(t[n]===r)return e[n]}}},u=function t(e,r,n){var o=new c,s=!Object.prototype.hasOwnProperty.call(r,"circular"),u=!1!==r.refs;return function e(c,f,l){var h,p,d,y="function"==typeof n?n(l||"",c):c;if(r.date&&y instanceof Date)return{$jsan:"d"+y.getTime()};if(r.regex&&y instanceof RegExp)return{$jsan:"r"+i(y)+","+y.source};if(r.function&&"function"==typeof y)return{$jsan:"f"+a(y,r.function)};if(r.nan&&"number"==typeof y&&isNaN(y))return{$jsan:"n"};if(r.infinity){if(Number.POSITIVE_INFINITY===y)return{$jsan:"i"};if(Number.NEGATIVE_INFINITY===y)return{$jsan:"y"}}if(r[void 0]&&void 0===y)return{$jsan:"u"};if(r.error&&y instanceof Error)return{$jsan:"e"+y.message};if(r.symbol&&"symbol"==typeof y){var v=Symbol.keyFor(y);return void 0!==v?{$jsan:"g"+v}:{$jsan:"s"+y.toString().slice(7,-1)}}if(r.map&&"function"==typeof Map&&y instanceof Map&&"function"==typeof Array.from)return{$jsan:"m"+JSON.stringify(t(Array.from(y),r,n))};if(r.set&&"function"==typeof Set&&y instanceof Set&&"function"==typeof Array.from)return{$jsan:"l"+JSON.stringify(t(Array.from(y),r,n))};if(y&&"function"==typeof y.toJSON)try{y=y.toJSON(l)}catch(t){var b=l||"$";return"toJSON failed for '"+(o.get(y)||b)+"'"}if(!("object"!=typeof y||null===y||y instanceof Boolean||y instanceof Date||y instanceof Number||y instanceof RegExp||y instanceof String||"symbol"==typeof y||y instanceof Error)){if("object"==typeof y){var g=o.get(y);if(g){if(s&&u)return{$jsan:g};if(0===f.indexOf(g))return s?{$jsan:g}:"function"==typeof r.circular?r.circular(y,f,g):r.circular;if(u)return{$jsan:g}}o.set(y,f)}if("[object Array]"===Object.prototype.toString.apply(y))for(d=[],h=0;h<y.length;h+=1)d[h]=e(y[h],f+"["+h+"]",h);else for(p in d={},y)if(Object.prototype.hasOwnProperty.call(y,p)){var m=/^\w+$/.test(p)?"."+p:"["+JSON.stringify(p)+"]";d[p]="$jsan"===p?[e(y[p],f+m)]:e(y[p],f+m,p)}return d}return y}(e,"$")},f=function(t){return function e(r){var n,o,i;if(r&&"object"==typeof r)if("[object Array]"===Object.prototype.toString.apply(r))for(n=0;n<r.length;n+=1)(o=r[n])&&"object"==typeof o&&(o.$jsan?r[n]=s(o.$jsan,t):e(o));else for(i in r){if("string"==typeof r[i]&&"$jsan"===i)return s(r.$jsan,t);"$jsan"===i&&(r[i]=r[i][0]),"object"==typeof r[i]&&(o=r[i])&&"object"==typeof o&&(o.$jsan?r[i]=s(o.$jsan,t):e(o))}return r}(t)},l={stringify:function(t,e,r,n){if(arguments.length<4)try{return 1===arguments.length?JSON.stringify(t):JSON.stringify.apply(JSON,arguments)}catch(t){}var o=n||!1;"boolean"==typeof o&&(o={date:o,function:o,regex:o,undefined:o,error:o,symbol:o,map:o,set:o,nan:o,infinity:o});var i=u(t,o,e);return 1===arguments.length?JSON.stringify(i):JSON.stringify(i,Array.isArray(e)?e:null,r)},parse:function(t,e){var r,n=/"\$jsan"/.test(t);return r=1===arguments.length?JSON.parse(t):JSON.parse(t,e),n&&(r=f(r)),r}},h=l,p=n((function(r,n){r.exports=function t(r,n,o){function i(s,c){if(!n[s]){if(!r[s]){if(!c&&e)return e();if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[s]={exports:{}};r[s][0].call(f.exports,(function(t){return i(r[s][1][t]||t)}),f,f.exports,t,r,n,o)}return n[s].exports}for(var a=e,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e,r){r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=u(t),a=n[0],s=n[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),f=0,l=s>0?a-4:a;for(r=0;r<l;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===s&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===s&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],a=0,s=r-o;a<s;a+=16383)i.push(f(t,a,a+16383>s?s:a+16383));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=a.length;s<c;++s)n[s]=a[s],o[a.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var o,i,a=[],s=e;s<r;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){(function(e){var n=t("base64-js"),o=t("ieee754");function i(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return a(t,e,r)}function a(t,r,n){if("string"==typeof t)return function(t,r){if("string"==typeof r&&""!==r||(r="utf8"),!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|l(t,r),o=i(n),a=o.write(t,r);return a!==n&&(o=o.slice(0,a)),o}(t,r);if(ArrayBuffer.isView(t))return u(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(U(t,ArrayBuffer)||t&&U(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n)).__proto__=e.prototype,o}(t,r,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var o=t.valueOf&&t.valueOf();if(null!=o&&o!==t)return e.from(o,r,n);var a=function(t){if(e.isBuffer(t)){var r=0|f(t.length),n=i(r);return 0===n.length||t.copy(n,0,0,r),n}return void 0!==t.length?"number"!=typeof t.length||D(t.length)?i(0):u(t):"Buffer"===t.type&&Array.isArray(t.data)?u(t.data):void 0}(t);if(a)return a;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return e.from(t[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return s(t),i(t<0?0:0|f(t))}function u(t){for(var e=t.length<0?0:0|f(t.length),r=i(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function l(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||U(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(t).length;default:if(i)return o?-1:P(t).length;r=(""+r).toLowerCase(),i=!0}}function h(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return O(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return w(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,r,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),D(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=e.from(r,o)),e.isBuffer(r))return 0===r.length?-1:y(t,r,n,o,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):y(t,[r],n,o,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var f=-1;for(i=r;i<s;i++)if(u(t,i)===u(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===c)return f*a}else-1!==f&&(i-=i-f),f=-1}else for(r+c>s&&(r=s-c),i=r;i>=0;i--){for(var l=!0,h=0;h<c;h++)if(u(t,i+h)!==u(e,h)){l=!1;break}if(l)return i}return-1}function v(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(D(s))return a;t[r+a]=s}return a}function b(t,e,r,n){return L(P(e,t.length-r),t,r,n)}function g(t,e,r,n){return L(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function m(t,e,r,n){return g(t,e,r,n)}function E(t,e,r,n){return L(B(e),t,r,n)}function S(t,e,r,n){return L(function(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,a,s,c,u=t[o],f=null,l=u>239?4:u>223?3:u>191?2:1;if(o+l<=r)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(i=t[o+1]))&&(c=(31&u)<<6|63&i)>127&&(f=c);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(c=(15&u)<<12|(63&i)<<6|63&a)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(f=c)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function w(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function O(t,e,r){var n,o=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>o)&&(r=o);for(var i="",a=e;a<r;++a)i+=(n=t[a])<16?"0"+n.toString(16):n.toString(16);return i}function k(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function C(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,r,n,o,i,a){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<a)throw new RangeError('"value" argument is out of bounds');if(n+o>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}r.Buffer=e,r.SlowBuffer=function(t){return+t!=t&&(t=0),e.alloc(+t)},r.INSPECT_MAX_BYTES=50,r.kMaxLength=2147483647,e.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}(),e.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(e.prototype,"parent",{enumerable:!0,get:function(){if(e.isBuffer(this))return this.buffer}}),Object.defineProperty(e.prototype,"offset",{enumerable:!0,get:function(){if(e.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&e[Symbol.species]===e&&Object.defineProperty(e,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),e.poolSize=8192,e.from=function(t,e,r){return a(t,e,r)},e.prototype.__proto__=Uint8Array.prototype,e.__proto__=Uint8Array,e.alloc=function(t,e,r){return function(t,e,r){return s(t),t<=0?i(t):void 0!==e?"string"==typeof r?i(t).fill(e,r):i(t).fill(e):i(t)}(t,e,r)},e.allocUnsafe=function(t){return c(t)},e.allocUnsafeSlow=function(t){return c(t)},e.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==e.prototype},e.compare=function(t,r){if(U(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),U(r,Uint8Array)&&(r=e.from(r,r.offset,r.byteLength)),!e.isBuffer(t)||!e.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var n=t.length,o=r.length,i=0,a=Math.min(n,o);i<a;++i)if(t[i]!==r[i]){n=t[i],o=r[i];break}return n<o?-1:o<n?1:0},e.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},e.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return e.alloc(0);var n;if(void 0===r)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var o=e.allocUnsafe(r),i=0;for(n=0;n<t.length;++n){var a=t[n];if(U(a,Uint8Array)&&(a=e.from(a)),!e.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(o,i),i+=a.length}return o},e.byteLength=l,e.prototype._isBuffer=!0,e.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)p(this,e,e+1);return this},e.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)p(this,e,e+3),p(this,e+1,e+2);return this},e.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},e.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):h.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},e.prototype.compare=function(t,r,n,o,i){if(U(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),r<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(this===t)return 0;for(var a=(i>>>=0)-(o>>>=0),s=(n>>>=0)-(r>>>=0),c=Math.min(a,s),u=this.slice(o,i),f=t.slice(r,n),l=0;l<c;++l)if(u[l]!==f[l]){a=u[l],s=f[l];break}return a<s?-1:s<a?1:0},e.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},e.prototype.indexOf=function(t,e,r){return d(this,t,e,r,!0)},e.prototype.lastIndexOf=function(t,e,r){return d(this,t,e,r,!1)},e.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},e.prototype.slice=function(t,r){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t);var o=this.subarray(t,r);return o.__proto__=e.prototype,o},e.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},e.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},e.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),o.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),o.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),o.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),o.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},e.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,o){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),o||0===o||(o=this.length),r>=t.length&&(r=t.length),r||(r=0),o>0&&o<n&&(o=n),o===n)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r<o-n&&(o=t.length-r+n);var i=o-n;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(r,n,o);else if(this===t&&n<r&&r<o)for(var a=i-1;a>=0;--a)t[a+r]=this[a+n];else Uint8Array.prototype.set.call(t,this.subarray(n,o),r);return i},e.prototype.fill=function(t,r,n,o){if("string"==typeof t){if("string"==typeof r?(o=r,r=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!e.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;var a;if(r>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=r;a<n;++a)this[a]=t;else{var s=e.isBuffer(t)?t:e.from(t,o),c=s.length;if(0===c)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=s[a%c]}return this};var x=/[^+/0-9A-Za-z-_]/g;function P(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function B(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(x,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function U(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function D(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":1,buffer:2,ieee754:3}],3:[function(t,e,r){r.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,c=(1<<s)-1,u=c>>1,f=-7,l=r?o-1:0,h=r?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=s;f>0;i=256*i+t[e+l],l+=h,f-=8);for(a=i&(1<<-f)-1,i>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===i)i=1-u;else{if(i===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=u}return(p?-1:1)*a*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var a,s,c,u=8*i-o-1,f=(1<<u)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+l>=1?h/c:h*Math.pow(2,1-l))*c>=2&&(a++,c/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*c-1)*Math.pow(2,o),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<<o|s,u+=o;u>0;t[r+p]=255&a,p+=d,a/=256,u-=8);t[r+p-d]|=128*y}},{}],4:[function(t,e,r){function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,i){e=e||"&",r=r||"=";var a={};if("string"!=typeof t||0===t.length)return a;var s=/\+/g;t=t.split(e);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var u=t.length;c>0&&u>c&&(u=c);for(var f=0;f<u;++f){var l,h,p,d,y=t[f].replace(s,"%20"),v=y.indexOf(r);v>=0?(l=y.substr(0,v),h=y.substr(v+1)):(l=y,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),n(a,p)?o(a[p])?a[p].push(d):a[p]=[a[p],d]:a[p]=d}return a};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],5:[function(t,e,r){var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,s){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?i(a(t),(function(a){var s=encodeURIComponent(n(a))+r;return o(t[a])?i(t[a],(function(t){return s+encodeURIComponent(n(t))})).join(e):s+encodeURIComponent(n(t[a]))})).join(e):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(t)):""};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},{}],6:[function(t,e,r){r.decode=r.parse=t("./decode"),r.encode=r.stringify=t("./encode")},{"./decode":4,"./encode":5}],7:[function(t,e,r){var n=t("./lib/scclientsocket"),o=t("./lib/factory");e.exports.factory=o,e.exports.SCClientSocket=n,e.exports.Emitter=t("component-emitter"),e.exports.create=function(t){return o.create(t)},e.exports.connect=e.exports.create,e.exports.destroy=function(t){return o.destroy(t)},e.exports.clients=o.clients,e.exports.version="14.2.1"},{"./lib/factory":9,"./lib/scclientsocket":11,"component-emitter":15}],8:[function(e,r,n){(function(t){var e=function(){this._internalStorage={},this.isLocalStorageEnabled=this._checkLocalStorageEnabled()};e.prototype._checkLocalStorageEnabled=function(){var e;try{t.localStorage,t.localStorage.setItem("__scLocalStorageTest",1),t.localStorage.removeItem("__scLocalStorageTest")}catch(t){e=t}return!e},e.prototype.saveToken=function(e,r,n,o){this.isLocalStorageEnabled&&t.localStorage?t.localStorage.setItem(e,r):this._internalStorage[e]=r,o&&o(null,r)},e.prototype.removeToken=function(e,r){var n;this.loadToken(e,(function(t,e){n=e})),this.isLocalStorageEnabled&&t.localStorage?t.localStorage.removeItem(e):delete this._internalStorage[e],r&&r(null,n)},e.prototype.loadToken=function(e,r){r(null,this.isLocalStorageEnabled&&t.localStorage?t.localStorage.getItem(e):this._internalStorage[e]||null)},r.exports.AuthEngine=e}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,r,n){(function(t){var n=e("./scclientsocket"),o=e("sc-errors"),i=e("uuid"),a=o.InvalidArgumentsError,s={};function c(e,r){var n=null==e.secure?r:e.secure;return e.port||(t.location&&location.port?location.port:n?443:80)}r.exports={create:function(e){if((e=e||{}).host&&!e.host.match(/[^:]+:\d{2,5}/))throw new a('The host option should include both the hostname and the port number in the format "hostname:port"');if(e.host&&e.hostname)throw new a('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(e.host&&e.port)throw new a('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');var r=t.location&&"https:"===location.protocol,o={port:c(e,r),hostname:t.location&&location.hostname||"localhost",path:"/socketcluster/",secure:r,autoConnect:!0,autoReconnect:!0,autoSubscribeOnConnect:!0,connectTimeout:2e4,ackTimeout:1e4,timestampRequests:!1,timestampParam:"t",authEngine:null,authTokenName:"socketCluster.authToken",binaryType:"arraybuffer",multiplex:!0,pubSubBatchDuration:null,cloneData:!1};for(var u in e)e.hasOwnProperty(u)&&(o[u]=e[u]);if(o.clientMap=s,!1===o.multiplex){o.clientId=i.v4();var f=new n(o);return s[o.clientId]=f,f}return o.clientId=function(t){var e=t.secure?"https://":"http://",r="";if(t.query)if("string"==typeof t.query)r=t.query;else{var n=[],o=t.query;for(var i in o)o.hasOwnProperty(i)&&n.push(i+"="+o[i]);n.length&&(r="?"+n.join("&"))}return e+(t.host?t.host:t.hostname+":"+t.port)+t.path+r}(o),s[o.clientId]?o.autoConnect&&s[o.clientId].connect():s[o.clientId]=new n(o),s[o.clientId]},destroy:function(t){t.destroy()},clients:s}}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./scclientsocket":11,"sc-errors":20,uuid:22}],10:[function(t,e,r){var n=t("sc-errors"),o=n.InvalidActionError,i=function(t,e){this.socket=t,this.id=e,this.sent=!1};i.prototype._respond=function(t){if(this.sent)throw new o("Response "+this.id+" has already been sent");this.sent=!0,this.socket.send({data:this.socket.encode(t)})},i.prototype.end=function(t){if(this.id){var e={rid:this.id};void 0!==t&&(e.data=t),this._respond(e)}},i.prototype.error=function(t,e){if(this.id){var r=n.dehydrateError(t),o={rid:this.id,error:r};void 0!==e&&(o.data=e),this._respond(o)}},i.prototype.callback=function(t,e){t?this.error(t,e):this.end(e)},e.exports.Response=i},{"sc-errors":20}],11:[function(e,r,n){(function(t,n){var o=e("component-emitter"),i=e("sc-channel").SCChannel,a=(e("./response").Response,e("./auth").AuthEngine),s=e("sc-formatter"),c=e("./wctransport").WCTransport,u=e("querystring"),f=e("linked-list"),l=e("base-64"),h=e("clone"),p=e("sc-errors"),d=p.InvalidArgumentsError,y=p.InvalidMessageError,v=p.InvalidActionError,b=p.SocketProtocolError,g=p.TimeoutError,m=p.BadConnectionError,E="undefined"!=typeof window,S=function(e){var r=this;o.call(this),this.id=null,this.state=this.CLOSED,this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null,this.pendingReconnect=!1,this.pendingReconnectTimeout=null,this.preparingPendingSubscriptions=!1,this.clientId=e.clientId,this.connectTimeout=e.connectTimeout,this.ackTimeout=e.ackTimeout,this.channelPrefix=e.channelPrefix||null,this.disconnectOnUnload=null==e.disconnectOnUnload||e.disconnectOnUnload,this.authTokenName=e.authTokenName,this.pingTimeout=this.ackTimeout,this.pingTimeoutDisabled=!!e.pingTimeoutDisabled,this.active=!0,this._clientMap=e.clientMap||{};var n=Math.pow(2,31)-1,i=function(t){if(r[t]>n)throw new d("The "+t+" value provided exceeded the maximum amount allowed")};if(i("connectTimeout"),i("ackTimeout"),this._localEvents={connect:1,connectAbort:1,close:1,disconnect:1,message:1,error:1,raw:1,kickOut:1,subscribe:1,unsubscribe:1,subscribeStateChange:1,authStateChange:1,authenticate:1,deauthenticate:1,removeAuthToken:1,subscribeRequest:1},this.connectAttempts=0,this._emitBuffer=new f,this.channels={},this.options=e,this._cid=1,this.options.callIdGenerator=function(){return r._cid++},this.options.autoReconnect){null==this.options.autoReconnectOptions&&(this.options.autoReconnectOptions={});var c=this.options.autoReconnectOptions;null==c.initialDelay&&(c.initialDelay=1e4),null==c.randomness&&(c.randomness=1e4),null==c.multiplier&&(c.multiplier=1.5),null==c.maxDelay&&(c.maxDelay=6e4)}if(null==this.options.subscriptionRetryOptions&&(this.options.subscriptionRetryOptions={}),this.options.authEngine?this.auth=this.options.authEngine:this.auth=new a,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=s,this.options.protocol){var l=new d('The "protocol" option does not affect socketcluster-client. If you want to utilize SSL/TLS - use "secure" option instead');this._onSCError(l)}this.options.path=this.options.path.replace(/\/$/,"")+"/",this.options.query=e.query||{},"string"==typeof this.options.query&&(this.options.query=u.parse(this.options.query)),this._channelEmitter=new o,this._unloadHandler=function(){r.disconnect()},E&&this.disconnectOnUnload&&t.addEventListener&&t.addEventListener("beforeunload",this._unloadHandler,!1),this._clientMap[this.clientId]=this,this.options.autoConnect&&this.connect()};S.prototype=Object.create(o.prototype),S.CONNECTING=S.prototype.CONNECTING=c.prototype.CONNECTING,S.OPEN=S.prototype.OPEN=c.prototype.OPEN,S.CLOSED=S.prototype.CLOSED=c.prototype.CLOSED,S.AUTHENTICATED=S.prototype.AUTHENTICATED="authenticated",S.UNAUTHENTICATED=S.prototype.UNAUTHENTICATED="unauthenticated",S.PENDING=S.prototype.PENDING="pending",S.ignoreStatuses=p.socketProtocolIgnoreStatuses,S.errorStatuses=p.socketProtocolErrorStatuses,S.prototype._privateEventHandlerMap={"#publish":function(t){var e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelEmitter.emit(e,t.data)},"#kickOut":function(t){var e=this._undecorateChannelName(t.channel),r=this.channels[e];r&&(o.prototype.emit.call(this,"kickOut",t.message,e),r.emit("kickOut",t.message,e),this._triggerChannelUnsubscribe(r))},"#setAuthToken":function(t,e){var r=this;t?this.auth.saveToken(this.authTokenName,t.token,{},(function(n){n?(e.error(n),r._onSCError(n)):(r._changeToAuthenticatedState(t.token),e.end())})):e.error(new y("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){var r=this;this.auth.removeToken(this.authTokenName,(function(t,n){t?(e.error(t),r._onSCError(t)):(o.prototype.emit.call(r,"removeAuthToken",n),r._changeToUnauthenticatedStateAndClearTokens(),e.end())}))},"#disconnect":function(t){this.transport.close(t.code,t.data)}},S.prototype.getState=function(){return this.state},S.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},S.prototype.deauthenticate=function(t){var e=this;this.auth.removeToken(this.authTokenName,(function(r,n){r?e._onSCError(r):(o.prototype.emit.call(e,"removeAuthToken",n),e.state!==e.CLOSED&&e.emit("#removeAuthToken"),e._changeToUnauthenticatedStateAndClearTokens()),t&&t(r)}))},S.prototype.connect=S.prototype.open=function(){var t=this;if(this.active)this.state===this.CLOSED&&(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this.state=this.CONNECTING,o.prototype.emit.call(this,"connecting"),this.transport&&this.transport.off(),this.transport=new c(this.auth,this.codec,this.options),this.transport.on("open",(function(e){t.state=t.OPEN,t._onSCOpen(e)})),this.transport.on("error",(function(e){t._onSCError(e)})),this.transport.on("close",(function(e,r){t.state=t.CLOSED,t._onSCClose(e,r)})),this.transport.on("openAbort",(function(e,r){t.state=t.CLOSED,t._onSCClose(e,r,!0)})),this.transport.on("event",(function(e,r,n){t._onSCEvent(e,r,n)})));else{var e=new v("Cannot connect a destroyed client");this._onSCError(e)}},S.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},S.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new d("If specified, the code argument must be a number");this.state===this.OPEN||this.state===this.CONNECTING?this.transport.close(t,e):(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef))},S.prototype.destroy=function(e,r){E&&t.removeEventListener&&t.removeEventListener("beforeunload",this._unloadHandler,!1),this.active=!1,this.disconnect(e,r),delete this._clientMap[this.clientId]},S.prototype._changeToUnauthenticatedStateAndClearTokens=function(){if(this.authState!==this.UNAUTHENTICATED){var t=this.authState,e=this.signedAuthToken;this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null;var r={oldState:t,newState:this.authState};o.prototype.emit.call(this,"authStateChange",r),o.prototype.emit.call(this,"deauthenticate",e)}},S.prototype._changeToAuthenticatedState=function(t){if(this.signedAuthToken=t,this.authToken=this._extractAuthTokenData(t),this.authState!==this.AUTHENTICATED){var e=this.authState;this.authState=this.AUTHENTICATED;var r={oldState:e,newState:this.authState,signedAuthToken:t,authToken:this.authToken};this.preparingPendingSubscriptions||this.processPendingSubscriptions(),o.prototype.emit.call(this,"authStateChange",r)}o.prototype.emit.call(this,"authenticate",t)},S.prototype.decodeBase64=function(e){return void 0===n?t.atob?t.atob(e):l.decode(e):n.from(e,"base64").toString("utf8")},S.prototype.encodeBase64=function(e){return void 0===n?t.btoa?t.btoa(e):l.encode(e):n.from(e,"utf8").toString("base64")},S.prototype._extractAuthTokenData=function(t){var e=(t||"").split(".")[1];if(null!=e){var r=e;try{return r=this.decodeBase64(r),JSON.parse(r)}catch(t){return r}}return null},S.prototype.getAuthToken=function(){return this.authToken},S.prototype.getSignedAuthToken=function(){return this.signedAuthToken},S.prototype.authenticate=function(t,e){var r=this;this.emit("#authenticate",t,(function(n,o){o&&null!=o.isAuthenticated?o.authError&&(o.authError=p.hydrateError(o.authError)):o={isAuthenticated:r.authState,authError:null},n?("BadConnectionError"!==n.name&&"TimeoutError"!==n.name&&r._changeToUnauthenticatedStateAndClearTokens(),e&&e(n,o)):r.auth.saveToken(r.authTokenName,t,{},(function(n){n&&r._onSCError(n),o.isAuthenticated?r._changeToAuthenticatedState(t):r._changeToUnauthenticatedStateAndClearTokens(),e&&e(n,o)}))}))},S.prototype._tryReconnect=function(t){var e,r=this,n=this.connectAttempts++,o=this.options.autoReconnectOptions;if(null==t||n>0){var i=Math.round(o.initialDelay+(o.randomness||0)*Math.random());e=Math.round(i*Math.pow(o.multiplier,n))}else e=t;e>o.maxDelay&&(e=o.maxDelay),clearTimeout(this._reconnectTimeoutRef),this.pendingReconnect=!0,this.pendingReconnectTimeout=e,this._reconnectTimeoutRef=setTimeout((function(){r.connect()}),e)},S.prototype._onSCOpen=function(t){var e=this;this.preparingPendingSubscriptions=!0,t?(this.id=t.id,this.pingTimeout=t.pingTimeout,this.transport.pingTimeout=this.pingTimeout,t.isAuthenticated?this._changeToAuthenticatedState(t.authToken):this._changeToUnauthenticatedStateAndClearTokens()):this._changeToUnauthenticatedStateAndClearTokens(),this.connectAttempts=0,this.options.autoSubscribeOnConnect&&this.processPendingSubscriptions(),o.prototype.emit.call(this,"connect",t,(function(){e.processPendingSubscriptions()})),this.state===this.OPEN&&this._flushEmitBuffer()},S.prototype._onSCError=function(t){var e=this;setTimeout((function(){if(e.listeners("error").length<1)throw t;o.prototype.emit.call(e,"error",t)}),0)},S.prototype._suspendSubscriptions=function(){var t,e;for(var r in this.channels)this.channels.hasOwnProperty(r)&&(e=(t=this.channels[r]).state===t.SUBSCRIBED||t.state===t.PENDING?t.PENDING:t.UNSUBSCRIBED,this._triggerChannelUnsubscribe(t,e))},S.prototype._abortAllPendingEventsDueToBadConnection=function(t){for(var e,r=this._emitBuffer.head;r;){e=r.next;var n=r.data;clearTimeout(n.timeout),delete n.timeout,r.detach(),r=e;var o=n.callback;if(o){delete n.callback;var i="Event '"+n.event+"' was aborted due to a bad connection",a=new m(i,t);o.call(n,a,n)}n.cid&&this.transport.cancelPendingResponse(n.cid)}},S.prototype._onSCClose=function(t,e,r){if(this.id=null,this.transport&&this.transport.off(),this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this._suspendSubscriptions(),this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect()),r?o.prototype.emit.call(this,"connectAbort",t,e):o.prototype.emit.call(this,"disconnect",t,e),o.prototype.emit.call(this,"close",t,e),!S.ignoreStatuses[t]){var n;n=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;var i=new b(S.errorStatuses[t]||n,t);this._onSCError(i)}},S.prototype._onSCEvent=function(t,e,r){var n=this._privateEventHandlerMap[t];n?n.call(this,e,r):o.prototype.emit.call(this,t,e,(function(){r&&r.callback.apply(r,arguments)}))},S.prototype.decode=function(t){return this.transport.decode(t)},S.prototype.encode=function(t){return this.transport.encode(t)},S.prototype._flushEmitBuffer=function(){for(var t,e=this._emitBuffer.head;e;){t=e.next;var r=e.data;e.detach(),this.transport.emitObject(r),e=t}},S.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;var r=t.callback;if(r){delete t.callback;var n=new g("Event response for '"+t.event+"' timed out");r.call(t,n,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},S.prototype._emit=function(t,e,r){var n=this;this.state===this.CLOSED&&this.connect();var o={event:t,callback:r},i=new f.Item;this.options.cloneData?o.data=h(e):o.data=e,i.data=o,o.timeout=setTimeout((function(){n._handleEventAckTimeout(o,i)}),this.ackTimeout),this._emitBuffer.append(i),this.state===this.OPEN&&this._flushEmitBuffer()},S.prototype.send=function(t){this.transport.send(t)},S.prototype.emit=function(t,e,r){if(null==this._localEvents[t])this._emit(t,e,r);else if("error"===t)o.prototype.emit.call(this,t,e);else{var n=new v('The "'+t+'" event is reserved and cannot be emitted on a client socket');this._onSCError(n)}},S.prototype.publish=function(t,e,r){var n={channel:this._decorateChannelName(t),data:e};this.emit("#publish",n,r)},S.prototype._triggerChannelSubscribe=function(t,e){var r=t.name;if(t.state!==t.SUBSCRIBED){var n=t.state;t.state=t.SUBSCRIBED;var i={channel:r,oldState:n,newState:t.state,subscriptionOptions:e};t.emit("subscribeStateChange",i),t.emit("subscribe",r,e),o.prototype.emit.call(this,"subscribeStateChange",i),o.prototype.emit.call(this,"subscribe",r,e)}},S.prototype._triggerChannelSubscribeFail=function(t,e,r){var n=e.name,i=!e.waitForAuth||this.authState===this.AUTHENTICATED;e.state!==e.UNSUBSCRIBED&&i&&(e.state=e.UNSUBSCRIBED,e.emit("subscribeFail",t,n,r),o.prototype.emit.call(this,"subscribeFail",t,n,r))},S.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},S.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},S.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},S.prototype._trySubscribe=function(t){var e=this,r=!t.waitForAuth||this.authState===this.AUTHENTICATED;if(this.state===this.OPEN&&!this.preparingPendingSubscriptions&&null==t._pendingSubscriptionCid&&r){var n={noTimeout:!0},i={channel:this._decorateChannelName(t.name)};t.waitForAuth&&(n.waitForAuth=!0,i.waitForAuth=n.waitForAuth),t.data&&(i.data=t.data),t.batch&&(n.batch=!0,i.batch=!0),t._pendingSubscriptionCid=this.transport.emit("#subscribe",i,n,(function(r){delete t._pendingSubscriptionCid,r?e._triggerChannelSubscribeFail(r,t,i):e._triggerChannelSubscribe(t,i)})),o.prototype.emit.call(this,"subscribeRequest",t.name,i)}},S.prototype.subscribe=function(t,e){var r=this.channels[t];return r?e&&r.setOptions(e):(r=new i(t,this,e),this.channels[t]=r),r.state===r.UNSUBSCRIBED&&(r.state=r.PENDING,this._trySubscribe(r)),r},S.prototype._triggerChannelUnsubscribe=function(t,e){var r=t.name,n=t.state;if(t.state=e||t.UNSUBSCRIBED,this._cancelPendingSubscribeCallback(t),n===t.SUBSCRIBED){var i={channel:r,oldState:n,newState:t.state};t.emit("subscribeStateChange",i),t.emit("unsubscribe",r),o.prototype.emit.call(this,"subscribeStateChange",i),o.prototype.emit.call(this,"unsubscribe",r)}},S.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){var e={noTimeout:!0};t.batch&&(e.batch=!0),this._cancelPendingSubscribeCallback(t);var r=this._decorateChannelName(t.name);this.transport.emit("#unsubscribe",r,e)}},S.prototype.unsubscribe=function(t){var e=this.channels[t];e&&e.state!==e.UNSUBSCRIBED&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},S.prototype.channel=function(t,e){var r=this.channels[t];return r||(r=new i(t,this,e),this.channels[t]=r),r},S.prototype.destroyChannel=function(t){var e=this.channels[t];e&&(e.unwatch(),e.unsubscribe(),delete this.channels[t])},S.prototype.subscriptions=function(t){var e,r=[];for(var n in this.channels)this.channels.hasOwnProperty(n)&&(e=this.channels[n],(t?e&&(e.state===e.SUBSCRIBED||e.state===e.PENDING):e&&e.state===e.SUBSCRIBED)&&r.push(n));return r},S.prototype.isSubscribed=function(t,e){var r=this.channels[t];return e?!!r&&(r.state===r.SUBSCRIBED||r.state===r.PENDING):!!r&&r.state===r.SUBSCRIBED},S.prototype.processPendingSubscriptions=function(){var t=this;this.preparingPendingSubscriptions=!1;var e=[];for(var r in this.channels)if(this.channels.hasOwnProperty(r)){var n=this.channels[r];n.state===n.PENDING&&e.push(n)}e.sort((function(t,e){var r=t.priority||0,n=e.priority||0;return r>n?-1:r<n?1:0})),e.forEach((function(e){t._trySubscribe(e)}))},S.prototype.watch=function(t,e){if("function"!=typeof e)throw new d("No handler function was provided");this._channelEmitter.on(t,e)},S.prototype.unwatch=function(t,e){e?this._channelEmitter.removeListener(t,e):this._channelEmitter.removeAllListeners(t)},S.prototype.watchers=function(t){return this._channelEmitter.listeners(t)},r.exports=S}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./auth":8,"./response":10,"./wctransport":12,"base-64":13,buffer:2,clone:14,"component-emitter":15,"linked-list":17,querystring:6,"sc-channel":18,"sc-errors":20,"sc-formatter":21}],12:[function(t,e,r){var n=t("component-emitter"),o=t("./response").Response,i=t("querystring"),a=t("sc-errors"),s=a.TimeoutError,c=a.BadConnectionError,u=function(t,e,r){var n=this;this.state=this.CLOSED,this.auth=t,this.codec=e,this.options=r,this.connectTimeout=r.connectTimeout,this.pingTimeout=r.ackTimeout,this.pingTimeoutDisabled=!!r.pingTimeoutDisabled,this.callIdGenerator=r.callIdGenerator,this.authTokenName=r.authTokenName,this._pingTimeoutTicker=null,this._callbackMap={},this._batchSendList=[],this.state=this.CONNECTING;var o=this.uri(),i=wx.connectSocket({url:o,data:this.options});i.binaryType=this.options.binaryType,this.socket=i,i.onOpen((function(){n._onOpen()})),i.onClose((function(t){var e;e=null==t.code?1005:t.code,n._onClose(e,t.reason)})),i.onMessage((function(t,e){n._onMessage(t.data)})),i.onError((function(t){n.state===n.CONNECTING&&n._onClose(1006),this._connectTimeoutRef=setTimeout((function(){n.