New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ckb-js-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ckb-js-toolkit - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

2

dist/ckb-js-toolkit.esm.js

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

class t{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class e{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class r{constructor(r){if("string"==typeof r){if(!r.startsWith("0x")||r.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new e(r)}if(r instanceof ArrayBuffer)return new t(r);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(e){const r=new ArrayBuffer(e.length),n=new DataView(r);for(let t=0;t<e.length;t++){const r=e.charCodeAt(t);if(r>255)throw new Error("fromRawString can only accept UTF-8 raw string!");n.setUint8(t,r)}return new t(r)}}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t,e){return t(e={exports:{}},e.exports),e.exports}var o=i((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:n);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,a="ArrayBuffer"in t;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function _(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function g(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=g(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=g(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=_(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[_(t)]},h.prototype.get=function(t){return t=_(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(_(t))},h.prototype.set=function(t,e){this.map[_(t)]=l(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),y.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},v.call(b.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];w.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function D(t,r){return new Promise((function(n,o){var a=new b(t,r);if(a.signal&&a.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}D.polyfill=!0,t.fetch||(t.fetch=D,t.Headers=h,t.Request=b,t.Response=w),e.Headers=h,e.Request=b,e.Response=w,e.fetch=D}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),a=(o.fetch,o.Headers,o.Request,o.Response,i((function(t,e){t.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function s(){return(s=a()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){function r(){return s(t,arguments,i(this).constructor)}if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)})(t)}function _(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var l=function(e){var o=Math.abs,a=Math.max,s=Math.imul,u=Math.clz32;function l(t,e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,l),t>l.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return(r=_(this,i(l).call(this,t))).sign=e,r}return n(l,e),r(l,[{key:"toDebugString",value:function(){var t=["BigInt["],e=!0,r=!1,n=void 0;try{for(var i,o,a=this[Symbol.iterator]();!(e=(i=a.next()).done);e=!0)o=i.value,t.push((o?(o>>>0).toString(16):o)+", ")}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}return t.push("]"),t.join("")}},{key:"toString",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10;if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?l.__toStringBasePowerOfTwo(this,t):l.__toStringGeneric(this,t,!1)}},{key:"__copy",value:function(){for(var t=new l(this.length,this.sign),e=0;e<this.length;e++)t[e]=this[e];return t}},{key:"__trim",value:function(){for(var t=this.length,e=this[t-1];0===e;)e=this[--t-1],this.pop();return 0===t&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var t=0;t<this.length;t++)this[t]=0}},{key:"__clzmsd",value:function(){return u(this[this.length-1])}},{key:"__inplaceMultiplyAdd",value:function(t,e,r){r>this.length&&(r=this.length);for(var n=65535&t,i=t>>>16,o=0,a=65535&e,u=e>>>16,_=0;_<r;_++){var l=this.__digit(_),f=65535&l,h=l>>>16,c=s(f,n),g=s(f,i),d=s(h,n),p=s(h,i),v=a+(65535&c),y=u+o+(v>>>16)+(c>>>16)+(65535&g)+(65535&d);o=(a=(g>>>16)+(d>>>16)+(65535&p)+(y>>>16))>>>16,a&=65535,u=p>>>16,this.__setDigit(_,65535&v|y<<16)}if(0!==o||0!==a||0!==u)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(t,e,r){for(var n,i=0,o=0;o<r;o++)i=(n=this.__halfDigit(e+o)+t.__halfDigit(o)+i)>>>16,this.__setHalfDigit(e+o,n);return i}},{key:"__inplaceSub",value:function(t,e,r){var n=0;if(1&e){e>>=1;for(var i=this.__digit(e),o=65535&i,a=0;a<r-1>>>1;a++){var s=t.__digit(a),u=(i>>>16)-(65535&s)-n;n=1&u>>>16,this.__setDigit(e+a,u<<16|65535&o),n=1&(o=(65535&(i=this.__digit(e+a+1)))-(s>>>16)-n)>>>16}var _=t.__digit(a),l=(i>>>16)-(65535&_)-n;if(n=1&l>>>16,this.__setDigit(e+a,l<<16|65535&o),e+a+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(n=1&(o=(65535&(i=this.__digit(e+a+1)))-(_>>>16)-n)>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;for(var f=0;f<t.length-1;f++){var h=this.__digit(e+f),c=t.__digit(f),g=(65535&h)-(65535&c)-n,d=(h>>>16)-(c>>>16)-(n=1&g>>>16);n=1&d>>>16,this.__setDigit(e+f,d<<16|65535&g)}var p=this.__digit(e+f),v=t.__digit(f),y=(65535&p)-(65535&v)-n;n=1&y>>>16;var b=0;0==(1&r)&&(n=1&(b=(p>>>16)-(v>>>16)-n)>>>16),this.__setDigit(e+f,b<<16|65535&y)}return n}},{key:"__inplaceRightShift",value:function(t){if(0!==t){for(var e,r=this.__digit(0)>>>t,n=this.length-1,i=0;i<n;i++)e=this.__digit(i+1),this.__setDigit(i,e<<32-t|r),r=e>>>t;this.__setDigit(n,r)}}},{key:"__digit",value:function(t){return this[t]}},{key:"__unsignedDigit",value:function(t){return this[t]>>>0}},{key:"__setDigit",value:function(t,e){this[t]=0|e}},{key:"__setDigitGrow",value:function(t,e){this[t]=0|e}},{key:"__halfDigitLength",value:function(){var t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}},{key:"__halfDigit",value:function(t){return 65535&this[t>>>1]>>>((1&t)<<4)}},{key:"__setHalfDigit",value:function(t,e){var r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}}],[{key:"BigInt",value:function(e){var r=Math.floor,n=Number.isFinite;if("number"==typeof e){if(0===e)return l.__zero();if((0|e)===e)return 0>e?l.__oneDigit(-e,!0):l.__oneDigit(e,!1);if(!n(e)||r(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return l.__fromDouble(e)}if("string"==typeof e){var i=l.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?l.__oneDigit(1,!1):l.__zero();if("object"===t(e)){if(e.constructor===l)return e;var o=l.__toPrimitive(e);return l.BigInt(o)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(t){var e=t.length;if(0===e)return 0;if(1===e){var r=t.__unsignedDigit(0);return t.sign?-r:r}var n=t.__digit(e-1),i=u(n),o=32*e-i;if(1024<o)return t.sign?-1/0:1/0;var a=o-1,s=n,_=e-1,f=i+1,h=32===f?0:s<<f;h>>>=12;var c=f-12,g=12<=f?0:s<<20+f,d=20+f;0<c&&0<_&&(_--,h|=(s=t.__digit(_))>>>32-c,g=s<<c,d=c),0<d&&0<_&&(_--,g|=(s=t.__digit(_))>>>32-d,d-=32);var p=l.__decideRounding(t,d,_,s);if((1===p||0===p&&1==(1&g))&&0==(g=g+1>>>0)&&0!=++h>>>20&&(h=0,1023<++a))return t.sign?-1/0:1/0;var v=t.sign?-2147483648:0;return a=a+1023<<20,l.__kBitConversionInts[1]=v|a|h,l.__kBitConversionInts[0]=g,l.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(t){if(0===t.length)return t;var e=t.__copy();return e.sign=!t.sign,e}},{key:"bitwiseNot",value:function(t){return t.sign?l.__absoluteSubOne(t).__trim():l.__absoluteAddOne(t,!0)}},{key:"exponentiate",value:function(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return l.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?l.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");var r=e.__unsignedDigit(0);if(1===r)return t;if(r>=l.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){var n=1+(r>>>5),i=new l(n,t.sign&&0!=(1&r));i.__initializeDigits();var o=1<<(31&r);return i.__setDigit(n-1,o),i}var a=null,s=t;for(0!=(1&r)&&(a=t),r>>=1;0!==r;r>>=1)s=l.multiply(s,s),0!=(1&r)&&(a=null===a?s:l.multiply(a,s));return a}},{key:"multiply",value:function(t,e){if(0===t.length)return t;if(0===e.length)return e;var r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;var n=new l(r,t.sign!==e.sign);n.__initializeDigits();for(var i=0;i<t.length;i++)l.__multiplyAccumulate(e,t.__digit(i),n,i);return n.__trim()}},{key:"divide",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return l.__zero();var r,n=t.sign!==e.sign,i=e.__unsignedDigit(0);if(1===e.length&&65535>=i){if(1===i)return n===t.sign?t:l.unaryMinus(t);r=l.__absoluteDivSmall(t,i,null)}else r=l.__absoluteDivLarge(t,e,!0,!1);return r.sign=n,r.__trim()}},{key:"remainder",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return t;var r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return l.__zero();var n=l.__absoluteModSmall(t,r);return 0===n?l.__zero():l.__oneDigit(n,t.sign)}var i=l.__absoluteDivLarge(t,e,!1,!0);return i.sign=t.sign,i.__trim()}},{key:"add",value:function(t,e){var r=t.sign;return r===e.sign?l.__absoluteAdd(t,e,r):0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r)}},{key:"subtract",value:function(t,e){var r=t.sign;return r===e.sign?0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r):l.__absoluteAdd(t,e,r)}},{key:"leftShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__rightShiftByAbsolute(t,e):l.__leftShiftByAbsolute(t,e)}},{key:"signedRightShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__leftShiftByAbsolute(t,e):l.__rightShiftByAbsolute(t,e)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(t,e){return 0>l.__compareToBigInt(t,e)}},{key:"lessThanOrEqual",value:function(t,e){return 0>=l.__compareToBigInt(t,e)}},{key:"greaterThan",value:function(t,e){return 0<l.__compareToBigInt(t,e)}},{key:"greaterThanOrEqual",value:function(t,e){return 0<=l.__compareToBigInt(t,e)}},{key:"equal",value:function(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}},{key:"notEqual",value:function(t,e){return!l.equal(t,e)}},{key:"bitwiseAnd",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length)+1,n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteOr(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}return l.__absoluteAndNot(t,l.__absoluteSubOne(e)).__trim()}},{key:"bitwiseXor",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length),n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return l.__absoluteXor(n,i,n).__trim()}var o=a(t.length,e.length)+1;if(t.sign){var s=[e,t];t=s[0],e=s[1]}var u=l.__absoluteSubOne(e,o);return u=l.__absoluteXor(u,t,u),l.__absoluteAddOne(u,!0,u).__trim()}},{key:"bitwiseOr",value:function(t,e){var r=a(t.length,e.length);if(!t.sign&&!e.sign)return l.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){var n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteAnd(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}var s=l.__absoluteSubOne(e,r);return s=l.__absoluteAndNot(s,t,s),l.__absoluteAddOne(s,!0,s).__trim()}},{key:"asIntN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return l.__truncateToNBits(t,e);if(!e.sign)return l.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(var o=r-2;0<=o;o--)if(0!==e.__digit(o))return l.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:l.__truncateToNBits(t,e)}return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}},{key:"asUintN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(e.sign){if(t>l.__kMaxLengthBits)throw new RangeError("BigInt too big");return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return l.__truncateToNBits(t,e)}},{key:"ADD",value:function(t,e){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)&&l.__isBigInt(e))return l.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(t,e){return l.__compare(t,e,0)}},{key:"LE",value:function(t,e){return l.__compare(t,e,1)}},{key:"GT",value:function(t,e){return l.__compare(t,e,2)}},{key:"GE",value:function(t,e){return l.__compare(t,e,3)}},{key:"EQ",value:function(e,r){for(;;){if(l.__isBigInt(e))return l.__isBigInt(r)?l.equal(e,r):l.EQ(r,e);if("number"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("string"==typeof e){if(l.__isBigInt(r))return null!==(e=l.__fromString(e))&&l.equal(e,r);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("boolean"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,+e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("symbol"===t(e)){if(l.__isBigInt(r))return!1;if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else{if("object"!==t(e))return e==r;if("object"===t(r)&&r.constructor!==l)return e==r;e=l.__toPrimitive(e)}}}},{key:"NE",value:function(t,e){return!l.EQ(t,e)}},{key:"__zero",value:function(){return new l(0,!1)}},{key:"__oneDigit",value:function(t,e){var r=new l(1,e);return r.__setDigit(0,t),r}},{key:"__decideRounding",value:function(t,e,r,n){if(0<e)return-1;var i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}var o=1<<i;if(0==(n&o))return-1;if(0!=(n&(o-=1)))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}},{key:"__fromDouble",value:function(t){l.__kBitConversionDouble[0]=t;var e,r=(2047&l.__kBitConversionInts[1]>>>20)-1023,n=1+(r>>>5),i=new l(n,0>t),o=1048575&l.__kBitConversionInts[1]|1048576,a=l.__kBitConversionInts[0],s=31&r,u=0;if(s<20){var _=20-s;u=_+32,e=o>>>_,o=o<<32-_|a>>>_,a<<=32-_}else if(20===s)u=32,e=o,o=a;else{var f=s-20;u=32-f,e=o<<f|a>>>32-f,o=a<<f}i.__setDigit(n-1,e);for(var h=n-2;0<=h;h--)0<u?(u-=32,e=o,o=a):e=0,i.__setDigit(h,e);return i.__trim()}},{key:"__isWhitespace",value:function(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}},{key:"__fromString",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=0,n=t.length,i=0;if(i===n)return l.__zero();for(var o=t.charCodeAt(i);l.__isWhitespace(o);){if(++i===n)return l.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return l.__zero();o=t.charCodeAt(i)}var a=n-i,s=l.__kMaxBitsPerChar[e],u=l.__kBitsPerCharTableMultiplier-1;if(a>1073741824/s)return null;var _=s*a+u>>>l.__kBitsPerCharTableShift,f=new l(_+31>>>5,!1),h=10>e?e:10,c=10<e?e-10:0;if(0==(e&e-1)){s>>=l.__kBitsPerCharTableShift;var g=[],d=[],p=!1;do{for(var v,y=0,b=0;;){if(v=void 0,o-48>>>0<h)v=o-48;else{if(!((32|o)-97>>>0<c)){p=!0;break}v=(32|o)-87}if(b+=s,y=y<<s|v,++i===n){p=!0;break}if(o=t.charCodeAt(i),32<b+s)break}g.push(y),d.push(b)}while(!p);l.__fillFromParts(f,g,d)}else{f.__initializeDigits();var m=!1,w=0;do{for(var k,D=0,B=1;;){if(k=void 0,o-48>>>0<h)k=o-48;else{if(!((32|o)-97>>>0<c)){m=!0;break}k=(32|o)-87}var A=B*e;if(4294967295<A)break;if(B=A,D=D*e+k,w++,++i===n){m=!0;break}o=t.charCodeAt(i)}var P=s*w+(u=32*l.__kBitsPerCharTableMultiplier-1)>>>l.__kBitsPerCharTableShift+5;f.__inplaceMultiplyAdd(B,D,P)}while(!m)}if(i!==n){if(!l.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!l.__isWhitespace(o))return null}return 0!==r&&10!==e?null:(f.sign=-1===r,f.__trim())}},{key:"__fillFromParts",value:function(t,e,r){for(var n=0,i=0,o=0,a=e.length-1;0<=a;a--){var s=e[a],u=r[a];i|=s<<o,32===(o+=u)?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),i=s>>>u-(o-=32))}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}},{key:"__toStringBasePowerOfTwo",value:function(t,e){var r=t.length,n=e-1,i=n=(15&(n=(51&(n=(85&n>>>1)+(85&n))>>>2)+(51&n))>>>4)+(15&n),o=e-1,a=t.__digit(r-1),s=0|(32*r-u(a)+i-1)/i;if(t.sign&&s++,268435456<s)throw new Error("string too long");for(var _=Array(s),f=s-1,h=0,c=0,g=0;g<r-1;g++){var d=t.__digit(g),p=(h|d<<c)&o;_[f--]=l.__kConversionChars[p];var v=i-c;for(h=d>>>v,c=32-v;c>=i;)_[f--]=l.__kConversionChars[h&o],h>>>=i,c-=i}var y=(h|a<<c)&o;for(_[f--]=l.__kConversionChars[y],h=a>>>i-c;0!==h;)_[f--]=l.__kConversionChars[h&o],h>>>=i;if(t.sign&&(_[f--]="-"),-1!==f)throw new Error("implementation bug");return _.join("")}},{key:"__toStringGeneric",value:function(t,e,r){var n=t.length;if(0===n)return"";if(1===n){var i=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(i="-"+i),i}var o,a,s=32*n-u(t.__digit(n-1)),_=l.__kMaxBitsPerChar[e]-1,f=s*l.__kBitsPerCharTableMultiplier,h=1+(f=0|(f+=_-1)/_)>>1,c=l.exponentiate(l.__oneDigit(e,!1),l.__oneDigit(h,!1)),g=c.__unsignedDigit(0);if(1===c.length&&65535>=g){(o=new l(t.length,!1)).__initializeDigits();for(var d,p=0,v=2*t.length-1;0<=v;v--)d=p<<16|t.__halfDigit(v),o.__setHalfDigit(v,0|d/g),p=0|d%g;a=p.toString(e)}else{var y=l.__absoluteDivLarge(t,c,!0,!0);o=y.quotient;var b=y.remainder.__trim();a=l.__toStringGeneric(b,e,!0)}o.__trim();for(var m=l.__toStringGeneric(o,e,!0);a.length<h;)a="0"+a;return!1===r&&t.sign&&(m="-"+m),m+a}},{key:"__unequalSign",value:function(t){return t?-1:1}},{key:"__absoluteGreater",value:function(t){return t?-1:1}},{key:"__absoluteLess",value:function(t){return t?1:-1}},{key:"__compareToBigInt",value:function(t,e){var r=t.sign;if(r!==e.sign)return l.__unequalSign(r);var n=l.__absoluteCompare(t,e);return 0<n?l.__absoluteGreater(r):0>n?l.__absoluteLess(r):0}},{key:"__compareToNumber",value:function(t,e){if(!0|e){var r=t.sign,n=0>e;if(r!==n)return l.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return l.__absoluteGreater(r);var i=o(e),a=t.__unsignedDigit(0);return a>i?l.__absoluteGreater(r):a<i?l.__absoluteLess(r):0}return l.__compareToDouble(t,e)}},{key:"__compareToDouble",value:function(t,e){if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;var r=t.sign;if(r!==0>e)return l.__unequalSign(r);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;l.__kBitConversionDouble[0]=e;var n=2047&l.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var i=n-1023;if(0>i)return l.__absoluteGreater(r);var o=t.length,a=t.__digit(o-1),s=u(a),_=32*o-s,f=i+1;if(_<f)return l.__absoluteLess(r);if(_>f)return l.__absoluteGreater(r);var h=1048576|1048575&l.__kBitConversionInts[1],c=l.__kBitConversionInts[0],g=31-s;if(g!==(_-1)%31)throw new Error("implementation bug");var d,p=0;if(g<20){var v=20-g;p=v+32,d=h>>>v,h=h<<32-v|c>>>v,c<<=32-v}else if(20===g)p=32,d=h,h=c;else{var y=g-20;p=32-y,d=h<<y|c>>>32-y,h=c<<y}if((a>>>=0)>(d>>>=0))return l.__absoluteGreater(r);if(a<d)return l.__absoluteLess(r);for(var b=o-2;0<=b;b--){0<p?(p-=32,d=h>>>0,h=c,c=0):d=0;var m=t.__unsignedDigit(b);if(m>d)return l.__absoluteGreater(r);if(m<d)return l.__absoluteLess(r)}if(0!==h||0!==c){if(0===p)throw new Error("implementation bug");return l.__absoluteLess(r)}return 0}},{key:"__equalToNumber",value:function(t,e){return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===o(e):0===l.__compareToDouble(t,e)}},{key:"__comparisonResultToBool",value:function(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}},{key:"__compare",value:function(t,e,r){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(l.__isBigInt(t)&&"string"==typeof e)return null!==(e=l.__fromString(e))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("string"==typeof t&&l.__isBigInt(e))return null!==(t=l.__fromString(t))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)){if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return l.__comparisonResultToBool(l.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}},{key:"__absoluteAdd",value:function(t,e,r){if(t.length<e.length)return l.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);var n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;for(var i=new l(n,r),o=0,a=0;a<e.length;a++){var s=e.__digit(a),u=t.__digit(a),_=(65535&u)+(65535&s)+o,f=(u>>>16)+(s>>>16)+(_>>>16);o=f>>>16,i.__setDigit(a,65535&_|f<<16)}for(;a<t.length;a++){var h=t.__digit(a),c=(65535&h)+o,g=(h>>>16)+(c>>>16);o=g>>>16,i.__setDigit(a,65535&c|g<<16)}return a<i.length&&i.__setDigit(a,o),i.__trim()}},{key:"__absoluteSub",value:function(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);for(var n=new l(t.length,r),i=0,o=0;o<e.length;o++){var a=t.__digit(o),s=e.__digit(o),u=(65535&a)-(65535&s)-i,_=(a>>>16)-(s>>>16)-(i=1&u>>>16);i=1&_>>>16,n.__setDigit(o,65535&u|_<<16)}for(;o<t.length;o++){var f=t.__digit(o),h=(65535&f)-i,c=(f>>>16)-(i=1&h>>>16);i=1&c>>>16,n.__setDigit(o,65535&h|c<<16)}return n.__trim()}},{key:"__absoluteAddOne",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length;null===r?r=new l(n,e):r.sign=e;for(var i=!0,o=0;o<n;o++){var a=t.__digit(o),s=-1===a;i&&(a=0|a+1),i=s,r.__setDigit(o,a)}return i&&r.__setDigitGrow(n,1),r}},{key:"__absoluteSubOne",value:function(t,e){for(var r=t.length,n=new l(e=e||r,!1),i=!0,o=0;o<r;o++){var a=t.__digit(o),s=0===a;i&&(a=0|a-1),i=s,n.__setDigit(o,a)}for(var u=r;u<e;u++)n.__setDigit(u,0);return n}},{key:"__absoluteAnd",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=o;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)&e.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteAndNot",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;n<i&&(o=n);var a=n;null===r?r=new l(a,!1):a=r.length;for(var s=0;s<o;s++)r.__setDigit(s,t.__digit(s)&~e.__digit(s));for(;s<n;s++)r.__setDigit(s,t.__digit(s));for(;s<a;s++)r.__setDigit(s,0);return r}},{key:"__absoluteOr",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)|e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteXor",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)^e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteCompare",value:function(t,e){var r=t.length-e.length;if(0!=r)return r;for(var n=t.length-1;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}},{key:"__multiplyAccumulate",value:function(t,e,r,n){if(0!==e){for(var i=65535&e,o=e>>>16,a=0,u=0,_=0,l=0;l<t.length;l++,n++){var f=r.__digit(n),h=65535&f,c=f>>>16,g=t.__digit(l),d=65535&g,p=g>>>16,v=s(d,i),y=s(d,o),b=s(p,i),m=s(p,o);a=(u=(y>>>16)+(b>>>16)+(65535&m)+(a=(c+=_+a+((h+=u+(65535&v))>>>16)+(v>>>16)+(65535&y)+(65535&b))>>>16))>>>16,u&=65535,_=m>>>16,f=65535&h|c<<16,r.__setDigit(n,f)}for(;0!==a||0!==u||0!==_;n++){var w=r.__digit(n),k=(65535&w)+u,D=(w>>>16)+(k>>>16)+_+a;u=0,_=0,a=D>>>16,w=65535&k|D<<16,r.__setDigit(n,w)}}}},{key:"__internalMultiplyAdd",value:function(t,e,r,n,i){for(var o=r,a=0,u=0;u<n;u++){var _=t.__digit(u),l=s(65535&_,e),f=(65535&l)+a+o;o=f>>>16;var h=s(_>>>16,e),c=(65535&h)+(l>>>16)+o;o=c>>>16,a=h>>>16,i.__setDigit(u,c<<16|65535&f)}if(i.length>n)for(i.__setDigit(n++,o+a);n<i.length;)i.__setDigit(n++,0);else if(0!==o+a)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(t,e,r){null===r&&(r=new l(t.length,!1));for(var n=0,i=2*t.length-1;0<=i;i-=2){var o=(n<<16|t.__halfDigit(i))>>>0,a=0|o/e,s=0|(o=((n=0|o%e)<<16|t.__halfDigit(i-1))>>>0)/e;n=0|o%e,r.__setDigit(i>>>1,a<<16|s)}return r}},{key:"__absoluteModSmall",value:function(t,e){for(var r=0,n=2*t.length-1;0<=n;n--)r=0|((r<<16|t.__halfDigit(n))>>>0)%e;return r}},{key:"__absoluteDivLarge",value:function(t,e,r,n){var i=e.__halfDigitLength(),o=e.length,a=t.__halfDigitLength()-i,u=null;r&&(u=new l(a+2>>>1,!1)).__initializeDigits();var _=new l(i+2>>>1,!1);_.__initializeDigits();var f=l.__clz16(e.__halfDigit(i-1));0<f&&(e=l.__specialLeftShift(e,f,0));for(var h=l.__specialLeftShift(t,f,1),c=e.__halfDigit(i-1),g=0,d=a;0<=d;d--){var p=65535,v=h.__halfDigit(d+i);if(v!==c){var y=(v<<16|h.__halfDigit(d+i-1))>>>0;p=0|y/c;for(var b=0|y%c,m=e.__halfDigit(i-2),w=h.__halfDigit(d+i-2);s(p,m)>>>0>(b<<16|w)>>>0&&(p--,!(65535<(b+=c))););}l.__internalMultiplyAdd(e,p,0,o,_);var k=h.__inplaceSub(_,d,i+1);0!==k&&(k=h.__inplaceAdd(e,d,i),h.__setHalfDigit(d+i,h.__halfDigit(d+i)+k),p--),r&&(1&d?g=p<<16:u.__setDigit(d>>>1,g|p))}return n?(h.__inplaceRightShift(f),r?{quotient:u,remainder:h}:h):r?u:void 0}},{key:"__clz16",value:function(t){return u(t)-16}},{key:"__specialLeftShift",value:function(t,e,r){var n=t.length,i=new l(n+r,!1);if(0===e){for(var o=0;o<n;o++)i.__setDigit(o,t.__digit(o));return 0<r&&i.__setDigit(n,0),i}for(var a,s=0,u=0;u<n;u++)a=t.__digit(u),i.__setDigit(u,a<<e|s),s=a>>>32-e;return 0<r&&i.__setDigit(n,s),i}},{key:"__leftShiftByAbsolute",value:function(t,e){var r=l.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");var n=r>>>5,i=31&r,o=t.length,a=0!==i&&0!=t.__digit(o-1)>>>32-i,s=o+n+(a?1:0),u=new l(s,t.sign);if(0===i){for(var _=0;_<n;_++)u.__setDigit(_,0);for(;_<s;_++)u.__setDigit(_,t.__digit(_-n))}else{for(var f=0,h=0;h<n;h++)u.__setDigit(h,0);for(var c,g=0;g<o;g++)c=t.__digit(g),u.__setDigit(g+n,c<<i|f),f=c>>>32-i;if(a)u.__setDigit(o+n,f);else if(0!==f)throw new Error("implementation bug")}return u.__trim()}},{key:"__rightShiftByAbsolute",value:function(t,e){var r=t.length,n=t.sign,i=l.__toShiftAmount(e);if(0>i)return l.__rightShiftByMaximum(n);var o=i>>>5,a=31&i,s=r-o;if(0>=s)return l.__rightShiftByMaximum(n);var u=!1;if(n)if(0!=(t.__digit(o)&(1<<a)-1))u=!0;else for(var _=0;_<o;_++)if(0!==t.__digit(_)){u=!0;break}u&&0===a&&0==~t.__digit(r-1)&&s++;var f=new l(s,n);if(0===a)for(var h=o;h<r;h++)f.__setDigit(h-o,t.__digit(h));else{for(var c,g=t.__digit(o)>>>a,d=r-o-1,p=0;p<d;p++)c=t.__digit(p+o+1),f.__setDigit(p,c<<32-a|g),g=c>>>a;f.__setDigit(d,g)}return u&&(f=l.__absoluteAddOne(f,!0,f)),f.__trim()}},{key:"__rightShiftByMaximum",value:function(t){return t?l.__oneDigit(1,!0):l.__zero()}},{key:"__toShiftAmount",value:function(t){if(1<t.length)return-1;var e=t.__unsignedDigit(0);return e>l.__kMaxLengthBits?-1:e}},{key:"__toPrimitive",value:function(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==t(e))return e;if(e.constructor===l)return e;var n=e[Symbol.toPrimitive];if(n){var i=n(r);if("object"!==t(i))return i;throw new TypeError("Cannot convert object to primitive value")}var o=e.valueOf;if(o){var a=o.call(e);if("object"!==t(a))return a}var s=e.toString;if(s){var u=s.call(e);if("object"!==t(u))return u}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(t){return l.__isBigInt(t)?t:+t}},{key:"__isBigInt",value:function(e){return"object"===t(e)&&e.constructor===l}},{key:"__truncateToNBits",value:function(t,e){for(var r=t+31>>>5,n=new l(r,e.sign),i=r-1,o=0;o<i;o++)n.__setDigit(o,e.__digit(o));var a=e.__digit(i);if(0!=(31&t)){var s=32-(31&t);a=a<<s>>>s}return n.__setDigit(i,a),n.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(t,e,r){for(var n=Math.min,i=t+31>>>5,o=new l(i,r),a=0,s=i-1,u=0,_=n(s,e.length);a<_;a++){var f=e.__digit(a),h=0-(65535&f)-u,c=0-(f>>>16)-(u=1&h>>>16);u=1&c>>>16,o.__setDigit(a,65535&h|c<<16)}for(;a<s;a++)o.__setDigit(a,0|-u);var g,d=s<e.length?e.__digit(s):0,p=31&t;if(0===p){var v=0-(65535&d)-u;g=65535&v|0-(d>>>16)-(u=1&v>>>16)<<16}else{var y=32-p,b=1<<32-y,m=(65535&b)-(65535&(d=d<<y>>>y))-u;g=65535&m|(b>>>16)-(d>>>16)-(u=1&m>>>16)<<16,g&=b-1}return o.__setDigit(s,g),o.__trim()}},{key:"__digitPow",value:function(t,e){for(var r=1;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}]),l}(u(Array));return l.__kMaxLength=33554432,l.__kMaxLengthBits=l.__kMaxLength<<5,l.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],l.__kBitsPerCharTableShift=5,l.__kBitsPerCharTableMultiplier=1<<l.__kBitsPerCharTableShift,l.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],l.__kBitConversionBuffer=new ArrayBuffer(8),l.__kBitConversionDouble=new Float64Array(l.__kBitConversionBuffer),l.__kBitConversionInts=new Int32Array(l.__kBitConversionBuffer),l}()})));const s={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await o(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),a=await i.json();if(a.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(a.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(a.error)}`);return a.result}};class u{constructor(t){return this.uri=t,new Proxy(this,s)}}function _(t){return a.BigInt(t)}function l(t){return"0x"+t.toString(16)}function f(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,a=r.length+n.length,s=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>a)throw new Error(s);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(s);if(u.find(t=>!n.includes(t)))throw new Error(s)}function h(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function c(t,e){if(h(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function g(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function d(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(f(r,t,["code_hash","hash_type","args"],[]),c(`${r}.code_hash`,t.code_hash),h(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function p(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){f(r,t,["tx_hash","index"],[]),c(`${r}.tx_hash`,t.tx_hash),g(`${r}.index`,t.index)}function v(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){f(r,t,["since","previous_output"],[]),g(`${r}.since`,t.since),e&&p(t.previous_output,{debugPath:`${r}.previous_output`})}function y(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){f(r,t,["capacity","lock"],["type"]),g(`${r}.capacity`,t.capacity),e&&(d(t.lock,{debugPath:`${r}.lock`}),t.type&&d(t.type,{debugPath:`${r}.type`}))}function b(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(f(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&p(t.out_point,{debugPath:`${r}.out_point`})}function m(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function w(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function k(t,e,r){g(`${t}.version`,e.version),m(`${t}.cell_deps`,e.cell_deps,w(b,r),r),m(`${t}.header_deps`,e.header_deps,c,r),m(`${t}.inputs`,e.inputs,w(v,r),r),m(`${t}.outputs`,e.outputs,w(y,r),r),m(`${t}.outputs_data`,e.outputs_data,h,r)}function D(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),k(r,t,e)}function B(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),k(r,t,e),m(`${r}.witnesses`,t.witnesses,h,e)}function A(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){g(`${t}.version`,e.version),g(`${t}.compact_target`,e.compact_target),g(`${t}.timestamp`,e.timestamp),g(`${t}.number`,e.number),g(`${t}.epoch`,e.epoch),c(`${t}.parent_hash`,e.parent_hash),c(`${t}.transactions_root`,e.transactions_root),c(`${t}.proposals_hash`,e.proposals_hash),c(`${t}.uncles_hash`,e.uncles_hash),c(`${t}.dao`,e.dao)}(r,t)}function P(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),h(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function T(t,e){if(h(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function S(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){f(r,t,["header","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.proposals`,t.proposals,T,e)}function E(t,{nestedValidation:e=!0,debugPath:r="block"}={}){f(r,t,["header","uncles","transactions","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.uncles`,t.uncles,w(S,e),e),m(`${r}.transactions`,t.transactions,w(B,e),e),m(`${r}.proposals`,t.proposals,T,e)}function x(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){f(r,t,["lock","message"],[]),h(`${r}.message`,t.message),e&&d(t.lock,{debugPath:`${r}.lock`})}function C(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){f(r,t,[],["lock","input_type","output_type"]),t.lock&&h(`${r}.lock`,t.lock),t.input_type&&h(`${r}.input_type`,t.input_type),t.output_type&&h(`${r}.output_type`,t.output_type)}var O=Object.freeze({__proto__:null,ValidateScript:d,ValidateOutPoint:p,ValidateCellInput:v,ValidateCellOutput:y,ValidateCellDep:b,ValidateRawTransaction:D,ValidateTransaction:B,ValidateRawHeader:A,ValidateHeader:P,ValidateUncleBlock:S,ValidateBlock:E,ValidateCellbaseWitness:x,ValidateWitnessArgs:C});function $(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function I(t,e,r){if(!((e=$(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function R(t,{validation:e=!0,debugPath:r="script"}={}){return t=I(r,t,{code_hash:$,hash_type:$,args:$}),e&&d(t,{debugPath:`(transformed) ${r}`}),t}function j(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=I(r,t,{tx_hash:$,index:$}),e&&p(t,{debugPath:`(transformed) ${r}`}),t}function M(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function z(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=I(r,t,{since:$,previous_output:M(j)}),e&&v(t,{debugPath:`(transformed) ${r}`}),t}function L(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=I(r,t,{capacity:$,lock:M(R),type:M(R)}),e&&y(t,{debugPath:`(transformed) ${r}`}),t}function N(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=I(r,t,{out_point:M(j),dep_type:$}),e&&b(t,{debugPath:`(transformed) ${r}`}),t}function F(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function U(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($),witnesses:F($)}),e&&B(t,{debugPath:`(transformed) ${r}`}),t}function V(t,{validation:e=!0,debugPath:r="header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$,nonce:$}),e&&P(t,{debugPath:`(transformed) ${r}`}),t}function q(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=I(r,t,{header:M(V),proposals:F($)}),e&&S(t,{debugPath:`(transformed) ${r}`}),t}var H=Object.freeze({__proto__:null,TransformScript:R,TransformOutPoint:j,TransformCellInput:z,TransformCellOutput:L,TransformCellDep:N,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($)}),e&&D(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:U,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$}),e&&A(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:V,TransformUncleBlock:q,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=I(r,t,{header:M(V),uncles:F(M(q)),transactions:F(M(U)),proposals:F($)}),e&&E(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=I(r,t,{lock:M(R),message:$}),e&&x(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=I(r,t,{lock:$,input_type:$,output_type:$}),e&&C(t,{debugPath:`(transformed) ${r}`}),t}});var G=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:n=!0,loadData:i=!1}={}){this.rpc=t,this.lockHash=new r(e).serializeJson(),this.skipCellWithContent=n,this.loadData=i}async*collect(){const t=_(await this.rpc.get_tip_block_number());let e=a.BigInt(0);for(;a.lessThanOrEqual(e,t);){let r=a.add(e,a.BigInt(100));a.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,l(e),l(r));for(const t of n)if(this.skipCellWithContent){if(t.type||a.greaterThan(_(t.output_data_len),a.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=a.add(r,a.BigInt(1))}}}});export{l as BigIntToHexString,_ as HexStringToBigInt,u as RPC,r as Reader,G as cell_collectors,H as transformers,O as validators};
class t{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class e{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class r{constructor(r){if("string"==typeof r){if(!r.startsWith("0x")||r.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new e(r)}if(r instanceof ArrayBuffer)return new t(r);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(e){const r=new ArrayBuffer(e.length),n=new DataView(r);for(let t=0;t<e.length;t++){const r=e.charCodeAt(t);if(r>255)throw new Error("fromRawString can only accept UTF-8 raw string!");n.setUint8(t,r)}return new t(r)}}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t,e){return t(e={exports:{}},e.exports),e.exports}var o=i((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:n);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,a="ArrayBuffer"in t;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function _(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function g(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=g(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=g(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=_(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[_(t)]},h.prototype.get=function(t){return t=_(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(_(t))},h.prototype.set=function(t,e){this.map[_(t)]=l(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),y.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},v.call(b.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];w.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function D(t,r){return new Promise((function(n,o){var a=new b(t,r);if(a.signal&&a.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}D.polyfill=!0,t.fetch||(t.fetch=D,t.Headers=h,t.Request=b,t.Response=w),e.Headers=h,e.Request=b,e.Response=w,e.fetch=D}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),a=(o.fetch,o.Headers,o.Request,o.Response,i((function(t,e){t.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function s(){return(s=a()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){function r(){return s(t,arguments,i(this).constructor)}if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)})(t)}function _(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var l=function(e){var o=Math.abs,a=Math.max,s=Math.imul,u=Math.clz32;function l(t,e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,l),t>l.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return(r=_(this,i(l).call(this,t))).sign=e,r}return n(l,e),r(l,[{key:"toDebugString",value:function(){var t=["BigInt["],e=!0,r=!1,n=void 0;try{for(var i,o,a=this[Symbol.iterator]();!(e=(i=a.next()).done);e=!0)o=i.value,t.push((o?(o>>>0).toString(16):o)+", ")}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}return t.push("]"),t.join("")}},{key:"toString",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10;if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?l.__toStringBasePowerOfTwo(this,t):l.__toStringGeneric(this,t,!1)}},{key:"__copy",value:function(){for(var t=new l(this.length,this.sign),e=0;e<this.length;e++)t[e]=this[e];return t}},{key:"__trim",value:function(){for(var t=this.length,e=this[t-1];0===e;)e=this[--t-1],this.pop();return 0===t&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var t=0;t<this.length;t++)this[t]=0}},{key:"__clzmsd",value:function(){return u(this[this.length-1])}},{key:"__inplaceMultiplyAdd",value:function(t,e,r){r>this.length&&(r=this.length);for(var n=65535&t,i=t>>>16,o=0,a=65535&e,u=e>>>16,_=0;_<r;_++){var l=this.__digit(_),f=65535&l,h=l>>>16,c=s(f,n),g=s(f,i),d=s(h,n),p=s(h,i),v=a+(65535&c),y=u+o+(v>>>16)+(c>>>16)+(65535&g)+(65535&d);o=(a=(g>>>16)+(d>>>16)+(65535&p)+(y>>>16))>>>16,a&=65535,u=p>>>16,this.__setDigit(_,65535&v|y<<16)}if(0!==o||0!==a||0!==u)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(t,e,r){for(var n,i=0,o=0;o<r;o++)i=(n=this.__halfDigit(e+o)+t.__halfDigit(o)+i)>>>16,this.__setHalfDigit(e+o,n);return i}},{key:"__inplaceSub",value:function(t,e,r){var n=0;if(1&e){e>>=1;for(var i=this.__digit(e),o=65535&i,a=0;a<r-1>>>1;a++){var s=t.__digit(a),u=(i>>>16)-(65535&s)-n;n=1&u>>>16,this.__setDigit(e+a,u<<16|65535&o),n=1&(o=(65535&(i=this.__digit(e+a+1)))-(s>>>16)-n)>>>16}var _=t.__digit(a),l=(i>>>16)-(65535&_)-n;if(n=1&l>>>16,this.__setDigit(e+a,l<<16|65535&o),e+a+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(n=1&(o=(65535&(i=this.__digit(e+a+1)))-(_>>>16)-n)>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;for(var f=0;f<t.length-1;f++){var h=this.__digit(e+f),c=t.__digit(f),g=(65535&h)-(65535&c)-n,d=(h>>>16)-(c>>>16)-(n=1&g>>>16);n=1&d>>>16,this.__setDigit(e+f,d<<16|65535&g)}var p=this.__digit(e+f),v=t.__digit(f),y=(65535&p)-(65535&v)-n;n=1&y>>>16;var b=0;0==(1&r)&&(n=1&(b=(p>>>16)-(v>>>16)-n)>>>16),this.__setDigit(e+f,b<<16|65535&y)}return n}},{key:"__inplaceRightShift",value:function(t){if(0!==t){for(var e,r=this.__digit(0)>>>t,n=this.length-1,i=0;i<n;i++)e=this.__digit(i+1),this.__setDigit(i,e<<32-t|r),r=e>>>t;this.__setDigit(n,r)}}},{key:"__digit",value:function(t){return this[t]}},{key:"__unsignedDigit",value:function(t){return this[t]>>>0}},{key:"__setDigit",value:function(t,e){this[t]=0|e}},{key:"__setDigitGrow",value:function(t,e){this[t]=0|e}},{key:"__halfDigitLength",value:function(){var t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}},{key:"__halfDigit",value:function(t){return 65535&this[t>>>1]>>>((1&t)<<4)}},{key:"__setHalfDigit",value:function(t,e){var r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}}],[{key:"BigInt",value:function(e){var r=Math.floor,n=Number.isFinite;if("number"==typeof e){if(0===e)return l.__zero();if((0|e)===e)return 0>e?l.__oneDigit(-e,!0):l.__oneDigit(e,!1);if(!n(e)||r(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return l.__fromDouble(e)}if("string"==typeof e){var i=l.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?l.__oneDigit(1,!1):l.__zero();if("object"===t(e)){if(e.constructor===l)return e;var o=l.__toPrimitive(e);return l.BigInt(o)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(t){var e=t.length;if(0===e)return 0;if(1===e){var r=t.__unsignedDigit(0);return t.sign?-r:r}var n=t.__digit(e-1),i=u(n),o=32*e-i;if(1024<o)return t.sign?-1/0:1/0;var a=o-1,s=n,_=e-1,f=i+1,h=32===f?0:s<<f;h>>>=12;var c=f-12,g=12<=f?0:s<<20+f,d=20+f;0<c&&0<_&&(_--,h|=(s=t.__digit(_))>>>32-c,g=s<<c,d=c),0<d&&0<_&&(_--,g|=(s=t.__digit(_))>>>32-d,d-=32);var p=l.__decideRounding(t,d,_,s);if((1===p||0===p&&1==(1&g))&&0==(g=g+1>>>0)&&0!=++h>>>20&&(h=0,1023<++a))return t.sign?-1/0:1/0;var v=t.sign?-2147483648:0;return a=a+1023<<20,l.__kBitConversionInts[1]=v|a|h,l.__kBitConversionInts[0]=g,l.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(t){if(0===t.length)return t;var e=t.__copy();return e.sign=!t.sign,e}},{key:"bitwiseNot",value:function(t){return t.sign?l.__absoluteSubOne(t).__trim():l.__absoluteAddOne(t,!0)}},{key:"exponentiate",value:function(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return l.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?l.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");var r=e.__unsignedDigit(0);if(1===r)return t;if(r>=l.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){var n=1+(r>>>5),i=new l(n,t.sign&&0!=(1&r));i.__initializeDigits();var o=1<<(31&r);return i.__setDigit(n-1,o),i}var a=null,s=t;for(0!=(1&r)&&(a=t),r>>=1;0!==r;r>>=1)s=l.multiply(s,s),0!=(1&r)&&(a=null===a?s:l.multiply(a,s));return a}},{key:"multiply",value:function(t,e){if(0===t.length)return t;if(0===e.length)return e;var r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;var n=new l(r,t.sign!==e.sign);n.__initializeDigits();for(var i=0;i<t.length;i++)l.__multiplyAccumulate(e,t.__digit(i),n,i);return n.__trim()}},{key:"divide",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return l.__zero();var r,n=t.sign!==e.sign,i=e.__unsignedDigit(0);if(1===e.length&&65535>=i){if(1===i)return n===t.sign?t:l.unaryMinus(t);r=l.__absoluteDivSmall(t,i,null)}else r=l.__absoluteDivLarge(t,e,!0,!1);return r.sign=n,r.__trim()}},{key:"remainder",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return t;var r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return l.__zero();var n=l.__absoluteModSmall(t,r);return 0===n?l.__zero():l.__oneDigit(n,t.sign)}var i=l.__absoluteDivLarge(t,e,!1,!0);return i.sign=t.sign,i.__trim()}},{key:"add",value:function(t,e){var r=t.sign;return r===e.sign?l.__absoluteAdd(t,e,r):0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r)}},{key:"subtract",value:function(t,e){var r=t.sign;return r===e.sign?0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r):l.__absoluteAdd(t,e,r)}},{key:"leftShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__rightShiftByAbsolute(t,e):l.__leftShiftByAbsolute(t,e)}},{key:"signedRightShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__leftShiftByAbsolute(t,e):l.__rightShiftByAbsolute(t,e)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(t,e){return 0>l.__compareToBigInt(t,e)}},{key:"lessThanOrEqual",value:function(t,e){return 0>=l.__compareToBigInt(t,e)}},{key:"greaterThan",value:function(t,e){return 0<l.__compareToBigInt(t,e)}},{key:"greaterThanOrEqual",value:function(t,e){return 0<=l.__compareToBigInt(t,e)}},{key:"equal",value:function(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}},{key:"notEqual",value:function(t,e){return!l.equal(t,e)}},{key:"bitwiseAnd",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length)+1,n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteOr(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}return l.__absoluteAndNot(t,l.__absoluteSubOne(e)).__trim()}},{key:"bitwiseXor",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length),n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return l.__absoluteXor(n,i,n).__trim()}var o=a(t.length,e.length)+1;if(t.sign){var s=[e,t];t=s[0],e=s[1]}var u=l.__absoluteSubOne(e,o);return u=l.__absoluteXor(u,t,u),l.__absoluteAddOne(u,!0,u).__trim()}},{key:"bitwiseOr",value:function(t,e){var r=a(t.length,e.length);if(!t.sign&&!e.sign)return l.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){var n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteAnd(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}var s=l.__absoluteSubOne(e,r);return s=l.__absoluteAndNot(s,t,s),l.__absoluteAddOne(s,!0,s).__trim()}},{key:"asIntN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return l.__truncateToNBits(t,e);if(!e.sign)return l.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(var o=r-2;0<=o;o--)if(0!==e.__digit(o))return l.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:l.__truncateToNBits(t,e)}return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}},{key:"asUintN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(e.sign){if(t>l.__kMaxLengthBits)throw new RangeError("BigInt too big");return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return l.__truncateToNBits(t,e)}},{key:"ADD",value:function(t,e){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)&&l.__isBigInt(e))return l.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(t,e){return l.__compare(t,e,0)}},{key:"LE",value:function(t,e){return l.__compare(t,e,1)}},{key:"GT",value:function(t,e){return l.__compare(t,e,2)}},{key:"GE",value:function(t,e){return l.__compare(t,e,3)}},{key:"EQ",value:function(e,r){for(;;){if(l.__isBigInt(e))return l.__isBigInt(r)?l.equal(e,r):l.EQ(r,e);if("number"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("string"==typeof e){if(l.__isBigInt(r))return null!==(e=l.__fromString(e))&&l.equal(e,r);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("boolean"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,+e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("symbol"===t(e)){if(l.__isBigInt(r))return!1;if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else{if("object"!==t(e))return e==r;if("object"===t(r)&&r.constructor!==l)return e==r;e=l.__toPrimitive(e)}}}},{key:"NE",value:function(t,e){return!l.EQ(t,e)}},{key:"__zero",value:function(){return new l(0,!1)}},{key:"__oneDigit",value:function(t,e){var r=new l(1,e);return r.__setDigit(0,t),r}},{key:"__decideRounding",value:function(t,e,r,n){if(0<e)return-1;var i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}var o=1<<i;if(0==(n&o))return-1;if(0!=(n&(o-=1)))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}},{key:"__fromDouble",value:function(t){l.__kBitConversionDouble[0]=t;var e,r=(2047&l.__kBitConversionInts[1]>>>20)-1023,n=1+(r>>>5),i=new l(n,0>t),o=1048575&l.__kBitConversionInts[1]|1048576,a=l.__kBitConversionInts[0],s=31&r,u=0;if(s<20){var _=20-s;u=_+32,e=o>>>_,o=o<<32-_|a>>>_,a<<=32-_}else if(20===s)u=32,e=o,o=a;else{var f=s-20;u=32-f,e=o<<f|a>>>32-f,o=a<<f}i.__setDigit(n-1,e);for(var h=n-2;0<=h;h--)0<u?(u-=32,e=o,o=a):e=0,i.__setDigit(h,e);return i.__trim()}},{key:"__isWhitespace",value:function(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}},{key:"__fromString",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=0,n=t.length,i=0;if(i===n)return l.__zero();for(var o=t.charCodeAt(i);l.__isWhitespace(o);){if(++i===n)return l.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return l.__zero();o=t.charCodeAt(i)}var a=n-i,s=l.__kMaxBitsPerChar[e],u=l.__kBitsPerCharTableMultiplier-1;if(a>1073741824/s)return null;var _=s*a+u>>>l.__kBitsPerCharTableShift,f=new l(_+31>>>5,!1),h=10>e?e:10,c=10<e?e-10:0;if(0==(e&e-1)){s>>=l.__kBitsPerCharTableShift;var g=[],d=[],p=!1;do{for(var v,y=0,b=0;;){if(v=void 0,o-48>>>0<h)v=o-48;else{if(!((32|o)-97>>>0<c)){p=!0;break}v=(32|o)-87}if(b+=s,y=y<<s|v,++i===n){p=!0;break}if(o=t.charCodeAt(i),32<b+s)break}g.push(y),d.push(b)}while(!p);l.__fillFromParts(f,g,d)}else{f.__initializeDigits();var m=!1,w=0;do{for(var k,D=0,B=1;;){if(k=void 0,o-48>>>0<h)k=o-48;else{if(!((32|o)-97>>>0<c)){m=!0;break}k=(32|o)-87}var A=B*e;if(4294967295<A)break;if(B=A,D=D*e+k,w++,++i===n){m=!0;break}o=t.charCodeAt(i)}var P=s*w+(u=32*l.__kBitsPerCharTableMultiplier-1)>>>l.__kBitsPerCharTableShift+5;f.__inplaceMultiplyAdd(B,D,P)}while(!m)}if(i!==n){if(!l.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!l.__isWhitespace(o))return null}return 0!==r&&10!==e?null:(f.sign=-1===r,f.__trim())}},{key:"__fillFromParts",value:function(t,e,r){for(var n=0,i=0,o=0,a=e.length-1;0<=a;a--){var s=e[a],u=r[a];i|=s<<o,32===(o+=u)?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),i=s>>>u-(o-=32))}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}},{key:"__toStringBasePowerOfTwo",value:function(t,e){var r=t.length,n=e-1,i=n=(15&(n=(51&(n=(85&n>>>1)+(85&n))>>>2)+(51&n))>>>4)+(15&n),o=e-1,a=t.__digit(r-1),s=0|(32*r-u(a)+i-1)/i;if(t.sign&&s++,268435456<s)throw new Error("string too long");for(var _=Array(s),f=s-1,h=0,c=0,g=0;g<r-1;g++){var d=t.__digit(g),p=(h|d<<c)&o;_[f--]=l.__kConversionChars[p];var v=i-c;for(h=d>>>v,c=32-v;c>=i;)_[f--]=l.__kConversionChars[h&o],h>>>=i,c-=i}var y=(h|a<<c)&o;for(_[f--]=l.__kConversionChars[y],h=a>>>i-c;0!==h;)_[f--]=l.__kConversionChars[h&o],h>>>=i;if(t.sign&&(_[f--]="-"),-1!==f)throw new Error("implementation bug");return _.join("")}},{key:"__toStringGeneric",value:function(t,e,r){var n=t.length;if(0===n)return"";if(1===n){var i=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(i="-"+i),i}var o,a,s=32*n-u(t.__digit(n-1)),_=l.__kMaxBitsPerChar[e]-1,f=s*l.__kBitsPerCharTableMultiplier,h=1+(f=0|(f+=_-1)/_)>>1,c=l.exponentiate(l.__oneDigit(e,!1),l.__oneDigit(h,!1)),g=c.__unsignedDigit(0);if(1===c.length&&65535>=g){(o=new l(t.length,!1)).__initializeDigits();for(var d,p=0,v=2*t.length-1;0<=v;v--)d=p<<16|t.__halfDigit(v),o.__setHalfDigit(v,0|d/g),p=0|d%g;a=p.toString(e)}else{var y=l.__absoluteDivLarge(t,c,!0,!0);o=y.quotient;var b=y.remainder.__trim();a=l.__toStringGeneric(b,e,!0)}o.__trim();for(var m=l.__toStringGeneric(o,e,!0);a.length<h;)a="0"+a;return!1===r&&t.sign&&(m="-"+m),m+a}},{key:"__unequalSign",value:function(t){return t?-1:1}},{key:"__absoluteGreater",value:function(t){return t?-1:1}},{key:"__absoluteLess",value:function(t){return t?1:-1}},{key:"__compareToBigInt",value:function(t,e){var r=t.sign;if(r!==e.sign)return l.__unequalSign(r);var n=l.__absoluteCompare(t,e);return 0<n?l.__absoluteGreater(r):0>n?l.__absoluteLess(r):0}},{key:"__compareToNumber",value:function(t,e){if(!0|e){var r=t.sign,n=0>e;if(r!==n)return l.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return l.__absoluteGreater(r);var i=o(e),a=t.__unsignedDigit(0);return a>i?l.__absoluteGreater(r):a<i?l.__absoluteLess(r):0}return l.__compareToDouble(t,e)}},{key:"__compareToDouble",value:function(t,e){if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;var r=t.sign;if(r!==0>e)return l.__unequalSign(r);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;l.__kBitConversionDouble[0]=e;var n=2047&l.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var i=n-1023;if(0>i)return l.__absoluteGreater(r);var o=t.length,a=t.__digit(o-1),s=u(a),_=32*o-s,f=i+1;if(_<f)return l.__absoluteLess(r);if(_>f)return l.__absoluteGreater(r);var h=1048576|1048575&l.__kBitConversionInts[1],c=l.__kBitConversionInts[0],g=31-s;if(g!==(_-1)%31)throw new Error("implementation bug");var d,p=0;if(g<20){var v=20-g;p=v+32,d=h>>>v,h=h<<32-v|c>>>v,c<<=32-v}else if(20===g)p=32,d=h,h=c;else{var y=g-20;p=32-y,d=h<<y|c>>>32-y,h=c<<y}if((a>>>=0)>(d>>>=0))return l.__absoluteGreater(r);if(a<d)return l.__absoluteLess(r);for(var b=o-2;0<=b;b--){0<p?(p-=32,d=h>>>0,h=c,c=0):d=0;var m=t.__unsignedDigit(b);if(m>d)return l.__absoluteGreater(r);if(m<d)return l.__absoluteLess(r)}if(0!==h||0!==c){if(0===p)throw new Error("implementation bug");return l.__absoluteLess(r)}return 0}},{key:"__equalToNumber",value:function(t,e){return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===o(e):0===l.__compareToDouble(t,e)}},{key:"__comparisonResultToBool",value:function(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}},{key:"__compare",value:function(t,e,r){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(l.__isBigInt(t)&&"string"==typeof e)return null!==(e=l.__fromString(e))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("string"==typeof t&&l.__isBigInt(e))return null!==(t=l.__fromString(t))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)){if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return l.__comparisonResultToBool(l.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}},{key:"__absoluteAdd",value:function(t,e,r){if(t.length<e.length)return l.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);var n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;for(var i=new l(n,r),o=0,a=0;a<e.length;a++){var s=e.__digit(a),u=t.__digit(a),_=(65535&u)+(65535&s)+o,f=(u>>>16)+(s>>>16)+(_>>>16);o=f>>>16,i.__setDigit(a,65535&_|f<<16)}for(;a<t.length;a++){var h=t.__digit(a),c=(65535&h)+o,g=(h>>>16)+(c>>>16);o=g>>>16,i.__setDigit(a,65535&c|g<<16)}return a<i.length&&i.__setDigit(a,o),i.__trim()}},{key:"__absoluteSub",value:function(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);for(var n=new l(t.length,r),i=0,o=0;o<e.length;o++){var a=t.__digit(o),s=e.__digit(o),u=(65535&a)-(65535&s)-i,_=(a>>>16)-(s>>>16)-(i=1&u>>>16);i=1&_>>>16,n.__setDigit(o,65535&u|_<<16)}for(;o<t.length;o++){var f=t.__digit(o),h=(65535&f)-i,c=(f>>>16)-(i=1&h>>>16);i=1&c>>>16,n.__setDigit(o,65535&h|c<<16)}return n.__trim()}},{key:"__absoluteAddOne",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length;null===r?r=new l(n,e):r.sign=e;for(var i=!0,o=0;o<n;o++){var a=t.__digit(o),s=-1===a;i&&(a=0|a+1),i=s,r.__setDigit(o,a)}return i&&r.__setDigitGrow(n,1),r}},{key:"__absoluteSubOne",value:function(t,e){for(var r=t.length,n=new l(e=e||r,!1),i=!0,o=0;o<r;o++){var a=t.__digit(o),s=0===a;i&&(a=0|a-1),i=s,n.__setDigit(o,a)}for(var u=r;u<e;u++)n.__setDigit(u,0);return n}},{key:"__absoluteAnd",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=o;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)&e.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteAndNot",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;n<i&&(o=n);var a=n;null===r?r=new l(a,!1):a=r.length;for(var s=0;s<o;s++)r.__setDigit(s,t.__digit(s)&~e.__digit(s));for(;s<n;s++)r.__setDigit(s,t.__digit(s));for(;s<a;s++)r.__setDigit(s,0);return r}},{key:"__absoluteOr",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)|e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteXor",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)^e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteCompare",value:function(t,e){var r=t.length-e.length;if(0!=r)return r;for(var n=t.length-1;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}},{key:"__multiplyAccumulate",value:function(t,e,r,n){if(0!==e){for(var i=65535&e,o=e>>>16,a=0,u=0,_=0,l=0;l<t.length;l++,n++){var f=r.__digit(n),h=65535&f,c=f>>>16,g=t.__digit(l),d=65535&g,p=g>>>16,v=s(d,i),y=s(d,o),b=s(p,i),m=s(p,o);a=(u=(y>>>16)+(b>>>16)+(65535&m)+(a=(c+=_+a+((h+=u+(65535&v))>>>16)+(v>>>16)+(65535&y)+(65535&b))>>>16))>>>16,u&=65535,_=m>>>16,f=65535&h|c<<16,r.__setDigit(n,f)}for(;0!==a||0!==u||0!==_;n++){var w=r.__digit(n),k=(65535&w)+u,D=(w>>>16)+(k>>>16)+_+a;u=0,_=0,a=D>>>16,w=65535&k|D<<16,r.__setDigit(n,w)}}}},{key:"__internalMultiplyAdd",value:function(t,e,r,n,i){for(var o=r,a=0,u=0;u<n;u++){var _=t.__digit(u),l=s(65535&_,e),f=(65535&l)+a+o;o=f>>>16;var h=s(_>>>16,e),c=(65535&h)+(l>>>16)+o;o=c>>>16,a=h>>>16,i.__setDigit(u,c<<16|65535&f)}if(i.length>n)for(i.__setDigit(n++,o+a);n<i.length;)i.__setDigit(n++,0);else if(0!==o+a)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(t,e,r){null===r&&(r=new l(t.length,!1));for(var n=0,i=2*t.length-1;0<=i;i-=2){var o=(n<<16|t.__halfDigit(i))>>>0,a=0|o/e,s=0|(o=((n=0|o%e)<<16|t.__halfDigit(i-1))>>>0)/e;n=0|o%e,r.__setDigit(i>>>1,a<<16|s)}return r}},{key:"__absoluteModSmall",value:function(t,e){for(var r=0,n=2*t.length-1;0<=n;n--)r=0|((r<<16|t.__halfDigit(n))>>>0)%e;return r}},{key:"__absoluteDivLarge",value:function(t,e,r,n){var i=e.__halfDigitLength(),o=e.length,a=t.__halfDigitLength()-i,u=null;r&&(u=new l(a+2>>>1,!1)).__initializeDigits();var _=new l(i+2>>>1,!1);_.__initializeDigits();var f=l.__clz16(e.__halfDigit(i-1));0<f&&(e=l.__specialLeftShift(e,f,0));for(var h=l.__specialLeftShift(t,f,1),c=e.__halfDigit(i-1),g=0,d=a;0<=d;d--){var p=65535,v=h.__halfDigit(d+i);if(v!==c){var y=(v<<16|h.__halfDigit(d+i-1))>>>0;p=0|y/c;for(var b=0|y%c,m=e.__halfDigit(i-2),w=h.__halfDigit(d+i-2);s(p,m)>>>0>(b<<16|w)>>>0&&(p--,!(65535<(b+=c))););}l.__internalMultiplyAdd(e,p,0,o,_);var k=h.__inplaceSub(_,d,i+1);0!==k&&(k=h.__inplaceAdd(e,d,i),h.__setHalfDigit(d+i,h.__halfDigit(d+i)+k),p--),r&&(1&d?g=p<<16:u.__setDigit(d>>>1,g|p))}return n?(h.__inplaceRightShift(f),r?{quotient:u,remainder:h}:h):r?u:void 0}},{key:"__clz16",value:function(t){return u(t)-16}},{key:"__specialLeftShift",value:function(t,e,r){var n=t.length,i=new l(n+r,!1);if(0===e){for(var o=0;o<n;o++)i.__setDigit(o,t.__digit(o));return 0<r&&i.__setDigit(n,0),i}for(var a,s=0,u=0;u<n;u++)a=t.__digit(u),i.__setDigit(u,a<<e|s),s=a>>>32-e;return 0<r&&i.__setDigit(n,s),i}},{key:"__leftShiftByAbsolute",value:function(t,e){var r=l.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");var n=r>>>5,i=31&r,o=t.length,a=0!==i&&0!=t.__digit(o-1)>>>32-i,s=o+n+(a?1:0),u=new l(s,t.sign);if(0===i){for(var _=0;_<n;_++)u.__setDigit(_,0);for(;_<s;_++)u.__setDigit(_,t.__digit(_-n))}else{for(var f=0,h=0;h<n;h++)u.__setDigit(h,0);for(var c,g=0;g<o;g++)c=t.__digit(g),u.__setDigit(g+n,c<<i|f),f=c>>>32-i;if(a)u.__setDigit(o+n,f);else if(0!==f)throw new Error("implementation bug")}return u.__trim()}},{key:"__rightShiftByAbsolute",value:function(t,e){var r=t.length,n=t.sign,i=l.__toShiftAmount(e);if(0>i)return l.__rightShiftByMaximum(n);var o=i>>>5,a=31&i,s=r-o;if(0>=s)return l.__rightShiftByMaximum(n);var u=!1;if(n)if(0!=(t.__digit(o)&(1<<a)-1))u=!0;else for(var _=0;_<o;_++)if(0!==t.__digit(_)){u=!0;break}u&&0===a&&0==~t.__digit(r-1)&&s++;var f=new l(s,n);if(0===a)for(var h=o;h<r;h++)f.__setDigit(h-o,t.__digit(h));else{for(var c,g=t.__digit(o)>>>a,d=r-o-1,p=0;p<d;p++)c=t.__digit(p+o+1),f.__setDigit(p,c<<32-a|g),g=c>>>a;f.__setDigit(d,g)}return u&&(f=l.__absoluteAddOne(f,!0,f)),f.__trim()}},{key:"__rightShiftByMaximum",value:function(t){return t?l.__oneDigit(1,!0):l.__zero()}},{key:"__toShiftAmount",value:function(t){if(1<t.length)return-1;var e=t.__unsignedDigit(0);return e>l.__kMaxLengthBits?-1:e}},{key:"__toPrimitive",value:function(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==t(e))return e;if(e.constructor===l)return e;var n=e[Symbol.toPrimitive];if(n){var i=n(r);if("object"!==t(i))return i;throw new TypeError("Cannot convert object to primitive value")}var o=e.valueOf;if(o){var a=o.call(e);if("object"!==t(a))return a}var s=e.toString;if(s){var u=s.call(e);if("object"!==t(u))return u}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(t){return l.__isBigInt(t)?t:+t}},{key:"__isBigInt",value:function(e){return"object"===t(e)&&e.constructor===l}},{key:"__truncateToNBits",value:function(t,e){for(var r=t+31>>>5,n=new l(r,e.sign),i=r-1,o=0;o<i;o++)n.__setDigit(o,e.__digit(o));var a=e.__digit(i);if(0!=(31&t)){var s=32-(31&t);a=a<<s>>>s}return n.__setDigit(i,a),n.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(t,e,r){for(var n=Math.min,i=t+31>>>5,o=new l(i,r),a=0,s=i-1,u=0,_=n(s,e.length);a<_;a++){var f=e.__digit(a),h=0-(65535&f)-u,c=0-(f>>>16)-(u=1&h>>>16);u=1&c>>>16,o.__setDigit(a,65535&h|c<<16)}for(;a<s;a++)o.__setDigit(a,0|-u);var g,d=s<e.length?e.__digit(s):0,p=31&t;if(0===p){var v=0-(65535&d)-u;g=65535&v|0-(d>>>16)-(u=1&v>>>16)<<16}else{var y=32-p,b=1<<32-y,m=(65535&b)-(65535&(d=d<<y>>>y))-u;g=65535&m|(b>>>16)-(d>>>16)-(u=1&m>>>16)<<16,g&=b-1}return o.__setDigit(s,g),o.__trim()}},{key:"__digitPow",value:function(t,e){for(var r=1;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}]),l}(u(Array));return l.__kMaxLength=33554432,l.__kMaxLengthBits=l.__kMaxLength<<5,l.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],l.__kBitsPerCharTableShift=5,l.__kBitsPerCharTableMultiplier=1<<l.__kBitsPerCharTableShift,l.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],l.__kBitConversionBuffer=new ArrayBuffer(8),l.__kBitConversionDouble=new Float64Array(l.__kBitConversionBuffer),l.__kBitConversionInts=new Int32Array(l.__kBitConversionBuffer),l}()})));const s={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await o(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),a=await i.json();if(a.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(a.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(a.error)}`);return a.result}};class u{constructor(t){return this.uri=t,new Proxy(this,s)}}function _(t){return a.BigInt(t)}function l(t){return"0x"+t.toString(16)}function f(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,a=r.length+n.length,s=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>a)throw new Error(s);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(s);if(u.find(t=>!n.includes(t)))throw new Error(s)}function h(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function c(t,e){if(h(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function g(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function d(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(f(r,t,["code_hash","hash_type","args"],[]),c(`${r}.code_hash`,t.code_hash),h(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function p(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){f(r,t,["tx_hash","index"],[]),c(`${r}.tx_hash`,t.tx_hash),g(`${r}.index`,t.index)}function v(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){f(r,t,["since","previous_output"],[]),g(`${r}.since`,t.since),e&&p(t.previous_output,{debugPath:`${r}.previous_output`})}function y(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){f(r,t,["capacity","lock"],["type"]),g(`${r}.capacity`,t.capacity),e&&(d(t.lock,{debugPath:`${r}.lock`}),t.type&&d(t.type,{debugPath:`${r}.type`}))}function b(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(f(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&p(t.out_point,{debugPath:`${r}.out_point`})}function m(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function w(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function k(t,e,r){g(`${t}.version`,e.version),m(`${t}.cell_deps`,e.cell_deps,w(b,r),r),m(`${t}.header_deps`,e.header_deps,c,r),m(`${t}.inputs`,e.inputs,w(v,r),r),m(`${t}.outputs`,e.outputs,w(y,r),r),m(`${t}.outputs_data`,e.outputs_data,h,r)}function D(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),k(r,t,e)}function B(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),k(r,t,e),m(`${r}.witnesses`,t.witnesses,h,e)}function A(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){g(`${t}.version`,e.version),g(`${t}.compact_target`,e.compact_target),g(`${t}.timestamp`,e.timestamp),g(`${t}.number`,e.number),g(`${t}.epoch`,e.epoch),c(`${t}.parent_hash`,e.parent_hash),c(`${t}.transactions_root`,e.transactions_root),c(`${t}.proposals_hash`,e.proposals_hash),c(`${t}.uncles_hash`,e.uncles_hash),c(`${t}.dao`,e.dao)}(r,t)}function P(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),h(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function T(t,e){if(h(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function S(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){f(r,t,["header","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.proposals`,t.proposals,T,e)}function E(t,{nestedValidation:e=!0,debugPath:r="block"}={}){f(r,t,["header","uncles","transactions","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.uncles`,t.uncles,w(S,e),e),m(`${r}.transactions`,t.transactions,w(B,e),e),m(`${r}.proposals`,t.proposals,T,e)}function x(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){f(r,t,["lock","message"],[]),h(`${r}.message`,t.message),e&&d(t.lock,{debugPath:`${r}.lock`})}function C(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){f(r,t,[],["lock","input_type","output_type"]),t.lock&&h(`${r}.lock`,t.lock),t.input_type&&h(`${r}.input_type`,t.input_type),t.output_type&&h(`${r}.output_type`,t.output_type)}var O=Object.freeze({__proto__:null,ValidateScript:d,ValidateOutPoint:p,ValidateCellInput:v,ValidateCellOutput:y,ValidateCellDep:b,ValidateRawTransaction:D,ValidateTransaction:B,ValidateRawHeader:A,ValidateHeader:P,ValidateUncleBlock:S,ValidateBlock:E,ValidateCellbaseWitness:x,ValidateWitnessArgs:C});function $(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function I(t,e,r){if(!((e=$(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function R(t,{validation:e=!0,debugPath:r="script"}={}){return t=I(r,t,{code_hash:$,hash_type:$,args:$}),e&&d(t,{debugPath:`(transformed) ${r}`}),t}function j(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=I(r,t,{tx_hash:$,index:$}),e&&p(t,{debugPath:`(transformed) ${r}`}),t}function M(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function z(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=I(r,t,{since:$,previous_output:M(j)}),e&&v(t,{debugPath:`(transformed) ${r}`}),t}function L(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=I(r,t,{capacity:$,lock:M(R),type:M(R)}),e&&y(t,{debugPath:`(transformed) ${r}`}),t}function N(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=I(r,t,{out_point:M(j),dep_type:$}),e&&b(t,{debugPath:`(transformed) ${r}`}),t}function F(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function U(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($),witnesses:F($)}),e&&B(t,{debugPath:`(transformed) ${r}`}),t}function V(t,{validation:e=!0,debugPath:r="header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$,nonce:$}),e&&P(t,{debugPath:`(transformed) ${r}`}),t}function q(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=I(r,t,{header:M(V),proposals:F($)}),e&&S(t,{debugPath:`(transformed) ${r}`}),t}var H=Object.freeze({__proto__:null,TransformScript:R,TransformOutPoint:j,TransformCellInput:z,TransformCellOutput:L,TransformCellDep:N,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($)}),e&&D(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:U,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$}),e&&A(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:V,TransformUncleBlock:q,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=I(r,t,{header:M(V),uncles:F(M(q)),transactions:F(M(U)),proposals:F($)}),e&&E(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=I(r,t,{lock:M(R),message:$}),e&&x(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=I(r,t,{lock:$,input_type:$,output_type:$}),e&&C(t,{debugPath:`(transformed) ${r}`}),t}});var G=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:n=!0,loadData:i=!1}={}){this.rpc=t,this.lockHash=new r(e).serializeJson(),this.skipCellWithContent=n,this.loadData=i}async*collect(){const t=_(await this.rpc.get_tip_block_number());let e=a.BigInt(0);for(;a.lessThanOrEqual(e,t);){let r=a.add(e,a.BigInt(100));a.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,l(e),l(r));for(const t of n)if(this.skipCellWithContent){if(t.type||a.greaterThan(_(t.output_data_len),a.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=a.add(r,a.BigInt(1))}}}});const W="0.5.0";export{l as BigIntToHexString,_ as HexStringToBigInt,u as RPC,r as Reader,W as VERSION,G as cell_collectors,H as transformers,O as validators};

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("stream")),r=t(require("http")),n=t(require("url")),i=t(require("https")),o=t(require("zlib"));class s{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class a{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class u{constructor(t){if("string"==typeof t){if(!t.startsWith("0x")||t.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new a(t)}if(t instanceof ArrayBuffer)return new s(t);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(t){const e=new ArrayBuffer(t.length),r=new DataView(e);for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n>255)throw new Error("fromRawString can only accept UTF-8 raw string!");r.setUint8(e,n)}return new s(e)}}const l=e.Readable,_=Symbol("buffer"),c=Symbol("type");class f{constructor(){this[c]="";const t=arguments[0],e=arguments[1],r=[];let n=0;if(t){const e=t,i=Number(e.length);for(let t=0;t<i;t++){const i=e[t];let o;o=i instanceof Buffer?i:ArrayBuffer.isView(i)?Buffer.from(i.buffer,i.byteOffset,i.byteLength):i instanceof ArrayBuffer?Buffer.from(i):i instanceof f?i[_]:Buffer.from("string"==typeof i?i:String(i)),n+=o.length,r.push(o)}}this[_]=Buffer.concat(r);let i=e&&void 0!==e.type&&String(e.type).toLowerCase();i&&!/[^\u0020-\u007E]/.test(i)&&(this[c]=i)}get size(){return this[_].length}get type(){return this[c]}text(){return Promise.resolve(this[_].toString())}arrayBuffer(){const t=this[_],e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return Promise.resolve(e)}stream(){const t=new l;return t._read=function(){},t.push(this[_]),t.push(null),t}toString(){return"[object Blob]"}slice(){const t=this.size,e=arguments[0],r=arguments[1];let n,i;n=void 0===e?0:e<0?Math.max(t+e,0):Math.min(e,t),i=void 0===r?t:r<0?Math.max(t+r,0):Math.min(r,t);const o=Math.max(i-n,0),s=this[_].slice(n,n+o),a=new f([],{type:arguments[2]});return a[_]=s,a}}function h(t,e,r){Error.call(this,t),this.message=t,this.type=e,r&&(this.code=this.errno=r.code),Error.captureStackTrace(this,this.constructor)}let g;Object.defineProperties(f.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(f.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="FetchError";try{g=require("encoding").convert}catch(t){}const d=Symbol("Body internals"),p=e.PassThrough;function b(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.size;let o=void 0===i?0:i;var s=n.timeout;let a=void 0===s?0:s;null==t?t=null:y(t)?t=Buffer.from(t.toString()):w(t)||Buffer.isBuffer(t)||("[object ArrayBuffer]"===Object.prototype.toString.call(t)?t=Buffer.from(t):ArrayBuffer.isView(t)?t=Buffer.from(t.buffer,t.byteOffset,t.byteLength):t instanceof e||(t=Buffer.from(String(t)))),this[d]={body:t,disturbed:!1,error:null},this.size=o,this.timeout=a,t instanceof e&&t.on("error",(function(t){const e="AbortError"===t.name?t:new h(`Invalid response body while trying to fetch ${r.url}: ${t.message}`,"system",t);r[d].error=e}))}function m(){var t=this;if(this[d].disturbed)return b.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[d].disturbed=!0,this[d].error)return b.Promise.reject(this[d].error);let r=this.body;if(null===r)return b.Promise.resolve(Buffer.alloc(0));if(w(r)&&(r=r.stream()),Buffer.isBuffer(r))return b.Promise.resolve(r);if(!(r instanceof e))return b.Promise.resolve(Buffer.alloc(0));let n=[],i=0,o=!1;return new b.Promise((function(e,s){let a;t.timeout&&(a=setTimeout((function(){o=!0,s(new h(`Response timeout while trying to fetch ${t.url} (over ${t.timeout}ms)`,"body-timeout"))}),t.timeout)),r.on("error",(function(e){"AbortError"===e.name?(o=!0,s(e)):s(new h(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e))})),r.on("data",(function(e){if(!o&&null!==e){if(t.size&&i+e.length>t.size)return o=!0,void s(new h(`content size at ${t.url} over limit: ${t.size}`,"max-size"));i+=e.length,n.push(e)}})),r.on("end",(function(){if(!o){clearTimeout(a);try{e(Buffer.concat(n,i))}catch(e){s(new h(`Could not create Buffer from response body for ${t.url}: ${e.message}`,"system",e))}}}))}))}function y(t){return"object"==typeof t&&"function"==typeof t.append&&"function"==typeof t.delete&&"function"==typeof t.get&&"function"==typeof t.getAll&&"function"==typeof t.has&&"function"==typeof t.set&&("URLSearchParams"===t.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(t)||"function"==typeof t.sort)}function w(t){return"object"==typeof t&&"function"==typeof t.arrayBuffer&&"string"==typeof t.type&&"function"==typeof t.stream&&"function"==typeof t.constructor&&"string"==typeof t.constructor.name&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag])}function v(t){let r,n,i=t.body;if(t.bodyUsed)throw new Error("cannot clone body after it is used");return i instanceof e&&"function"!=typeof i.getBoundary&&(r=new p,n=new p,i.pipe(r),i.pipe(n),t[d].body=r,i=n),i}function B(t){return null===t?null:"string"==typeof t?"text/plain;charset=UTF-8":y(t)?"application/x-www-form-urlencoded;charset=UTF-8":w(t)?t.type||null:Buffer.isBuffer(t)||"[object ArrayBuffer]"===Object.prototype.toString.call(t)||ArrayBuffer.isView(t)?null:"function"==typeof t.getBoundary?`multipart/form-data;boundary=${t.getBoundary()}`:t instanceof e?null:"text/plain;charset=UTF-8"}function D(t){const e=t.body;return null===e?0:w(e)?e.size:Buffer.isBuffer(e)?e.length:e&&"function"==typeof e.getLengthSync&&(e._lengthRetrievers&&0==e._lengthRetrievers.length||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}b.prototype={get body(){return this[d].body},get bodyUsed(){return this[d].disturbed},arrayBuffer(){return m.call(this).then((function(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}))},blob(){let t=this.headers&&this.headers.get("content-type")||"";return m.call(this).then((function(e){return Object.assign(new f([],{type:t.toLowerCase()}),{[_]:e})}))},json(){var t=this;return m.call(this).then((function(e){try{return JSON.parse(e.toString())}catch(e){return b.Promise.reject(new h(`invalid json response body at ${t.url} reason: ${e.message}`,"invalid-json"))}}))},text(){return m.call(this).then((function(t){return t.toString()}))},buffer(){return m.call(this)},textConverted(){var t=this;return m.call(this).then((function(e){return function(t,e){if("function"!=typeof g)throw new Error("The package `encoding` must be installed to use the textConverted() function");const r=e.get("content-type");let n,i,o="utf-8";r&&(n=/charset=([^;]*)/i.exec(r));i=t.slice(0,1024).toString(),!n&&i&&(n=/<meta.+?charset=(['"])(.+?)\1/i.exec(i));!n&&i&&(n=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(i),n&&(n=/charset=(.*)/i.exec(n.pop())));!n&&i&&(n=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(i));n&&(o=n.pop(),"gb2312"!==o&&"gbk"!==o||(o="gb18030"));return g(t,"UTF-8",o).toString()}(e,t.headers)}))}},Object.defineProperties(b.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),b.mixIn=function(t){for(const e of Object.getOwnPropertyNames(b.prototype))if(!(e in t)){const r=Object.getOwnPropertyDescriptor(b.prototype,e);Object.defineProperty(t,e,r)}},b.Promise=global.Promise;const S=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,T=/[^\t\x20-\x7e\x80-\xff]/;function P(t){if(t=`${t}`,S.test(t)||""===t)throw new TypeError(`${t} is not a legal HTTP header name`)}function C(t){if(t=`${t}`,T.test(t))throw new TypeError(`${t} is not a legal HTTP header value`)}function k(t,e){e=e.toLowerCase();for(const r in t)if(r.toLowerCase()===e)return r}const x=Symbol("map");class ${constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[x]=Object.create(null),t instanceof $){const e=t.raw(),r=Object.keys(e);for(const t of r)for(const r of e[t])this.append(t,r)}else if(null==t);else{if("object"!=typeof t)throw new TypeError("Provided initializer must be an object");{const e=t[Symbol.iterator];if(null!=e){if("function"!=typeof e)throw new TypeError("Header pairs must be iterable");const r=[];for(const e of t){if("object"!=typeof e||"function"!=typeof e[Symbol.iterator])throw new TypeError("Each header pair must be iterable");r.push(Array.from(e))}for(const t of r){if(2!==t.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(t[0],t[1])}}else for(const e of Object.keys(t)){const r=t[e];this.append(e,r)}}}}get(t){P(t=`${t}`);const e=k(this[x],t);return void 0===e?null:this[x][e].join(", ")}forEach(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=E(this),n=0;for(;n<r.length;){var i=r[n];const o=i[0],s=i[1];t.call(e,s,o,this),r=E(this),n++}}set(t,e){e=`${e}`,P(t=`${t}`),C(e);const r=k(this[x],t);this[x][void 0!==r?r:t]=[e]}append(t,e){e=`${e}`,P(t=`${t}`),C(e);const r=k(this[x],t);void 0!==r?this[x][r].push(e):this[x][t]=[e]}has(t){return P(t=`${t}`),void 0!==k(this[x],t)}delete(t){P(t=`${t}`);const e=k(this[x],t);void 0!==e&&delete this[x][e]}raw(){return this[x]}keys(){return O(this,"key")}values(){return O(this,"value")}[Symbol.iterator](){return O(this,"key+value")}}function E(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";const r=Object.keys(t[x]).sort();return r.map("key"===e?function(t){return t.toLowerCase()}:"value"===e?function(e){return t[x][e].join(", ")}:function(e){return[e.toLowerCase(),t[x][e].join(", ")]})}$.prototype.entries=$.prototype[Symbol.iterator],Object.defineProperty($.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties($.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const A=Symbol("internal");function O(t,e){const r=Object.create(j);return r[A]={target:t,kind:e,index:0},r}const j=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==j)throw new TypeError("Value of `this` is not a HeadersIterator");var t=this[A];const e=t.target,r=t.kind,n=t.index,i=E(e,r);return n>=i.length?{value:void 0,done:!0}:(this[A].index=n+1,{value:i[n],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function z(t){const e=Object.assign({__proto__:null},t[x]),r=k(t[x],"Host");return void 0!==r&&(e[r]=e[r][0]),e}Object.defineProperty(j,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const I=Symbol("Response internals"),R=r.STATUS_CODES;class L{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b.call(this,t,e);const r=e.status||200,n=new $(e.headers);if(null!=t&&!n.has("Content-Type")){const e=B(t);e&&n.append("Content-Type",e)}this[I]={url:e.url,status:r,statusText:e.statusText||R[r],headers:n,counter:e.counter}}get url(){return this[I].url||""}get status(){return this[I].status}get ok(){return this[I].status>=200&&this[I].status<300}get redirected(){return this[I].counter>0}get statusText(){return this[I].statusText}get headers(){return this[I].headers}clone(){return new L(v(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}b.mixIn(L.prototype),Object.defineProperties(L.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(L.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const M=Symbol("Request internals"),q=n.parse,V=n.format,N="destroy"in e.Readable.prototype;function H(t){return"object"==typeof t&&"object"==typeof t[M]}class U{constructor(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};H(t)?e=q(t.url):(e=t&&t.href?q(t.href):q(`${t}`),t={});let n=r.method||t.method||"GET";if(n=n.toUpperCase(),(null!=r.body||H(t)&&null!==t.body)&&("GET"===n||"HEAD"===n))throw new TypeError("Request with GET/HEAD method cannot have body");let i=null!=r.body?r.body:H(t)&&null!==t.body?v(t):null;b.call(this,i,{timeout:r.timeout||t.timeout||0,size:r.size||t.size||0});const o=new $(r.headers||t.headers||{});if(null!=i&&!o.has("Content-Type")){const t=B(i);t&&o.append("Content-Type",t)}let s=H(t)?t.signal:null;if("signal"in r&&(s=r.signal),null!=s&&!function(t){const e=t&&"object"==typeof t&&Object.getPrototypeOf(t);return!(!e||"AbortSignal"!==e.constructor.name)}(s))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[M]={method:n,redirect:r.redirect||t.redirect||"follow",headers:o,parsedURL:e,signal:s},this.follow=void 0!==r.follow?r.follow:void 0!==t.follow?t.follow:20,this.compress=void 0!==r.compress?r.compress:void 0===t.compress||t.compress,this.counter=r.counter||t.counter||0,this.agent=r.agent||t.agent}get method(){return this[M].method}get url(){return V(this[M].parsedURL)}get headers(){return this[M].headers}get redirect(){return this[M].redirect}get signal(){return this[M].signal}clone(){return new U(this)}}function F(t){Error.call(this,t),this.type="aborted",this.message=t,Error.captureStackTrace(this,this.constructor)}b.mixIn(U.prototype),Object.defineProperty(U.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(U.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),F.prototype=Object.create(Error.prototype),F.prototype.constructor=F,F.prototype.name="AbortError";const G=e.PassThrough,W=n.resolve;function J(t,n){if(!J.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return b.Promise=J.Promise,new J.Promise((function(s,a){const u=new U(t,n),l=function(t){const r=t[M].parsedURL,n=new $(t[M].headers);if(n.has("Accept")||n.set("Accept","*/*"),!r.protocol||!r.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(r.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(t.signal&&t.body instanceof e.Readable&&!N)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let i=null;if(null==t.body&&/^(POST|PUT)$/i.test(t.method)&&(i="0"),null!=t.body){const e=D(t);"number"==typeof e&&(i=String(e))}i&&n.set("Content-Length",i),n.has("User-Agent")||n.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),t.compress&&!n.has("Accept-Encoding")&&n.set("Accept-Encoding","gzip,deflate");let o=t.agent;return"function"==typeof o&&(o=o(r)),n.has("Connection")||o||n.set("Connection","close"),Object.assign({},r,{method:t.method,headers:z(n),agent:o})}(u),_=("https:"===l.protocol?i:r).request,c=u.signal;let f=null;const g=function(){let t=new F("The user aborted a request.");a(t),u.body&&u.body instanceof e.Readable&&u.body.destroy(t),f&&f.body&&f.body.emit("error",t)};if(c&&c.aborted)return void g();const d=function(){g(),m()},p=_(l);let b;function m(){p.abort(),c&&c.removeEventListener("abort",d),clearTimeout(b)}c&&c.addEventListener("abort",d),u.timeout&&p.once("socket",(function(t){b=setTimeout((function(){a(new h(`network timeout at: ${u.url}`,"request-timeout")),m()}),u.timeout)})),p.on("error",(function(t){a(new h(`request to ${u.url} failed, reason: ${t.message}`,"system",t)),m()})),p.on("response",(function(t){clearTimeout(b);const e=function(t){const e=new $;for(const r of Object.keys(t))if(!S.test(r))if(Array.isArray(t[r]))for(const n of t[r])T.test(n)||(void 0===e[x][r]?e[x][r]=[n]:e[x][r].push(n));else T.test(t[r])||(e[x][r]=[t[r]]);return e}(t.headers);if(J.isRedirect(t.statusCode)){const r=e.get("Location"),n=null===r?null:W(u.url,r);switch(u.redirect){case"error":return a(new h(`redirect mode is set to error: ${u.url}`,"no-redirect")),void m();case"manual":if(null!==n)try{e.set("Location",n)}catch(t){a(t)}break;case"follow":if(null===n)break;if(u.counter>=u.follow)return a(new h(`maximum redirect reached at: ${u.url}`,"max-redirect")),void m();const r={headers:new $(u.headers),follow:u.follow,counter:u.counter+1,agent:u.agent,compress:u.compress,method:u.method,body:u.body,signal:u.signal,timeout:u.timeout};return 303!==t.statusCode&&u.body&&null===D(u)?(a(new h("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void m()):(303!==t.statusCode&&(301!==t.statusCode&&302!==t.statusCode||"POST"!==u.method)||(r.method="GET",r.body=void 0,r.headers.delete("content-length")),s(J(new U(n,r))),void m())}}t.once("end",(function(){c&&c.removeEventListener("abort",d)}));let r=t.pipe(new G);const n={url:u.url,status:t.statusCode,statusText:t.statusMessage,headers:e,size:u.size,timeout:u.timeout,counter:u.counter},i=e.get("Content-Encoding");if(!u.compress||"HEAD"===u.method||null===i||204===t.statusCode||304===t.statusCode)return f=new L(r,n),void s(f);const l={flush:o.Z_SYNC_FLUSH,finishFlush:o.Z_SYNC_FLUSH};if("gzip"==i||"x-gzip"==i)return r=r.pipe(o.createGunzip(l)),f=new L(r,n),void s(f);if("deflate"!=i&&"x-deflate"!=i){if("br"==i&&"function"==typeof o.createBrotliDecompress)return r=r.pipe(o.createBrotliDecompress()),f=new L(r,n),void s(f);f=new L(r,n),s(f)}else{t.pipe(new G).once("data",(function(t){r=8==(15&t[0])?r.pipe(o.createInflate()):r.pipe(o.createInflateRaw()),f=new L(r,n),s(f)}))}})),function(t,e){const r=e.body;null===r?t.end():w(r)?r.stream().pipe(t):Buffer.isBuffer(r)?(t.write(r),t.end()):r.pipe(t)}(p,u)}))}J.isRedirect=function(t){return 301===t||302===t||303===t||307===t||308===t},J.Promise=global.Promise;var X,Q=(X=Object.freeze({__proto__:null,default:J,Headers:$,Request:U,Response:L,FetchError:h}))&&X.default||X,Z=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var r=Q.default||Q,n=function(t,e){return/^\/\//.test(t)&&(t="https:"+t),r.call(this,t,e)};t.exports=e=n,e.fetch=n,e.Headers=Q.Headers,e.Request=Q.Request,e.Response=Q.Response,e.default=n}));Z.fetch,Z.Headers,Z.Request,Z.Response;class K extends Array{constructor(t,e){if(t>K.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");super(t),this.sign=e}static BigInt(t){var e=Math.floor,r=Number.isFinite;if("number"==typeof t){if(0===t)return K.__zero();if((0|t)===t)return 0>t?K.__oneDigit(-t,!0):K.__oneDigit(t,!1);if(!r(t)||e(t)!==t)throw new RangeError("The number "+t+" cannot be converted to BigInt because it is not an integer");return K.__fromDouble(t)}if("string"==typeof t){const e=K.__fromString(t);if(null===e)throw new SyntaxError("Cannot convert "+t+" to a BigInt");return e}if("boolean"==typeof t)return!0===t?K.__oneDigit(1,!1):K.__zero();if("object"==typeof t){if(t.constructor===K)return t;const e=K.__toPrimitive(t);return K.BigInt(e)}throw new TypeError("Cannot convert "+t+" to a BigInt")}toDebugString(){const t=["BigInt["];for(const e of this)t.push((e?(e>>>0).toString(16):e)+", ");return t.push("]"),t.join("")}toString(t=10){if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?K.__toStringBasePowerOfTwo(this,t):K.__toStringGeneric(this,t,!1)}static toNumber(t){var e=Math.clz32;const r=t.length;if(0===r)return 0;if(1===r){const e=t.__unsignedDigit(0);return t.sign?-e:e}const n=t.__digit(r-1),i=e(n),o=32*r-i;if(1024<o)return t.sign?-1/0:1/0;let s=o-1,a=n,u=r-1;const l=i+1;let _=32===l?0:a<<l;_>>>=12;const c=l-12;let f=12<=l?0:a<<20+l,h=20+l;0<c&&0<u&&(u--,a=t.__digit(u),_|=a>>>32-c,f=a<<c,h=c),0<h&&0<u&&(u--,a=t.__digit(u),f|=a>>>32-h,h-=32);const g=K.__decideRounding(t,h,u,a);if((1===g||0===g&&1==(1&f))&&(f=f+1>>>0,0==f&&(_++,0!=_>>>20&&(_=0,s++,1023<s))))return t.sign?-1/0:1/0;const d=t.sign?-2147483648:0;return s=s+1023<<20,K.__kBitConversionInts[1]=d|s|_,K.__kBitConversionInts[0]=f,K.__kBitConversionDouble[0]}static unaryMinus(t){if(0===t.length)return t;const e=t.__copy();return e.sign=!t.sign,e}static bitwiseNot(t){return t.sign?K.__absoluteSubOne(t).__trim():K.__absoluteAddOne(t,!0)}static exponentiate(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return K.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?K.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");let r=e.__unsignedDigit(0);if(1===r)return t;if(r>=K.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){const e=1+(r>>>5),n=t.sign&&0!=(1&r),i=new K(e,n);i.__initializeDigits();const o=1<<(31&r);return i.__setDigit(e-1,o),i}let n=null,i=t;for(0!=(1&r)&&(n=t),r>>=1;0!==r;r>>=1)i=K.multiply(i,i),0!=(1&r)&&(n=null===n?i:K.multiply(n,i));return n}static multiply(t,e){if(0===t.length)return t;if(0===e.length)return e;let r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;const n=new K(r,t.sign!==e.sign);n.__initializeDigits();for(let r=0;r<t.length;r++)K.__multiplyAccumulate(e,t.__digit(r),n,r);return n.__trim()}static divide(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>K.__absoluteCompare(t,e))return K.__zero();const r=t.sign!==e.sign,n=e.__unsignedDigit(0);let i;if(1===e.length&&65535>=n){if(1===n)return r===t.sign?t:K.unaryMinus(t);i=K.__absoluteDivSmall(t,n,null)}else i=K.__absoluteDivLarge(t,e,!0,!1);return i.sign=r,i.__trim()}static remainder(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>K.__absoluteCompare(t,e))return t;const r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return K.__zero();const e=K.__absoluteModSmall(t,r);return 0===e?K.__zero():K.__oneDigit(e,t.sign)}const n=K.__absoluteDivLarge(t,e,!1,!0);return n.sign=t.sign,n.__trim()}static add(t,e){const r=t.sign;return r===e.sign?K.__absoluteAdd(t,e,r):0<=K.__absoluteCompare(t,e)?K.__absoluteSub(t,e,r):K.__absoluteSub(e,t,!r)}static subtract(t,e){const r=t.sign;return r===e.sign?0<=K.__absoluteCompare(t,e)?K.__absoluteSub(t,e,r):K.__absoluteSub(e,t,!r):K.__absoluteAdd(t,e,r)}static leftShift(t,e){return 0===e.length||0===t.length?t:e.sign?K.__rightShiftByAbsolute(t,e):K.__leftShiftByAbsolute(t,e)}static signedRightShift(t,e){return 0===e.length||0===t.length?t:e.sign?K.__leftShiftByAbsolute(t,e):K.__rightShiftByAbsolute(t,e)}static unsignedRightShift(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}static lessThan(t,e){return 0>K.__compareToBigInt(t,e)}static lessThanOrEqual(t,e){return 0>=K.__compareToBigInt(t,e)}static greaterThan(t,e){return 0<K.__compareToBigInt(t,e)}static greaterThanOrEqual(t,e){return 0<=K.__compareToBigInt(t,e)}static equal(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}static notEqual(t,e){return!K.equal(t,e)}static bitwiseAnd(t,e){var r=Math.max;if(!t.sign&&!e.sign)return K.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){const n=r(t.length,e.length)+1;let i=K.__absoluteSubOne(t,n);const o=K.__absoluteSubOne(e);return i=K.__absoluteOr(i,o,i),K.__absoluteAddOne(i,!0,i).__trim()}return t.sign&&([t,e]=[e,t]),K.__absoluteAndNot(t,K.__absoluteSubOne(e)).__trim()}static bitwiseXor(t,e){var r=Math.max;if(!t.sign&&!e.sign)return K.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){const n=r(t.length,e.length),i=K.__absoluteSubOne(t,n),o=K.__absoluteSubOne(e);return K.__absoluteXor(i,o,i).__trim()}const n=r(t.length,e.length)+1;t.sign&&([t,e]=[e,t]);let i=K.__absoluteSubOne(e,n);return i=K.__absoluteXor(i,t,i),K.__absoluteAddOne(i,!0,i).__trim()}static bitwiseOr(t,e){const r=(0,Math.max)(t.length,e.length);if(!t.sign&&!e.sign)return K.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){let n=K.__absoluteSubOne(t,r);const i=K.__absoluteSubOne(e);return n=K.__absoluteAnd(n,i,n),K.__absoluteAddOne(n,!0,n).__trim()}t.sign&&([t,e]=[e,t]);let n=K.__absoluteSubOne(e,r);return n=K.__absoluteAndNot(n,t,n),K.__absoluteAddOne(n,!0,n).__trim()}static asIntN(t,e){if(0===e.length)return e;if(0===t)return K.__zero();if(t>=K.__kMaxLengthBits)return e;const r=t+31>>>5;if(e.length<r)return e;const n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return K.__truncateToNBits(t,e);if(!e.sign)return K.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(let n=r-2;0<=n;n--)if(0!==e.__digit(n))return K.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:K.__truncateToNBits(t,e)}return K.__truncateAndSubFromPowerOfTwo(t,e,!1)}static asUintN(t,e){if(0===e.length)return e;if(0===t)return K.__zero();if(e.sign){if(t>K.__kMaxLengthBits)throw new RangeError("BigInt too big");return K.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=K.__kMaxLengthBits)return e;const r=t+31>>>5;if(e.length<r)return e;const n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return K.__truncateToNBits(t,e)}static ADD(t,e){if(t=K.__toPrimitive(t),e=K.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=K.__toNumeric(t),e=K.__toNumeric(e),K.__isBigInt(t)&&K.__isBigInt(e))return K.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}static LT(t,e){return K.__compare(t,e,0)}static LE(t,e){return K.__compare(t,e,1)}static GT(t,e){return K.__compare(t,e,2)}static GE(t,e){return K.__compare(t,e,3)}static EQ(t,e){for(;;){if(K.__isBigInt(t))return K.__isBigInt(e)?K.equal(t,e):K.EQ(e,t);if("number"==typeof t){if(K.__isBigInt(e))return K.__equalToNumber(e,t);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("string"==typeof t){if(K.__isBigInt(e))return null!==(t=K.__fromString(t))&&K.equal(t,e);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("boolean"==typeof t){if(K.__isBigInt(e))return K.__equalToNumber(e,+t);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("symbol"==typeof t){if(K.__isBigInt(e))return!1;if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else{if("object"!=typeof t)return t==e;if("object"==typeof e&&e.constructor!==K)return t==e;t=K.__toPrimitive(t)}}}static NE(t,e){return!K.EQ(t,e)}static __zero(){return new K(0,!1)}static __oneDigit(t,e){const r=new K(1,e);return r.__setDigit(0,t),r}__copy(){const t=new K(this.length,this.sign);for(let e=0;e<this.length;e++)t[e]=this[e];return t}__trim(){let t=this.length,e=this[t-1];for(;0===e;)t--,e=this[t-1],this.pop();return 0===t&&(this.sign=!1),this}__initializeDigits(){for(let t=0;t<this.length;t++)this[t]=0}static __decideRounding(t,e,r,n){if(0<e)return-1;let i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}let o=1<<i;if(0==(n&o))return-1;if(o-=1,0!=(n&o))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}static __fromDouble(t){K.__kBitConversionDouble[0]=t;const e=(2047&K.__kBitConversionInts[1]>>>20)-1023,r=1+(e>>>5),n=new K(r,0>t);let i=1048575&K.__kBitConversionInts[1]|1048576,o=K.__kBitConversionInts[0];const s=31&e;let a,u=0;if(s<20){const t=20-s;u=t+32,a=i>>>t,i=i<<32-t|o>>>t,o<<=32-t}else if(20===s)u=32,a=i,i=o;else{const t=s-20;u=32-t,a=i<<t|o>>>32-t,i=o<<t}n.__setDigit(r-1,a);for(let t=r-2;0<=t;t--)0<u?(u-=32,a=i,i=o):a=0,n.__setDigit(t,a);return n.__trim()}static __isWhitespace(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}static __fromString(t,e=0){let r=0;const n=t.length;let i=0;if(i===n)return K.__zero();let o=t.charCodeAt(i);for(;K.__isWhitespace(o);){if(++i===n)return K.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return K.__zero();if(o=t.charCodeAt(i),88===o||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return K.__zero();if(o=t.charCodeAt(i),88===o||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return K.__zero();o=t.charCodeAt(i)}const s=n-i;let a=K.__kMaxBitsPerChar[e],u=K.__kBitsPerCharTableMultiplier-1;if(s>1073741824/a)return null;const l=a*s+u>>>K.__kBitsPerCharTableShift,_=new K(l+31>>>5,!1),c=10>e?e:10,f=10<e?e-10:0;if(0==(e&e-1)){a>>=K.__kBitsPerCharTableShift;const e=[],r=[];let s=!1;do{let u=0,l=0;for(;;){let e;if(o-48>>>0<c)e=o-48;else{if(!((32|o)-97>>>0<f)){s=!0;break}e=(32|o)-87}if(l+=a,u=u<<a|e,++i===n){s=!0;break}if(o=t.charCodeAt(i),32<l+a)break}e.push(u),r.push(l)}while(!s);K.__fillFromParts(_,e,r)}else{_.__initializeDigits();let r=!1,s=0;do{let l=0,h=1;for(;;){let a;if(o-48>>>0<c)a=o-48;else{if(!((32|o)-97>>>0<f)){r=!0;break}a=(32|o)-87}const u=h*e;if(4294967295<u)break;if(h=u,l=l*e+a,s++,++i===n){r=!0;break}o=t.charCodeAt(i)}u=32*K.__kBitsPerCharTableMultiplier-1;const g=a*s+u>>>K.__kBitsPerCharTableShift+5;_.__inplaceMultiplyAdd(h,l,g)}while(!r)}if(i!==n){if(!K.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!K.__isWhitespace(o))return null}return 0!=r&&10!==e?null:(_.sign=-1==r,_.__trim())}static __fillFromParts(t,e,r){let n=0,i=0,o=0;for(let s=e.length-1;0<=s;s--){const a=e[s],u=r[s];i|=a<<o,o+=u,32===o?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),o-=32,i=a>>>u-o)}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}static __toStringBasePowerOfTwo(t,e){var r=Math.clz32;const n=t.length;let i=e-1;i=(85&i>>>1)+(85&i),i=(51&i>>>2)+(51&i),i=(15&i>>>4)+(15&i);const o=i,s=e-1,a=t.__digit(n-1);let u=0|(32*n-r(a)+o-1)/o;if(t.sign&&u++,268435456<u)throw new Error("string too long");const l=Array(u);let _=u-1,c=0,f=0;for(let e=0;e<n-1;e++){const r=t.__digit(e),n=(c|r<<f)&s;l[_--]=K.__kConversionChars[n];const i=o-f;for(c=r>>>i,f=32-i;f>=o;)l[_--]=K.__kConversionChars[c&s],c>>>=o,f-=o}const h=(c|a<<f)&s;for(l[_--]=K.__kConversionChars[h],c=a>>>o-f;0!==c;)l[_--]=K.__kConversionChars[c&s],c>>>=o;if(t.sign&&(l[_--]="-"),-1!=_)throw new Error("implementation bug");return l.join("")}static __toStringGeneric(t,e,r){var n=Math.clz32;const i=t.length;if(0===i)return"";if(1===i){let n=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(n="-"+n),n}const o=32*i-n(t.__digit(i-1)),s=K.__kMaxBitsPerChar[e]-1;let a=o*K.__kBitsPerCharTableMultiplier;a+=s-1,a=0|a/s;const u=a+1>>1,l=K.exponentiate(K.__oneDigit(e,!1),K.__oneDigit(u,!1));let _,c;const f=l.__unsignedDigit(0);if(1===l.length&&65535>=f){_=new K(t.length,!1),_.__initializeDigits();let r=0;for(let e=2*t.length-1;0<=e;e--){const n=r<<16|t.__halfDigit(e);_.__setHalfDigit(e,0|n/f),r=0|n%f}c=r.toString(e)}else{const r=K.__absoluteDivLarge(t,l,!0,!0);_=r.quotient;const n=r.remainder.__trim();c=K.__toStringGeneric(n,e,!0)}_.__trim();let h=K.__toStringGeneric(_,e,!0);for(;c.length<u;)c="0"+c;return!1===r&&t.sign&&(h="-"+h),h+c}static __unequalSign(t){return t?-1:1}static __absoluteGreater(t){return t?-1:1}static __absoluteLess(t){return t?1:-1}static __compareToBigInt(t,e){const r=t.sign;if(r!==e.sign)return K.__unequalSign(r);const n=K.__absoluteCompare(t,e);return 0<n?K.__absoluteGreater(r):0>n?K.__absoluteLess(r):0}static __compareToNumber(t,e){if(!0|e){const r=t.sign,n=0>e;if(r!==n)return K.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return K.__absoluteGreater(r);const i=Math.abs(e),o=t.__unsignedDigit(0);return o>i?K.__absoluteGreater(r):o<i?K.__absoluteLess(r):0}return K.__compareToDouble(t,e)}static __compareToDouble(t,e){var r=Math.clz32;if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;const n=t.sign;if(n!==0>e)return K.__unequalSign(n);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;K.__kBitConversionDouble[0]=e;const i=2047&K.__kBitConversionInts[1]>>>20;if(2047==i)throw new Error("implementation bug: handled elsewhere");const o=i-1023;if(0>o)return K.__absoluteGreater(n);const s=t.length;let a=t.__digit(s-1);const u=r(a),l=32*s-u,_=o+1;if(l<_)return K.__absoluteLess(n);if(l>_)return K.__absoluteGreater(n);let c=1048576|1048575&K.__kBitConversionInts[1],f=K.__kBitConversionInts[0];const h=31-u;if(h!==(l-1)%31)throw new Error("implementation bug");let g,d=0;if(20>h){const t=20-h;d=t+32,g=c>>>t,c=c<<32-t|f>>>t,f<<=32-t}else if(20===h)d=32,g=c,c=f;else{const t=h-20;d=32-t,g=c<<t|f>>>32-t,c=f<<t}if(a>>>=0,g>>>=0,a>g)return K.__absoluteGreater(n);if(a<g)return K.__absoluteLess(n);for(let e=s-2;0<=e;e--){0<d?(d-=32,g=c>>>0,c=f,f=0):g=0;const r=t.__unsignedDigit(e);if(r>g)return K.__absoluteGreater(n);if(r<g)return K.__absoluteLess(n)}if(0!==c||0!==f){if(0===d)throw new Error("implementation bug");return K.__absoluteLess(n)}return 0}static __equalToNumber(t,e){var r=Math.abs;return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===r(e):0===K.__compareToDouble(t,e)}static __comparisonResultToBool(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}static __compare(t,e,r){if(t=K.__toPrimitive(t),e=K.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(K.__isBigInt(t)&&"string"==typeof e)return null!==(e=K.__fromString(e))&&K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if("string"==typeof t&&K.__isBigInt(e))return null!==(t=K.__fromString(t))&&K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if(t=K.__toNumeric(t),e=K.__toNumeric(e),K.__isBigInt(t)){if(K.__isBigInt(e))return K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return K.__comparisonResultToBool(K.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(K.__isBigInt(e))return K.__comparisonResultToBool(K.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}__clzmsd(){return Math.clz32(this[this.length-1])}static __absoluteAdd(t,e,r){if(t.length<e.length)return K.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:K.unaryMinus(t);let n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;const i=new K(n,r);let o=0,s=0;for(;s<e.length;s++){const r=e.__digit(s),n=t.__digit(s),a=(65535&n)+(65535&r)+o,u=(n>>>16)+(r>>>16)+(a>>>16);o=u>>>16,i.__setDigit(s,65535&a|u<<16)}for(;s<t.length;s++){const e=t.__digit(s),r=(65535&e)+o,n=(e>>>16)+(r>>>16);o=n>>>16,i.__setDigit(s,65535&r|n<<16)}return s<i.length&&i.__setDigit(s,o),i.__trim()}static __absoluteSub(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:K.unaryMinus(t);const n=new K(t.length,r);let i=0,o=0;for(;o<e.length;o++){const r=t.__digit(o),s=e.__digit(o),a=(65535&r)-(65535&s)-i;i=1&a>>>16;const u=(r>>>16)-(s>>>16)-i;i=1&u>>>16,n.__setDigit(o,65535&a|u<<16)}for(;o<t.length;o++){const e=t.__digit(o),r=(65535&e)-i;i=1&r>>>16;const s=(e>>>16)-i;i=1&s>>>16,n.__setDigit(o,65535&r|s<<16)}return n.__trim()}static __absoluteAddOne(t,e,r=null){const n=t.length;null===r?r=new K(n,e):r.sign=e;let i=!0;for(let e,o=0;o<n;o++){e=t.__digit(o);const n=-1===e;i&&(e=0|e+1),i=n,r.__setDigit(o,e)}return i&&r.__setDigitGrow(n,1),r}static __absoluteSubOne(t,e){const r=t.length,n=new K(e=e||r,!1);let i=!0;for(let e,o=0;o<r;o++){e=t.__digit(o);const r=0===e;i&&(e=0|e-1),i=r,n.__setDigit(o,e)}for(let t=r;t<e;t++)n.__setDigit(t,0);return n}static __absoluteAnd(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=o;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)&e.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteAndNot(t,e,r=null){const n=t.length,i=e.length;let o=i;n<i&&(o=n);let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)&~e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteOr(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)|e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteXor(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)^e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteCompare(t,e){const r=t.length-e.length;if(0!=r)return r;let n=t.length-1;for(;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}static __multiplyAccumulate(t,e,r,n){var i=Math.imul;if(0===e)return;const o=65535&e,s=e>>>16;let a=0,u=0,l=0;for(let e=0;e<t.length;e++,n++){let _=r.__digit(n),c=65535&_,f=_>>>16;const h=t.__digit(e),g=65535&h,d=h>>>16,p=i(g,o),b=i(g,s),m=i(d,o),y=i(d,s);c+=u+(65535&p),f+=l+a+(c>>>16)+(p>>>16)+(65535&b)+(65535&m),a=f>>>16,u=(b>>>16)+(m>>>16)+(65535&y)+a,a=u>>>16,u&=65535,l=y>>>16,_=65535&c|f<<16,r.__setDigit(n,_)}for(;0!=a||0!==u||0!==l;n++){let t=r.__digit(n);const e=(65535&t)+u,i=(t>>>16)+(e>>>16)+l+a;u=0,l=0,a=i>>>16,t=65535&e|i<<16,r.__setDigit(n,t)}}static __internalMultiplyAdd(t,e,r,n,i){var o=Math.imul;let s=r,a=0;for(let r=0;r<n;r++){const n=t.__digit(r),u=o(65535&n,e),l=(65535&u)+a+s;s=l>>>16;const _=o(n>>>16,e),c=(65535&_)+(u>>>16)+s;s=c>>>16,a=_>>>16,i.__setDigit(r,c<<16|65535&l)}if(i.length>n)for(i.__setDigit(n++,s+a);n<i.length;)i.__setDigit(n++,0);else if(0!==s+a)throw new Error("implementation bug")}__inplaceMultiplyAdd(t,e,r){var n=Math.imul;r>this.length&&(r=this.length);const i=65535&t,o=t>>>16;let s=0,a=65535&e,u=e>>>16;for(let t=0;t<r;t++){const e=this.__digit(t),r=65535&e,l=e>>>16,_=n(r,i),c=n(r,o),f=n(l,i),h=n(l,o),g=a+(65535&_),d=u+s+(g>>>16)+(_>>>16)+(65535&c)+(65535&f);a=(c>>>16)+(f>>>16)+(65535&h)+(d>>>16),s=a>>>16,a&=65535,u=h>>>16,this.__setDigit(t,65535&g|d<<16)}if(0!=s||0!==a||0!==u)throw new Error("implementation bug")}static __absoluteDivSmall(t,e,r){null===r&&(r=new K(t.length,!1));let n=0;for(let i,o=2*t.length-1;0<=o;o-=2){i=(n<<16|t.__halfDigit(o))>>>0;const s=0|i/e;n=0|i%e,i=(n<<16|t.__halfDigit(o-1))>>>0;const a=0|i/e;n=0|i%e,r.__setDigit(o>>>1,s<<16|a)}return r}static __absoluteModSmall(t,e){let r=0;for(let n=2*t.length-1;0<=n;n--){r=0|((r<<16|t.__halfDigit(n))>>>0)%e}return r}static __absoluteDivLarge(t,e,r,n){var i=Math.imul;const o=e.__halfDigitLength(),s=e.length,a=t.__halfDigitLength()-o;let u=null;r&&(u=new K(a+2>>>1,!1),u.__initializeDigits());const l=new K(o+2>>>1,!1);l.__initializeDigits();const _=K.__clz16(e.__halfDigit(o-1));0<_&&(e=K.__specialLeftShift(e,_,0));const c=K.__specialLeftShift(t,_,1),f=e.__halfDigit(o-1);let h=0;for(let t,n=a;0<=n;n--){t=65535;const a=c.__halfDigit(n+o);if(a!==f){const r=(a<<16|c.__halfDigit(n+o-1))>>>0;t=0|r/f;let s=0|r%f;const u=e.__halfDigit(o-2),l=c.__halfDigit(n+o-2);for(;i(t,u)>>>0>(s<<16|l)>>>0&&(t--,s+=f,!(65535<s)););}K.__internalMultiplyAdd(e,t,0,s,l);let _=c.__inplaceSub(l,n,o+1);0!==_&&(_=c.__inplaceAdd(e,n,o),c.__setHalfDigit(n+o,c.__halfDigit(n+o)+_),t--),r&&(1&n?h=t<<16:u.__setDigit(n>>>1,h|t))}return n?(c.__inplaceRightShift(_),r?{quotient:u,remainder:c}:c):r?u:void 0}static __clz16(t){return Math.clz32(t)-16}__inplaceAdd(t,e,r){let n=0;for(let i=0;i<r;i++){const r=this.__halfDigit(e+i)+t.__halfDigit(i)+n;n=r>>>16,this.__setHalfDigit(e+i,r)}return n}__inplaceSub(t,e,r){let n=0;if(1&e){e>>=1;let i=this.__digit(e),o=65535&i,s=0;for(;s<r-1>>>1;s++){const r=t.__digit(s),a=(i>>>16)-(65535&r)-n;n=1&a>>>16,this.__setDigit(e+s,a<<16|65535&o),i=this.__digit(e+s+1),o=(65535&i)-(r>>>16)-n,n=1&o>>>16}const a=t.__digit(s),u=(i>>>16)-(65535&a)-n;if(n=1&u>>>16,this.__setDigit(e+s,u<<16|65535&o),e+s+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(i=this.__digit(e+s+1),o=(65535&i)-(a>>>16)-n,n=1&o>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;let i=0;for(;i<t.length-1;i++){const r=this.__digit(e+i),o=t.__digit(i),s=(65535&r)-(65535&o)-n;n=1&s>>>16;const a=(r>>>16)-(o>>>16)-n;n=1&a>>>16,this.__setDigit(e+i,a<<16|65535&s)}const o=this.__digit(e+i),s=t.__digit(i),a=(65535&o)-(65535&s)-n;n=1&a>>>16;let u=0;0==(1&r)&&(u=(o>>>16)-(s>>>16)-n,n=1&u>>>16),this.__setDigit(e+i,u<<16|65535&a)}return n}__inplaceRightShift(t){if(0===t)return;let e=this.__digit(0)>>>t;const r=this.length-1;for(let n=0;n<r;n++){const r=this.__digit(n+1);this.__setDigit(n,r<<32-t|e),e=r>>>t}this.__setDigit(r,e)}static __specialLeftShift(t,e,r){const n=t.length,i=new K(n+r,!1);if(0===e){for(let e=0;e<n;e++)i.__setDigit(e,t.__digit(e));return 0<r&&i.__setDigit(n,0),i}let o=0;for(let r=0;r<n;r++){const n=t.__digit(r);i.__setDigit(r,n<<e|o),o=n>>>32-e}return 0<r&&i.__setDigit(n,o),i}static __leftShiftByAbsolute(t,e){const r=K.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");const n=r>>>5,i=31&r,o=t.length,s=0!==i&&0!=t.__digit(o-1)>>>32-i,a=o+n+(s?1:0),u=new K(a,t.sign);if(0===i){let e=0;for(;e<n;e++)u.__setDigit(e,0);for(;e<a;e++)u.__setDigit(e,t.__digit(e-n))}else{let e=0;for(let t=0;t<n;t++)u.__setDigit(t,0);for(let r=0;r<o;r++){const o=t.__digit(r);u.__setDigit(r+n,o<<i|e),e=o>>>32-i}if(s)u.__setDigit(o+n,e);else if(0!=e)throw new Error("implementation bug")}return u.__trim()}static __rightShiftByAbsolute(t,e){const r=t.length,n=t.sign,i=K.__toShiftAmount(e);if(0>i)return K.__rightShiftByMaximum(n);const o=i>>>5,s=31&i;let a=r-o;if(0>=a)return K.__rightShiftByMaximum(n);let u=!1;if(n)if(0!=(t.__digit(o)&(1<<s)-1))u=!0;else for(let e=0;e<o;e++)if(0!==t.__digit(e)){u=!0;break}if(u&&0===s){0==~t.__digit(r-1)&&a++}let l=new K(a,n);if(0===s)for(let e=o;e<r;e++)l.__setDigit(e-o,t.__digit(e));else{let e=t.__digit(o)>>>s;const n=r-o-1;for(let r=0;r<n;r++){const n=t.__digit(r+o+1);l.__setDigit(r,n<<32-s|e),e=n>>>s}l.__setDigit(n,e)}return u&&(l=K.__absoluteAddOne(l,!0,l)),l.__trim()}static __rightShiftByMaximum(t){return t?K.__oneDigit(1,!0):K.__zero()}static __toShiftAmount(t){if(1<t.length)return-1;const e=t.__unsignedDigit(0);return e>K.__kMaxLengthBits?-1:e}static __toPrimitive(t,e="default"){if("object"!=typeof t)return t;if(t.constructor===K)return t;const r=t[Symbol.toPrimitive];if(r){const t=r(e);if("object"!=typeof t)return t;throw new TypeError("Cannot convert object to primitive value")}const n=t.valueOf;if(n){const e=n.call(t);if("object"!=typeof e)return e}const i=t.toString;if(i){const e=i.call(t);if("object"!=typeof e)return e}throw new TypeError("Cannot convert object to primitive value")}static __toNumeric(t){return K.__isBigInt(t)?t:+t}static __isBigInt(t){return"object"==typeof t&&t.constructor===K}static __truncateToNBits(t,e){const r=t+31>>>5,n=new K(r,e.sign),i=r-1;for(let t=0;t<i;t++)n.__setDigit(t,e.__digit(t));let o=e.__digit(i);if(0!=(31&t)){const e=32-(31&t);o=o<<e>>>e}return n.__setDigit(i,o),n.__trim()}static __truncateAndSubFromPowerOfTwo(t,e,r){var n=Math.min;const i=t+31>>>5,o=new K(i,r);let s=0;const a=i-1;let u=0;for(const t=n(a,e.length);s<t;s++){const t=e.__digit(s),r=0-(65535&t)-u;u=1&r>>>16;const n=0-(t>>>16)-u;u=1&n>>>16,o.__setDigit(s,65535&r|n<<16)}for(;s<a;s++)o.__setDigit(s,0|-u);let l=a<e.length?e.__digit(a):0;const _=31&t;let c;if(0==_){const t=0-(65535&l)-u;u=1&t>>>16,c=65535&t|0-(l>>>16)-u<<16}else{const t=32-_;l=l<<t>>>t;const e=1<<32-t,r=(65535&e)-(65535&l)-u;u=1&r>>>16,c=65535&r|(e>>>16)-(l>>>16)-u<<16,c&=e-1}return o.__setDigit(a,c),o.__trim()}__digit(t){return this[t]}__unsignedDigit(t){return this[t]>>>0}__setDigit(t,e){this[t]=0|e}__setDigitGrow(t,e){this[t]=0|e}__halfDigitLength(){const t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}__halfDigit(t){return 65535&this[t>>>1]>>>((1&t)<<4)}__setHalfDigit(t,e){const r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}static __digitPow(t,e){let r=1;for(;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}K.__kMaxLength=33554432,K.__kMaxLengthBits=K.__kMaxLength<<5,K.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],K.__kBitsPerCharTableShift=5,K.__kBitsPerCharTableMultiplier=1<<K.__kBitsPerCharTableShift,K.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],K.__kBitConversionBuffer=new ArrayBuffer(8),K.__kBitConversionDouble=new Float64Array(K.__kBitConversionBuffer),K.__kBitConversionInts=new Int32Array(K.__kBitConversionBuffer);const Y={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await Z(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),o=await i.json();if(o.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(o.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(o.error)}`);return o.result}};function tt(t){return K.BigInt(t)}function et(t){return"0x"+t.toString(16)}function rt(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,s=r.length+n.length,a=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>s)throw new Error(a);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(a);if(u.find(t=>!n.includes(t)))throw new Error(a)}function nt(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function it(t,e){if(nt(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function ot(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function st(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(rt(r,t,["code_hash","hash_type","args"],[]),it(`${r}.code_hash`,t.code_hash),nt(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function at(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){rt(r,t,["tx_hash","index"],[]),it(`${r}.tx_hash`,t.tx_hash),ot(`${r}.index`,t.index)}function ut(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){rt(r,t,["since","previous_output"],[]),ot(`${r}.since`,t.since),e&&at(t.previous_output,{debugPath:`${r}.previous_output`})}function lt(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){rt(r,t,["capacity","lock"],["type"]),ot(`${r}.capacity`,t.capacity),e&&(st(t.lock,{debugPath:`${r}.lock`}),t.type&&st(t.type,{debugPath:`${r}.type`}))}function _t(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(rt(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&at(t.out_point,{debugPath:`${r}.out_point`})}function ct(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function ft(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function ht(t,e,r){ot(`${t}.version`,e.version),ct(`${t}.cell_deps`,e.cell_deps,ft(_t,r),r),ct(`${t}.header_deps`,e.header_deps,it,r),ct(`${t}.inputs`,e.inputs,ft(ut,r),r),ct(`${t}.outputs`,e.outputs,ft(lt,r),r),ct(`${t}.outputs_data`,e.outputs_data,nt,r)}function gt(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){rt(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),ht(r,t,e)}function dt(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){rt(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),ht(r,t,e),ct(`${r}.witnesses`,t.witnesses,nt,e)}function pt(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){rt(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){ot(`${t}.version`,e.version),ot(`${t}.compact_target`,e.compact_target),ot(`${t}.timestamp`,e.timestamp),ot(`${t}.number`,e.number),ot(`${t}.epoch`,e.epoch),it(`${t}.parent_hash`,e.parent_hash),it(`${t}.transactions_root`,e.transactions_root),it(`${t}.proposals_hash`,e.proposals_hash),it(`${t}.uncles_hash`,e.uncles_hash),it(`${t}.dao`,e.dao)}(r,t)}function bt(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(rt(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),nt(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function mt(t,e){if(nt(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function yt(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){rt(r,t,["header","proposals"],[]),e&&bt(t.header,{debugPath:`${r}.header`}),ct(`${r}.proposals`,t.proposals,mt,e)}function wt(t,{nestedValidation:e=!0,debugPath:r="block"}={}){rt(r,t,["header","uncles","transactions","proposals"],[]),e&&bt(t.header,{debugPath:`${r}.header`}),ct(`${r}.uncles`,t.uncles,ft(yt,e),e),ct(`${r}.transactions`,t.transactions,ft(dt,e),e),ct(`${r}.proposals`,t.proposals,mt,e)}function vt(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){rt(r,t,["lock","message"],[]),nt(`${r}.message`,t.message),e&&st(t.lock,{debugPath:`${r}.lock`})}function Bt(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){rt(r,t,[],["lock","input_type","output_type"]),t.lock&&nt(`${r}.lock`,t.lock),t.input_type&&nt(`${r}.input_type`,t.input_type),t.output_type&&nt(`${r}.output_type`,t.output_type)}var Dt=Object.freeze({__proto__:null,ValidateScript:st,ValidateOutPoint:at,ValidateCellInput:ut,ValidateCellOutput:lt,ValidateCellDep:_t,ValidateRawTransaction:gt,ValidateTransaction:dt,ValidateRawHeader:pt,ValidateHeader:bt,ValidateUncleBlock:yt,ValidateBlock:wt,ValidateCellbaseWitness:vt,ValidateWitnessArgs:Bt});function St(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function Tt(t,e,r){if(!((e=St(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function Pt(t,{validation:e=!0,debugPath:r="script"}={}){return t=Tt(r,t,{code_hash:St,hash_type:St,args:St}),e&&st(t,{debugPath:`(transformed) ${r}`}),t}function Ct(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=Tt(r,t,{tx_hash:St,index:St}),e&&at(t,{debugPath:`(transformed) ${r}`}),t}function kt(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function xt(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=Tt(r,t,{since:St,previous_output:kt(Ct)}),e&&ut(t,{debugPath:`(transformed) ${r}`}),t}function $t(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=Tt(r,t,{capacity:St,lock:kt(Pt),type:kt(Pt)}),e&&lt(t,{debugPath:`(transformed) ${r}`}),t}function Et(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=Tt(r,t,{out_point:kt(Ct),dep_type:St}),e&&_t(t,{debugPath:`(transformed) ${r}`}),t}function At(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function Ot(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=Tt(r,t,{version:St,cell_deps:At(kt(Et)),header_deps:At(St),inputs:At(kt(xt)),outputs:At(kt($t)),outputs_data:At(St),witnesses:At(St)}),e&&dt(t,{debugPath:`(transformed) ${r}`}),t}function jt(t,{validation:e=!0,debugPath:r="header"}={}){return t=Tt(r,t,{version:St,compact_target:St,timestamp:St,number:St,epoch:St,parent_hash:St,transactions_root:St,proposals_hash:St,uncles_hash:St,dao:St,nonce:St}),e&&bt(t,{debugPath:`(transformed) ${r}`}),t}function zt(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=Tt(r,t,{header:kt(jt),proposals:At(St)}),e&&yt(t,{debugPath:`(transformed) ${r}`}),t}var It=Object.freeze({__proto__:null,TransformScript:Pt,TransformOutPoint:Ct,TransformCellInput:xt,TransformCellOutput:$t,TransformCellDep:Et,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=Tt(r,t,{version:St,cell_deps:At(kt(Et)),header_deps:At(St),inputs:At(kt(xt)),outputs:At(kt($t)),outputs_data:At(St)}),e&&gt(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:Ot,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=Tt(r,t,{version:St,compact_target:St,timestamp:St,number:St,epoch:St,parent_hash:St,transactions_root:St,proposals_hash:St,uncles_hash:St,dao:St}),e&&pt(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:jt,TransformUncleBlock:zt,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=Tt(r,t,{header:kt(jt),uncles:At(kt(zt)),transactions:At(kt(Ot)),proposals:At(St)}),e&&wt(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=Tt(r,t,{lock:kt(Pt),message:St}),e&&vt(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=Tt(r,t,{lock:St,input_type:St,output_type:St}),e&&Bt(t,{debugPath:`(transformed) ${r}`}),t}});var Rt=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:r=!0,loadData:n=!1}={}){this.rpc=t,this.lockHash=new u(e).serializeJson(),this.skipCellWithContent=r,this.loadData=n}async*collect(){const t=tt(await this.rpc.get_tip_block_number());let e=K.BigInt(0);for(;K.lessThanOrEqual(e,t);){let r=K.add(e,K.BigInt(100));K.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,et(e),et(r));for(const t of n)if(this.skipCellWithContent){if(t.type||K.greaterThan(tt(t.output_data_len),K.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=K.add(r,K.BigInt(1))}}}});exports.BigIntToHexString=et,exports.HexStringToBigInt=tt,exports.RPC=class{constructor(t){return this.uri=t,new Proxy(this,Y)}},exports.Reader=u,exports.cell_collectors=Rt,exports.transformers=It,exports.validators=Dt;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("stream")),r=t(require("http")),n=t(require("url")),i=t(require("https")),o=t(require("zlib"));class s{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class a{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class u{constructor(t){if("string"==typeof t){if(!t.startsWith("0x")||t.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new a(t)}if(t instanceof ArrayBuffer)return new s(t);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(t){const e=new ArrayBuffer(t.length),r=new DataView(e);for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n>255)throw new Error("fromRawString can only accept UTF-8 raw string!");r.setUint8(e,n)}return new s(e)}}const l=e.Readable,_=Symbol("buffer"),c=Symbol("type");class f{constructor(){this[c]="";const t=arguments[0],e=arguments[1],r=[];let n=0;if(t){const e=t,i=Number(e.length);for(let t=0;t<i;t++){const i=e[t];let o;o=i instanceof Buffer?i:ArrayBuffer.isView(i)?Buffer.from(i.buffer,i.byteOffset,i.byteLength):i instanceof ArrayBuffer?Buffer.from(i):i instanceof f?i[_]:Buffer.from("string"==typeof i?i:String(i)),n+=o.length,r.push(o)}}this[_]=Buffer.concat(r);let i=e&&void 0!==e.type&&String(e.type).toLowerCase();i&&!/[^\u0020-\u007E]/.test(i)&&(this[c]=i)}get size(){return this[_].length}get type(){return this[c]}text(){return Promise.resolve(this[_].toString())}arrayBuffer(){const t=this[_],e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return Promise.resolve(e)}stream(){const t=new l;return t._read=function(){},t.push(this[_]),t.push(null),t}toString(){return"[object Blob]"}slice(){const t=this.size,e=arguments[0],r=arguments[1];let n,i;n=void 0===e?0:e<0?Math.max(t+e,0):Math.min(e,t),i=void 0===r?t:r<0?Math.max(t+r,0):Math.min(r,t);const o=Math.max(i-n,0),s=this[_].slice(n,n+o),a=new f([],{type:arguments[2]});return a[_]=s,a}}function h(t,e,r){Error.call(this,t),this.message=t,this.type=e,r&&(this.code=this.errno=r.code),Error.captureStackTrace(this,this.constructor)}let g;Object.defineProperties(f.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(f.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="FetchError";try{g=require("encoding").convert}catch(t){}const d=Symbol("Body internals"),p=e.PassThrough;function b(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.size;let o=void 0===i?0:i;var s=n.timeout;let a=void 0===s?0:s;null==t?t=null:y(t)?t=Buffer.from(t.toString()):w(t)||Buffer.isBuffer(t)||("[object ArrayBuffer]"===Object.prototype.toString.call(t)?t=Buffer.from(t):ArrayBuffer.isView(t)?t=Buffer.from(t.buffer,t.byteOffset,t.byteLength):t instanceof e||(t=Buffer.from(String(t)))),this[d]={body:t,disturbed:!1,error:null},this.size=o,this.timeout=a,t instanceof e&&t.on("error",(function(t){const e="AbortError"===t.name?t:new h(`Invalid response body while trying to fetch ${r.url}: ${t.message}`,"system",t);r[d].error=e}))}function m(){var t=this;if(this[d].disturbed)return b.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[d].disturbed=!0,this[d].error)return b.Promise.reject(this[d].error);let r=this.body;if(null===r)return b.Promise.resolve(Buffer.alloc(0));if(w(r)&&(r=r.stream()),Buffer.isBuffer(r))return b.Promise.resolve(r);if(!(r instanceof e))return b.Promise.resolve(Buffer.alloc(0));let n=[],i=0,o=!1;return new b.Promise((function(e,s){let a;t.timeout&&(a=setTimeout((function(){o=!0,s(new h(`Response timeout while trying to fetch ${t.url} (over ${t.timeout}ms)`,"body-timeout"))}),t.timeout)),r.on("error",(function(e){"AbortError"===e.name?(o=!0,s(e)):s(new h(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e))})),r.on("data",(function(e){if(!o&&null!==e){if(t.size&&i+e.length>t.size)return o=!0,void s(new h(`content size at ${t.url} over limit: ${t.size}`,"max-size"));i+=e.length,n.push(e)}})),r.on("end",(function(){if(!o){clearTimeout(a);try{e(Buffer.concat(n,i))}catch(e){s(new h(`Could not create Buffer from response body for ${t.url}: ${e.message}`,"system",e))}}}))}))}function y(t){return"object"==typeof t&&"function"==typeof t.append&&"function"==typeof t.delete&&"function"==typeof t.get&&"function"==typeof t.getAll&&"function"==typeof t.has&&"function"==typeof t.set&&("URLSearchParams"===t.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(t)||"function"==typeof t.sort)}function w(t){return"object"==typeof t&&"function"==typeof t.arrayBuffer&&"string"==typeof t.type&&"function"==typeof t.stream&&"function"==typeof t.constructor&&"string"==typeof t.constructor.name&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag])}function v(t){let r,n,i=t.body;if(t.bodyUsed)throw new Error("cannot clone body after it is used");return i instanceof e&&"function"!=typeof i.getBoundary&&(r=new p,n=new p,i.pipe(r),i.pipe(n),t[d].body=r,i=n),i}function B(t){return null===t?null:"string"==typeof t?"text/plain;charset=UTF-8":y(t)?"application/x-www-form-urlencoded;charset=UTF-8":w(t)?t.type||null:Buffer.isBuffer(t)||"[object ArrayBuffer]"===Object.prototype.toString.call(t)||ArrayBuffer.isView(t)?null:"function"==typeof t.getBoundary?`multipart/form-data;boundary=${t.getBoundary()}`:t instanceof e?null:"text/plain;charset=UTF-8"}function D(t){const e=t.body;return null===e?0:w(e)?e.size:Buffer.isBuffer(e)?e.length:e&&"function"==typeof e.getLengthSync&&(e._lengthRetrievers&&0==e._lengthRetrievers.length||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}b.prototype={get body(){return this[d].body},get bodyUsed(){return this[d].disturbed},arrayBuffer(){return m.call(this).then((function(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}))},blob(){let t=this.headers&&this.headers.get("content-type")||"";return m.call(this).then((function(e){return Object.assign(new f([],{type:t.toLowerCase()}),{[_]:e})}))},json(){var t=this;return m.call(this).then((function(e){try{return JSON.parse(e.toString())}catch(e){return b.Promise.reject(new h(`invalid json response body at ${t.url} reason: ${e.message}`,"invalid-json"))}}))},text(){return m.call(this).then((function(t){return t.toString()}))},buffer(){return m.call(this)},textConverted(){var t=this;return m.call(this).then((function(e){return function(t,e){if("function"!=typeof g)throw new Error("The package `encoding` must be installed to use the textConverted() function");const r=e.get("content-type");let n,i,o="utf-8";r&&(n=/charset=([^;]*)/i.exec(r));i=t.slice(0,1024).toString(),!n&&i&&(n=/<meta.+?charset=(['"])(.+?)\1/i.exec(i));!n&&i&&(n=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(i),n&&(n=/charset=(.*)/i.exec(n.pop())));!n&&i&&(n=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(i));n&&(o=n.pop(),"gb2312"!==o&&"gbk"!==o||(o="gb18030"));return g(t,"UTF-8",o).toString()}(e,t.headers)}))}},Object.defineProperties(b.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),b.mixIn=function(t){for(const e of Object.getOwnPropertyNames(b.prototype))if(!(e in t)){const r=Object.getOwnPropertyDescriptor(b.prototype,e);Object.defineProperty(t,e,r)}},b.Promise=global.Promise;const S=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,T=/[^\t\x20-\x7e\x80-\xff]/;function P(t){if(t=`${t}`,S.test(t)||""===t)throw new TypeError(`${t} is not a legal HTTP header name`)}function C(t){if(t=`${t}`,T.test(t))throw new TypeError(`${t} is not a legal HTTP header value`)}function x(t,e){e=e.toLowerCase();for(const r in t)if(r.toLowerCase()===e)return r}const k=Symbol("map");class E{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[k]=Object.create(null),t instanceof E){const e=t.raw(),r=Object.keys(e);for(const t of r)for(const r of e[t])this.append(t,r)}else if(null==t);else{if("object"!=typeof t)throw new TypeError("Provided initializer must be an object");{const e=t[Symbol.iterator];if(null!=e){if("function"!=typeof e)throw new TypeError("Header pairs must be iterable");const r=[];for(const e of t){if("object"!=typeof e||"function"!=typeof e[Symbol.iterator])throw new TypeError("Each header pair must be iterable");r.push(Array.from(e))}for(const t of r){if(2!==t.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(t[0],t[1])}}else for(const e of Object.keys(t)){const r=t[e];this.append(e,r)}}}}get(t){P(t=`${t}`);const e=x(this[k],t);return void 0===e?null:this[k][e].join(", ")}forEach(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=$(this),n=0;for(;n<r.length;){var i=r[n];const o=i[0],s=i[1];t.call(e,s,o,this),r=$(this),n++}}set(t,e){e=`${e}`,P(t=`${t}`),C(e);const r=x(this[k],t);this[k][void 0!==r?r:t]=[e]}append(t,e){e=`${e}`,P(t=`${t}`),C(e);const r=x(this[k],t);void 0!==r?this[k][r].push(e):this[k][t]=[e]}has(t){return P(t=`${t}`),void 0!==x(this[k],t)}delete(t){P(t=`${t}`);const e=x(this[k],t);void 0!==e&&delete this[k][e]}raw(){return this[k]}keys(){return O(this,"key")}values(){return O(this,"value")}[Symbol.iterator](){return O(this,"key+value")}}function $(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";const r=Object.keys(t[k]).sort();return r.map("key"===e?function(t){return t.toLowerCase()}:"value"===e?function(e){return t[k][e].join(", ")}:function(e){return[e.toLowerCase(),t[k][e].join(", ")]})}E.prototype.entries=E.prototype[Symbol.iterator],Object.defineProperty(E.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(E.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const A=Symbol("internal");function O(t,e){const r=Object.create(j);return r[A]={target:t,kind:e,index:0},r}const j=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==j)throw new TypeError("Value of `this` is not a HeadersIterator");var t=this[A];const e=t.target,r=t.kind,n=t.index,i=$(e,r);return n>=i.length?{value:void 0,done:!0}:(this[A].index=n+1,{value:i[n],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function z(t){const e=Object.assign({__proto__:null},t[k]),r=x(t[k],"Host");return void 0!==r&&(e[r]=e[r][0]),e}Object.defineProperty(j,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const I=Symbol("Response internals"),R=r.STATUS_CODES;class L{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b.call(this,t,e);const r=e.status||200,n=new E(e.headers);if(null!=t&&!n.has("Content-Type")){const e=B(t);e&&n.append("Content-Type",e)}this[I]={url:e.url,status:r,statusText:e.statusText||R[r],headers:n,counter:e.counter}}get url(){return this[I].url||""}get status(){return this[I].status}get ok(){return this[I].status>=200&&this[I].status<300}get redirected(){return this[I].counter>0}get statusText(){return this[I].statusText}get headers(){return this[I].headers}clone(){return new L(v(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}b.mixIn(L.prototype),Object.defineProperties(L.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(L.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const M=Symbol("Request internals"),q=n.parse,V=n.format,N="destroy"in e.Readable.prototype;function H(t){return"object"==typeof t&&"object"==typeof t[M]}class U{constructor(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};H(t)?e=q(t.url):(e=t&&t.href?q(t.href):q(`${t}`),t={});let n=r.method||t.method||"GET";if(n=n.toUpperCase(),(null!=r.body||H(t)&&null!==t.body)&&("GET"===n||"HEAD"===n))throw new TypeError("Request with GET/HEAD method cannot have body");let i=null!=r.body?r.body:H(t)&&null!==t.body?v(t):null;b.call(this,i,{timeout:r.timeout||t.timeout||0,size:r.size||t.size||0});const o=new E(r.headers||t.headers||{});if(null!=i&&!o.has("Content-Type")){const t=B(i);t&&o.append("Content-Type",t)}let s=H(t)?t.signal:null;if("signal"in r&&(s=r.signal),null!=s&&!function(t){const e=t&&"object"==typeof t&&Object.getPrototypeOf(t);return!(!e||"AbortSignal"!==e.constructor.name)}(s))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[M]={method:n,redirect:r.redirect||t.redirect||"follow",headers:o,parsedURL:e,signal:s},this.follow=void 0!==r.follow?r.follow:void 0!==t.follow?t.follow:20,this.compress=void 0!==r.compress?r.compress:void 0===t.compress||t.compress,this.counter=r.counter||t.counter||0,this.agent=r.agent||t.agent}get method(){return this[M].method}get url(){return V(this[M].parsedURL)}get headers(){return this[M].headers}get redirect(){return this[M].redirect}get signal(){return this[M].signal}clone(){return new U(this)}}function F(t){Error.call(this,t),this.type="aborted",this.message=t,Error.captureStackTrace(this,this.constructor)}b.mixIn(U.prototype),Object.defineProperty(U.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(U.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),F.prototype=Object.create(Error.prototype),F.prototype.constructor=F,F.prototype.name="AbortError";const G=e.PassThrough,W=n.resolve;function J(t,n){if(!J.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return b.Promise=J.Promise,new J.Promise((function(s,a){const u=new U(t,n),l=function(t){const r=t[M].parsedURL,n=new E(t[M].headers);if(n.has("Accept")||n.set("Accept","*/*"),!r.protocol||!r.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(r.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(t.signal&&t.body instanceof e.Readable&&!N)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let i=null;if(null==t.body&&/^(POST|PUT)$/i.test(t.method)&&(i="0"),null!=t.body){const e=D(t);"number"==typeof e&&(i=String(e))}i&&n.set("Content-Length",i),n.has("User-Agent")||n.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),t.compress&&!n.has("Accept-Encoding")&&n.set("Accept-Encoding","gzip,deflate");let o=t.agent;return"function"==typeof o&&(o=o(r)),n.has("Connection")||o||n.set("Connection","close"),Object.assign({},r,{method:t.method,headers:z(n),agent:o})}(u),_=("https:"===l.protocol?i:r).request,c=u.signal;let f=null;const g=function(){let t=new F("The user aborted a request.");a(t),u.body&&u.body instanceof e.Readable&&u.body.destroy(t),f&&f.body&&f.body.emit("error",t)};if(c&&c.aborted)return void g();const d=function(){g(),m()},p=_(l);let b;function m(){p.abort(),c&&c.removeEventListener("abort",d),clearTimeout(b)}c&&c.addEventListener("abort",d),u.timeout&&p.once("socket",(function(t){b=setTimeout((function(){a(new h(`network timeout at: ${u.url}`,"request-timeout")),m()}),u.timeout)})),p.on("error",(function(t){a(new h(`request to ${u.url} failed, reason: ${t.message}`,"system",t)),m()})),p.on("response",(function(t){clearTimeout(b);const e=function(t){const e=new E;for(const r of Object.keys(t))if(!S.test(r))if(Array.isArray(t[r]))for(const n of t[r])T.test(n)||(void 0===e[k][r]?e[k][r]=[n]:e[k][r].push(n));else T.test(t[r])||(e[k][r]=[t[r]]);return e}(t.headers);if(J.isRedirect(t.statusCode)){const r=e.get("Location"),n=null===r?null:W(u.url,r);switch(u.redirect){case"error":return a(new h(`redirect mode is set to error: ${u.url}`,"no-redirect")),void m();case"manual":if(null!==n)try{e.set("Location",n)}catch(t){a(t)}break;case"follow":if(null===n)break;if(u.counter>=u.follow)return a(new h(`maximum redirect reached at: ${u.url}`,"max-redirect")),void m();const r={headers:new E(u.headers),follow:u.follow,counter:u.counter+1,agent:u.agent,compress:u.compress,method:u.method,body:u.body,signal:u.signal,timeout:u.timeout};return 303!==t.statusCode&&u.body&&null===D(u)?(a(new h("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void m()):(303!==t.statusCode&&(301!==t.statusCode&&302!==t.statusCode||"POST"!==u.method)||(r.method="GET",r.body=void 0,r.headers.delete("content-length")),s(J(new U(n,r))),void m())}}t.once("end",(function(){c&&c.removeEventListener("abort",d)}));let r=t.pipe(new G);const n={url:u.url,status:t.statusCode,statusText:t.statusMessage,headers:e,size:u.size,timeout:u.timeout,counter:u.counter},i=e.get("Content-Encoding");if(!u.compress||"HEAD"===u.method||null===i||204===t.statusCode||304===t.statusCode)return f=new L(r,n),void s(f);const l={flush:o.Z_SYNC_FLUSH,finishFlush:o.Z_SYNC_FLUSH};if("gzip"==i||"x-gzip"==i)return r=r.pipe(o.createGunzip(l)),f=new L(r,n),void s(f);if("deflate"!=i&&"x-deflate"!=i){if("br"==i&&"function"==typeof o.createBrotliDecompress)return r=r.pipe(o.createBrotliDecompress()),f=new L(r,n),void s(f);f=new L(r,n),s(f)}else{t.pipe(new G).once("data",(function(t){r=8==(15&t[0])?r.pipe(o.createInflate()):r.pipe(o.createInflateRaw()),f=new L(r,n),s(f)}))}})),function(t,e){const r=e.body;null===r?t.end():w(r)?r.stream().pipe(t):Buffer.isBuffer(r)?(t.write(r),t.end()):r.pipe(t)}(p,u)}))}J.isRedirect=function(t){return 301===t||302===t||303===t||307===t||308===t},J.Promise=global.Promise;var X,Q=(X=Object.freeze({__proto__:null,default:J,Headers:E,Request:U,Response:L,FetchError:h}))&&X.default||X,Z=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var r=Q.default||Q,n=function(t,e){return/^\/\//.test(t)&&(t="https:"+t),r.call(this,t,e)};t.exports=e=n,e.fetch=n,e.Headers=Q.Headers,e.Request=Q.Request,e.Response=Q.Response,e.default=n}));Z.fetch,Z.Headers,Z.Request,Z.Response;class K extends Array{constructor(t,e){if(t>K.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");super(t),this.sign=e}static BigInt(t){var e=Math.floor,r=Number.isFinite;if("number"==typeof t){if(0===t)return K.__zero();if((0|t)===t)return 0>t?K.__oneDigit(-t,!0):K.__oneDigit(t,!1);if(!r(t)||e(t)!==t)throw new RangeError("The number "+t+" cannot be converted to BigInt because it is not an integer");return K.__fromDouble(t)}if("string"==typeof t){const e=K.__fromString(t);if(null===e)throw new SyntaxError("Cannot convert "+t+" to a BigInt");return e}if("boolean"==typeof t)return!0===t?K.__oneDigit(1,!1):K.__zero();if("object"==typeof t){if(t.constructor===K)return t;const e=K.__toPrimitive(t);return K.BigInt(e)}throw new TypeError("Cannot convert "+t+" to a BigInt")}toDebugString(){const t=["BigInt["];for(const e of this)t.push((e?(e>>>0).toString(16):e)+", ");return t.push("]"),t.join("")}toString(t=10){if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?K.__toStringBasePowerOfTwo(this,t):K.__toStringGeneric(this,t,!1)}static toNumber(t){var e=Math.clz32;const r=t.length;if(0===r)return 0;if(1===r){const e=t.__unsignedDigit(0);return t.sign?-e:e}const n=t.__digit(r-1),i=e(n),o=32*r-i;if(1024<o)return t.sign?-1/0:1/0;let s=o-1,a=n,u=r-1;const l=i+1;let _=32===l?0:a<<l;_>>>=12;const c=l-12;let f=12<=l?0:a<<20+l,h=20+l;0<c&&0<u&&(u--,a=t.__digit(u),_|=a>>>32-c,f=a<<c,h=c),0<h&&0<u&&(u--,a=t.__digit(u),f|=a>>>32-h,h-=32);const g=K.__decideRounding(t,h,u,a);if((1===g||0===g&&1==(1&f))&&(f=f+1>>>0,0==f&&(_++,0!=_>>>20&&(_=0,s++,1023<s))))return t.sign?-1/0:1/0;const d=t.sign?-2147483648:0;return s=s+1023<<20,K.__kBitConversionInts[1]=d|s|_,K.__kBitConversionInts[0]=f,K.__kBitConversionDouble[0]}static unaryMinus(t){if(0===t.length)return t;const e=t.__copy();return e.sign=!t.sign,e}static bitwiseNot(t){return t.sign?K.__absoluteSubOne(t).__trim():K.__absoluteAddOne(t,!0)}static exponentiate(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return K.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?K.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");let r=e.__unsignedDigit(0);if(1===r)return t;if(r>=K.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){const e=1+(r>>>5),n=t.sign&&0!=(1&r),i=new K(e,n);i.__initializeDigits();const o=1<<(31&r);return i.__setDigit(e-1,o),i}let n=null,i=t;for(0!=(1&r)&&(n=t),r>>=1;0!==r;r>>=1)i=K.multiply(i,i),0!=(1&r)&&(n=null===n?i:K.multiply(n,i));return n}static multiply(t,e){if(0===t.length)return t;if(0===e.length)return e;let r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;const n=new K(r,t.sign!==e.sign);n.__initializeDigits();for(let r=0;r<t.length;r++)K.__multiplyAccumulate(e,t.__digit(r),n,r);return n.__trim()}static divide(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>K.__absoluteCompare(t,e))return K.__zero();const r=t.sign!==e.sign,n=e.__unsignedDigit(0);let i;if(1===e.length&&65535>=n){if(1===n)return r===t.sign?t:K.unaryMinus(t);i=K.__absoluteDivSmall(t,n,null)}else i=K.__absoluteDivLarge(t,e,!0,!1);return i.sign=r,i.__trim()}static remainder(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>K.__absoluteCompare(t,e))return t;const r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return K.__zero();const e=K.__absoluteModSmall(t,r);return 0===e?K.__zero():K.__oneDigit(e,t.sign)}const n=K.__absoluteDivLarge(t,e,!1,!0);return n.sign=t.sign,n.__trim()}static add(t,e){const r=t.sign;return r===e.sign?K.__absoluteAdd(t,e,r):0<=K.__absoluteCompare(t,e)?K.__absoluteSub(t,e,r):K.__absoluteSub(e,t,!r)}static subtract(t,e){const r=t.sign;return r===e.sign?0<=K.__absoluteCompare(t,e)?K.__absoluteSub(t,e,r):K.__absoluteSub(e,t,!r):K.__absoluteAdd(t,e,r)}static leftShift(t,e){return 0===e.length||0===t.length?t:e.sign?K.__rightShiftByAbsolute(t,e):K.__leftShiftByAbsolute(t,e)}static signedRightShift(t,e){return 0===e.length||0===t.length?t:e.sign?K.__leftShiftByAbsolute(t,e):K.__rightShiftByAbsolute(t,e)}static unsignedRightShift(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}static lessThan(t,e){return 0>K.__compareToBigInt(t,e)}static lessThanOrEqual(t,e){return 0>=K.__compareToBigInt(t,e)}static greaterThan(t,e){return 0<K.__compareToBigInt(t,e)}static greaterThanOrEqual(t,e){return 0<=K.__compareToBigInt(t,e)}static equal(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}static notEqual(t,e){return!K.equal(t,e)}static bitwiseAnd(t,e){var r=Math.max;if(!t.sign&&!e.sign)return K.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){const n=r(t.length,e.length)+1;let i=K.__absoluteSubOne(t,n);const o=K.__absoluteSubOne(e);return i=K.__absoluteOr(i,o,i),K.__absoluteAddOne(i,!0,i).__trim()}return t.sign&&([t,e]=[e,t]),K.__absoluteAndNot(t,K.__absoluteSubOne(e)).__trim()}static bitwiseXor(t,e){var r=Math.max;if(!t.sign&&!e.sign)return K.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){const n=r(t.length,e.length),i=K.__absoluteSubOne(t,n),o=K.__absoluteSubOne(e);return K.__absoluteXor(i,o,i).__trim()}const n=r(t.length,e.length)+1;t.sign&&([t,e]=[e,t]);let i=K.__absoluteSubOne(e,n);return i=K.__absoluteXor(i,t,i),K.__absoluteAddOne(i,!0,i).__trim()}static bitwiseOr(t,e){const r=(0,Math.max)(t.length,e.length);if(!t.sign&&!e.sign)return K.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){let n=K.__absoluteSubOne(t,r);const i=K.__absoluteSubOne(e);return n=K.__absoluteAnd(n,i,n),K.__absoluteAddOne(n,!0,n).__trim()}t.sign&&([t,e]=[e,t]);let n=K.__absoluteSubOne(e,r);return n=K.__absoluteAndNot(n,t,n),K.__absoluteAddOne(n,!0,n).__trim()}static asIntN(t,e){if(0===e.length)return e;if(0===t)return K.__zero();if(t>=K.__kMaxLengthBits)return e;const r=t+31>>>5;if(e.length<r)return e;const n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return K.__truncateToNBits(t,e);if(!e.sign)return K.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(let n=r-2;0<=n;n--)if(0!==e.__digit(n))return K.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:K.__truncateToNBits(t,e)}return K.__truncateAndSubFromPowerOfTwo(t,e,!1)}static asUintN(t,e){if(0===e.length)return e;if(0===t)return K.__zero();if(e.sign){if(t>K.__kMaxLengthBits)throw new RangeError("BigInt too big");return K.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=K.__kMaxLengthBits)return e;const r=t+31>>>5;if(e.length<r)return e;const n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return K.__truncateToNBits(t,e)}static ADD(t,e){if(t=K.__toPrimitive(t),e=K.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=K.__toNumeric(t),e=K.__toNumeric(e),K.__isBigInt(t)&&K.__isBigInt(e))return K.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}static LT(t,e){return K.__compare(t,e,0)}static LE(t,e){return K.__compare(t,e,1)}static GT(t,e){return K.__compare(t,e,2)}static GE(t,e){return K.__compare(t,e,3)}static EQ(t,e){for(;;){if(K.__isBigInt(t))return K.__isBigInt(e)?K.equal(t,e):K.EQ(e,t);if("number"==typeof t){if(K.__isBigInt(e))return K.__equalToNumber(e,t);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("string"==typeof t){if(K.__isBigInt(e))return null!==(t=K.__fromString(t))&&K.equal(t,e);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("boolean"==typeof t){if(K.__isBigInt(e))return K.__equalToNumber(e,+t);if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else if("symbol"==typeof t){if(K.__isBigInt(e))return!1;if("object"!=typeof e)return t==e;e=K.__toPrimitive(e)}else{if("object"!=typeof t)return t==e;if("object"==typeof e&&e.constructor!==K)return t==e;t=K.__toPrimitive(t)}}}static NE(t,e){return!K.EQ(t,e)}static __zero(){return new K(0,!1)}static __oneDigit(t,e){const r=new K(1,e);return r.__setDigit(0,t),r}__copy(){const t=new K(this.length,this.sign);for(let e=0;e<this.length;e++)t[e]=this[e];return t}__trim(){let t=this.length,e=this[t-1];for(;0===e;)t--,e=this[t-1],this.pop();return 0===t&&(this.sign=!1),this}__initializeDigits(){for(let t=0;t<this.length;t++)this[t]=0}static __decideRounding(t,e,r,n){if(0<e)return-1;let i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}let o=1<<i;if(0==(n&o))return-1;if(o-=1,0!=(n&o))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}static __fromDouble(t){K.__kBitConversionDouble[0]=t;const e=(2047&K.__kBitConversionInts[1]>>>20)-1023,r=1+(e>>>5),n=new K(r,0>t);let i=1048575&K.__kBitConversionInts[1]|1048576,o=K.__kBitConversionInts[0];const s=31&e;let a,u=0;if(s<20){const t=20-s;u=t+32,a=i>>>t,i=i<<32-t|o>>>t,o<<=32-t}else if(20===s)u=32,a=i,i=o;else{const t=s-20;u=32-t,a=i<<t|o>>>32-t,i=o<<t}n.__setDigit(r-1,a);for(let t=r-2;0<=t;t--)0<u?(u-=32,a=i,i=o):a=0,n.__setDigit(t,a);return n.__trim()}static __isWhitespace(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}static __fromString(t,e=0){let r=0;const n=t.length;let i=0;if(i===n)return K.__zero();let o=t.charCodeAt(i);for(;K.__isWhitespace(o);){if(++i===n)return K.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return K.__zero();if(o=t.charCodeAt(i),88===o||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return K.__zero();if(o=t.charCodeAt(i),88===o||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return K.__zero();o=t.charCodeAt(i)}const s=n-i;let a=K.__kMaxBitsPerChar[e],u=K.__kBitsPerCharTableMultiplier-1;if(s>1073741824/a)return null;const l=a*s+u>>>K.__kBitsPerCharTableShift,_=new K(l+31>>>5,!1),c=10>e?e:10,f=10<e?e-10:0;if(0==(e&e-1)){a>>=K.__kBitsPerCharTableShift;const e=[],r=[];let s=!1;do{let u=0,l=0;for(;;){let e;if(o-48>>>0<c)e=o-48;else{if(!((32|o)-97>>>0<f)){s=!0;break}e=(32|o)-87}if(l+=a,u=u<<a|e,++i===n){s=!0;break}if(o=t.charCodeAt(i),32<l+a)break}e.push(u),r.push(l)}while(!s);K.__fillFromParts(_,e,r)}else{_.__initializeDigits();let r=!1,s=0;do{let l=0,h=1;for(;;){let a;if(o-48>>>0<c)a=o-48;else{if(!((32|o)-97>>>0<f)){r=!0;break}a=(32|o)-87}const u=h*e;if(4294967295<u)break;if(h=u,l=l*e+a,s++,++i===n){r=!0;break}o=t.charCodeAt(i)}u=32*K.__kBitsPerCharTableMultiplier-1;const g=a*s+u>>>K.__kBitsPerCharTableShift+5;_.__inplaceMultiplyAdd(h,l,g)}while(!r)}if(i!==n){if(!K.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!K.__isWhitespace(o))return null}return 0!=r&&10!==e?null:(_.sign=-1==r,_.__trim())}static __fillFromParts(t,e,r){let n=0,i=0,o=0;for(let s=e.length-1;0<=s;s--){const a=e[s],u=r[s];i|=a<<o,o+=u,32===o?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),o-=32,i=a>>>u-o)}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}static __toStringBasePowerOfTwo(t,e){var r=Math.clz32;const n=t.length;let i=e-1;i=(85&i>>>1)+(85&i),i=(51&i>>>2)+(51&i),i=(15&i>>>4)+(15&i);const o=i,s=e-1,a=t.__digit(n-1);let u=0|(32*n-r(a)+o-1)/o;if(t.sign&&u++,268435456<u)throw new Error("string too long");const l=Array(u);let _=u-1,c=0,f=0;for(let e=0;e<n-1;e++){const r=t.__digit(e),n=(c|r<<f)&s;l[_--]=K.__kConversionChars[n];const i=o-f;for(c=r>>>i,f=32-i;f>=o;)l[_--]=K.__kConversionChars[c&s],c>>>=o,f-=o}const h=(c|a<<f)&s;for(l[_--]=K.__kConversionChars[h],c=a>>>o-f;0!==c;)l[_--]=K.__kConversionChars[c&s],c>>>=o;if(t.sign&&(l[_--]="-"),-1!=_)throw new Error("implementation bug");return l.join("")}static __toStringGeneric(t,e,r){var n=Math.clz32;const i=t.length;if(0===i)return"";if(1===i){let n=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(n="-"+n),n}const o=32*i-n(t.__digit(i-1)),s=K.__kMaxBitsPerChar[e]-1;let a=o*K.__kBitsPerCharTableMultiplier;a+=s-1,a=0|a/s;const u=a+1>>1,l=K.exponentiate(K.__oneDigit(e,!1),K.__oneDigit(u,!1));let _,c;const f=l.__unsignedDigit(0);if(1===l.length&&65535>=f){_=new K(t.length,!1),_.__initializeDigits();let r=0;for(let e=2*t.length-1;0<=e;e--){const n=r<<16|t.__halfDigit(e);_.__setHalfDigit(e,0|n/f),r=0|n%f}c=r.toString(e)}else{const r=K.__absoluteDivLarge(t,l,!0,!0);_=r.quotient;const n=r.remainder.__trim();c=K.__toStringGeneric(n,e,!0)}_.__trim();let h=K.__toStringGeneric(_,e,!0);for(;c.length<u;)c="0"+c;return!1===r&&t.sign&&(h="-"+h),h+c}static __unequalSign(t){return t?-1:1}static __absoluteGreater(t){return t?-1:1}static __absoluteLess(t){return t?1:-1}static __compareToBigInt(t,e){const r=t.sign;if(r!==e.sign)return K.__unequalSign(r);const n=K.__absoluteCompare(t,e);return 0<n?K.__absoluteGreater(r):0>n?K.__absoluteLess(r):0}static __compareToNumber(t,e){if(!0|e){const r=t.sign,n=0>e;if(r!==n)return K.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return K.__absoluteGreater(r);const i=Math.abs(e),o=t.__unsignedDigit(0);return o>i?K.__absoluteGreater(r):o<i?K.__absoluteLess(r):0}return K.__compareToDouble(t,e)}static __compareToDouble(t,e){var r=Math.clz32;if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;const n=t.sign;if(n!==0>e)return K.__unequalSign(n);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;K.__kBitConversionDouble[0]=e;const i=2047&K.__kBitConversionInts[1]>>>20;if(2047==i)throw new Error("implementation bug: handled elsewhere");const o=i-1023;if(0>o)return K.__absoluteGreater(n);const s=t.length;let a=t.__digit(s-1);const u=r(a),l=32*s-u,_=o+1;if(l<_)return K.__absoluteLess(n);if(l>_)return K.__absoluteGreater(n);let c=1048576|1048575&K.__kBitConversionInts[1],f=K.__kBitConversionInts[0];const h=31-u;if(h!==(l-1)%31)throw new Error("implementation bug");let g,d=0;if(20>h){const t=20-h;d=t+32,g=c>>>t,c=c<<32-t|f>>>t,f<<=32-t}else if(20===h)d=32,g=c,c=f;else{const t=h-20;d=32-t,g=c<<t|f>>>32-t,c=f<<t}if(a>>>=0,g>>>=0,a>g)return K.__absoluteGreater(n);if(a<g)return K.__absoluteLess(n);for(let e=s-2;0<=e;e--){0<d?(d-=32,g=c>>>0,c=f,f=0):g=0;const r=t.__unsignedDigit(e);if(r>g)return K.__absoluteGreater(n);if(r<g)return K.__absoluteLess(n)}if(0!==c||0!==f){if(0===d)throw new Error("implementation bug");return K.__absoluteLess(n)}return 0}static __equalToNumber(t,e){var r=Math.abs;return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===r(e):0===K.__compareToDouble(t,e)}static __comparisonResultToBool(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}static __compare(t,e,r){if(t=K.__toPrimitive(t),e=K.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(K.__isBigInt(t)&&"string"==typeof e)return null!==(e=K.__fromString(e))&&K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if("string"==typeof t&&K.__isBigInt(e))return null!==(t=K.__fromString(t))&&K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if(t=K.__toNumeric(t),e=K.__toNumeric(e),K.__isBigInt(t)){if(K.__isBigInt(e))return K.__comparisonResultToBool(K.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return K.__comparisonResultToBool(K.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(K.__isBigInt(e))return K.__comparisonResultToBool(K.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}__clzmsd(){return Math.clz32(this[this.length-1])}static __absoluteAdd(t,e,r){if(t.length<e.length)return K.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:K.unaryMinus(t);let n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;const i=new K(n,r);let o=0,s=0;for(;s<e.length;s++){const r=e.__digit(s),n=t.__digit(s),a=(65535&n)+(65535&r)+o,u=(n>>>16)+(r>>>16)+(a>>>16);o=u>>>16,i.__setDigit(s,65535&a|u<<16)}for(;s<t.length;s++){const e=t.__digit(s),r=(65535&e)+o,n=(e>>>16)+(r>>>16);o=n>>>16,i.__setDigit(s,65535&r|n<<16)}return s<i.length&&i.__setDigit(s,o),i.__trim()}static __absoluteSub(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:K.unaryMinus(t);const n=new K(t.length,r);let i=0,o=0;for(;o<e.length;o++){const r=t.__digit(o),s=e.__digit(o),a=(65535&r)-(65535&s)-i;i=1&a>>>16;const u=(r>>>16)-(s>>>16)-i;i=1&u>>>16,n.__setDigit(o,65535&a|u<<16)}for(;o<t.length;o++){const e=t.__digit(o),r=(65535&e)-i;i=1&r>>>16;const s=(e>>>16)-i;i=1&s>>>16,n.__setDigit(o,65535&r|s<<16)}return n.__trim()}static __absoluteAddOne(t,e,r=null){const n=t.length;null===r?r=new K(n,e):r.sign=e;let i=!0;for(let e,o=0;o<n;o++){e=t.__digit(o);const n=-1===e;i&&(e=0|e+1),i=n,r.__setDigit(o,e)}return i&&r.__setDigitGrow(n,1),r}static __absoluteSubOne(t,e){const r=t.length,n=new K(e=e||r,!1);let i=!0;for(let e,o=0;o<r;o++){e=t.__digit(o);const r=0===e;i&&(e=0|e-1),i=r,n.__setDigit(o,e)}for(let t=r;t<e;t++)n.__setDigit(t,0);return n}static __absoluteAnd(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=o;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)&e.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteAndNot(t,e,r=null){const n=t.length,i=e.length;let o=i;n<i&&(o=n);let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)&~e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteOr(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)|e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteXor(t,e,r=null){let n=t.length,i=e.length,o=i;if(n<i){o=n;const r=t,s=n;t=e,n=i,e=r,i=s}let s=n;null===r?r=new K(s,!1):s=r.length;let a=0;for(;a<o;a++)r.__setDigit(a,t.__digit(a)^e.__digit(a));for(;a<n;a++)r.__setDigit(a,t.__digit(a));for(;a<s;a++)r.__setDigit(a,0);return r}static __absoluteCompare(t,e){const r=t.length-e.length;if(0!=r)return r;let n=t.length-1;for(;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}static __multiplyAccumulate(t,e,r,n){var i=Math.imul;if(0===e)return;const o=65535&e,s=e>>>16;let a=0,u=0,l=0;for(let e=0;e<t.length;e++,n++){let _=r.__digit(n),c=65535&_,f=_>>>16;const h=t.__digit(e),g=65535&h,d=h>>>16,p=i(g,o),b=i(g,s),m=i(d,o),y=i(d,s);c+=u+(65535&p),f+=l+a+(c>>>16)+(p>>>16)+(65535&b)+(65535&m),a=f>>>16,u=(b>>>16)+(m>>>16)+(65535&y)+a,a=u>>>16,u&=65535,l=y>>>16,_=65535&c|f<<16,r.__setDigit(n,_)}for(;0!=a||0!==u||0!==l;n++){let t=r.__digit(n);const e=(65535&t)+u,i=(t>>>16)+(e>>>16)+l+a;u=0,l=0,a=i>>>16,t=65535&e|i<<16,r.__setDigit(n,t)}}static __internalMultiplyAdd(t,e,r,n,i){var o=Math.imul;let s=r,a=0;for(let r=0;r<n;r++){const n=t.__digit(r),u=o(65535&n,e),l=(65535&u)+a+s;s=l>>>16;const _=o(n>>>16,e),c=(65535&_)+(u>>>16)+s;s=c>>>16,a=_>>>16,i.__setDigit(r,c<<16|65535&l)}if(i.length>n)for(i.__setDigit(n++,s+a);n<i.length;)i.__setDigit(n++,0);else if(0!==s+a)throw new Error("implementation bug")}__inplaceMultiplyAdd(t,e,r){var n=Math.imul;r>this.length&&(r=this.length);const i=65535&t,o=t>>>16;let s=0,a=65535&e,u=e>>>16;for(let t=0;t<r;t++){const e=this.__digit(t),r=65535&e,l=e>>>16,_=n(r,i),c=n(r,o),f=n(l,i),h=n(l,o),g=a+(65535&_),d=u+s+(g>>>16)+(_>>>16)+(65535&c)+(65535&f);a=(c>>>16)+(f>>>16)+(65535&h)+(d>>>16),s=a>>>16,a&=65535,u=h>>>16,this.__setDigit(t,65535&g|d<<16)}if(0!=s||0!==a||0!==u)throw new Error("implementation bug")}static __absoluteDivSmall(t,e,r){null===r&&(r=new K(t.length,!1));let n=0;for(let i,o=2*t.length-1;0<=o;o-=2){i=(n<<16|t.__halfDigit(o))>>>0;const s=0|i/e;n=0|i%e,i=(n<<16|t.__halfDigit(o-1))>>>0;const a=0|i/e;n=0|i%e,r.__setDigit(o>>>1,s<<16|a)}return r}static __absoluteModSmall(t,e){let r=0;for(let n=2*t.length-1;0<=n;n--){r=0|((r<<16|t.__halfDigit(n))>>>0)%e}return r}static __absoluteDivLarge(t,e,r,n){var i=Math.imul;const o=e.__halfDigitLength(),s=e.length,a=t.__halfDigitLength()-o;let u=null;r&&(u=new K(a+2>>>1,!1),u.__initializeDigits());const l=new K(o+2>>>1,!1);l.__initializeDigits();const _=K.__clz16(e.__halfDigit(o-1));0<_&&(e=K.__specialLeftShift(e,_,0));const c=K.__specialLeftShift(t,_,1),f=e.__halfDigit(o-1);let h=0;for(let t,n=a;0<=n;n--){t=65535;const a=c.__halfDigit(n+o);if(a!==f){const r=(a<<16|c.__halfDigit(n+o-1))>>>0;t=0|r/f;let s=0|r%f;const u=e.__halfDigit(o-2),l=c.__halfDigit(n+o-2);for(;i(t,u)>>>0>(s<<16|l)>>>0&&(t--,s+=f,!(65535<s)););}K.__internalMultiplyAdd(e,t,0,s,l);let _=c.__inplaceSub(l,n,o+1);0!==_&&(_=c.__inplaceAdd(e,n,o),c.__setHalfDigit(n+o,c.__halfDigit(n+o)+_),t--),r&&(1&n?h=t<<16:u.__setDigit(n>>>1,h|t))}return n?(c.__inplaceRightShift(_),r?{quotient:u,remainder:c}:c):r?u:void 0}static __clz16(t){return Math.clz32(t)-16}__inplaceAdd(t,e,r){let n=0;for(let i=0;i<r;i++){const r=this.__halfDigit(e+i)+t.__halfDigit(i)+n;n=r>>>16,this.__setHalfDigit(e+i,r)}return n}__inplaceSub(t,e,r){let n=0;if(1&e){e>>=1;let i=this.__digit(e),o=65535&i,s=0;for(;s<r-1>>>1;s++){const r=t.__digit(s),a=(i>>>16)-(65535&r)-n;n=1&a>>>16,this.__setDigit(e+s,a<<16|65535&o),i=this.__digit(e+s+1),o=(65535&i)-(r>>>16)-n,n=1&o>>>16}const a=t.__digit(s),u=(i>>>16)-(65535&a)-n;if(n=1&u>>>16,this.__setDigit(e+s,u<<16|65535&o),e+s+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(i=this.__digit(e+s+1),o=(65535&i)-(a>>>16)-n,n=1&o>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;let i=0;for(;i<t.length-1;i++){const r=this.__digit(e+i),o=t.__digit(i),s=(65535&r)-(65535&o)-n;n=1&s>>>16;const a=(r>>>16)-(o>>>16)-n;n=1&a>>>16,this.__setDigit(e+i,a<<16|65535&s)}const o=this.__digit(e+i),s=t.__digit(i),a=(65535&o)-(65535&s)-n;n=1&a>>>16;let u=0;0==(1&r)&&(u=(o>>>16)-(s>>>16)-n,n=1&u>>>16),this.__setDigit(e+i,u<<16|65535&a)}return n}__inplaceRightShift(t){if(0===t)return;let e=this.__digit(0)>>>t;const r=this.length-1;for(let n=0;n<r;n++){const r=this.__digit(n+1);this.__setDigit(n,r<<32-t|e),e=r>>>t}this.__setDigit(r,e)}static __specialLeftShift(t,e,r){const n=t.length,i=new K(n+r,!1);if(0===e){for(let e=0;e<n;e++)i.__setDigit(e,t.__digit(e));return 0<r&&i.__setDigit(n,0),i}let o=0;for(let r=0;r<n;r++){const n=t.__digit(r);i.__setDigit(r,n<<e|o),o=n>>>32-e}return 0<r&&i.__setDigit(n,o),i}static __leftShiftByAbsolute(t,e){const r=K.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");const n=r>>>5,i=31&r,o=t.length,s=0!==i&&0!=t.__digit(o-1)>>>32-i,a=o+n+(s?1:0),u=new K(a,t.sign);if(0===i){let e=0;for(;e<n;e++)u.__setDigit(e,0);for(;e<a;e++)u.__setDigit(e,t.__digit(e-n))}else{let e=0;for(let t=0;t<n;t++)u.__setDigit(t,0);for(let r=0;r<o;r++){const o=t.__digit(r);u.__setDigit(r+n,o<<i|e),e=o>>>32-i}if(s)u.__setDigit(o+n,e);else if(0!=e)throw new Error("implementation bug")}return u.__trim()}static __rightShiftByAbsolute(t,e){const r=t.length,n=t.sign,i=K.__toShiftAmount(e);if(0>i)return K.__rightShiftByMaximum(n);const o=i>>>5,s=31&i;let a=r-o;if(0>=a)return K.__rightShiftByMaximum(n);let u=!1;if(n)if(0!=(t.__digit(o)&(1<<s)-1))u=!0;else for(let e=0;e<o;e++)if(0!==t.__digit(e)){u=!0;break}if(u&&0===s){0==~t.__digit(r-1)&&a++}let l=new K(a,n);if(0===s)for(let e=o;e<r;e++)l.__setDigit(e-o,t.__digit(e));else{let e=t.__digit(o)>>>s;const n=r-o-1;for(let r=0;r<n;r++){const n=t.__digit(r+o+1);l.__setDigit(r,n<<32-s|e),e=n>>>s}l.__setDigit(n,e)}return u&&(l=K.__absoluteAddOne(l,!0,l)),l.__trim()}static __rightShiftByMaximum(t){return t?K.__oneDigit(1,!0):K.__zero()}static __toShiftAmount(t){if(1<t.length)return-1;const e=t.__unsignedDigit(0);return e>K.__kMaxLengthBits?-1:e}static __toPrimitive(t,e="default"){if("object"!=typeof t)return t;if(t.constructor===K)return t;const r=t[Symbol.toPrimitive];if(r){const t=r(e);if("object"!=typeof t)return t;throw new TypeError("Cannot convert object to primitive value")}const n=t.valueOf;if(n){const e=n.call(t);if("object"!=typeof e)return e}const i=t.toString;if(i){const e=i.call(t);if("object"!=typeof e)return e}throw new TypeError("Cannot convert object to primitive value")}static __toNumeric(t){return K.__isBigInt(t)?t:+t}static __isBigInt(t){return"object"==typeof t&&t.constructor===K}static __truncateToNBits(t,e){const r=t+31>>>5,n=new K(r,e.sign),i=r-1;for(let t=0;t<i;t++)n.__setDigit(t,e.__digit(t));let o=e.__digit(i);if(0!=(31&t)){const e=32-(31&t);o=o<<e>>>e}return n.__setDigit(i,o),n.__trim()}static __truncateAndSubFromPowerOfTwo(t,e,r){var n=Math.min;const i=t+31>>>5,o=new K(i,r);let s=0;const a=i-1;let u=0;for(const t=n(a,e.length);s<t;s++){const t=e.__digit(s),r=0-(65535&t)-u;u=1&r>>>16;const n=0-(t>>>16)-u;u=1&n>>>16,o.__setDigit(s,65535&r|n<<16)}for(;s<a;s++)o.__setDigit(s,0|-u);let l=a<e.length?e.__digit(a):0;const _=31&t;let c;if(0==_){const t=0-(65535&l)-u;u=1&t>>>16,c=65535&t|0-(l>>>16)-u<<16}else{const t=32-_;l=l<<t>>>t;const e=1<<32-t,r=(65535&e)-(65535&l)-u;u=1&r>>>16,c=65535&r|(e>>>16)-(l>>>16)-u<<16,c&=e-1}return o.__setDigit(a,c),o.__trim()}__digit(t){return this[t]}__unsignedDigit(t){return this[t]>>>0}__setDigit(t,e){this[t]=0|e}__setDigitGrow(t,e){this[t]=0|e}__halfDigitLength(){const t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}__halfDigit(t){return 65535&this[t>>>1]>>>((1&t)<<4)}__setHalfDigit(t,e){const r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}static __digitPow(t,e){let r=1;for(;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}K.__kMaxLength=33554432,K.__kMaxLengthBits=K.__kMaxLength<<5,K.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],K.__kBitsPerCharTableShift=5,K.__kBitsPerCharTableMultiplier=1<<K.__kBitsPerCharTableShift,K.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],K.__kBitConversionBuffer=new ArrayBuffer(8),K.__kBitConversionDouble=new Float64Array(K.__kBitConversionBuffer),K.__kBitConversionInts=new Int32Array(K.__kBitConversionBuffer);const Y={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await Z(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),o=await i.json();if(o.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(o.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(o.error)}`);return o.result}};function tt(t){return K.BigInt(t)}function et(t){return"0x"+t.toString(16)}function rt(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,s=r.length+n.length,a=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>s)throw new Error(a);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(a);if(u.find(t=>!n.includes(t)))throw new Error(a)}function nt(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function it(t,e){if(nt(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function ot(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function st(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(rt(r,t,["code_hash","hash_type","args"],[]),it(`${r}.code_hash`,t.code_hash),nt(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function at(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){rt(r,t,["tx_hash","index"],[]),it(`${r}.tx_hash`,t.tx_hash),ot(`${r}.index`,t.index)}function ut(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){rt(r,t,["since","previous_output"],[]),ot(`${r}.since`,t.since),e&&at(t.previous_output,{debugPath:`${r}.previous_output`})}function lt(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){rt(r,t,["capacity","lock"],["type"]),ot(`${r}.capacity`,t.capacity),e&&(st(t.lock,{debugPath:`${r}.lock`}),t.type&&st(t.type,{debugPath:`${r}.type`}))}function _t(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(rt(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&at(t.out_point,{debugPath:`${r}.out_point`})}function ct(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function ft(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function ht(t,e,r){ot(`${t}.version`,e.version),ct(`${t}.cell_deps`,e.cell_deps,ft(_t,r),r),ct(`${t}.header_deps`,e.header_deps,it,r),ct(`${t}.inputs`,e.inputs,ft(ut,r),r),ct(`${t}.outputs`,e.outputs,ft(lt,r),r),ct(`${t}.outputs_data`,e.outputs_data,nt,r)}function gt(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){rt(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),ht(r,t,e)}function dt(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){rt(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),ht(r,t,e),ct(`${r}.witnesses`,t.witnesses,nt,e)}function pt(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){rt(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){ot(`${t}.version`,e.version),ot(`${t}.compact_target`,e.compact_target),ot(`${t}.timestamp`,e.timestamp),ot(`${t}.number`,e.number),ot(`${t}.epoch`,e.epoch),it(`${t}.parent_hash`,e.parent_hash),it(`${t}.transactions_root`,e.transactions_root),it(`${t}.proposals_hash`,e.proposals_hash),it(`${t}.uncles_hash`,e.uncles_hash),it(`${t}.dao`,e.dao)}(r,t)}function bt(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(rt(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),nt(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function mt(t,e){if(nt(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function yt(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){rt(r,t,["header","proposals"],[]),e&&bt(t.header,{debugPath:`${r}.header`}),ct(`${r}.proposals`,t.proposals,mt,e)}function wt(t,{nestedValidation:e=!0,debugPath:r="block"}={}){rt(r,t,["header","uncles","transactions","proposals"],[]),e&&bt(t.header,{debugPath:`${r}.header`}),ct(`${r}.uncles`,t.uncles,ft(yt,e),e),ct(`${r}.transactions`,t.transactions,ft(dt,e),e),ct(`${r}.proposals`,t.proposals,mt,e)}function vt(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){rt(r,t,["lock","message"],[]),nt(`${r}.message`,t.message),e&&st(t.lock,{debugPath:`${r}.lock`})}function Bt(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){rt(r,t,[],["lock","input_type","output_type"]),t.lock&&nt(`${r}.lock`,t.lock),t.input_type&&nt(`${r}.input_type`,t.input_type),t.output_type&&nt(`${r}.output_type`,t.output_type)}var Dt=Object.freeze({__proto__:null,ValidateScript:st,ValidateOutPoint:at,ValidateCellInput:ut,ValidateCellOutput:lt,ValidateCellDep:_t,ValidateRawTransaction:gt,ValidateTransaction:dt,ValidateRawHeader:pt,ValidateHeader:bt,ValidateUncleBlock:yt,ValidateBlock:wt,ValidateCellbaseWitness:vt,ValidateWitnessArgs:Bt});function St(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function Tt(t,e,r){if(!((e=St(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function Pt(t,{validation:e=!0,debugPath:r="script"}={}){return t=Tt(r,t,{code_hash:St,hash_type:St,args:St}),e&&st(t,{debugPath:`(transformed) ${r}`}),t}function Ct(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=Tt(r,t,{tx_hash:St,index:St}),e&&at(t,{debugPath:`(transformed) ${r}`}),t}function xt(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function kt(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=Tt(r,t,{since:St,previous_output:xt(Ct)}),e&&ut(t,{debugPath:`(transformed) ${r}`}),t}function Et(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=Tt(r,t,{capacity:St,lock:xt(Pt),type:xt(Pt)}),e&&lt(t,{debugPath:`(transformed) ${r}`}),t}function $t(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=Tt(r,t,{out_point:xt(Ct),dep_type:St}),e&&_t(t,{debugPath:`(transformed) ${r}`}),t}function At(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function Ot(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=Tt(r,t,{version:St,cell_deps:At(xt($t)),header_deps:At(St),inputs:At(xt(kt)),outputs:At(xt(Et)),outputs_data:At(St),witnesses:At(St)}),e&&dt(t,{debugPath:`(transformed) ${r}`}),t}function jt(t,{validation:e=!0,debugPath:r="header"}={}){return t=Tt(r,t,{version:St,compact_target:St,timestamp:St,number:St,epoch:St,parent_hash:St,transactions_root:St,proposals_hash:St,uncles_hash:St,dao:St,nonce:St}),e&&bt(t,{debugPath:`(transformed) ${r}`}),t}function zt(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=Tt(r,t,{header:xt(jt),proposals:At(St)}),e&&yt(t,{debugPath:`(transformed) ${r}`}),t}var It=Object.freeze({__proto__:null,TransformScript:Pt,TransformOutPoint:Ct,TransformCellInput:kt,TransformCellOutput:Et,TransformCellDep:$t,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=Tt(r,t,{version:St,cell_deps:At(xt($t)),header_deps:At(St),inputs:At(xt(kt)),outputs:At(xt(Et)),outputs_data:At(St)}),e&&gt(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:Ot,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=Tt(r,t,{version:St,compact_target:St,timestamp:St,number:St,epoch:St,parent_hash:St,transactions_root:St,proposals_hash:St,uncles_hash:St,dao:St}),e&&pt(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:jt,TransformUncleBlock:zt,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=Tt(r,t,{header:xt(jt),uncles:At(xt(zt)),transactions:At(xt(Ot)),proposals:At(St)}),e&&wt(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=Tt(r,t,{lock:xt(Pt),message:St}),e&&vt(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=Tt(r,t,{lock:St,input_type:St,output_type:St}),e&&Bt(t,{debugPath:`(transformed) ${r}`}),t}});var Rt=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:r=!0,loadData:n=!1}={}){this.rpc=t,this.lockHash=new u(e).serializeJson(),this.skipCellWithContent=r,this.loadData=n}async*collect(){const t=tt(await this.rpc.get_tip_block_number());let e=K.BigInt(0);for(;K.lessThanOrEqual(e,t);){let r=K.add(e,K.BigInt(100));K.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,et(e),et(r));for(const t of n)if(this.skipCellWithContent){if(t.type||K.greaterThan(tt(t.output_data_len),K.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=K.add(r,K.BigInt(1))}}}});exports.BigIntToHexString=et,exports.HexStringToBigInt=tt,exports.RPC=class{constructor(t){return this.uri=t,new Proxy(this,Y)}},exports.Reader=u,exports.VERSION="0.5.0",exports.cell_collectors=Rt,exports.transformers=It,exports.validators=Dt;
//# sourceMappingURL=ckb-js-toolkit.node.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).CKBJSToolkit={})}(this,(function(t){"use strict";class e{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class r{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class n{constructor(t){if("string"==typeof t){if(!t.startsWith("0x")||t.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new r(t)}if(t instanceof ArrayBuffer)return new e(t);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(t){const r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r>255)throw new Error("fromRawString can only accept UTF-8 raw string!");n.setUint8(e,r)}return new e(r)}}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:i);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,a="ArrayBuffer"in t;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function _(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function g(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=g(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=g(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=_(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[_(t)]},h.prototype.get=function(t){return t=_(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(_(t))},h.prototype.set=function(t,e){this.map[_(t)]=l(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),y.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},v.call(b.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];w.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function D(t,r){return new Promise((function(n,o){var a=new b(t,r);if(a.signal&&a.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}D.polyfill=!0,t.fetch||(t.fetch=D,t.Headers=h,t.Request=b,t.Response=w),e.Headers=h,e.Request=b,e.Response=w,e.fetch=D}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),s=(a.fetch,a.Headers,a.Request,a.Response,o((function(t,e){t.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function s(){return(s=a()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){function r(){return s(t,arguments,i(this).constructor)}if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)})(t)}function _(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var l=function(e){var o=Math.abs,a=Math.max,s=Math.imul,u=Math.clz32;function l(t,e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,l),t>l.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return(r=_(this,i(l).call(this,t))).sign=e,r}return n(l,e),r(l,[{key:"toDebugString",value:function(){var t=["BigInt["],e=!0,r=!1,n=void 0;try{for(var i,o,a=this[Symbol.iterator]();!(e=(i=a.next()).done);e=!0)o=i.value,t.push((o?(o>>>0).toString(16):o)+", ")}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}return t.push("]"),t.join("")}},{key:"toString",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10;if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?l.__toStringBasePowerOfTwo(this,t):l.__toStringGeneric(this,t,!1)}},{key:"__copy",value:function(){for(var t=new l(this.length,this.sign),e=0;e<this.length;e++)t[e]=this[e];return t}},{key:"__trim",value:function(){for(var t=this.length,e=this[t-1];0===e;)e=this[--t-1],this.pop();return 0===t&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var t=0;t<this.length;t++)this[t]=0}},{key:"__clzmsd",value:function(){return u(this[this.length-1])}},{key:"__inplaceMultiplyAdd",value:function(t,e,r){r>this.length&&(r=this.length);for(var n=65535&t,i=t>>>16,o=0,a=65535&e,u=e>>>16,_=0;_<r;_++){var l=this.__digit(_),f=65535&l,h=l>>>16,c=s(f,n),g=s(f,i),d=s(h,n),p=s(h,i),v=a+(65535&c),y=u+o+(v>>>16)+(c>>>16)+(65535&g)+(65535&d);o=(a=(g>>>16)+(d>>>16)+(65535&p)+(y>>>16))>>>16,a&=65535,u=p>>>16,this.__setDigit(_,65535&v|y<<16)}if(0!==o||0!==a||0!==u)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(t,e,r){for(var n,i=0,o=0;o<r;o++)i=(n=this.__halfDigit(e+o)+t.__halfDigit(o)+i)>>>16,this.__setHalfDigit(e+o,n);return i}},{key:"__inplaceSub",value:function(t,e,r){var n=0;if(1&e){e>>=1;for(var i=this.__digit(e),o=65535&i,a=0;a<r-1>>>1;a++){var s=t.__digit(a),u=(i>>>16)-(65535&s)-n;n=1&u>>>16,this.__setDigit(e+a,u<<16|65535&o),n=1&(o=(65535&(i=this.__digit(e+a+1)))-(s>>>16)-n)>>>16}var _=t.__digit(a),l=(i>>>16)-(65535&_)-n;if(n=1&l>>>16,this.__setDigit(e+a,l<<16|65535&o),e+a+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(n=1&(o=(65535&(i=this.__digit(e+a+1)))-(_>>>16)-n)>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;for(var f=0;f<t.length-1;f++){var h=this.__digit(e+f),c=t.__digit(f),g=(65535&h)-(65535&c)-n,d=(h>>>16)-(c>>>16)-(n=1&g>>>16);n=1&d>>>16,this.__setDigit(e+f,d<<16|65535&g)}var p=this.__digit(e+f),v=t.__digit(f),y=(65535&p)-(65535&v)-n;n=1&y>>>16;var b=0;0==(1&r)&&(n=1&(b=(p>>>16)-(v>>>16)-n)>>>16),this.__setDigit(e+f,b<<16|65535&y)}return n}},{key:"__inplaceRightShift",value:function(t){if(0!==t){for(var e,r=this.__digit(0)>>>t,n=this.length-1,i=0;i<n;i++)e=this.__digit(i+1),this.__setDigit(i,e<<32-t|r),r=e>>>t;this.__setDigit(n,r)}}},{key:"__digit",value:function(t){return this[t]}},{key:"__unsignedDigit",value:function(t){return this[t]>>>0}},{key:"__setDigit",value:function(t,e){this[t]=0|e}},{key:"__setDigitGrow",value:function(t,e){this[t]=0|e}},{key:"__halfDigitLength",value:function(){var t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}},{key:"__halfDigit",value:function(t){return 65535&this[t>>>1]>>>((1&t)<<4)}},{key:"__setHalfDigit",value:function(t,e){var r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}}],[{key:"BigInt",value:function(e){var r=Math.floor,n=Number.isFinite;if("number"==typeof e){if(0===e)return l.__zero();if((0|e)===e)return 0>e?l.__oneDigit(-e,!0):l.__oneDigit(e,!1);if(!n(e)||r(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return l.__fromDouble(e)}if("string"==typeof e){var i=l.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?l.__oneDigit(1,!1):l.__zero();if("object"===t(e)){if(e.constructor===l)return e;var o=l.__toPrimitive(e);return l.BigInt(o)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(t){var e=t.length;if(0===e)return 0;if(1===e){var r=t.__unsignedDigit(0);return t.sign?-r:r}var n=t.__digit(e-1),i=u(n),o=32*e-i;if(1024<o)return t.sign?-1/0:1/0;var a=o-1,s=n,_=e-1,f=i+1,h=32===f?0:s<<f;h>>>=12;var c=f-12,g=12<=f?0:s<<20+f,d=20+f;0<c&&0<_&&(_--,h|=(s=t.__digit(_))>>>32-c,g=s<<c,d=c),0<d&&0<_&&(_--,g|=(s=t.__digit(_))>>>32-d,d-=32);var p=l.__decideRounding(t,d,_,s);if((1===p||0===p&&1==(1&g))&&0==(g=g+1>>>0)&&0!=++h>>>20&&(h=0,1023<++a))return t.sign?-1/0:1/0;var v=t.sign?-2147483648:0;return a=a+1023<<20,l.__kBitConversionInts[1]=v|a|h,l.__kBitConversionInts[0]=g,l.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(t){if(0===t.length)return t;var e=t.__copy();return e.sign=!t.sign,e}},{key:"bitwiseNot",value:function(t){return t.sign?l.__absoluteSubOne(t).__trim():l.__absoluteAddOne(t,!0)}},{key:"exponentiate",value:function(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return l.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?l.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");var r=e.__unsignedDigit(0);if(1===r)return t;if(r>=l.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){var n=1+(r>>>5),i=new l(n,t.sign&&0!=(1&r));i.__initializeDigits();var o=1<<(31&r);return i.__setDigit(n-1,o),i}var a=null,s=t;for(0!=(1&r)&&(a=t),r>>=1;0!==r;r>>=1)s=l.multiply(s,s),0!=(1&r)&&(a=null===a?s:l.multiply(a,s));return a}},{key:"multiply",value:function(t,e){if(0===t.length)return t;if(0===e.length)return e;var r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;var n=new l(r,t.sign!==e.sign);n.__initializeDigits();for(var i=0;i<t.length;i++)l.__multiplyAccumulate(e,t.__digit(i),n,i);return n.__trim()}},{key:"divide",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return l.__zero();var r,n=t.sign!==e.sign,i=e.__unsignedDigit(0);if(1===e.length&&65535>=i){if(1===i)return n===t.sign?t:l.unaryMinus(t);r=l.__absoluteDivSmall(t,i,null)}else r=l.__absoluteDivLarge(t,e,!0,!1);return r.sign=n,r.__trim()}},{key:"remainder",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return t;var r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return l.__zero();var n=l.__absoluteModSmall(t,r);return 0===n?l.__zero():l.__oneDigit(n,t.sign)}var i=l.__absoluteDivLarge(t,e,!1,!0);return i.sign=t.sign,i.__trim()}},{key:"add",value:function(t,e){var r=t.sign;return r===e.sign?l.__absoluteAdd(t,e,r):0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r)}},{key:"subtract",value:function(t,e){var r=t.sign;return r===e.sign?0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r):l.__absoluteAdd(t,e,r)}},{key:"leftShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__rightShiftByAbsolute(t,e):l.__leftShiftByAbsolute(t,e)}},{key:"signedRightShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__leftShiftByAbsolute(t,e):l.__rightShiftByAbsolute(t,e)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(t,e){return 0>l.__compareToBigInt(t,e)}},{key:"lessThanOrEqual",value:function(t,e){return 0>=l.__compareToBigInt(t,e)}},{key:"greaterThan",value:function(t,e){return 0<l.__compareToBigInt(t,e)}},{key:"greaterThanOrEqual",value:function(t,e){return 0<=l.__compareToBigInt(t,e)}},{key:"equal",value:function(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}},{key:"notEqual",value:function(t,e){return!l.equal(t,e)}},{key:"bitwiseAnd",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length)+1,n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteOr(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}return l.__absoluteAndNot(t,l.__absoluteSubOne(e)).__trim()}},{key:"bitwiseXor",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length),n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return l.__absoluteXor(n,i,n).__trim()}var o=a(t.length,e.length)+1;if(t.sign){var s=[e,t];t=s[0],e=s[1]}var u=l.__absoluteSubOne(e,o);return u=l.__absoluteXor(u,t,u),l.__absoluteAddOne(u,!0,u).__trim()}},{key:"bitwiseOr",value:function(t,e){var r=a(t.length,e.length);if(!t.sign&&!e.sign)return l.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){var n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteAnd(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}var s=l.__absoluteSubOne(e,r);return s=l.__absoluteAndNot(s,t,s),l.__absoluteAddOne(s,!0,s).__trim()}},{key:"asIntN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return l.__truncateToNBits(t,e);if(!e.sign)return l.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(var o=r-2;0<=o;o--)if(0!==e.__digit(o))return l.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:l.__truncateToNBits(t,e)}return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}},{key:"asUintN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(e.sign){if(t>l.__kMaxLengthBits)throw new RangeError("BigInt too big");return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return l.__truncateToNBits(t,e)}},{key:"ADD",value:function(t,e){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)&&l.__isBigInt(e))return l.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(t,e){return l.__compare(t,e,0)}},{key:"LE",value:function(t,e){return l.__compare(t,e,1)}},{key:"GT",value:function(t,e){return l.__compare(t,e,2)}},{key:"GE",value:function(t,e){return l.__compare(t,e,3)}},{key:"EQ",value:function(e,r){for(;;){if(l.__isBigInt(e))return l.__isBigInt(r)?l.equal(e,r):l.EQ(r,e);if("number"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("string"==typeof e){if(l.__isBigInt(r))return null!==(e=l.__fromString(e))&&l.equal(e,r);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("boolean"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,+e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("symbol"===t(e)){if(l.__isBigInt(r))return!1;if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else{if("object"!==t(e))return e==r;if("object"===t(r)&&r.constructor!==l)return e==r;e=l.__toPrimitive(e)}}}},{key:"NE",value:function(t,e){return!l.EQ(t,e)}},{key:"__zero",value:function(){return new l(0,!1)}},{key:"__oneDigit",value:function(t,e){var r=new l(1,e);return r.__setDigit(0,t),r}},{key:"__decideRounding",value:function(t,e,r,n){if(0<e)return-1;var i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}var o=1<<i;if(0==(n&o))return-1;if(0!=(n&(o-=1)))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}},{key:"__fromDouble",value:function(t){l.__kBitConversionDouble[0]=t;var e,r=(2047&l.__kBitConversionInts[1]>>>20)-1023,n=1+(r>>>5),i=new l(n,0>t),o=1048575&l.__kBitConversionInts[1]|1048576,a=l.__kBitConversionInts[0],s=31&r,u=0;if(s<20){var _=20-s;u=_+32,e=o>>>_,o=o<<32-_|a>>>_,a<<=32-_}else if(20===s)u=32,e=o,o=a;else{var f=s-20;u=32-f,e=o<<f|a>>>32-f,o=a<<f}i.__setDigit(n-1,e);for(var h=n-2;0<=h;h--)0<u?(u-=32,e=o,o=a):e=0,i.__setDigit(h,e);return i.__trim()}},{key:"__isWhitespace",value:function(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}},{key:"__fromString",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=0,n=t.length,i=0;if(i===n)return l.__zero();for(var o=t.charCodeAt(i);l.__isWhitespace(o);){if(++i===n)return l.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return l.__zero();o=t.charCodeAt(i)}var a=n-i,s=l.__kMaxBitsPerChar[e],u=l.__kBitsPerCharTableMultiplier-1;if(a>1073741824/s)return null;var _=s*a+u>>>l.__kBitsPerCharTableShift,f=new l(_+31>>>5,!1),h=10>e?e:10,c=10<e?e-10:0;if(0==(e&e-1)){s>>=l.__kBitsPerCharTableShift;var g=[],d=[],p=!1;do{for(var v,y=0,b=0;;){if(v=void 0,o-48>>>0<h)v=o-48;else{if(!((32|o)-97>>>0<c)){p=!0;break}v=(32|o)-87}if(b+=s,y=y<<s|v,++i===n){p=!0;break}if(o=t.charCodeAt(i),32<b+s)break}g.push(y),d.push(b)}while(!p);l.__fillFromParts(f,g,d)}else{f.__initializeDigits();var m=!1,w=0;do{for(var k,D=0,B=1;;){if(k=void 0,o-48>>>0<h)k=o-48;else{if(!((32|o)-97>>>0<c)){m=!0;break}k=(32|o)-87}var A=B*e;if(4294967295<A)break;if(B=A,D=D*e+k,w++,++i===n){m=!0;break}o=t.charCodeAt(i)}var P=s*w+(u=32*l.__kBitsPerCharTableMultiplier-1)>>>l.__kBitsPerCharTableShift+5;f.__inplaceMultiplyAdd(B,D,P)}while(!m)}if(i!==n){if(!l.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!l.__isWhitespace(o))return null}return 0!==r&&10!==e?null:(f.sign=-1===r,f.__trim())}},{key:"__fillFromParts",value:function(t,e,r){for(var n=0,i=0,o=0,a=e.length-1;0<=a;a--){var s=e[a],u=r[a];i|=s<<o,32===(o+=u)?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),i=s>>>u-(o-=32))}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}},{key:"__toStringBasePowerOfTwo",value:function(t,e){var r=t.length,n=e-1,i=n=(15&(n=(51&(n=(85&n>>>1)+(85&n))>>>2)+(51&n))>>>4)+(15&n),o=e-1,a=t.__digit(r-1),s=0|(32*r-u(a)+i-1)/i;if(t.sign&&s++,268435456<s)throw new Error("string too long");for(var _=Array(s),f=s-1,h=0,c=0,g=0;g<r-1;g++){var d=t.__digit(g),p=(h|d<<c)&o;_[f--]=l.__kConversionChars[p];var v=i-c;for(h=d>>>v,c=32-v;c>=i;)_[f--]=l.__kConversionChars[h&o],h>>>=i,c-=i}var y=(h|a<<c)&o;for(_[f--]=l.__kConversionChars[y],h=a>>>i-c;0!==h;)_[f--]=l.__kConversionChars[h&o],h>>>=i;if(t.sign&&(_[f--]="-"),-1!==f)throw new Error("implementation bug");return _.join("")}},{key:"__toStringGeneric",value:function(t,e,r){var n=t.length;if(0===n)return"";if(1===n){var i=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(i="-"+i),i}var o,a,s=32*n-u(t.__digit(n-1)),_=l.__kMaxBitsPerChar[e]-1,f=s*l.__kBitsPerCharTableMultiplier,h=1+(f=0|(f+=_-1)/_)>>1,c=l.exponentiate(l.__oneDigit(e,!1),l.__oneDigit(h,!1)),g=c.__unsignedDigit(0);if(1===c.length&&65535>=g){(o=new l(t.length,!1)).__initializeDigits();for(var d,p=0,v=2*t.length-1;0<=v;v--)d=p<<16|t.__halfDigit(v),o.__setHalfDigit(v,0|d/g),p=0|d%g;a=p.toString(e)}else{var y=l.__absoluteDivLarge(t,c,!0,!0);o=y.quotient;var b=y.remainder.__trim();a=l.__toStringGeneric(b,e,!0)}o.__trim();for(var m=l.__toStringGeneric(o,e,!0);a.length<h;)a="0"+a;return!1===r&&t.sign&&(m="-"+m),m+a}},{key:"__unequalSign",value:function(t){return t?-1:1}},{key:"__absoluteGreater",value:function(t){return t?-1:1}},{key:"__absoluteLess",value:function(t){return t?1:-1}},{key:"__compareToBigInt",value:function(t,e){var r=t.sign;if(r!==e.sign)return l.__unequalSign(r);var n=l.__absoluteCompare(t,e);return 0<n?l.__absoluteGreater(r):0>n?l.__absoluteLess(r):0}},{key:"__compareToNumber",value:function(t,e){if(!0|e){var r=t.sign,n=0>e;if(r!==n)return l.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return l.__absoluteGreater(r);var i=o(e),a=t.__unsignedDigit(0);return a>i?l.__absoluteGreater(r):a<i?l.__absoluteLess(r):0}return l.__compareToDouble(t,e)}},{key:"__compareToDouble",value:function(t,e){if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;var r=t.sign;if(r!==0>e)return l.__unequalSign(r);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;l.__kBitConversionDouble[0]=e;var n=2047&l.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var i=n-1023;if(0>i)return l.__absoluteGreater(r);var o=t.length,a=t.__digit(o-1),s=u(a),_=32*o-s,f=i+1;if(_<f)return l.__absoluteLess(r);if(_>f)return l.__absoluteGreater(r);var h=1048576|1048575&l.__kBitConversionInts[1],c=l.__kBitConversionInts[0],g=31-s;if(g!==(_-1)%31)throw new Error("implementation bug");var d,p=0;if(g<20){var v=20-g;p=v+32,d=h>>>v,h=h<<32-v|c>>>v,c<<=32-v}else if(20===g)p=32,d=h,h=c;else{var y=g-20;p=32-y,d=h<<y|c>>>32-y,h=c<<y}if((a>>>=0)>(d>>>=0))return l.__absoluteGreater(r);if(a<d)return l.__absoluteLess(r);for(var b=o-2;0<=b;b--){0<p?(p-=32,d=h>>>0,h=c,c=0):d=0;var m=t.__unsignedDigit(b);if(m>d)return l.__absoluteGreater(r);if(m<d)return l.__absoluteLess(r)}if(0!==h||0!==c){if(0===p)throw new Error("implementation bug");return l.__absoluteLess(r)}return 0}},{key:"__equalToNumber",value:function(t,e){return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===o(e):0===l.__compareToDouble(t,e)}},{key:"__comparisonResultToBool",value:function(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}},{key:"__compare",value:function(t,e,r){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(l.__isBigInt(t)&&"string"==typeof e)return null!==(e=l.__fromString(e))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("string"==typeof t&&l.__isBigInt(e))return null!==(t=l.__fromString(t))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)){if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return l.__comparisonResultToBool(l.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}},{key:"__absoluteAdd",value:function(t,e,r){if(t.length<e.length)return l.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);var n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;for(var i=new l(n,r),o=0,a=0;a<e.length;a++){var s=e.__digit(a),u=t.__digit(a),_=(65535&u)+(65535&s)+o,f=(u>>>16)+(s>>>16)+(_>>>16);o=f>>>16,i.__setDigit(a,65535&_|f<<16)}for(;a<t.length;a++){var h=t.__digit(a),c=(65535&h)+o,g=(h>>>16)+(c>>>16);o=g>>>16,i.__setDigit(a,65535&c|g<<16)}return a<i.length&&i.__setDigit(a,o),i.__trim()}},{key:"__absoluteSub",value:function(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);for(var n=new l(t.length,r),i=0,o=0;o<e.length;o++){var a=t.__digit(o),s=e.__digit(o),u=(65535&a)-(65535&s)-i,_=(a>>>16)-(s>>>16)-(i=1&u>>>16);i=1&_>>>16,n.__setDigit(o,65535&u|_<<16)}for(;o<t.length;o++){var f=t.__digit(o),h=(65535&f)-i,c=(f>>>16)-(i=1&h>>>16);i=1&c>>>16,n.__setDigit(o,65535&h|c<<16)}return n.__trim()}},{key:"__absoluteAddOne",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length;null===r?r=new l(n,e):r.sign=e;for(var i=!0,o=0;o<n;o++){var a=t.__digit(o),s=-1===a;i&&(a=0|a+1),i=s,r.__setDigit(o,a)}return i&&r.__setDigitGrow(n,1),r}},{key:"__absoluteSubOne",value:function(t,e){for(var r=t.length,n=new l(e=e||r,!1),i=!0,o=0;o<r;o++){var a=t.__digit(o),s=0===a;i&&(a=0|a-1),i=s,n.__setDigit(o,a)}for(var u=r;u<e;u++)n.__setDigit(u,0);return n}},{key:"__absoluteAnd",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=o;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)&e.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteAndNot",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;n<i&&(o=n);var a=n;null===r?r=new l(a,!1):a=r.length;for(var s=0;s<o;s++)r.__setDigit(s,t.__digit(s)&~e.__digit(s));for(;s<n;s++)r.__setDigit(s,t.__digit(s));for(;s<a;s++)r.__setDigit(s,0);return r}},{key:"__absoluteOr",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)|e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteXor",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)^e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteCompare",value:function(t,e){var r=t.length-e.length;if(0!=r)return r;for(var n=t.length-1;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}},{key:"__multiplyAccumulate",value:function(t,e,r,n){if(0!==e){for(var i=65535&e,o=e>>>16,a=0,u=0,_=0,l=0;l<t.length;l++,n++){var f=r.__digit(n),h=65535&f,c=f>>>16,g=t.__digit(l),d=65535&g,p=g>>>16,v=s(d,i),y=s(d,o),b=s(p,i),m=s(p,o);a=(u=(y>>>16)+(b>>>16)+(65535&m)+(a=(c+=_+a+((h+=u+(65535&v))>>>16)+(v>>>16)+(65535&y)+(65535&b))>>>16))>>>16,u&=65535,_=m>>>16,f=65535&h|c<<16,r.__setDigit(n,f)}for(;0!==a||0!==u||0!==_;n++){var w=r.__digit(n),k=(65535&w)+u,D=(w>>>16)+(k>>>16)+_+a;u=0,_=0,a=D>>>16,w=65535&k|D<<16,r.__setDigit(n,w)}}}},{key:"__internalMultiplyAdd",value:function(t,e,r,n,i){for(var o=r,a=0,u=0;u<n;u++){var _=t.__digit(u),l=s(65535&_,e),f=(65535&l)+a+o;o=f>>>16;var h=s(_>>>16,e),c=(65535&h)+(l>>>16)+o;o=c>>>16,a=h>>>16,i.__setDigit(u,c<<16|65535&f)}if(i.length>n)for(i.__setDigit(n++,o+a);n<i.length;)i.__setDigit(n++,0);else if(0!==o+a)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(t,e,r){null===r&&(r=new l(t.length,!1));for(var n=0,i=2*t.length-1;0<=i;i-=2){var o=(n<<16|t.__halfDigit(i))>>>0,a=0|o/e,s=0|(o=((n=0|o%e)<<16|t.__halfDigit(i-1))>>>0)/e;n=0|o%e,r.__setDigit(i>>>1,a<<16|s)}return r}},{key:"__absoluteModSmall",value:function(t,e){for(var r=0,n=2*t.length-1;0<=n;n--)r=0|((r<<16|t.__halfDigit(n))>>>0)%e;return r}},{key:"__absoluteDivLarge",value:function(t,e,r,n){var i=e.__halfDigitLength(),o=e.length,a=t.__halfDigitLength()-i,u=null;r&&(u=new l(a+2>>>1,!1)).__initializeDigits();var _=new l(i+2>>>1,!1);_.__initializeDigits();var f=l.__clz16(e.__halfDigit(i-1));0<f&&(e=l.__specialLeftShift(e,f,0));for(var h=l.__specialLeftShift(t,f,1),c=e.__halfDigit(i-1),g=0,d=a;0<=d;d--){var p=65535,v=h.__halfDigit(d+i);if(v!==c){var y=(v<<16|h.__halfDigit(d+i-1))>>>0;p=0|y/c;for(var b=0|y%c,m=e.__halfDigit(i-2),w=h.__halfDigit(d+i-2);s(p,m)>>>0>(b<<16|w)>>>0&&(p--,!(65535<(b+=c))););}l.__internalMultiplyAdd(e,p,0,o,_);var k=h.__inplaceSub(_,d,i+1);0!==k&&(k=h.__inplaceAdd(e,d,i),h.__setHalfDigit(d+i,h.__halfDigit(d+i)+k),p--),r&&(1&d?g=p<<16:u.__setDigit(d>>>1,g|p))}return n?(h.__inplaceRightShift(f),r?{quotient:u,remainder:h}:h):r?u:void 0}},{key:"__clz16",value:function(t){return u(t)-16}},{key:"__specialLeftShift",value:function(t,e,r){var n=t.length,i=new l(n+r,!1);if(0===e){for(var o=0;o<n;o++)i.__setDigit(o,t.__digit(o));return 0<r&&i.__setDigit(n,0),i}for(var a,s=0,u=0;u<n;u++)a=t.__digit(u),i.__setDigit(u,a<<e|s),s=a>>>32-e;return 0<r&&i.__setDigit(n,s),i}},{key:"__leftShiftByAbsolute",value:function(t,e){var r=l.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");var n=r>>>5,i=31&r,o=t.length,a=0!==i&&0!=t.__digit(o-1)>>>32-i,s=o+n+(a?1:0),u=new l(s,t.sign);if(0===i){for(var _=0;_<n;_++)u.__setDigit(_,0);for(;_<s;_++)u.__setDigit(_,t.__digit(_-n))}else{for(var f=0,h=0;h<n;h++)u.__setDigit(h,0);for(var c,g=0;g<o;g++)c=t.__digit(g),u.__setDigit(g+n,c<<i|f),f=c>>>32-i;if(a)u.__setDigit(o+n,f);else if(0!==f)throw new Error("implementation bug")}return u.__trim()}},{key:"__rightShiftByAbsolute",value:function(t,e){var r=t.length,n=t.sign,i=l.__toShiftAmount(e);if(0>i)return l.__rightShiftByMaximum(n);var o=i>>>5,a=31&i,s=r-o;if(0>=s)return l.__rightShiftByMaximum(n);var u=!1;if(n)if(0!=(t.__digit(o)&(1<<a)-1))u=!0;else for(var _=0;_<o;_++)if(0!==t.__digit(_)){u=!0;break}u&&0===a&&0==~t.__digit(r-1)&&s++;var f=new l(s,n);if(0===a)for(var h=o;h<r;h++)f.__setDigit(h-o,t.__digit(h));else{for(var c,g=t.__digit(o)>>>a,d=r-o-1,p=0;p<d;p++)c=t.__digit(p+o+1),f.__setDigit(p,c<<32-a|g),g=c>>>a;f.__setDigit(d,g)}return u&&(f=l.__absoluteAddOne(f,!0,f)),f.__trim()}},{key:"__rightShiftByMaximum",value:function(t){return t?l.__oneDigit(1,!0):l.__zero()}},{key:"__toShiftAmount",value:function(t){if(1<t.length)return-1;var e=t.__unsignedDigit(0);return e>l.__kMaxLengthBits?-1:e}},{key:"__toPrimitive",value:function(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==t(e))return e;if(e.constructor===l)return e;var n=e[Symbol.toPrimitive];if(n){var i=n(r);if("object"!==t(i))return i;throw new TypeError("Cannot convert object to primitive value")}var o=e.valueOf;if(o){var a=o.call(e);if("object"!==t(a))return a}var s=e.toString;if(s){var u=s.call(e);if("object"!==t(u))return u}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(t){return l.__isBigInt(t)?t:+t}},{key:"__isBigInt",value:function(e){return"object"===t(e)&&e.constructor===l}},{key:"__truncateToNBits",value:function(t,e){for(var r=t+31>>>5,n=new l(r,e.sign),i=r-1,o=0;o<i;o++)n.__setDigit(o,e.__digit(o));var a=e.__digit(i);if(0!=(31&t)){var s=32-(31&t);a=a<<s>>>s}return n.__setDigit(i,a),n.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(t,e,r){for(var n=Math.min,i=t+31>>>5,o=new l(i,r),a=0,s=i-1,u=0,_=n(s,e.length);a<_;a++){var f=e.__digit(a),h=0-(65535&f)-u,c=0-(f>>>16)-(u=1&h>>>16);u=1&c>>>16,o.__setDigit(a,65535&h|c<<16)}for(;a<s;a++)o.__setDigit(a,0|-u);var g,d=s<e.length?e.__digit(s):0,p=31&t;if(0===p){var v=0-(65535&d)-u;g=65535&v|0-(d>>>16)-(u=1&v>>>16)<<16}else{var y=32-p,b=1<<32-y,m=(65535&b)-(65535&(d=d<<y>>>y))-u;g=65535&m|(b>>>16)-(d>>>16)-(u=1&m>>>16)<<16,g&=b-1}return o.__setDigit(s,g),o.__trim()}},{key:"__digitPow",value:function(t,e){for(var r=1;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}]),l}(u(Array));return l.__kMaxLength=33554432,l.__kMaxLengthBits=l.__kMaxLength<<5,l.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],l.__kBitsPerCharTableShift=5,l.__kBitsPerCharTableMultiplier=1<<l.__kBitsPerCharTableShift,l.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],l.__kBitConversionBuffer=new ArrayBuffer(8),l.__kBitConversionDouble=new Float64Array(l.__kBitConversionBuffer),l.__kBitConversionInts=new Int32Array(l.__kBitConversionBuffer),l}()})));const u={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await a(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),o=await i.json();if(o.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(o.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(o.error)}`);return o.result}};function _(t){return s.BigInt(t)}function l(t){return"0x"+t.toString(16)}function f(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,a=r.length+n.length,s=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>a)throw new Error(s);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(s);if(u.find(t=>!n.includes(t)))throw new Error(s)}function h(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function c(t,e){if(h(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function g(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function d(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(f(r,t,["code_hash","hash_type","args"],[]),c(`${r}.code_hash`,t.code_hash),h(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function p(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){f(r,t,["tx_hash","index"],[]),c(`${r}.tx_hash`,t.tx_hash),g(`${r}.index`,t.index)}function v(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){f(r,t,["since","previous_output"],[]),g(`${r}.since`,t.since),e&&p(t.previous_output,{debugPath:`${r}.previous_output`})}function y(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){f(r,t,["capacity","lock"],["type"]),g(`${r}.capacity`,t.capacity),e&&(d(t.lock,{debugPath:`${r}.lock`}),t.type&&d(t.type,{debugPath:`${r}.type`}))}function b(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(f(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&p(t.out_point,{debugPath:`${r}.out_point`})}function m(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function w(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function k(t,e,r){g(`${t}.version`,e.version),m(`${t}.cell_deps`,e.cell_deps,w(b,r),r),m(`${t}.header_deps`,e.header_deps,c,r),m(`${t}.inputs`,e.inputs,w(v,r),r),m(`${t}.outputs`,e.outputs,w(y,r),r),m(`${t}.outputs_data`,e.outputs_data,h,r)}function D(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),k(r,t,e)}function B(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),k(r,t,e),m(`${r}.witnesses`,t.witnesses,h,e)}function A(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){g(`${t}.version`,e.version),g(`${t}.compact_target`,e.compact_target),g(`${t}.timestamp`,e.timestamp),g(`${t}.number`,e.number),g(`${t}.epoch`,e.epoch),c(`${t}.parent_hash`,e.parent_hash),c(`${t}.transactions_root`,e.transactions_root),c(`${t}.proposals_hash`,e.proposals_hash),c(`${t}.uncles_hash`,e.uncles_hash),c(`${t}.dao`,e.dao)}(r,t)}function P(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),h(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function T(t,e){if(h(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function S(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){f(r,t,["header","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.proposals`,t.proposals,T,e)}function E(t,{nestedValidation:e=!0,debugPath:r="block"}={}){f(r,t,["header","uncles","transactions","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.uncles`,t.uncles,w(S,e),e),m(`${r}.transactions`,t.transactions,w(B,e),e),m(`${r}.proposals`,t.proposals,T,e)}function x(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){f(r,t,["lock","message"],[]),h(`${r}.message`,t.message),e&&d(t.lock,{debugPath:`${r}.lock`})}function C(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){f(r,t,[],["lock","input_type","output_type"]),t.lock&&h(`${r}.lock`,t.lock),t.input_type&&h(`${r}.input_type`,t.input_type),t.output_type&&h(`${r}.output_type`,t.output_type)}var O=Object.freeze({__proto__:null,ValidateScript:d,ValidateOutPoint:p,ValidateCellInput:v,ValidateCellOutput:y,ValidateCellDep:b,ValidateRawTransaction:D,ValidateTransaction:B,ValidateRawHeader:A,ValidateHeader:P,ValidateUncleBlock:S,ValidateBlock:E,ValidateCellbaseWitness:x,ValidateWitnessArgs:C});function $(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function I(t,e,r){if(!((e=$(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function R(t,{validation:e=!0,debugPath:r="script"}={}){return t=I(r,t,{code_hash:$,hash_type:$,args:$}),e&&d(t,{debugPath:`(transformed) ${r}`}),t}function j(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=I(r,t,{tx_hash:$,index:$}),e&&p(t,{debugPath:`(transformed) ${r}`}),t}function M(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function z(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=I(r,t,{since:$,previous_output:M(j)}),e&&v(t,{debugPath:`(transformed) ${r}`}),t}function L(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=I(r,t,{capacity:$,lock:M(R),type:M(R)}),e&&y(t,{debugPath:`(transformed) ${r}`}),t}function N(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=I(r,t,{out_point:M(j),dep_type:$}),e&&b(t,{debugPath:`(transformed) ${r}`}),t}function F(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function U(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($),witnesses:F($)}),e&&B(t,{debugPath:`(transformed) ${r}`}),t}function V(t,{validation:e=!0,debugPath:r="header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$,nonce:$}),e&&P(t,{debugPath:`(transformed) ${r}`}),t}function q(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=I(r,t,{header:M(V),proposals:F($)}),e&&S(t,{debugPath:`(transformed) ${r}`}),t}var H=Object.freeze({__proto__:null,TransformScript:R,TransformOutPoint:j,TransformCellInput:z,TransformCellOutput:L,TransformCellDep:N,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=I(r,t,{version:$,cell_deps:F(M(N)),header_deps:F($),inputs:F(M(z)),outputs:F(M(L)),outputs_data:F($)}),e&&D(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:U,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=I(r,t,{version:$,compact_target:$,timestamp:$,number:$,epoch:$,parent_hash:$,transactions_root:$,proposals_hash:$,uncles_hash:$,dao:$}),e&&A(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:V,TransformUncleBlock:q,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=I(r,t,{header:M(V),uncles:F(M(q)),transactions:F(M(U)),proposals:F($)}),e&&E(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=I(r,t,{lock:M(R),message:$}),e&&x(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=I(r,t,{lock:$,input_type:$,output_type:$}),e&&C(t,{debugPath:`(transformed) ${r}`}),t}});var G=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:r=!0,loadData:i=!1}={}){this.rpc=t,this.lockHash=new n(e).serializeJson(),this.skipCellWithContent=r,this.loadData=i}async*collect(){const t=_(await this.rpc.get_tip_block_number());let e=s.BigInt(0);for(;s.lessThanOrEqual(e,t);){let r=s.add(e,s.BigInt(100));s.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,l(e),l(r));for(const t of n)if(this.skipCellWithContent){if(t.type||s.greaterThan(_(t.output_data_len),s.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=s.add(r,s.BigInt(1))}}}});t.BigIntToHexString=l,t.HexStringToBigInt=_,t.RPC=class{constructor(t){return this.uri=t,new Proxy(this,u)}},t.Reader=n,t.cell_collectors=G,t.transformers=H,t.validators=O,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).CKBJSToolkit={})}(this,(function(t){"use strict";class e{constructor(t){this.view=new DataView(t)}length(){return this.view.byteLength}indexAt(t){return this.view.getUint8(t)}toArrayBuffer(){return this.view.buffer}serializeJson(){return"0x"+Array.prototype.map.call(new Uint8Array(this.view.buffer),t=>("00"+t.toString(16)).slice(-2)).join("")}}class r{constructor(t){this.string=t}length(){return this.string.length/2-1}indexAt(t){return parseInt(this.string.substr(2+2*t,2),16)}toArrayBuffer(){const t=new ArrayBuffer(this.length()),e=new DataView(t);for(let t=0;t<this.length();t++)e.setUint8(t,this.indexAt(t));return t}serializeJson(){return this.string}}class n{constructor(t){if("string"==typeof t){if(!t.startsWith("0x")||t.length%2!=0)throw new Error("Hex string must start with 0x, and has even numbered length!");return new r(t)}if(t instanceof ArrayBuffer)return new e(t);throw new Error("Reader can only accept hex string or ArrayBuffer!")}static fromRawString(t){const r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r>255)throw new Error("fromRawString can only accept UTF-8 raw string!");n.setUint8(e,r)}return new e(r)}}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:i);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,a="ArrayBuffer"in t;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function _(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function g(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=g(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=g(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=_(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[_(t)]},h.prototype.get=function(t){return t=_(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(_(t))},h.prototype.set=function(t,e){this.map[_(t)]=l(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),y.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},v.call(b.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];w.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function D(t,r){return new Promise((function(n,o){var a=new b(t,r);if(a.signal&&a.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}D.polyfill=!0,t.fetch||(t.fetch=D,t.Headers=h,t.Request=b,t.Response=w),e.Headers=h,e.Request=b,e.Response=w,e.fetch=D}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),s=(a.fetch,a.Headers,a.Request,a.Response,o((function(t,e){t.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function s(){return(s=a()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){function r(){return s(t,arguments,i(this).constructor)}if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)})(t)}function _(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var l=function(e){var o=Math.abs,a=Math.max,s=Math.imul,u=Math.clz32;function l(t,e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,l),t>l.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return(r=_(this,i(l).call(this,t))).sign=e,r}return n(l,e),r(l,[{key:"toDebugString",value:function(){var t=["BigInt["],e=!0,r=!1,n=void 0;try{for(var i,o,a=this[Symbol.iterator]();!(e=(i=a.next()).done);e=!0)o=i.value,t.push((o?(o>>>0).toString(16):o)+", ")}catch(t){r=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(r)throw n}}return t.push("]"),t.join("")}},{key:"toString",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10;if(2>t||36<t)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":0==(t&t-1)?l.__toStringBasePowerOfTwo(this,t):l.__toStringGeneric(this,t,!1)}},{key:"__copy",value:function(){for(var t=new l(this.length,this.sign),e=0;e<this.length;e++)t[e]=this[e];return t}},{key:"__trim",value:function(){for(var t=this.length,e=this[t-1];0===e;)e=this[--t-1],this.pop();return 0===t&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var t=0;t<this.length;t++)this[t]=0}},{key:"__clzmsd",value:function(){return u(this[this.length-1])}},{key:"__inplaceMultiplyAdd",value:function(t,e,r){r>this.length&&(r=this.length);for(var n=65535&t,i=t>>>16,o=0,a=65535&e,u=e>>>16,_=0;_<r;_++){var l=this.__digit(_),f=65535&l,h=l>>>16,c=s(f,n),g=s(f,i),d=s(h,n),p=s(h,i),v=a+(65535&c),y=u+o+(v>>>16)+(c>>>16)+(65535&g)+(65535&d);o=(a=(g>>>16)+(d>>>16)+(65535&p)+(y>>>16))>>>16,a&=65535,u=p>>>16,this.__setDigit(_,65535&v|y<<16)}if(0!==o||0!==a||0!==u)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(t,e,r){for(var n,i=0,o=0;o<r;o++)i=(n=this.__halfDigit(e+o)+t.__halfDigit(o)+i)>>>16,this.__setHalfDigit(e+o,n);return i}},{key:"__inplaceSub",value:function(t,e,r){var n=0;if(1&e){e>>=1;for(var i=this.__digit(e),o=65535&i,a=0;a<r-1>>>1;a++){var s=t.__digit(a),u=(i>>>16)-(65535&s)-n;n=1&u>>>16,this.__setDigit(e+a,u<<16|65535&o),n=1&(o=(65535&(i=this.__digit(e+a+1)))-(s>>>16)-n)>>>16}var _=t.__digit(a),l=(i>>>16)-(65535&_)-n;if(n=1&l>>>16,this.__setDigit(e+a,l<<16|65535&o),e+a+1>=this.length)throw new RangeError("out of bounds");0==(1&r)&&(n=1&(o=(65535&(i=this.__digit(e+a+1)))-(_>>>16)-n)>>>16,this.__setDigit(e+t.length,4294901760&i|65535&o))}else{e>>=1;for(var f=0;f<t.length-1;f++){var h=this.__digit(e+f),c=t.__digit(f),g=(65535&h)-(65535&c)-n,d=(h>>>16)-(c>>>16)-(n=1&g>>>16);n=1&d>>>16,this.__setDigit(e+f,d<<16|65535&g)}var p=this.__digit(e+f),v=t.__digit(f),y=(65535&p)-(65535&v)-n;n=1&y>>>16;var b=0;0==(1&r)&&(n=1&(b=(p>>>16)-(v>>>16)-n)>>>16),this.__setDigit(e+f,b<<16|65535&y)}return n}},{key:"__inplaceRightShift",value:function(t){if(0!==t){for(var e,r=this.__digit(0)>>>t,n=this.length-1,i=0;i<n;i++)e=this.__digit(i+1),this.__setDigit(i,e<<32-t|r),r=e>>>t;this.__setDigit(n,r)}}},{key:"__digit",value:function(t){return this[t]}},{key:"__unsignedDigit",value:function(t){return this[t]>>>0}},{key:"__setDigit",value:function(t,e){this[t]=0|e}},{key:"__setDigitGrow",value:function(t,e){this[t]=0|e}},{key:"__halfDigitLength",value:function(){var t=this.length;return 65535>=this.__unsignedDigit(t-1)?2*t-1:2*t}},{key:"__halfDigit",value:function(t){return 65535&this[t>>>1]>>>((1&t)<<4)}},{key:"__setHalfDigit",value:function(t,e){var r=t>>>1,n=this.__digit(r),i=1&t?65535&n|e<<16:4294901760&n|65535&e;this.__setDigit(r,i)}}],[{key:"BigInt",value:function(e){var r=Math.floor,n=Number.isFinite;if("number"==typeof e){if(0===e)return l.__zero();if((0|e)===e)return 0>e?l.__oneDigit(-e,!0):l.__oneDigit(e,!1);if(!n(e)||r(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return l.__fromDouble(e)}if("string"==typeof e){var i=l.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?l.__oneDigit(1,!1):l.__zero();if("object"===t(e)){if(e.constructor===l)return e;var o=l.__toPrimitive(e);return l.BigInt(o)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(t){var e=t.length;if(0===e)return 0;if(1===e){var r=t.__unsignedDigit(0);return t.sign?-r:r}var n=t.__digit(e-1),i=u(n),o=32*e-i;if(1024<o)return t.sign?-1/0:1/0;var a=o-1,s=n,_=e-1,f=i+1,h=32===f?0:s<<f;h>>>=12;var c=f-12,g=12<=f?0:s<<20+f,d=20+f;0<c&&0<_&&(_--,h|=(s=t.__digit(_))>>>32-c,g=s<<c,d=c),0<d&&0<_&&(_--,g|=(s=t.__digit(_))>>>32-d,d-=32);var p=l.__decideRounding(t,d,_,s);if((1===p||0===p&&1==(1&g))&&0==(g=g+1>>>0)&&0!=++h>>>20&&(h=0,1023<++a))return t.sign?-1/0:1/0;var v=t.sign?-2147483648:0;return a=a+1023<<20,l.__kBitConversionInts[1]=v|a|h,l.__kBitConversionInts[0]=g,l.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(t){if(0===t.length)return t;var e=t.__copy();return e.sign=!t.sign,e}},{key:"bitwiseNot",value:function(t){return t.sign?l.__absoluteSubOne(t).__trim():l.__absoluteAddOne(t,!0)}},{key:"exponentiate",value:function(t,e){if(e.sign)throw new RangeError("Exponent must be positive");if(0===e.length)return l.__oneDigit(1,!1);if(0===t.length)return t;if(1===t.length&&1===t.__digit(0))return t.sign&&0==(1&e.__digit(0))?l.unaryMinus(t):t;if(1<e.length)throw new RangeError("BigInt too big");var r=e.__unsignedDigit(0);if(1===r)return t;if(r>=l.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===t.length&&2===t.__digit(0)){var n=1+(r>>>5),i=new l(n,t.sign&&0!=(1&r));i.__initializeDigits();var o=1<<(31&r);return i.__setDigit(n-1,o),i}var a=null,s=t;for(0!=(1&r)&&(a=t),r>>=1;0!==r;r>>=1)s=l.multiply(s,s),0!=(1&r)&&(a=null===a?s:l.multiply(a,s));return a}},{key:"multiply",value:function(t,e){if(0===t.length)return t;if(0===e.length)return e;var r=t.length+e.length;32<=t.__clzmsd()+e.__clzmsd()&&r--;var n=new l(r,t.sign!==e.sign);n.__initializeDigits();for(var i=0;i<t.length;i++)l.__multiplyAccumulate(e,t.__digit(i),n,i);return n.__trim()}},{key:"divide",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return l.__zero();var r,n=t.sign!==e.sign,i=e.__unsignedDigit(0);if(1===e.length&&65535>=i){if(1===i)return n===t.sign?t:l.unaryMinus(t);r=l.__absoluteDivSmall(t,i,null)}else r=l.__absoluteDivLarge(t,e,!0,!1);return r.sign=n,r.__trim()}},{key:"remainder",value:function(t,e){if(0===e.length)throw new RangeError("Division by zero");if(0>l.__absoluteCompare(t,e))return t;var r=e.__unsignedDigit(0);if(1===e.length&&65535>=r){if(1===r)return l.__zero();var n=l.__absoluteModSmall(t,r);return 0===n?l.__zero():l.__oneDigit(n,t.sign)}var i=l.__absoluteDivLarge(t,e,!1,!0);return i.sign=t.sign,i.__trim()}},{key:"add",value:function(t,e){var r=t.sign;return r===e.sign?l.__absoluteAdd(t,e,r):0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r)}},{key:"subtract",value:function(t,e){var r=t.sign;return r===e.sign?0<=l.__absoluteCompare(t,e)?l.__absoluteSub(t,e,r):l.__absoluteSub(e,t,!r):l.__absoluteAdd(t,e,r)}},{key:"leftShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__rightShiftByAbsolute(t,e):l.__leftShiftByAbsolute(t,e)}},{key:"signedRightShift",value:function(t,e){return 0===e.length||0===t.length?t:e.sign?l.__leftShiftByAbsolute(t,e):l.__rightShiftByAbsolute(t,e)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(t,e){return 0>l.__compareToBigInt(t,e)}},{key:"lessThanOrEqual",value:function(t,e){return 0>=l.__compareToBigInt(t,e)}},{key:"greaterThan",value:function(t,e){return 0<l.__compareToBigInt(t,e)}},{key:"greaterThanOrEqual",value:function(t,e){return 0<=l.__compareToBigInt(t,e)}},{key:"equal",value:function(t,e){if(t.sign!==e.sign)return!1;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t.__digit(r)!==e.__digit(r))return!1;return!0}},{key:"notEqual",value:function(t,e){return!l.equal(t,e)}},{key:"bitwiseAnd",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteAnd(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length)+1,n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteOr(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}return l.__absoluteAndNot(t,l.__absoluteSubOne(e)).__trim()}},{key:"bitwiseXor",value:function(t,e){if(!t.sign&&!e.sign)return l.__absoluteXor(t,e).__trim();if(t.sign&&e.sign){var r=a(t.length,e.length),n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return l.__absoluteXor(n,i,n).__trim()}var o=a(t.length,e.length)+1;if(t.sign){var s=[e,t];t=s[0],e=s[1]}var u=l.__absoluteSubOne(e,o);return u=l.__absoluteXor(u,t,u),l.__absoluteAddOne(u,!0,u).__trim()}},{key:"bitwiseOr",value:function(t,e){var r=a(t.length,e.length);if(!t.sign&&!e.sign)return l.__absoluteOr(t,e).__trim();if(t.sign&&e.sign){var n=l.__absoluteSubOne(t,r),i=l.__absoluteSubOne(e);return n=l.__absoluteAnd(n,i,n),l.__absoluteAddOne(n,!0,n).__trim()}if(t.sign){var o=[e,t];t=o[0],e=o[1]}var s=l.__absoluteSubOne(e,r);return s=l.__absoluteAndNot(s,t,s),l.__absoluteAddOne(s,!0,s).__trim()}},{key:"asIntN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=e.__unsignedDigit(r-1),i=1<<(31&t-1);if(e.length===r&&n<i)return e;if((n&i)!==i)return l.__truncateToNBits(t,e);if(!e.sign)return l.__truncateAndSubFromPowerOfTwo(t,e,!0);if(0==(n&i-1)){for(var o=r-2;0<=o;o--)if(0!==e.__digit(o))return l.__truncateAndSubFromPowerOfTwo(t,e,!1);return e.length===r&&n===i?e:l.__truncateToNBits(t,e)}return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}},{key:"asUintN",value:function(t,e){if(0===e.length)return e;if(0===t)return l.__zero();if(e.sign){if(t>l.__kMaxLengthBits)throw new RangeError("BigInt too big");return l.__truncateAndSubFromPowerOfTwo(t,e,!1)}if(t>=l.__kMaxLengthBits)return e;var r=t+31>>>5;if(e.length<r)return e;var n=31&t;if(e.length==r){if(0==n)return e;if(0==e.__digit(r-1)>>>n)return e}return l.__truncateToNBits(t,e)}},{key:"ADD",value:function(t,e){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t)return"string"!=typeof e&&(e=e.toString()),t+e;if("string"==typeof e)return t.toString()+e;if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)&&l.__isBigInt(e))return l.add(t,e);if("number"==typeof t&&"number"==typeof e)return t+e;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(t,e){return l.__compare(t,e,0)}},{key:"LE",value:function(t,e){return l.__compare(t,e,1)}},{key:"GT",value:function(t,e){return l.__compare(t,e,2)}},{key:"GE",value:function(t,e){return l.__compare(t,e,3)}},{key:"EQ",value:function(e,r){for(;;){if(l.__isBigInt(e))return l.__isBigInt(r)?l.equal(e,r):l.EQ(r,e);if("number"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("string"==typeof e){if(l.__isBigInt(r))return null!==(e=l.__fromString(e))&&l.equal(e,r);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("boolean"==typeof e){if(l.__isBigInt(r))return l.__equalToNumber(r,+e);if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else if("symbol"===t(e)){if(l.__isBigInt(r))return!1;if("object"!==t(r))return e==r;r=l.__toPrimitive(r)}else{if("object"!==t(e))return e==r;if("object"===t(r)&&r.constructor!==l)return e==r;e=l.__toPrimitive(e)}}}},{key:"NE",value:function(t,e){return!l.EQ(t,e)}},{key:"__zero",value:function(){return new l(0,!1)}},{key:"__oneDigit",value:function(t,e){var r=new l(1,e);return r.__setDigit(0,t),r}},{key:"__decideRounding",value:function(t,e,r,n){if(0<e)return-1;var i;if(0>e)i=-e-1;else{if(0===r)return-1;r--,n=t.__digit(r),i=31}var o=1<<i;if(0==(n&o))return-1;if(0!=(n&(o-=1)))return 1;for(;0<r;)if(r--,0!==t.__digit(r))return 1;return 0}},{key:"__fromDouble",value:function(t){l.__kBitConversionDouble[0]=t;var e,r=(2047&l.__kBitConversionInts[1]>>>20)-1023,n=1+(r>>>5),i=new l(n,0>t),o=1048575&l.__kBitConversionInts[1]|1048576,a=l.__kBitConversionInts[0],s=31&r,u=0;if(s<20){var _=20-s;u=_+32,e=o>>>_,o=o<<32-_|a>>>_,a<<=32-_}else if(20===s)u=32,e=o,o=a;else{var f=s-20;u=32-f,e=o<<f|a>>>32-f,o=a<<f}i.__setDigit(n-1,e);for(var h=n-2;0<=h;h--)0<u?(u-=32,e=o,o=a):e=0,i.__setDigit(h,e);return i.__trim()}},{key:"__isWhitespace",value:function(t){return!!(13>=t&&9<=t)||(159>=t?32==t:131071>=t?160==t||5760==t:196607>=t?10>=(t&=131071)||40==t||41==t||47==t||95==t||4096==t:65279==t)}},{key:"__fromString",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=0,n=t.length,i=0;if(i===n)return l.__zero();for(var o=t.charCodeAt(i);l.__isWhitespace(o);){if(++i===n)return l.__zero();o=t.charCodeAt(i)}if(43===o){if(++i===n)return null;o=t.charCodeAt(i),r=1}else if(45===o){if(++i===n)return null;o=t.charCodeAt(i),r=-1}if(0===e){if(e=10,48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(e=16,++i===n)return null;o=t.charCodeAt(i)}else if(79===o||111===o){if(e=8,++i===n)return null;o=t.charCodeAt(i)}else if(66===o||98===o){if(e=2,++i===n)return null;o=t.charCodeAt(i)}}}else if(16===e&&48===o){if(++i===n)return l.__zero();if(88===(o=t.charCodeAt(i))||120===o){if(++i===n)return null;o=t.charCodeAt(i)}}for(;48===o;){if(++i===n)return l.__zero();o=t.charCodeAt(i)}var a=n-i,s=l.__kMaxBitsPerChar[e],u=l.__kBitsPerCharTableMultiplier-1;if(a>1073741824/s)return null;var _=s*a+u>>>l.__kBitsPerCharTableShift,f=new l(_+31>>>5,!1),h=10>e?e:10,c=10<e?e-10:0;if(0==(e&e-1)){s>>=l.__kBitsPerCharTableShift;var g=[],d=[],p=!1;do{for(var v,y=0,b=0;;){if(v=void 0,o-48>>>0<h)v=o-48;else{if(!((32|o)-97>>>0<c)){p=!0;break}v=(32|o)-87}if(b+=s,y=y<<s|v,++i===n){p=!0;break}if(o=t.charCodeAt(i),32<b+s)break}g.push(y),d.push(b)}while(!p);l.__fillFromParts(f,g,d)}else{f.__initializeDigits();var m=!1,w=0;do{for(var k,D=0,B=1;;){if(k=void 0,o-48>>>0<h)k=o-48;else{if(!((32|o)-97>>>0<c)){m=!0;break}k=(32|o)-87}var A=B*e;if(4294967295<A)break;if(B=A,D=D*e+k,w++,++i===n){m=!0;break}o=t.charCodeAt(i)}var P=s*w+(u=32*l.__kBitsPerCharTableMultiplier-1)>>>l.__kBitsPerCharTableShift+5;f.__inplaceMultiplyAdd(B,D,P)}while(!m)}if(i!==n){if(!l.__isWhitespace(o))return null;for(i++;i<n;i++)if(o=t.charCodeAt(i),!l.__isWhitespace(o))return null}return 0!==r&&10!==e?null:(f.sign=-1===r,f.__trim())}},{key:"__fillFromParts",value:function(t,e,r){for(var n=0,i=0,o=0,a=e.length-1;0<=a;a--){var s=e[a],u=r[a];i|=s<<o,32===(o+=u)?(t.__setDigit(n++,i),o=0,i=0):32<o&&(t.__setDigit(n++,i),i=s>>>u-(o-=32))}if(0!==i){if(n>=t.length)throw new Error("implementation bug");t.__setDigit(n++,i)}for(;n<t.length;n++)t.__setDigit(n,0)}},{key:"__toStringBasePowerOfTwo",value:function(t,e){var r=t.length,n=e-1,i=n=(15&(n=(51&(n=(85&n>>>1)+(85&n))>>>2)+(51&n))>>>4)+(15&n),o=e-1,a=t.__digit(r-1),s=0|(32*r-u(a)+i-1)/i;if(t.sign&&s++,268435456<s)throw new Error("string too long");for(var _=Array(s),f=s-1,h=0,c=0,g=0;g<r-1;g++){var d=t.__digit(g),p=(h|d<<c)&o;_[f--]=l.__kConversionChars[p];var v=i-c;for(h=d>>>v,c=32-v;c>=i;)_[f--]=l.__kConversionChars[h&o],h>>>=i,c-=i}var y=(h|a<<c)&o;for(_[f--]=l.__kConversionChars[y],h=a>>>i-c;0!==h;)_[f--]=l.__kConversionChars[h&o],h>>>=i;if(t.sign&&(_[f--]="-"),-1!==f)throw new Error("implementation bug");return _.join("")}},{key:"__toStringGeneric",value:function(t,e,r){var n=t.length;if(0===n)return"";if(1===n){var i=t.__unsignedDigit(0).toString(e);return!1===r&&t.sign&&(i="-"+i),i}var o,a,s=32*n-u(t.__digit(n-1)),_=l.__kMaxBitsPerChar[e]-1,f=s*l.__kBitsPerCharTableMultiplier,h=1+(f=0|(f+=_-1)/_)>>1,c=l.exponentiate(l.__oneDigit(e,!1),l.__oneDigit(h,!1)),g=c.__unsignedDigit(0);if(1===c.length&&65535>=g){(o=new l(t.length,!1)).__initializeDigits();for(var d,p=0,v=2*t.length-1;0<=v;v--)d=p<<16|t.__halfDigit(v),o.__setHalfDigit(v,0|d/g),p=0|d%g;a=p.toString(e)}else{var y=l.__absoluteDivLarge(t,c,!0,!0);o=y.quotient;var b=y.remainder.__trim();a=l.__toStringGeneric(b,e,!0)}o.__trim();for(var m=l.__toStringGeneric(o,e,!0);a.length<h;)a="0"+a;return!1===r&&t.sign&&(m="-"+m),m+a}},{key:"__unequalSign",value:function(t){return t?-1:1}},{key:"__absoluteGreater",value:function(t){return t?-1:1}},{key:"__absoluteLess",value:function(t){return t?1:-1}},{key:"__compareToBigInt",value:function(t,e){var r=t.sign;if(r!==e.sign)return l.__unequalSign(r);var n=l.__absoluteCompare(t,e);return 0<n?l.__absoluteGreater(r):0>n?l.__absoluteLess(r):0}},{key:"__compareToNumber",value:function(t,e){if(!0|e){var r=t.sign,n=0>e;if(r!==n)return l.__unequalSign(r);if(0===t.length){if(n)throw new Error("implementation bug");return 0===e?0:-1}if(1<t.length)return l.__absoluteGreater(r);var i=o(e),a=t.__unsignedDigit(0);return a>i?l.__absoluteGreater(r):a<i?l.__absoluteLess(r):0}return l.__compareToDouble(t,e)}},{key:"__compareToDouble",value:function(t,e){if(e!=e)return e;if(e===1/0)return-1;if(e===-1/0)return 1;var r=t.sign;if(r!==0>e)return l.__unequalSign(r);if(0===e)throw new Error("implementation bug: should be handled elsewhere");if(0===t.length)return-1;l.__kBitConversionDouble[0]=e;var n=2047&l.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var i=n-1023;if(0>i)return l.__absoluteGreater(r);var o=t.length,a=t.__digit(o-1),s=u(a),_=32*o-s,f=i+1;if(_<f)return l.__absoluteLess(r);if(_>f)return l.__absoluteGreater(r);var h=1048576|1048575&l.__kBitConversionInts[1],c=l.__kBitConversionInts[0],g=31-s;if(g!==(_-1)%31)throw new Error("implementation bug");var d,p=0;if(g<20){var v=20-g;p=v+32,d=h>>>v,h=h<<32-v|c>>>v,c<<=32-v}else if(20===g)p=32,d=h,h=c;else{var y=g-20;p=32-y,d=h<<y|c>>>32-y,h=c<<y}if((a>>>=0)>(d>>>=0))return l.__absoluteGreater(r);if(a<d)return l.__absoluteLess(r);for(var b=o-2;0<=b;b--){0<p?(p-=32,d=h>>>0,h=c,c=0):d=0;var m=t.__unsignedDigit(b);if(m>d)return l.__absoluteGreater(r);if(m<d)return l.__absoluteLess(r)}if(0!==h||0!==c){if(0===p)throw new Error("implementation bug");return l.__absoluteLess(r)}return 0}},{key:"__equalToNumber",value:function(t,e){return e|0===e?0===e?0===t.length:1===t.length&&t.sign===0>e&&t.__unsignedDigit(0)===o(e):0===l.__compareToDouble(t,e)}},{key:"__comparisonResultToBool",value:function(t,e){switch(e){case 0:return 0>t;case 1:return 0>=t;case 2:return 0<t;case 3:return 0<=t}throw new Error("unreachable")}},{key:"__compare",value:function(t,e,r){if(t=l.__toPrimitive(t),e=l.__toPrimitive(e),"string"==typeof t&&"string"==typeof e)switch(r){case 0:return t<e;case 1:return t<=e;case 2:return t>e;case 3:return t>=e}if(l.__isBigInt(t)&&"string"==typeof e)return null!==(e=l.__fromString(e))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("string"==typeof t&&l.__isBigInt(e))return null!==(t=l.__fromString(t))&&l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if(t=l.__toNumeric(t),e=l.__toNumeric(e),l.__isBigInt(t)){if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToBigInt(t,e),r);if("number"!=typeof e)throw new Error("implementation bug");return l.__comparisonResultToBool(l.__compareToNumber(t,e),r)}if("number"!=typeof t)throw new Error("implementation bug");if(l.__isBigInt(e))return l.__comparisonResultToBool(l.__compareToNumber(e,t),2^r);if("number"!=typeof e)throw new Error("implementation bug");return 0===r?t<e:1===r?t<=e:2===r?t>e:3===r?t>=e:void 0}},{key:"__absoluteAdd",value:function(t,e,r){if(t.length<e.length)return l.__absoluteAdd(e,t,r);if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);var n=t.length;(0===t.__clzmsd()||e.length===t.length&&0===e.__clzmsd())&&n++;for(var i=new l(n,r),o=0,a=0;a<e.length;a++){var s=e.__digit(a),u=t.__digit(a),_=(65535&u)+(65535&s)+o,f=(u>>>16)+(s>>>16)+(_>>>16);o=f>>>16,i.__setDigit(a,65535&_|f<<16)}for(;a<t.length;a++){var h=t.__digit(a),c=(65535&h)+o,g=(h>>>16)+(c>>>16);o=g>>>16,i.__setDigit(a,65535&c|g<<16)}return a<i.length&&i.__setDigit(a,o),i.__trim()}},{key:"__absoluteSub",value:function(t,e,r){if(0===t.length)return t;if(0===e.length)return t.sign===r?t:l.unaryMinus(t);for(var n=new l(t.length,r),i=0,o=0;o<e.length;o++){var a=t.__digit(o),s=e.__digit(o),u=(65535&a)-(65535&s)-i,_=(a>>>16)-(s>>>16)-(i=1&u>>>16);i=1&_>>>16,n.__setDigit(o,65535&u|_<<16)}for(;o<t.length;o++){var f=t.__digit(o),h=(65535&f)-i,c=(f>>>16)-(i=1&h>>>16);i=1&c>>>16,n.__setDigit(o,65535&h|c<<16)}return n.__trim()}},{key:"__absoluteAddOne",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length;null===r?r=new l(n,e):r.sign=e;for(var i=!0,o=0;o<n;o++){var a=t.__digit(o),s=-1===a;i&&(a=0|a+1),i=s,r.__setDigit(o,a)}return i&&r.__setDigitGrow(n,1),r}},{key:"__absoluteSubOne",value:function(t,e){for(var r=t.length,n=new l(e=e||r,!1),i=!0,o=0;o<r;o++){var a=t.__digit(o),s=0===a;i&&(a=0|a-1),i=s,n.__setDigit(o,a)}for(var u=r;u<e;u++)n.__setDigit(u,0);return n}},{key:"__absoluteAnd",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=o;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)&e.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteAndNot",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;n<i&&(o=n);var a=n;null===r?r=new l(a,!1):a=r.length;for(var s=0;s<o;s++)r.__setDigit(s,t.__digit(s)&~e.__digit(s));for(;s<n;s++)r.__setDigit(s,t.__digit(s));for(;s<a;s++)r.__setDigit(s,0);return r}},{key:"__absoluteOr",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)|e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteXor",value:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=t.length,i=e.length,o=i;if(n<i){o=n;var a=t,s=n;t=e,n=i,e=a,i=s}var u=n;null===r?r=new l(u,!1):u=r.length;for(var _=0;_<o;_++)r.__setDigit(_,t.__digit(_)^e.__digit(_));for(;_<n;_++)r.__setDigit(_,t.__digit(_));for(;_<u;_++)r.__setDigit(_,0);return r}},{key:"__absoluteCompare",value:function(t,e){var r=t.length-e.length;if(0!=r)return r;for(var n=t.length-1;0<=n&&t.__digit(n)===e.__digit(n);)n--;return 0>n?0:t.__unsignedDigit(n)>e.__unsignedDigit(n)?1:-1}},{key:"__multiplyAccumulate",value:function(t,e,r,n){if(0!==e){for(var i=65535&e,o=e>>>16,a=0,u=0,_=0,l=0;l<t.length;l++,n++){var f=r.__digit(n),h=65535&f,c=f>>>16,g=t.__digit(l),d=65535&g,p=g>>>16,v=s(d,i),y=s(d,o),b=s(p,i),m=s(p,o);a=(u=(y>>>16)+(b>>>16)+(65535&m)+(a=(c+=_+a+((h+=u+(65535&v))>>>16)+(v>>>16)+(65535&y)+(65535&b))>>>16))>>>16,u&=65535,_=m>>>16,f=65535&h|c<<16,r.__setDigit(n,f)}for(;0!==a||0!==u||0!==_;n++){var w=r.__digit(n),k=(65535&w)+u,D=(w>>>16)+(k>>>16)+_+a;u=0,_=0,a=D>>>16,w=65535&k|D<<16,r.__setDigit(n,w)}}}},{key:"__internalMultiplyAdd",value:function(t,e,r,n,i){for(var o=r,a=0,u=0;u<n;u++){var _=t.__digit(u),l=s(65535&_,e),f=(65535&l)+a+o;o=f>>>16;var h=s(_>>>16,e),c=(65535&h)+(l>>>16)+o;o=c>>>16,a=h>>>16,i.__setDigit(u,c<<16|65535&f)}if(i.length>n)for(i.__setDigit(n++,o+a);n<i.length;)i.__setDigit(n++,0);else if(0!==o+a)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(t,e,r){null===r&&(r=new l(t.length,!1));for(var n=0,i=2*t.length-1;0<=i;i-=2){var o=(n<<16|t.__halfDigit(i))>>>0,a=0|o/e,s=0|(o=((n=0|o%e)<<16|t.__halfDigit(i-1))>>>0)/e;n=0|o%e,r.__setDigit(i>>>1,a<<16|s)}return r}},{key:"__absoluteModSmall",value:function(t,e){for(var r=0,n=2*t.length-1;0<=n;n--)r=0|((r<<16|t.__halfDigit(n))>>>0)%e;return r}},{key:"__absoluteDivLarge",value:function(t,e,r,n){var i=e.__halfDigitLength(),o=e.length,a=t.__halfDigitLength()-i,u=null;r&&(u=new l(a+2>>>1,!1)).__initializeDigits();var _=new l(i+2>>>1,!1);_.__initializeDigits();var f=l.__clz16(e.__halfDigit(i-1));0<f&&(e=l.__specialLeftShift(e,f,0));for(var h=l.__specialLeftShift(t,f,1),c=e.__halfDigit(i-1),g=0,d=a;0<=d;d--){var p=65535,v=h.__halfDigit(d+i);if(v!==c){var y=(v<<16|h.__halfDigit(d+i-1))>>>0;p=0|y/c;for(var b=0|y%c,m=e.__halfDigit(i-2),w=h.__halfDigit(d+i-2);s(p,m)>>>0>(b<<16|w)>>>0&&(p--,!(65535<(b+=c))););}l.__internalMultiplyAdd(e,p,0,o,_);var k=h.__inplaceSub(_,d,i+1);0!==k&&(k=h.__inplaceAdd(e,d,i),h.__setHalfDigit(d+i,h.__halfDigit(d+i)+k),p--),r&&(1&d?g=p<<16:u.__setDigit(d>>>1,g|p))}return n?(h.__inplaceRightShift(f),r?{quotient:u,remainder:h}:h):r?u:void 0}},{key:"__clz16",value:function(t){return u(t)-16}},{key:"__specialLeftShift",value:function(t,e,r){var n=t.length,i=new l(n+r,!1);if(0===e){for(var o=0;o<n;o++)i.__setDigit(o,t.__digit(o));return 0<r&&i.__setDigit(n,0),i}for(var a,s=0,u=0;u<n;u++)a=t.__digit(u),i.__setDigit(u,a<<e|s),s=a>>>32-e;return 0<r&&i.__setDigit(n,s),i}},{key:"__leftShiftByAbsolute",value:function(t,e){var r=l.__toShiftAmount(e);if(0>r)throw new RangeError("BigInt too big");var n=r>>>5,i=31&r,o=t.length,a=0!==i&&0!=t.__digit(o-1)>>>32-i,s=o+n+(a?1:0),u=new l(s,t.sign);if(0===i){for(var _=0;_<n;_++)u.__setDigit(_,0);for(;_<s;_++)u.__setDigit(_,t.__digit(_-n))}else{for(var f=0,h=0;h<n;h++)u.__setDigit(h,0);for(var c,g=0;g<o;g++)c=t.__digit(g),u.__setDigit(g+n,c<<i|f),f=c>>>32-i;if(a)u.__setDigit(o+n,f);else if(0!==f)throw new Error("implementation bug")}return u.__trim()}},{key:"__rightShiftByAbsolute",value:function(t,e){var r=t.length,n=t.sign,i=l.__toShiftAmount(e);if(0>i)return l.__rightShiftByMaximum(n);var o=i>>>5,a=31&i,s=r-o;if(0>=s)return l.__rightShiftByMaximum(n);var u=!1;if(n)if(0!=(t.__digit(o)&(1<<a)-1))u=!0;else for(var _=0;_<o;_++)if(0!==t.__digit(_)){u=!0;break}u&&0===a&&0==~t.__digit(r-1)&&s++;var f=new l(s,n);if(0===a)for(var h=o;h<r;h++)f.__setDigit(h-o,t.__digit(h));else{for(var c,g=t.__digit(o)>>>a,d=r-o-1,p=0;p<d;p++)c=t.__digit(p+o+1),f.__setDigit(p,c<<32-a|g),g=c>>>a;f.__setDigit(d,g)}return u&&(f=l.__absoluteAddOne(f,!0,f)),f.__trim()}},{key:"__rightShiftByMaximum",value:function(t){return t?l.__oneDigit(1,!0):l.__zero()}},{key:"__toShiftAmount",value:function(t){if(1<t.length)return-1;var e=t.__unsignedDigit(0);return e>l.__kMaxLengthBits?-1:e}},{key:"__toPrimitive",value:function(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==t(e))return e;if(e.constructor===l)return e;var n=e[Symbol.toPrimitive];if(n){var i=n(r);if("object"!==t(i))return i;throw new TypeError("Cannot convert object to primitive value")}var o=e.valueOf;if(o){var a=o.call(e);if("object"!==t(a))return a}var s=e.toString;if(s){var u=s.call(e);if("object"!==t(u))return u}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(t){return l.__isBigInt(t)?t:+t}},{key:"__isBigInt",value:function(e){return"object"===t(e)&&e.constructor===l}},{key:"__truncateToNBits",value:function(t,e){for(var r=t+31>>>5,n=new l(r,e.sign),i=r-1,o=0;o<i;o++)n.__setDigit(o,e.__digit(o));var a=e.__digit(i);if(0!=(31&t)){var s=32-(31&t);a=a<<s>>>s}return n.__setDigit(i,a),n.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(t,e,r){for(var n=Math.min,i=t+31>>>5,o=new l(i,r),a=0,s=i-1,u=0,_=n(s,e.length);a<_;a++){var f=e.__digit(a),h=0-(65535&f)-u,c=0-(f>>>16)-(u=1&h>>>16);u=1&c>>>16,o.__setDigit(a,65535&h|c<<16)}for(;a<s;a++)o.__setDigit(a,0|-u);var g,d=s<e.length?e.__digit(s):0,p=31&t;if(0===p){var v=0-(65535&d)-u;g=65535&v|0-(d>>>16)-(u=1&v>>>16)<<16}else{var y=32-p,b=1<<32-y,m=(65535&b)-(65535&(d=d<<y>>>y))-u;g=65535&m|(b>>>16)-(d>>>16)-(u=1&m>>>16)<<16,g&=b-1}return o.__setDigit(s,g),o.__trim()}},{key:"__digitPow",value:function(t,e){for(var r=1;0<e;)1&e&&(r*=t),e>>>=1,t*=t;return r}}]),l}(u(Array));return l.__kMaxLength=33554432,l.__kMaxLengthBits=l.__kMaxLength<<5,l.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],l.__kBitsPerCharTableShift=5,l.__kBitsPerCharTableMultiplier=1<<l.__kBitsPerCharTableShift,l.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],l.__kBitConversionBuffer=new ArrayBuffer(8),l.__kBitConversionDouble=new Float64Array(l.__kBitConversionBuffer),l.__kBitConversionInts=new Int32Array(l.__kBitConversionBuffer),l}()})));const u={get:(t,e)=>async(...r)=>{const n=Math.round(1e7*Math.random()),i=await a(t.uri,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:r})}),o=await i.json();if(o.id!==n)throw new Error("JSONRPCError: response ID does not match request ID!");if(o.error)throw new Error(`JSONRPCError: server error ${JSON.stringify(o.error)}`);return o.result}};function _(t){return s.BigInt(t)}function l(t){return"0x"+t.toString(16)}function f(t,e,r,n=[]){!function(t,e){if(!(e instanceof Object))throw new Error(`${t} is not an object!`)}(t,e);const i=Object.keys(e).sort(),o=r.length,a=r.length+n.length,s=`${t} does not have correct keys! Required keys: [${r.sort().join(", ")}], optional keys: [${n.sort().join(", ")}], actual keys: [${i.join(", ")}]`;if(i.length<o||i.length>a)throw new Error(s);let u=i.filter(t=>!r.includes(t));if(i.length-u.length!==o)throw new Error(s);if(u.find(t=>!n.includes(t)))throw new Error(s)}function h(t,e){if(!/^0x([0-9a-fA-F][0-9a-fA-F])*$/.test(e))throw new Error(`${t} must be a hex string!`)}function c(t,e){if(h(t,e),66!=e.length)throw new Error(`${t} must be a hex string of 66 bytes long!`)}function g(t,e){if("0x0"!==e&&!/^0x[1-9a-fA-F][0-9a-fA-F]*$/.test(e))throw new Error(`${t} must be a hex integer!`)}function d(t,{nestedValidation:e=!0,debugPath:r="script"}={}){if(f(r,t,["code_hash","hash_type","args"],[]),c(`${r}.code_hash`,t.code_hash),h(`${r}.args`,t.args),"data"!==t.hash_type&&"type"!==t.hash_type)throw new Error(`${r}.hash_type must be either data or type!`)}function p(t,{nestedValidation:e=!0,debugPath:r="out_point"}={}){f(r,t,["tx_hash","index"],[]),c(`${r}.tx_hash`,t.tx_hash),g(`${r}.index`,t.index)}function v(t,{nestedValidation:e=!0,debugPath:r="cell_input"}={}){f(r,t,["since","previous_output"],[]),g(`${r}.since`,t.since),e&&p(t.previous_output,{debugPath:`${r}.previous_output`})}function y(t,{nestedValidation:e=!0,debugPath:r="cell_output"}={}){f(r,t,["capacity","lock"],["type"]),g(`${r}.capacity`,t.capacity),e&&(d(t.lock,{debugPath:`${r}.lock`}),t.type&&d(t.type,{debugPath:`${r}.type`}))}function b(t,{nestedValidation:e=!0,debugPath:r="cell_dep"}={}){if(f(r,t,["out_point","dep_type"],[]),"code"!==t.dep_type&&"dep_group"!==t.dep_type)throw new Error(`${r}.dep_type must be either code or dep_group!`);e&&p(t.out_point,{debugPath:`${r}.out_point`})}function m(t,e,r,n){if(!Array.isArray(e))throw new Error(`${t} is not an array!`);if(n)for(let n=0;n<e.length;n++)r(`${t}[${n}]`,e[n])}function w(t,e){return function(r,n){t(n,{nestedValidation:e,debugPath:r})}}function k(t,e,r){g(`${t}.version`,e.version),m(`${t}.cell_deps`,e.cell_deps,w(b,r),r),m(`${t}.header_deps`,e.header_deps,c,r),m(`${t}.inputs`,e.inputs,w(v,r),r),m(`${t}.outputs`,e.outputs,w(y,r),r),m(`${t}.outputs_data`,e.outputs_data,h,r)}function D(t,{nestedValidation:e=!0,debugPath:r="raw_transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data"],[]),k(r,t,e)}function B(t,{nestedValidation:e=!0,debugPath:r="transaction"}={}){f(r,t,["version","cell_deps","header_deps","inputs","outputs","outputs_data","witnesses"],[]),k(r,t,e),m(`${r}.witnesses`,t.witnesses,h,e)}function A(t,{nestedValidation:e=!0,debugPath:r="raw_header"}={}){f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao"],[]),function(t,e){g(`${t}.version`,e.version),g(`${t}.compact_target`,e.compact_target),g(`${t}.timestamp`,e.timestamp),g(`${t}.number`,e.number),g(`${t}.epoch`,e.epoch),c(`${t}.parent_hash`,e.parent_hash),c(`${t}.transactions_root`,e.transactions_root),c(`${t}.proposals_hash`,e.proposals_hash),c(`${t}.uncles_hash`,e.uncles_hash),c(`${t}.dao`,e.dao)}(r,t)}function P(t,{nestedValidation:e=!0,debugPath:r="header"}={}){if(f(r,t,["version","compact_target","timestamp","number","epoch","parent_hash","transactions_root","proposals_hash","uncles_hash","dao","nonce"],[]),h(`${r}.nonce`,t.nonce),34!=t.nonce.length)throw new Error(`${r}.nonce must be a hex string of 34 bytes long!`)}function S(t,e){if(h(t,e),22!=e.length)throw new Error(`${t} must be a hex string of 22 bytes long!`)}function T(t,{nestedValidation:e=!0,debugPath:r="uncle_block"}={}){f(r,t,["header","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.proposals`,t.proposals,S,e)}function E(t,{nestedValidation:e=!0,debugPath:r="block"}={}){f(r,t,["header","uncles","transactions","proposals"],[]),e&&P(t.header,{debugPath:`${r}.header`}),m(`${r}.uncles`,t.uncles,w(T,e),e),m(`${r}.transactions`,t.transactions,w(B,e),e),m(`${r}.proposals`,t.proposals,S,e)}function x(t,{nestedValidation:e=!0,debugPath:r="cellbase_witness"}={}){f(r,t,["lock","message"],[]),h(`${r}.message`,t.message),e&&d(t.lock,{debugPath:`${r}.lock`})}function C(t,{nestedValidation:e=!0,debugPath:r="witness_args"}={}){f(r,t,[],["lock","input_type","output_type"]),t.lock&&h(`${r}.lock`,t.lock),t.input_type&&h(`${r}.input_type`,t.input_type),t.output_type&&h(`${r}.output_type`,t.output_type)}var O=Object.freeze({__proto__:null,ValidateScript:d,ValidateOutPoint:p,ValidateCellInput:v,ValidateCellOutput:y,ValidateCellDep:b,ValidateRawTransaction:D,ValidateTransaction:B,ValidateRawHeader:A,ValidateHeader:P,ValidateUncleBlock:T,ValidateBlock:E,ValidateCellbaseWitness:x,ValidateWitnessArgs:C});function I(t,e){return e instanceof Object&&e.serializeJson instanceof Function?e.serializeJson.call(e):e}function $(t,e,r){if(!((e=I(0,e))instanceof Object))throw new Error(`Transformed ${t} is not an object!`);const n={};for(const[i,o]of Object.entries(r)){const r=e[i];r&&(n[i]=o(`${t}.${i}`,r))}return n}function R(t,{validation:e=!0,debugPath:r="script"}={}){return t=$(r,t,{code_hash:I,hash_type:I,args:I}),e&&d(t,{debugPath:`(transformed) ${r}`}),t}function j(t,{validation:e=!0,debugPath:r="out_point"}={}){return t=$(r,t,{tx_hash:I,index:I}),e&&p(t,{debugPath:`(transformed) ${r}`}),t}function M(t){return function(e,r){return t(r,{validation:!1,debugPath:e})}}function z(t,{validation:e=!0,debugPath:r="cell_input"}={}){return t=$(r,t,{since:I,previous_output:M(j)}),e&&v(t,{debugPath:`(transformed) ${r}`}),t}function L(t,{validation:e=!0,debugPath:r="cell_output"}={}){return t=$(r,t,{capacity:I,lock:M(R),type:M(R)}),e&&y(t,{debugPath:`(transformed) ${r}`}),t}function N(t,{validation:e=!0,debugPath:r="cell_dep"}={}){return t=$(r,t,{out_point:M(j),dep_type:I}),e&&b(t,{debugPath:`(transformed) ${r}`}),t}function V(t){return function(e,r){return r.map((r,n)=>t(`${e}[${n}]`,r))}}function F(t,{validation:e=!0,debugPath:r="transaction"}={}){return t=$(r,t,{version:I,cell_deps:V(M(N)),header_deps:V(I),inputs:V(M(z)),outputs:V(M(L)),outputs_data:V(I),witnesses:V(I)}),e&&B(t,{debugPath:`(transformed) ${r}`}),t}function U(t,{validation:e=!0,debugPath:r="header"}={}){return t=$(r,t,{version:I,compact_target:I,timestamp:I,number:I,epoch:I,parent_hash:I,transactions_root:I,proposals_hash:I,uncles_hash:I,dao:I,nonce:I}),e&&P(t,{debugPath:`(transformed) ${r}`}),t}function q(t,{validation:e=!0,debugPath:r="uncle_block"}={}){return t=$(r,t,{header:M(U),proposals:V(I)}),e&&T(t,{debugPath:`(transformed) ${r}`}),t}var H=Object.freeze({__proto__:null,TransformScript:R,TransformOutPoint:j,TransformCellInput:z,TransformCellOutput:L,TransformCellDep:N,TransformRawTransaction:function(t,{validation:e=!0,debugPath:r="raw_transaction"}={}){return t=$(r,t,{version:I,cell_deps:V(M(N)),header_deps:V(I),inputs:V(M(z)),outputs:V(M(L)),outputs_data:V(I)}),e&&D(t,{debugPath:`(transformed) ${r}`}),t},TransformTransaction:F,TransformRawHeader:function(t,{validation:e=!0,debugPath:r="raw_header"}={}){return t=$(r,t,{version:I,compact_target:I,timestamp:I,number:I,epoch:I,parent_hash:I,transactions_root:I,proposals_hash:I,uncles_hash:I,dao:I}),e&&A(t,{debugPath:`(transformed) ${r}`}),t},TransformHeader:U,TransformUncleBlock:q,TransformBlock:function(t,{validation:e=!0,debugPath:r="block"}={}){return t=$(r,t,{header:M(U),uncles:V(M(q)),transactions:V(M(F)),proposals:V(I)}),e&&E(t,{debugPath:`(transformed) ${r}`}),t},TransformCellbaseWitness:function(t,{validation:e=!0,debugPath:r="cellbase_witness"}={}){return t=$(r,t,{lock:M(R),message:I}),e&&x(t,{debugPath:`(transformed) ${r}`}),t},TransformWitnessArgs:function(t,{validation:e=!0,debugPath:r="witness_args"}={}){return t=$(r,t,{lock:I,input_type:I,output_type:I}),e&&C(t,{debugPath:`(transformed) ${r}`}),t}});var G=Object.freeze({__proto__:null,RPCCollector:class{constructor(t,e,{skipCellWithContent:r=!0,loadData:i=!1}={}){this.rpc=t,this.lockHash=new n(e).serializeJson(),this.skipCellWithContent=r,this.loadData=i}async*collect(){const t=_(await this.rpc.get_tip_block_number());let e=s.BigInt(0);for(;s.lessThanOrEqual(e,t);){let r=s.add(e,s.BigInt(100));s.greaterThan(r,t)&&(r=t);const n=await this.rpc.get_cells_by_lock_hash(this.lockHash,l(e),l(r));for(const t of n)if(this.skipCellWithContent){if(t.type||s.greaterThan(_(t.output_data_len),s.BigInt(100)))continue;let e=null;if(this.loadData){e=(await this.rpc.get_live_cell(t.out_point,!0)).cell.data.content}yield{cell_output:{capacity:t.capacity,lock:t.lock,type:t.type},out_point:t.out_point,block_hash:t.block_hash,data:e}}e=s.add(r,s.BigInt(1))}}}});t.BigIntToHexString=l,t.HexStringToBigInt=_,t.RPC=class{constructor(t){return this.uri=t,new Proxy(this,u)}},t.Reader=n,t.VERSION="0.5.0",t.cell_collectors=G,t.transformers=H,t.validators=O,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "ckb-js-toolkit",
"version": "0.4.0",
"version": "0.5.0",
"description": "JavaScript toolkits used to build dapps for Nervos CKB",

@@ -28,2 +28,3 @@ "main": "dist/ckb-js-toolkit.node.js",

"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-replace": "^2.3.1",
"ava": "^3.5.0",

@@ -30,0 +31,0 @@ "prettier": "1.19.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc