@mayanfinance/swap-sdk
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -1,2 +0,2 @@ | ||
var t=require("cross-fetch"),e=require("ethers"),n=require("@solana/web3.js"),r=require("js-sha3"),i=require("@solana/buffer-layout");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=/*#__PURE__*/o(t),u="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",a="https://price-api.mayan.finance/v1",f=function(){try{return Promise.resolve(s.default(a+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}};function l(){return l=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},l.apply(this,arguments)}let c=!1,h=!1;const p={debug:1,default:2,info:2,warning:3,error:4,off:5};let y=p.default,g=null;const d=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var m,b;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(m||(m={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(b||(b={}));const w="0123456789abcdef";class E{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==p[n]&&this.throwArgumentError("invalid log level name","logLevel",t),y>p[n]||console.log.apply(console,e)}debug(...t){this._log(E.levels.DEBUG,t)}info(...t){this._log(E.levels.INFO,t)}warn(...t){this._log(E.levels.WARNING,t)}makeError(t,e,n){if(h)return this.makeError("censored error",e,{});e||(e=E.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=w[e[t]>>4],n+=w[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case b.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case b.CALL_EXCEPTION:case b.INSUFFICIENT_FUNDS:case b.MISSING_NEW:case b.NONCE_EXPIRED:case b.REPLACEMENT_UNDERPRICED:case b.TRANSACTION_REPLACED:case b.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,E.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){d&&this.throwError("platform missing String.prototype.normalize",E.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,E.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,E.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,E.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,E.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",E.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",E.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",E.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return g||(g=new E("logger/5.7.0")),g}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",E.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),c){if(!t)return;this.globalLogger().throwError("error censorship permanent",E.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}h=!!t,c=!!e}static setLogLevel(t){const e=p[t.toLowerCase()];null!=e?y=e:E.globalLogger().warn("invalid log level - "+t)}static from(t){return new E(t)}}E.errors=b,E.levels=m;const T=new E("bytes/5.7.0");function I(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return I(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function A(t){return"number"==typeof t&&t==t&&t%1==0}function v(t,e){if(e||(e={}),"number"==typeof t){T.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),I(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":T.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return I(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!A(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!A(n)||n<0||n>=256)return!1}return!0}(t)?I(new Uint8Array(t)):T.throwArgumentError("invalid arrayify value","value",t)}function R(t,e){(t=v(t)).length>e&&T.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),I(n)}for(var N=[],B=[],U="undefined"!=typeof Uint8Array?Uint8Array:Array,S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=0,O=S.length;P<O;++P)N[P]=S[P],B[S.charCodeAt(P)]=P;function C(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(N[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+N[r>>12&63]+N[r>>6&63]+N[63&r]);return i.join("")}B["-".charCodeAt(0)]=62,B["_".charCodeAt(0)]=63;var k,_,M,L=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,l=-7,c=n?i-1:0,h=n?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=u;l>0;o=256*o+t[e+c],c+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},F=function(t,e,n,r,i,o){var s,u,a,f=8*o-i-1,l=(1<<f)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?h/a:h*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=l?(u=0,s=l):s+c>=1?(u=(e*a-1)*Math.pow(2,i),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},D=(k=function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|h(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return l(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return l(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|c(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return u(t),i(t<0?0:0|c(t))}function f(t){const e=t.length<0?0:0|c(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function l(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function c(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(t).length;default:if(i)return r?-1:Y(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return S(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:d(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):d(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function d(t,e,n,r,i){let o,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<u;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===a)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){let n=!0;for(let r=0;r<a;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function b(t,e,n,r){return H(Y(e,t.length-n),t,n,r)}function w(t,e,n,r){return H(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return H(J(e),t,n,r)}function T(t,e,n,r){return H(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function I(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,u=n-r;s<u;s+=o)i.push(C(t,s,s+o>u?u:s+o));return 1===r?i.push(N[(e=t[n-1])>>2]+N[e<<4&63]+"=="):2===r&&i.push(N[(e=(t[n-2]<<8)+t[n-1])>>10]+N[e>>4&63]+N[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,u,a;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(a=(31&e)<<6|63&n,a>127&&(o=a));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(a=(15&e)<<12|(63&n)<<6|63&r,a>2047&&(a<55296||a>57343)&&(o=a));break;case 4:n=t[i+1],r=t[i+2],u=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(o=a))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return a(t)},o.allocUnsafeSlow=function(t){return a(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=h,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0);const a=Math.min(s,u),f=this.slice(r,i),l=t.slice(e,n);for(let t=0;t<a;++t)if(f[t]!==l[t]){s=f[t],u=l[t];break}return s<u?-1:u<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function S(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function P(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function O(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function k(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function _(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function M(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function D(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function x(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function G(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,4),F(t,e,n,r,23,4),n+4}function W(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,8),F(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||V(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),L(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),L(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),L(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),L(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||_(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||_(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);_(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);_(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return G(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return G(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return W(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return W(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%u]}return this};const j={};function K(t,e,n){j[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){q(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||V(e,t.length-(n+1))}(r,i,o)}function q(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,n){if(Math.floor(t)!==t)throw q(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}K("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),K("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const X=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new U(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),u=0,a=o>0?i-4:i;for(n=0;n<a;n+=4)e=B[t.charCodeAt(n)]<<18|B[t.charCodeAt(n+1)]<<12|B[t.charCodeAt(n+2)]<<6|B[t.charCodeAt(n+3)],s[u++]=e>>16&255,s[u++]=e>>8&255,s[u++]=255&e;return 2===o&&(e=B[t.charCodeAt(n)]<<2|B[t.charCodeAt(n+1)]>>4,s[u++]=255&e),1===o&&(e=B[t.charCodeAt(n)]<<10|B[t.charCodeAt(n+1)]<<4|B[t.charCodeAt(n+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}},k(_={exports:{}},_.exports),_.exports);function x(t,e){var i;if(1===e)i=R(new n.PublicKey(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+r.sha3_256(t);for(var o=t.substring(2),s=[],u=0;u<o.length;u+=2)s.push(parseInt(o.substring(u,u+2),16));i=R(new Uint8Array(s),32)}return"0x"+D.Buffer.from(i).toString("hex")}function G(t,e,r,i,o){if(void 0===r&&(r=!1),void 0===i&&(i=new n.PublicKey(u)),void 0===o&&(o=new n.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),!r&&!n.PublicKey.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return n.PublicKey.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function W(t,n){var r=Number(t).toFixed(Math.min(8,Number(n)));return e.ethers.utils.parseUnits(r,Number(n))}var j={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function K(t){return j[t]}var $=((M={})[1]=2,M[56]=4,M[137]=5,M[43114]=6,M),z=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}];function q(t,e,r,i,o,s){return void 0===o&&(o=new n.PublicKey(u)),void 0===s&&(s=new n.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),new n.TransactionInstruction({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:n.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:n.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],programId:s,data:D.Buffer.alloc(0)})}var V=i.struct([i.u8("instruction")]),X=i.struct([i.u8("instruction"),i.u8("mainNonce"),i.u8("stateNonce"),i.nu64("amount"),i.nu64("minAmountOut"),i.nu64("deadline"),i.nu64("feeSwap"),i.nu64("feeReturn"),i.nu64("feeCancel"),i.u16("destinationChain"),i.blob(32,"destinationAddress")]);exports.fetchAllTokenList=function(){try{return Promise.resolve(s.default(a+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}},exports.fetchQuote=function(t){try{var e=t.customRelayerFees;return Promise.resolve(s.default(a+"/quote?amountIn="+t.amount+"&fromToken="+t.fromToken+"&fromChain="+t.fromChain+"&toToken="+t.toToken+"&toChain="+t.toChain+"&slippage="+t.slippage/100+(e?"&swapRelayerFee="+e.swapRelayerFee+"&redeemRelayerFee="+e.redeemRelayerFee+"&refundRelayerFee="+e.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},exports.fetchTokenList=function(t){try{return Promise.resolve(s.default(a+"/tokens?chain="+t)).then(function(e){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===e.status)return Promise.resolve(e.json()).then(function(e){return n=1,e[t]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},exports.getCurrentSolanaTime=f,exports.swapFromEvm=function(t,r,i,o,s,u){try{var a=new n.PublicKey("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E");return Promise.resolve(n.PublicKey.findProgramAddress([Buffer.from("MAIN")],a)).then(function(a){var c=a[0],h=G(new n.PublicKey(t.fromToken.mint),c,!0),p=W(t.effectiveAmountIn,t.fromToken.decimals),y=x(h.toString(),1);return Promise.resolve(s.getChainId()).then(function(n){var a=$[n],c=K(t.fromChain),h=K(t.toChain);if(c!==a)throw new Error("Signer chain id and quote from chain are not same!");var g={mayanAddr:y,mayanChainId:1,destAddr:x(r,h),destChainId:h};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(n){return Promise.resolve(f()).then(function(r){var o,a,f={transferDeadline:e.ethers.BigNumber.from(n+i),swapDeadline:e.ethers.BigNumber.from(r+i),amountOutMin:W(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),a=Buffer.alloc(4),a.writeUInt32LE(o,0),a).readUInt32LE(0)},c={swapFee:W(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:W(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:W(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},h=x(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===e.ethers.constants.AddressZero?function(t,n,r,i,o,s,u,a,f){try{var c=new e.ethers.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",z,a);return Promise.resolve(c.wrapAndSwapETH(n,r,i,o,s,f?l({value:u},f):{value:u}))}catch(t){return Promise.reject(t)}}(0,c,g,h,t.toToken.realOriginChainId,f,p,s,u):function(t,n,r,i,o,s,u,a,f,l){try{var c=new e.ethers.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",z,f);return Promise.resolve(l?c.swap(n,r,i,o,s,u,a,l):c.swap(n,r,i,o,s,u,a))}catch(t){return Promise.reject(t)}}(0,c,g,h,t.toToken.realOriginChainId,f,t.fromToken.contract,p,s,u)})})})})}catch(t){return Promise.reject(t)}},exports.swapFromSolana=function(t,r,i,o,s,a){try{var l=null!=a?a:new n.Connection("https://rpc.ankr.com/solana"),c=new n.PublicKey("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E"),h=new n.PublicKey(u),p=new n.PublicKey(r),y=n.PublicKey.findProgramAddressSync([D.Buffer.from("MAIN")],c),g=y[0],d=y[1],m=n.Keypair.generate().publicKey,b=n.Keypair.generate().publicKey,w=n.PublicKey.findProgramAddressSync([D.Buffer.from("V2STATE"),D.Buffer.from(m.toBytes()),D.Buffer.from(b.toBytes())],c),E=w[0],T=w[1],I=new n.PublicKey(t.fromToken.mint),A=new n.PublicKey(t.toToken.mint),v=G(I,p),R=G(I,g,!0),N=new n.Transaction({feePayer:p});return Promise.resolve(l.getAccountInfo(v,"finalized")).then(function(r){return r&&0!==r.data.length||N.add(q(p,v,p,I)),Promise.resolve(l.getAccountInfo(R,"finalized")).then(function(r){var a,y;r&&0!==r.data.length||N.add(q(p,R,g,I)),t.fromToken.contract===e.ethers.constants.AddressZero&&(N.add(n.SystemProgram.transfer({fromPubkey:p,toPubkey:v,lamports:W(t.effectiveAmountIn,9).toBigInt()})),N.add((a=[{pubkey:v,isSigner:!1,isWritable:!0}],y=D.Buffer.alloc(V.span),V.encode({instruction:17},y),new n.TransactionInstruction({keys:a,programId:new n.PublicKey(u),data:y}))));var w=[{pubkey:p,isWritable:!1,isSigner:!0},{pubkey:g,isWritable:!1,isSigner:!1},{pubkey:m,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:E,isWritable:!0,isSigner:!1},{pubkey:v,isWritable:!0,isSigner:!1},{pubkey:R,isWritable:!0,isSigner:!1},{pubkey:I,isWritable:!1,isSigner:!1},{pubkey:A,isWritable:!1,isSigner:!1},{pubkey:n.SYSVAR_CLOCK_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:n.SYSVAR_RENT_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:h,isWritable:!1,isSigner:!1},{pubkey:n.SystemProgram.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(f()).then(function(e){function r(r){var a,f=D.Buffer.from((a=x(i,u),new Uint8Array(D.Buffer.from(a.substring(2),"hex")))),h=W(t.effectiveAmountIn,t.mintDecimals.from),p=W(t.minAmountOut,t.mintDecimals.to),y=W(t.swapRelayerFee,t.mintDecimals.from),g=W(t.redeemRelayerFee,t.mintDecimals.to),m=W(t.refundRelayerFee,t.mintDecimals.from),b=D.Buffer.alloc(X.span);X.encode({instruction:101,mainNonce:d,stateNonce:T,amount:h,minAmountOut:p,deadline:e+o,feeSwap:y,feeReturn:g,feeCancel:m,destinationChain:u,destinationAddress:f},b);var E=new n.TransactionInstruction({keys:w,data:b,programId:c});return N.add(E),Promise.resolve(l.getLatestBlockhash()).then(function(t){return N.recentBlockhash=t.blockhash,Promise.resolve(s(N)).then(function(t){return Promise.resolve(l.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var u=K(t.toChain),a=function(){if(1===u)return Promise.resolve(l.getAccountInfo(new n.PublicKey(i))).then(function(t){if(t.owner.equals(h))throw new Error("Destination address is not about token account. It should be a owner address")})}();return a&&a.then?a.then(r):r()})})})}catch(t){return Promise.reject(t)}}; | ||
var t=require("cross-fetch"),e=require("ethers"),n=require("@solana/web3.js"),r=require("js-sha3"),i=require("@solana/buffer-layout");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=/*#__PURE__*/o(t),u="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",a="https://price-api.mayan.finance/v1",f=function(){try{return Promise.resolve(s.default(a+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}};function c(){return c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c.apply(this,arguments)}let l=!1,h=!1;const p={debug:1,default:2,info:2,warning:3,error:4,off:5};let y=p.default,g=null;const d=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var m,b;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(m||(m={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(b||(b={}));const w="0123456789abcdef";class E{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==p[n]&&this.throwArgumentError("invalid log level name","logLevel",t),y>p[n]||console.log.apply(console,e)}debug(...t){this._log(E.levels.DEBUG,t)}info(...t){this._log(E.levels.INFO,t)}warn(...t){this._log(E.levels.WARNING,t)}makeError(t,e,n){if(h)return this.makeError("censored error",e,{});e||(e=E.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=w[e[t]>>4],n+=w[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case b.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case b.CALL_EXCEPTION:case b.INSUFFICIENT_FUNDS:case b.MISSING_NEW:case b.NONCE_EXPIRED:case b.REPLACEMENT_UNDERPRICED:case b.TRANSACTION_REPLACED:case b.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,E.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){d&&this.throwError("platform missing String.prototype.normalize",E.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,E.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,E.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,E.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,E.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",E.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",E.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",E.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return g||(g=new E("logger/5.7.0")),g}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",E.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),l){if(!t)return;this.globalLogger().throwError("error censorship permanent",E.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}h=!!t,l=!!e}static setLogLevel(t){const e=p[t.toLowerCase()];null!=e?y=e:E.globalLogger().warn("invalid log level - "+t)}static from(t){return new E(t)}}E.errors=b,E.levels=m;const T=new E("bytes/5.7.0");function I(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return I(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function A(t){return"number"==typeof t&&t==t&&t%1==0}function v(t,e){if(e||(e={}),"number"==typeof t){T.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),I(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":T.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return I(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!A(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!A(n)||n<0||n>=256)return!1}return!0}(t)?I(new Uint8Array(t)):T.throwArgumentError("invalid arrayify value","value",t)}function R(t,e){(t=v(t)).length>e&&T.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),I(n)}for(var B=[],N=[],U="undefined"!=typeof Uint8Array?Uint8Array:Array,S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=0,O=S.length;P<O;++P)B[P]=S[P],N[S.charCodeAt(P)]=P;function C(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(B[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+B[r>>12&63]+B[r>>6&63]+B[63&r]);return i.join("")}N["-".charCodeAt(0)]=62,N["_".charCodeAt(0)]=63;var k,_,M,L=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,c=-7,l=n?i-1:0,h=n?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[e+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+t[e+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},F=function(t,e,n,r,i,o){var s,u,a,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(u=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+l>=1?h/a:h*Math.pow(2,1-l))*a>=2&&(s++,a/=2),s+l>=c?(u=0,s=c):s+l>=1?(u=(e*a-1)*Math.pow(2,i),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},D=(k=function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|h(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|l(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return u(t),i(t<0?0:0|l(t))}function f(t){const e=t.length<0?0:0|l(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(t).length;default:if(i)return r?-1:Y(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return S(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:d(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):d(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function d(t,e,n,r,i){let o,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<u;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===a)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){let n=!0;for(let r=0;r<a;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function b(t,e,n,r){return H(Y(e,t.length-n),t,n,r)}function w(t,e,n,r){return H(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return H(J(e),t,n,r)}function T(t,e,n,r){return H(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function I(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,u=n-r;s<u;s+=o)i.push(C(t,s,s+o>u?u:s+o));return 1===r?i.push(B[(e=t[n-1])>>2]+B[e<<4&63]+"=="):2===r&&i.push(B[(e=(t[n-2]<<8)+t[n-1])>>10]+B[e>>4&63]+B[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,u,a;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(a=(31&e)<<6|63&n,a>127&&(o=a));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(a=(15&e)<<12|(63&n)<<6|63&r,a>2047&&(a<55296||a>57343)&&(o=a));break;case 4:n=t[i+1],r=t[i+2],u=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(o=a))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return a(t)},o.allocUnsafeSlow=function(t){return a(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=h,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0);const a=Math.min(s,u),f=this.slice(r,i),c=t.slice(e,n);for(let t=0;t<a;++t)if(f[t]!==c[t]){s=f[t],u=c[t];break}return s<u?-1:u<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function S(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function P(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function O(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function k(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function _(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function M(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function D(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function x(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function G(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,4),F(t,e,n,r,23,4),n+4}function W(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,8),F(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||k(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||V(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){q(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),L(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),L(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),L(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),L(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||_(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||_(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);_(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);_(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||_(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return G(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return G(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return W(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return W(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%u]}return this};const j={};function K(t,e,n){j[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){q(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||V(e,t.length-(n+1))}(r,i,o)}function q(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,n){if(Math.floor(t)!==t)throw q(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}K("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),K("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const X=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new U(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),u=0,a=o>0?i-4:i;for(n=0;n<a;n+=4)e=N[t.charCodeAt(n)]<<18|N[t.charCodeAt(n+1)]<<12|N[t.charCodeAt(n+2)]<<6|N[t.charCodeAt(n+3)],s[u++]=e>>16&255,s[u++]=e>>8&255,s[u++]=255&e;return 2===o&&(e=N[t.charCodeAt(n)]<<2|N[t.charCodeAt(n+1)]>>4,s[u++]=255&e),1===o&&(e=N[t.charCodeAt(n)]<<10|N[t.charCodeAt(n+1)]<<4|N[t.charCodeAt(n+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}},k(_={exports:{}},_.exports),_.exports);function x(t,e){var i;if(1===e)i=R(new n.PublicKey(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+r.sha3_256(t);for(var o=t.substring(2),s=[],u=0;u<o.length;u+=2)s.push(parseInt(o.substring(u,u+2),16));i=R(new Uint8Array(s),32)}return"0x"+D.Buffer.from(i).toString("hex")}function G(t,e,r,i,o){if(void 0===r&&(r=!1),void 0===i&&(i=new n.PublicKey(u)),void 0===o&&(o=new n.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),!r&&!n.PublicKey.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return n.PublicKey.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function W(t,n){var r=Number(t).toFixed(Math.min(8,Number(n)));return e.ethers.utils.parseUnits(r,Number(n))}var j={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function K(t){return j[t]}var $=((M={})[1]=2,M[56]=4,M[137]=5,M[43114]=6,M),z=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}];function q(t,e,r,i,o,s){return void 0===o&&(o=new n.PublicKey(u)),void 0===s&&(s=new n.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),new n.TransactionInstruction({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:n.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:n.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],programId:s,data:D.Buffer.alloc(0)})}var V=i.struct([i.u8("instruction")]),X=i.struct([i.u8("instruction"),i.u8("mainNonce"),i.u8("stateNonce"),i.nu64("amount"),i.nu64("minAmountOut"),i.nu64("deadline"),i.nu64("feeSwap"),i.nu64("feeReturn"),i.nu64("feeCancel"),i.u16("destinationChain"),i.blob(32,"destinationAddress")]);exports.fetchAllTokenList=function(){try{return Promise.resolve(s.default(a+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}},exports.fetchQuote=function(t){try{var e=t.customRelayerFees;return Promise.resolve(s.default(a+"/quote?amountIn="+t.amount+"&fromToken="+t.fromToken+"&fromChain="+t.fromChain+"&toToken="+t.toToken+"&toChain="+t.toChain+"&slippage="+t.slippage/100+(e?"&swapRelayerFee="+e.swapRelayerFee+"&redeemRelayerFee="+e.redeemRelayerFee+"&refundRelayerFee="+e.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},exports.fetchTokenList=function(t){try{return Promise.resolve(s.default(a+"/tokens?chain="+t)).then(function(e){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===e.status)return Promise.resolve(e.json()).then(function(e){return n=1,e[t]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},exports.getCurrentSolanaTime=f,exports.swapFromEvm=function(t,r,i,o,s,u){try{var a=new n.PublicKey("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E");return Promise.resolve(n.PublicKey.findProgramAddress([Buffer.from("MAIN")],a)).then(function(a){var l=a[0],h=G(new n.PublicKey(t.fromToken.mint),l,!0),p=W(t.effectiveAmountIn,t.fromToken.decimals),y=x(h.toString(),1);return Promise.resolve(s.getChainId()).then(function(n){var a=$[n],l=K(t.fromChain),h=K(t.toChain);if(l!==a)throw new Error("Signer chain id and quote from chain are not same!");var g={mayanAddr:y,mayanChainId:1,destAddr:x(r,h),destChainId:h};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(n){return Promise.resolve(f()).then(function(r){var o,a,f={transferDeadline:e.ethers.BigNumber.from(n+i),swapDeadline:e.ethers.BigNumber.from(r+i),amountOutMin:W(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),a=Buffer.alloc(4),a.writeUInt32LE(o,0),a).readUInt32LE(0)},l={swapFee:W(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:W(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:W(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},h=x(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===e.ethers.constants.AddressZero?function(t,n,r,i,o,s,u,a,f){try{var l=new e.ethers.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",z,a);return Promise.resolve(l.wrapAndSwapETH(n,r,i,o,s,f?c({value:u},f):{value:u}))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,p,s,u):function(t,n,r,i,o,s,u,a,f,c){try{var l=new e.ethers.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",z,f);return Promise.resolve(c?l.swap(n,r,i,o,s,u,a,c):l.swap(n,r,i,o,s,u,a))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,t.fromToken.contract,p,s,u)})})})})}catch(t){return Promise.reject(t)}},exports.swapFromSolana=function(t,r,i,o,s,a){try{var c=null!=a?a:new n.Connection("https://rpc.ankr.com/solana"),l=new n.PublicKey("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E"),h=new n.PublicKey(u),p=new n.PublicKey(r),y=n.PublicKey.findProgramAddressSync([D.Buffer.from("MAIN")],l),g=y[0],d=y[1],m=n.Keypair.generate().publicKey,b=n.Keypair.generate().publicKey,w=n.PublicKey.findProgramAddressSync([D.Buffer.from("V2STATE"),D.Buffer.from(m.toBytes()),D.Buffer.from(b.toBytes())],l),E=w[0],T=w[1],I=new n.PublicKey(t.fromToken.mint),A=new n.PublicKey(t.toToken.mint),v=G(I,p),R=G(I,g,!0),B=new n.Transaction({feePayer:p});return Promise.resolve(c.getAccountInfo(v,"finalized")).then(function(r){return r&&0!==r.data.length||B.add(q(p,v,p,I)),Promise.resolve(c.getAccountInfo(R,"finalized")).then(function(r){var a,y;r&&0!==r.data.length||B.add(q(p,R,g,I)),t.fromToken.contract===e.ethers.constants.AddressZero&&(B.add(n.SystemProgram.transfer({fromPubkey:p,toPubkey:v,lamports:W(t.effectiveAmountIn,9).toBigInt()})),B.add((a=[{pubkey:v,isSigner:!1,isWritable:!0}],y=D.Buffer.alloc(V.span),V.encode({instruction:17},y),new n.TransactionInstruction({keys:a,programId:new n.PublicKey(u),data:y}))));var w=[{pubkey:p,isWritable:!1,isSigner:!0},{pubkey:g,isWritable:!1,isSigner:!1},{pubkey:m,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:E,isWritable:!0,isSigner:!1},{pubkey:v,isWritable:!0,isSigner:!1},{pubkey:R,isWritable:!0,isSigner:!1},{pubkey:I,isWritable:!1,isSigner:!1},{pubkey:A,isWritable:!1,isSigner:!1},{pubkey:n.SYSVAR_CLOCK_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:n.SYSVAR_RENT_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:h,isWritable:!1,isSigner:!1},{pubkey:n.SystemProgram.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(f()).then(function(e){function r(r){var a,f=D.Buffer.from((a=x(i,u),new Uint8Array(D.Buffer.from(a.substring(2),"hex")))),h=W(t.effectiveAmountIn,t.mintDecimals.from),p=W(t.minAmountOut,t.mintDecimals.to),y=W(t.swapRelayerFee,t.mintDecimals.from),g=W(t.redeemRelayerFee,t.mintDecimals.to),m=W(t.refundRelayerFee,t.mintDecimals.from),b=D.Buffer.alloc(X.span);X.encode({instruction:101,mainNonce:d,stateNonce:T,amount:h,minAmountOut:p,deadline:e+o,feeSwap:y,feeReturn:g,feeCancel:m,destinationChain:u,destinationAddress:f},b);var E=new n.TransactionInstruction({keys:w,data:b,programId:l});return B.add(E),Promise.resolve(c.getLatestBlockhash()).then(function(t){return B.recentBlockhash=t.blockhash,Promise.resolve(s(B)).then(function(t){return Promise.resolve(c.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var u=K(t.toChain),a=function(){if(1===u)return Promise.resolve(c.getAccountInfo(new n.PublicKey(i))).then(function(t){if(t.owner.equals(h))throw new Error("Destination address is not about token account. It should be a owner address")})}();return a&&a.then?a.then(r):r()})})})}catch(t){return Promise.reject(t)}}; | ||
//# sourceMappingURL=main.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"cross-fetch";import{ethers as e}from"ethers";import{PublicKey as n,Connection as r,Keypair as i,Transaction as o,SystemProgram as s,SYSVAR_CLOCK_PUBKEY as a,SYSVAR_RENT_PUBKEY as u,TransactionInstruction as f}from"@solana/web3.js";import{sha3_256 as h}from"js-sha3";import{struct as l,u8 as c,nu64 as p,u16 as y,blob as g}from"@solana/buffer-layout";var m="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",d="https://price-api.mayan.finance/v1",w=function(){try{return Promise.resolve(t(d+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}},b=function(e){try{var n=e.customRelayerFees;return Promise.resolve(t(d+"/quote?amountIn="+e.amount+"&fromToken="+e.fromToken+"&fromChain="+e.fromChain+"&toToken="+e.toToken+"&toChain="+e.toChain+"&slippage="+e.slippage/100+(n?"&swapRelayerFee="+n.swapRelayerFee+"&redeemRelayerFee="+n.redeemRelayerFee+"&refundRelayerFee="+n.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},E=function(e){try{return Promise.resolve(t(d+"/tokens?chain="+e)).then(function(t){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return n=1,t[e]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},I=function(){try{return Promise.resolve(t(d+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}};function T(){return T=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T.apply(this,arguments)}let A=!1,v=!1;const R={debug:1,default:2,info:2,warning:3,error:4,off:5};let N=R.default,B=null;const U=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var S,O;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(S||(S={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(O||(O={}));const C="0123456789abcdef";class P{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==R[n]&&this.throwArgumentError("invalid log level name","logLevel",t),N>R[n]||console.log.apply(console,e)}debug(...t){this._log(P.levels.DEBUG,t)}info(...t){this._log(P.levels.INFO,t)}warn(...t){this._log(P.levels.WARNING,t)}makeError(t,e,n){if(v)return this.makeError("censored error",e,{});e||(e=P.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=C[e[t]>>4],n+=C[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case O.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case O.CALL_EXCEPTION:case O.INSUFFICIENT_FUNDS:case O.MISSING_NEW:case O.NONCE_EXPIRED:case O.REPLACEMENT_UNDERPRICED:case O.TRANSACTION_REPLACED:case O.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,P.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){U&&this.throwError("platform missing String.prototype.normalize",P.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:U})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,P.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,P.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,P.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,P.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",P.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",P.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",P.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return B||(B=new P("logger/5.7.0")),B}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",P.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),A){if(!t)return;this.globalLogger().throwError("error censorship permanent",P.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}v=!!t,A=!!e}static setLogLevel(t){const e=R[t.toLowerCase()];null!=e?N=e:P.globalLogger().warn("invalid log level - "+t)}static from(t){return new P(t)}}P.errors=O,P.levels=S;const k=new P("bytes/5.7.0");function _(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return _(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function M(t){return"number"==typeof t&&t==t&&t%1==0}function L(t,e){if(e||(e={}),"number"==typeof t){k.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),_(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":k.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return _(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!M(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!M(n)||n<0||n>=256)return!1}return!0}(t)?_(new Uint8Array(t)):k.throwArgumentError("invalid arrayify value","value",t)}function F(t,e){(t=L(t)).length>e&&k.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),_(n)}for(var D=[],x=[],G="undefined"!=typeof Uint8Array?Uint8Array:Array,W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=0,$=W.length;j<$;++j)D[j]=W[j],x[W.charCodeAt(j)]=j;function z(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(D[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+D[r>>12&63]+D[r>>6&63]+D[63&r]);return i.join("")}x["-".charCodeAt(0)]=62,x["_".charCodeAt(0)]=63;var V,q,X,K=function(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,f=u>>1,h=-7,l=n?i-1:0,c=n?-1:1,p=t[e+l];for(l+=c,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},J=function(t,e,n,r,i,o){var s,a,u,f=8*o-i-1,h=(1<<f)-1,l=h>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=y,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},H=(V=function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|c(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return h(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return h(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|l(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return a(t),i(t<0?0:0|l(t))}function f(t){const e=t.length<0?0:0|l(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function h(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function c(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return X(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return H(t).length;default:if(i)return r?-1:X(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return N(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){let o,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<a;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===u)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let r=0;r<u;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function d(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function w(t,e,n,r){return Y(X(e,t.length-n),t,n,r)}function b(t,e,n,r){return Y(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return Y(H(e),t,n,r)}function I(t,e,n,r){return Y(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,a=n-r;s<a;s+=o)i.push(z(t,s,s+o>a?a:s+o));return 1===r?i.push(D[(e=t[n-1])>>2]+D[e<<4&63]+"=="):2===r&&i.push(D[(e=(t[n-2]<<8)+t[n-1])>>10]+D[e>>4&63]+D[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(o=u));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(u=(15&e)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return a(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return u(t)},o.allocUnsafeSlow=function(t){return u(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=c,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0);const u=Math.min(s,a),f=this.slice(r,i),h=t.slice(e,n);for(let t=0;t<u;++t)if(f[t]!==h[t]){s=f[t],a=h[t];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return d(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function N(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function B(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function U(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function S(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function C(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function P(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function k(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function _(t,e,n,r,i){return e=+e,n>>>=0,i||k(t,0,n,4),J(t,e,n,r,23,4),n+4}function M(t,e,n,r,i){return e=+e,n>>>=0,i||k(t,0,n,8),J(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||V(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),K(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),K(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),K(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),K(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||O(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||O(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return _(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return _(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return M(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return M(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%a]}return this};const L={};function F(t,e,n){L[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function j(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new L.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||V(e,t.length-(n+1))}(r,i,o)}function $(t,e){if("number"!=typeof t)throw new L.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,n){if(Math.floor(t)!==t)throw $(t,n),new L.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),F("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),F("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=W(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const q=/[^+/0-9A-Za-z-_]/g;function X(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new G(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),a=0,u=o>0?i-4:i;for(n=0;n<u;n+=4)e=x[t.charCodeAt(n)]<<18|x[t.charCodeAt(n+1)]<<12|x[t.charCodeAt(n+2)]<<6|x[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===o&&(e=x[t.charCodeAt(n)]<<2|x[t.charCodeAt(n+1)]>>4,s[a++]=255&e),1===o&&(e=x[t.charCodeAt(n)]<<10|x[t.charCodeAt(n+1)]<<4|x[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}},V(q={exports:{}},q.exports),q.exports);function Y(t,e){var r;if(1===e)r=F(new n(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+h(t);for(var i=t.substring(2),o=[],s=0;s<i.length;s+=2)o.push(parseInt(i.substring(s,s+2),16));r=F(new Uint8Array(o),32)}return"0x"+H.Buffer.from(r).toString("hex")}function Z(t,e,r,i,o){if(void 0===r&&(r=!1),void 0===i&&(i=new n(m)),void 0===o&&(o=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),!r&&!n.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return n.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function Q(t,n){var r=Number(t).toFixed(Math.min(8,Number(n)));return e.utils.parseUnits(r,Number(n))}var tt={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function et(t){return tt[t]}var nt=((X={})[1]=2,X[56]=4,X[137]=5,X[43114]=6,X),rt=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}],it=function(t,r,i,o,s,a){try{var u=new n("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E");return Promise.resolve(n.findProgramAddress([Buffer.from("MAIN")],u)).then(function(u){var f=u[0],h=Z(new n(t.fromToken.mint),f,!0),l=Q(t.effectiveAmountIn,t.fromToken.decimals),c=Y(h.toString(),1);return Promise.resolve(s.getChainId()).then(function(n){var u=nt[n],f=et(t.fromChain),h=et(t.toChain);if(f!==u)throw new Error("Signer chain id and quote from chain are not same!");var p={mayanAddr:c,mayanChainId:1,destAddr:Y(r,h),destChainId:h};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(n){return Promise.resolve(w()).then(function(r){var o,u,f={transferDeadline:e.BigNumber.from(n+i),swapDeadline:e.BigNumber.from(r+i),amountOutMin:Q(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),u=Buffer.alloc(4),u.writeUInt32LE(o,0),u).readUInt32LE(0)},h={swapFee:Q(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:Q(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:Q(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},c=Y(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===e.constants.AddressZero?function(t,n,r,i,o,s,a,u,f){try{var h=new e.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",rt,u);return Promise.resolve(h.wrapAndSwapETH(n,r,i,o,s,f?T({value:a},f):{value:a}))}catch(t){return Promise.reject(t)}}(0,h,p,c,t.toToken.realOriginChainId,f,l,s,a):function(t,n,r,i,o,s,a,u,f,h){try{var l=new e.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",rt,f);return Promise.resolve(h?l.swap(n,r,i,o,s,a,u,h):l.swap(n,r,i,o,s,a,u))}catch(t){return Promise.reject(t)}}(0,h,p,c,t.toToken.realOriginChainId,f,t.fromToken.contract,l,s,a)})})})})}catch(t){return Promise.reject(t)}};function ot(t,e,r,i,o,a){return void 0===o&&(o=new n(m)),void 0===a&&(a=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),new f({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!1}],programId:a,data:H.Buffer.alloc(0)})}var st=function(t,h,l,c,p,y){try{var g=null!=y?y:new r("https://rpc.ankr.com/solana"),d=new n("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E"),b=new n(m),E=new n(h),I=n.findProgramAddressSync([H.Buffer.from("MAIN")],d),T=I[0],A=I[1],v=i.generate().publicKey,R=i.generate().publicKey,N=n.findProgramAddressSync([H.Buffer.from("V2STATE"),H.Buffer.from(v.toBytes()),H.Buffer.from(R.toBytes())],d),B=N[0],U=N[1],S=new n(t.fromToken.mint),O=new n(t.toToken.mint),C=Z(S,E),P=Z(S,T,!0),k=new o({feePayer:E});return Promise.resolve(g.getAccountInfo(C,"finalized")).then(function(r){return r&&0!==r.data.length||k.add(ot(E,C,E,S)),Promise.resolve(g.getAccountInfo(P,"finalized")).then(function(r){var i,o;r&&0!==r.data.length||k.add(ot(E,P,T,S)),t.fromToken.contract===e.constants.AddressZero&&(k.add(s.transfer({fromPubkey:E,toPubkey:C,lamports:Q(t.effectiveAmountIn,9).toBigInt()})),k.add((i=[{pubkey:C,isSigner:!1,isWritable:!0}],o=H.Buffer.alloc(at.span),at.encode({instruction:17},o),new f({keys:i,programId:new n(m),data:o}))));var h=[{pubkey:E,isWritable:!1,isSigner:!0},{pubkey:T,isWritable:!1,isSigner:!1},{pubkey:v,isWritable:!1,isSigner:!1},{pubkey:R,isWritable:!1,isSigner:!1},{pubkey:B,isWritable:!0,isSigner:!1},{pubkey:C,isWritable:!0,isSigner:!1},{pubkey:P,isWritable:!0,isSigner:!1},{pubkey:S,isWritable:!1,isSigner:!1},{pubkey:O,isWritable:!1,isSigner:!1},{pubkey:a,isWritable:!1,isSigner:!1},{pubkey:u,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:s.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(w()).then(function(e){function r(n){var r,o=H.Buffer.from((r=Y(l,i),new Uint8Array(H.Buffer.from(r.substring(2),"hex")))),s=Q(t.effectiveAmountIn,t.mintDecimals.from),a=Q(t.minAmountOut,t.mintDecimals.to),u=Q(t.swapRelayerFee,t.mintDecimals.from),y=Q(t.redeemRelayerFee,t.mintDecimals.to),m=Q(t.refundRelayerFee,t.mintDecimals.from),w=H.Buffer.alloc(ut.span);ut.encode({instruction:101,mainNonce:A,stateNonce:U,amount:s,minAmountOut:a,deadline:e+c,feeSwap:u,feeReturn:y,feeCancel:m,destinationChain:i,destinationAddress:o},w);var b=new f({keys:h,data:w,programId:d});return k.add(b),Promise.resolve(g.getLatestBlockhash()).then(function(t){return k.recentBlockhash=t.blockhash,Promise.resolve(p(k)).then(function(t){return Promise.resolve(g.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var i=et(t.toChain),o=function(){if(1===i)return Promise.resolve(g.getAccountInfo(new n(l))).then(function(t){if(t.owner.equals(b))throw new Error("Destination address is not about token account. It should be a owner address")})}();return o&&o.then?o.then(r):r()})})})}catch(t){return Promise.reject(t)}},at=l([c("instruction")]),ut=l([c("instruction"),c("mainNonce"),c("stateNonce"),p("amount"),p("minAmountOut"),p("deadline"),p("feeSwap"),p("feeReturn"),p("feeCancel"),y("destinationChain"),g(32,"destinationAddress")]);export{I as fetchAllTokenList,b as fetchQuote,E as fetchTokenList,w as getCurrentSolanaTime,it as swapFromEvm,st as swapFromSolana}; | ||
import t from"cross-fetch";import{ethers as e}from"ethers";import{PublicKey as n,Connection as r,Keypair as i,Transaction as o,SystemProgram as s,SYSVAR_CLOCK_PUBKEY as a,SYSVAR_RENT_PUBKEY as u,TransactionInstruction as f}from"@solana/web3.js";import{sha3_256 as h}from"js-sha3";import{struct as l,u8 as c,nu64 as p,u16 as y,blob as g}from"@solana/buffer-layout";var d="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",m="https://price-api.mayan.finance/v1",w=function(){try{return Promise.resolve(t(m+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}},b=function(e){try{var n=e.customRelayerFees;return Promise.resolve(t(m+"/quote?amountIn="+e.amount+"&fromToken="+e.fromToken+"&fromChain="+e.fromChain+"&toToken="+e.toToken+"&toChain="+e.toChain+"&slippage="+e.slippage/100+(n?"&swapRelayerFee="+n.swapRelayerFee+"&redeemRelayerFee="+n.redeemRelayerFee+"&refundRelayerFee="+n.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},E=function(e){try{return Promise.resolve(t(m+"/tokens?chain="+e)).then(function(t){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return n=1,t[e]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},I=function(){try{return Promise.resolve(t(m+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}};function T(){return T=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T.apply(this,arguments)}let A=!1,v=!1;const R={debug:1,default:2,info:2,warning:3,error:4,off:5};let B=R.default,N=null;const U=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var S,O;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(S||(S={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(O||(O={}));const C="0123456789abcdef";class P{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==R[n]&&this.throwArgumentError("invalid log level name","logLevel",t),B>R[n]||console.log.apply(console,e)}debug(...t){this._log(P.levels.DEBUG,t)}info(...t){this._log(P.levels.INFO,t)}warn(...t){this._log(P.levels.WARNING,t)}makeError(t,e,n){if(v)return this.makeError("censored error",e,{});e||(e=P.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=C[e[t]>>4],n+=C[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case O.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case O.CALL_EXCEPTION:case O.INSUFFICIENT_FUNDS:case O.MISSING_NEW:case O.NONCE_EXPIRED:case O.REPLACEMENT_UNDERPRICED:case O.TRANSACTION_REPLACED:case O.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,P.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){U&&this.throwError("platform missing String.prototype.normalize",P.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:U})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,P.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,P.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,P.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,P.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",P.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",P.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",P.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return N||(N=new P("logger/5.7.0")),N}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",P.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),A){if(!t)return;this.globalLogger().throwError("error censorship permanent",P.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}v=!!t,A=!!e}static setLogLevel(t){const e=R[t.toLowerCase()];null!=e?B=e:P.globalLogger().warn("invalid log level - "+t)}static from(t){return new P(t)}}P.errors=O,P.levels=S;const k=new P("bytes/5.7.0");function _(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return _(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function M(t){return"number"==typeof t&&t==t&&t%1==0}function L(t,e){if(e||(e={}),"number"==typeof t){k.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),_(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":k.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return _(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!M(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!M(n)||n<0||n>=256)return!1}return!0}(t)?_(new Uint8Array(t)):k.throwArgumentError("invalid arrayify value","value",t)}function F(t,e){(t=L(t)).length>e&&k.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),_(n)}for(var D=[],x=[],G="undefined"!=typeof Uint8Array?Uint8Array:Array,W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=0,$=W.length;j<$;++j)D[j]=W[j],x[W.charCodeAt(j)]=j;function z(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(D[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+D[r>>12&63]+D[r>>6&63]+D[63&r]);return i.join("")}x["-".charCodeAt(0)]=62,x["_".charCodeAt(0)]=63;var V,q,X,K=function(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,f=u>>1,h=-7,l=n?i-1:0,c=n?-1:1,p=t[e+l];for(l+=c,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=c,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+l],l+=c,h-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},J=function(t,e,n,r,i,o){var s,a,u,f=8*o-i-1,h=(1<<f)-1,l=h>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=y,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},H=(V=function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|c(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return h(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return h(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|l(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return a(t),i(t<0?0:0|l(t))}function f(t){const e=t.length<0?0:0|l(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function h(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function c(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return X(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return H(t).length;default:if(i)return r?-1:X(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return B(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:d(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):d(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function d(t,e,n,r,i){let o,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<a;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===u)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let r=0;r<u;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function w(t,e,n,r){return Y(X(e,t.length-n),t,n,r)}function b(t,e,n,r){return Y(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return Y(H(e),t,n,r)}function I(t,e,n,r){return Y(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function T(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,a=n-r;s<a;s+=o)i.push(z(t,s,s+o>a?a:s+o));return 1===r?i.push(D[(e=t[n-1])>>2]+D[e<<4&63]+"=="):2===r&&i.push(D[(e=(t[n-2]<<8)+t[n-1])>>10]+D[e>>4&63]+D[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(o=u));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(u=(15&e)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return a(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return u(t)},o.allocUnsafeSlow=function(t){return u(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=c,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0);const u=Math.min(s,a),f=this.slice(r,i),h=t.slice(e,n);for(let t=0;t<u;++t)if(f[t]!==h[t]){s=f[t],a=h[t];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function B(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function N(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function U(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function S(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function C(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function P(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function k(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function _(t,e,n,r,i){return e=+e,n>>>=0,i||k(t,0,n,4),J(t,e,n,r,23,4),n+4}function M(t,e,n,r,i){return e=+e,n>>>=0,i||k(t,0,n,8),J(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||S(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||V(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||V(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),K(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),K(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),K(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),K(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||O(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||O(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return _(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return _(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return M(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return M(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%a]}return this};const L={};function F(t,e,n){L[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function j(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new L.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||V(e,t.length-(n+1))}(r,i,o)}function $(t,e){if("number"!=typeof t)throw new L.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,n){if(Math.floor(t)!==t)throw $(t,n),new L.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),F("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),F("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=W(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const q=/[^+/0-9A-Za-z-_]/g;function X(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new G(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),a=0,u=o>0?i-4:i;for(n=0;n<u;n+=4)e=x[t.charCodeAt(n)]<<18|x[t.charCodeAt(n+1)]<<12|x[t.charCodeAt(n+2)]<<6|x[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===o&&(e=x[t.charCodeAt(n)]<<2|x[t.charCodeAt(n+1)]>>4,s[a++]=255&e),1===o&&(e=x[t.charCodeAt(n)]<<10|x[t.charCodeAt(n+1)]<<4|x[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}},V(q={exports:{}},q.exports),q.exports);function Y(t,e){var r;if(1===e)r=F(new n(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+h(t);for(var i=t.substring(2),o=[],s=0;s<i.length;s+=2)o.push(parseInt(i.substring(s,s+2),16));r=F(new Uint8Array(o),32)}return"0x"+H.Buffer.from(r).toString("hex")}function Z(t,e,r,i,o){if(void 0===r&&(r=!1),void 0===i&&(i=new n(d)),void 0===o&&(o=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),!r&&!n.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return n.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function Q(t,n){var r=Number(t).toFixed(Math.min(8,Number(n)));return e.utils.parseUnits(r,Number(n))}var tt={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function et(t){return tt[t]}var nt=((X={})[1]=2,X[56]=4,X[137]=5,X[43114]=6,X),rt=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}],it=function(t,r,i,o,s,a){try{var u=new n("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E");return Promise.resolve(n.findProgramAddress([Buffer.from("MAIN")],u)).then(function(u){var f=u[0],h=Z(new n(t.fromToken.mint),f,!0),l=Q(t.effectiveAmountIn,t.fromToken.decimals),c=Y(h.toString(),1);return Promise.resolve(s.getChainId()).then(function(n){var u=nt[n],f=et(t.fromChain),h=et(t.toChain);if(f!==u)throw new Error("Signer chain id and quote from chain are not same!");var p={mayanAddr:c,mayanChainId:1,destAddr:Y(r,h),destChainId:h};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(n){return Promise.resolve(w()).then(function(r){var o,u,f={transferDeadline:e.BigNumber.from(n+i),swapDeadline:e.BigNumber.from(r+i),amountOutMin:Q(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),u=Buffer.alloc(4),u.writeUInt32LE(o,0),u).readUInt32LE(0)},h={swapFee:Q(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:Q(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:Q(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},c=Y(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===e.constants.AddressZero?function(t,n,r,i,o,s,a,u,f){try{var h=new e.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",rt,u);return Promise.resolve(h.wrapAndSwapETH(n,r,i,o,s,f?T({value:a},f):{value:a}))}catch(t){return Promise.reject(t)}}(0,h,p,c,t.toToken.realOriginChainId,f,l,s,a):function(t,n,r,i,o,s,a,u,f,h){try{var l=new e.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",rt,f);return Promise.resolve(h?l.swap(n,r,i,o,s,a,u,h):l.swap(n,r,i,o,s,a,u))}catch(t){return Promise.reject(t)}}(0,h,p,c,t.toToken.realOriginChainId,f,t.fromToken.contract,l,s,a)})})})})}catch(t){return Promise.reject(t)}};function ot(t,e,r,i,o,a){return void 0===o&&(o=new n(d)),void 0===a&&(a=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),new f({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!1}],programId:a,data:H.Buffer.alloc(0)})}var st=function(t,h,l,c,p,y){try{var g=null!=y?y:new r("https://rpc.ankr.com/solana"),m=new n("8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E"),b=new n(d),E=new n(h),I=n.findProgramAddressSync([H.Buffer.from("MAIN")],m),T=I[0],A=I[1],v=i.generate().publicKey,R=i.generate().publicKey,B=n.findProgramAddressSync([H.Buffer.from("V2STATE"),H.Buffer.from(v.toBytes()),H.Buffer.from(R.toBytes())],m),N=B[0],U=B[1],S=new n(t.fromToken.mint),O=new n(t.toToken.mint),C=Z(S,E),P=Z(S,T,!0),k=new o({feePayer:E});return Promise.resolve(g.getAccountInfo(C,"finalized")).then(function(r){return r&&0!==r.data.length||k.add(ot(E,C,E,S)),Promise.resolve(g.getAccountInfo(P,"finalized")).then(function(r){var i,o;r&&0!==r.data.length||k.add(ot(E,P,T,S)),t.fromToken.contract===e.constants.AddressZero&&(k.add(s.transfer({fromPubkey:E,toPubkey:C,lamports:Q(t.effectiveAmountIn,9).toBigInt()})),k.add((i=[{pubkey:C,isSigner:!1,isWritable:!0}],o=H.Buffer.alloc(at.span),at.encode({instruction:17},o),new f({keys:i,programId:new n(d),data:o}))));var h=[{pubkey:E,isWritable:!1,isSigner:!0},{pubkey:T,isWritable:!1,isSigner:!1},{pubkey:v,isWritable:!1,isSigner:!1},{pubkey:R,isWritable:!1,isSigner:!1},{pubkey:N,isWritable:!0,isSigner:!1},{pubkey:C,isWritable:!0,isSigner:!1},{pubkey:P,isWritable:!0,isSigner:!1},{pubkey:S,isWritable:!1,isSigner:!1},{pubkey:O,isWritable:!1,isSigner:!1},{pubkey:a,isWritable:!1,isSigner:!1},{pubkey:u,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:s.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(w()).then(function(e){function r(n){var r,o=H.Buffer.from((r=Y(l,i),new Uint8Array(H.Buffer.from(r.substring(2),"hex")))),s=Q(t.effectiveAmountIn,t.mintDecimals.from),a=Q(t.minAmountOut,t.mintDecimals.to),u=Q(t.swapRelayerFee,t.mintDecimals.from),y=Q(t.redeemRelayerFee,t.mintDecimals.to),d=Q(t.refundRelayerFee,t.mintDecimals.from),w=H.Buffer.alloc(ut.span);ut.encode({instruction:101,mainNonce:A,stateNonce:U,amount:s,minAmountOut:a,deadline:e+c,feeSwap:u,feeReturn:y,feeCancel:d,destinationChain:i,destinationAddress:o},w);var b=new f({keys:h,data:w,programId:m});return k.add(b),Promise.resolve(g.getLatestBlockhash()).then(function(t){return k.recentBlockhash=t.blockhash,Promise.resolve(p(k)).then(function(t){return Promise.resolve(g.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var i=et(t.toChain),o=function(){if(1===i)return Promise.resolve(g.getAccountInfo(new n(l))).then(function(t){if(t.owner.equals(b))throw new Error("Destination address is not about token account. It should be a owner address")})}();return o&&o.then?o.then(r):r()})})})}catch(t){return Promise.reject(t)}},at=l([c("instruction")]),ut=l([c("instruction"),c("mainNonce"),c("stateNonce"),p("amount"),p("minAmountOut"),p("deadline"),p("feeSwap"),p("feeReturn"),p("feeCancel"),y("destinationChain"),g(32,"destinationAddress")]);export{I as fetchAllTokenList,b as fetchQuote,E as fetchTokenList,w as getCurrentSolanaTime,it as swapFromEvm,st as swapFromSolana}; | ||
//# sourceMappingURL=main.modern.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("cross-fetch"),require("ethers"),require("@solana/web3.js"),require("js-sha3"),require("@solana/buffer-layout")):"function"==typeof define&&define.amd?define(["exports","cross-fetch","ethers","@solana/web3.js","js-sha3","@solana/buffer-layout"],e):e((t||self).swapSdk={},t.crossFetch,t.ethers,t.web3_js,t.jsSha3,t.bufferLayout)}(this,function(t,e,n,r,i,o){function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=/*#__PURE__*/s(e),a="8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E",f="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",l="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",c="https://price-api.mayan.finance/v1",h=function(){try{return Promise.resolve(u.default(c+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}};function p(){return p=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p.apply(this,arguments)}let y=!1,g=!1;const d={debug:1,default:2,info:2,warning:3,error:4,off:5};let m=d.default,b=null;const w=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var E,T;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(E||(E={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(T||(T={}));const I="0123456789abcdef";class A{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==d[n]&&this.throwArgumentError("invalid log level name","logLevel",t),m>d[n]||console.log.apply(console,e)}debug(...t){this._log(A.levels.DEBUG,t)}info(...t){this._log(A.levels.INFO,t)}warn(...t){this._log(A.levels.WARNING,t)}makeError(t,e,n){if(g)return this.makeError("censored error",e,{});e||(e=A.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=I[e[t]>>4],n+=I[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case T.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case T.CALL_EXCEPTION:case T.INSUFFICIENT_FUNDS:case T.MISSING_NEW:case T.NONCE_EXPIRED:case T.REPLACEMENT_UNDERPRICED:case T.TRANSACTION_REPLACED:case T.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,A.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){w&&this.throwError("platform missing String.prototype.normalize",A.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:w})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,A.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,A.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,A.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,A.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",A.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",A.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",A.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return b||(b=new A("logger/5.7.0")),b}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",A.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),y){if(!t)return;this.globalLogger().throwError("error censorship permanent",A.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}g=!!t,y=!!e}static setLogLevel(t){const e=d[t.toLowerCase()];null!=e?m=e:A.globalLogger().warn("invalid log level - "+t)}static from(t){return new A(t)}}A.errors=T,A.levels=E;const v=new A("bytes/5.7.0");function R(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return R(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function B(t){return"number"==typeof t&&t==t&&t%1==0}function N(t,e){if(e||(e={}),"number"==typeof t){v.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),R(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":v.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return R(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!B(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!B(n)||n<0||n>=256)return!1}return!0}(t)?R(new Uint8Array(t)):v.throwArgumentError("invalid arrayify value","value",t)}function U(t,e){(t=N(t)).length>e&&v.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),R(n)}for(var S=[],P=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,_=C.length;k<_;++k)S[k]=C[k],P[C.charCodeAt(k)]=k;function M(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(S[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+S[r>>12&63]+S[r>>6&63]+S[63&r]);return i.join("")}P["-".charCodeAt(0)]=62,P["_".charCodeAt(0)]=63;var L,F=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,l=-7,c=n?i-1:0,h=n?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=u;l>0;o=256*o+t[e+c],c+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},D=function(t,e,n,r,i,o){var s,u,a,f=8*o-i-1,l=(1<<f)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?h/a:h*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=l?(u=0,s=l):s+c>=1?(u=(e*a-1)*Math.pow(2,i),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},x=function(t){var e={exports:{}};return function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|h(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return l(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return l(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|c(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return u(t),i(t<0?0:0|c(t))}function f(t){const e=t.length<0?0:0|c(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function l(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function c(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(t).length;default:if(i)return r?-1:Y(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return B(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:d(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):d(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function d(t,e,n,r,i){let o,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<u;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===a)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){let n=!0;for(let r=0;r<a;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function b(t,e,n,r){return H(Y(e,t.length-n),t,n,r)}function w(t,e,n,r){return H(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return H(J(e),t,n,r)}function T(t,e,n,r){return H(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function I(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,u=n-r;s<u;s+=o)i.push(M(t,s,s+o>u?u:s+o));return 1===r?i.push(S[(e=t[n-1])>>2]+S[e<<4&63]+"=="):2===r&&i.push(S[(e=(t[n-2]<<8)+t[n-1])>>10]+S[e>>4&63]+S[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,u,a;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(a=(31&e)<<6|63&n,a>127&&(o=a));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(a=(15&e)<<12|(63&n)<<6|63&r,a>2047&&(a<55296||a>57343)&&(o=a));break;case 4:n=t[i+1],r=t[i+2],u=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(o=a))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return a(t)},o.allocUnsafeSlow=function(t){return a(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=h,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0);const a=Math.min(s,u),f=this.slice(r,i),l=t.slice(e,n);for(let t=0;t<a;++t)if(f[t]!==l[t]){s=f[t],u=l[t];break}return s<u?-1:u<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function B(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function N(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function U(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function C(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function _(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function L(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function x(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,4),D(t,e,n,r,23,4),n+4}function G(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,8),D(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||q(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),F(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),F(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),F(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),F(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||k(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||k(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);k(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);k(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return G(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return G(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%u]}return this};const W={};function K(t,e,n){W[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new W.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||q(e,t.length-(n+1))}(r,i,o)}function V(t,e){if("number"!=typeof t)throw new W.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,n){if(Math.floor(t)!==t)throw V(t,n),new W.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new W.ERR_BUFFER_OUT_OF_BOUNDS;throw new W.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}K("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),K("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const X=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new O(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),u=0,a=o>0?i-4:i;for(n=0;n<a;n+=4)e=P[t.charCodeAt(n)]<<18|P[t.charCodeAt(n+1)]<<12|P[t.charCodeAt(n+2)]<<6|P[t.charCodeAt(n+3)],s[u++]=e>>16&255,s[u++]=e>>8&255,s[u++]=255&e;return 2===o&&(e=P[t.charCodeAt(n)]<<2|P[t.charCodeAt(n+1)]>>4,s[u++]=255&e),1===o&&(e=P[t.charCodeAt(n)]<<10|P[t.charCodeAt(n+1)]<<4|P[t.charCodeAt(n+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}}(0,e.exports),e.exports}();function j(t,e){var n;if(1===e)n=U(new r.PublicKey(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+i.sha3_256(t);for(var o=t.substring(2),s=[],u=0;u<o.length;u+=2)s.push(parseInt(o.substring(u,u+2),16));n=U(new Uint8Array(s),32)}return"0x"+x.Buffer.from(n).toString("hex")}function G(t,e,n,i,o){if(void 0===n&&(n=!1),void 0===i&&(i=new r.PublicKey(f)),void 0===o&&(o=new r.PublicKey(l)),!n&&!r.PublicKey.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return r.PublicKey.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function W(t,e){var r=Number(t).toFixed(Math.min(8,Number(e)));return n.ethers.utils.parseUnits(r,Number(e))}var K={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function $(t){return K[t]}var z=((L={})[1]=2,L[56]=4,L[137]=5,L[43114]=6,L),V=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}];function q(t,e,n,i,o,s){return void 0===o&&(o=new r.PublicKey(f)),void 0===s&&(s=new r.PublicKey(l)),new r.TransactionInstruction({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:r.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],programId:s,data:x.Buffer.alloc(0)})}var X=o.struct([o.u8("instruction")]),Y=o.struct([o.u8("instruction"),o.u8("mainNonce"),o.u8("stateNonce"),o.nu64("amount"),o.nu64("minAmountOut"),o.nu64("deadline"),o.nu64("feeSwap"),o.nu64("feeReturn"),o.nu64("feeCancel"),o.u16("destinationChain"),o.blob(32,"destinationAddress")]);t.fetchAllTokenList=function(){try{return Promise.resolve(u.default(c+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}},t.fetchQuote=function(t){try{var e=t.customRelayerFees;return Promise.resolve(u.default(c+"/quote?amountIn="+t.amount+"&fromToken="+t.fromToken+"&fromChain="+t.fromChain+"&toToken="+t.toToken+"&toChain="+t.toChain+"&slippage="+t.slippage/100+(e?"&swapRelayerFee="+e.swapRelayerFee+"&redeemRelayerFee="+e.redeemRelayerFee+"&refundRelayerFee="+e.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},t.fetchTokenList=function(t){try{return Promise.resolve(u.default(c+"/tokens?chain="+t)).then(function(e){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===e.status)return Promise.resolve(e.json()).then(function(e){return n=1,e[t]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},t.getCurrentSolanaTime=h,t.swapFromEvm=function(t,e,i,o,s,u){try{var f=new r.PublicKey(a);return Promise.resolve(r.PublicKey.findProgramAddress([Buffer.from("MAIN")],f)).then(function(a){var f=a[0],l=G(new r.PublicKey(t.fromToken.mint),f,!0),c=W(t.effectiveAmountIn,t.fromToken.decimals),y=j(l.toString(),1);return Promise.resolve(s.getChainId()).then(function(r){var a=z[r],f=$(t.fromChain),l=$(t.toChain);if(f!==a)throw new Error("Signer chain id and quote from chain are not same!");var g={mayanAddr:y,mayanChainId:1,destAddr:j(e,l),destChainId:l};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(e){return Promise.resolve(h()).then(function(r){var o,a,f={transferDeadline:n.ethers.BigNumber.from(e+i),swapDeadline:n.ethers.BigNumber.from(r+i),amountOutMin:W(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),a=Buffer.alloc(4),a.writeUInt32LE(o,0),a).readUInt32LE(0)},l={swapFee:W(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:W(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:W(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},h=j(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===n.ethers.constants.AddressZero?function(t,e,r,i,o,s,u,a,f){try{var l=new n.ethers.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",V,a);return Promise.resolve(l.wrapAndSwapETH(e,r,i,o,s,f?p({value:u},f):{value:u}))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,c,s,u):function(t,e,r,i,o,s,u,a,f,l){try{var c=new n.ethers.Contract("0x521095972A7E258bcE82faD1E45D6e86838A0452",V,f);return Promise.resolve(l?c.swap(e,r,i,o,s,u,a,l):c.swap(e,r,i,o,s,u,a))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,t.fromToken.contract,c,s,u)})})})})}catch(t){return Promise.reject(t)}},t.swapFromSolana=function(t,e,i,o,s,u){try{var l=null!=u?u:new r.Connection("https://rpc.ankr.com/solana"),c=new r.PublicKey(a),p=new r.PublicKey(f),y=new r.PublicKey(e),g=r.PublicKey.findProgramAddressSync([x.Buffer.from("MAIN")],c),d=g[0],m=g[1],b=r.Keypair.generate().publicKey,w=r.Keypair.generate().publicKey,E=r.PublicKey.findProgramAddressSync([x.Buffer.from("V2STATE"),x.Buffer.from(b.toBytes()),x.Buffer.from(w.toBytes())],c),T=E[0],I=E[1],A=new r.PublicKey(t.fromToken.mint),v=new r.PublicKey(t.toToken.mint),R=G(A,y),B=G(A,d,!0),N=new r.Transaction({feePayer:y});return Promise.resolve(l.getAccountInfo(R,"finalized")).then(function(e){return e&&0!==e.data.length||N.add(q(y,R,y,A)),Promise.resolve(l.getAccountInfo(B,"finalized")).then(function(e){var u,a;e&&0!==e.data.length||N.add(q(y,B,d,A)),t.fromToken.contract===n.ethers.constants.AddressZero&&(N.add(r.SystemProgram.transfer({fromPubkey:y,toPubkey:R,lamports:W(t.effectiveAmountIn,9).toBigInt()})),N.add((u=[{pubkey:R,isSigner:!1,isWritable:!0}],a=x.Buffer.alloc(X.span),X.encode({instruction:17},a),new r.TransactionInstruction({keys:u,programId:new r.PublicKey(f),data:a}))));var g=[{pubkey:y,isWritable:!1,isSigner:!0},{pubkey:d,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:w,isWritable:!1,isSigner:!1},{pubkey:T,isWritable:!0,isSigner:!1},{pubkey:R,isWritable:!0,isSigner:!1},{pubkey:B,isWritable:!0,isSigner:!1},{pubkey:A,isWritable:!1,isSigner:!1},{pubkey:v,isWritable:!1,isSigner:!1},{pubkey:r.SYSVAR_CLOCK_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:r.SYSVAR_RENT_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:p,isWritable:!1,isSigner:!1},{pubkey:r.SystemProgram.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(h()).then(function(e){function n(n){var a,f=x.Buffer.from((a=j(i,u),new Uint8Array(x.Buffer.from(a.substring(2),"hex")))),h=W(t.effectiveAmountIn,t.mintDecimals.from),p=W(t.minAmountOut,t.mintDecimals.to),y=W(t.swapRelayerFee,t.mintDecimals.from),d=W(t.redeemRelayerFee,t.mintDecimals.to),b=W(t.refundRelayerFee,t.mintDecimals.from),w=x.Buffer.alloc(Y.span);Y.encode({instruction:101,mainNonce:m,stateNonce:I,amount:h,minAmountOut:p,deadline:e+o,feeSwap:y,feeReturn:d,feeCancel:b,destinationChain:u,destinationAddress:f},w);var E=new r.TransactionInstruction({keys:g,data:w,programId:c});return N.add(E),Promise.resolve(l.getLatestBlockhash()).then(function(t){return N.recentBlockhash=t.blockhash,Promise.resolve(s(N)).then(function(t){return Promise.resolve(l.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var u=$(t.toChain),a=function(){if(1===u)return Promise.resolve(l.getAccountInfo(new r.PublicKey(i))).then(function(t){if(t.owner.equals(p))throw new Error("Destination address is not about token account. It should be a owner address")})}();return a&&a.then?a.then(n):n()})})})}catch(t){return Promise.reject(t)}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("cross-fetch"),require("ethers"),require("@solana/web3.js"),require("js-sha3"),require("@solana/buffer-layout")):"function"==typeof define&&define.amd?define(["exports","cross-fetch","ethers","@solana/web3.js","js-sha3","@solana/buffer-layout"],e):e((t||self).swapSdk={},t.crossFetch,t.ethers,t.web3_js,t.jsSha3,t.bufferLayout)}(this,function(t,e,n,r,i,o){function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=/*#__PURE__*/s(e),a="8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E",f="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",l="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",c="https://price-api.mayan.finance/v1",h=function(){try{return Promise.resolve(u.default(c+"/clock/solana")).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw e;return e.clock})})}catch(t){return Promise.reject(t)}};function p(){return p=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p.apply(this,arguments)}let y=!1,g=!1;const d={debug:1,default:2,info:2,warning:3,error:4,off:5};let m=d.default,b=null;const w=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(n){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var E,T;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(E||(E={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(T||(T={}));const I="0123456789abcdef";class A{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();null==d[n]&&this.throwArgumentError("invalid log level name","logLevel",t),m>d[n]||console.log.apply(console,e)}debug(...t){this._log(A.levels.DEBUG,t)}info(...t){this._log(A.levels.INFO,t)}warn(...t){this._log(A.levels.WARNING,t)}makeError(t,e,n){if(g)return this.makeError("censored error",e,{});e||(e=A.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach(t=>{const e=n[t];try{if(e instanceof Uint8Array){let n="";for(let t=0;t<e.length;t++)n+=I[e[t]>>4],n+=I[15&e[t]];r.push(t+"=Uint8Array(0x"+n+")")}else r.push(t+"="+JSON.stringify(e))}catch(e){r.push(t+"="+JSON.stringify(n[t].toString()))}}),r.push(`code=${e}`),r.push(`version=${this.version}`);const i=t;let o="";switch(e){case T.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case T.CALL_EXCEPTION:case T.INSUFFICIENT_FUNDS:case T.MISSING_NEW:case T.NONCE_EXPIRED:case T.REPLACEMENT_UNDERPRICED:case T.TRANSACTION_REPLACED:case T.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),r.length&&(t+=" ("+r.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(n).forEach(function(t){s[t]=n[t]}),s}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,A.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,r){t||this.throwError(e,n,r)}assertArgument(t,e,n,r){t||this.throwArgumentError(e,n,r)}checkNormalize(t){w&&this.throwError("platform missing String.prototype.normalize",A.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:w})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,A.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,A.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n=n?": "+n:"",t<e&&this.throwError("missing argument"+n,A.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,A.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",A.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",A.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",A.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return b||(b=new A("logger/5.7.0")),b}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",A.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),y){if(!t)return;this.globalLogger().throwError("error censorship permanent",A.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}g=!!t,y=!!e}static setLogLevel(t){const e=d[t.toLowerCase()];null!=e?m=e:A.globalLogger().warn("invalid log level - "+t)}static from(t){return new A(t)}}A.errors=T,A.levels=E;const v=new A("bytes/5.7.0");function R(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return R(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function B(t){return"number"==typeof t&&t==t&&t%1==0}function N(t,e){if(e||(e={}),"number"==typeof t){v.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),R(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))}(t)){let n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":v.throwArgumentError("hex data is odd-length","value",t));const r=[];for(let t=0;t<n.length;t+=2)r.push(parseInt(n.substring(t,t+2),16));return R(new Uint8Array(r))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!B(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const n=t[e];if(!B(n)||n<0||n>=256)return!1}return!0}(t)?R(new Uint8Array(t)):v.throwArgumentError("invalid arrayify value","value",t)}function U(t,e){(t=N(t)).length>e&&v.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(e);return n.set(t,e-t.length),R(n)}for(var S=[],P=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,_=C.length;k<_;++k)S[k]=C[k],P[C.charCodeAt(k)]=k;function M(t,e,n){for(var r,i=[],o=e;o<n;o+=3)i.push(S[(r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]))>>18&63]+S[r>>12&63]+S[r>>6&63]+S[63&r]);return i.join("")}P["-".charCodeAt(0)]=62,P["_".charCodeAt(0)]=63;var L,F=function(t,e,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,l=-7,c=n?i-1:0,h=n?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=u;l>0;o=256*o+t[e+c],c+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},D=function(t,e,n,r,i,o){var s,u,a,f=8*o-i-1,l=(1<<f)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?h/a:h*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=l?(u=0,s=l):s+c>=1?(u=(e*a-1)*Math.pow(2,i),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[n+p]=255&s,p+=y,s/=256,f-=8);t[n+p-y]|=128*g},x=function(t){var e={exports:{}};return function(t,e){const n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50;const r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|h(t,e);let r=i(n);const s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return l(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return l(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return o.from(r,e,n);const s=function(t){if(o.isBuffer(t)){const e=0|c(t.length),n=i(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?i(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return u(t),i(t<0?0:0|c(t))}function f(t){const e=t.length<0?0:0|c(t.length),n=i(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function l(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,o.prototype),r}function c(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(t).length;default:if(i)return r?-1:Y(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return B(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:d(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):d(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function d(t,e,n,r,i){let o,s=1,u=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<u;o++)if(f(t,o)===f(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===a)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){let n=!0;for(let r=0;r<a;r++)if(f(t,o+r)!==f(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Q(r))return s;t[n+s]=r}return s}function b(t,e,n,r){return H(Y(e,t.length-n),t,n,r)}function w(t,e,n,r){return H(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return H(J(e),t,n,r)}function T(t,e,n,r){return H(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function I(t,e,n){return function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,u=n-r;s<u;s+=o)i.push(M(t,s,s+o>u?u:s+o));return 1===r?i.push(S[(e=t[n-1])>>2]+S[e<<4&63]+"=="):2===r&&i.push(S[(e=(t[n-2]<<8)+t[n-1])>>10]+S[e>>4&63]+S[e<<2&63]+"="),i.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,u,a;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(a=(31&e)<<6|63&n,a>127&&(o=a));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(a=(15&e)<<12|(63&n)<<6|63&r,a>2047&&(a<55296||a>57343)&&(o=a));break;case 4:n=t[i+1],r=t[i+2],u=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&u)&&(a=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&u,a>65535&&a<1114112&&(o=a))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=v)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=v));return n}(r)}e.kMaxLength=r,(o.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}(t,e,n)},o.allocUnsafe=function(t){return a(t)},o.allocUnsafeSlow=function(t){return a(t)},o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=o.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(Z(e,Uint8Array))i+e.length>r.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},o.byteLength=h,o.prototype._isBuffer=!0,o.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},o.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},o.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},o.prototype.toLocaleString=o.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,n,r,i){if(Z(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0);const a=Math.min(s,u),f=this.slice(r,i),l=t.slice(e,n);for(let t=0;t<a;++t)if(f[t]!==l[t]){s=f[t],u=l[t];break}return s<u?-1:u<s?1:0},o.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},o.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0)},o.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1)},o.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":case"latin1":case"binary":return w(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const v=4096;function R(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function B(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function N(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=tt[t[r]];return i}function U(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function C(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function _(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function L(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function x(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,4),D(t,e,n,r,23,4),n+4}function G(t,e,n,r,i){return e=+e,n>>>=0,i||x(t,0,n,8),D(t,e,n,r,52,8),n+8}o.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),o.prototype.readBigUInt64BE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),o.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];return void 0!==e&&void 0!==n||q(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),o.prototype.readBigInt64BE=et(function(t){V(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),o.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),F(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),F(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),F(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),F(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||k(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||k(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=et(function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=et(function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);k(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);k(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=et(function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=et(function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return G(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return G(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,r){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},o.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const s=o.isBuffer(t)?t:o.from(t,r),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=s[i%u]}return this};const W={};function K(t,e,n){W[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new W.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||q(e,t.length-(n+1))}(r,i,o)}function V(t,e){if("number"!=typeof t)throw new W.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,n){if(Math.floor(t)!==t)throw V(t,n),new W.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new W.ERR_BUFFER_OUT_OF_BOUNDS;throw new W.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}K("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),K("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const X=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let n;e=e||Infinity;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function J(t){return function(t){var e,n,r=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),i=r[0],o=r[1],s=new O(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),u=0,a=o>0?i-4:i;for(n=0;n<a;n+=4)e=P[t.charCodeAt(n)]<<18|P[t.charCodeAt(n+1)]<<12|P[t.charCodeAt(n+2)]<<6|P[t.charCodeAt(n+3)],s[u++]=e>>16&255,s[u++]=e>>8&255,s[u++]=255&e;return 2===o&&(e=P[t.charCodeAt(n)]<<2|P[t.charCodeAt(n+1)]>>4,s[u++]=255&e),1===o&&(e=P[t.charCodeAt(n)]<<10|P[t.charCodeAt(n+1)]<<4|P[t.charCodeAt(n+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e),s}(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const tt=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function et(t){return"undefined"==typeof BigInt?nt:t}function nt(){throw new Error("BigInt not supported")}}(0,e.exports),e.exports}();function j(t,e){var n;if(1===e)n=U(new r.PublicKey(t).toBytes(),32);else{if(2!==e&&4!==e&&5!==e&&6!==e&&22!==e)throw new Error("Unsupported token chain");if(22===e&&/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(t))return"0x"+i.sha3_256(t);for(var o=t.substring(2),s=[],u=0;u<o.length;u+=2)s.push(parseInt(o.substring(u,u+2),16));n=U(new Uint8Array(s),32)}return"0x"+x.Buffer.from(n).toString("hex")}function G(t,e,n,i,o){if(void 0===n&&(n=!1),void 0===i&&(i=new r.PublicKey(f)),void 0===o&&(o=new r.PublicKey(l)),!n&&!r.PublicKey.isOnCurve(e.toBuffer()))throw new Error("TokenOwnerOffCurveError");return r.PublicKey.findProgramAddressSync([e.toBuffer(),i.toBuffer(),t.toBuffer()],o)[0]}function W(t,e){var r=Number(t).toFixed(Math.min(8,Number(e)));return n.ethers.utils.parseUnits(r,Number(e))}var K={solana:1,ethereum:2,bsc:4,polygon:5,avalanche:6,aptos:22};function $(t){return K[t]}var z=((L={})[1]=2,L[56]=4,L[137]=5,L[43114]=6,L),V=[{inputs:[{internalType:"address",name:"_tokenBridge",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"newGuardian",type:"address"}],name:"changeGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"claimGuardian",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint8",name:"payloadID",type:"uint8"},{internalType:"bytes32",name:"tokenAddr",type:"bytes32"},{internalType:"uint16",name:"tokenChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"},{internalType:"bytes32",name:"sourceAddr",type:"bytes32"},{internalType:"uint16",name:"sourceChainId",type:"uint16"},{internalType:"uint64",name:"sequence",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint64",name:"deadline",type:"uint64"},{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanStructs.Swap",name:"s",type:"tuple"}],name:"encodeSwap",outputs:[{internalType:"bytes",name:"encoded",type:"bytes"}],stateMutability:"pure",type:"function"},{inputs:[],name:"isPaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bool",name:"_pause",type:"bool"}],name:"setPause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"},{internalType:"address",name:"tokenIn",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"swap",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address payable",name:"to",type:"address"}],name:"sweepEth",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint64",name:"swapFee",type:"uint64"},{internalType:"uint64",name:"redeemFee",type:"uint64"},{internalType:"uint64",name:"refundFee",type:"uint64"}],internalType:"struct MayanSwap.RelayerFees",name:"relayerFees",type:"tuple"},{components:[{internalType:"bytes32",name:"mayanAddr",type:"bytes32"},{internalType:"uint16",name:"mayanChainId",type:"uint16"},{internalType:"bytes32",name:"destAddr",type:"bytes32"},{internalType:"uint16",name:"destChainId",type:"uint16"}],internalType:"struct MayanSwap.Recepient",name:"recepient",type:"tuple"},{internalType:"bytes32",name:"tokenOutAddr",type:"bytes32"},{internalType:"uint16",name:"tokenOutChainId",type:"uint16"},{components:[{internalType:"uint256",name:"transferDeadline",type:"uint256"},{internalType:"uint64",name:"swapDeadline",type:"uint64"},{internalType:"uint64",name:"amountOutMin",type:"uint64"},{internalType:"uint32",name:"nonce",type:"uint32"}],internalType:"struct MayanSwap.Criteria",name:"criteria",type:"tuple"}],name:"wrapAndSwapETH",outputs:[{internalType:"uint64",name:"sequence",type:"uint64"}],stateMutability:"payable",type:"function"}];function q(t,e,n,i,o,s){return void 0===o&&(o=new r.PublicKey(f)),void 0===s&&(s=new r.PublicKey(l)),new r.TransactionInstruction({keys:[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:r.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],programId:s,data:x.Buffer.alloc(0)})}var X=o.struct([o.u8("instruction")]),Y=o.struct([o.u8("instruction"),o.u8("mainNonce"),o.u8("stateNonce"),o.nu64("amount"),o.nu64("minAmountOut"),o.nu64("deadline"),o.nu64("feeSwap"),o.nu64("feeReturn"),o.nu64("feeCancel"),o.u16("destinationChain"),o.blob(32,"destinationAddress")]);t.fetchAllTokenList=function(){try{return Promise.resolve(u.default(c+"/tokens")).then(function(t){var e;function n(t){if(e)return t;throw new Error("Cannot fetch Mayan tokens!")}var r=function(){if(200===t.status)return Promise.resolve(t.json()).then(function(t){return e=1,t})}();return r&&r.then?r.then(n):n(r)})}catch(t){return Promise.reject(t)}},t.fetchQuote=function(t){try{var e=t.customRelayerFees;return Promise.resolve(u.default(c+"/quote?amountIn="+t.amount+"&fromToken="+t.fromToken+"&fromChain="+t.fromChain+"&toToken="+t.toToken+"&toChain="+t.toChain+"&slippage="+t.slippage/100+(e?"&swapRelayerFee="+e.swapRelayerFee+"&redeemRelayerFee="+e.redeemRelayerFee+"&refundRelayerFee="+e.refundRelayerFee:""))).then(function(t){return Promise.resolve(t.json()).then(function(e){if(200!==t.status)throw{code:(null==e?void 0:e.code)||0,message:(null==e?void 0:e.msg)||"Route not found"};return e})})}catch(t){return Promise.reject(t)}},t.fetchTokenList=function(t){try{return Promise.resolve(u.default(c+"/tokens?chain="+t)).then(function(e){var n;function r(t){if(n)return t;throw new Error("Cannot fetch Mayan tokens!")}var i=function(){if(200===e.status)return Promise.resolve(e.json()).then(function(e){return n=1,e[t]})}();return i&&i.then?i.then(r):r(i)})}catch(t){return Promise.reject(t)}},t.getCurrentSolanaTime=h,t.swapFromEvm=function(t,e,i,o,s,u){try{var f=new r.PublicKey(a);return Promise.resolve(r.PublicKey.findProgramAddress([Buffer.from("MAIN")],f)).then(function(a){var f=a[0],l=G(new r.PublicKey(t.fromToken.mint),f,!0),c=W(t.effectiveAmountIn,t.fromToken.decimals),y=j(l.toString(),1);return Promise.resolve(s.getChainId()).then(function(r){var a=z[r],f=$(t.fromChain),l=$(t.toChain);if(f!==a)throw new Error("Signer chain id and quote from chain are not same!");var g={mayanAddr:y,mayanChainId:1,destAddr:j(e,l),destChainId:l};return Promise.resolve(function(t){try{return Promise.resolve(t.getBlock("latest")).then(function(t){return t.timestamp})}catch(t){return Promise.reject(t)}}(o)).then(function(e){return Promise.resolve(h()).then(function(r){var o,a,f={transferDeadline:n.ethers.BigNumber.from(e+i),swapDeadline:n.ethers.BigNumber.from(r+i),amountOutMin:W(t.minAmountOut,Math.min(8,t.toToken.decimals)),nonce:(o=1e5*Math.random(),a=Buffer.alloc(4),a.writeUInt32LE(o,0),a).readUInt32LE(0)},l={swapFee:W(t.swapRelayerFee,Math.min(8,t.fromToken.decimals)),redeemFee:W(t.redeemRelayerFee,Math.min(8,t.toToken.decimals)),refundFee:W(t.refundRelayerFee,Math.min(8,t.fromToken.decimals))},h=j(t.toToken.realOriginContractAddress,t.toToken.realOriginChainId);return t.fromToken.contract===n.ethers.constants.AddressZero?function(t,e,r,i,o,s,u,a,f){try{var l=new n.ethers.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",V,a);return Promise.resolve(l.wrapAndSwapETH(e,r,i,o,s,f?p({value:u},f):{value:u}))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,c,s,u):function(t,e,r,i,o,s,u,a,f,l){try{var c=new n.ethers.Contract("0xD61cd61aE0b30b56bDC40830aaEd44B19cF5bD74",V,f);return Promise.resolve(l?c.swap(e,r,i,o,s,u,a,l):c.swap(e,r,i,o,s,u,a))}catch(t){return Promise.reject(t)}}(0,l,g,h,t.toToken.realOriginChainId,f,t.fromToken.contract,c,s,u)})})})})}catch(t){return Promise.reject(t)}},t.swapFromSolana=function(t,e,i,o,s,u){try{var l=null!=u?u:new r.Connection("https://rpc.ankr.com/solana"),c=new r.PublicKey(a),p=new r.PublicKey(f),y=new r.PublicKey(e),g=r.PublicKey.findProgramAddressSync([x.Buffer.from("MAIN")],c),d=g[0],m=g[1],b=r.Keypair.generate().publicKey,w=r.Keypair.generate().publicKey,E=r.PublicKey.findProgramAddressSync([x.Buffer.from("V2STATE"),x.Buffer.from(b.toBytes()),x.Buffer.from(w.toBytes())],c),T=E[0],I=E[1],A=new r.PublicKey(t.fromToken.mint),v=new r.PublicKey(t.toToken.mint),R=G(A,y),B=G(A,d,!0),N=new r.Transaction({feePayer:y});return Promise.resolve(l.getAccountInfo(R,"finalized")).then(function(e){return e&&0!==e.data.length||N.add(q(y,R,y,A)),Promise.resolve(l.getAccountInfo(B,"finalized")).then(function(e){var u,a;e&&0!==e.data.length||N.add(q(y,B,d,A)),t.fromToken.contract===n.ethers.constants.AddressZero&&(N.add(r.SystemProgram.transfer({fromPubkey:y,toPubkey:R,lamports:W(t.effectiveAmountIn,9).toBigInt()})),N.add((u=[{pubkey:R,isSigner:!1,isWritable:!0}],a=x.Buffer.alloc(X.span),X.encode({instruction:17},a),new r.TransactionInstruction({keys:u,programId:new r.PublicKey(f),data:a}))));var g=[{pubkey:y,isWritable:!1,isSigner:!0},{pubkey:d,isWritable:!1,isSigner:!1},{pubkey:b,isWritable:!1,isSigner:!1},{pubkey:w,isWritable:!1,isSigner:!1},{pubkey:T,isWritable:!0,isSigner:!1},{pubkey:R,isWritable:!0,isSigner:!1},{pubkey:B,isWritable:!0,isSigner:!1},{pubkey:A,isWritable:!1,isSigner:!1},{pubkey:v,isWritable:!1,isSigner:!1},{pubkey:r.SYSVAR_CLOCK_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:r.SYSVAR_RENT_PUBKEY,isWritable:!1,isSigner:!1},{pubkey:p,isWritable:!1,isSigner:!1},{pubkey:r.SystemProgram.programId,isWritable:!1,isSigner:!1}];return Promise.resolve(h()).then(function(e){function n(n){var a,f=x.Buffer.from((a=j(i,u),new Uint8Array(x.Buffer.from(a.substring(2),"hex")))),h=W(t.effectiveAmountIn,t.mintDecimals.from),p=W(t.minAmountOut,t.mintDecimals.to),y=W(t.swapRelayerFee,t.mintDecimals.from),d=W(t.redeemRelayerFee,t.mintDecimals.to),b=W(t.refundRelayerFee,t.mintDecimals.from),w=x.Buffer.alloc(Y.span);Y.encode({instruction:101,mainNonce:m,stateNonce:I,amount:h,minAmountOut:p,deadline:e+o,feeSwap:y,feeReturn:d,feeCancel:b,destinationChain:u,destinationAddress:f},w);var E=new r.TransactionInstruction({keys:g,data:w,programId:c});return N.add(E),Promise.resolve(l.getLatestBlockhash()).then(function(t){return N.recentBlockhash=t.blockhash,Promise.resolve(s(N)).then(function(t){return Promise.resolve(l.sendRawTransaction(t.serialize(),{skipPreflight:!0}))})})}var u=$(t.toChain),a=function(){if(1===u)return Promise.resolve(l.getAccountInfo(new r.PublicKey(i))).then(function(t){if(t.owner.equals(p))throw new Error("Destination address is not about token account. It should be a owner address")})}();return a&&a.then?a.then(n):n()})})})}catch(t){return Promise.reject(t)}}}); | ||
//# sourceMappingURL=main.umd.js.map |
{ | ||
"name": "@mayanfinance/swap-sdk", | ||
"description": "A SDK to swap with Mayan", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"source": "src/main.ts", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.umd.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package