enc-utils
Version:
Byte encoding utils
10 lines • 28.2 kB
JavaScript
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("encUtils",[],r):"object"==typeof exports?exports.encUtils=r():t.encUtils=r()}(this,(function(){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=2)}([function(t,r,n){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var e=n(4),i=n(5),o=n(6);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(t,r){if(u()<r)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=a.prototype:(null===t&&(t=new a(r)),t.length=r),t}function a(t,r,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,r,n);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return s(this,t,r,n)}function s(t,r,n,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,n,e){if(r.byteLength,n<0||r.byteLength<n)throw new RangeError("'offset' is out of bounds");if(r.byteLength<n+(e||0))throw new RangeError("'length' is out of bounds");r=void 0===n&&void 0===e?new Uint8Array(r):void 0===e?new Uint8Array(r,n):new Uint8Array(r,n,e);a.TYPED_ARRAY_SUPPORT?(t=r).__proto__=a.prototype:t=l(t,r);return t}(t,r,n,e):"string"==typeof r?function(t,r,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var e=0|y(r,n),i=(t=f(t,e)).write(r,n);i!==e&&(t=t.slice(0,i));return t}(t,r,n):function(t,r){if(a.isBuffer(r)){var n=0|p(r.length);return 0===(t=f(t,n)).length||r.copy(t,0,0,n),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(e=r.length)!=e?f(t,0):l(t,r);if("Buffer"===r.type&&o(r.data))return l(t,r.data)}var e;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function c(t,r){if(h(r),t=f(t,r<0?0:0|p(r)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<r;++n)t[n]=0;return t}function l(t,r){var n=r.length<0?0:0|p(r.length);t=f(t,n);for(var e=0;e<n;e+=1)t[e]=255&r[e];return t}function p(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function y(t,r){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var e=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(t).length;default:if(e)return k(t).length;r=(""+r).toLowerCase(),e=!0}}function g(t,r,n){var e=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,r,n);case"utf8":case"utf-8":return B(this,r,n);case"ascii":return P(this,r,n);case"latin1":case"binary":return U(this,r,n);case"base64":return R(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,r,n);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}function d(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function w(t,r,n,e,i){if(0===t.length)return-1;if("string"==typeof n?(e=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(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=a.from(r,e)),a.isBuffer(r))return 0===r.length?-1:b(t,r,n,e,i);if("number"==typeof r)return r&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):b(t,[r],n,e,i);throw new TypeError("val must be string, number or Buffer")}function b(t,r,n,e,i){var o,u=1,f=t.length,a=r.length;if(void 0!==e&&("ucs2"===(e=String(e).toLowerCase())||"ucs-2"===e||"utf16le"===e||"utf-16le"===e)){if(t.length<2||r.length<2)return-1;u=2,f/=2,a/=2,n/=2}function s(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var h=-1;for(o=n;o<f;o++)if(s(t,o)===s(r,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===a)return h*u}else-1!==h&&(o-=o-h),h=-1}else for(n+a>f&&(n=f-a),o=n;o>=0;o--){for(var c=!0,l=0;l<a;l++)if(s(t,o+l)!==s(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,n,e){n=Number(n)||0;var i=t.length-n;e?(e=Number(e))>i&&(e=i):e=i;var o=r.length;if(o%2!=0)throw new TypeError("Invalid hex string");e>o/2&&(e=o/2);for(var u=0;u<e;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[n+u]=f}return u}function v(t,r,n,e){return H(k(r,t.length-n),t,n,e)}function m(t,r,n,e){return H(function(t){for(var r=[],n=0;n<t.length;++n)r.push(255&t.charCodeAt(n));return r}(r),t,n,e)}function E(t,r,n,e){return m(t,r,n,e)}function T(t,r,n,e){return H(F(r),t,n,e)}function _(t,r,n,e){return H(function(t,r){for(var n,e,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=t.charCodeAt(u),e=n>>8,i=n%256,o.push(i),o.push(e);return o}(r,t.length-n),t,n,e)}function R(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function B(t,r,n){n=Math.min(t.length,n);for(var e=[],i=r;i<n;){var o,u,f,a,s=t[i],h=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=n)switch(c){case 1:s<128&&(h=s);break;case 2:128==(192&(o=t[i+1]))&&(a=(31&s)<<6|63&o)>127&&(h=a);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(a=(15&s)<<12|(63&o)<<6|63&u)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(a=(15&s)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&a<1114112&&(h=a)}null===h?(h=65533,c=1):h>65535&&(h-=65536,e.push(h>>>10&1023|55296),h=56320|1023&h),e.push(h),i+=c}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);var n="",e=0;for(;e<r;)n+=String.fromCharCode.apply(String,t.slice(e,e+=4096));return n}(e)}r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),r.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,r,n){return s(null,t,r,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,r,n){return function(t,r,n,e){return h(r),r<=0?f(t,r):void 0!==n?"string"==typeof e?f(t,r).fill(n,e):f(t,r).fill(n):f(t,r)}(null,t,r,n)},a.allocUnsafe=function(t){return c(null,t)},a.allocUnsafeSlow=function(t){return c(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,r){if(!a.isBuffer(t)||!a.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,e=r.length,i=0,o=Math.min(n,e);i<o;++i)if(t[i]!==r[i]){n=t[i],e=r[i];break}return n<e?-1:e<n?1:0},a.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}},a.concat=function(t,r){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var n;if(void 0===r)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var e=a.allocUnsafe(r),i=0;for(n=0;n<t.length;++n){var u=t[n];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(e,i),i+=u.length}return e},a.byteLength=y,a.prototype._isBuffer=!0,a.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 r=0;r<t;r+=2)d(this,r,r+1);return this},a.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 r=0;r<t;r+=4)d(this,r,r+3),d(this,r+1,r+2);return this},a.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 r=0;r<t;r+=8)d(this,r,r+7),d(this,r+1,r+6),d(this,r+2,r+5),d(this,r+3,r+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?B(this,0,t):g.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",n=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,r,n,e,i){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===e&&(e=0),void 0===i&&(i=this.length),r<0||n>t.length||e<0||i>this.length)throw new RangeError("out of range index");if(e>=i&&r>=n)return 0;if(e>=i)return-1;if(r>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(e>>>=0),u=(n>>>=0)-(r>>>=0),f=Math.min(o,u),s=this.slice(e,i),h=t.slice(r,n),c=0;c<f;++c)if(s[c]!==h[c]){o=s[c],u=h[c];break}return o<u?-1:u<o?1:0},a.prototype.includes=function(t,r,n){return-1!==this.indexOf(t,r,n)},a.prototype.indexOf=function(t,r,n){return w(this,t,r,n,!0)},a.prototype.lastIndexOf=function(t,r,n){return w(this,t,r,n,!1)},a.prototype.write=function(t,r,n,e){if(void 0===r)e="utf8",n=this.length,r=0;else if(void 0===n&&"string"==typeof r)e=r,n=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(n)?(n|=0,void 0===e&&(e="utf8")):(e=n,n=void 0)}var i=this.length-r;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");for(var o=!1;;)switch(e){case"hex":return A(this,t,r,n);case"utf8":case"utf-8":return v(this,t,r,n);case"ascii":return m(this,t,r,n);case"latin1":case"binary":return E(this,t,r,n);case"base64":return T(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(t,r,n){var e="";n=Math.min(t.length,n);for(var i=r;i<n;++i)e+=String.fromCharCode(127&t[i]);return e}function U(t,r,n){var e="";n=Math.min(t.length,n);for(var i=r;i<n;++i)e+=String.fromCharCode(t[i]);return e}function S(t,r,n){var e=t.length;(!r||r<0)&&(r=0),(!n||n<0||n>e)&&(n=e);for(var i="",o=r;o<n;++o)i+=N(t[o]);return i}function x(t,r,n){for(var e=t.slice(r,n),i="",o=0;o<e.length;o+=2)i+=String.fromCharCode(e[o]+256*e[o+1]);return i}function I(t,r,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>n)throw new RangeError("Trying to access beyond buffer length")}function Y(t,r,n,e,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(n+e>t.length)throw new RangeError("Index out of range")}function O(t,r,n,e){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(r&255<<8*(e?i:1-i))>>>8*(e?i:1-i)}function L(t,r,n,e){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=r>>>8*(e?i:3-i)&255}function M(t,r,n,e,i,o){if(n+e>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(t,r,n,e,o){return o||M(t,0,n,4),i.write(t,r,n,e,23,4),n+4}function j(t,r,n,e,o){return o||M(t,0,n,8),i.write(t,r,n,e,52,8),n+8}a.prototype.slice=function(t,r){var n,e=this.length;if((t=~~t)<0?(t+=e)<0&&(t=0):t>e&&(t=e),(r=void 0===r?e:~~r)<0?(r+=e)<0&&(r=0):r>e&&(r=e),r<t&&(r=t),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,r)).__proto__=a.prototype;else{var i=r-t;n=new a(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},a.prototype.readUIntLE=function(t,r,n){t|=0,r|=0,n||I(t,r,this.length);for(var e=this[t],i=1,o=0;++o<r&&(i*=256);)e+=this[t+o]*i;return e},a.prototype.readUIntBE=function(t,r,n){t|=0,r|=0,n||I(t,r,this.length);for(var e=this[t+--r],i=1;r>0&&(i*=256);)e+=this[t+--r]*i;return e},a.prototype.readUInt8=function(t,r){return r||I(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,r){return r||I(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,r){return r||I(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,r){return r||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,r){return r||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,r,n){t|=0,r|=0,n||I(t,r,this.length);for(var e=this[t],i=1,o=0;++o<r&&(i*=256);)e+=this[t+o]*i;return e>=(i*=128)&&(e-=Math.pow(2,8*r)),e},a.prototype.readIntBE=function(t,r,n){t|=0,r|=0,n||I(t,r,this.length);for(var e=r,i=1,o=this[t+--e];e>0&&(i*=256);)o+=this[t+--e]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},a.prototype.readInt8=function(t,r){return r||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,r){r||I(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,r){r||I(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,r){return r||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,r){return r||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,r){return r||I(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,r){return r||I(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,r){return r||I(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,r){return r||I(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,r,n,e){(t=+t,r|=0,n|=0,e)||Y(this,t,r,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[r]=255&t;++o<n&&(i*=256);)this[r+o]=t/i&255;return r+n},a.prototype.writeUIntBE=function(t,r,n,e){(t=+t,r|=0,n|=0,e)||Y(this,t,r,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+n},a.prototype.writeUInt8=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},a.prototype.writeUInt16LE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},a.prototype.writeUInt16BE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},a.prototype.writeUInt32LE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):L(this,t,r,!0),r+4},a.prototype.writeUInt32BE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},a.prototype.writeIntLE=function(t,r,n,e){if(t=+t,r|=0,!e){var i=Math.pow(2,8*n-1);Y(this,t,r,n,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<n&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+n},a.prototype.writeIntBE=function(t,r,n,e){if(t=+t,r|=0,!e){var i=Math.pow(2,8*n-1);Y(this,t,r,n,i-1,-i)}var o=n-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+n},a.prototype.writeInt8=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},a.prototype.writeInt16LE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},a.prototype.writeInt16BE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},a.prototype.writeInt32LE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):L(this,t,r,!0),r+4},a.prototype.writeInt32BE=function(t,r,n){return t=+t,r|=0,n||Y(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},a.prototype.writeFloatLE=function(t,r,n){return C(this,t,r,!0,n)},a.prototype.writeFloatBE=function(t,r,n){return C(this,t,r,!1,n)},a.prototype.writeDoubleLE=function(t,r,n){return j(this,t,r,!0,n)},a.prototype.writeDoubleBE=function(t,r,n){return j(this,t,r,!1,n)},a.prototype.copy=function(t,r,n,e){if(n||(n=0),e||0===e||(e=this.length),r>=t.length&&(r=t.length),r||(r=0),e>0&&e<n&&(e=n),e===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("sourceStart out of bounds");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),t.length-r<e-n&&(e=t.length-r+n);var i,o=e-n;if(this===t&&n<r&&r<e)for(i=o-1;i>=0;--i)t[i+r]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),r);return o},a.prototype.fill=function(t,r,n,e){if("string"==typeof t){if("string"==typeof r?(e=r,r=0,n=this.length):"string"==typeof n&&(e=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==e&&"string"!=typeof e)throw new TypeError("encoding must be a string");if("string"==typeof e&&!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e)}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 o;if(r>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=r;o<n;++o)this[o]=t;else{var u=a.isBuffer(t)?t:k(new a(t,e).toString()),f=u.length;for(o=0;o<n-r;++o)this[o+r]=u[o%f]}return this};var D=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function k(t,r){var n;r=r||1/0;for(var e=t.length,i=null,o=[],u=0;u<e;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!i){if(n>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===e){(r-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(r-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((r-=1)<0)break;o.push(n)}else if(n<2048){if((r-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((r-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function F(t){return e.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,r,n,e){for(var i=0;i<e&&!(i+n>=r.length||i>=t.length);++i)r[i+n]=t[i];return i}}).call(this,n(3))},function(t,r){t.exports=i,i.strict=o,i.loose=u;var n=Object.prototype.toString,e={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(t){return o(t)||u(t)}function o(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function u(t){return e[n.call(t)]}},function(t,r,n){"use strict";(function(t){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});const i=e(n(1)),o=e(n(7));function u(t){return new Uint8Array(t)}function f(t,r=!1){const n=t.toString("hex");return r?M(n):n}function a(t){return t.toString("utf8")}function s(t){return t.readUIntBE(0,t.length)}function h(t){return o.default(t)}function c(t,r=!1){return f(h(t),r)}function l(t){return a(h(t))}function p(t){return s(h(t))}function y(t){return Array.from(t).map(v).join("")}function g(r){return t.from(L(r),"hex")}function d(t){return u(g(t))}function w(t){return y(d(t))}function b(r){return t.from(r,"utf8")}function A(t){return u(b(t))}function v(t){return Y((t>>>0).toString(2))}function m(t){return h(E(t))}function E(t){return new Uint8Array(x(t).map(t=>parseInt(t,2)))}function T(t,r){return c(E(t),r)}function _(t){return!("string"!=typeof t||!new RegExp(/^[01]+$/).test(t))&&t.length%8==0}function R(t,r){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!r||t.length===2+2*r)}function B(r){return t.isBuffer(r)}function P(t){return i.default.strict(t)&&!B(t)}function U(t){return!P(t)&&!B(t)&&void 0!==t.byteLength}function S(t,r=8){const n=t%r;return n?(t-n)/r*r+r:t}function x(t,r=8){const n=Y(t).match(new RegExp(`.{${r}}`,"gi"));return Array.from(n||[])}function I(t){return x(t).map(C).join("")}function Y(t,r=8,n="0"){return O(t,S(t.length,r),n)}function O(t,r,n="0"){return j(t,r,!0,n)}function L(t){return t.replace(/^0x/,"")}function M(t){return t.startsWith("0x")?t:"0x"+t}function C(t){return t.split("").reverse().join("")}function j(t,r,n,e="0"){const i=r-t.length;let o=t;if(i>0){const r=e.repeat(i);o=n?r+t:t+r}return o}r.bufferToArray=u,r.bufferToHex=f,r.bufferToUtf8=a,r.bufferToNumber=s,r.bufferToBinary=function(t){return y(u(t))},r.arrayToBuffer=h,r.arrayToHex=c,r.arrayToUtf8=l,r.arrayToNumber=p,r.arrayToBinary=y,r.hexToBuffer=g,r.hexToArray=d,r.hexToUtf8=function(t){return a(g(t))},r.hexToNumber=function(t){return p(d(t))},r.hexToBinary=w,r.utf8ToBuffer=b,r.utf8ToArray=A,r.utf8ToHex=function(t,r=!1){return f(b(t),r)},r.utf8ToNumber=function(t){const r=parseInt(t,10);return function(t,r){if(!t)throw new Error(r)}(!function(t){return void 0===t}(r),"Number can only safely store up to 53 bits"),r},r.utf8ToBinary=function(t){return y(A(t))},r.numberToBuffer=function(t){return m(v(t))},r.numberToArray=function(t){return E(v(t))},r.numberToHex=function(t,r){return T(v(t),r)},r.numberToUtf8=function(t){return""+t},r.numberToBinary=v,r.binaryToBuffer=m,r.binaryToArray=E,r.binaryToHex=T,r.binaryToUtf8=function(t){return l(E(t))},r.binaryToNumber=function(t){return p(E(t))},r.isBinaryString=_,r.isHexString=R,r.isBuffer=B,r.isTypedArray=P,r.isArrayBuffer=U,r.getType=function(t){return B(t)?"buffer":P(t)?"typed-array":U(t)?"array-buffer":Array.isArray(t)?"array":typeof t},r.getEncoding=function(t){return _(t)?"binary":R(t)?"hex":"utf8"},r.concatBuffers=function(...r){return t.concat(r)},r.concatArrays=function(...t){let r=[];return t.forEach(t=>r=r.concat(Array.from(t))),new Uint8Array([...r])},r.trimLeft=function(t,r){const n=t.length-r;return n>0&&(t=t.slice(n)),t},r.trimRight=function(t,r){return t.slice(0,r)},r.calcByteLength=S,r.splitBytes=x,r.swapBytes=I,r.swapHex=function(t){return T(I(w(t)))},r.sanitizeBytes=Y,r.padLeft=O,r.padRight=function(t,r,n="0"){return j(t,r,!1,n)},r.removeHexPrefix=L,r.addHexPrefix=M,r.sanitizeHex=function(t){return(t=Y(t=L(t),2))&&(t=M(t)),t},r.removeHexLeadingZeros=function(t){const r=t.startsWith("0x");return t=(t=L(t)).startsWith("0")?t.substring(1):t,r?M(t):t}}).call(this,n(0).Buffer)},function(t,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,r,n){"use strict";r.byteLength=function(t){var r=s(t),n=r[0],e=r[1];return 3*(n+e)/4-e},r.toByteArray=function(t){var r,n,e=s(t),u=e[0],f=e[1],a=new o(function(t,r,n){return 3*(r+n)/4-n}(0,u,f)),h=0,c=f>0?u-4:u;for(n=0;n<c;n+=4)r=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],a[h++]=r>>16&255,a[h++]=r>>8&255,a[h++]=255&r;2===f&&(r=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,a[h++]=255&r);1===f&&(r=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,a[h++]=r>>8&255,a[h++]=255&r);return a},r.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],u=0,f=n-i;u<f;u+=16383)o.push(h(t,u,u+16383>f?f:u+16383));1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"="));return o.join("")};for(var e=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,a=u.length;f<a;++f)e[f]=u[f],i[u.charCodeAt(f)]=f;function s(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=r),[n,n===r?0:4-n%4]}function h(t,r,n){for(var i,o,u=[],f=r;f<n;f+=3)i=(t[f]<<16&16711680)+(t[f+1]<<8&65280)+(255&t[f+2]),u.push(e[(o=i)>>18&63]+e[o>>12&63]+e[o>>6&63]+e[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,r){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
r.read=function(t,r,n,e,i){var o,u,f=8*i-e-1,a=(1<<f)-1,s=a>>1,h=-7,c=n?i-1:0,l=n?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-h)-1,p>>=-h,h+=f;h>0;o=256*o+t[r+c],c+=l,h-=8);for(u=o&(1<<-h)-1,o>>=-h,h+=e;h>0;u=256*u+t[r+c],c+=l,h-=8);if(0===o)o=1-s;else{if(o===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,e),o-=s}return(p?-1:1)*u*Math.pow(2,o-e)},r.write=function(t,r,n,e,i,o){var u,f,a,s=8*o-i-1,h=(1<<s)-1,c=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=e?0:o-1,y=e?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,u=h):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),(r+=u+c>=1?l/a:l*Math.pow(2,1-c))*a>=2&&(u++,a/=2),u+c>=h?(f=0,u=h):u+c>=1?(f=(r*a-1)*Math.pow(2,i),u+=c):(f=r*Math.pow(2,c-1)*Math.pow(2,i),u=0));i>=8;t[n+p]=255&f,p+=y,f/=256,i-=8);for(u=u<<i|f,s+=i;s>0;t[n+p]=255&u,p+=y,u/=256,s-=8);t[n+p-y]|=128*g}},function(t,r){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,r,n){(function(r){var e=n(1).strict;t.exports=function(t){if(e(t)){var n=r.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(n=n.slice(t.byteOffset,t.byteOffset+t.byteLength)),n}return r.from(t)}}).call(this,n(0).Buffer)}])}));