UNPKG

@stellar/stellar-sdk

Version:

A library for working with the Stellar network, including communication with the Horizon and Soroban RPC servers.

2 lines 484 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).StellarSdk={})}(this,function(e){"use strict";async function t(e,t){const n={config:e};return n.status=t.status,n.statusText=t.statusText,n.headers=t.headers,"stream"===e.responseType?(n.data=t.body,n):t[e.responseType||"text"]().then(r=>{e.transformResponse?(Array.isArray(e.transformResponse)?e.transformResponse.map(n=>r=n.call(e,r,t?.headers,t?.status)):r=e.transformResponse(r,t?.headers,t?.status),n.data=r):(n.data=r,n.data=JSON.parse(r))}).catch(Object).then(()=>n)}function n(e){let t=e.url||"";return e.baseURL&&e.url&&(t=e.url.replace(/^(?!.*\/\/)\/?/,`${e.baseURL}/`)),e.params&&Object.keys(e.params).length>0&&e.url&&(t+=(~e.url.indexOf("?")?"&":"?")+(e.paramsSerializer?e.paramsSerializer(e.params):new URLSearchParams(e.params))),t}function r(e,t){const n={...t,...e};if(t?.params&&e?.params&&(n.params={...t?.params,...e?.params}),t?.headers&&e?.headers){n.headers=new Headers(t.headers||{});new Headers(e.headers||{}).forEach((e,t)=>{n.headers.set(t,e)})}return n}function o(e,t){const n=t.get("content-type");return n?"application/x-www-form-urlencoded"!==n||e instanceof URLSearchParams?"application/json"===n&&"object"==typeof e&&(e=JSON.stringify(e)):e=new URLSearchParams(e):"string"==typeof e?t.set("content-type","text/plain"):e instanceof URLSearchParams?t.set("content-type","application/x-www-form-urlencoded"):e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?t.set("content-type","application/octet-stream"):"object"==typeof e&&"function"!=typeof e.append&&"function"!=typeof e.text&&(e=JSON.stringify(e),t.set("content-type","application/json")),e}async function s(e,i,a,l,d,p){"string"==typeof e?(i=i||{}).url=e:i=e||{};const h=r(i,a||{});if(h.fetchOptions=h.fetchOptions||{},h.timeout=h.timeout||0,h.headers=new Headers(h.headers||{}),h.transformRequest=h.transformRequest??o,p=p||h.data,h.transformRequest&&p&&(Array.isArray(h.transformRequest)?h.transformRequest.map(e=>p=e.call(h,p,h.headers)):p=h.transformRequest(p,h.headers)),h.url=n(h),h.method=l||h.method||"get",d&&d.request.handlers.length>0){const e=d.request.handlers.filter(e=>!e?.runWhen||"function"==typeof e.runWhen&&e.runWhen(h)).flatMap(e=>[e.fulfilled,e.rejected]);let t=h;for(let n=0,r=e.length;n<r;n+=2){const r=e[n],o=e[n+1];try{r&&(t=r(t))}catch(e){o&&o?.(e);break}}}const f=function(e,t){const n={...t,...e};t?.headers&&e?.headers&&(n.headers=new Headers(t.headers||{}),new Headers(e.headers||{}).forEach((e,t)=>{n.headers.set(t,e)}));return n}({method:h.method?.toUpperCase(),body:p,headers:h.headers,credentials:h.withCredentials?"include":void 0,signal:h.signal},h.fetchOptions);let m=async function(e,n){let r=null;if("any"in AbortSignal){const t=[];e.timeout&&t.push(AbortSignal.timeout(e.timeout)),e.signal&&t.push(e.signal),t.length>0&&(n.signal=AbortSignal.any(t))}else e.timeout&&(n.signal=AbortSignal.timeout(e.timeout));try{return r=await fetch(e.url,n),(e.validateStatus?e.validateStatus(r.status):r.ok)?await t(e,r):Promise.reject(new c(`Request failed with status code ${r?.status}`,[c.ERR_BAD_REQUEST,c.ERR_BAD_RESPONSE][Math.floor(r?.status/100)-4],e,new Request(e.url,n),await t(e,r)))}catch(t){if("AbortError"===t.name||"TimeoutError"===t.name){const n="TimeoutError"===t.name;return Promise.reject(n?new c(e.timeoutErrorMessage||`timeout of ${e.timeout} ms exceeded`,c.ECONNABORTED,e,s):new u(null,e))}return Promise.reject(new c(t.message,void 0,e,s,void 0))}}(h,f);if(d&&d.response.handlers.length>0){const e=d.response.handlers.flatMap(e=>[e.fulfilled,e.rejected]);for(let t=0,n=e.length;t<n;t+=2)m=m.then(e[t],e[t+1])}return m}var i=class{handlers=[];constructor(){this.handlers=[]}use=(e,t,n)=>(this.handlers.push({fulfilled:e,rejected:t,runWhen:n?.runWhen}),this.handlers.length-1);eject=e=>{this.handlers[e]&&(this.handlers[e]=null)};clear=()=>{this.handlers=[]}};function a(e){e=e||{};const t={request:new i,response:new i},o=(n,r)=>s(n,r,e,void 0,t);return o.defaults=e,o.interceptors=t,o.getUri=t=>n(r(t||{},e)),o.request=n=>s(n,void 0,e,void 0,t),["get","delete","head","options"].forEach(n=>{o[n]=(r,o)=>s(r,o,e,n,t)}),["post","put","patch"].forEach(n=>{o[n]=(r,o,i)=>s(r,i,e,n,t,o)}),["postForm","putForm","patchForm"].forEach(n=>{o[n]=(r,o,i)=>((i=i||{}).headers=new Headers(i.headers||{}),i.headers.set("content-type","application/x-www-form-urlencoded"),s(r,i,e,n.replace("Form",""),t,o))}),o}var c=class extends Error{config;code;request;response;status;isAxiosError;constructor(e,t,n,r,o){super(e),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.name="AxiosError",this.code=t,this.config=n,this.request=r,this.response=o,this.isAxiosError=!0}static ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";static ERR_BAD_OPTION="ERR_BAD_OPTION";static ERR_NETWORK="ERR_NETWORK";static ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";static ERR_BAD_REQUEST="ERR_BAD_REQUEST";static ERR_INVALID_URL="ERR_INVALID_URL";static ERR_CANCELED="ERR_CANCELED";static ECONNABORTED="ECONNABORTED";static ETIMEDOUT="ETIMEDOUT"},u=class extends c{constructor(e,t,n){super(e||"canceled",c.ERR_CANCELED,t,n),this.name="CanceledError"}},l=a();l.create=e=>a(e);var d=l;class p{promise;reason;throwIfRequested(){if(this.reason)throw new Error(this.reason)}constructor(e){let t;this.promise=new Promise(e=>{t=e}),e(e=>{this.reason=e,t()})}}const h=Symbol.for("@stellar/stellar-sdk.canceled");class f{handlers=[];use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}forEach(e){this.handlers.forEach(t=>{null!==t&&e(t)})}}function m(e){const t=e||{};return t.headers=new Headers(t.headers||{}),t.headers.set("Content-Type","application/x-www-form-urlencoded"),t}function g(e,t){if(!t)return{...e};const n={...e,...t};if(void 0!==e?.headers||void 0!==t.headers){const r=new Headers(e?.headers||{});new Headers(t.headers||{}).forEach((e,t)=>{r.set(t,e)}),n.headers=r}return void 0===e?.params&&void 0===t.params||(n.params={...e?.params||{},...t.params||{}}),n}async function y(e,t){if(void 0!==t){const n=e.headers.get("content-length");if(n&&Number(n)>t)throw new Error(`maxContentLength size of ${t} exceeded`)}if(!e.body)return new Uint8Array(0);const n=e.body.getReader(),r=[];let o=0;for(;;){const{done:e,value:s}=await n.read();if(e)break;if(s){if(o+=s.byteLength,void 0!==t&&o>t)throw await n.cancel(),new Error(`maxContentLength size of ${t} exceeded`);r.push(s)}}const s=new Uint8Array(o);let i=0;for(const e of r)s.set(e,i),i+=e.byteLength;return s}function w(e,t){if(307===t||308===t)return e;const n={...e,method:"GET",body:void 0},r=new Headers(e.headers||{});return r.delete("content-type"),r.delete("content-length"),r.delete("transfer-encoding"),n.headers=r,n}function S(e,t,n){let r;try{r=new URL(t).origin===new URL(n).origin}catch{r=!1}if(r)return e;const o=new Headers(e.headers||{});return o.delete("authorization"),o.delete("proxy-authorization"),o.delete("cookie"),{...e,headers:o}}function A(e,t,n){const r=new Error(`Request failed with status code ${e.status}`);return r.response={status:e.status,statusText:e.statusText,headers:e.headers,data:n,config:t},r}async function v(e){const{maxRedirects:t,maxContentLength:n,timeout:r}=e,o=[];r&&r>0&&o.push(function(e){if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout)return AbortSignal.timeout(e);const t=new AbortController;return setTimeout(()=>{const e=new Error("Timeout");e.name="TimeoutError",t.abort(e)},e),t.signal}(r));const s=function(e){if(0===e.length)return;if(1===e.length)return e[0];if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.any)return AbortSignal.any(e);const t=new AbortController;for(const n of e){if(n.aborted){t.abort(n.reason);break}n.addEventListener("abort",()=>t.abort(n.reason),{once:!0})}return t.signal}(o),i=void 0!==t,a="undefined"!=typeof process&&!!process.versions&&!!process.versions.node;let c;c=i?a?"manual":0===t?"error":"follow":"follow";const u=new Headers(e.headers||{}),l=function(e,t){if(null!=e)return"string"==typeof e?e:e instanceof URLSearchParams?(t.has("content-type")||t.set("content-type","application/x-www-form-urlencoded"),e):e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?(t.has("content-type")||t.set("content-type","application/octet-stream"),e):"undefined"!=typeof FormData&&e instanceof FormData?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e))}(e.data,u);let d,p={...e.fetchOptions,method:(e.method||"get").toUpperCase(),headers:u,body:l,redirect:c,...s?{signal:s}:{}},h=function(e){let t=e.url||"";if(e.baseURL&&t&&!/^https?:\/\//i.test(t)&&(t=t.replace(/^\/?/,`${e.baseURL.replace(/\/$/,"")}/`)),e.params&&Object.keys(e.params).length>0){const n=new URLSearchParams(e.params).toString();t+=(t.includes("?")?"&":"?")+n}return t}(e),f=t??0;for(;;){try{d=await fetch(h,p)}catch(t){if("TimeoutError"===t?.name)throw new Error(`timeout of ${e.timeout}ms exceeded`);throw t}if(!("manual"===c&&d.status>=300&&d.status<400))break;if(f<=0){if(0===t)throw A(d,e);throw new Error("Maximum number of redirects exceeded")}const n=d.headers.get("location");if(!n)break;const r=new URL(n,h).toString();p=w(p,d.status),p=S(p,h,r),h=r,f-=1}if(!d.ok){let t;try{const e=await y(d,n),r=(new TextDecoder).decode(e);try{t=JSON.parse(r)}catch{t=r}}catch(e){throw e}throw A(d,e,t)}const m=await y(d,n),g=(new TextDecoder).decode(m);let v=g;try{v=JSON.parse(g)}catch{}return{data:v,headers:d.headers,config:e,status:d.status,statusText:d.statusText}}function b(e={}){const t={...e,headers:e.headers||{}},n=(d.default??d).create(t),r=new f,o=new f,s={interceptors:{request:r,response:o},defaults:{...t,adapter:e=>void 0!==e.maxRedirects||void 0!==e.maxContentLength?v(e):n.request(e)},create(e){return b({...this.defaults,...e})},makeRequest(e){return new Promise((t,n)=>{function s(e,t,n){const r=e.adapter||this.defaults.adapter;if(!r)throw new Error("No adapter available");let s=r(e).then(e=>({data:e.data,headers:e.headers,config:e.config,status:e.status,statusText:e.statusText}));if(o.handlers.length>0){const e=o.handlers.filter(e=>null!==e).flatMap(e=>[e.fulfilled,e.rejected]);for(let t=0,n=e.length;t<n;t+=2)s=s.then(n=>{const r=e[t];return"function"==typeof r?r(n):n},n=>{const r=e[t+1];if("function"==typeof r)return r(n);throw n}).then(e=>e)}s.then(t).catch(n)}const i=new AbortController;if(e.signal=i.signal,e.cancelToken){const{cancelToken:t}=e;t.promise.then(()=>{i.abort(),n(function(e){const t=new Error(e||"Request canceled");return t[h]=!0,t}(t.reason))})}const a=e;if(r.handlers.length>0){const e=r.handlers.filter(e=>null!==e).flatMap(e=>[e.fulfilled,e.rejected]);let o=Promise.resolve(a);for(let t=0,n=e.length;t<n;t+=2)o=o.then(e[t],e[t+1]);return void o.then(e=>{s.call(this,e,t,n)}).catch(n)}s.call(this,a,t,n)})},get(e,t){return this.makeRequest({...g(this.defaults,t),url:e,method:"get"})},delete(e,t){return this.makeRequest({...g(this.defaults,t),url:e,method:"delete"})},head(e,t){return this.makeRequest({...g(this.defaults,t),url:e,method:"head"})},options(e,t){return this.makeRequest({...g(this.defaults,t),url:e,method:"options"})},post(e,t,n){return this.makeRequest({...g(this.defaults,n),url:e,method:"post",data:t})},put(e,t,n){return this.makeRequest({...g(this.defaults,n),url:e,method:"put",data:t})},patch(e,t,n){return this.makeRequest({...g(this.defaults,n),url:e,method:"patch",data:t})},postForm(e,t,n){const r=m(n);return this.makeRequest({...g(this.defaults,r),url:e,method:"post",data:t})},putForm(e,t,n){const r=m(n);return this.makeRequest({...g(this.defaults,r),url:e,method:"put",data:t})},patchForm(e,t,n){const r=m(n);return this.makeRequest({...g(this.defaults,r),url:e,method:"patch",data:t})},CancelToken:p,isCancel:e=>e instanceof Error&&!0===e[h]};return s}const T=b();class E extends Error{response;constructor(e,t){super(e),this.response=t}getResponse(){return this.response}}class k extends E{}class I extends E{}class C extends E{}function B(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x,R={exports:{}}; /*! For license information please see xdr.js.LICENSE.txt */var _=(x||(x=1,function(e){var t;t=()=>(()=>{var e={348(e,t,n){const r=n(928);e.exports=r},350(e,t){t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,s=a(e),i=s[0],c=s[1],u=new o(function(e,t,n){return 3*(t+n)/4-n}(0,i,c)),l=0,d=c>0?i-4:i;for(n=0;n<d;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===c&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[l++]=255&t),1===c&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,s=[],i=16383,a=0,c=r-o;a<c;a+=i)s.push(u(e,a,a+i>c?c:a+i));return 1===o?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),s.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)n[i]=s[i],r[s.charCodeAt(i)]=i;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function u(e,t,n){for(var r,o=[],s=t;s<n;s+=3)r=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),o.push(c(r));return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},686(e,t,n){const r=n(350),o=n(947),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const i=2147483647;function a(e){if(e>i)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return u(e,t,n)}function u(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|m(e,t);let r=a(n);const o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(z(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(z(e,ArrayBuffer)||e&&z(e.buffer,ArrayBuffer))return h(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(z(e,SharedArrayBuffer)||e&&z(e.buffer,SharedArrayBuffer)))return h(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return c.from(r,t,n);const o=function(e){if(c.isBuffer(e)){const t=0|f(e.length),n=a(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?a(0):p(e):"Buffer"===e.type&&Array.isArray(e.data)?p(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return l(e),a(e<0?0:0|f(e))}function p(e){const t=e.length<0?0:0|f(e.length),n=a(t);for(let r=0;r<t;r+=1)n[r]=255&e[r];return n}function h(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,c.prototype),r}function f(e){if(e>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||z(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return X(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(e).length;default:if(o)return r?-1:X(e).length;t=(""+t).toLowerCase(),o=!0}}function g(e,t,n){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return B(this,t,n);case"latin1":case"binary":return x(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function w(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:S(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):S(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function S(e,t,n,r,o){let s,i=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;i=2,a/=2,c/=2,n/=2}function u(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){let r=-1;for(s=n;s<a;s++)if(u(e,s)===u(t,-1===r?0:s-r)){if(-1===r&&(r=s),s-r+1===c)return r*i}else-1!==r&&(s-=s-r),r=-1}else for(n+c>a&&(n=a-c),s=n;s>=0;s--){let n=!0;for(let r=0;r<c;r++)if(u(e,s+r)!==u(t,r)){n=!1;break}if(n)return s}return-1}function A(e,t,n,r){n=Number(n)||0;const o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;const s=t.length;let i;for(r>s/2&&(r=s/2),i=0;i<r;++i){const r=parseInt(t.substr(2*i,2),16);if(j(r))return i;e[n+i]=r}return i}function v(e,t,n,r){return Z(X(t,e.length-n),e,n,r)}function b(e,t,n,r){return Z(function(e){const t=[];for(let n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function T(e,t,n,r){return Z(W(t),e,n,r)}function E(e,t,n,r){return Z(function(e,t){let n,r,o;const s=[];for(let i=0;i<e.length&&!((t-=2)<0);++i)n=e.charCodeAt(i),r=n>>8,o=n%256,s.push(o),s.push(r);return s}(t,e.length-n),e,n,r)}function k(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);const r=[];let o=t;for(;o<n;){const t=e[o];let s=null,i=t>239?4:t>223?3:t>191?2:1;if(o+i<=n){let n,r,a,c;switch(i){case 1:t<128&&(s=t);break;case 2:n=e[o+1],128==(192&n)&&(c=(31&t)<<6|63&n,c>127&&(s=c));break;case 3:n=e[o+1],r=e[o+2],128==(192&n)&&128==(192&r)&&(c=(15&t)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:n=e[o+1],r=e[o+2],a=e[o+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&t)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,i=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),o+=i}return function(e){const t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=C));return n}(r)}c.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,n){return u(e,t,n)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,n){return function(e,t,n){return l(e),e<=0?a(e):void 0!==t?"string"==typeof n?a(e).fill(t,n):a(e).fill(t):a(e)}(e,t,n)},c.allocUnsafe=function(e){return d(e)},c.allocUnsafeSlow=function(e){return d(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(z(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),z(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,r=t.length;for(let o=0,s=Math.min(n,r);o<s;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);let n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const r=c.allocUnsafe(t);let o=0;for(n=0;n<e.length;++n){let t=e[n];if(z(t,Uint8Array))o+t.length>r.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(r,o)):Uint8Array.prototype.set.call(r,t,o);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,o)}o+=t.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):g.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){let e="";const n=t.IS;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,n,r,o){if(z(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;let s=(o>>>=0)-(r>>>=0),i=(n>>>=0)-(t>>>=0);const a=Math.min(s,i),u=this.slice(r,o),l=e.slice(t,n);for(let e=0;e<a;++e)if(u[e]!==l[e]){s=u[e],i=l[e];break}return s<i?-1:i<s?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return w(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return w(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let s=!1;for(;;)switch(r){case"hex":return A(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":case"latin1":case"binary":return b(this,e,t,n);case"base64":return T(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const C=4096;function B(e,t,n){let r="";n=Math.min(e.length,n);for(let o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function x(e,t,n){let r="";n=Math.min(e.length,n);for(let o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function R(e,t,n){const r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let o="";for(let r=t;r<n;++r)o+=Y[e[r]];return o}function _(e,t,n){const r=e.slice(t,n);let o="";for(let e=0;e<r.length-1;e+=2)o+=String.fromCharCode(r[e]+256*r[e+1]);return o}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,n,r,o,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function U(e,t,n,r,o){$(t,r,o,e,n,7);let s=Number(t&BigInt(4294967295));e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s,s>>=8,e[n++]=s;let i=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=i,i>>=8,e[n++]=i,i>>=8,e[n++]=i,i>>=8,e[n++]=i,n}function L(e,t,n,r,o){$(t,r,o,e,n,7);let s=Number(t&BigInt(4294967295));e[n+7]=s,s>>=8,e[n+6]=s,s>>=8,e[n+5]=s,s>>=8,e[n+4]=s;let i=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=i,i>>=8,e[n+2]=i,i>>=8,e[n+1]=i,i>>=8,e[n]=i,n+8}function N(e,t,n,r,o,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function V(e,t,n,r,s){return t=+t,n>>>=0,s||N(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,s){return t=+t,n>>>=0,s||N(e,0,n,8),o.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);const r=this.subarray(e,t);return Object.setPrototypeOf(r,c.prototype),r},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],o=1,s=0;for(;++s<t&&(o*=256);)r+=this[e+s]*o;return r},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e+--t],o=1;for(;t>0&&(o*=256);)r+=this[e+--t]*o;return r},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=J(function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))}),c.prototype.readBigUInt64BE=J(function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(r)<<BigInt(32))+BigInt(o)}),c.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],o=1,s=0;for(;++s<t&&(o*=256);)r+=this[e+s]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=t,o=1,s=this[e+--r];for(;r>0&&(o*=256);)s+=this[e+--r]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=J(function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),c.prototype.readBigInt64BE=J(function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||G(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+n)}),c.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||O(this,e,t,n,Math.pow(2,8*n)-1,0);let o=1,s=0;for(this[t]=255&e;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||O(this,e,t,n,Math.pow(2,8*n)-1,0);let o=n-1,s=1;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=J(function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=J(function(e,t=0){return L(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}let o=0,s=1,i=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===i&&0!==this[t+o-1]&&(i=1),this[t+o]=(e/s|0)-i&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}let o=n-1,s=1,i=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===i&&0!==this[t+o+1]&&(i=1),this[t+o]=(e/s|0)-i&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=J(function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=J(function(e,t=0){return L(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeFloatLE=function(e,t,n){return V(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return V(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<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),e.length-t<r-n&&(r=e.length-t+n);const o=r-n;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=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&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){const t=e.charCodeAt(0);("utf8"===r&&t<128||"latin1"===r)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;let o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{const s=c.isBuffer(e)?e:c.from(e,r),i=s.length;if(0===i)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%i]}return this};const D={};function M(e,t,n){D[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function q(e){let t="",n=e.length;const r="-"===e[0]?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function $(e,t,n,r,o,s){if(e>n||e<t){const n="bigint"==typeof t?"n":"";let r;throw r=0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`,new D.ERR_OUT_OF_RANGE("value",r,e)}!function(e,t,n){H(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||G(t,e.length-(n+1))}(r,o,s)}function H(e,t){if("number"!=typeof e)throw new D.ERR_INVALID_ARG_TYPE(t,"number",e)}function G(e,t,n){if(Math.floor(e)!==e)throw H(e,n),new D.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}M("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),M("ERR_OUT_OF_RANGE",function(e,t,n){let r=`The value of "${e}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=q(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=q(o)),o+="n"),r+=` It must be ${t}. Received ${o}`,r},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function X(e,t){let n;t=t||1/0;const r=e.length;let o=null;const s=[];for(let i=0;i<r;++i){if(n=e.charCodeAt(i),n>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(i+1===r){(t-=3)>-1&&s.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function W(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Z(e,t,n,r){let o;for(o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function z(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function j(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let o=0;o<16;++o)t[r+o]=e[n]+e[o]}return t}();function J(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},928(e,t,n){n.r(t),n.d(t,{Array:()=>$,Bool:()=>L,Double:()=>O,Enum:()=>X,Float:()=>P,Hyper:()=>B,Int:()=>T,LargeInt:()=>C,Opaque:()=>D,Option:()=>G,Quadruple:()=>U,Reference:()=>W,String:()=>V,Struct:()=>Z,Union:()=>j,UnsignedHyper:()=>_,UnsignedInt:()=>R,VarArray:()=>H,VarOpaque:()=>q,Void:()=>K,XdrReader:()=>c,XdrWriter:()=>d,config:()=>se});class r extends TypeError{constructor(e){super(`XDR Write Error: ${e}`)}}class o extends TypeError{constructor(e){super(`XDR Read Error: ${e}`)}}class s extends TypeError{constructor(e){super(`XDR Type Definition Error: ${e}`)}}class i extends s{constructor(){super("method not implemented, it should be overloaded in the descendant class.")}}var a=n(686).hp;class c{constructor(e){if(!a.isBuffer(e)){if(!(e instanceof Array||Array.isArray(e)||ArrayBuffer.isView(e)))throw new o(`source invalid: ${e}`);e=a.from(e)}this._buffer=e,this._length=e.length,this._index=0}_buffer;_length;_index;get eof(){return this._index===this._length}advance(e){const t=this._index;if(this._index+=e,this._length<this._index)throw new o("attempt to read outside the boundary of the buffer");const n=4-(e%4||4);if(n>0){for(let e=0;e<n;e++)if(0!==this._buffer[this._index+e])throw new o("invalid padding");this._index+=n}return t}rewind(){this._index=0}remainingBytes(){return this._length-this._index}read(e){const t=this.advance(e);return this._buffer.subarray(t,t+e)}readInt32BE(){return this._buffer.readInt32BE(this.advance(4))}readUInt32BE(){return this._buffer.readUInt32BE(this.advance(4))}readBigInt64BE(){return this._buffer.readBigInt64BE(this.advance(8))}readBigUInt64BE(){return this._buffer.readBigUInt64BE(this.advance(8))}readFloatBE(){return this._buffer.readFloatBE(this.advance(4))}readDoubleBE(){return this._buffer.readDoubleBE(this.advance(8))}ensureInputConsumed(){if(this._index!==this._length)throw new o("invalid XDR contract typecast - source buffer not entirely consumed")}}var u=n(686).hp;const l=8192;class d{constructor(e){"number"==typeof e?e=u.allocUnsafe(e):e instanceof u||(e=u.allocUnsafe(l)),this._buffer=e,this._length=e.length}_buffer;_length;_index=0;alloc(e){const t=this._index;return this._index+=e,this._length<this._index&&this.resize(this._index),t}resize(e){const t=Math.ceil(e/l)*l,n=u.allocUnsafe(t);this._buffer.copy(n,0,0,this._length),this._buffer=n,this._length=t}finalize(){return this._buffer.subarray(0,this._index)}toArray(){return[...this.finalize()]}write(e,t){if("string"==typeof e){const n=this.alloc(t);this._buffer.write(e,n,"utf8")}else{e instanceof u||(e=u.from(e));const n=this.alloc(t);e.copy(this._buffer,n,0,t)}const n=4-(t%4||4);if(n>0){const e=this.alloc(n);this._buffer.fill(0,e,this._index)}}writeInt32BE(e){const t=this.alloc(4);this._buffer.writeInt32BE(e,t)}writeUInt32BE(e){const t=this.alloc(4);this._buffer.writeUInt32BE(e,t)}writeBigInt64BE(e){const t=this.alloc(8);this._buffer.writeBigInt64BE(e,t)}writeBigUInt64BE(e){const t=this.alloc(8);this._buffer.writeBigUInt64BE(e,t)}writeFloatBE(e){const t=this.alloc(4);this._buffer.writeFloatBE(e,t)}writeDoubleBE(e){const t=this.alloc(8);this._buffer.writeDoubleBE(e,t)}static bufferChunkSize=l}var p=n(686).hp;class h{toXDR(e="raw"){if(!this.write)return this.constructor.toXDR(this,e);const t=new d;return this.write(this,t),w(t.finalize(),e)}fromXDR(e,t="raw"){if(!this.read)return this.constructor.fromXDR(e,t);const n=new c(S(e,t)),r=this.read(n);return n.ensureInputConsumed(),r}validateXDR(e,t="raw"){try{return this.fromXDR(e,t),!0}catch(e){return!1}}static toXDR(e,t="raw"){const n=new d;return this.write(e,n),w(n.finalize(),t)}static fromXDR(e,t="raw"){const n=new c(S(e,t)),r=this.read(n);return n.ensureInputConsumed(),r}static validateXDR(e,t="raw"){try{return this.fromXDR(e,t),!0}catch(e){return!1}}}class f extends h{static read(e){throw new i}static write(e,t){throw new i}static isValid(e){return!1}}class m extends h{isValid(e){return!1}}class g extends m{constructor(e){super(),this._maxDepth=e??g.DEFAULT_MAX_DEPTH}static checkDepth(e){if(void 0!==e){if(!Number.isFinite(e))throw new TypeError(`remainingDepth (current remaining decoding depth budget) must be a finite number, got ${typeof e}: ${e}`);if(e<0)throw new o("exceeded max decoding depth")}}}g.DEFAULT_MAX_DEPTH=200,g._maxDepth=g.DEFAULT_MAX_DEPTH;class y extends TypeError{constructor(e){super(`Invalid format ${e}, must be one of "raw", "hex", "base64"`)}}function w(e,t){switch(t){case"raw":return e;case"hex":return e.toString("hex");case"base64":return e.toString("base64");default:throw new y(t)}}function S(e,t){switch(t){case"raw":return e;case"hex":return p.from(e,"hex");case"base64":return p.from(e,"base64");default:throw new y(t)}}function A(e,t){return null!=e&&(e instanceof t||v(e,t)&&"function"==typeof e.constructor.read&&"function"==typeof e.constructor.write&&v(e,"XdrType"))}function v(e,t){do{if(e.constructor.name===t)return!0}while(e=Object.getPrototypeOf(e));return!1}const b=2147483647;class T extends f{static read(e){return e.readInt32BE()}static write(e,t){if("number"!=typeof e)throw new r("not a number");if((0|e)!==e)throw new r("invalid i32 value");t.writeInt32BE(e)}static isValid(e){return"number"==typeof e&&(0|e)===e&&e>=-2147483648&&e<=b}}function E(e,t){return`${t?"u":"i"}${e}`}function k(e,t){if(t)return[0n,(1n<<BigInt(e))-1n];const n=1n<<BigInt(e-1);return[0n-n,n-1n]}function I(e,t){const n=BigInt.asIntN(t,e)===e,r=BigInt.asUintN(t,e)===e;if(!n&&!r)throw new RangeError(`slice value ${e} does not fit in ${t} bits`)}T.MAX_VALUE=b,T.MIN_VALUE=2147483648;class C extends f{constructor(e){super(),this._value=function(e,t,n){e instanceof Array?e.length&&e[0]instanceof Array&&(e=e[0]):e=[e];const r=t/e.length;switch(r){case 32:case 64:case 128:case 256:break;default:throw new RangeError(`expected slices to fit in 32/64/128/256 bits, got ${e}`)}try{for(let t=0;t<e.length;t++)"bigint"!=typeof e[t]&&(e[t]=BigInt(e[t].valueOf()))}catch(t){throw new TypeError(`expected bigint-like values, got: ${e} (${t})`)}if(1===e.length){const r=e[0];if(n&&r<0n)throw new RangeError(`expected a positive value, got: ${e}`);const[o,s]=k(t,n);if(r<o||r>s)throw new RangeError(`bigint value ${r} for ${E(t,n)} out of range [${o}, ${s}]`);return r}let o=0n;for(let t=0;t<e.length;t++)I(e[t],r),o|=BigInt.asUintN(r,e[t])<<BigInt(t*r);n||(o=BigInt.asIntN(t,o));const[s,i]=k(t,n);if(o>=s&&o<=i)return o;throw new RangeError(`bigint values [${e}] for ${E(t,n)} out of range [${s}, ${i}]: ${o}`)}(e,this.size,this.unsigned)}get unsigned(){throw new i}get size(){throw new i}slice(e){return function(e,t,n){if("bigint"!=typeof e)throw new TypeError("Expected bigint 'value', got "+typeof e);const r=t/n;if(1===r)return[e];if(n<32||n>128||2!==r&&4!==r&&8!==r)throw new TypeError(`invalid bigint (${e}) and slice size (${t} -> ${n}) combination`);const o=BigInt(n),s=new Array(r);for(let t=0;t<r;t++)s[t]=BigInt.asIntN(n,e),e>>=o;return s}(this._value,this.size,e)}toString(){return this._value.toString()}toJSON(){return{_value:this._value.toString()}}toBigInt(){return BigInt(this._value)}static read(e){const{size:t,unsigned:n}=this.prototype;return 64===t?new this(n?e.readBigUInt64BE():e.readBigInt64BE()):new this(...Array.from({length:t/64},()=>e.readBigUInt64BE()).reverse())}static write(e,t){if(e instanceof this)e=e._value;else if("bigint"!=typeof e||e>this.MAX_VALUE||e<this.MIN_VALUE)throw new r(`${e} is not a ${this.name}`);const{unsigned:n,size:o}=this.prototype;if(64===o)n?t.writeBigUInt64BE(e):t.writeBigInt64BE(e);else{const r=n?e:BigInt.asUintN(o,e);for(let e=o/64-1;e>=0;e--)t.writeBigUInt64BE(r>>BigInt(64*e)&0xffffffffffffffffn)}}static isValid(e){return e instanceof this||"bigint"==typeof e&&e>=this.MIN_VALUE&&e<=this.MAX_VALUE}static fromString(e){return new this(e)}static MAX_VALUE=0n;static MIN_VALUE=0n;static defineIntBoundaries(){const[e,t]=k(this.prototype.size,this.prototype.unsigned);this.MIN_VALUE=e,this.MAX_VALUE=t}}class B extends C{constructor(...e){super(e)}get low(){return 0|Number(0xffffffffn&this._value)}get high(){return 0|Number(this._value>>32n)}get size(){return 64}get unsigned(){return!1}static fromBits(e,t){return new this(e,t)}}B.defineIntBoundaries();const x=4294967295;class R extends f{static read(e){return e.readUInt32BE()}static write(e,t){if("number"!=typeof e||!(e>=0&&e<=x)||e%1!=0)throw new r("invalid u32 value");t.writeUInt32BE(e)}static isValid(e){return"number"==typeof e&&e%1==0&&e>=0&&e<=x}}R.MAX_VALUE=x,R.MIN_VALUE=0;class _ extends C{constructor(...e){super(e)}get low(){return 0|Number(0xffffffffn&this._value)}get high(){return 0|Number(this._value>>32n)}get size(){return 64}get unsigned(){return!0}static fromBits(e,t){return new this(e,t)}}_.defineIntBoundaries();class P extends f{static read(e){return e.readFloatBE()}static write(e,t){if("number"!=typeof e)throw new r("not a number");t.writeFloatBE(e)}static isValid(e){return"number"==typeof e}}class O extends f{static read(e){return e.readDoubleBE()}static write(e,t){if("number"!=typeof e)throw new r("not a number");t.writeDoubleBE(e)}static isValid(e){return"number"==typeof e}}class U extends f{static read(){throw new s("quadruple not supported")}static write(){throw new s("quadruple not supported")}static isValid(){return!1}}class L extends f{static read(e){const t=T.read(e);switch(t){case 0:return!1;case 1:return!0;default:throw new o(`got ${t} when trying to read a bool`)}}static write(e,t){const n=e?1:0;T.write(n,t)}static isValid(e){return"boolean"==typeof e}}var N=n(686).hp;class V extends m{constructor(e=R.MAX_VALUE){super(),this._maxLength=e}read(e){const t=R.read(e);if(t>this._maxLength)throw new o(`saw ${t} length String, max allowed is ${this._maxLength}`);return e.read(t)}readString(e){return this.read(e).toString("utf8")}write(e,t){const n="string"==typeof e?N.byteLength(e,"utf8"):e.length;if(n>this._maxLength)throw new r(`got ${e.length} bytes, max allowed is ${this._maxLength}`);R.write(n,t),t.write(e,n)}isValid(e){return"string"==typeof e?N.byteLength(e,"utf8")<=this._maxLength:!!(e instanceof Array||N.isBuffer(e))&&e.length<=this._maxLength}}var F=n(686).hp;class D extends m{constructor(e){super(),this._length=e}read(e){return e.read(this._length)}write(e,t){const{length:n}=e;if(n!==this._length)throw new r(`got ${e.length} bytes, expected ${this._length}`);t.write(e,n)}isValid(e){return F.isBuffer(e)&&e.length===this._length}}var M=n(686).hp;class q extends m{constructor(e=R.MAX_VALUE){super(),this._maxLength=e}read(e){const t=R.read(e);if(t>this._maxLength)throw new o(`saw ${t} length VarOpaque, max allowed is ${this._maxLength}`);return e.read(t)}write(e,t){const{length:n}=e;if(e.length>this._maxLength)throw new r(`got ${e.length} bytes, max allowed is ${this._maxLength}`);R.write(n,t),t.write(e,n)}isValid(e){return M.isBuffer(e)&&e.length<=this._maxLength}}class $ extends g{constructor(e,t,n=g.DEFAULT_MAX_DEPTH){super(n),this._childType=e,this._length=t}read(e,t=this._maxDepth){if(this._length>e.remainingBytes())throw new o(`Array length ${this._length} exceeds remaining ${e.remainingBytes()} bytes`);g.checkDepth(t);const n=[];for(let r=0;r<this._length;r++)n.push(this._childType.read(e,t-1));return n}write(e,t){if(!n.g.Array.isArray(e))throw new r("value is not array");if(e.length!==this._length)throw new r(`got array of size ${e.length}, expected ${this