UNPKG

gitlab

Version:

Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.

16 lines (14 loc) 148 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).gitlab={})}(this,(function(e){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,r)};function r(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{a(n.next(e))}catch(e){s(e)}}function u(e){try{a(n.throw(e))}catch(e){s(e)}}function a(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(i,u)}a((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function a(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}; /*! MIT License © Sindre Sorhus */const c={},h=e=>"undefined"!=typeof self&&self&&e in self?self:"undefined"!=typeof window&&window&&e in window?window:void 0!==p&&p&&e in p?p:"undefined"!=typeof globalThis&&globalThis?globalThis:void 0,f=["Headers","Request","Response","ReadableStream","fetch","AbortController","FormData"];for(const e of f)Object.defineProperty(c,e,{get(){const t=h(e),r=t&&t[e];return"function"==typeof r?r.bind(t):r}});const l=e=>null!==e&&"object"==typeof e,d="function"==typeof c.AbortController,m="function"==typeof c.ReadableStream,y="function"==typeof c.FormData,g=(...e)=>{let t={};for(const r of e)if(Array.isArray(r))Array.isArray(t)||(t=[]),t=[...t,...r];else if(l(r))for(let[e,n]of Object.entries(r))l(n)&&Reflect.has(t,e)&&(n=g(t[e],n)),t={...t,[e]:n};return t},v=["get","post","put","patch","head","delete"],b={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},w=[413,429,503],R=Symbol("stop");class I extends Error{constructor(e){super(e.statusText),this.name="HTTPError",this.response=e}}class C extends Error{constructor(){super("Request timed out"),this.name="TimeoutError"}}const _=e=>new Promise(t=>setTimeout(t,e)),j=(e,t,r)=>new Promise((n,o)=>{const s=setTimeout(()=>{r&&r.abort(),o(new C)},t);e.then(n).catch(o).then(()=>{clearTimeout(s)})}),U=e=>v.includes(e)?e.toUpperCase():e,k={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:w},E=(e={})=>{if("number"==typeof e)return{...k,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...k,...e,afterStatusCodes:w}},S=2147483647;class A{constructor(e,t={}){if(this._retryCount=0,this._input=e,this._options={credentials:this._input.credentials||"same-origin",...t,hooks:g({beforeRequest:[],beforeRetry:[],afterResponse:[]},t.hooks),method:U(t.method||this._input.method),prefixUrl:String(t.prefixUrl||""),retry:E(t.retry),throwHttpErrors:!1!==t.throwHttpErrors,timeout:void 0===t.timeout?1e4:t.timeout},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof c.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(d&&(this.abortController=new c.AbortController,this._options.signal&&(this._options.signal.addEventListener("abort",()=>{this.abortController.abort()}),this._options.signal=this.abortController.signal)),this.request=new c.Request(this._input,this._options),this._options.searchParams){const e=new URL(this.request.url);e.search=new URLSearchParams(this._options.searchParams),this.request=new c.Request(e,this.request)}if((y&&this._options.body instanceof c.FormData||this._options.body instanceof URLSearchParams)&&this.request.headers.has("content-type"))throw new Error(`The \`content-type\` header cannot be used with a ${this._options.body.constructor.name} body. It will be set automatically.`);this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type","application/json"),this.request=new c.Request(this.request,{body:this._options.body}));const r=async()=>{if(this._options.timeout>S)throw new RangeError(`The \`timeout\` option cannot be greater than ${S}`);await _(1);let e=await this._fetch();for(const t of this._options.hooks.afterResponse){const r=await t(this.request,this._options,e.clone());r instanceof c.Response&&(e=r)}if(!e.ok&&this._options.throwHttpErrors)throw new I(e);if(this._options.onDownloadProgress){if("function"!=typeof this._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!m)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return this._stream(e.clone(),this._options.onDownloadProgress)}return e},n=this._options.retry.methods.includes(this.request.method.toLowerCase())?this._retry(r):r();for(const[e,t]of Object.entries(b))n[e]=async()=>{this.request.headers.set("accept",this.request.headers.get("accept")||t);const r=(await n).clone();return"json"===e&&204===r.status?"":r[e]()};return n}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(e instanceof C)){if(e instanceof I){if(!this._options.retry.statusCodes.includes(e.response.status))return 0;const t=e.response.headers.get("Retry-After");if(t&&this._options.retry.afterStatusCodes.includes(e.response.status)){let e=Number(t);return Number.isNaN(e)?e=Date.parse(t)-Date.now():e*=1e3,void 0!==this._options.retry.maxRetryAfter&&e>this._options.retry.maxRetryAfter?0:e}if(413===e.response.status)return 0}return.3*2**(this._retryCount-1)*1e3}return 0}async _retry(e){try{return await e()}catch(t){const r=Math.min(this._calculateRetryDelay(t),S);if(0!==r&&this._retryCount>0){await _(r);for(const e of this._options.hooks.beforeRetry){if(await e(this.request,this._options,t,this._retryCount)===R)return}return this._retry(e)}if(this._options.throwHttpErrors)throw t}}async _fetch(){for(const e of this._options.hooks.beforeRequest){const t=await e(this.request,this._options);if(t instanceof Request){this.request=t;break}if(t instanceof Response)return t}return!1===this._options.timeout?c.fetch(this.request):j(c.fetch(this.request),this._options.timeout,this.abortController)}_stream(e,t){const r=Number(e.headers.get("content-length"))||0;let n=0;return new c.Response(new c.ReadableStream({start(o){const s=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array),async function e(){const{done:i,value:u}=await s.read();if(i)o.close();else{if(t){n+=u.byteLength,t({percent:0===r?0:n/r,transferredBytes:n,totalBytes:r},u)}o.enqueue(u),e()}}()}}))}}const P=(...e)=>{for(const t of e)if((!l(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The `options` argument must be an object");return g({},...e)},T=e=>{const t=(t,r)=>new A(t,P(e,r));for(const r of v)t[r]=(t,n)=>new A(t,P(e,n,{method:r}));return t.create=e=>T(P(e)),t.extend=t=>T(P(e,t)),t.stop=R,t};var x=T(),L="object"==typeof self?self.FormData:window.FormData,q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function M(e,t){return e(t={exports:{}},t.exports),t.exports}var B,O=M((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function n(e){return e>=97&&e<=122}function o(e){return e>=65&&e<=90}function s(e){return e>=48&&e<=57}function i(e){return n(e)?e-32:e}function u(e){return e+32}function a(e){return e&&"object"==(void 0===e?"undefined":r(e))&&!(e instanceof Date)&&!(e instanceof Function)}function p(e,t,r){var n=void 0;if(e instanceof Array)n=[];else{if(void 0!==e.prototype)return e;n={}}for(var o in e){var s=e[o];"string"==typeof o&&(o=t(o,r&&r.separator)),a(s)?n[o]=p(s,t,r):n[o]=s}return n}function c(e,t,r){for(var n=Object.keys(e),o=0;o<n.length;++o){var s=n[o],i=e[s],u=t(s,r&&r.separator);u!==s&&delete e[s],a(i)?e[u]=p(i,t,r):e[u]=i}return e}function h(e,t){return function(e,t){var r=e.charCodeAt(0);if(s(r)||o(r)||r==t)return e;var n=[],a=!1;o(r)?(a=!0,n.push(u(r))):n.push(r);for(var p=e.length,c=1;c<p;++c){var h=e.charCodeAt(c);if(h===t){if(a=!0,h=e.charCodeAt(++c),isNaN(h))return e;n.push(i(h))}else n.push(h)}return a?String.fromCharCode.apply(void 0,n):e}(e,t&&t.charCodeAt(0)||95)}function f(e,t){return function(e,t){if(!n(e.charCodeAt(0)))return e;for(var r=e.length,s=!1,i=[],a=0;a<r;++a){var p=e.charCodeAt(a);o(p)?(i.push(t),i.push(u(p)),s=!0):i.push(p)}return s?String.fromCharCode.apply(void 0,i):e}(e,t&&t.charCodeAt(0)||95)}function l(e,t){return function(e,t){var r=e.charCodeAt(0);if(s(r)||r==t)return e;for(var o=e.length,u=!1,a=[],p=0;p<o;++p){var c=e.charCodeAt(p);if(c===t){if(u=!0,c=e.charCodeAt(++p),isNaN(c))return e;a.push(i(c))}else 0===p&&n(c)?(u=!0,a.push(c-32)):a.push(c)}return u?String.fromCharCode.apply(void 0,a):e}(e,t&&t.charCodeAt(0)||95)}function d(e,t){return function(e,t){if(!o(e.charCodeAt(0)))return e;for(var r=e.length,n=!1,s=[],i=0;i<r;++i){var a=e.charCodeAt(i);o(a)?(i>0&&s.push(t),s.push(u(a)),n=!0):s.push(a)}return n?String.fromCharCode.apply(void 0,s):e}(e,t&&t.charCodeAt(0)||95)}t.camelize=h,t.decamelize=f,t.pascalize=l,t.depascalize=d,t.camelizeKeys=function(e,t){return t=t||{},a(e)?t.inPlace?c(e,h,t):p(e,h,t):e},t.decamelizeKeys=function(e,t){return t=t||{},a(e)?t.inPlace?c(e,f,t):p(e,f,t):e},t.pascalizeKeys=function(e,t){return t=t||{},a(e)?t.inPlace?c(e,l,t):p(e,l,t):e},t.depascalizeKeys=function(e,t){return t=t||{},a(e)?t.inPlace?c(e,d,t):p(e,d,t):e}}));(B=O)&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")&&B.default;O.camelize,O.decamelize,O.pascalize,O.depascalize;var D=O.camelizeKeys,N=O.decamelizeKeys,z=(O.pascalizeKeys,O.depascalizeKeys,e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`));function G(e,t){return t.encode?t.strict?z(e):encodeURIComponent(e):e}var F=(e,t)=>{if(!e)return"";const r=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const o=r.length;return void 0===n||e.skipNull&&null===n?r:null===n?[...r,[G(t,e),"[",o,"]"].join("")]:[...r,[G(t,e),"[",G(o,e),"]=",G(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n?r:null===n?[...r,[G(t,e),"[]"].join("")]:[...r,[G(t,e),"[]=",G(n,e)].join("")];case"comma":return t=>(r,n)=>null==n||0===n.length?r:0===r.length?[[G(t,e),"=",G(n,e)].join("")]:[[r,G(n,e)].join(",")];default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n?r:null===n?[...r,G(t,e)]:[...r,[G(t,e),"=",G(n,e)].join("")]}}(t=Object.assign({encode:!0,strict:!0,arrayFormat:"none"},t)),n=Object.assign({},e);if(t.skipNull)for(const e of Object.keys(n))void 0!==n[e]&&null!==n[e]||delete n[e];const o=Object.keys(n);return!1!==t.sort&&o.sort(t.sort),o.map(n=>{const o=e[n];return void 0===o?"":null===o?G(n,t):Array.isArray(o)?o.reduce(r(n),[]).join("&"):G(n,t)+"="+G(o,t)}).filter(e=>e.length>0).join("&")},Y=[],H=[],W="undefined"!=typeof Uint8Array?Uint8Array:Array,K=!1;function V(){K=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)Y[t]=e[t],H[e.charCodeAt(t)]=t;H["-".charCodeAt(0)]=62,H["_".charCodeAt(0)]=63}function J(e,t,r){for(var n,o,s=[],i=t;i<r;i+=3)n=(e[i]<<16)+(e[i+1]<<8)+e[i+2],s.push(Y[(o=n)>>18&63]+Y[o>>12&63]+Y[o>>6&63]+Y[63&o]);return s.join("")}function X(e){var t;K||V();for(var r=e.length,n=r%3,o="",s=[],i=0,u=r-n;i<u;i+=16383)s.push(J(e,i,i+16383>u?u:i+16383));return 1===n?(t=e[r-1],o+=Y[t>>2],o+=Y[t<<4&63],o+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],o+=Y[t>>10],o+=Y[t>>4&63],o+=Y[t<<2&63],o+="="),s.push(o),s.join("")}function $(e,t,r,n,o){var s,i,u=8*o-n-1,a=(1<<u)-1,p=a>>1,c=-7,h=r?o-1:0,f=r?-1:1,l=e[t+h];for(h+=f,s=l&(1<<-c)-1,l>>=-c,c+=u;c>0;s=256*s+e[t+h],h+=f,c-=8);for(i=s&(1<<-c)-1,s>>=-c,c+=n;c>0;i=256*i+e[t+h],h+=f,c-=8);if(0===s)s=1-p;else{if(s===a)return i?NaN:1/0*(l?-1:1);i+=Math.pow(2,n),s-=p}return(l?-1:1)*i*Math.pow(2,s-n)}function Z(e,t,r,n,o,s){var i,u,a,p=8*s-o-1,c=(1<<p)-1,h=c>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:s-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,i=c):(i=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-i))<1&&(i--,a*=2),(t+=i+h>=1?f/a:f*Math.pow(2,1-h))*a>=2&&(i++,a/=2),i+h>=c?(u=0,i=c):i+h>=1?(u=(t*a-1)*Math.pow(2,o),i+=h):(u=t*Math.pow(2,h-1)*Math.pow(2,o),i=0));o>=8;e[r+l]=255&u,l+=d,u/=256,o-=8);for(i=i<<o|u,p+=o;p>0;e[r+l]=255&i,l+=d,i/=256,p-=8);e[r+l-d]|=128*m}var Q={}.toString,ee=Array.isArray||function(e){return"[object Array]"==Q.call(e)};function te(){return ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function re(e,t){if(te()<t)throw new RangeError("Invalid typed array length");return ne.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ne.prototype:(null===e&&(e=new ne(t)),e.length=t),e}function ne(e,t,r){if(!(ne.TYPED_ARRAY_SUPPORT||this instanceof ne))return new ne(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return ie(this,e)}return oe(this,e,t,r)}function oe(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);ne.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ne.prototype:e=ue(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!ne.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|ce(t,r),o=(e=re(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(pe(t)){var r=0|ae(t.length);return 0===(e=re(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?re(e,0):ue(e,t);if("Buffer"===t.type&&ee(t.data))return ue(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function se(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function ie(e,t){if(se(t),e=re(e,t<0?0:0|ae(t)),!ne.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function ue(e,t){var r=t.length<0?0:0|ae(t.length);e=re(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function ae(e){if(e>=te())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+te().toString(16)+" bytes");return 0|e}function pe(e){return!(null==e||!e._isBuffer)}function ce(e,t){if(pe(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Oe(e).length;default:if(n)return Be(e).length;t=(""+t).toLowerCase(),n=!0}}function he(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ue(this,t,r);case"utf8":case"utf-8":return Ie(this,t,r);case"ascii":return _e(this,t,r);case"latin1":case"binary":return je(this,t,r);case"base64":return Re(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ke(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function fe(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function le(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=ne.from(t,n)),pe(t))return 0===t.length?-1:de(e,t,r,n,o);if("number"==typeof t)return t&=255,ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):de(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function de(e,t,r,n,o){var s,i=1,u=e.length,a=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;i=2,u/=2,a/=2,r/=2}function p(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){var c=-1;for(s=r;s<u;s++)if(p(e,s)===p(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===a)return c*i}else-1!==c&&(s-=s-c),c=-1}else for(r+a>u&&(r=u-a),s=r;s>=0;s--){for(var h=!0,f=0;f<a;f++)if(p(e,s+f)!==p(t,f)){h=!1;break}if(h)return s}return-1}function me(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var i=0;i<n;++i){var u=parseInt(t.substr(2*i,2),16);if(isNaN(u))return i;e[r+i]=u}return i}function ye(e,t,r,n){return De(Be(t,e.length-r),e,r,n)}function ge(e,t,r,n){return De(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function ve(e,t,r,n){return ge(e,t,r,n)}function be(e,t,r,n){return De(Oe(t),e,r,n)}function we(e,t,r,n){return De(function(e,t){for(var r,n,o,s=[],i=0;i<e.length&&!((t-=2)<0);++i)r=e.charCodeAt(i),n=r>>8,o=r%256,s.push(o),s.push(n);return s}(t,e.length-r),e,r,n)}function Re(e,t,r){return 0===t&&r===e.length?X(e):X(e.slice(t,r))}function Ie(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var s,i,u,a,p=e[o],c=null,h=p>239?4:p>223?3:p>191?2:1;if(o+h<=r)switch(h){case 1:p<128&&(c=p);break;case 2:128==(192&(s=e[o+1]))&&(a=(31&p)<<6|63&s)>127&&(c=a);break;case 3:s=e[o+1],i=e[o+2],128==(192&s)&&128==(192&i)&&(a=(15&p)<<12|(63&s)<<6|63&i)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:s=e[o+1],i=e[o+2],u=e[o+3],128==(192&s)&&128==(192&i)&&128==(192&u)&&(a=(15&p)<<18|(63&s)<<12|(63&i)<<6|63&u)>65535&&a<1114112&&(c=a)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(e){var t=e.length;if(t<=Ce)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ce));return r}(n)}ne.TYPED_ARRAY_SUPPORT=void 0===p.TYPED_ARRAY_SUPPORT||p.TYPED_ARRAY_SUPPORT,ne.poolSize=8192,ne._augment=function(e){return e.__proto__=ne.prototype,e},ne.from=function(e,t,r){return oe(null,e,t,r)},ne.TYPED_ARRAY_SUPPORT&&(ne.prototype.__proto__=Uint8Array.prototype,ne.__proto__=Uint8Array),ne.alloc=function(e,t,r){return function(e,t,r,n){return se(t),t<=0?re(e,t):void 0!==r?"string"==typeof n?re(e,t).fill(r,n):re(e,t).fill(r):re(e,t)}(null,e,t,r)},ne.allocUnsafe=function(e){return ie(null,e)},ne.allocUnsafeSlow=function(e){return ie(null,e)},ne.isBuffer=Ne,ne.compare=function(e,t){if(!pe(e)||!pe(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o<s;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},ne.isEncoding=function(e){switch(String(e).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}},ne.concat=function(e,t){if(!ee(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ne.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=ne.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!pe(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},ne.byteLength=ce,ne.prototype._isBuffer=!0,ne.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)fe(this,t,t+1);return this},ne.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)fe(this,t,t+3),fe(this,t+1,t+2);return this},ne.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)fe(this,t,t+7),fe(this,t+1,t+6),fe(this,t+2,t+5),fe(this,t+3,t+4);return this},ne.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Ie(this,0,e):he.apply(this,arguments)},ne.prototype.equals=function(e){if(!pe(e))throw new TypeError("Argument must be a Buffer");return this===e||0===ne.compare(this,e)},ne.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ne.prototype.compare=function(e,t,r,n,o){if(!pe(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(n>>>=0),i=(r>>>=0)-(t>>>=0),u=Math.min(s,i),a=this.slice(n,o),p=e.slice(t,r),c=0;c<u;++c)if(a[c]!==p[c]){s=a[c],i=p[c];break}return s<i?-1:i<s?1:0},ne.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},ne.prototype.indexOf=function(e,t,r){return le(this,e,t,r,!0)},ne.prototype.lastIndexOf=function(e,t,r){return le(this,e,t,r,!1)},ne.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return me(this,e,t,r);case"utf8":case"utf-8":return ye(this,e,t,r);case"ascii":return ge(this,e,t,r);case"latin1":case"binary":return ve(this,e,t,r);case"base64":return be(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return we(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},ne.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ce=4096;function _e(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function je(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function Ue(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",s=t;s<r;++s)o+=Me(e[s]);return o}function ke(e,t,r){for(var n=e.slice(t,r),o="",s=0;s<n.length;s+=2)o+=String.fromCharCode(n[s]+256*n[s+1]);return o}function Ee(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function Se(e,t,r,n,o,s){if(!pe(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function Ae(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,s=Math.min(e.length-r,2);o<s;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function Pe(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,s=Math.min(e.length-r,4);o<s;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function Te(e,t,r,n,o,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function xe(e,t,r,n,o){return o||Te(e,0,r,4),Z(e,t,r,n,23,4),r+4}function Le(e,t,r,n,o){return o||Te(e,0,r,8),Z(e,t,r,n,52,8),r+8}ne.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),ne.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=ne.prototype;else{var o=t-e;r=new ne(o,void 0);for(var s=0;s<o;++s)r[s]=this[s+e]}return r},ne.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||Ee(e,t,this.length);for(var n=this[e],o=1,s=0;++s<t&&(o*=256);)n+=this[e+s]*o;return n},ne.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||Ee(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},ne.prototype.readUInt8=function(e,t){return t||Ee(e,1,this.length),this[e]},ne.prototype.readUInt16LE=function(e,t){return t||Ee(e,2,this.length),this[e]|this[e+1]<<8},ne.prototype.readUInt16BE=function(e,t){return t||Ee(e,2,this.length),this[e]<<8|this[e+1]},ne.prototype.readUInt32LE=function(e,t){return t||Ee(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ne.prototype.readUInt32BE=function(e,t){return t||Ee(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ne.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Ee(e,t,this.length);for(var n=this[e],o=1,s=0;++s<t&&(o*=256);)n+=this[e+s]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},ne.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Ee(e,t,this.length);for(var n=t,o=1,s=this[e+--n];n>0&&(o*=256);)s+=this[e+--n]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*t)),s},ne.prototype.readInt8=function(e,t){return t||Ee(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ne.prototype.readInt16LE=function(e,t){t||Ee(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ne.prototype.readInt16BE=function(e,t){t||Ee(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ne.prototype.readInt32LE=function(e,t){return t||Ee(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ne.prototype.readInt32BE=function(e,t){return t||Ee(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ne.prototype.readFloatLE=function(e,t){return t||Ee(e,4,this.length),$(this,e,!0,23,4)},ne.prototype.readFloatBE=function(e,t){return t||Ee(e,4,this.length),$(this,e,!1,23,4)},ne.prototype.readDoubleLE=function(e,t){return t||Ee(e,8,this.length),$(this,e,!0,52,8)},ne.prototype.readDoubleBE=function(e,t){return t||Ee(e,8,this.length),$(this,e,!1,52,8)},ne.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Se(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,s=0;for(this[t]=255&e;++s<r&&(o*=256);)this[t+s]=e/o&255;return t+r},ne.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Se(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,s=1;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+r},ne.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,1,255,0),ne.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ne.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,2,65535,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ae(this,e,t,!0),t+2},ne.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,2,65535,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ae(this,e,t,!1),t+2},ne.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,4,4294967295,0),ne.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Pe(this,e,t,!0),t+4},ne.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,4,4294967295,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Pe(this,e,t,!1),t+4},ne.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);Se(this,e,t,r,o-1,-o)}var s=0,i=1,u=0;for(this[t]=255&e;++s<r&&(i*=256);)e<0&&0===u&&0!==this[t+s-1]&&(u=1),this[t+s]=(e/i>>0)-u&255;return t+r},ne.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);Se(this,e,t,r,o-1,-o)}var s=r-1,i=1,u=0;for(this[t+s]=255&e;--s>=0&&(i*=256);)e<0&&0===u&&0!==this[t+s+1]&&(u=1),this[t+s]=(e/i>>0)-u&255;return t+r},ne.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,1,127,-128),ne.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ne.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,2,32767,-32768),ne.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ae(this,e,t,!0),t+2},ne.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,2,32767,-32768),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ae(this,e,t,!1),t+2},ne.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,4,2147483647,-2147483648),ne.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Pe(this,e,t,!0),t+4},ne.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Se(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Pe(this,e,t,!1),t+4},ne.prototype.writeFloatLE=function(e,t,r){return xe(this,e,t,!0,r)},ne.prototype.writeFloatBE=function(e,t,r){return xe(this,e,t,!1,r)},ne.prototype.writeDoubleLE=function(e,t,r){return Le(this,e,t,!0,r)},ne.prototype.writeDoubleBE=function(e,t,r){return Le(this,e,t,!1,r)},ne.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,s=n-r;if(this===e&&r<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+r];else if(s<1e3||!ne.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},ne.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!ne.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var i=pe(e)?e:Be(new ne(e,n).toString()),u=i.length;for(s=0;s<r-t;++s)this[s+t]=i[s%u]}return this};var qe=/[^+\/0-9A-Za-z-_]/g;function Me(e){return e<16?"0"+e.toString(16):e.toString(16)}function Be(e,t){var r;t=t||1/0;for(var n=e.length,o=null,s=[],i=0;i<n;++i){if((r=e.charCodeAt(i))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function Oe(e){return function(e){var t,r,n,o,s,i;K||V();var u=e.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[u-2]?2:"="===e[u-1]?1:0,i=new W(3*u/4-s),n=s>0?u-4:u;var a=0;for(t=0,r=0;t<n;t+=4,r+=3)o=H[e.charCodeAt(t)]<<18|H[e.charCodeAt(t+1)]<<12|H[e.charCodeAt(t+2)]<<6|H[e.charCodeAt(t+3)],i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=255&o;return 2===s?(o=H[e.charCodeAt(t)]<<2|H[e.charCodeAt(t+1)]>>4,i[a++]=255&o):1===s&&(o=H[e.charCodeAt(t)]<<10|H[e.charCodeAt(t+1)]<<4|H[e.charCodeAt(t+2)]>>2,i[a++]=o>>8&255,i[a++]=255&o),i}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(qe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function De(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function Ne(e){return null!=e&&(!!e._isBuffer||ze(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ze(e.slice(0,0))}(e))}function ze(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Ge(){throw new Error("setTimeout has not been defined")}function Fe(){throw new Error("clearTimeout has not been defined")}var Ye=Ge,He=Fe;function We(e){if(Ye===setTimeout)return setTimeout(e,0);if((Ye===Ge||!Ye)&&setTimeout)return Ye=setTimeout,setTimeout(e,0);try{return Ye(e,0)}catch(t){try{return Ye.call(null,e,0)}catch(t){return Ye.call(this,e,0)}}}"function"==typeof p.setTimeout&&(Ye=setTimeout),"function"==typeof p.clearTimeout&&(He=clearTimeout);var Ke,Ve=[],Je=!1,Xe=-1;function $e(){Je&&Ke&&(Je=!1,Ke.length?Ve=Ke.concat(Ve):Xe=-1,Ve.length&&Ze())}function Ze(){if(!Je){var e=We($e);Je=!0;for(var t=Ve.length;t;){for(Ke=Ve,Ve=[];++Xe<t;)Ke&&Ke[Xe].run();Xe=-1,t=Ve.length}Ke=null,Je=!1,function(e){if(He===clearTimeout)return clearTimeout(e);if((He===Fe||!He)&&clearTimeout)return He=clearTimeout,clearTimeout(e);try{He(e)}catch(t){try{return He.call(null,e)}catch(t){return He.call(this,e)}}}(e)}}function Qe(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Ve.push(new et(e,t)),1!==Ve.length||Je||We(Ze)}function et(e,t){this.fun=e,this.array=t}et.prototype.run=function(){this.fun.apply(null,this.array)};var tt,rt,nt=p.performance||{},ot=(nt.now||nt.mozNow||nt.msNow||nt.oNow||nt.webkitNow,lt(p.fetch)&&lt(p.ReadableStream));function st(e){rt||(rt=new p.XMLHttpRequest).open("GET",p.location.host?"/":"https://example.com");try{return rt.responseType=e,rt.responseType===e}catch(e){return!1}}var it=void 0!==p.ArrayBuffer,ut=it&&lt(p.ArrayBuffer.prototype.slice),at=it&&st("arraybuffer"),pt=!ot&&ut&&st("ms-stream"),ct=!ot&&it&&st("moz-chunked-arraybuffer"),ht=lt(rt.overrideMimeType),ft=lt(p.VBArray);function lt(e){return"function"==typeof e}rt=null;var dt="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},mt=/%[sdj%]/g;function yt(e){if(!Et(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(wt(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,o=n.length,s=String(e).replace(mt,(function(e){if("%%"===e)return"%";if(r>=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),i=n[r];r<o;i=n[++r])kt(i)||!Pt(i)?s+=" "+i:s+=" "+wt(i);return s}function gt(e,t){if(St(p.process))return function(){return gt(e,t).apply(this,arguments)};var r=!1;return function(){return r||(console.error(t),r=!0),e.apply(this,arguments)}}var vt,bt={};function wt(e,t){var r={seen:[],stylize:It};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Ut(t)?r.showHidden=t:t&&function(e,t){if(!t||!Pt(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),St(r.showHidden)&&(r.showHidden=!1),St(r.depth)&&(r.depth=2),St(r.colors)&&(r.colors=!1),St(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Rt),Ct(r,e,r.depth)}function Rt(e,t){var r=wt.styles[t];return r?"["+wt.colors[r][0]+"m"+e+"["+wt.colors[r][1]+"m":e}function It(e,t){return e}function Ct(e,t,r){if(e.customInspect&&t&&Lt(t.inspect)&&t.inspect!==wt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return Et(n)||(n=Ct(e,n,r)),n}var o=function(e,t){if(St(t))return e.stylize("undefined","undefined");if(Et(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(n=t,"number"==typeof n)return e.stylize(""+t,"number");var n;if(Ut(t))return e.stylize(""+t,"boolean");if(kt(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),i=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),xt(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return _t(t);if(0===s.length){if(Lt(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(At(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Tt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(xt(t))return _t(t)}var a,p,c="",h=!1,f=["{","}"];(a=t,Array.isArray(a)&&(h=!0,f=["[","]"]),Lt(t))&&(c=" [Function"+(t.name?": "+t.name:"")+"]");return At(t)&&(c=" "+RegExp.prototype.toString.call(t)),Tt(t)&&(c=" "+Date.prototype.toUTCString.call(t)),xt(t)&&(c=" "+_t(t)),0!==s.length||h&&0!=t.length?r<0?At(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),p=h?function(e,t,r,n,o){for(var s=[],i=0,u=t.length;i<u;++i)Mt(t,String(i))?s.push(jt(e,t,r,n,String(i),!0)):s.push("");return o.forEach((function(o){o.match(/^\d+$/)||s.push(jt(e,t,r,n,o,!0))})),s}(e,t,r,i,s):s.map((function(n){return jt(e,t,r,i,n,h)})),e.seen.pop(),function(e,t,r){if(e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(p,c,f)):f[0]+c+f[1]}function _t(e){return"["+Error.prototype.toString.call(e)+"]"}function jt(e,t,r,n,o,s){var i,u,a;if((a=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?u=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),Mt(n,o)||(i="["+o+"]"),u||(e.seen.indexOf(a.value)<0?(u=kt(r)?Ct(e,a.value,null):Ct(e,a.value,r-1)).indexOf("\n")>-1&&(u=s?u.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+u.split("\n").map((function(e){return" "+e})).join("\n")):u=e.stylize("[Circular]","special")),St(i)){if(s&&o.match(/^\d+$/))return u;(i=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(i=i.substr(1,i.length-2),i=e.stylize(i,"name")):(i=i.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),i=e.stylize(i,"string"))}return i+": "+u}function Ut(e){return"boolean"==typeof e}function kt(e){return null===e}function Et(e){return"string"==typeof e}function St(e){return void 0===e}function At(e){return Pt(e)&&"[object RegExp]"===qt(e)}function Pt(e){return"object"==typeof e&&null!==e}function Tt(e){return Pt(e)&&"[object Date]"===qt(e)}function xt(e){return Pt(e)&&("[object Error]"===qt(e)||e instanceof Error)}function Lt(e){return"function"==typeof e}function qt(e){return Object.prototype.toString.call(e)}function Mt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Bt(){}function Ot(){Ot.init.call(this)}function Dt(e){return void 0===e._maxListeners?Ot.defaultMaxListeners:e._maxListeners}function Nt(e,t,r){if(t)e.call(r);else for(var n=e.length,o=Vt(e,n),s=0;s<n;++s)o[s].call(r)}function zt(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,s=Vt(e,o),i=0;i<o;++i)s[i].call(r,n)}function Gt(e,t,r,n,o){if(t)e.call(r,n,o);else for(var s=e.length,i=Vt(e,s),u=0;u<s;++u)i[u].call(r,n,o)}function Ft(e,t,r,n,o,s){if(t)e.call(r,n,o,s);else for(var i=e.length,u=Vt(e,i),a=0;a<i;++a)u[a].call(r,n,o,s)}function Yt(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,s=Vt(e,o),i=0;i<o;++i)s[i].apply(r,n)}function Ht(e,t,r,n){var o,s,i,u;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]):(s=e._events=new Bt,e._eventsCount=0),i){if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(o=Dt(e))&&o>0&&i.length>o){i.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=i.length,u=a,"function"==typeof console.warn?console.warn(u):console.log(u)}}else i=s[t]=r,++e._eventsCount;return e}function Wt(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function Kt(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Vt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}function Jt(){this.head=null,this.tail=null,this.length=0}wt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},wt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Bt.prototype=Object.create(null),Ot.EventEmitter=Ot,Ot.usingDomains=!1,Ot.prototype.domain=void 0,Ot.prototype._events=void 0,Ot.prototype._maxListeners=void 0,Ot.defaultMaxListeners=10,Ot.init=function(){this.domain=null,Ot.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Bt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ot.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ot.prototype.getMaxListeners=function(){return Dt(this)},Ot.prototype.emit=function(e){var t,r,n,o,s,i,u,a="error"===e;if(i=this._events)a=a&&null==i.error;else if(!a)return!1;if(u=this.domain,a){if(t=arguments[1],!u){if(t instanceof Error)throw t;var p=new Error('Uncaught, unspecified "error" event. ('+t+")");throw p.context=t,p}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t),!1}if(!(r=i[e]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:Nt(r,c,this);break;case 2:zt(r,c,this,arguments[1]);break;case 3:Gt(r,c,this,arguments[1],arguments[2]);break;case 4:Ft(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),s=1;s<n;s++)o[s-1]=arguments[s];Yt(r,c,this,o)}return!0},Ot.prototype.addListener=function(e,t){return Ht(this,e,t,!1)},Ot.prototype.on=Ot.prototype.addListener,Ot.prototype.prependListener=function(e,t){return Ht(this,e,t,!0)},Ot.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Wt(this,e,t)),this},Ot.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Wt(this,e,t)),this},Ot.prototype.removeListener=function(e,t){var r,n,o,s,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Bt:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Bt,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,i||t)}return this},Ot.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Bt,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Bt:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),s=0;s<o.length;++s)"removeListener"!==(n=o[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Bt,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Ot.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Ot.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Kt.call(e,t)},Ot.prototype.listenerCount=Kt,Ot.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]},Jt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Jt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Jt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Jt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Jt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Jt.prototype.concat=function(e){if(0===this.length)return ne.alloc(0);if(1===this.length)return this.head.data;for(var t=ne.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var Xt=ne.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function $t(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Xt(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Qt;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=er;break;default:return void(this.write=Zt)}this.charBuffer=new ne(6),this.charReceived=0,this.charLength=0}function Zt(e){return e.toString(this.encoding)}function Qt(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function er(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}$t.prototype.write=function(e){for(var t="";this.charLength;){var r=e