@stellar/stellar-sdk 16.0.1 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/stellar-sdk-axios.js +5608 -4598
- package/dist/stellar-sdk-axios.js.map +1 -1
- package/dist/stellar-sdk-axios.min.js +12 -11
- package/dist/stellar-sdk-axios.min.js.map +1 -1
- package/dist/stellar-sdk.js +3902 -3434
- package/dist/stellar-sdk.js.map +1 -1
- package/dist/stellar-sdk.min.js +17 -17
- package/dist/stellar-sdk.min.js.map +1 -1
- package/lib/axios/cjs/base/auth.js +107 -0
- package/lib/axios/cjs/base/auth.js.map +1 -1
- package/lib/axios/cjs/base/keypair.js +39 -0
- package/lib/axios/cjs/base/keypair.js.map +1 -1
- package/lib/axios/cjs/base/scval.js +34 -0
- package/lib/axios/cjs/base/scval.js.map +1 -1
- package/lib/axios/cjs/bindings/config.js +1 -1
- package/lib/axios/cjs/cli/index.js +1 -1
- package/lib/axios/cjs/cli/index.js.map +1 -1
- package/lib/axios/cjs/contract/assembled_transaction.js +8 -7
- package/lib/axios/cjs/contract/assembled_transaction.js.map +1 -1
- package/lib/axios/cjs/contract/client.js +56 -3
- package/lib/axios/cjs/contract/client.js.map +1 -1
- package/lib/axios/cjs/contract/spec.js +7 -3
- package/lib/axios/cjs/contract/spec.js.map +1 -1
- package/lib/axios/cjs/errors/transaction_failed.js +62 -0
- package/lib/axios/cjs/errors/transaction_failed.js.map +1 -0
- package/lib/axios/cjs/errors/wrap_http_error.js +20 -0
- package/lib/axios/cjs/errors/wrap_http_error.js.map +1 -0
- package/lib/axios/cjs/federation/server.js +14 -15
- package/lib/axios/cjs/federation/server.js.map +1 -1
- package/lib/axios/cjs/horizon/call_builder.js +20 -0
- package/lib/axios/cjs/horizon/call_builder.js.map +1 -1
- package/lib/axios/cjs/horizon/horizon_api.js +5 -0
- package/lib/axios/cjs/horizon/horizon_api.js.map +1 -1
- package/lib/axios/cjs/horizon/horizon_axios_client.js +1 -1
- package/lib/axios/cjs/horizon/server.js +20 -26
- package/lib/axios/cjs/horizon/server.js.map +1 -1
- package/lib/axios/cjs/horizon/trade_aggregation_call_builder.js +20 -0
- package/lib/axios/cjs/horizon/trade_aggregation_call_builder.js.map +1 -1
- package/lib/axios/cjs/index.js +4 -0
- package/lib/axios/cjs/index.js.map +1 -1
- package/lib/axios/cjs/rpc/api.js.map +1 -1
- package/lib/axios/cjs/rpc/axios.js +1 -1
- package/lib/axios/cjs/rpc/server.js +163 -8
- package/lib/axios/cjs/rpc/server.js.map +1 -1
- package/lib/axios/esm/base/auth.d.ts +141 -0
- package/lib/axios/esm/base/auth.js +106 -1
- package/lib/axios/esm/base/auth.js.map +1 -1
- package/lib/axios/esm/base/index.d.ts +2 -2
- package/lib/axios/esm/base/keypair.d.ts +27 -0
- package/lib/axios/esm/base/keypair.js +39 -0
- package/lib/axios/esm/base/keypair.js.map +1 -1
- package/lib/axios/esm/base/scval.d.ts +4 -0
- package/lib/axios/esm/base/scval.js +34 -0
- package/lib/axios/esm/base/scval.js.map +1 -1
- package/lib/axios/esm/bindings/config.js +1 -1
- package/lib/axios/esm/cli/index.js +1 -1
- package/lib/axios/esm/cli/index.js.map +1 -1
- package/lib/axios/esm/contract/assembled_transaction.d.ts +1 -1
- package/lib/axios/esm/contract/assembled_transaction.js +9 -8
- package/lib/axios/esm/contract/assembled_transaction.js.map +1 -1
- package/lib/axios/esm/contract/client.d.ts +49 -3
- package/lib/axios/esm/contract/client.js +56 -3
- package/lib/axios/esm/contract/client.js.map +1 -1
- package/lib/axios/esm/contract/spec.js +7 -3
- package/lib/axios/esm/contract/spec.js.map +1 -1
- package/lib/axios/esm/errors/index.d.ts +1 -0
- package/lib/axios/esm/errors/transaction_failed.d.ts +55 -0
- package/lib/axios/esm/errors/transaction_failed.js +60 -0
- package/lib/axios/esm/errors/transaction_failed.js.map +1 -0
- package/lib/axios/esm/errors/wrap_http_error.d.ts +20 -0
- package/lib/axios/esm/errors/wrap_http_error.js +18 -0
- package/lib/axios/esm/errors/wrap_http_error.js.map +1 -0
- package/lib/axios/esm/federation/server.js +14 -15
- package/lib/axios/esm/federation/server.js.map +1 -1
- package/lib/axios/esm/horizon/call_builder.js +20 -0
- package/lib/axios/esm/horizon/call_builder.js.map +1 -1
- package/lib/axios/esm/horizon/horizon_api.d.ts +12 -1
- package/lib/axios/esm/horizon/horizon_api.js +5 -0
- package/lib/axios/esm/horizon/horizon_api.js.map +1 -1
- package/lib/axios/esm/horizon/horizon_axios_client.js +1 -1
- package/lib/axios/esm/horizon/server.d.ts +10 -4
- package/lib/axios/esm/horizon/server.js +20 -26
- package/lib/axios/esm/horizon/server.js.map +1 -1
- package/lib/axios/esm/horizon/trade_aggregation_call_builder.js +20 -0
- package/lib/axios/esm/horizon/trade_aggregation_call_builder.js.map +1 -1
- package/lib/axios/esm/index.js +2 -1
- package/lib/axios/esm/index.js.map +1 -1
- package/lib/axios/esm/rpc/api.d.ts +21 -0
- package/lib/axios/esm/rpc/api.js.map +1 -1
- package/lib/axios/esm/rpc/axios.js +1 -1
- package/lib/axios/esm/rpc/server.d.ts +104 -1
- package/lib/axios/esm/rpc/server.js +163 -8
- package/lib/axios/esm/rpc/server.js.map +1 -1
- package/lib/cjs/base/auth.js +107 -0
- package/lib/cjs/base/auth.js.map +1 -1
- package/lib/cjs/base/keypair.js +39 -0
- package/lib/cjs/base/keypair.js.map +1 -1
- package/lib/cjs/base/scval.js +34 -0
- package/lib/cjs/base/scval.js.map +1 -1
- package/lib/cjs/bindings/config.js +1 -1
- package/lib/cjs/cli/index.js +1 -1
- package/lib/cjs/cli/index.js.map +1 -1
- package/lib/cjs/contract/assembled_transaction.js +8 -7
- package/lib/cjs/contract/assembled_transaction.js.map +1 -1
- package/lib/cjs/contract/client.js +56 -3
- package/lib/cjs/contract/client.js.map +1 -1
- package/lib/cjs/contract/spec.js +7 -3
- package/lib/cjs/contract/spec.js.map +1 -1
- package/lib/cjs/errors/transaction_failed.js +62 -0
- package/lib/cjs/errors/transaction_failed.js.map +1 -0
- package/lib/cjs/errors/wrap_http_error.js +20 -0
- package/lib/cjs/errors/wrap_http_error.js.map +1 -0
- package/lib/cjs/federation/server.js +14 -15
- package/lib/cjs/federation/server.js.map +1 -1
- package/lib/cjs/horizon/call_builder.js +20 -0
- package/lib/cjs/horizon/call_builder.js.map +1 -1
- package/lib/cjs/horizon/horizon_api.js +5 -0
- package/lib/cjs/horizon/horizon_api.js.map +1 -1
- package/lib/cjs/horizon/horizon_axios_client.js +1 -1
- package/lib/cjs/horizon/server.js +20 -26
- package/lib/cjs/horizon/server.js.map +1 -1
- package/lib/cjs/horizon/trade_aggregation_call_builder.js +20 -0
- package/lib/cjs/horizon/trade_aggregation_call_builder.js.map +1 -1
- package/lib/cjs/index.js +4 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/rpc/api.js.map +1 -1
- package/lib/cjs/rpc/axios.js +1 -1
- package/lib/cjs/rpc/server.js +163 -8
- package/lib/cjs/rpc/server.js.map +1 -1
- package/lib/esm/base/auth.d.ts +141 -0
- package/lib/esm/base/auth.js +106 -1
- package/lib/esm/base/auth.js.map +1 -1
- package/lib/esm/base/index.d.ts +2 -2
- package/lib/esm/base/keypair.d.ts +27 -0
- package/lib/esm/base/keypair.js +39 -0
- package/lib/esm/base/keypair.js.map +1 -1
- package/lib/esm/base/scval.d.ts +4 -0
- package/lib/esm/base/scval.js +34 -0
- package/lib/esm/base/scval.js.map +1 -1
- package/lib/esm/bindings/config.js +1 -1
- package/lib/esm/cli/index.js +1 -1
- package/lib/esm/cli/index.js.map +1 -1
- package/lib/esm/contract/assembled_transaction.d.ts +1 -1
- package/lib/esm/contract/assembled_transaction.js +9 -8
- package/lib/esm/contract/assembled_transaction.js.map +1 -1
- package/lib/esm/contract/client.d.ts +49 -3
- package/lib/esm/contract/client.js +56 -3
- package/lib/esm/contract/client.js.map +1 -1
- package/lib/esm/contract/spec.js +7 -3
- package/lib/esm/contract/spec.js.map +1 -1
- package/lib/esm/errors/index.d.ts +1 -0
- package/lib/esm/errors/transaction_failed.d.ts +55 -0
- package/lib/esm/errors/transaction_failed.js +60 -0
- package/lib/esm/errors/transaction_failed.js.map +1 -0
- package/lib/esm/errors/wrap_http_error.d.ts +20 -0
- package/lib/esm/errors/wrap_http_error.js +18 -0
- package/lib/esm/errors/wrap_http_error.js.map +1 -0
- package/lib/esm/federation/server.js +14 -15
- package/lib/esm/federation/server.js.map +1 -1
- package/lib/esm/horizon/call_builder.js +20 -0
- package/lib/esm/horizon/call_builder.js.map +1 -1
- package/lib/esm/horizon/horizon_api.d.ts +12 -1
- package/lib/esm/horizon/horizon_api.js +5 -0
- package/lib/esm/horizon/horizon_api.js.map +1 -1
- package/lib/esm/horizon/horizon_axios_client.js +1 -1
- package/lib/esm/horizon/server.d.ts +10 -4
- package/lib/esm/horizon/server.js +20 -26
- package/lib/esm/horizon/server.js.map +1 -1
- package/lib/esm/horizon/trade_aggregation_call_builder.js +20 -0
- package/lib/esm/horizon/trade_aggregation_call_builder.js.map +1 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/rpc/api.d.ts +21 -0
- package/lib/esm/rpc/api.js.map +1 -1
- package/lib/esm/rpc/axios.js +1 -1
- package/lib/esm/rpc/server.d.ts +104 -1
- package/lib/esm/rpc/server.js +163 -8
- package/lib/esm/rpc/server.js.map +1 -1
- package/package.json +27 -30
package/dist/stellar-sdk.min.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
!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 A(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 S(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 b(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 S(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=A(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 S(d,e,t)}const m=await y(d,n),g=(new TextDecoder).decode(m);let b=g;try{b=JSON.parse(g)}catch{}return{data:b,headers:d.headers,config:e,status:d.status,statusText:d.statusText}}function v(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?b(e):n.request(e)},create(e){return v({...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=v();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{}class B extends Error{accountId;operationIndex;constructor(e,t,n){super(e),this.accountId=t,this.operationIndex=n}}const x={allowHttp:!1,timeout:0};let R={...x};class _{static setAllowHttp(e){R.allowHttp=e}static setTimeout(e){R.timeout=e}static isAllowHttp(){return R.allowHttp}static getTimeout(){return R.timeout}static setDefault(){R={...x}}}class P{static validateTimebounds(e,t=0){if(!e.timeBounds)return!1;const n=Math.floor(Date.now()/1e3),{minTime:r,maxTime:o}=e.timeBounds;return n>=Number.parseInt(r,10)-t&&n<=Number.parseInt(o,10)+t}static sleep(e){return new Promise(t=>setTimeout(t,e))}}
|
|
1
|
+
!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 A(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 S(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 b(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 S(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=A(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 S(d,e,t)}const m=await y(d,n),g=(new TextDecoder).decode(m);let b=g;try{b=JSON.parse(g)}catch{}return{data:b,headers:d.headers,config:e,status:d.status,statusText:d.statusText}}function v(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?b(e):n.request(e)},create(e){return v({...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=v();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:{}};
|
|
2
|
+
/*! 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 K(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:K(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:A(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):A(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function A(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 S(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 b(e,t,n,r){return Z(K(t,e.length-n),e,n,r)}function v(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 S(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":case"latin1":case"binary":return v(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){H(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){H(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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 H(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){G(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||$(t,e.length-(n+1))}(r,o,s)}function G(e,t){if("number"!=typeof e)throw new D.ERR_INVALID_ARG_TYPE(t,"number",e)}function $(e,t,n){if(Math.floor(e)!==e)throw G(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 X=/[^+/0-9A-Za-z-_]/g;function K(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(X,"")).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:()=>H,Bool:()=>L,Double:()=>O,Enum:()=>K,Float:()=>P,Hyper:()=>B,Int:()=>T,LargeInt:()=>C,Opaque:()=>D,Option:()=>$,Quadruple:()=>U,Reference:()=>W,String:()=>V,Struct:()=>Z,Union:()=>j,UnsignedHyper:()=>_,UnsignedInt:()=>R,VarArray:()=>G,VarOpaque:()=>q,Void:()=>X,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(A(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(A(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 A(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 S(e,t){return null!=e&&(e instanceof t||b(e,t)&&"function"==typeof e.constructor.read&&"function"==typeof e.constructor.write&&b(e,"XdrType"))}function b(e,t){do{if(e.constructor.name===t)return!0}while(e=Object.getPrototypeOf(e));return!1}const v=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<=v}}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=v,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 H 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._length}`);for(const n of e)this._childType.write(n,t)}isValid(e){if(!(e instanceof n.g.Array)||e.length!==this._length)return!1;for(const t of e)if(!this._childType.isValid(t))return!1;return!0}}class G extends g{constructor(e,t=R.MAX_VALUE,n=g.DEFAULT_MAX_DEPTH){super(n),this._childType=e,this._maxLength=t}read(e,t=this._maxDepth){g.checkDepth(t);const n=R.read(e);if(n>this._maxLength)throw new o(`saw ${n} length VarArray, max allowed is ${this._maxLength}`);if(n>e.remainingBytes())throw new o(`VarArray length ${n} exceeds remaining ${e.remainingBytes()} bytes`);const r=[];for(let o=0;o<n;o++)r.push(this._childType.read(e,t-1));return r}write(e,t){if(!(e instanceof Array))throw new r("value is not array");if(e.length>this._maxLength)throw new r(`got array of size ${e.length}, max allowed is ${this._maxLength}`);R.write(e.length,t);for(const n of e)this._childType.write(n,t)}isValid(e){if(!(e instanceof Array)||e.length>this._maxLength)return!1;for(const t of e)if(!this._childType.isValid(t))return!1;return!0}}class $ extends g{constructor(e,t=g.DEFAULT_MAX_DEPTH){super(t),this._childType=e}read(e,t=this._maxDepth){if(g.checkDepth(t),L.read(e))return this._childType.read(e,t-1)}write(e,t){const n=null!=e;L.write(n,t),n&&this._childType.write(e,t)}isValid(e){return null==e||this._childType.isValid(e)}}class X extends f{static read(){}static write(e){if(void 0!==e)throw new r("trying to write value to a void slot")}static isValid(e){return void 0===e}}class K extends f{constructor(e,t){super(),this.name=e,this.value=t}static read(e){const t=T.read(e),n=this._byValue[t];if(void 0===n)throw new o(`unknown ${this.enumName} member for value ${t}`);return n}static write(e,t){if(!this.isValid(e))throw new r(`${e} has enum name ${e?.enumName}, not ${this.enumName}: ${JSON.stringify(e)}`);T.write(e.value,t)}static isValid(e){return e?.constructor?.enumName===this.enumName||S(e,this)}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(e){const t=this._members[e];if(!t)throw new TypeError(`${e} is not a member of ${this.enumName}`);return t}static fromValue(e){const t=this._byValue[e];if(void 0===t)throw new TypeError(`${e} is not a value of any member of ${this.enumName}`);return t}static create(e,t,n){const r=class extends K{};r.enumName=t,e.results[t]=r,r._members={},r._byValue={};for(const[e,t]of Object.entries(n)){const n=new r(e,t);r._members[e]=n,r._byValue[t]=n,r[e]=()=>n}return r}}class W extends f{resolve(){throw new s('"resolve" method should be implemented in the descendant class')}}class Z extends g{constructor(e,t){super(t??new.target?._maxDepth),this._attributes=e||{}}static read(e,t=this._maxDepth){g.checkDepth(t);const n={};for(const[r,o]of this._fields)n[r]=o.read(e,t-1);return new this(n,this._maxDepth)}static write(e,t){if(!this.isValid(e))throw new r(`${e} has struct name ${e?.constructor?.structName}, not ${this.structName}: ${JSON.stringify(e)}`);for(const[n,r]of this._fields){const o=e._attributes[n];r.write(o,t)}}static isValid(e){return e?.constructor?.structName===this.structName||S(e,this)}static create(e,t,n,r=g.DEFAULT_MAX_DEPTH){const o=class extends Z{};o.structName=t,o._maxDepth=r,e.results[t]=o;const s=new Array(n.length);for(let t=0;t<n.length;t++){const r=n[t],i=r[0];let a=r[1];a instanceof W&&(a=a.resolve(e)),s[t]=[i,a],o.prototype[i]=z(i)}return o._fields=s,o}}function z(e){return function(t){return void 0!==t&&(this._attributes[e]=t),this._attributes[e]}}class j extends g{constructor(e,t,n){super(n??new.target?._maxDepth),this.set(e,t)}set(e,t){"string"==typeof e&&(e=this.constructor._switchOn.fromName(e)),this._switch=e;const n=this.constructor.armForSwitch(this._switch);this._arm=n,this._armType=n===X?X:this.constructor._arms[n],this._value=t}get(e=this._arm){if(this._arm!==X&&this._arm!==e)throw new TypeError(`${e} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(e){const t=this._switches.get(e);if(void 0!==t)return t;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${e}`)}static armTypeForArm(e){return e===X?X:this._arms[e]}static read(e,t=this._maxDepth){g.checkDepth(t);const n=this._switchOn.read(e,t-1),r=this.armForSwitch(n),o=r===X?X:this._arms[r];let s;return s=void 0!==o?o.read(e,t-1):r.read(e,t-1),new this(n,s,this._maxDepth)}static write(e,t){if(!this.isValid(e))throw new r(`${e} has union name ${e?.unionName}, not ${this.unionName}: ${JSON.stringify(e)}`);this._switchOn.write(e.switch(),t),e.armType().write(e.value(),t)}static isValid(e){return e?.constructor?.unionName===this.unionName||S(e,this)}static create(e,t,n,r=g.DEFAULT_MAX_DEPTH){const o=class extends j{};o.unionName=t,o._maxDepth=r,e.results[t]=o,n.switchOn instanceof W?o._switchOn=n.switchOn.resolve(e):o._switchOn=n.switchOn,o._switches=new Map,o._arms={};let s=n.defaultArm;s instanceof W&&(s=s.resolve(e)),o._defaultArm=s;for(const[e,t]of n.switches){const n="string"==typeof e?o._switchOn.fromName(e):e;o._switches.set(n,t)}if(void 0!==o._switchOn.values)for(const e of o._switchOn.values())o[e.name]=function(t){return new o(e,t)},o.prototype[e.name]=function(t){return this.set(e,t)};if(n.arms)for(const[t,r]of Object.entries(n.arms))o._arms[t]=r instanceof W?r.resolve(e):r,r!==X&&(o.prototype[t]=function(){return this.get(t)});return o}}class Y extends W{constructor(e){super(),this.name=e}resolve(e){return e.definitions[this.name].resolve(e)}}class J extends W{constructor(e,t,n=!1){super(),this.childReference=e,this.length=t,this.variable=n}resolve(e){let t=this.childReference,n=this.length;return t instanceof W&&(t=t.resolve(e)),n instanceof W&&(n=n.resolve(e)),this.variable?new G(t,n):new H(t,n)}}class Q extends W{constructor(e){super(),this.childReference=e,this.name=e.name}resolve(e){let t=this.childReference;return t instanceof W&&(t=t.resolve(e)),new $(t)}}class ee extends W{constructor(e,t){super(),this.sizedType=e,this.length=t}resolve(e){let t=this.length;return t instanceof W&&(t=t.resolve(e)),new this.sizedType(t)}}class te{constructor(e,t,n){this.constructor=e,this.name=t,this.config=n}resolve(e){return this.name in e.results?e.results[this.name]:this.constructor(e,this.name,this.config)}}function ne(e,t,n){return n instanceof W&&(n=n.resolve(e)),e.results[t]=n,n}function re(e,t,n){return e.results[t]=n,n}class oe{constructor(e){this._destination=e,this._definitions={}}enum(e,t){const n=new te(K.create,e,t);this.define(e,n)}struct(e,t){const n=new te(Z.create,e,t);this.define(e,n)}union(e,t){const n=new te(j.create,e,t);this.define(e,n)}typedef(e,t){const n=new te(ne,e,t);this.define(e,n)}const(e,t){const n=new te(re,e,t);this.define(e,n)}void(){return X}bool(){return L}int(){return T}hyper(){return B}uint(){return R}uhyper(){return _}float(){return P}double(){return O}quadruple(){return U}string(e){return new ee(V,e)}opaque(e){return new ee(D,e)}varOpaque(e){return new ee(q,e)}array(e,t){return new J(e,t)}varArray(e,t){return new J(e,t,!0)}option(e){return new Q(e)}define(e,t){if(void 0!==this._destination[e])throw new s(`${e} is already defined`);this._definitions[e]=t}lookup(e){return new Y(e)}resolve(){for(const e of Object.values(this._definitions))e.resolve({definitions:this._definitions,results:this._destination})}}function se(e,t={}){if(e){const n=new oe(t);e(n),n.resolve()}return t}},947(e,t){t.read=function(e,t,n,r,o){var s,i,a=8*o-r-1,c=(1<<a)-1,u=c>>1,l=-7,d=n?o-1:0,p=n?-1:1,h=e[t+d];for(d+=p,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=p,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=r;l>0;i=256*i+e[t+d],d+=p,l-=8);if(0===s)s=1-u;else{if(s===c)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,r),s-=u}return(h?-1:1)*i*Math.pow(2,s-r)},t.write=function(e,t,n,r,o,s){var i,a,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),(t+=i+d>=1?p/c:p*Math.pow(2,1-d))*c>=2&&(i++,c/=2),i+d>=l?(a=0,i=l):i+d>=1?(a=(t*c-1)*Math.pow(2,o),i+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(i=i<<o|a,u+=o;u>0;e[n+h]=255&i,h+=f,i/=256,u-=8);e[n+h-f]|=128*m}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(348)})(),e.exports=t()}(R)),R.exports),P=_.config(e=>{const t=1024;e.typedef("Value",e.varOpaque()),e.struct("ScpBallot",[["counter",e.lookup("Uint32")],["value",e.lookup("Value")]]),e.enum("ScpStatementType",{scpStPrepare:0,scpStConfirm:1,scpStExternalize:2,scpStNominate:3}),e.struct("ScpNomination",[["quorumSetHash",e.lookup("Hash")],["votes",e.varArray(e.lookup("Value"),2147483647)],["accepted",e.varArray(e.lookup("Value"),2147483647)]]),e.struct("ScpStatementPrepare",[["quorumSetHash",e.lookup("Hash")],["ballot",e.lookup("ScpBallot")],["prepared",e.option(e.lookup("ScpBallot"))],["preparedPrime",e.option(e.lookup("ScpBallot"))],["nC",e.lookup("Uint32")],["nH",e.lookup("Uint32")]]),e.struct("ScpStatementConfirm",[["ballot",e.lookup("ScpBallot")],["nPrepared",e.lookup("Uint32")],["nCommit",e.lookup("Uint32")],["nH",e.lookup("Uint32")],["quorumSetHash",e.lookup("Hash")]]),e.struct("ScpStatementExternalize",[["commit",e.lookup("ScpBallot")],["nH",e.lookup("Uint32")],["commitQuorumSetHash",e.lookup("Hash")]]),e.union("ScpStatementPledges",{switchOn:e.lookup("ScpStatementType"),switchName:"type",switches:[["scpStPrepare","prepare"],["scpStConfirm","confirm"],["scpStExternalize","externalize"],["scpStNominate","nominate"]],arms:{prepare:e.lookup("ScpStatementPrepare"),confirm:e.lookup("ScpStatementConfirm"),externalize:e.lookup("ScpStatementExternalize"),nominate:e.lookup("ScpNomination")}}),e.struct("ScpStatement",[["nodeId",e.lookup("NodeId")],["slotIndex",e.lookup("Uint64")],["pledges",e.lookup("ScpStatementPledges")]]),e.struct("ScpEnvelope",[["statement",e.lookup("ScpStatement")],["signature",e.lookup("Signature")]]),e.struct("ScpQuorumSet",[["threshold",e.lookup("Uint32")],["validators",e.varArray(e.lookup("NodeId"),2147483647)],["innerSets",e.varArray(e.lookup("ScpQuorumSet"),2147483647)]]),e.typedef("Thresholds",e.opaque(4)),e.typedef("String32",e.string(32)),e.typedef("String64",e.string(64)),e.typedef("SequenceNumber",e.lookup("Int64")),e.typedef("DataValue",e.varOpaque(64)),e.typedef("AssetCode4",e.opaque(4)),e.typedef("AssetCode12",e.opaque(12)),e.enum("AssetType",{assetTypeNative:0,assetTypeCreditAlphanum4:1,assetTypeCreditAlphanum12:2,assetTypePoolShare:3}),e.union("AssetCode",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeCreditAlphanum4","assetCode4"],["assetTypeCreditAlphanum12","assetCode12"]],arms:{assetCode4:e.lookup("AssetCode4"),assetCode12:e.lookup("AssetCode12")}}),e.struct("AlphaNum4",[["assetCode",e.lookup("AssetCode4")],["issuer",e.lookup("AccountId")]]),e.struct("AlphaNum12",[["assetCode",e.lookup("AssetCode12")],["issuer",e.lookup("AccountId")]]),e.union("Asset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12")}}),e.struct("Price",[["n",e.lookup("Int32")],["d",e.lookup("Int32")]]),e.struct("Liabilities",[["buying",e.lookup("Int64")],["selling",e.lookup("Int64")]]),e.enum("ThresholdIndices",{thresholdMasterWeight:0,thresholdLow:1,thresholdMed:2,thresholdHigh:3}),e.enum("LedgerEntryType",{account:0,trustline:1,offer:2,data:3,claimableBalance:4,liquidityPool:5,contractData:6,contractCode:7,configSetting:8,ttl:9}),e.struct("Signer",[["key",e.lookup("SignerKey")],["weight",e.lookup("Uint32")]]),e.enum("AccountFlags",{authRequiredFlag:1,authRevocableFlag:2,authImmutableFlag:4,authClawbackEnabledFlag:8}),e.const("MASK_ACCOUNT_FLAGS",7),e.const("MASK_ACCOUNT_FLAGS_V17",15),e.const("MAX_SIGNERS",20),e.typedef("SponsorshipDescriptor",e.option(e.lookup("AccountId"))),e.struct("AccountEntryExtensionV3",[["ext",e.lookup("ExtensionPoint")],["seqLedger",e.lookup("Uint32")],["seqTime",e.lookup("TimePoint")]]),e.union("AccountEntryExtensionV2Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[3,"v3"]],arms:{v3:e.lookup("AccountEntryExtensionV3")}}),e.struct("AccountEntryExtensionV2",[["numSponsored",e.lookup("Uint32")],["numSponsoring",e.lookup("Uint32")],["signerSponsoringIDs",e.varArray(e.lookup("SponsorshipDescriptor"),e.lookup("MAX_SIGNERS"))],["ext",e.lookup("AccountEntryExtensionV2Ext")]]),e.union("AccountEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[2,"v2"]],arms:{v2:e.lookup("AccountEntryExtensionV2")}}),e.struct("AccountEntryExtensionV1",[["liabilities",e.lookup("Liabilities")],["ext",e.lookup("AccountEntryExtensionV1Ext")]]),e.union("AccountEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("AccountEntryExtensionV1")}}),e.struct("AccountEntry",[["accountId",e.lookup("AccountId")],["balance",e.lookup("Int64")],["seqNum",e.lookup("SequenceNumber")],["numSubEntries",e.lookup("Uint32")],["inflationDest",e.option(e.lookup("AccountId"))],["flags",e.lookup("Uint32")],["homeDomain",e.lookup("String32")],["thresholds",e.lookup("Thresholds")],["signers",e.varArray(e.lookup("Signer"),e.lookup("MAX_SIGNERS"))],["ext",e.lookup("AccountEntryExt")]]),e.enum("TrustLineFlags",{authorizedFlag:1,authorizedToMaintainLiabilitiesFlag:2,trustlineClawbackEnabledFlag:4}),e.const("MASK_TRUSTLINE_FLAGS",1),e.const("MASK_TRUSTLINE_FLAGS_V13",3),e.const("MASK_TRUSTLINE_FLAGS_V17",7),e.enum("LiquidityPoolType",{liquidityPoolConstantProduct:0}),e.union("TrustLineAsset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"],["assetTypePoolShare","liquidityPoolId"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12"),liquidityPoolId:e.lookup("PoolId")}}),e.union("TrustLineEntryExtensionV2Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TrustLineEntryExtensionV2",[["liquidityPoolUseCount",e.lookup("Int32")],["ext",e.lookup("TrustLineEntryExtensionV2Ext")]]),e.union("TrustLineEntryV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[2,"v2"]],arms:{v2:e.lookup("TrustLineEntryExtensionV2")}}),e.struct("TrustLineEntryV1",[["liabilities",e.lookup("Liabilities")],["ext",e.lookup("TrustLineEntryV1Ext")]]),e.union("TrustLineEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("TrustLineEntryV1")}}),e.struct("TrustLineEntry",[["accountId",e.lookup("AccountId")],["asset",e.lookup("TrustLineAsset")],["balance",e.lookup("Int64")],["limit",e.lookup("Int64")],["flags",e.lookup("Uint32")],["ext",e.lookup("TrustLineEntryExt")]]),e.enum("OfferEntryFlags",{passiveFlag:1}),e.const("MASK_OFFERENTRY_FLAGS",1),e.union("OfferEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("OfferEntry",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")],["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")],["flags",e.lookup("Uint32")],["ext",e.lookup("OfferEntryExt")]]),e.union("DataEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("DataEntry",[["accountId",e.lookup("AccountId")],["dataName",e.lookup("String64")],["dataValue",e.lookup("DataValue")],["ext",e.lookup("DataEntryExt")]]),e.enum("ClaimPredicateType",{claimPredicateUnconditional:0,claimPredicateAnd:1,claimPredicateOr:2,claimPredicateNot:3,claimPredicateBeforeAbsoluteTime:4,claimPredicateBeforeRelativeTime:5}),e.union("ClaimPredicate",{switchOn:e.lookup("ClaimPredicateType"),switchName:"type",switches:[["claimPredicateUnconditional",e.void()],["claimPredicateAnd","andPredicates"],["claimPredicateOr","orPredicates"],["claimPredicateNot","notPredicate"],["claimPredicateBeforeAbsoluteTime","absBefore"],["claimPredicateBeforeRelativeTime","relBefore"]],arms:{andPredicates:e.varArray(e.lookup("ClaimPredicate"),2),orPredicates:e.varArray(e.lookup("ClaimPredicate"),2),notPredicate:e.option(e.lookup("ClaimPredicate")),absBefore:e.lookup("Int64"),relBefore:e.lookup("Int64")}}),e.enum("ClaimantType",{claimantTypeV0:0}),e.struct("ClaimantV0",[["destination",e.lookup("AccountId")],["predicate",e.lookup("ClaimPredicate")]]),e.union("Claimant",{switchOn:e.lookup("ClaimantType"),switchName:"type",switches:[["claimantTypeV0","v0"]],arms:{v0:e.lookup("ClaimantV0")}}),e.enum("ClaimableBalanceFlags",{claimableBalanceClawbackEnabledFlag:1}),e.const("MASK_CLAIMABLE_BALANCE_FLAGS",1),e.union("ClaimableBalanceEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("ClaimableBalanceEntryExtensionV1",[["ext",e.lookup("ClaimableBalanceEntryExtensionV1Ext")],["flags",e.lookup("Uint32")]]),e.union("ClaimableBalanceEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("ClaimableBalanceEntryExtensionV1")}}),e.struct("ClaimableBalanceEntry",[["balanceId",e.lookup("ClaimableBalanceId")],["claimants",e.varArray(e.lookup("Claimant"),10)],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")],["ext",e.lookup("ClaimableBalanceEntryExt")]]),e.struct("LiquidityPoolConstantProductParameters",[["assetA",e.lookup("Asset")],["assetB",e.lookup("Asset")],["fee",e.lookup("Int32")]]),e.struct("LiquidityPoolEntryConstantProduct",[["params",e.lookup("LiquidityPoolConstantProductParameters")],["reserveA",e.lookup("Int64")],["reserveB",e.lookup("Int64")],["totalPoolShares",e.lookup("Int64")],["poolSharesTrustLineCount",e.lookup("Int64")]]),e.union("LiquidityPoolEntryBody",{switchOn:e.lookup("LiquidityPoolType"),switchName:"type",switches:[["liquidityPoolConstantProduct","constantProduct"]],arms:{constantProduct:e.lookup("LiquidityPoolEntryConstantProduct")}}),e.struct("LiquidityPoolEntry",[["liquidityPoolId",e.lookup("PoolId")],["body",e.lookup("LiquidityPoolEntryBody")]]),e.enum("ContractDataDurability",{temporary:0,persistent:1}),e.struct("ContractDataEntry",[["ext",e.lookup("ExtensionPoint")],["contract",e.lookup("ScAddress")],["key",e.lookup("ScVal")],["durability",e.lookup("ContractDataDurability")],["val",e.lookup("ScVal")]]),e.struct("ContractCodeCostInputs",[["ext",e.lookup("ExtensionPoint")],["nInstructions",e.lookup("Uint32")],["nFunctions",e.lookup("Uint32")],["nGlobals",e.lookup("Uint32")],["nTableEntries",e.lookup("Uint32")],["nTypes",e.lookup("Uint32")],["nDataSegments",e.lookup("Uint32")],["nElemSegments",e.lookup("Uint32")],["nImports",e.lookup("Uint32")],["nExports",e.lookup("Uint32")],["nDataSegmentBytes",e.lookup("Uint32")]]),e.struct("ContractCodeEntryV1",[["ext",e.lookup("ExtensionPoint")],["costInputs",e.lookup("ContractCodeCostInputs")]]),e.union("ContractCodeEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("ContractCodeEntryV1")}}),e.struct("ContractCodeEntry",[["ext",e.lookup("ContractCodeEntryExt")],["hash",e.lookup("Hash")],["code",e.varOpaque()]]),e.struct("TtlEntry",[["keyHash",e.lookup("Hash")],["liveUntilLedgerSeq",e.lookup("Uint32")]]),e.union("LedgerEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerEntryExtensionV1",[["sponsoringId",e.lookup("SponsorshipDescriptor")],["ext",e.lookup("LedgerEntryExtensionV1Ext")]]),e.union("LedgerEntryData",{switchOn:e.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["data","data"],["claimableBalance","claimableBalance"],["liquidityPool","liquidityPool"],["contractData","contractData"],["contractCode","contractCode"],["configSetting","configSetting"],["ttl","ttl"]],arms:{account:e.lookup("AccountEntry"),trustLine:e.lookup("TrustLineEntry"),offer:e.lookup("OfferEntry"),data:e.lookup("DataEntry"),claimableBalance:e.lookup("ClaimableBalanceEntry"),liquidityPool:e.lookup("LiquidityPoolEntry"),contractData:e.lookup("ContractDataEntry"),contractCode:e.lookup("ContractCodeEntry"),configSetting:e.lookup("ConfigSettingEntry"),ttl:e.lookup("TtlEntry")}}),e.union("LedgerEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerEntryExtensionV1")}}),e.struct("LedgerEntry",[["lastModifiedLedgerSeq",e.lookup("Uint32")],["data",e.lookup("LedgerEntryData")],["ext",e.lookup("LedgerEntryExt")]]),e.struct("LedgerKeyAccount",[["accountId",e.lookup("AccountId")]]),e.struct("LedgerKeyTrustLine",[["accountId",e.lookup("AccountId")],["asset",e.lookup("TrustLineAsset")]]),e.struct("LedgerKeyOffer",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")]]),e.struct("LedgerKeyData",[["accountId",e.lookup("AccountId")],["dataName",e.lookup("String64")]]),e.struct("LedgerKeyClaimableBalance",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("LedgerKeyLiquidityPool",[["liquidityPoolId",e.lookup("PoolId")]]),e.struct("LedgerKeyContractData",[["contract",e.lookup("ScAddress")],["key",e.lookup("ScVal")],["durability",e.lookup("ContractDataDurability")]]),e.struct("LedgerKeyContractCode",[["hash",e.lookup("Hash")]]),e.struct("LedgerKeyConfigSetting",[["configSettingId",e.lookup("ConfigSettingId")]]),e.struct("LedgerKeyTtl",[["keyHash",e.lookup("Hash")]]),e.union("LedgerKey",{switchOn:e.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["data","data"],["claimableBalance","claimableBalance"],["liquidityPool","liquidityPool"],["contractData","contractData"],["contractCode","contractCode"],["configSetting","configSetting"],["ttl","ttl"]],arms:{account:e.lookup("LedgerKeyAccount"),trustLine:e.lookup("LedgerKeyTrustLine"),offer:e.lookup("LedgerKeyOffer"),data:e.lookup("LedgerKeyData"),claimableBalance:e.lookup("LedgerKeyClaimableBalance"),liquidityPool:e.lookup("LedgerKeyLiquidityPool"),contractData:e.lookup("LedgerKeyContractData"),contractCode:e.lookup("LedgerKeyContractCode"),configSetting:e.lookup("LedgerKeyConfigSetting"),ttl:e.lookup("LedgerKeyTtl")}}),e.enum("EnvelopeType",{envelopeTypeTxV0:0,envelopeTypeScp:1,envelopeTypeTx:2,envelopeTypeAuth:3,envelopeTypeScpvalue:4,envelopeTypeTxFeeBump:5,envelopeTypeOpId:6,envelopeTypePoolRevokeOpId:7,envelopeTypeContractId:8,envelopeTypeSorobanAuthorization:9,envelopeTypeSorobanAuthorizationWithAddress:10}),e.enum("BucketListType",{live:0,hotArchive:1}),e.enum("BucketEntryType",{metaentry:-1,liveentry:0,deadentry:1,initentry:2}),e.enum("HotArchiveBucketEntryType",{hotArchiveMetaentry:-1,hotArchiveArchived:0,hotArchiveLive:1}),e.union("BucketMetadataExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"bucketListType"]],arms:{bucketListType:e.lookup("BucketListType")}}),e.struct("BucketMetadata",[["ledgerVersion",e.lookup("Uint32")],["ext",e.lookup("BucketMetadataExt")]]),e.union("BucketEntry",{switchOn:e.lookup("BucketEntryType"),switchName:"type",switches:[["liveentry","liveEntry"],["initentry","liveEntry"],["deadentry","deadEntry"],["metaentry","metaEntry"]],arms:{liveEntry:e.lookup("LedgerEntry"),deadEntry:e.lookup("LedgerKey"),metaEntry:e.lookup("BucketMetadata")}}),e.union("HotArchiveBucketEntry",{switchOn:e.lookup("HotArchiveBucketEntryType"),switchName:"type",switches:[["hotArchiveArchived","archivedEntry"],["hotArchiveLive","key"],["hotArchiveMetaentry","metaEntry"]],arms:{archivedEntry:e.lookup("LedgerEntry"),key:e.lookup("LedgerKey"),metaEntry:e.lookup("BucketMetadata")}}),e.typedef("UpgradeType",e.varOpaque(128)),e.enum("StellarValueType",{stellarValueBasic:0,stellarValueSigned:1}),e.struct("LedgerCloseValueSignature",[["nodeId",e.lookup("NodeId")],["signature",e.lookup("Signature")]]),e.union("StellarValueExt",{switchOn:e.lookup("StellarValueType"),switchName:"v",switches:[["stellarValueBasic",e.void()],["stellarValueSigned","lcValueSignature"]],arms:{lcValueSignature:e.lookup("LedgerCloseValueSignature")}}),e.struct("StellarValue",[["txSetHash",e.lookup("Hash")],["closeTime",e.lookup("TimePoint")],["upgrades",e.varArray(e.lookup("UpgradeType"),6)],["ext",e.lookup("StellarValueExt")]]),e.const("MASK_LEDGER_HEADER_FLAGS",7),e.enum("LedgerHeaderFlags",{disableLiquidityPoolTradingFlag:1,disableLiquidityPoolDepositFlag:2,disableLiquidityPoolWithdrawalFlag:4}),e.union("LedgerHeaderExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerHeaderExtensionV1",[["flags",e.lookup("Uint32")],["ext",e.lookup("LedgerHeaderExtensionV1Ext")]]),e.union("LedgerHeaderExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerHeaderExtensionV1")}}),e.struct("LedgerHeader",[["ledgerVersion",e.lookup("Uint32")],["previousLedgerHash",e.lookup("Hash")],["scpValue",e.lookup("StellarValue")],["txSetResultHash",e.lookup("Hash")],["bucketListHash",e.lookup("Hash")],["ledgerSeq",e.lookup("Uint32")],["totalCoins",e.lookup("Int64")],["feePool",e.lookup("Int64")],["inflationSeq",e.lookup("Uint32")],["idPool",e.lookup("Uint64")],["baseFee",e.lookup("Uint32")],["baseReserve",e.lookup("Uint32")],["maxTxSetSize",e.lookup("Uint32")],["skipList",e.array(e.lookup("Hash"),4)],["ext",e.lookup("LedgerHeaderExt")]]),e.enum("LedgerUpgradeType",{ledgerUpgradeVersion:1,ledgerUpgradeBaseFee:2,ledgerUpgradeMaxTxSetSize:3,ledgerUpgradeBaseReserve:4,ledgerUpgradeFlags:5,ledgerUpgradeConfig:6,ledgerUpgradeMaxSorobanTxSetSize:7}),e.struct("ConfigUpgradeSetKey",[["contractId",e.lookup("ContractId")],["contentHash",e.lookup("Hash")]]),e.union("LedgerUpgrade",{switchOn:e.lookup("LedgerUpgradeType"),switchName:"type",switches:[["ledgerUpgradeVersion","newLedgerVersion"],["ledgerUpgradeBaseFee","newBaseFee"],["ledgerUpgradeMaxTxSetSize","newMaxTxSetSize"],["ledgerUpgradeBaseReserve","newBaseReserve"],["ledgerUpgradeFlags","newFlags"],["ledgerUpgradeConfig","newConfig"],["ledgerUpgradeMaxSorobanTxSetSize","newMaxSorobanTxSetSize"]],arms:{newLedgerVersion:e.lookup("Uint32"),newBaseFee:e.lookup("Uint32"),newMaxTxSetSize:e.lookup("Uint32"),newBaseReserve:e.lookup("Uint32"),newFlags:e.lookup("Uint32"),newConfig:e.lookup("ConfigUpgradeSetKey"),newMaxSorobanTxSetSize:e.lookup("Uint32")}}),e.struct("ConfigUpgradeSet",[["updatedEntry",e.varArray(e.lookup("ConfigSettingEntry"),2147483647)]]),e.enum("TxSetComponentType",{txsetCompTxsMaybeDiscountedFee:0}),e.typedef("DependentTxCluster",e.varArray(e.lookup("TransactionEnvelope"),2147483647)),e.typedef("ParallelTxExecutionStage",e.varArray(e.lookup("DependentTxCluster"),2147483647)),e.struct("ParallelTxsComponent",[["baseFee",e.option(e.lookup("Int64"))],["executionStages",e.varArray(e.lookup("ParallelTxExecutionStage"),2147483647)]]),e.struct("TxSetComponentTxsMaybeDiscountedFee",[["baseFee",e.option(e.lookup("Int64"))],["txes",e.varArray(e.lookup("TransactionEnvelope"),2147483647)]]),e.union("TxSetComponent",{switchOn:e.lookup("TxSetComponentType"),switchName:"type",switches:[["txsetCompTxsMaybeDiscountedFee","txsMaybeDiscountedFee"]],arms:{txsMaybeDiscountedFee:e.lookup("TxSetComponentTxsMaybeDiscountedFee")}}),e.union("TransactionPhase",{switchOn:e.int(),switchName:"v",switches:[[0,"v0Components"],[1,"parallelTxsComponent"]],arms:{v0Components:e.varArray(e.lookup("TxSetComponent"),2147483647),parallelTxsComponent:e.lookup("ParallelTxsComponent")}}),e.struct("TransactionSet",[["previousLedgerHash",e.lookup("Hash")],["txes",e.varArray(e.lookup("TransactionEnvelope"),2147483647)]]),e.struct("TransactionSetV1",[["previousLedgerHash",e.lookup("Hash")],["phases",e.varArray(e.lookup("TransactionPhase"),2147483647)]]),e.union("GeneralizedTransactionSet",{switchOn:e.int(),switchName:"v",switches:[[1,"v1TxSet"]],arms:{v1TxSet:e.lookup("TransactionSetV1")}}),e.struct("TransactionResultPair",[["transactionHash",e.lookup("Hash")],["result",e.lookup("TransactionResult")]]),e.struct("TransactionResultSet",[["results",e.varArray(e.lookup("TransactionResultPair"),2147483647)]]),e.union("TransactionHistoryEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"generalizedTxSet"]],arms:{generalizedTxSet:e.lookup("GeneralizedTransactionSet")}}),e.struct("TransactionHistoryEntry",[["ledgerSeq",e.lookup("Uint32")],["txSet",e.lookup("TransactionSet")],["ext",e.lookup("TransactionHistoryEntryExt")]]),e.union("TransactionHistoryResultEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionHistoryResultEntry",[["ledgerSeq",e.lookup("Uint32")],["txResultSet",e.lookup("TransactionResultSet")],["ext",e.lookup("TransactionHistoryResultEntryExt")]]),e.union("LedgerHeaderHistoryEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerHeaderHistoryEntry",[["hash",e.lookup("Hash")],["header",e.lookup("LedgerHeader")],["ext",e.lookup("LedgerHeaderHistoryEntryExt")]]),e.struct("LedgerScpMessages",[["ledgerSeq",e.lookup("Uint32")],["messages",e.varArray(e.lookup("ScpEnvelope"),2147483647)]]),e.struct("ScpHistoryEntryV0",[["quorumSets",e.varArray(e.lookup("ScpQuorumSet"),2147483647)],["ledgerMessages",e.lookup("LedgerScpMessages")]]),e.union("ScpHistoryEntry",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("ScpHistoryEntryV0")}}),e.enum("LedgerEntryChangeType",{ledgerEntryCreated:0,ledgerEntryUpdated:1,ledgerEntryRemoved:2,ledgerEntryState:3,ledgerEntryRestored:4}),e.union("LedgerEntryChange",{switchOn:e.lookup("LedgerEntryChangeType"),switchName:"type",switches:[["ledgerEntryCreated","created"],["ledgerEntryUpdated","updated"],["ledgerEntryRemoved","removed"],["ledgerEntryState","state"],["ledgerEntryRestored","restored"]],arms:{created:e.lookup("LedgerEntry"),updated:e.lookup("LedgerEntry"),removed:e.lookup("LedgerKey"),state:e.lookup("LedgerEntry"),restored:e.lookup("LedgerEntry")}}),e.typedef("LedgerEntryChanges",e.varArray(e.lookup("LedgerEntryChange"),2147483647)),e.struct("OperationMeta",[["changes",e.lookup("LedgerEntryChanges")]]),e.struct("TransactionMetaV1",[["txChanges",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)]]),e.struct("TransactionMetaV2",[["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")]]),e.enum("ContractEventType",{system:0,contract:1,diagnostic:2}),e.struct("ContractEventV0",[["topics",e.varArray(e.lookup("ScVal"),2147483647)],["data",e.lookup("ScVal")]]),e.union("ContractEventBody",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("ContractEventV0")}}),e.struct("ContractEvent",[["ext",e.lookup("ExtensionPoint")],["contractId",e.option(e.lookup("ContractId"))],["type",e.lookup("ContractEventType")],["body",e.lookup("ContractEventBody")]]),e.struct("DiagnosticEvent",[["inSuccessfulContractCall",e.bool()],["event",e.lookup("ContractEvent")]]),e.struct("SorobanTransactionMetaExtV1",[["ext",e.lookup("ExtensionPoint")],["totalNonRefundableResourceFeeCharged",e.lookup("Int64")],["totalRefundableResourceFeeCharged",e.lookup("Int64")],["rentFeeCharged",e.lookup("Int64")]]),e.union("SorobanTransactionMetaExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("SorobanTransactionMetaExtV1")}}),e.struct("SorobanTransactionMeta",[["ext",e.lookup("SorobanTransactionMetaExt")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)],["returnValue",e.lookup("ScVal")],["diagnosticEvents",e.varArray(e.lookup("DiagnosticEvent"),2147483647)]]),e.struct("TransactionMetaV3",[["ext",e.lookup("ExtensionPoint")],["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")],["sorobanMeta",e.option(e.lookup("SorobanTransactionMeta"))]]),e.struct("OperationMetaV2",[["ext",e.lookup("ExtensionPoint")],["changes",e.lookup("LedgerEntryChanges")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)]]),e.struct("SorobanTransactionMetaV2",[["ext",e.lookup("SorobanTransactionMetaExt")],["returnValue",e.option(e.lookup("ScVal"))]]),e.enum("TransactionEventStage",{transactionEventStageBeforeAllTxes:0,transactionEventStageAfterTx:1,transactionEventStageAfterAllTxes:2}),e.struct("TransactionEvent",[["stage",e.lookup("TransactionEventStage")],["event",e.lookup("ContractEvent")]]),e.struct("TransactionMetaV4",[["ext",e.lookup("ExtensionPoint")],["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMetaV2"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")],["sorobanMeta",e.option(e.lookup("SorobanTransactionMetaV2"))],["events",e.varArray(e.lookup("TransactionEvent"),2147483647)],["diagnosticEvents",e.varArray(e.lookup("DiagnosticEvent"),2147483647)]]),e.struct("InvokeHostFunctionSuccessPreImage",[["returnValue",e.lookup("ScVal")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)]]),e.union("TransactionMeta",{switchOn:e.int(),switchName:"v",switches:[[0,"operations"],[1,"v1"],[2,"v2"],[3,"v3"],[4,"v4"]],arms:{operations:e.varArray(e.lookup("OperationMeta"),2147483647),v1:e.lookup("TransactionMetaV1"),v2:e.lookup("TransactionMetaV2"),v3:e.lookup("TransactionMetaV3"),v4:e.lookup("TransactionMetaV4")}}),e.struct("TransactionResultMeta",[["result",e.lookup("TransactionResultPair")],["feeProcessing",e.lookup("LedgerEntryChanges")],["txApplyProcessing",e.lookup("TransactionMeta")]]),e.struct("TransactionResultMetaV1",[["ext",e.lookup("ExtensionPoint")],["result",e.lookup("TransactionResultPair")],["feeProcessing",e.lookup("LedgerEntryChanges")],["txApplyProcessing",e.lookup("TransactionMeta")],["postTxApplyFeeProcessing",e.lookup("LedgerEntryChanges")]]),e.struct("UpgradeEntryMeta",[["upgrade",e.lookup("LedgerUpgrade")],["changes",e.lookup("LedgerEntryChanges")]]),e.struct("LedgerCloseMetaV0",[["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("TransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMeta"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)]]),e.struct("LedgerCloseMetaExtV1",[["ext",e.lookup("ExtensionPoint")],["sorobanFeeWrite1Kb",e.lookup("Int64")]]),e.union("LedgerCloseMetaExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerCloseMetaExtV1")}}),e.struct("LedgerCloseMetaV1",[["ext",e.lookup("LedgerCloseMetaExt")],["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("GeneralizedTransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMeta"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)],["totalByteSizeOfLiveSorobanState",e.lookup("Uint64")],["evictedKeys",e.varArray(e.lookup("LedgerKey"),2147483647)],["unused",e.varArray(e.lookup("LedgerEntry"),2147483647)]]),e.struct("LedgerCloseMetaV2",[["ext",e.lookup("LedgerCloseMetaExt")],["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("GeneralizedTransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMetaV1"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)],["totalByteSizeOfLiveSorobanState",e.lookup("Uint64")],["evictedKeys",e.varArray(e.lookup("LedgerKey"),2147483647)]]),e.union("LedgerCloseMeta",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"],[1,"v1"],[2,"v2"]],arms:{v0:e.lookup("LedgerCloseMetaV0"),v1:e.lookup("LedgerCloseMetaV1"),v2:e.lookup("LedgerCloseMetaV2")}}),e.enum("ErrorCode",{errMisc:0,errData:1,errConf:2,errAuth:3,errLoad:4}),e.struct("Error",[["code",e.lookup("ErrorCode")],["msg",e.string(100)]]),e.struct("SendMore",[["numMessages",e.lookup("Uint32")]]),e.struct("SendMoreExtended",[["numMessages",e.lookup("Uint32")],["numBytes",e.lookup("Uint32")]]),e.struct("AuthCert",[["pubkey",e.lookup("Curve25519Public")],["expiration",e.lookup("Uint64")],["sig",e.lookup("Signature")]]),e.struct("Hello",[["ledgerVersion",e.lookup("Uint32")],["overlayVersion",e.lookup("Uint32")],["overlayMinVersion",e.lookup("Uint32")],["networkId",e.lookup("Hash")],["versionStr",e.string(100)],["listeningPort",e.int()],["peerId",e.lookup("NodeId")],["cert",e.lookup("AuthCert")],["nonce",e.lookup("Uint256")]]),e.const("AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED",200),e.struct("Auth",[["flags",e.int()]]),e.enum("IpAddrType",{iPv4:0,iPv6:1}),e.union("PeerAddressIp",{switchOn:e.lookup("IpAddrType"),switchName:"type",switches:[["iPv4","ipv4"],["iPv6","ipv6"]],arms:{ipv4:e.opaque(4),ipv6:e.opaque(16)}}),e.struct("PeerAddress",[["ip",e.lookup("PeerAddressIp")],["port",e.lookup("Uint32")],["numFailures",e.lookup("Uint32")]]),e.enum("MessageType",{errorMsg:0,auth:2,dontHave:3,peers:5,getTxSet:6,txSet:7,generalizedTxSet:17,transaction:8,getScpQuorumset:9,scpQuorumset:10,scpMessage:11,getScpState:12,hello:13,sendMore:16,sendMoreExtended:20,floodAdvert:18,floodDemand:19,timeSlicedSurveyRequest:21,timeSlicedSurveyResponse:22,timeSlicedSurveyStartCollecting:23,timeSlicedSurveyStopCollecting:24}),e.struct("DontHave",[["type",e.lookup("MessageType")],["reqHash",e.lookup("Uint256")]]),e.enum("SurveyMessageCommandType",{timeSlicedSurveyTopology:1}),e.enum("SurveyMessageResponseType",{surveyTopologyResponseV2:2}),e.struct("TimeSlicedSurveyStartCollectingMessage",[["surveyorId",e.lookup("NodeId")],["nonce",e.lookup("Uint32")],["ledgerNum",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyStartCollectingMessage",[["signature",e.lookup("Signature")],["startCollecting",e.lookup("TimeSlicedSurveyStartCollectingMessage")]]),e.struct("TimeSlicedSurveyStopCollectingMessage",[["surveyorId",e.lookup("NodeId")],["nonce",e.lookup("Uint32")],["ledgerNum",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyStopCollectingMessage",[["signature",e.lookup("Signature")],["stopCollecting",e.lookup("TimeSlicedSurveyStopCollectingMessage")]]),e.struct("SurveyRequestMessage",[["surveyorPeerId",e.lookup("NodeId")],["surveyedPeerId",e.lookup("NodeId")],["ledgerNum",e.lookup("Uint32")],["encryptionKey",e.lookup("Curve25519Public")],["commandType",e.lookup("SurveyMessageCommandType")]]),e.struct("TimeSlicedSurveyRequestMessage",[["request",e.lookup("SurveyRequestMessage")],["nonce",e.lookup("Uint32")],["inboundPeersIndex",e.lookup("Uint32")],["outboundPeersIndex",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyRequestMessage",[["requestSignature",e.lookup("Signature")],["request",e.lookup("TimeSlicedSurveyRequestMessage")]]),e.typedef("EncryptedBody",e.varOpaque(64e3)),e.struct("SurveyResponseMessage",[["surveyorPeerId",e.lookup("NodeId")],["surveyedPeerId",e.lookup("NodeId")],["ledgerNum",e.lookup("Uint32")],["commandType",e.lookup("SurveyMessageCommandType")],["encryptedBody",e.lookup("EncryptedBody")]]),e.struct("TimeSlicedSurveyResponseMessage",[["response",e.lookup("SurveyResponseMessage")],["nonce",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyResponseMessage",[["responseSignature",e.lookup("Signature")],["response",e.lookup("TimeSlicedSurveyResponseMessage")]]),e.struct("PeerStats",[["id",e.lookup("NodeId")],["versionStr",e.string(100)],["messagesRead",e.lookup("Uint64")],["messagesWritten",e.lookup("Uint64")],["bytesRead",e.lookup("Uint64")],["bytesWritten",e.lookup("Uint64")],["secondsConnected",e.lookup("Uint64")],["uniqueFloodBytesRecv",e.lookup("Uint64")],["duplicateFloodBytesRecv",e.lookup("Uint64")],["uniqueFetchBytesRecv",e.lookup("Uint64")],["duplicateFetchBytesRecv",e.lookup("Uint64")],["uniqueFloodMessageRecv",e.lookup("Uint64")],["duplicateFloodMessageRecv",e.lookup("Uint64")],["uniqueFetchMessageRecv",e.lookup("Uint64")],["duplicateFetchMessageRecv",e.lookup("Uint64")]]),e.struct("TimeSlicedNodeData",[["addedAuthenticatedPeers",e.lookup("Uint32")],["droppedAuthenticatedPeers",e.lookup("Uint32")],["totalInboundPeerCount",e.lookup("Uint32")],["totalOutboundPeerCount",e.lookup("Uint32")],["p75ScpFirstToSelfLatencyMs",e.lookup("Uint32")],["p75ScpSelfToOtherLatencyMs",e.lookup("Uint32")],["lostSyncCount",e.lookup("Uint32")],["isValidator",e.bool()],["maxInboundPeerCount",e.lookup("Uint32")],["maxOutboundPeerCount",e.lookup("Uint32")]]),e.struct("TimeSlicedPeerData",[["peerStats",e.lookup("PeerStats")],["averageLatencyMs",e.lookup("Uint32")]]),e.typedef("TimeSlicedPeerDataList",e.varArray(e.lookup("TimeSlicedPeerData"),25)),e.struct("TopologyResponseBodyV2",[["inboundPeers",e.lookup("TimeSlicedPeerDataList")],["outboundPeers",e.lookup("TimeSlicedPeerDataList")],["nodeData",e.lookup("TimeSlicedNodeData")]]),e.union("SurveyResponseBody",{switchOn:e.lookup("SurveyMessageResponseType"),switchName:"type",switches:[["surveyTopologyResponseV2","topologyResponseBodyV2"]],arms:{topologyResponseBodyV2:e.lookup("TopologyResponseBodyV2")}}),e.const("TX_ADVERT_VECTOR_MAX_SIZE",1e3),e.typedef("TxAdvertVector",e.varArray(e.lookup("Hash"),e.lookup("TX_ADVERT_VECTOR_MAX_SIZE"))),e.struct("FloodAdvert",[["txHashes",e.lookup("TxAdvertVector")]]),e.const("TX_DEMAND_VECTOR_MAX_SIZE",1e3),e.typedef("TxDemandVector",e.varArray(e.lookup("Hash"),e.lookup("TX_DEMAND_VECTOR_MAX_SIZE"))),e.struct("FloodDemand",[["txHashes",e.lookup("TxDemandVector")]]),e.union("StellarMessage",{switchOn:e.lookup("MessageType"),switchName:"type",switches:[["errorMsg","error"],["hello","hello"],["auth","auth"],["dontHave","dontHave"],["peers","peers"],["getTxSet","txSetHash"],["txSet","txSet"],["generalizedTxSet","generalizedTxSet"],["transaction","transaction"],["timeSlicedSurveyRequest","signedTimeSlicedSurveyRequestMessage"],["timeSlicedSurveyResponse","signedTimeSlicedSurveyResponseMessage"],["timeSlicedSurveyStartCollecting","signedTimeSlicedSurveyStartCollectingMessage"],["timeSlicedSurveyStopCollecting","signedTimeSlicedSurveyStopCollectingMessage"],["getScpQuorumset","qSetHash"],["scpQuorumset","qSet"],["scpMessage","envelope"],["getScpState","getScpLedgerSeq"],["sendMore","sendMoreMessage"],["sendMoreExtended","sendMoreExtendedMessage"],["floodAdvert","floodAdvert"],["floodDemand","floodDemand"]],arms:{error:e.lookup("Error"),hello:e.lookup("Hello"),auth:e.lookup("Auth"),dontHave:e.lookup("DontHave"),peers:e.varArray(e.lookup("PeerAddress"),100),txSetHash:e.lookup("Uint256"),txSet:e.lookup("TransactionSet"),generalizedTxSet:e.lookup("GeneralizedTransactionSet"),transaction:e.lookup("TransactionEnvelope"),signedTimeSlicedSurveyRequestMessage:e.lookup("SignedTimeSlicedSurveyRequestMessage"),signedTimeSlicedSurveyResponseMessage:e.lookup("SignedTimeSlicedSurveyResponseMessage"),signedTimeSlicedSurveyStartCollectingMessage:e.lookup("SignedTimeSlicedSurveyStartCollectingMessage"),signedTimeSlicedSurveyStopCollectingMessage:e.lookup("SignedTimeSlicedSurveyStopCollectingMessage"),qSetHash:e.lookup("Uint256"),qSet:e.lookup("ScpQuorumSet"),envelope:e.lookup("ScpEnvelope"),getScpLedgerSeq:e.lookup("Uint32"),sendMoreMessage:e.lookup("SendMore"),sendMoreExtendedMessage:e.lookup("SendMoreExtended"),floodAdvert:e.lookup("FloodAdvert"),floodDemand:e.lookup("FloodDemand")}}),e.struct("AuthenticatedMessageV0",[["sequence",e.lookup("Uint64")],["message",e.lookup("StellarMessage")],["mac",e.lookup("HmacSha256Mac")]]),e.union("AuthenticatedMessage",{switchOn:e.lookup("Uint32"),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("AuthenticatedMessageV0")}}),e.const("MAX_OPS_PER_TX",100),e.union("LiquidityPoolParameters",{switchOn:e.lookup("LiquidityPoolType"),switchName:"type",switches:[["liquidityPoolConstantProduct","constantProduct"]],arms:{constantProduct:e.lookup("LiquidityPoolConstantProductParameters")}}),e.struct("MuxedAccountMed25519",[["id",e.lookup("Uint64")],["ed25519",e.lookup("Uint256")]]),e.union("MuxedAccount",{switchOn:e.lookup("CryptoKeyType"),switchName:"type",switches:[["keyTypeEd25519","ed25519"],["keyTypeMuxedEd25519","med25519"]],arms:{ed25519:e.lookup("Uint256"),med25519:e.lookup("MuxedAccountMed25519")}}),e.struct("DecoratedSignature",[["hint",e.lookup("SignatureHint")],["signature",e.lookup("Signature")]]),e.enum("OperationType",{createAccount:0,payment:1,pathPaymentStrictReceive:2,manageSellOffer:3,createPassiveSellOffer:4,setOptions:5,changeTrust:6,allowTrust:7,accountMerge:8,inflation:9,manageData:10,bumpSequence:11,manageBuyOffer:12,pathPaymentStrictSend:13,createClaimableBalance:14,claimClaimableBalance:15,beginSponsoringFutureReserves:16,endSponsoringFutureReserves:17,revokeSponsorship:18,clawback:19,clawbackClaimableBalance:20,setTrustLineFlags:21,liquidityPoolDeposit:22,liquidityPoolWithdraw:23,invokeHostFunction:24,extendFootprintTtl:25,restoreFootprint:26}),e.struct("CreateAccountOp",[["destination",e.lookup("AccountId")],["startingBalance",e.lookup("Int64")]]),e.struct("PaymentOp",[["destination",e.lookup("MuxedAccount")],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")]]),e.struct("PathPaymentStrictReceiveOp",[["sendAsset",e.lookup("Asset")],["sendMax",e.lookup("Int64")],["destination",e.lookup("MuxedAccount")],["destAsset",e.lookup("Asset")],["destAmount",e.lookup("Int64")],["path",e.varArray(e.lookup("Asset"),5)]]),e.struct("PathPaymentStrictSendOp",[["sendAsset",e.lookup("Asset")],["sendAmount",e.lookup("Int64")],["destination",e.lookup("MuxedAccount")],["destAsset",e.lookup("Asset")],["destMin",e.lookup("Int64")],["path",e.varArray(e.lookup("Asset"),5)]]),e.struct("ManageSellOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")],["offerId",e.lookup("Int64")]]),e.struct("ManageBuyOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["buyAmount",e.lookup("Int64")],["price",e.lookup("Price")],["offerId",e.lookup("Int64")]]),e.struct("CreatePassiveSellOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")]]),e.struct("SetOptionsOp",[["inflationDest",e.option(e.lookup("AccountId"))],["clearFlags",e.option(e.lookup("Uint32"))],["setFlags",e.option(e.lookup("Uint32"))],["masterWeight",e.option(e.lookup("Uint32"))],["lowThreshold",e.option(e.lookup("Uint32"))],["medThreshold",e.option(e.lookup("Uint32"))],["highThreshold",e.option(e.lookup("Uint32"))],["homeDomain",e.option(e.lookup("String32"))],["signer",e.option(e.lookup("Signer"))]]),e.union("ChangeTrustAsset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"],["assetTypePoolShare","liquidityPool"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12"),liquidityPool:e.lookup("LiquidityPoolParameters")}}),e.struct("ChangeTrustOp",[["line",e.lookup("ChangeTrustAsset")],["limit",e.lookup("Int64")]]),e.struct("AllowTrustOp",[["trustor",e.lookup("AccountId")],["asset",e.lookup("AssetCode")],["authorize",e.lookup("Uint32")]]),e.struct("ManageDataOp",[["dataName",e.lookup("String64")],["dataValue",e.option(e.lookup("DataValue"))]]),e.struct("BumpSequenceOp",[["bumpTo",e.lookup("SequenceNumber")]]),e.struct("CreateClaimableBalanceOp",[["asset",e.lookup("Asset")],["amount",e.lookup("Int64")],["claimants",e.varArray(e.lookup("Claimant"),10)]]),e.struct("ClaimClaimableBalanceOp",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("BeginSponsoringFutureReservesOp",[["sponsoredId",e.lookup("AccountId")]]),e.enum("RevokeSponsorshipType",{revokeSponsorshipLedgerEntry:0,revokeSponsorshipSigner:1}),e.struct("RevokeSponsorshipOpSigner",[["accountId",e.lookup("AccountId")],["signerKey",e.lookup("SignerKey")]]),e.union("RevokeSponsorshipOp",{switchOn:e.lookup("RevokeSponsorshipType"),switchName:"type",switches:[["revokeSponsorshipLedgerEntry","ledgerKey"],["revokeSponsorshipSigner","signer"]],arms:{ledgerKey:e.lookup("LedgerKey"),signer:e.lookup("RevokeSponsorshipOpSigner")}}),e.struct("ClawbackOp",[["asset",e.lookup("Asset")],["from",e.lookup("MuxedAccount")],["amount",e.lookup("Int64")]]),e.struct("ClawbackClaimableBalanceOp",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("SetTrustLineFlagsOp",[["trustor",e.lookup("AccountId")],["asset",e.lookup("Asset")],["clearFlags",e.lookup("Uint32")],["setFlags",e.lookup("Uint32")]]),e.const("LIQUIDITY_POOL_FEE_V18",30),e.struct("LiquidityPoolDepositOp",[["liquidityPoolId",e.lookup("PoolId")],["maxAmountA",e.lookup("Int64")],["maxAmountB",e.lookup("Int64")],["minPrice",e.lookup("Price")],["maxPrice",e.lookup("Price")]]),e.struct("LiquidityPoolWithdrawOp",[["liquidityPoolId",e.lookup("PoolId")],["amount",e.lookup("Int64")],["minAmountA",e.lookup("Int64")],["minAmountB",e.lookup("Int64")]]),e.enum("HostFunctionType",{hostFunctionTypeInvokeContract:0,hostFunctionTypeCreateContract:1,hostFunctionTypeUploadContractWasm:2,hostFunctionTypeCreateContractV2:3}),e.enum("ContractIdPreimageType",{contractIdPreimageFromAddress:0,contractIdPreimageFromAsset:1}),e.struct("ContractIdPreimageFromAddress",[["address",e.lookup("ScAddress")],["salt",e.lookup("Uint256")]]),e.union("ContractIdPreimage",{switchOn:e.lookup("ContractIdPreimageType"),switchName:"type",switches:[["contractIdPreimageFromAddress","fromAddress"],["contractIdPreimageFromAsset","fromAsset"]],arms:{fromAddress:e.lookup("ContractIdPreimageFromAddress"),fromAsset:e.lookup("Asset")}}),e.struct("CreateContractArgs",[["contractIdPreimage",e.lookup("ContractIdPreimage")],["executable",e.lookup("ContractExecutable")]]),e.struct("CreateContractArgsV2",[["contractIdPreimage",e.lookup("ContractIdPreimage")],["executable",e.lookup("ContractExecutable")],["constructorArgs",e.varArray(e.lookup("ScVal"),2147483647)]]),e.struct("InvokeContractArgs",[["contractAddress",e.lookup("ScAddress")],["functionName",e.lookup("ScSymbol")],["args",e.varArray(e.lookup("ScVal"),2147483647)]]),e.union("HostFunction",{switchOn:e.lookup("HostFunctionType"),switchName:"type",switches:[["hostFunctionTypeInvokeContract","invokeContract"],["hostFunctionTypeCreateContract","createContract"],["hostFunctionTypeUploadContractWasm","wasm"],["hostFunctionTypeCreateContractV2","createContractV2"]],arms:{invokeContract:e.lookup("InvokeContractArgs"),createContract:e.lookup("CreateContractArgs"),wasm:e.varOpaque(),createContractV2:e.lookup("CreateContractArgsV2")}}),e.enum("SorobanAuthorizedFunctionType",{sorobanAuthorizedFunctionTypeContractFn:0,sorobanAuthorizedFunctionTypeCreateContractHostFn:1,sorobanAuthorizedFunctionTypeCreateContractV2HostFn:2}),e.union("SorobanAuthorizedFunction",{switchOn:e.lookup("SorobanAuthorizedFunctionType"),switchName:"type",switches:[["sorobanAuthorizedFunctionTypeContractFn","contractFn"],["sorobanAuthorizedFunctionTypeCreateContractHostFn","createContractHostFn"],["sorobanAuthorizedFunctionTypeCreateContractV2HostFn","createContractV2HostFn"]],arms:{contractFn:e.lookup("InvokeContractArgs"),createContractHostFn:e.lookup("CreateContractArgs"),createContractV2HostFn:e.lookup("CreateContractArgsV2")}}),e.struct("SorobanAuthorizedInvocation",[["function",e.lookup("SorobanAuthorizedFunction")],["subInvocations",e.varArray(e.lookup("SorobanAuthorizedInvocation"),2147483647)]]),e.struct("SorobanAddressCredentials",[["address",e.lookup("ScAddress")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["signature",e.lookup("ScVal")]]),e.struct("SorobanDelegateSignature",[["address",e.lookup("ScAddress")],["signature",e.lookup("ScVal")],["nestedDelegates",e.varArray(e.lookup("SorobanDelegateSignature"),2147483647)]]),e.struct("SorobanAddressCredentialsWithDelegates",[["addressCredentials",e.lookup("SorobanAddressCredentials")],["delegates",e.varArray(e.lookup("SorobanDelegateSignature"),2147483647)]]),e.enum("SorobanCredentialsType",{sorobanCredentialsSourceAccount:0,sorobanCredentialsAddress:1,sorobanCredentialsAddressV2:2,sorobanCredentialsAddressWithDelegates:3}),e.union("SorobanCredentials",{switchOn:e.lookup("SorobanCredentialsType"),switchName:"type",switches:[["sorobanCredentialsSourceAccount",e.void()],["sorobanCredentialsAddress","address"],["sorobanCredentialsAddressV2","addressV2"],["sorobanCredentialsAddressWithDelegates","addressWithDelegates"]],arms:{address:e.lookup("SorobanAddressCredentials"),addressV2:e.lookup("SorobanAddressCredentials"),addressWithDelegates:e.lookup("SorobanAddressCredentialsWithDelegates")}}),e.struct("SorobanAuthorizationEntry",[["credentials",e.lookup("SorobanCredentials")],["rootInvocation",e.lookup("SorobanAuthorizedInvocation")]]),e.typedef("SorobanAuthorizationEntries",e.varArray(e.lookup("SorobanAuthorizationEntry"),2147483647)),e.struct("InvokeHostFunctionOp",[["hostFunction",e.lookup("HostFunction")],["auth",e.varArray(e.lookup("SorobanAuthorizationEntry"),2147483647)]]),e.struct("ExtendFootprintTtlOp",[["ext",e.lookup("ExtensionPoint")],["extendTo",e.lookup("Uint32")]]),e.struct("RestoreFootprintOp",[["ext",e.lookup("ExtensionPoint")]]),e.union("OperationBody",{switchOn:e.lookup("OperationType"),switchName:"type",switches:[["createAccount","createAccountOp"],["payment","paymentOp"],["pathPaymentStrictReceive","pathPaymentStrictReceiveOp"],["manageSellOffer","manageSellOfferOp"],["createPassiveSellOffer","createPassiveSellOfferOp"],["setOptions","setOptionsOp"],["changeTrust","changeTrustOp"],["allowTrust","allowTrustOp"],["accountMerge","destination"],["inflation",e.void()],["manageData","manageDataOp"],["bumpSequence","bumpSequenceOp"],["manageBuyOffer","manageBuyOfferOp"],["pathPaymentStrictSend","pathPaymentStrictSendOp"],["createClaimableBalance","createClaimableBalanceOp"],["claimClaimableBalance","claimClaimableBalanceOp"],["beginSponsoringFutureReserves","beginSponsoringFutureReservesOp"],["endSponsoringFutureReserves",e.void()],["revokeSponsorship","revokeSponsorshipOp"],["clawback","clawbackOp"],["clawbackClaimableBalance","clawbackClaimableBalanceOp"],["setTrustLineFlags","setTrustLineFlagsOp"],["liquidityPoolDeposit","liquidityPoolDepositOp"],["liquidityPoolWithdraw","liquidityPoolWithdrawOp"],["invokeHostFunction","invokeHostFunctionOp"],["extendFootprintTtl","extendFootprintTtlOp"],["restoreFootprint","restoreFootprintOp"]],arms:{createAccountOp:e.lookup("CreateAccountOp"),paymentOp:e.lookup("PaymentOp"),pathPaymentStrictReceiveOp:e.lookup("PathPaymentStrictReceiveOp"),manageSellOfferOp:e.lookup("ManageSellOfferOp"),createPassiveSellOfferOp:e.lookup("CreatePassiveSellOfferOp"),setOptionsOp:e.lookup("SetOptionsOp"),changeTrustOp:e.lookup("ChangeTrustOp"),allowTrustOp:e.lookup("AllowTrustOp"),destination:e.lookup("MuxedAccount"),manageDataOp:e.lookup("ManageDataOp"),bumpSequenceOp:e.lookup("BumpSequenceOp"),manageBuyOfferOp:e.lookup("ManageBuyOfferOp"),pathPaymentStrictSendOp:e.lookup("PathPaymentStrictSendOp"),createClaimableBalanceOp:e.lookup("CreateClaimableBalanceOp"),claimClaimableBalanceOp:e.lookup("ClaimClaimableBalanceOp"),beginSponsoringFutureReservesOp:e.lookup("BeginSponsoringFutureReservesOp"),revokeSponsorshipOp:e.lookup("RevokeSponsorshipOp"),clawbackOp:e.lookup("ClawbackOp"),clawbackClaimableBalanceOp:e.lookup("ClawbackClaimableBalanceOp"),setTrustLineFlagsOp:e.lookup("SetTrustLineFlagsOp"),liquidityPoolDepositOp:e.lookup("LiquidityPoolDepositOp"),liquidityPoolWithdrawOp:e.lookup("LiquidityPoolWithdrawOp"),invokeHostFunctionOp:e.lookup("InvokeHostFunctionOp"),extendFootprintTtlOp:e.lookup("ExtendFootprintTtlOp"),restoreFootprintOp:e.lookup("RestoreFootprintOp")}}),e.struct("Operation",[["sourceAccount",e.option(e.lookup("MuxedAccount"))],["body",e.lookup("OperationBody")]]),e.struct("HashIdPreimageOperationId",[["sourceAccount",e.lookup("AccountId")],["seqNum",e.lookup("SequenceNumber")],["opNum",e.lookup("Uint32")]]),e.struct("HashIdPreimageRevokeId",[["sourceAccount",e.lookup("AccountId")],["seqNum",e.lookup("SequenceNumber")],["opNum",e.lookup("Uint32")],["liquidityPoolId",e.lookup("PoolId")],["asset",e.lookup("Asset")]]),e.struct("HashIdPreimageContractId",[["networkId",e.lookup("Hash")],["contractIdPreimage",e.lookup("ContractIdPreimage")]]),e.struct("HashIdPreimageSorobanAuthorization",[["networkId",e.lookup("Hash")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["invocation",e.lookup("SorobanAuthorizedInvocation")]]),e.struct("HashIdPreimageSorobanAuthorizationWithAddress",[["networkId",e.lookup("Hash")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["address",e.lookup("ScAddress")],["invocation",e.lookup("SorobanAuthorizedInvocation")]]),e.union("HashIdPreimage",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeOpId","operationId"],["envelopeTypePoolRevokeOpId","revokeId"],["envelopeTypeContractId","contractId"],["envelopeTypeSorobanAuthorization","sorobanAuthorization"],["envelopeTypeSorobanAuthorizationWithAddress","sorobanAuthorizationWithAddress"]],arms:{operationId:e.lookup("HashIdPreimageOperationId"),revokeId:e.lookup("HashIdPreimageRevokeId"),contractId:e.lookup("HashIdPreimageContractId"),sorobanAuthorization:e.lookup("HashIdPreimageSorobanAuthorization"),sorobanAuthorizationWithAddress:e.lookup("HashIdPreimageSorobanAuthorizationWithAddress")}}),e.enum("MemoType",{memoNone:0,memoText:1,memoId:2,memoHash:3,memoReturn:4}),e.union("Memo",{switchOn:e.lookup("MemoType"),switchName:"type",switches:[["memoNone",e.void()],["memoText","text"],["memoId","id"],["memoHash","hash"],["memoReturn","retHash"]],arms:{text:e.string(28),id:e.lookup("Uint64"),hash:e.lookup("Hash"),retHash:e.lookup("Hash")}}),e.struct("TimeBounds",[["minTime",e.lookup("TimePoint")],["maxTime",e.lookup("TimePoint")]]),e.struct("LedgerBounds",[["minLedger",e.lookup("Uint32")],["maxLedger",e.lookup("Uint32")]]),e.struct("PreconditionsV2",[["timeBounds",e.option(e.lookup("TimeBounds"))],["ledgerBounds",e.option(e.lookup("LedgerBounds"))],["minSeqNum",e.option(e.lookup("SequenceNumber"))],["minSeqAge",e.lookup("Duration")],["minSeqLedgerGap",e.lookup("Uint32")],["extraSigners",e.varArray(e.lookup("SignerKey"),2)]]),e.enum("PreconditionType",{precondNone:0,precondTime:1,precondV2:2}),e.union("Preconditions",{switchOn:e.lookup("PreconditionType"),switchName:"type",switches:[["precondNone",e.void()],["precondTime","timeBounds"],["precondV2","v2"]],arms:{timeBounds:e.lookup("TimeBounds"),v2:e.lookup("PreconditionsV2")}}),e.struct("LedgerFootprint",[["readOnly",e.varArray(e.lookup("LedgerKey"),2147483647)],["readWrite",e.varArray(e.lookup("LedgerKey"),2147483647)]]),e.struct("SorobanResources",[["footprint",e.lookup("LedgerFootprint")],["instructions",e.lookup("Uint32")],["diskReadBytes",e.lookup("Uint32")],["writeBytes",e.lookup("Uint32")]]),e.struct("SorobanResourcesExtV0",[["archivedSorobanEntries",e.varArray(e.lookup("Uint32"),2147483647)]]),e.union("SorobanTransactionDataExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"resourceExt"]],arms:{resourceExt:e.lookup("SorobanResourcesExtV0")}}),e.struct("SorobanTransactionData",[["ext",e.lookup("SorobanTransactionDataExt")],["resources",e.lookup("SorobanResources")],["resourceFee",e.lookup("Int64")]]),e.union("TransactionV0Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionV0",[["sourceAccountEd25519",e.lookup("Uint256")],["fee",e.lookup("Uint32")],["seqNum",e.lookup("SequenceNumber")],["timeBounds",e.option(e.lookup("TimeBounds"))],["memo",e.lookup("Memo")],["operations",e.varArray(e.lookup("Operation"),e.lookup("MAX_OPS_PER_TX"))],["ext",e.lookup("TransactionV0Ext")]]),e.struct("TransactionV0Envelope",[["tx",e.lookup("TransactionV0")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("TransactionExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"sorobanData"]],arms:{sorobanData:e.lookup("SorobanTransactionData")}}),e.struct("Transaction",[["sourceAccount",e.lookup("MuxedAccount")],["fee",e.lookup("Uint32")],["seqNum",e.lookup("SequenceNumber")],["cond",e.lookup("Preconditions")],["memo",e.lookup("Memo")],["operations",e.varArray(e.lookup("Operation"),e.lookup("MAX_OPS_PER_TX"))],["ext",e.lookup("TransactionExt")]]),e.struct("TransactionV1Envelope",[["tx",e.lookup("Transaction")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("FeeBumpTransactionInnerTx",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTx","v1"]],arms:{v1:e.lookup("TransactionV1Envelope")}}),e.union("FeeBumpTransactionExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("FeeBumpTransaction",[["feeSource",e.lookup("MuxedAccount")],["fee",e.lookup("Int64")],["innerTx",e.lookup("FeeBumpTransactionInnerTx")],["ext",e.lookup("FeeBumpTransactionExt")]]),e.struct("FeeBumpTransactionEnvelope",[["tx",e.lookup("FeeBumpTransaction")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("TransactionEnvelope",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTxV0","v0"],["envelopeTypeTx","v1"],["envelopeTypeTxFeeBump","feeBump"]],arms:{v0:e.lookup("TransactionV0Envelope"),v1:e.lookup("TransactionV1Envelope"),feeBump:e.lookup("FeeBumpTransactionEnvelope")}}),e.union("TransactionSignaturePayloadTaggedTransaction",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTx","tx"],["envelopeTypeTxFeeBump","feeBump"]],arms:{tx:e.lookup("Transaction"),feeBump:e.lookup("FeeBumpTransaction")}}),e.struct("TransactionSignaturePayload",[["networkId",e.lookup("Hash")],["taggedTransaction",e.lookup("TransactionSignaturePayloadTaggedTransaction")]]),e.enum("ClaimAtomType",{claimAtomTypeV0:0,claimAtomTypeOrderBook:1,claimAtomTypeLiquidityPool:2}),e.struct("ClaimOfferAtomV0",[["sellerEd25519",e.lookup("Uint256")],["offerId",e.lookup("Int64")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.struct("ClaimOfferAtom",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.struct("ClaimLiquidityAtom",[["liquidityPoolId",e.lookup("PoolId")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.union("ClaimAtom",{switchOn:e.lookup("ClaimAtomType"),switchName:"type",switches:[["claimAtomTypeV0","v0"],["claimAtomTypeOrderBook","orderBook"],["claimAtomTypeLiquidityPool","liquidityPool"]],arms:{v0:e.lookup("ClaimOfferAtomV0"),orderBook:e.lookup("ClaimOfferAtom"),liquidityPool:e.lookup("ClaimLiquidityAtom")}}),e.enum("CreateAccountResultCode",{createAccountSuccess:0,createAccountMalformed:-1,createAccountUnderfunded:-2,createAccountLowReserve:-3,createAccountAlreadyExist:-4}),e.union("CreateAccountResult",{switchOn:e.lookup("CreateAccountResultCode"),switchName:"code",switches:[["createAccountSuccess",e.void()],["createAccountMalformed",e.void()],["createAccountUnderfunded",e.void()],["createAccountLowReserve",e.void()],["createAccountAlreadyExist",e.void()]],arms:{}}),e.enum("PaymentResultCode",{paymentSuccess:0,paymentMalformed:-1,paymentUnderfunded:-2,paymentSrcNoTrust:-3,paymentSrcNotAuthorized:-4,paymentNoDestination:-5,paymentNoTrust:-6,paymentNotAuthorized:-7,paymentLineFull:-8,paymentNoIssuer:-9}),e.union("PaymentResult",{switchOn:e.lookup("PaymentResultCode"),switchName:"code",switches:[["paymentSuccess",e.void()],["paymentMalformed",e.void()],["paymentUnderfunded",e.void()],["paymentSrcNoTrust",e.void()],["paymentSrcNotAuthorized",e.void()],["paymentNoDestination",e.void()],["paymentNoTrust",e.void()],["paymentNotAuthorized",e.void()],["paymentLineFull",e.void()],["paymentNoIssuer",e.void()]],arms:{}}),e.enum("PathPaymentStrictReceiveResultCode",{pathPaymentStrictReceiveSuccess:0,pathPaymentStrictReceiveMalformed:-1,pathPaymentStrictReceiveUnderfunded:-2,pathPaymentStrictReceiveSrcNoTrust:-3,pathPaymentStrictReceiveSrcNotAuthorized:-4,pathPaymentStrictReceiveNoDestination:-5,pathPaymentStrictReceiveNoTrust:-6,pathPaymentStrictReceiveNotAuthorized:-7,pathPaymentStrictReceiveLineFull:-8,pathPaymentStrictReceiveNoIssuer:-9,pathPaymentStrictReceiveTooFewOffers:-10,pathPaymentStrictReceiveOfferCrossSelf:-11,pathPaymentStrictReceiveOverSendmax:-12}),e.struct("SimplePaymentResult",[["destination",e.lookup("AccountId")],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")]]),e.struct("PathPaymentStrictReceiveResultSuccess",[["offers",e.varArray(e.lookup("ClaimAtom"),2147483647)],["last",e.lookup("SimplePaymentResult")]]),e.union("PathPaymentStrictReceiveResult",{switchOn:e.lookup("PathPaymentStrictReceiveResultCode"),switchName:"code",switches:[["pathPaymentStrictReceiveSuccess","success"],["pathPaymentStrictReceiveMalformed",e.void()],["pathPaymentStrictReceiveUnderfunded",e.void()],["pathPaymentStrictReceiveSrcNoTrust",e.void()],["pathPaymentStrictReceiveSrcNotAuthorized",e.void()],["pathPaymentStrictReceiveNoDestination",e.void()],["pathPaymentStrictReceiveNoTrust",e.void()],["pathPaymentStrictReceiveNotAuthorized",e.void()],["pathPaymentStrictReceiveLineFull",e.void()],["pathPaymentStrictReceiveNoIssuer","noIssuer"],["pathPaymentStrictReceiveTooFewOffers",e.void()],["pathPaymentStrictReceiveOfferCrossSelf",e.void()],["pathPaymentStrictReceiveOverSendmax",e.void()]],arms:{success:e.lookup("PathPaymentStrictReceiveResultSuccess"),noIssuer:e.lookup("Asset")}}),e.enum("PathPaymentStrictSendResultCode",{pathPaymentStrictSendSuccess:0,pathPaymentStrictSendMalformed:-1,pathPaymentStrictSendUnderfunded:-2,pathPaymentStrictSendSrcNoTrust:-3,pathPaymentStrictSendSrcNotAuthorized:-4,pathPaymentStrictSendNoDestination:-5,pathPaymentStrictSendNoTrust:-6,pathPaymentStrictSendNotAuthorized:-7,pathPaymentStrictSendLineFull:-8,pathPaymentStrictSendNoIssuer:-9,pathPaymentStrictSendTooFewOffers:-10,pathPaymentStrictSendOfferCrossSelf:-11,pathPaymentStrictSendUnderDestmin:-12}),e.struct("PathPaymentStrictSendResultSuccess",[["offers",e.varArray(e.lookup("ClaimAtom"),2147483647)],["last",e.lookup("SimplePaymentResult")]]),e.union("PathPaymentStrictSendResult",{switchOn:e.lookup("PathPaymentStrictSendResultCode"),switchName:"code",switches:[["pathPaymentStrictSendSuccess","success"],["pathPaymentStrictSendMalformed",e.void()],["pathPaymentStrictSendUnderfunded",e.void()],["pathPaymentStrictSendSrcNoTrust",e.void()],["pathPaymentStrictSendSrcNotAuthorized",e.void()],["pathPaymentStrictSendNoDestination",e.void()],["pathPaymentStrictSendNoTrust",e.void()],["pathPaymentStrictSendNotAuthorized",e.void()],["pathPaymentStrictSendLineFull",e.void()],["pathPaymentStrictSendNoIssuer","noIssuer"],["pathPaymentStrictSendTooFewOffers",e.void()],["pathPaymentStrictSendOfferCrossSelf",e.void()],["pathPaymentStrictSendUnderDestmin",e.void()]],arms:{success:e.lookup("PathPaymentStrictSendResultSuccess"),noIssuer:e.lookup("Asset")}}),e.enum("ManageSellOfferResultCode",{manageSellOfferSuccess:0,manageSellOfferMalformed:-1,manageSellOfferSellNoTrust:-2,manageSellOfferBuyNoTrust:-3,manageSellOfferSellNotAuthorized:-4,manageSellOfferBuyNotAuthorized:-5,manageSellOfferLineFull:-6,manageSellOfferUnderfunded:-7,manageSellOfferCrossSelf:-8,manageSellOfferSellNoIssuer:-9,manageSellOfferBuyNoIssuer:-10,manageSellOfferNotFound:-11,manageSellOfferLowReserve:-12}),e.enum("ManageOfferEffect",{manageOfferCreated:0,manageOfferUpdated:1,manageOfferDeleted:2}),e.union("ManageOfferSuccessResultOffer",{switchOn:e.lookup("ManageOfferEffect"),switchName:"effect",switches:[["manageOfferCreated","offer"],["manageOfferUpdated","offer"],["manageOfferDeleted",e.void()]],arms:{offer:e.lookup("OfferEntry")}}),e.struct("ManageOfferSuccessResult",[["offersClaimed",e.varArray(e.lookup("ClaimAtom"),2147483647)],["offer",e.lookup("ManageOfferSuccessResultOffer")]]),e.union("ManageSellOfferResult",{switchOn:e.lookup("ManageSellOfferResultCode"),switchName:"code",switches:[["manageSellOfferSuccess","success"],["manageSellOfferMalformed",e.void()],["manageSellOfferSellNoTrust",e.void()],["manageSellOfferBuyNoTrust",e.void()],["manageSellOfferSellNotAuthorized",e.void()],["manageSellOfferBuyNotAuthorized",e.void()],["manageSellOfferLineFull",e.void()],["manageSellOfferUnderfunded",e.void()],["manageSellOfferCrossSelf",e.void()],["manageSellOfferSellNoIssuer",e.void()],["manageSellOfferBuyNoIssuer",e.void()],["manageSellOfferNotFound",e.void()],["manageSellOfferLowReserve",e.void()]],arms:{success:e.lookup("ManageOfferSuccessResult")}}),e.enum("ManageBuyOfferResultCode",{manageBuyOfferSuccess:0,manageBuyOfferMalformed:-1,manageBuyOfferSellNoTrust:-2,manageBuyOfferBuyNoTrust:-3,manageBuyOfferSellNotAuthorized:-4,manageBuyOfferBuyNotAuthorized:-5,manageBuyOfferLineFull:-6,manageBuyOfferUnderfunded:-7,manageBuyOfferCrossSelf:-8,manageBuyOfferSellNoIssuer:-9,manageBuyOfferBuyNoIssuer:-10,manageBuyOfferNotFound:-11,manageBuyOfferLowReserve:-12}),e.union("ManageBuyOfferResult",{switchOn:e.lookup("ManageBuyOfferResultCode"),switchName:"code",switches:[["manageBuyOfferSuccess","success"],["manageBuyOfferMalformed",e.void()],["manageBuyOfferSellNoTrust",e.void()],["manageBuyOfferBuyNoTrust",e.void()],["manageBuyOfferSellNotAuthorized",e.void()],["manageBuyOfferBuyNotAuthorized",e.void()],["manageBuyOfferLineFull",e.void()],["manageBuyOfferUnderfunded",e.void()],["manageBuyOfferCrossSelf",e.void()],["manageBuyOfferSellNoIssuer",e.void()],["manageBuyOfferBuyNoIssuer",e.void()],["manageBuyOfferNotFound",e.void()],["manageBuyOfferLowReserve",e.void()]],arms:{success:e.lookup("ManageOfferSuccessResult")}}),e.enum("SetOptionsResultCode",{setOptionsSuccess:0,setOptionsLowReserve:-1,setOptionsTooManySigners:-2,setOptionsBadFlags:-3,setOptionsInvalidInflation:-4,setOptionsCantChange:-5,setOptionsUnknownFlag:-6,setOptionsThresholdOutOfRange:-7,setOptionsBadSigner:-8,setOptionsInvalidHomeDomain:-9,setOptionsAuthRevocableRequired:-10}),e.union("SetOptionsResult",{switchOn:e.lookup("SetOptionsResultCode"),switchName:"code",switches:[["setOptionsSuccess",e.void()],["setOptionsLowReserve",e.void()],["setOptionsTooManySigners",e.void()],["setOptionsBadFlags",e.void()],["setOptionsInvalidInflation",e.void()],["setOptionsCantChange",e.void()],["setOptionsUnknownFlag",e.void()],["setOptionsThresholdOutOfRange",e.void()],["setOptionsBadSigner",e.void()],["setOptionsInvalidHomeDomain",e.void()],["setOptionsAuthRevocableRequired",e.void()]],arms:{}}),e.enum("ChangeTrustResultCode",{changeTrustSuccess:0,changeTrustMalformed:-1,changeTrustNoIssuer:-2,changeTrustInvalidLimit:-3,changeTrustLowReserve:-4,changeTrustSelfNotAllowed:-5,changeTrustTrustLineMissing:-6,changeTrustCannotDelete:-7,changeTrustNotAuthMaintainLiabilities:-8}),e.union("ChangeTrustResult",{switchOn:e.lookup("ChangeTrustResultCode"),switchName:"code",switches:[["changeTrustSuccess",e.void()],["changeTrustMalformed",e.void()],["changeTrustNoIssuer",e.void()],["changeTrustInvalidLimit",e.void()],["changeTrustLowReserve",e.void()],["changeTrustSelfNotAllowed",e.void()],["changeTrustTrustLineMissing",e.void()],["changeTrustCannotDelete",e.void()],["changeTrustNotAuthMaintainLiabilities",e.void()]],arms:{}}),e.enum("AllowTrustResultCode",{allowTrustSuccess:0,allowTrustMalformed:-1,allowTrustNoTrustLine:-2,allowTrustTrustNotRequired:-3,allowTrustCantRevoke:-4,allowTrustSelfNotAllowed:-5,allowTrustLowReserve:-6}),e.union("AllowTrustResult",{switchOn:e.lookup("AllowTrustResultCode"),switchName:"code",switches:[["allowTrustSuccess",e.void()],["allowTrustMalformed",e.void()],["allowTrustNoTrustLine",e.void()],["allowTrustTrustNotRequired",e.void()],["allowTrustCantRevoke",e.void()],["allowTrustSelfNotAllowed",e.void()],["allowTrustLowReserve",e.void()]],arms:{}}),e.enum("AccountMergeResultCode",{accountMergeSuccess:0,accountMergeMalformed:-1,accountMergeNoAccount:-2,accountMergeImmutableSet:-3,accountMergeHasSubEntries:-4,accountMergeSeqnumTooFar:-5,accountMergeDestFull:-6,accountMergeIsSponsor:-7}),e.union("AccountMergeResult",{switchOn:e.lookup("AccountMergeResultCode"),switchName:"code",switches:[["accountMergeSuccess","sourceAccountBalance"],["accountMergeMalformed",e.void()],["accountMergeNoAccount",e.void()],["accountMergeImmutableSet",e.void()],["accountMergeHasSubEntries",e.void()],["accountMergeSeqnumTooFar",e.void()],["accountMergeDestFull",e.void()],["accountMergeIsSponsor",e.void()]],arms:{sourceAccountBalance:e.lookup("Int64")}}),e.enum("InflationResultCode",{inflationSuccess:0,inflationNotTime:-1}),e.struct("InflationPayout",[["destination",e.lookup("AccountId")],["amount",e.lookup("Int64")]]),e.union("InflationResult",{switchOn:e.lookup("InflationResultCode"),switchName:"code",switches:[["inflationSuccess","payouts"],["inflationNotTime",e.void()]],arms:{payouts:e.varArray(e.lookup("InflationPayout"),2147483647)}}),e.enum("ManageDataResultCode",{manageDataSuccess:0,manageDataNotSupportedYet:-1,manageDataNameNotFound:-2,manageDataLowReserve:-3,manageDataInvalidName:-4}),e.union("ManageDataResult",{switchOn:e.lookup("ManageDataResultCode"),switchName:"code",switches:[["manageDataSuccess",e.void()],["manageDataNotSupportedYet",e.void()],["manageDataNameNotFound",e.void()],["manageDataLowReserve",e.void()],["manageDataInvalidName",e.void()]],arms:{}}),e.enum("BumpSequenceResultCode",{bumpSequenceSuccess:0,bumpSequenceBadSeq:-1}),e.union("BumpSequenceResult",{switchOn:e.lookup("BumpSequenceResultCode"),switchName:"code",switches:[["bumpSequenceSuccess",e.void()],["bumpSequenceBadSeq",e.void()]],arms:{}}),e.enum("CreateClaimableBalanceResultCode",{createClaimableBalanceSuccess:0,createClaimableBalanceMalformed:-1,createClaimableBalanceLowReserve:-2,createClaimableBalanceNoTrust:-3,createClaimableBalanceNotAuthorized:-4,createClaimableBalanceUnderfunded:-5}),e.union("CreateClaimableBalanceResult",{switchOn:e.lookup("CreateClaimableBalanceResultCode"),switchName:"code",switches:[["createClaimableBalanceSuccess","balanceId"],["createClaimableBalanceMalformed",e.void()],["createClaimableBalanceLowReserve",e.void()],["createClaimableBalanceNoTrust",e.void()],["createClaimableBalanceNotAuthorized",e.void()],["createClaimableBalanceUnderfunded",e.void()]],arms:{balanceId:e.lookup("ClaimableBalanceId")}}),e.enum("ClaimClaimableBalanceResultCode",{claimClaimableBalanceSuccess:0,claimClaimableBalanceDoesNotExist:-1,claimClaimableBalanceCannotClaim:-2,claimClaimableBalanceLineFull:-3,claimClaimableBalanceNoTrust:-4,claimClaimableBalanceNotAuthorized:-5,claimClaimableBalanceTrustlineFrozen:-6}),e.union("ClaimClaimableBalanceResult",{switchOn:e.lookup("ClaimClaimableBalanceResultCode"),switchName:"code",switches:[["claimClaimableBalanceSuccess",e.void()],["claimClaimableBalanceDoesNotExist",e.void()],["claimClaimableBalanceCannotClaim",e.void()],["claimClaimableBalanceLineFull",e.void()],["claimClaimableBalanceNoTrust",e.void()],["claimClaimableBalanceNotAuthorized",e.void()],["claimClaimableBalanceTrustlineFrozen",e.void()]],arms:{}}),e.enum("BeginSponsoringFutureReservesResultCode",{beginSponsoringFutureReservesSuccess:0,beginSponsoringFutureReservesMalformed:-1,beginSponsoringFutureReservesAlreadySponsored:-2,beginSponsoringFutureReservesRecursive:-3}),e.union("BeginSponsoringFutureReservesResult",{switchOn:e.lookup("BeginSponsoringFutureReservesResultCode"),switchName:"code",switches:[["beginSponsoringFutureReservesSuccess",e.void()],["beginSponsoringFutureReservesMalformed",e.void()],["beginSponsoringFutureReservesAlreadySponsored",e.void()],["beginSponsoringFutureReservesRecursive",e.void()]],arms:{}}),e.enum("EndSponsoringFutureReservesResultCode",{endSponsoringFutureReservesSuccess:0,endSponsoringFutureReservesNotSponsored:-1}),e.union("EndSponsoringFutureReservesResult",{switchOn:e.lookup("EndSponsoringFutureReservesResultCode"),switchName:"code",switches:[["endSponsoringFutureReservesSuccess",e.void()],["endSponsoringFutureReservesNotSponsored",e.void()]],arms:{}}),e.enum("RevokeSponsorshipResultCode",{revokeSponsorshipSuccess:0,revokeSponsorshipDoesNotExist:-1,revokeSponsorshipNotSponsor:-2,revokeSponsorshipLowReserve:-3,revokeSponsorshipOnlyTransferable:-4,revokeSponsorshipMalformed:-5}),e.union("RevokeSponsorshipResult",{switchOn:e.lookup("RevokeSponsorshipResultCode"),switchName:"code",switches:[["revokeSponsorshipSuccess",e.void()],["revokeSponsorshipDoesNotExist",e.void()],["revokeSponsorshipNotSponsor",e.void()],["revokeSponsorshipLowReserve",e.void()],["revokeSponsorshipOnlyTransferable",e.void()],["revokeSponsorshipMalformed",e.void()]],arms:{}}),e.enum("ClawbackResultCode",{clawbackSuccess:0,clawbackMalformed:-1,clawbackNotClawbackEnabled:-2,clawbackNoTrust:-3,clawbackUnderfunded:-4}),e.union("ClawbackResult",{switchOn:e.lookup("ClawbackResultCode"),switchName:"code",switches:[["clawbackSuccess",e.void()],["clawbackMalformed",e.void()],["clawbackNotClawbackEnabled",e.void()],["clawbackNoTrust",e.void()],["clawbackUnderfunded",e.void()]],arms:{}}),e.enum("ClawbackClaimableBalanceResultCode",{clawbackClaimableBalanceSuccess:0,clawbackClaimableBalanceDoesNotExist:-1,clawbackClaimableBalanceNotIssuer:-2,clawbackClaimableBalanceNotClawbackEnabled:-3}),e.union("ClawbackClaimableBalanceResult",{switchOn:e.lookup("ClawbackClaimableBalanceResultCode"),switchName:"code",switches:[["clawbackClaimableBalanceSuccess",e.void()],["clawbackClaimableBalanceDoesNotExist",e.void()],["clawbackClaimableBalanceNotIssuer",e.void()],["clawbackClaimableBalanceNotClawbackEnabled",e.void()]],arms:{}}),e.enum("SetTrustLineFlagsResultCode",{setTrustLineFlagsSuccess:0,setTrustLineFlagsMalformed:-1,setTrustLineFlagsNoTrustLine:-2,setTrustLineFlagsCantRevoke:-3,setTrustLineFlagsInvalidState:-4,setTrustLineFlagsLowReserve:-5}),e.union("SetTrustLineFlagsResult",{switchOn:e.lookup("SetTrustLineFlagsResultCode"),switchName:"code",switches:[["setTrustLineFlagsSuccess",e.void()],["setTrustLineFlagsMalformed",e.void()],["setTrustLineFlagsNoTrustLine",e.void()],["setTrustLineFlagsCantRevoke",e.void()],["setTrustLineFlagsInvalidState",e.void()],["setTrustLineFlagsLowReserve",e.void()]],arms:{}}),e.enum("LiquidityPoolDepositResultCode",{liquidityPoolDepositSuccess:0,liquidityPoolDepositMalformed:-1,liquidityPoolDepositNoTrust:-2,liquidityPoolDepositNotAuthorized:-3,liquidityPoolDepositUnderfunded:-4,liquidityPoolDepositLineFull:-5,liquidityPoolDepositBadPrice:-6,liquidityPoolDepositPoolFull:-7,liquidityPoolDepositTrustlineFrozen:-8}),e.union("LiquidityPoolDepositResult",{switchOn:e.lookup("LiquidityPoolDepositResultCode"),switchName:"code",switches:[["liquidityPoolDepositSuccess",e.void()],["liquidityPoolDepositMalformed",e.void()],["liquidityPoolDepositNoTrust",e.void()],["liquidityPoolDepositNotAuthorized",e.void()],["liquidityPoolDepositUnderfunded",e.void()],["liquidityPoolDepositLineFull",e.void()],["liquidityPoolDepositBadPrice",e.void()],["liquidityPoolDepositPoolFull",e.void()],["liquidityPoolDepositTrustlineFrozen",e.void()]],arms:{}}),e.enum("LiquidityPoolWithdrawResultCode",{liquidityPoolWithdrawSuccess:0,liquidityPoolWithdrawMalformed:-1,liquidityPoolWithdrawNoTrust:-2,liquidityPoolWithdrawUnderfunded:-3,liquidityPoolWithdrawLineFull:-4,liquidityPoolWithdrawUnderMinimum:-5,liquidityPoolWithdrawTrustlineFrozen:-6}),e.union("LiquidityPoolWithdrawResult",{switchOn:e.lookup("LiquidityPoolWithdrawResultCode"),switchName:"code",switches:[["liquidityPoolWithdrawSuccess",e.void()],["liquidityPoolWithdrawMalformed",e.void()],["liquidityPoolWithdrawNoTrust",e.void()],["liquidityPoolWithdrawUnderfunded",e.void()],["liquidityPoolWithdrawLineFull",e.void()],["liquidityPoolWithdrawUnderMinimum",e.void()],["liquidityPoolWithdrawTrustlineFrozen",e.void()]],arms:{}}),e.enum("InvokeHostFunctionResultCode",{invokeHostFunctionSuccess:0,invokeHostFunctionMalformed:-1,invokeHostFunctionTrapped:-2,invokeHostFunctionResourceLimitExceeded:-3,invokeHostFunctionEntryArchived:-4,invokeHostFunctionInsufficientRefundableFee:-5}),e.union("InvokeHostFunctionResult",{switchOn:e.lookup("InvokeHostFunctionResultCode"),switchName:"code",switches:[["invokeHostFunctionSuccess","success"],["invokeHostFunctionMalformed",e.void()],["invokeHostFunctionTrapped",e.void()],["invokeHostFunctionResourceLimitExceeded",e.void()],["invokeHostFunctionEntryArchived",e.void()],["invokeHostFunctionInsufficientRefundableFee",e.void()]],arms:{success:e.lookup("Hash")}}),e.enum("ExtendFootprintTtlResultCode",{extendFootprintTtlSuccess:0,extendFootprintTtlMalformed:-1,extendFootprintTtlResourceLimitExceeded:-2,extendFootprintTtlInsufficientRefundableFee:-3}),e.union("ExtendFootprintTtlResult",{switchOn:e.lookup("ExtendFootprintTtlResultCode"),switchName:"code",switches:[["extendFootprintTtlSuccess",e.void()],["extendFootprintTtlMalformed",e.void()],["extendFootprintTtlResourceLimitExceeded",e.void()],["extendFootprintTtlInsufficientRefundableFee",e.void()]],arms:{}}),e.enum("RestoreFootprintResultCode",{restoreFootprintSuccess:0,restoreFootprintMalformed:-1,restoreFootprintResourceLimitExceeded:-2,restoreFootprintInsufficientRefundableFee:-3}),e.union("RestoreFootprintResult",{switchOn:e.lookup("RestoreFootprintResultCode"),switchName:"code",switches:[["restoreFootprintSuccess",e.void()],["restoreFootprintMalformed",e.void()],["restoreFootprintResourceLimitExceeded",e.void()],["restoreFootprintInsufficientRefundableFee",e.void()]],arms:{}}),e.enum("OperationResultCode",{opInner:0,opBadAuth:-1,opNoAccount:-2,opNotSupported:-3,opTooManySubentries:-4,opExceededWorkLimit:-5,opTooManySponsoring:-6}),e.union("OperationResultTr",{switchOn:e.lookup("OperationType"),switchName:"type",switches:[["createAccount","createAccountResult"],["payment","paymentResult"],["pathPaymentStrictReceive","pathPaymentStrictReceiveResult"],["manageSellOffer","manageSellOfferResult"],["createPassiveSellOffer","createPassiveSellOfferResult"],["setOptions","setOptionsResult"],["changeTrust","changeTrustResult"],["allowTrust","allowTrustResult"],["accountMerge","accountMergeResult"],["inflation","inflationResult"],["manageData","manageDataResult"],["bumpSequence","bumpSeqResult"],["manageBuyOffer","manageBuyOfferResult"],["pathPaymentStrictSend","pathPaymentStrictSendResult"],["createClaimableBalance","createClaimableBalanceResult"],["claimClaimableBalance","claimClaimableBalanceResult"],["beginSponsoringFutureReserves","beginSponsoringFutureReservesResult"],["endSponsoringFutureReserves","endSponsoringFutureReservesResult"],["revokeSponsorship","revokeSponsorshipResult"],["clawback","clawbackResult"],["clawbackClaimableBalance","clawbackClaimableBalanceResult"],["setTrustLineFlags","setTrustLineFlagsResult"],["liquidityPoolDeposit","liquidityPoolDepositResult"],["liquidityPoolWithdraw","liquidityPoolWithdrawResult"],["invokeHostFunction","invokeHostFunctionResult"],["extendFootprintTtl","extendFootprintTtlResult"],["restoreFootprint","restoreFootprintResult"]],arms:{createAccountResult:e.lookup("CreateAccountResult"),paymentResult:e.lookup("PaymentResult"),pathPaymentStrictReceiveResult:e.lookup("PathPaymentStrictReceiveResult"),manageSellOfferResult:e.lookup("ManageSellOfferResult"),createPassiveSellOfferResult:e.lookup("ManageSellOfferResult"),setOptionsResult:e.lookup("SetOptionsResult"),changeTrustResult:e.lookup("ChangeTrustResult"),allowTrustResult:e.lookup("AllowTrustResult"),accountMergeResult:e.lookup("AccountMergeResult"),inflationResult:e.lookup("InflationResult"),manageDataResult:e.lookup("ManageDataResult"),bumpSeqResult:e.lookup("BumpSequenceResult"),manageBuyOfferResult:e.lookup("ManageBuyOfferResult"),pathPaymentStrictSendResult:e.lookup("PathPaymentStrictSendResult"),createClaimableBalanceResult:e.lookup("CreateClaimableBalanceResult"),claimClaimableBalanceResult:e.lookup("ClaimClaimableBalanceResult"),beginSponsoringFutureReservesResult:e.lookup("BeginSponsoringFutureReservesResult"),endSponsoringFutureReservesResult:e.lookup("EndSponsoringFutureReservesResult"),revokeSponsorshipResult:e.lookup("RevokeSponsorshipResult"),clawbackResult:e.lookup("ClawbackResult"),clawbackClaimableBalanceResult:e.lookup("ClawbackClaimableBalanceResult"),setTrustLineFlagsResult:e.lookup("SetTrustLineFlagsResult"),liquidityPoolDepositResult:e.lookup("LiquidityPoolDepositResult"),liquidityPoolWithdrawResult:e.lookup("LiquidityPoolWithdrawResult"),invokeHostFunctionResult:e.lookup("InvokeHostFunctionResult"),extendFootprintTtlResult:e.lookup("ExtendFootprintTtlResult"),restoreFootprintResult:e.lookup("RestoreFootprintResult")}}),e.union("OperationResult",{switchOn:e.lookup("OperationResultCode"),switchName:"code",switches:[["opInner","tr"],["opBadAuth",e.void()],["opNoAccount",e.void()],["opNotSupported",e.void()],["opTooManySubentries",e.void()],["opExceededWorkLimit",e.void()],["opTooManySponsoring",e.void()]],arms:{tr:e.lookup("OperationResultTr")}}),e.enum("TransactionResultCode",{txFeeBumpInnerSuccess:1,txSuccess:0,txFailed:-1,txTooEarly:-2,txTooLate:-3,txMissingOperation:-4,txBadSeq:-5,txBadAuth:-6,txInsufficientBalance:-7,txNoAccount:-8,txInsufficientFee:-9,txBadAuthExtra:-10,txInternalError:-11,txNotSupported:-12,txFeeBumpInnerFailed:-13,txBadSponsorship:-14,txBadMinSeqAgeOrGap:-15,txMalformed:-16,txSorobanInvalid:-17,txFrozenKeyAccessed:-18}),e.union("InnerTransactionResultResult",{switchOn:e.lookup("TransactionResultCode"),switchName:"code",switches:[["txSuccess","results"],["txFailed","results"],["txTooEarly",e.void()],["txTooLate",e.void()],["txMissingOperation",e.void()],["txBadSeq",e.void()],["txBadAuth",e.void()],["txInsufficientBalance",e.void()],["txNoAccount",e.void()],["txInsufficientFee",e.void()],["txBadAuthExtra",e.void()],["txInternalError",e.void()],["txNotSupported",e.void()],["txBadSponsorship",e.void()],["txBadMinSeqAgeOrGap",e.void()],["txMalformed",e.void()],["txSorobanInvalid",e.void()],["txFrozenKeyAccessed",e.void()]],arms:{results:e.varArray(e.lookup("OperationResult"),2147483647)}}),e.union("InnerTransactionResultExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("InnerTransactionResult",[["feeCharged",e.lookup("Int64")],["result",e.lookup("InnerTransactionResultResult")],["ext",e.lookup("InnerTransactionResultExt")]]),e.struct("InnerTransactionResultPair",[["transactionHash",e.lookup("Hash")],["result",e.lookup("InnerTransactionResult")]]),e.union("TransactionResultResult",{switchOn:e.lookup("TransactionResultCode"),switchName:"code",switches:[["txFeeBumpInnerSuccess","innerResultPair"],["txFeeBumpInnerFailed","innerResultPair"],["txSuccess","results"],["txFailed","results"],["txTooEarly",e.void()],["txTooLate",e.void()],["txMissingOperation",e.void()],["txBadSeq",e.void()],["txBadAuth",e.void()],["txInsufficientBalance",e.void()],["txNoAccount",e.void()],["txInsufficientFee",e.void()],["txBadAuthExtra",e.void()],["txInternalError",e.void()],["txNotSupported",e.void()],["txBadSponsorship",e.void()],["txBadMinSeqAgeOrGap",e.void()],["txMalformed",e.void()],["txSorobanInvalid",e.void()],["txFrozenKeyAccessed",e.void()]],arms:{innerResultPair:e.lookup("InnerTransactionResultPair"),results:e.varArray(e.lookup("OperationResult"),2147483647)}}),e.union("TransactionResultExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionResult",[["feeCharged",e.lookup("Int64")],["result",e.lookup("TransactionResultResult")],["ext",e.lookup("TransactionResultExt")]]),e.typedef("Hash",e.opaque(32)),e.typedef("Uint256",e.opaque(32)),e.typedef("Uint32",e.uint()),e.typedef("Int32",e.int()),e.typedef("Uint64",e.uhyper()),e.typedef("Int64",e.hyper()),e.typedef("TimePoint",e.lookup("Uint64")),e.typedef("Duration",e.lookup("Uint64")),e.union("ExtensionPoint",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.enum("CryptoKeyType",{keyTypeEd25519:0,keyTypePreAuthTx:1,keyTypeHashX:2,keyTypeEd25519SignedPayload:3,keyTypeMuxedEd25519:256}),e.enum("PublicKeyType",{publicKeyTypeEd25519:0}),e.enum("SignerKeyType",{signerKeyTypeEd25519:0,signerKeyTypePreAuthTx:1,signerKeyTypeHashX:2,signerKeyTypeEd25519SignedPayload:3}),e.union("PublicKey",{switchOn:e.lookup("PublicKeyType"),switchName:"type",switches:[["publicKeyTypeEd25519","ed25519"]],arms:{ed25519:e.lookup("Uint256")}}),e.struct("SignerKeyEd25519SignedPayload",[["ed25519",e.lookup("Uint256")],["payload",e.varOpaque(64)]]),e.union("SignerKey",{switchOn:e.lookup("SignerKeyType"),switchName:"type",switches:[["signerKeyTypeEd25519","ed25519"],["signerKeyTypePreAuthTx","preAuthTx"],["signerKeyTypeHashX","hashX"],["signerKeyTypeEd25519SignedPayload","ed25519SignedPayload"]],arms:{ed25519:e.lookup("Uint256"),preAuthTx:e.lookup("Uint256"),hashX:e.lookup("Uint256"),ed25519SignedPayload:e.lookup("SignerKeyEd25519SignedPayload")}}),e.typedef("Signature",e.varOpaque(64)),e.typedef("SignatureHint",e.opaque(4)),e.typedef("NodeId",e.lookup("PublicKey")),e.typedef("AccountId",e.lookup("PublicKey")),e.typedef("ContractId",e.lookup("Hash")),e.struct("Curve25519Secret",[["key",e.opaque(32)]]),e.struct("Curve25519Public",[["key",e.opaque(32)]]),e.struct("HmacSha256Key",[["key",e.opaque(32)]]),e.struct("HmacSha256Mac",[["mac",e.opaque(32)]]),e.struct("ShortHashSeed",[["seed",e.opaque(16)]]),e.enum("BinaryFuseFilterType",{binaryFuseFilter8Bit:0,binaryFuseFilter16Bit:1,binaryFuseFilter32Bit:2}),e.struct("SerializedBinaryFuseFilter",[["type",e.lookup("BinaryFuseFilterType")],["inputHashSeed",e.lookup("ShortHashSeed")],["filterSeed",e.lookup("ShortHashSeed")],["segmentLength",e.lookup("Uint32")],["segementLengthMask",e.lookup("Uint32")],["segmentCount",e.lookup("Uint32")],["segmentCountLength",e.lookup("Uint32")],["fingerprintLength",e.lookup("Uint32")],["fingerprints",e.varOpaque()]]),e.typedef("PoolId",e.lookup("Hash")),e.enum("ClaimableBalanceIdType",{claimableBalanceIdTypeV0:0}),e.union("ClaimableBalanceId",{switchOn:e.lookup("ClaimableBalanceIdType"),switchName:"type",switches:[["claimableBalanceIdTypeV0","v0"]],arms:{v0:e.lookup("Hash")}}),e.enum("ScValType",{scvBool:0,scvVoid:1,scvError:2,scvU32:3,scvI32:4,scvU64:5,scvI64:6,scvTimepoint:7,scvDuration:8,scvU128:9,scvI128:10,scvU256:11,scvI256:12,scvBytes:13,scvString:14,scvSymbol:15,scvVec:16,scvMap:17,scvAddress:18,scvContractInstance:19,scvLedgerKeyContractInstance:20,scvLedgerKeyNonce:21}),e.enum("ScErrorType",{sceContract:0,sceWasmVm:1,sceContext:2,sceStorage:3,sceObject:4,sceCrypto:5,sceEvents:6,sceBudget:7,sceValue:8,sceAuth:9}),e.enum("ScErrorCode",{scecArithDomain:0,scecIndexBounds:1,scecInvalidInput:2,scecMissingValue:3,scecExistingValue:4,scecExceededLimit:5,scecInvalidAction:6,scecInternalError:7,scecUnexpectedType:8,scecUnexpectedSize:9}),e.union("ScError",{switchOn:e.lookup("ScErrorType"),switchName:"type",switches:[["sceContract","contractCode"],["sceWasmVm","code"],["sceContext","code"],["sceStorage","code"],["sceObject","code"],["sceCrypto","code"],["sceEvents","code"],["sceBudget","code"],["sceValue","code"],["sceAuth","code"]],arms:{contractCode:e.lookup("Uint32"),code:e.lookup("ScErrorCode")}}),e.struct("UInt128Parts",[["hi",e.lookup("Uint64")],["lo",e.lookup("Uint64")]]),e.struct("Int128Parts",[["hi",e.lookup("Int64")],["lo",e.lookup("Uint64")]]),e.struct("UInt256Parts",[["hiHi",e.lookup("Uint64")],["hiLo",e.lookup("Uint64")],["loHi",e.lookup("Uint64")],["loLo",e.lookup("Uint64")]]),e.struct("Int256Parts",[["hiHi",e.lookup("Int64")],["hiLo",e.lookup("Uint64")],["loHi",e.lookup("Uint64")],["loLo",e.lookup("Uint64")]]),e.enum("ContractExecutableType",{contractExecutableWasm:0,contractExecutableStellarAsset:1}),e.union("ContractExecutable",{switchOn:e.lookup("ContractExecutableType"),switchName:"type",switches:[["contractExecutableWasm","wasmHash"],["contractExecutableStellarAsset",e.void()]],arms:{wasmHash:e.lookup("Hash")}}),e.enum("ScAddressType",{scAddressTypeAccount:0,scAddressTypeContract:1,scAddressTypeMuxedAccount:2,scAddressTypeClaimableBalance:3,scAddressTypeLiquidityPool:4}),e.struct("MuxedEd25519Account",[["id",e.lookup("Uint64")],["ed25519",e.lookup("Uint256")]]),e.union("ScAddress",{switchOn:e.lookup("ScAddressType"),switchName:"type",switches:[["scAddressTypeAccount","accountId"],["scAddressTypeContract","contractId"],["scAddressTypeMuxedAccount","muxedAccount"],["scAddressTypeClaimableBalance","claimableBalanceId"],["scAddressTypeLiquidityPool","liquidityPoolId"]],arms:{accountId:e.lookup("AccountId"),contractId:e.lookup("ContractId"),muxedAccount:e.lookup("MuxedEd25519Account"),claimableBalanceId:e.lookup("ClaimableBalanceId"),liquidityPoolId:e.lookup("PoolId")}}),e.const("SCSYMBOL_LIMIT",32),e.typedef("ScVec",e.varArray(e.lookup("ScVal"),2147483647)),e.typedef("ScMap",e.varArray(e.lookup("ScMapEntry"),2147483647)),e.typedef("ScBytes",e.varOpaque()),e.typedef("ScString",e.string()),e.typedef("ScSymbol",e.string(32)),e.struct("ScNonceKey",[["nonce",e.lookup("Int64")]]),e.struct("ScContractInstance",[["executable",e.lookup("ContractExecutable")],["storage",e.option(e.lookup("ScMap"))]]),e.union("ScVal",{switchOn:e.lookup("ScValType"),switchName:"type",switches:[["scvBool","b"],["scvVoid",e.void()],["scvError","error"],["scvU32","u32"],["scvI32","i32"],["scvU64","u64"],["scvI64","i64"],["scvTimepoint","timepoint"],["scvDuration","duration"],["scvU128","u128"],["scvI128","i128"],["scvU256","u256"],["scvI256","i256"],["scvBytes","bytes"],["scvString","str"],["scvSymbol","sym"],["scvVec","vec"],["scvMap","map"],["scvAddress","address"],["scvContractInstance","instance"],["scvLedgerKeyContractInstance",e.void()],["scvLedgerKeyNonce","nonceKey"]],arms:{b:e.bool(),error:e.lookup("ScError"),u32:e.lookup("Uint32"),i32:e.lookup("Int32"),u64:e.lookup("Uint64"),i64:e.lookup("Int64"),timepoint:e.lookup("TimePoint"),duration:e.lookup("Duration"),u128:e.lookup("UInt128Parts"),i128:e.lookup("Int128Parts"),u256:e.lookup("UInt256Parts"),i256:e.lookup("Int256Parts"),bytes:e.lookup("ScBytes"),str:e.lookup("ScString"),sym:e.lookup("ScSymbol"),vec:e.option(e.lookup("ScVec")),map:e.option(e.lookup("ScMap")),address:e.lookup("ScAddress"),instance:e.lookup("ScContractInstance"),nonceKey:e.lookup("ScNonceKey")}}),e.struct("ScMapEntry",[["key",e.lookup("ScVal")],["val",e.lookup("ScVal")]]),e.enum("ScEnvMetaKind",{scEnvMetaKindInterfaceVersion:0}),e.struct("ScEnvMetaEntryInterfaceVersion",[["protocol",e.lookup("Uint32")],["preRelease",e.lookup("Uint32")]]),e.union("ScEnvMetaEntry",{switchOn:e.lookup("ScEnvMetaKind"),switchName:"kind",switches:[["scEnvMetaKindInterfaceVersion","interfaceVersion"]],arms:{interfaceVersion:e.lookup("ScEnvMetaEntryInterfaceVersion")}}),e.struct("ScMetaV0",[["key",e.string()],["val",e.string()]]),e.enum("ScMetaKind",{scMetaV0:0}),e.union("ScMetaEntry",{switchOn:e.lookup("ScMetaKind"),switchName:"kind",switches:[["scMetaV0","v0"]],arms:{v0:e.lookup("ScMetaV0")}}),e.const("SC_SPEC_DOC_LIMIT",1024),e.enum("ScSpecType",{scSpecTypeVal:0,scSpecTypeBool:1,scSpecTypeVoid:2,scSpecTypeError:3,scSpecTypeU32:4,scSpecTypeI32:5,scSpecTypeU64:6,scSpecTypeI64:7,scSpecTypeTimepoint:8,scSpecTypeDuration:9,scSpecTypeU128:10,scSpecTypeI128:11,scSpecTypeU256:12,scSpecTypeI256:13,scSpecTypeBytes:14,scSpecTypeString:16,scSpecTypeSymbol:17,scSpecTypeAddress:19,scSpecTypeMuxedAddress:20,scSpecTypeOption:1e3,scSpecTypeResult:1001,scSpecTypeVec:1002,scSpecTypeMap:1004,scSpecTypeTuple:1005,scSpecTypeBytesN:1006,scSpecTypeUdt:2e3}),e.struct("ScSpecTypeOption",[["valueType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeResult",[["okType",e.lookup("ScSpecTypeDef")],["errorType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeVec",[["elementType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeMap",[["keyType",e.lookup("ScSpecTypeDef")],["valueType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeTuple",[["valueTypes",e.varArray(e.lookup("ScSpecTypeDef"),12)]]),e.struct("ScSpecTypeBytesN",[["n",e.lookup("Uint32")]]),e.struct("ScSpecTypeUdt",[["name",e.string(60)]]),e.union("ScSpecTypeDef",{switchOn:e.lookup("ScSpecType"),switchName:"type",switches:[["scSpecTypeVal",e.void()],["scSpecTypeBool",e.void()],["scSpecTypeVoid",e.void()],["scSpecTypeError",e.void()],["scSpecTypeU32",e.void()],["scSpecTypeI32",e.void()],["scSpecTypeU64",e.void()],["scSpecTypeI64",e.void()],["scSpecTypeTimepoint",e.void()],["scSpecTypeDuration",e.void()],["scSpecTypeU128",e.void()],["scSpecTypeI128",e.void()],["scSpecTypeU256",e.void()],["scSpecTypeI256",e.void()],["scSpecTypeBytes",e.void()],["scSpecTypeString",e.void()],["scSpecTypeSymbol",e.void()],["scSpecTypeAddress",e.void()],["scSpecTypeMuxedAddress",e.void()],["scSpecTypeOption","option"],["scSpecTypeResult","result"],["scSpecTypeVec","vec"],["scSpecTypeMap","map"],["scSpecTypeTuple","tuple"],["scSpecTypeBytesN","bytesN"],["scSpecTypeUdt","udt"]],arms:{option:e.lookup("ScSpecTypeOption"),result:e.lookup("ScSpecTypeResult"),vec:e.lookup("ScSpecTypeVec"),map:e.lookup("ScSpecTypeMap"),tuple:e.lookup("ScSpecTypeTuple"),bytesN:e.lookup("ScSpecTypeBytesN"),udt:e.lookup("ScSpecTypeUdt")}}),e.struct("ScSpecUdtStructFieldV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecUdtStructV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["fields",e.varArray(e.lookup("ScSpecUdtStructFieldV0"),2147483647)]]),e.struct("ScSpecUdtUnionCaseVoidV0",[["doc",e.string(t)],["name",e.string(60)]]),e.struct("ScSpecUdtUnionCaseTupleV0",[["doc",e.string(t)],["name",e.string(60)],["type",e.varArray(e.lookup("ScSpecTypeDef"),2147483647)]]),e.enum("ScSpecUdtUnionCaseV0Kind",{scSpecUdtUnionCaseVoidV0:0,scSpecUdtUnionCaseTupleV0:1}),e.union("ScSpecUdtUnionCaseV0",{switchOn:e.lookup("ScSpecUdtUnionCaseV0Kind"),switchName:"kind",switches:[["scSpecUdtUnionCaseVoidV0","voidCase"],["scSpecUdtUnionCaseTupleV0","tupleCase"]],arms:{voidCase:e.lookup("ScSpecUdtUnionCaseVoidV0"),tupleCase:e.lookup("ScSpecUdtUnionCaseTupleV0")}}),e.struct("ScSpecUdtUnionV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtUnionCaseV0"),2147483647)]]),e.struct("ScSpecUdtEnumCaseV0",[["doc",e.string(t)],["name",e.string(60)],["value",e.lookup("Uint32")]]),e.struct("ScSpecUdtEnumV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtEnumCaseV0"),2147483647)]]),e.struct("ScSpecUdtErrorEnumCaseV0",[["doc",e.string(t)],["name",e.string(60)],["value",e.lookup("Uint32")]]),e.struct("ScSpecUdtErrorEnumV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtErrorEnumCaseV0"),2147483647)]]),e.struct("ScSpecFunctionInputV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecFunctionV0",[["doc",e.string(t)],["name",e.lookup("ScSymbol")],["inputs",e.varArray(e.lookup("ScSpecFunctionInputV0"),2147483647)],["outputs",e.varArray(e.lookup("ScSpecTypeDef"),1)]]),e.enum("ScSpecEventParamLocationV0",{scSpecEventParamLocationData:0,scSpecEventParamLocationTopicList:1}),e.struct("ScSpecEventParamV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")],["location",e.lookup("ScSpecEventParamLocationV0")]]),e.enum("ScSpecEventDataFormat",{scSpecEventDataFormatSingleValue:0,scSpecEventDataFormatVec:1,scSpecEventDataFormatMap:2}),e.struct("ScSpecEventV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.lookup("ScSymbol")],["prefixTopics",e.varArray(e.lookup("ScSymbol"),2)],["params",e.varArray(e.lookup("ScSpecEventParamV0"),2147483647)],["dataFormat",e.lookup("ScSpecEventDataFormat")]]),e.enum("ScSpecEntryKind",{scSpecEntryFunctionV0:0,scSpecEntryUdtStructV0:1,scSpecEntryUdtUnionV0:2,scSpecEntryUdtEnumV0:3,scSpecEntryUdtErrorEnumV0:4,scSpecEntryEventV0:5}),e.union("ScSpecEntry",{switchOn:e.lookup("ScSpecEntryKind"),switchName:"kind",switches:[["scSpecEntryFunctionV0","functionV0"],["scSpecEntryUdtStructV0","udtStructV0"],["scSpecEntryUdtUnionV0","udtUnionV0"],["scSpecEntryUdtEnumV0","udtEnumV0"],["scSpecEntryUdtErrorEnumV0","udtErrorEnumV0"],["scSpecEntryEventV0","eventV0"]],arms:{functionV0:e.lookup("ScSpecFunctionV0"),udtStructV0:e.lookup("ScSpecUdtStructV0"),udtUnionV0:e.lookup("ScSpecUdtUnionV0"),udtEnumV0:e.lookup("ScSpecUdtEnumV0"),udtErrorEnumV0:e.lookup("ScSpecUdtErrorEnumV0"),eventV0:e.lookup("ScSpecEventV0")}}),e.typedef("EncodedLedgerKey",e.varOpaque()),e.struct("ConfigSettingContractExecutionLanesV0",[["ledgerMaxTxCount",e.lookup("Uint32")]]),e.struct("ConfigSettingContractComputeV0",[["ledgerMaxInstructions",e.lookup("Int64")],["txMaxInstructions",e.lookup("Int64")],["feeRatePerInstructionsIncrement",e.lookup("Int64")],["txMemoryLimit",e.lookup("Uint32")]]),e.struct("ConfigSettingContractParallelComputeV0",[["ledgerMaxDependentTxClusters",e.lookup("Uint32")]]),e.struct("ConfigSettingContractLedgerCostV0",[["ledgerMaxDiskReadEntries",e.lookup("Uint32")],["ledgerMaxDiskReadBytes",e.lookup("Uint32")],["ledgerMaxWriteLedgerEntries",e.lookup("Uint32")],["ledgerMaxWriteBytes",e.lookup("Uint32")],["txMaxDiskReadEntries",e.lookup("Uint32")],["txMaxDiskReadBytes",e.lookup("Uint32")],["txMaxWriteLedgerEntries",e.lookup("Uint32")],["txMaxWriteBytes",e.lookup("Uint32")],["feeDiskReadLedgerEntry",e.lookup("Int64")],["feeWriteLedgerEntry",e.lookup("Int64")],["feeDiskRead1Kb",e.lookup("Int64")],["sorobanStateTargetSizeBytes",e.lookup("Int64")],["rentFee1KbSorobanStateSizeLow",e.lookup("Int64")],["rentFee1KbSorobanStateSizeHigh",e.lookup("Int64")],["sorobanStateRentFeeGrowthFactor",e.lookup("Uint32")]]),e.struct("ConfigSettingContractLedgerCostExtV0",[["txMaxFootprintEntries",e.lookup("Uint32")],["feeWrite1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractHistoricalDataV0",[["feeHistorical1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractEventsV0",[["txMaxContractEventsSizeBytes",e.lookup("Uint32")],["feeContractEvents1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractBandwidthV0",[["ledgerMaxTxsSizeBytes",e.lookup("Uint32")],["txMaxSizeBytes",e.lookup("Uint32")],["feeTxSize1Kb",e.lookup("Int64")]]),e.enum("ContractCostType",{wasmInsnExec:0,memAlloc:1,memCpy:2,memCmp:3,dispatchHostFunction:4,visitObject:5,valSer:6,valDeser:7,computeSha256Hash:8,computeEd25519PubKey:9,verifyEd25519Sig:10,vmInstantiation:11,vmCachedInstantiation:12,invokeVmFunction:13,computeKeccak256Hash:14,decodeEcdsaCurve256Sig:15,recoverEcdsaSecp256k1Key:16,int256AddSub:17,int256Mul:18,int256Div:19,int256Pow:20,int256Shift:21,chaCha20DrawBytes:22,parseWasmInstructions:23,parseWasmFunctions:24,parseWasmGlobals:25,parseWasmTableEntries:26,parseWasmTypes:27,parseWasmDataSegments:28,parseWasmElemSegments:29,parseWasmImports:30,parseWasmExports:31,parseWasmDataSegmentBytes:32,instantiateWasmInstructions:33,instantiateWasmFunctions:34,instantiateWasmGlobals:35,instantiateWasmTableEntries:36,instantiateWasmTypes:37,instantiateWasmDataSegments:38,instantiateWasmElemSegments:39,instantiateWasmImports:40,instantiateWasmExports:41,instantiateWasmDataSegmentBytes:42,sec1DecodePointUncompressed:43,verifyEcdsaSecp256r1Sig:44,bls12381EncodeFp:45,bls12381DecodeFp:46,bls12381G1CheckPointOnCurve:47,bls12381G1CheckPointInSubgroup:48,bls12381G2CheckPointOnCurve:49,bls12381G2CheckPointInSubgroup:50,bls12381G1ProjectiveToAffine:51,bls12381G2ProjectiveToAffine:52,bls12381G1Add:53,bls12381G1Mul:54,bls12381G1Msm:55,bls12381MapFpToG1:56,bls12381HashToG1:57,bls12381G2Add:58,bls12381G2Mul:59,bls12381G2Msm:60,bls12381MapFp2ToG2:61,bls12381HashToG2:62,bls12381Pairing:63,bls12381FrFromU256:64,bls12381FrToU256:65,bls12381FrAddSub:66,bls12381FrMul:67,bls12381FrPow:68,bls12381FrInv:69,bn254EncodeFp:70,bn254DecodeFp:71,bn254G1CheckPointOnCurve:72,bn254G2CheckPointOnCurve:73,bn254G2CheckPointInSubgroup:74,bn254G1ProjectiveToAffine:75,bn254G1Add:76,bn254G1Mul:77,bn254Pairing:78,bn254FrFromU256:79,bn254FrToU256:80,bn254FrAddSub:81,bn254FrMul:82,bn254FrPow:83,bn254FrInv:84,bn254G1Msm:85}),e.struct("ContractCostParamEntry",[["ext",e.lookup("ExtensionPoint")],["constTerm",e.lookup("Int64")],["linearTerm",e.lookup("Int64")]]),e.struct("StateArchivalSettings",[["maxEntryTtl",e.lookup("Uint32")],["minTemporaryTtl",e.lookup("Uint32")],["minPersistentTtl",e.lookup("Uint32")],["persistentRentRateDenominator",e.lookup("Int64")],["tempRentRateDenominator",e.lookup("Int64")],["maxEntriesToArchive",e.lookup("Uint32")],["liveSorobanStateSizeWindowSampleSize",e.lookup("Uint32")],["liveSorobanStateSizeWindowSamplePeriod",e.lookup("Uint32")],["evictionScanSize",e.lookup("Uint32")],["startingEvictionScanLevel",e.lookup("Uint32")]]),e.struct("EvictionIterator",[["bucketListLevel",e.lookup("Uint32")],["isCurrBucket",e.bool()],["bucketFileOffset",e.lookup("Uint64")]]),e.struct("ConfigSettingScpTiming",[["ledgerTargetCloseTimeMilliseconds",e.lookup("Uint32")],["nominationTimeoutInitialMilliseconds",e.lookup("Uint32")],["nominationTimeoutIncrementMilliseconds",e.lookup("Uint32")],["ballotTimeoutInitialMilliseconds",e.lookup("Uint32")],["ballotTimeoutIncrementMilliseconds",e.lookup("Uint32")]]),e.struct("FrozenLedgerKeys",[["keys",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)]]),e.struct("FrozenLedgerKeysDelta",[["keysToFreeze",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)],["keysToUnfreeze",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)]]),e.struct("FreezeBypassTxes",[["txHashes",e.varArray(e.lookup("Hash"),2147483647)]]),e.struct("FreezeBypassTxsDelta",[["addTxes",e.varArray(e.lookup("Hash"),2147483647)],["removeTxes",e.varArray(e.lookup("Hash"),2147483647)]]),e.const("CONTRACT_COST_COUNT_LIMIT",1024),e.typedef("ContractCostParams",e.varArray(e.lookup("ContractCostParamEntry"),e.lookup("CONTRACT_COST_COUNT_LIMIT"))),e.enum("ConfigSettingId",{configSettingContractMaxSizeBytes:0,configSettingContractComputeV0:1,configSettingContractLedgerCostV0:2,configSettingContractHistoricalDataV0:3,configSettingContractEventsV0:4,configSettingContractBandwidthV0:5,configSettingContractCostParamsCpuInstructions:6,configSettingContractCostParamsMemoryBytes:7,configSettingContractDataKeySizeBytes:8,configSettingContractDataEntrySizeBytes:9,configSettingStateArchival:10,configSettingContractExecutionLanes:11,configSettingLiveSorobanStateSizeWindow:12,configSettingEvictionIterator:13,configSettingContractParallelComputeV0:14,configSettingContractLedgerCostExtV0:15,configSettingScpTiming:16,configSettingFrozenLedgerKeys:17,configSettingFrozenLedgerKeysDelta:18,configSettingFreezeBypassTxes:19,configSettingFreezeBypassTxsDelta:20}),e.union("ConfigSettingEntry",{switchOn:e.lookup("ConfigSettingId"),switchName:"configSettingId",switches:[["configSettingContractMaxSizeBytes","contractMaxSizeBytes"],["configSettingContractComputeV0","contractCompute"],["configSettingContractLedgerCostV0","contractLedgerCost"],["configSettingContractHistoricalDataV0","contractHistoricalData"],["configSettingContractEventsV0","contractEvents"],["configSettingContractBandwidthV0","contractBandwidth"],["configSettingContractCostParamsCpuInstructions","contractCostParamsCpuInsns"],["configSettingContractCostParamsMemoryBytes","contractCostParamsMemBytes"],["configSettingContractDataKeySizeBytes","contractDataKeySizeBytes"],["configSettingContractDataEntrySizeBytes","contractDataEntrySizeBytes"],["configSettingStateArchival","stateArchivalSettings"],["configSettingContractExecutionLanes","contractExecutionLanes"],["configSettingLiveSorobanStateSizeWindow","liveSorobanStateSizeWindow"],["configSettingEvictionIterator","evictionIterator"],["configSettingContractParallelComputeV0","contractParallelCompute"],["configSettingContractLedgerCostExtV0","contractLedgerCostExt"],["configSettingScpTiming","contractScpTiming"],["configSettingFrozenLedgerKeys","frozenLedgerKeys"],["configSettingFrozenLedgerKeysDelta","frozenLedgerKeysDelta"],["configSettingFreezeBypassTxes","freezeBypassTxes"],["configSettingFreezeBypassTxsDelta","freezeBypassTxsDelta"]],arms:{contractMaxSizeBytes:e.lookup("Uint32"),contractCompute:e.lookup("ConfigSettingContractComputeV0"),contractLedgerCost:e.lookup("ConfigSettingContractLedgerCostV0"),contractHistoricalData:e.lookup("ConfigSettingContractHistoricalDataV0"),contractEvents:e.lookup("ConfigSettingContractEventsV0"),contractBandwidth:e.lookup("ConfigSettingContractBandwidthV0"),contractCostParamsCpuInsns:e.lookup("ContractCostParams"),contractCostParamsMemBytes:e.lookup("ContractCostParams"),contractDataKeySizeBytes:e.lookup("Uint32"),contractDataEntrySizeBytes:e.lookup("Uint32"),stateArchivalSettings:e.lookup("StateArchivalSettings"),contractExecutionLanes:e.lookup("ConfigSettingContractExecutionLanesV0"),liveSorobanStateSizeWindow:e.varArray(e.lookup("Uint64"),2147483647),evictionIterator:e.lookup("EvictionIterator"),contractParallelCompute:e.lookup("ConfigSettingContractParallelComputeV0"),contractLedgerCostExt:e.lookup("ConfigSettingContractLedgerCostExtV0"),contractScpTiming:e.lookup("ConfigSettingScpTiming"),frozenLedgerKeys:e.lookup("FrozenLedgerKeys"),frozenLedgerKeysDelta:e.lookup("FrozenLedgerKeysDelta"),freezeBypassTxes:e.lookup("FreezeBypassTxes"),freezeBypassTxsDelta:e.lookup("FreezeBypassTxsDelta")}}),e.struct("LedgerCloseMetaBatch",[["startSequence",e.lookup("Uint32")],["endSequence",e.lookup("Uint32")],["ledgerCloseMeta",e.varArray(e.lookup("LedgerCloseMeta"),2147483647)]])});const O={XdrWriter:_.XdrWriter,XdrReader:_.XdrReader};var U,L={},N={};var V,F,D={};
|
|
3
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function M(){return V||(V=1,D.read=function(e,t,n,r,o){var s,i,a=8*o-r-1,c=(1<<a)-1,u=c>>1,l=-7,d=n?o-1:0,p=n?-1:1,h=e[t+d];for(d+=p,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=p,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=r;l>0;i=256*i+e[t+d],d+=p,l-=8);if(0===s)s=1-u;else{if(s===c)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,r),s-=u}return(h?-1:1)*i*Math.pow(2,s-r)},D.write=function(e,t,n,r,o,s){var i,a,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),(t+=i+d>=1?p/c:p*Math.pow(2,1-d))*c>=2&&(i++,c/=2),i+d>=l?(a=0,i=l):i+d>=1?(a=(t*c-1)*Math.pow(2,o),i+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(i=i<<o|a,u+=o;u>0;e[n+h]=255&i,h+=f,i/=256,u-=8);e[n+h-f]|=128*m}),D}
|
|
4
|
+
/*!
|
|
5
|
+
* The buffer module from node.js, for the browser.
|
|
6
|
+
*
|
|
7
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/var q=(F||(F=1,function(e){const t=function(){if(U)return N;U=1,N.byteLength=function(e){var t=s(e),n=t[0],r=t[1];return 3*(n+r)/4-r},N.toByteArray=function(e){var r,o,i=s(e),a=i[0],c=i[1],u=new n(function(e,t,n){return 3*(t+n)/4-n}(0,a,c)),l=0,d=c>0?a-4:a;for(o=0;o<d;o+=4)r=t[e.charCodeAt(o)]<<18|t[e.charCodeAt(o+1)]<<12|t[e.charCodeAt(o+2)]<<6|t[e.charCodeAt(o+3)],u[l++]=r>>16&255,u[l++]=r>>8&255,u[l++]=255&r;return 2===c&&(r=t[e.charCodeAt(o)]<<2|t[e.charCodeAt(o+1)]>>4,u[l++]=255&r),1===c&&(r=t[e.charCodeAt(o)]<<10|t[e.charCodeAt(o+1)]<<4|t[e.charCodeAt(o+2)]>>2,u[l++]=r>>8&255,u[l++]=255&r),u},N.fromByteArray=function(t){for(var n,r=t.length,o=r%3,s=[],i=16383,c=0,u=r-o;c<u;c+=i)s.push(a(t,c,c+i>u?u:c+i));return 1===o?(n=t[r-1],s.push(e[n>>2]+e[n<<4&63]+"==")):2===o&&(n=(t[r-2]<<8)+t[r-1],s.push(e[n>>10]+e[n>>4&63]+e[n<<2&63]+"=")),s.join("")};for(var e=[],t=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)e[o]=r[o],t[r.charCodeAt(o)]=o;function s(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 i(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function a(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(i(r));return o.join("")}return t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63,N}(),n=M(),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(e){return+e!=e&&(e=0),i.alloc(+e)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,i.prototype),t}function i(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 u(e)}return a(e,t,n)}function a(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|h(e,t);let r=s(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(j(e,Uint8Array)){const t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return l(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(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return d(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(j(e,SharedArrayBuffer)||e&&j(e.buffer,SharedArrayBuffer)))return d(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 i.from(r,t,n);const o=function(e){if(i.isBuffer(e)){const t=0|p(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||Y(e.length)?s(0):l(e):"Buffer"===e.type&&Array.isArray(e.data)?l(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return i.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 c(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 u(e){return c(e),s(e<0?0:0|p(e))}function l(e){const t=e.length<0?0:0|p(e.length),n=s(t);for(let r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(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,i.prototype),r}function p(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function h(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||j(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 W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Z(e).length;default:if(o)return r?-1:W(e).length;t=(""+t).toLowerCase(),o=!0}}function f(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 B(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function g(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),Y(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=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:y(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):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(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 w(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(Y(r))return i;e[n+i]=r}return i}function A(e,t,n,r){return z(W(t,e.length-n),e,n,r)}function S(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 b(e,t,n,r){return z(Z(t),e,n,r)}function v(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 T(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function E(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<=k)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=k));return n}(r)}e.kMaxLength=o,i.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}}(),i.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(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(e,t,n){return a(e,t,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(e,t,n){return function(e,t,n){return c(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}(e,t,n)},i.allocUnsafe=function(e){return u(e)},i.allocUnsafeSlow=function(e){return u(e)},i.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==i.prototype},i.compare=function(e,t){if(j(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),j(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(e)||!i.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},i.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}},i.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return i.alloc(0);let n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const r=i.allocUnsafe(t);let o=0;for(n=0;n<e.length;++n){let t=e[n];if(j(t,Uint8Array))o+t.length>r.length?(i.isBuffer(t)||(t=i.from(t)),t.copy(r,o)):Uint8Array.prototype.set.call(r,t,o);else{if(!i.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,o)}o+=t.length}return r},i.byteLength=h,i.prototype._isBuffer=!0,i.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)m(this,t,t+1);return this},i.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)m(this,t,t+3),m(this,t+1,t+2);return this},i.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)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},i.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?E(this,0,e):f.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(e){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===i.compare(this,e)},i.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+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(e,t,n,r,o){if(j(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.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),a=(n>>>=0)-(t>>>=0);const c=Math.min(s,a),u=this.slice(r,o),l=e.slice(t,n);for(let e=0;e<c;++e)if(u[e]!==l[e]){s=u[e],a=l[e];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},i.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},i.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},i.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 w(this,e,t,n);case"utf8":case"utf-8":return A(this,e,t,n);case"ascii":case"latin1":case"binary":return S(this,e,t,n);case"base64":return b(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function I(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 C(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 B(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+=J[e[r]];return o}function x(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 R(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 _(e,t,n,r,o,s){if(!i.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 P(e,t,n,r,o){G(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 O(e,t,n,r,o){G(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 L(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,r,o,s){return t=+t,r>>>=0,s||L(e,0,r,4),n.write(e,t,r,o,23,4),r+4}function F(e,t,r,o,s){return t=+t,r>>>=0,s||L(e,0,r,8),n.write(e,t,r,o,52,8),r+8}i.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,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);let r=this[e],o=1,s=0;for(;++s<t&&(o*=256);)r+=this[e+s]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);let r=this[e+--t],o=1;for(;t>0&&(o*=256);)r+=this[e+--t]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readBigUInt64LE=Q(function(e){$(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||X(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))}),i.prototype.readBigUInt64BE=Q(function(e){$(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||X(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)}),i.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||R(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},i.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||R(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},i.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readBigInt64LE=Q(function(e){$(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||X(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)}),i.prototype.readBigInt64BE=Q(function(e){$(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||X(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)}),i.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),n.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),n.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),n.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),n.read(this,e,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||_(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},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||_(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},i.prototype.writeUint8=i.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeBigUInt64LE=Q(function(e,t=0){return P(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=Q(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);_(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},i.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);_(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},i.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeBigInt64LE=Q(function(e,t=0){return P(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=Q(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(e,t,n){return V(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return V(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(!i.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},i.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&&!i.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=i.isBuffer(e)?e:i.from(e,r),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};const D={};function q(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 H(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 G(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){$(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||X(t,e.length-(n+1))}(r,o,s)}function $(e,t){if("number"!=typeof e)throw new D.ERR_INVALID_ARG_TYPE(t,"number",e)}function X(e,t,n){if(Math.floor(e)!==e)throw $(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)}q("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),q("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),q("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=H(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=H(o)),o+="n"),r+=` It must be ${t}. Received ${o}`,r},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function W(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 Z(e){return t.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 j(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}const J=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 Q(e){return"undefined"==typeof BigInt?ee:e}function ee(){throw new Error("BigInt not supported")}}(L)),L);function H(e,t,n=""){const r=(o=e)instanceof Uint8Array||ArrayBuffer.isView(o)&&"Uint8Array"===o.constructor.name&&"BYTES_PER_ELEMENT"in o&&1===o.BYTES_PER_ELEMENT;var o;const s=e?.length;if(!r||void 0!==t){const t=(n&&`"${n}" `)+"expected Uint8Array"+""+", got "+(r?`length=${s}`:"type="+typeof e);if(!r)throw new TypeError(t);throw new RangeError(t)}return e}function G(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function X(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function K(e,t){return e<<32-t|e>>>t}function W(e,t={}){const n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}const Z=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function z(e,t,n){return e&t^~e&n}function j(e,t,n){return e&t^e&n^t&n}class Y{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=X(this.buffer)}update(e){G(this),H(e);const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i===r){const t=X(e);for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){G(this),function(e,t){H(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,$(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(8*this.length),o),this.process(n,0);const i=X(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)i.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=i,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const J=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ee=BigInt(2**32-1),te=BigInt(32);function ne(e,t=!1){return t?{h:Number(e&ee),l:Number(e>>te&ee)}:{h:0|Number(e>>te&ee),l:0|Number(e&ee)}}const re=(e,t,n)=>e>>>n,oe=(e,t,n)=>e<<32-n|t>>>n,se=(e,t,n)=>e>>>n|t<<32-n,ie=(e,t,n)=>e<<32-n|t>>>n,ae=(e,t,n)=>e<<64-n|t>>>n-32,ce=(e,t,n)=>e>>>n-32|t<<64-n;function ue(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}const le=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),de=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,pe=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),he=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,fe=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),me=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,ge=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ye=new Uint32Array(64);class we extends Y{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)ye[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ye[e-15],n=ye[e-2],r=K(t,7)^K(t,18)^t>>>3,o=K(n,17)^K(n,19)^n>>>10;ye[e]=o+ye[e-7]+r+ye[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(K(i,6)^K(i,11)^K(i,25))+z(i,a,c)+ge[e]+ye[e]|0,l=(K(n,2)^K(n,13)^K(n,22))+j(n,r,o)|0;u=c,c=a,a=i,i=s+t|0,s=o,o=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,s,i,a,c,u)}roundClean(){$(ye)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),$(this.buffer)}}class Ae extends we{A=0|J[0];B=0|J[1];C=0|J[2];D=0|J[3];E=0|J[4];F=0|J[5];G=0|J[6];H=0|J[7];constructor(){super(32)}}const Se=(()=>function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:i}=ne(e[s],t);[r[s],o[s]]=[n,i]}return[r,o]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),be=(()=>Se[0])(),ve=(()=>Se[1])(),Te=new Uint32Array(80),Ee=new Uint32Array(80);class ke extends Y{constructor(e){super(128,e,16,!1)}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:l,Fl:d,Gh:p,Gl:h,Hh:f,Hl:m}=this;return[e,t,n,r,o,s,i,a,c,u,l,d,p,h,f,m]}set(e,t,n,r,o,s,i,a,c,u,l,d,p,h,f,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|d,this.Gh=0|p,this.Gl=0|h,this.Hh=0|f,this.Hl=0|m}process(e,t){for(let n=0;n<16;n++,t+=4)Te[n]=e.getUint32(t),Ee[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Te[e-15],n=0|Ee[e-15],r=se(t,n,1)^se(t,n,8)^re(t,0,7),o=ie(t,n,1)^ie(t,n,8)^oe(t,n,7),s=0|Te[e-2],i=0|Ee[e-2],a=se(s,i,19)^ae(s,i,61)^re(s,0,6),c=ie(s,i,19)^ce(s,i,61)^oe(s,i,6),u=pe(o,c,Ee[e-7],Ee[e-16]),l=he(u,r,a,Te[e-7],Te[e-16]);Te[e]=0|l,Ee[e]=0|u}let{Ah:n,Al:r,Bh:o,Bl:s,Ch:i,Cl:a,Dh:c,Dl:u,Eh:l,El:d,Fh:p,Fl:h,Gh:f,Gl:m,Hh:g,Hl:y}=this;for(let e=0;e<80;e++){const t=se(l,d,14)^se(l,d,18)^ae(l,d,41),w=ie(l,d,14)^ie(l,d,18)^ce(l,d,41),A=l&p^~l&f,S=fe(y,w,d&h^~d&m,ve[e],Ee[e]),b=me(S,g,t,A,be[e],Te[e]),v=0|S,T=se(n,r,28)^ae(n,r,34)^ae(n,r,39),E=ie(n,r,28)^ce(n,r,34)^ce(n,r,39),k=n&o^n&i^o&i,I=r&s^r&a^s&a;g=0|f,y=0|m,f=0|p,m=0|h,p=0|l,h=0|d,({h:l,l:d}=ue(0|c,0|u,0|b,0|v)),c=0|i,u=0|a,i=0|o,a=0|s,o=0|n,s=0|r;const C=le(v,E,I);n=de(C,b,T,k),r=0|C}({h:n,l:r}=ue(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:s}=ue(0|this.Bh,0|this.Bl,0|o,0|s)),({h:i,l:a}=ue(0|this.Ch,0|this.Cl,0|i,0|a)),({h:c,l:u}=ue(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:d}=ue(0|this.Eh,0|this.El,0|l,0|d)),({h:p,l:h}=ue(0|this.Fh,0|this.Fl,0|p,0|h)),({h:f,l:m}=ue(0|this.Gh,0|this.Gl,0|f,0|m)),({h:g,l:y}=ue(0|this.Hh,0|this.Hl,0|g,0|y)),this.set(n,r,o,s,i,a,c,u,l,d,p,h,f,m,g,y)}roundClean(){$(Te,Ee)}destroy(){this.destroyed=!0,$(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ie extends ke{Ah=0|Q[0];Al=0|Q[1];Bh=0|Q[2];Bl=0|Q[3];Ch=0|Q[4];Cl=0|Q[5];Dh=0|Q[6];Dl=0|Q[7];Eh=0|Q[8];El=0|Q[9];Fh=0|Q[10];Fl=0|Q[11];Gh=0|Q[12];Gl=0|Q[13];Hh=0|Q[14];Hl=0|Q[15];constructor(){super(64)}}const Ce=W(()=>new Ae,Z(1)),Be=W(()=>new Ie,Z(3));function xe(e){const t="string"==typeof e?q.Buffer.from(e,"utf8"):e;return q.Buffer.from(Ce(t))}
|
|
10
|
+
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Re=Object.freeze({p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n}),{p:_e,n:Pe,Gx:Oe,Gy:Ue,a:Le,d:Ne,h:Ve}=Re,Fe=32,De=(e="")=>{const t=new Error(e);throw((...e)=>{"captureStackTrace"in Error&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(...e)})(t,De),t},Me=(e,t,n="")=>{const r=(o=e)instanceof Uint8Array||ArrayBuffer.isView(o)&&"Uint8Array"===o.constructor.name&&"BYTES_PER_ELEMENT"in o&&1===o.BYTES_PER_ELEMENT;var o;const s=e?.length,i=void 0!==t;if(!r||i&&s!==t){const o=(n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(r?`length=${s}`:"type="+typeof e);throw r?new RangeError(o):new TypeError(o)}return e},qe=e=>new Uint8Array(e),He=e=>Uint8Array.from(e),Ge=(e,t)=>e.toString(16).padStart(t,"0"),$e=e=>Array.from(Me(e)).map(e=>Ge(e,2)).join(""),Xe=48,Ke=57,We=65,Ze=70,ze=97,je=102,Ye=e=>e>=Xe&&e<=Ke?e-Xe:e>=We&&e<=Ze?e-(We-10):e>=ze&&e<=je?e-(ze-10):void 0,Je=e=>{const t="hex invalid";if("string"!=typeof e)return De(t);const n=e.length,r=n/2;if(n%2)return De(t);const o=qe(r);for(let n=0,s=0;n<r;n++,s+=2){const r=Ye(e.charCodeAt(s)),i=Ye(e.charCodeAt(s+1));if(void 0===r||void 0===i)return De(t);o[n]=16*r+i}return o},Qe=()=>globalThis?.crypto,et=(...e)=>{let t=0;for(const n of e)t+=Me(n).length;const n=qe(t);let r=0;return e.forEach(e=>{n.set(e,r),r+=e.length}),n},tt=BigInt,nt=(e,t,n,r="bad number: out of range")=>{if(!(e=>"bigint"==typeof e)(e))throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},rt=(e,t=_e)=>{const n=e%t;return n>=0n?n:t+n},ot=(1n<<255n)-1n,st=e=>{e<0n&&De("negative coordinate");let t=19n*(e>>255n)+(e&ot);return t=19n*(t>>255n)+(t&ot),t%_e},it=e=>rt(e,Pe),at=e=>{const t=Ct[e];return"function"!=typeof t&&De("hashes."+e+" not set"),t},ct=e=>Me(e,64,"digest"),ut=e=>e instanceof dt?e:De("Point expected"),lt=2n**256n;class dt{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){const o=lt;this.X=nt(e,0n,o),this.Y=nt(t,0n,o),this.Z=nt(n,1n,o),this.T=nt(r,0n,o),Object.freeze(this)}static CURVE(){return Re}static fromAffine(e){return new dt(e.x,e.y,1n,st(e.x*e.y))}static fromBytes(e,t=!1){const n=Ne,r=He(Me(e,Fe)),o=e[31];r[31]=-129&o;const s=mt(r);nt(s,0n,t?lt:_e);const i=st(s*s),a=rt(i-1n),c=st(n*i+1n);let{isValid:u,value:l}=wt(a,c);u||De("bad point: y not sqrt");const d=1n==(1n&l),p=!!(128&o);return!t&&0n===l&&p&&De("bad point: x==0, isLastByteOdd"),p!==d&&(l=rt(-l)),new dt(l,s,1n,st(l*s))}static fromHex(e,t){return dt.fromBytes(Je(e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=Le,t=Ne;if(this.is0())return De("bad point: ZERO");const{X:n,Y:r,Z:o,T:s}=this,i=st(n*n),a=st(r*r),c=st(o*o),u=st(c*c),l=st(i*e);if(st(c*(l+a))!==rt(u+st(t*st(i*a))))return De("bad point: equation left != right (1)");return st(n*r)!==st(o*s)?De("bad point: equation left != right (2)"):this}equals(e){const{X:t,Y:n,Z:r}=this,{X:o,Y:s,Z:i}=ut(e),a=st(t*i),c=st(o*r),u=st(n*i),l=st(s*r);return a===c&&u===l}is0(){return this.equals(ht)}negate(){return new dt(rt(-this.X),this.Y,this.Z,rt(-this.T))}double(){const{X:e,Y:t,Z:n}=this,r=Le,o=st(e*e),s=st(t*t),i=st(2n*n*n),a=st(r*o),c=rt(e+t),u=rt(st(c*c)-o-s),l=rt(a+s),d=rt(l-i),p=rt(a-s),h=st(u*d),f=st(l*p),m=st(u*p),g=st(d*l);return new dt(h,f,g,m)}add(e){const{X:t,Y:n,Z:r,T:o}=this,{X:s,Y:i,Z:a,T:c}=ut(e),u=Le,l=Ne,d=st(t*s),p=st(n*i),h=st(st(o*l)*c),f=st(r*a),m=rt(st(rt(t+n)*rt(s+i))-d-p),g=rt(f-h),y=rt(f+h),w=rt(p-st(u*d)),A=st(m*g),S=st(y*w),b=st(m*w),v=st(g*y);return new dt(A,S,v,b)}subtract(e){return this.add(ut(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return ht;if(nt(e,1n,Pe),!t&&this.is0())return ht;if(1n===e)return this;if(this.equals(pt))return Pt(e).p;let n=ht,r=pt;for(let o=this;e>0n;o=o.double(),e>>=1n)1n&e?n=n.add(o):t&&(r=r.add(o));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:n}=this;if(this.equals(ht))return{x:0n,y:1n};const r=((e,t)=>{(0n===e||t<=0n)&&De("no inverse n="+e+" mod="+t);let n=rt(e,t),r=t,o=0n,s=1n;for(;0n!==n;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}return 1n===r?rt(o,t):De("no inverse")})(n,_e);1n!==st(n*r)&&De("invalid inverse");return{x:st(e*r),y:st(t*r)}}toBytes(){const{x:e,y:t}=this.toAffine(),n=ft(t);return n[31]|=1n&e?128:0,n}toHex(){return $e(this.toBytes())}clearCofactor(){return this.multiply(tt(Ve),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(Pe/2n,!1).double();return Pe%2n&&(e=e.add(this)),e.is0()}}const pt=new dt(Oe,Ue,1n,rt(Oe*Ue)),ht=new dt(0n,1n,1n,0n);dt.BASE=pt,dt.ZERO=ht;const ft=e=>Je(Ge(nt(e,0n,lt),64)).reverse(),mt=e=>tt("0x"+$e(He(Me(e)).reverse())),gt=(e,t)=>{let n=e;for(;t-- >0n;)n=st(n*n);return n},yt=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,wt=(e,t)=>{const n=st(t*st(t*t)),r=st(st(n*n)*t),o=(e=>{const t=st(e*e),n=st(t*e),r=st(gt(n,2n)*n),o=st(gt(r,1n)*e),s=st(gt(o,5n)*o),i=st(gt(s,10n)*s),a=st(gt(i,20n)*i),c=st(gt(a,40n)*a),u=st(gt(c,80n)*c),l=st(gt(u,80n)*c),d=st(gt(l,10n)*s);return{pow_p_5_8:st(gt(d,2n)*e),b2:n}})(st(e*r)).pow_p_5_8;let s=st(e*st(n*o));const i=st(t*st(s*s)),a=s,c=st(s*yt),u=i===e,l=i===rt(-e),d=i===rt(-e*yt);return u&&(s=a),(l||d)&&(s=c),1n==(1n&rt(s))&&(s=rt(-s)),{isValid:u||l,value:s}},At=e=>it(mt(e)),St=(...e)=>ct(at("sha512")(et(...e))),bt=e=>{const t=He(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;const r=t.slice(32,64),o=At(n),s=pt.multiply(o),i=s.toBytes();return{head:n,prefix:r,scalar:o,point:s,pointBytes:i}},vt=e=>bt(St(Me(e,Fe))),Tt=e=>e.finish(St(e.hashable)),Et=(e,t)=>{const n=Me(e),r=vt(t),o=St(r.prefix,n);return Tt(((e,t,n)=>{const{pointBytes:r,scalar:o}=e,s=At(t),i=pt.multiply(s).toBytes();return{hashable:et(i,r,n),finish:e=>{const t=it(s+At(e)*o);return Me(et(i,ft(t)),64)}}})(r,o,n))},kt={zip215:!0},It=(e,t,n,r=kt)=>Tt(((e,t,n,r=kt)=>{e=Me(e,64),t=Me(t),n=Me(n,Fe);const{zip215:o=!0}=r,s=e.subarray(0,Fe),i=mt(e.subarray(Fe,64));let a,c,u,l=Uint8Array.of(),d=!1;try{a=dt.fromBytes(n,o),c=dt.fromBytes(s,o),u=pt.multiply(i,!1),l=et(s,n,t),d=!0}catch(e){}return{hashable:l,finish:e=>{if(!d)return!1;if(!o&&a.isSmallOrder())return!1;const t=At(e);return c.add(a.multiply(t,!1)).subtract(u).clearCofactor().is0()}}})(e,t,n,r)),Ct={sha512Async:async e=>{const t=Qe()?.subtle??De("crypto.subtle must be defined, consider polyfill"),n=et(e);return qe(await t.digest("SHA-512",n.buffer))},sha512:void 0},Bt=Object.freeze({getExtendedPublicKeyAsync:e=>((...e)=>Promise.resolve(at("sha512Async")(et(...e))).then(ct))(Me(e,Fe)).then(bt),getExtendedPublicKey:vt,randomSecretKey:e=>(e=void 0===e?((e=Fe)=>Qe().getRandomValues(qe(e)))(Fe):e,Me(e,Fe))}),xt=Math.ceil(32)+1;let Rt;const _t=(e,t)=>{const n=t.negate();return e?n:t},Pt=e=>{const t=Rt||(Rt=(()=>{const e=[];let t=pt,n=t;for(let r=0;r<xt;r++){n=t,e.push(n);for(let r=1;r<128;r++)n=n.add(t),e.push(n);t=n.double()}return e})());let n=ht,r=pt;const o=tt(255),s=tt(8);for(let i=0;i<xt;i++){let a=Number(e&o);e>>=s,a>128&&(a-=256,e+=1n);const c=128*i,u=c,l=c+Math.abs(a)-1,d=i%2!=0,p=a<0;0===a?r=r.add(_t(d,t[u])):n=n.add(_t(p,t[l]))}return 0n!==e&&De("invalid wnaf"),{p:n,f:r}};function Ot(e){return q.Buffer.from(vt(e).pointBytes)}function Ut(e,t){return q.Buffer.from(Et(q.Buffer.from(e),t))}function Lt(e,t,n){return It(q.Buffer.from(t),q.Buffer.from(e),q.Buffer.from(n),{zip215:!1})}Ct.sha512=Be;const Nt=(e,t)=>{const n="number"==typeof e;let r=String(e);for(;r.endsWith(t);)r=r.slice(0,-1);return n?Number(r):r};var Vt,Ft={};var Dt=(Vt||(Vt=1,function(e){var t=function(e,t){return t||(t={}),e.split("").forEach(function(e,n){e in t||(t[e]=n)}),t},n={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",charmap:{0:14,1:8}};n.charmap=t(n.alphabet,n.charmap);var r={alphabet:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",charmap:{O:0,I:1,L:1}};r.charmap=t(r.alphabet,r.charmap);var o={alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",charmap:{}};function s(t){if(this.buf=[],this.shift=8,this.carry=0,t){switch(t.type){case"rfc4648":this.charmap=e.rfc4648.charmap;break;case"crockford":this.charmap=e.crockford.charmap;break;case"base32hex":this.charmap=e.base32hex.charmap;break;default:throw new Error("invalid type")}t.charmap&&(this.charmap=t.charmap)}}function i(t){if(this.buf="",this.shift=3,this.carry=0,t){switch(t.type){case"rfc4648":this.alphabet=e.rfc4648.alphabet;break;case"crockford":this.alphabet=e.crockford.alphabet;break;case"base32hex":this.alphabet=e.base32hex.alphabet;break;default:throw new Error("invalid type")}t.alphabet?this.alphabet=t.alphabet:t.lc&&(this.alphabet=this.alphabet.toLowerCase())}}o.charmap=t(o.alphabet,o.charmap),s.prototype.charmap=n.charmap,s.prototype.write=function(e){var t=this.charmap,n=this.buf,r=this.shift,o=this.carry;return e.toUpperCase().split("").forEach(function(e){if("="!=e){var s=255&t[e];(r-=5)>0?o|=s<<r:r<0?(n.push(o|s>>-r),o=s<<(r+=8)&255):(n.push(o|s),r=8,o=0)}}),this.shift=r,this.carry=o,this},s.prototype.finalize=function(e){return e&&this.write(e),8!==this.shift&&0!==this.carry&&(this.buf.push(this.carry),this.shift=8,this.carry=0),this.buf},i.prototype.alphabet=n.alphabet,i.prototype.write=function(e){var t,n,r,o=this.shift,s=this.carry;for(r=0;r<e.length;r++)t=s|(n=e[r])>>o,this.buf+=this.alphabet[31&t],o>5&&(t=n>>(o-=5),this.buf+=this.alphabet[31&t]),s=n<<(o=5-o),o=8-o;return this.shift=o,this.carry=s,this},i.prototype.finalize=function(e){return e&&this.write(e),3!==this.shift&&(this.buf+=this.alphabet[31&this.carry],this.shift=3,this.carry=0),this.buf},e.encode=function(e,t){return new i(t).finalize(e)},e.decode=function(e,t){return new s(t).finalize(e)},e.Decoder=s,e.Encoder=i,e.charmap=t,e.crockford=r,e.rfc4648=n,e.base32hex=o}(Ft)),Ft),Mt=B(Dt);const qt={ed25519PublicKey:48,ed25519SecretSeed:144,med25519PublicKey:96,preAuthTx:152,sha256Hash:184,signedPayload:120,contract:16,liquidityPool:88,claimableBalance:8},Ht={G:"ed25519PublicKey",S:"ed25519SecretSeed",M:"med25519PublicKey",T:"preAuthTx",X:"sha256Hash",P:"signedPayload",C:"contract",L:"liquidityPool",B:"claimableBalance"};function Gt(e){return Object.prototype.hasOwnProperty.call(qt,e)}class $t{static types=Ht;static encodeEd25519PublicKey(e){return Wt("ed25519PublicKey",e)}static decodeEd25519PublicKey(e){return Kt("ed25519PublicKey",e)}static isValidEd25519PublicKey(e){return Xt("ed25519PublicKey",e)}static encodeEd25519SecretSeed(e){return Wt("ed25519SecretSeed",e)}static decodeEd25519SecretSeed(e){return Kt("ed25519SecretSeed",e)}static isValidEd25519SecretSeed(e){return Xt("ed25519SecretSeed",e)}static encodeMed25519PublicKey(e){return Wt("med25519PublicKey",e)}static decodeMed25519PublicKey(e){return Kt("med25519PublicKey",e)}static isValidMed25519PublicKey(e){return Xt("med25519PublicKey",e)}static encodePreAuthTx(e){return Wt("preAuthTx",e)}static decodePreAuthTx(e){return Kt("preAuthTx",e)}static encodeSha256Hash(e){return Wt("sha256Hash",e)}static decodeSha256Hash(e){return Kt("sha256Hash",e)}static encodeSignedPayload(e){return Wt("signedPayload",e)}static decodeSignedPayload(e){return Kt("signedPayload",e)}static isValidSignedPayload(e){return Xt("signedPayload",e)}static encodeContract(e){return Wt("contract",e)}static decodeContract(e){return Kt("contract",e)}static isValidContract(e){return Xt("contract",e)}static encodeClaimableBalance(e){return Wt("claimableBalance",e)}static decodeClaimableBalance(e){return Kt("claimableBalance",e)}static isValidClaimableBalance(e){return Xt("claimableBalance",e)}static encodeLiquidityPool(e){return Wt("liquidityPool",e)}static decodeLiquidityPool(e){return Kt("liquidityPool",e)}static isValidLiquidityPool(e){return Xt("liquidityPool",e)}static getVersionByteForPrefix(e){if(e.length<1)return;const t=e[0];return Ht[t]}}function Xt(e,t){if("string"!=typeof t)return!1;switch(e){case"ed25519PublicKey":case"ed25519SecretSeed":case"preAuthTx":case"sha256Hash":case"contract":case"liquidityPool":if(56!==t.length)return!1;break;case"claimableBalance":if(58!==t.length)return!1;break;case"med25519PublicKey":if(69!==t.length)return!1;break;case"signedPayload":if(t.length<56||t.length>165)return!1;break;default:return!1}let n;try{n=Kt(e,t)}catch{return!1}switch(e){case"ed25519PublicKey":case"ed25519SecretSeed":case"preAuthTx":case"sha256Hash":case"contract":case"liquidityPool":return 32===n.length;case"claimableBalance":return 33===n.length;case"med25519PublicKey":return 40===n.length;case"signedPayload":return n.length>=40&&n.length<=100;default:return!1}}function Kt(e,t){if("string"!=typeof t)throw new TypeError("encoded argument must be of type String");const n=Mt.decode(t),r=n[0],o=n.slice(0,-2),s=o.slice(1),i=n.slice(-2);if(t!==Mt.encode(n))throw new Error("invalid encoded string");if(!Gt(e))throw new Error(`${e} is not a valid version byte name. Expected one of ${Object.keys(qt).join(", ")}`);const a=qt[e];if(r!==a)throw new Error(`invalid version byte. expected ${a}, got ${r}`);if(!function(e,t){if(e.length!==t.length)return!1;if(0===e.length)return!0;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}(Zt(o),i))throw new Error("invalid checksum");return q.Buffer.from(s)}function Wt(e,t){if(null==t)throw new Error("cannot encode null data");if(!Gt(e))throw new Error(`${e} is not a valid version byte name. Expected one of ${Object.keys(qt).join(", ")}`);const n=qt[e];t=q.Buffer.from(t);const r=q.Buffer.from([n]),o=q.Buffer.concat([r,t]),s=q.Buffer.from(Zt(o)),i=q.Buffer.concat([o,s]);return Mt.encode(i)}function Zt(e){const t=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];let n=0;for(let r=0;r<e.length;r+=1){const o=e[r];if(void 0===o)continue;n=n<<8^(t[n>>8^o]??0),n&=65535}const r=new Uint8Array(2);return r[0]=255&n,r[1]=n>>8&255,r}Ct.sha512=Be;const zt=q.Buffer.from("Stellar Signed Message:\n","utf8");class jt{type;_publicKey;_secretSeed;_secretKey;constructor(e){if("ed25519"!==e.type)throw new Error("Invalid keys type");if(this.type=e.type,"secretKey"in e){if(e.secretKey=q.Buffer.from(e.secretKey),32!==e.secretKey.length)throw new Error("secretKey length is invalid");if(this._secretSeed=e.secretKey,this._publicKey=Ot(e.secretKey),this._secretKey=e.secretKey,e.publicKey&&!this._publicKey.equals(q.Buffer.from(e.publicKey)))throw new Error("secretKey does not match publicKey")}else{if(!("publicKey"in e))throw new Error("At least one of publicKey or secretKey must be provided");if(this._publicKey=q.Buffer.from(e.publicKey),32!==this._publicKey.length)throw new Error("publicKey length is invalid")}}static fromSecret(e){const t=$t.decodeEd25519SecretSeed(e);return this.fromRawEd25519Seed(t)}static fromRawEd25519Seed(e){return new this({type:"ed25519",secretKey:e})}static master(e){if(!e)throw new Error("No network selected. Please pass a network argument, e.g. `Keypair.master(Networks.PUBLIC)`.");return this.fromRawEd25519Seed(xe(e))}static fromPublicKey(e){const t=$t.decodeEd25519PublicKey(e);if(32!==t.length)throw new Error("Invalid Stellar public key");return new this({type:"ed25519",publicKey:t})}static random(){const e=Bt.randomSecretKey();return this.fromRawEd25519Seed(q.Buffer.from(e))}xdrAccountId(){return P.PublicKey.publicKeyTypeEd25519(this._publicKey)}xdrPublicKey(){return P.PublicKey.publicKeyTypeEd25519(this._publicKey)}xdrMuxedAccount(e){if(void 0!==e){if("string"!=typeof e)throw new TypeError("expected string for ID, got "+typeof e);return P.MuxedAccount.keyTypeMuxedEd25519(new P.MuxedAccountMed25519({id:P.Uint64.fromString(e),ed25519:this._publicKey}))}return P.MuxedAccount.keyTypeEd25519(this._publicKey)}rawPublicKey(){return this._publicKey}signatureHint(){const e=this.xdrAccountId().toXDR();return e.subarray(e.length-4)}publicKey(){return $t.encodeEd25519PublicKey(this._publicKey)}secret(){if(!this._secretSeed)throw new Error("no secret key available");if("ed25519"===this.type)return $t.encodeEd25519SecretSeed(this._secretSeed);throw new Error("Invalid Keypair type")}rawSecretKey(){if(!this._secretSeed)throw new Error("no secret seed available");return this._secretSeed}canSign(){return!!this._secretKey}sign(e){if(!this._secretKey)throw new Error("cannot sign: no secret key available");return Ut(e,this._secretKey)}verify(e,t){try{return Lt(e,t,this._publicKey)}catch{return!1}}signMessage(e){return this.sign(this._hashMessage(e))}verifyMessage(e,t){try{return this.verify(this._hashMessage(e),t)}catch{return!1}}_hashMessage(e){const t="string"==typeof e?q.Buffer.from(e,"utf8"):e;return xe(q.Buffer.concat([zt,t]))}signDecorated(e){const t=this.sign(e),n=this.signatureHint();return new P.DecoratedSignature({hint:n,signature:t})}signPayloadDecorated(e){const t=q.Buffer.isBuffer(e)?e:q.Buffer.from(e),n=this.sign(t),r=this.signatureHint();let o=q.Buffer.from(t.subarray(-4));o.length<4&&(o=q.Buffer.concat([o,q.Buffer.alloc(4-o.length,0)]));for(let e=0;e<o.length;e++)o[e]=o[e]^r[e];return new P.DecoratedSignature({hint:o,signature:n})}}const Yt={native:"native",credit4:"credit_alphanum4",credit12:"credit_alphanum12",liquidityPoolShares:"liquidity_pool_shares"};function Jt(e,t){return q.Buffer.compare(q.Buffer.from(e,"ascii"),q.Buffer.from(t,"ascii"))}class Qt{code;issuer;constructor(e,t){if(!/^[a-zA-Z0-9]{1,12}$/.test(e))throw new Error("Asset code is invalid (maximum alphanumeric, 12 characters at max)");if("xlm"!==String(e).toLowerCase()&&!t)throw new Error("Issuer cannot be null");if(t&&!$t.isValidEd25519PublicKey(t))throw new Error("Issuer is invalid");"xlm"===String(e).toLowerCase()?this.code="XLM":this.code=e,this.issuer=t}static native(){return new Qt("XLM")}static fromOperation(e){let t,n,r;switch(e.switch()){case P.AssetType.assetTypeNative():return this.native();case P.AssetType.assetTypeCreditAlphanum4():return t=e.alphaNum4(),r=$t.encodeEd25519PublicKey(t.issuer().ed25519()),n=Nt(t.assetCode().toString(),"\0"),new this(n,r);case P.AssetType.assetTypeCreditAlphanum12():return t=e.alphaNum12(),r=$t.encodeEd25519PublicKey(t.issuer().ed25519()),n=Nt(t.assetCode().toString(),"\0"),new this(n,r);default:throw new Error(`Invalid asset type: ${e.switch().name}`)}}toXDRObject(){return this._toXDRObject(P.Asset)}toChangeTrustXDRObject(){return this._toXDRObject(P.ChangeTrustAsset)}toTrustLineXDRObject(){return this._toXDRObject(P.TrustLineAsset)}contractId(e){const t=xe(q.Buffer.from(e)),n=P.HashIdPreimage.envelopeTypeContractId(new P.HashIdPreimageContractId({networkId:t,contractIdPreimage:P.ContractIdPreimage.contractIdPreimageFromAsset(this.toXDRObject())}));return $t.encodeContract(xe(n.toXDR()))}_toXDRObject(e){if(this.isNative())return e.assetTypeNative();if(!this.issuer)throw new Error("Issuer cannot be null for non-native asset");let t,n;this.code.length<=4?(t=P.AlphaNum4,n="assetTypeCreditAlphanum4"):(t=P.AlphaNum12,n="assetTypeCreditAlphanum12");const r=this.code.length<=4?4:12;return new e(n,new t({assetCode:this.code.padEnd(r,"\0"),issuer:jt.fromPublicKey(this.issuer).xdrAccountId()}))}getCode(){return String(this.code)}getIssuer(){if(void 0!==this.issuer)return String(this.issuer)}getAssetType(){switch(this.getRawAssetType().value){case P.AssetType.assetTypeNative().value:return Yt.native;case P.AssetType.assetTypeCreditAlphanum4().value:return Yt.credit4;case P.AssetType.assetTypeCreditAlphanum12().value:return Yt.credit12;default:throw new Error("Supported asset types are: native, credit_alphanum4, credit_alphanum12")}}getRawAssetType(){return this.isNative()?P.AssetType.assetTypeNative():this.code.length<=4?P.AssetType.assetTypeCreditAlphanum4():P.AssetType.assetTypeCreditAlphanum12()}isNative(){return!this.issuer}equals(e){return this.code===e.getCode()&&this.issuer===e.getIssuer()}toString(){return this.isNative()?"native":`${this.getCode()}:${this.getIssuer()}`}static compare(e,t){if(!(e&&e instanceof Qt))throw new Error("assetA is invalid");if(!(t&&t instanceof Qt))throw new Error("assetB is invalid");if(e.equals(t))return 0;const n=e.getRawAssetType().value,r=t.getRawAssetType().value;if(n!==r)return n<r?-1:1;const o=Jt(e.getCode(),t.getCode());if(0!==o)return o;const s=e.getIssuer(),i=t.getIssuer();if(void 0===s||void 0===i)throw new Error("Issuer is undefined for non-native asset");return Jt(s,i)}}function en(e,t){if("constant_product"!==e)throw new Error("liquidityPoolType is invalid");const{assetA:n,assetB:r,fee:o}=t??{};if(!(n&&n instanceof Qt))throw new Error("assetA is invalid");if(!(r&&r instanceof Qt))throw new Error("assetB is invalid");if(!o||30!==o)throw new Error("fee is invalid");if(-1!==Qt.compare(n,r))throw new Error("Assets are not in lexicographic order");return xe(P.LiquidityPoolParameters.liquidityPoolConstantProduct(new P.LiquidityPoolConstantProductParameters({assetA:n.toXDRObject(),assetB:r.toXDRObject(),fee:o})).toXDR())}class tn{_tx;_signatures;_fee;_networkPassphrase;constructor(e,t,n,r){if("string"!=typeof r)throw new Error("Invalid passphrase provided to Transaction: expected a string but got a "+typeof r);this._networkPassphrase=r,this._tx=e,this._signatures=t,this._fee=n}get signatures(){return this._signatures}set signatures(e){throw new Error("Transaction is immutable")}get tx(){const e=this._tx.toXDR();if(this._tx instanceof P.Transaction)return P.Transaction.fromXDR(e);if(this._tx instanceof P.TransactionV0)return P.TransactionV0.fromXDR(e);if(this._tx instanceof P.FeeBumpTransaction)return P.FeeBumpTransaction.fromXDR(e);throw new Error("Unknown transaction type")}set tx(e){throw new Error("Transaction is immutable")}get fee(){return this._fee}set fee(e){throw new Error("Transaction is immutable")}get networkPassphrase(){return this._networkPassphrase}set networkPassphrase(e){throw new Error("Transaction is immutable")}sign(...e){const t=this.hash();e.forEach(e=>{const n=e.signDecorated(t);this.signatures.push(n)})}getKeypairSignature(e){return e.sign(this.hash()).toString("base64")}addSignature(e="",t=""){if(!t||"string"!=typeof t)throw new Error("Invalid signature");if(!e||"string"!=typeof e)throw new Error("Invalid publicKey");let n,r;const o=q.Buffer.from(t,"base64");try{n=jt.fromPublicKey(e),r=n.signatureHint()}catch{throw new Error("Invalid publicKey")}if(!n.verify(this.hash(),o))throw new Error("Invalid signature");this.signatures.push(new P.DecoratedSignature({hint:r,signature:o}))}addDecoratedSignature(e){this.signatures.push(e)}signHashX(e){if("string"==typeof e&&(e=q.Buffer.from(e,"hex")),e.length>64)throw new Error("preimage cannot be longer than 64 bytes");const t=e,n=xe(e),r=n.subarray(n.length-4);this.signatures.push(new P.DecoratedSignature({hint:r,signature:t}))}hash(){return xe(this.signatureBase())}signatureBase(){throw new Error("Implement in subclass")}toEnvelope(){throw new Error("Implement in subclass")}toXDR(){return this.toEnvelope().toXDR().toString("base64")}}class nn{assetA;assetB;fee;constructor(e,t,n){if(!(e&&e instanceof Qt))throw new Error("assetA is invalid");if(!(t&&t instanceof Qt))throw new Error("assetB is invalid");if(-1!==Qt.compare(e,t))throw new Error("Assets are not in lexicographic order");if(!n||30!==n)throw new Error("fee is invalid");this.assetA=e,this.assetB=t,this.fee=n}static fromOperation(e){const t=e.switch();if(t===P.AssetType.assetTypePoolShare()){const t=e.liquidityPool().constantProduct();return new this(Qt.fromOperation(t.assetA()),Qt.fromOperation(t.assetB()),t.fee())}throw new Error(`Invalid asset type: ${t.name}`)}toXDRObject(){const e=new P.LiquidityPoolConstantProductParameters({assetA:this.assetA.toXDRObject(),assetB:this.assetB.toXDRObject(),fee:this.fee}),t=P.LiquidityPoolParameters.liquidityPoolConstantProduct(e);return P.ChangeTrustAsset.assetTypePoolShare(t)}getLiquidityPoolParameters(){return{...this,assetA:this.assetA,assetB:this.assetB,fee:this.fee}}getAssetType(){return"liquidity_pool_shares"}equals(e){return this.assetA.equals(e.assetA)&&this.assetB.equals(e.assetB)&&this.fee===e.fee}toString(){return`liquidity_pool:${en("constant_product",this.getLiquidityPoolParameters()).toString("hex")}`}}class rn{_destination;_predicate;constructor(e,t){if(!$t.isValidEd25519PublicKey(e))throw new Error("Destination is invalid");if(this._destination=e,t){if(!(t instanceof P.ClaimPredicate))throw new Error("Predicate should be an xdr.ClaimPredicate");this._predicate=t}else this._predicate=P.ClaimPredicate.claimPredicateUnconditional()}static predicateUnconditional(){return P.ClaimPredicate.claimPredicateUnconditional()}static predicateAnd(e,t){if(!(e instanceof P.ClaimPredicate))throw new Error("left Predicate should be an xdr.ClaimPredicate");if(!(t instanceof P.ClaimPredicate))throw new Error("right Predicate should be an xdr.ClaimPredicate");return P.ClaimPredicate.claimPredicateAnd([e,t])}static predicateOr(e,t){if(!(e instanceof P.ClaimPredicate))throw new Error("left Predicate should be an xdr.ClaimPredicate");if(!(t instanceof P.ClaimPredicate))throw new Error("right Predicate should be an xdr.ClaimPredicate");return P.ClaimPredicate.claimPredicateOr([e,t])}static predicateNot(e){if(!(e instanceof P.ClaimPredicate))throw new Error("Predicate should be an xdr.ClaimPredicate");return P.ClaimPredicate.claimPredicateNot(e)}static predicateBeforeAbsoluteTime(e){return P.ClaimPredicate.claimPredicateBeforeAbsoluteTime(P.Int64.fromString(e))}static predicateBeforeRelativeTime(e){return P.ClaimPredicate.claimPredicateBeforeRelativeTime(P.Int64.fromString(e))}static fromXDR(e){let t;if(e.switch()===P.ClaimantType.claimantTypeV0())return t=e.v0(),new this($t.encodeEd25519PublicKey(t.destination().ed25519()),t.predicate());throw new Error(`Invalid claimant type: ${e.switch().name}`)}toXDRObject(){const e=new P.ClaimantV0({destination:jt.fromPublicKey(this._destination).xdrAccountId(),predicate:this._predicate});return P.Claimant.claimantTypeV0(e)}get destination(){return this._destination}set destination(e){throw new Error("Claimant is immutable")}get predicate(){return this._predicate}set predicate(e){throw new Error("Claimant is immutable")}}class on{liquidityPoolId;constructor(e){if(!e)throw new Error("liquidityPoolId cannot be empty");if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Liquidity pool ID is not a valid hash");this.liquidityPoolId=e}static fromOperation(e){const t=e.switch();if(t===P.AssetType.assetTypePoolShare()){const t=e.liquidityPoolId().toString("hex");return new on(t)}throw new Error(`Invalid asset type: ${t.name}`)}toXDRObject(){const e=q.Buffer.from(this.liquidityPoolId,"hex");return P.TrustLineAsset.assetTypePoolShare(e)}getLiquidityPoolId(){return String(this.liquidityPoolId)}getAssetType(){return"liquidity_pool_shares"}equals(e){return this.liquidityPoolId===e.getLiquidityPoolId()}toString(){return`liquidity_pool:${this.liquidityPoolId}`}}function sn(e){return $t.isValidMed25519PublicKey(e)?function(e){const t=$t.decodeMed25519PublicKey(e);return P.MuxedAccount.keyTypeMuxedEd25519(new P.MuxedAccountMed25519({id:P.Uint64.fromXDR(t.subarray(-8)),ed25519:t.subarray(0,-8)}))}(e):P.MuxedAccount.keyTypeEd25519($t.decodeEd25519PublicKey(e))}function an(e){return e.switch().value===P.CryptoKeyType.keyTypeMuxedEd25519().value?function(e){if(e.switch()===P.CryptoKeyType.keyTypeEd25519())return an(e);const t=e.med25519();return $t.encodeMed25519PublicKey(q.Buffer.concat([t.ed25519(),t.id().toXDR("raw")]))}(e):$t.encodeEd25519PublicKey(e.ed25519())}function cn(e,t){if(!$t.isValidEd25519PublicKey(e))throw new Error("address should be a Stellar account ID (G...)");if("string"!=typeof t)throw new Error("id should be a string representing a number (uint64)");return P.MuxedAccount.keyTypeMuxedEd25519(new P.MuxedAccountMed25519({id:P.Uint64.fromString(t),ed25519:$t.decodeEd25519PublicKey(e)}))}function un(e){if($t.isValidEd25519PublicKey(e))return e;if(!$t.isValidMed25519PublicKey(e))throw new TypeError(`expected muxed account (M...), got ${e}`);const t=sn(e);return $t.encodeEd25519PublicKey(t.med25519().ed25519())}var ln=function e(t){var n,r,o=/^(-?)0([xbo])(?=[^.])/i,s=/^-?(Infinity|NaN)$/,i=/^\s*\+(?!-)|^\s+|\s+$/g,a=b.prototype={constructor:b,toString:null,valueOf:null},c=new b(1),u=20,l=4,d=-7,p=21,h=-1e7,f=1e7,m=!1,g=!0,y=1,w=0,A={prefix:"",negativeSign:"-",positiveSign:"",groupSeparator:",",groupSize:3,secondaryGroupSize:0,decimalSeparator:".",fractionGroupSeparator:"",fractionGroupSize:0,suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz";function b(e,t){var n,r,a,c,u=this;if(!(u instanceof b))return new b(e,t);if(c=typeof e,null==t){if(k(e))return u.s=e.s,void(!e.c||e.e>f?u.c=u.e=null:e.e<h?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if("number"==c){if(0*e!=0)return u.s=isNaN(e)?null:e<0?-1:1,void(u.c=u.e=null);if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(n=0,r=e;r>=10;r/=10,n++);return void(n>f?u.c=u.e=null:(u.e=n,u.c=[e]))}return v(u,String(e))}if("bigint"==c)return u.s=e<0?(e=-e,-1):1,v(u,String(e));if("string"==c)a=e;else{if(g)throw Error(fn+"BigNumber, string, number, or BigInt expected: "+e);a=String(e)}if(dn.test(a))return u.s=45==a.charCodeAt(0)?(a=a.slice(1),-1):1,v(u,a);if(a=a.replace(i,""),s.test(a))return u.s=isNaN(a)?null:a<0?-1:1,void(u.c=u.e=null);if(a=a.replace(o,function(e,n,r){return t="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n}),t)return T(u,a,t,e);if(a=a.replace(/(\d)_(?=\d)/g,"$1"),dn.test(a))return u.s=45==a.charCodeAt(0)?(a=a.slice(1),-1):1,v(u,a);if(g)throw Error(fn+"Not a number: "+e);u.s=u.c=u.e=null}else{if("string"!=c){if(g)throw Error(fn+"String expected: "+e);e=String(e)}En(t,2,S.length,"Base"),T(u,e.replace(i,""),t,e)}}function v(e,t){var n,r,o;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(o=t.length;48===t.charCodeAt(--o););if(t=t.slice(r,++o))if(o-=r,(n=n-r-1)>f)e.c=e.e=null;else if(n<h)e.c=[e.e=0];else{if(e.e=n,e.c=[],r=(n+1)%gn,n<0&&(r+=gn),r<o){for(r&&e.c.push(+t.slice(0,r)),o-=gn;r<o;)e.c.push(+t.slice(r,r+=gn));r=gn-(t=t.slice(r)).length}else r-=o;for(;r--;t+="0");e.c.push(+t)}else e.c=[e.e=0]}function T(e,t,n,o){var s,i,a=S.slice(0,n),c=0,u="",l=!1,d=!1,p=!1;for(e.s=45===t.charCodeAt(0)?(t=t.slice(1),-1):1,i=t.length;c<i;c++){if(s=t.charAt(c),!(a.indexOf(s)>=0)){if("_"==s){if(d&&c+1<i){d=!1;continue}}else if("."==s){if(0==c||!l&&d){if(c+1==i)break;0==c&&(u="0"),u+=s,l=!0,d=!1;continue}}else if(!p&&(t==t.toUpperCase()&&a==a.toLowerCase()&&(t=t.toLowerCase())||t==t.toLowerCase()&&a==a.toUpperCase()&&(t=t.toUpperCase()))){c=-1,u="",p=!0,l=d=!1;continue}if(g)throw Error(fn+"Not a base "+n+" number: "+o);return void(e.s=e.c=e.e=null)}u+=s,d=!0}v(e,r(u,n,10,e.s))}function E(e,t,n,r){var o,s,i,a,c;if(n=null==n?l:En(n,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)c=vn(e.c),c=1==r||2==r&&(i<=d||i>=p)?Cn(c,i):Bn(c,i,"0");else if(s=(e=x(new b(e),t,n)).e,a=(c=vn(e.c)).length,1==r||2==r&&(t<=s||s<=d)){for(;a<t;c+="0",a++);c=Cn(c,s)}else if(t-=i+(2===r&&s>i),c=Bn(c,s,"0"),s+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=s-a)>0)for(s+1==a&&(c+=".");t--;c+="0");return e.s<0&&o?"-"+c:c}function k(e){return e instanceof b||!!e&&!0===e._isBigNumber}function I(e,t){for(var n,r,o=1,s=new b(e[0]);o<e.length;o++)(!(r=new b(e[o])).s||(n=Tn(s,r))===t||0===n&&s.s===t)&&(s=r);return s}function C(e,t,n){for(var r=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,r++);return(n=r+n*gn-1)>f?e.c=e.e=null:n<h?e.c=[e.e=0]:(e.e=n,e.c=t),e}function B(e){var t,n={};for(t in A)A.hasOwnProperty(t)&&(n[t]=e.hasOwnProperty(t)?e[t]:A[t]);return n}function x(e,t,n,r){var o,s,i,a,c,u,l,d=e.c,p=wn;if(d){e:{for(o=1,a=d[0];a>=10;a/=10,o++);if((s=t-o)<0)s+=gn,i=t,c=d[u=0],l=hn(c/p[o-i-1]%10);else if((u=pn((s+1)/gn))>=d.length){if(!r)break e;for(;d.length<=u;d.push(0));c=l=0,o=1,i=(s%=gn)-gn+1}else{for(c=a=d[u],o=1;a>=10;a/=10,o++);l=(i=(s%=gn)-gn+o)<0?0:hn(c/p[o-i-1]%10)}if(r=r||t<0||null!=d[u+1]||(i<0?c:c%p[o-i-1]),r=n<4?(l||r)&&(0==n||n==(e.s<0?3:2)):l>5||5==l&&(4==n||r||6==n&&(s>0?i>0?c/p[o-i]:0:d[u-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,r?(t-=e.e+1,d[0]=p[(gn-t%gn)%gn],e.e=-t||0):d[0]=e.e=0,e;if(0==s?(d.length=u,a=1,u--):(d.length=u+1,a=p[gn-s],d[u]=i>0?hn(c/p[o-i]%p[i])*a:0),r)for(;;){if(0==u){for(s=1,i=d[0];i>=10;i/=10,s++);for(i=d[0]+=a,a=1;i>=10;i/=10,a++);s!=a&&(e.e++,d[0]==mn&&(d[0]=1));break}if(d[u]+=a,d[u]!=mn)break;d[u--]=0,a=1}for(s=d.length;0===d[--s];d.pop());}e.e>f?e.c=e.e=null:e.e<h&&(e.c=[e.e=0])}return e}function R(e){var t,n=e.e;return null===n?e.toString():(t=vn(e.c),t=n<=d||n>=p?Cn(t,n):Bn(t,n,"0"),e.s<0?"-"+t:t)}b.clone=e,b.ROUND_UP=0,b.ROUND_DOWN=1,b.ROUND_CEIL=2,b.ROUND_FLOOR=3,b.ROUND_HALF_UP=4,b.ROUND_HALF_DOWN=5,b.ROUND_HALF_EVEN=6,b.ROUND_HALF_CEIL=7,b.ROUND_HALF_FLOOR=8,b.EUCLID=9,b.config=b.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(fn+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(u=En(e[t],0,Sn,t)),e.hasOwnProperty(t="ROUNDING_MODE")&&(l=En(e[t],0,8,t)),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(kn(n=e[t])?(En(n[0],-Sn,0,t),En(n[1],0,Sn,t),d=n[0],p=n[1]):d=-(p=En(n,-Sn,Sn,t)<0?-n:n)),e.hasOwnProperty(t="RANGE")){if(!(n=e[t]))throw Error(fn+t+" cannot be zero: "+n);kn(n)?(En(n[0],-Sn,-1,t),En(n[1],1,Sn,t),h=n[0],f=n[1]):h=-(f=En(n,-Sn,Sn,t)<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(fn+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw m=!n,Error(fn+"crypto unavailable");m=n}else m=n}if(e.hasOwnProperty(t="STRICT")){if((n=e[t])!==!!n)throw Error(fn+t+" not true or false: "+n);g=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(y=En(e[t],0,9,t)),e.hasOwnProperty(t="POW_PRECISION")&&(w=En(e[t],0,Sn,t)),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(fn+t+" not an object: "+n);for(t in n)n.hasOwnProperty(t)&&A.hasOwnProperty(t)&&(A[t]=n[t])}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(fn+t+" invalid: "+n);S=n}}return{DECIMAL_PLACES:u,ROUNDING_MODE:l,EXPONENTIAL_AT:[d,p],RANGE:[h,f],CRYPTO:m,STRICT:g,MODULO_MODE:y,POW_PRECISION:w,FORMAT:A,ALPHABET:S}},b.fromFormat=function(e,t){if("string"!=typeof e)throw Error(fn+"Not a string: "+e);if(null==t)t=A;else{if("object"!=typeof t)throw Error(fn+"Argument not an object: "+t);t=B(t)}var n,r,o,s,i=t.negativeSign||"-",a=t.positiveSign||"",c=t.prefix||"",u=t.suffix||"",l=t.groupSeparator||"",d=t.decimalSeparator||".",p=t.fractionGroupSeparator||"";if(c&&0===e.indexOf(c)&&(e=e.slice(c.length)),u&&e.lastIndexOf(u)===e.length-u.length&&(e=e.slice(0,-u.length)),0===e.indexOf(i)?(e=e.slice(i.length),r=!0):a&&0===e.indexOf(a)&&(e=e.slice(a.length)),(n=e.indexOf(d))<0){if(l)for(;e.indexOf(l)>-1;)e=e.replace(l,"")}else{if(o=e.slice(0,n),s=e.slice(n+d.length),l)for(;o.indexOf(l)>-1;)o=o.replace(l,"");if(p)for(;s.indexOf(p)>-1;)s=s.replace(p,"");e=o+"."+s}return new b(r?"-"+e:e)},b.isBigNumber=function(e){if(!k(e))return!1;var t,n,r=e.c,o=e.e,s=e.s;if(!kn(r))return null===r&&null===o&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||o<-Sn||o>Sn||o!==hn(o))return!1;if(0===r[0])return 0===o&&1===r.length;if((t=(o+1)%gn)<1&&(t+=gn),String(r[0]).length!==t)return!1;for(t=0;t<r.length;t++)if((n=r[t])<0||n>=mn||n!==hn(n))return!1;return 0!==n},b.maximum=b.max=function(){return I(arguments,-1)},b.minimum=b.min=function(){return I(arguments,1)},b.random=function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return hn(Math.random()*e)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(e){var n,r,o,s,i,a=0,l=[],d=new b(c);if(e=null==e?u:En(e,0,Sn),s=pn(e/gn),m)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));a<s;)(i=131072*n[a]+(n[a+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[a]=r[0],n[a+1]=r[1]):(l.push(i%1e14),a+=2);a=s/2}else{if(!crypto.randomBytes)throw m=!1,Error(fn+"crypto unavailable");for(n=crypto.randomBytes(s*=7);a<s;)(i=281474976710656*(31&n[a])+1099511627776*n[a+1]+4294967296*n[a+2]+16777216*n[a+3]+(n[a+4]<<16)+(n[a+5]<<8)+n[a+6])>=9e15?crypto.randomBytes(7).copy(n,a):(l.push(i%1e14),a+=7);a=s/7}if(!m)for(;a<s;)(i=t())<9e15&&(l[a++]=i%1e14);for(s=l[--a],e%=gn,s&&e&&(i=wn[gn-e],l[a]=hn(s/i)*i);0===l[a];l.pop(),a--);if(a<0)l=[o=0];else{for(o=-1;0===l[0];l.splice(0,1),o-=gn);for(a=1,i=l[0];i>=10;i/=10,a++);a<gn&&(o-=gn-a)}return d.e=o,d.c=l,d}}(),b.sum=function(){for(var e=0,t=new b(0);e<arguments.length;)t=t.plus(arguments[e++]);return t},r=function(){var e="0123456789";function t(e,t,n,r){for(var o,s,i=[0],a=0,c=e.length;a<c;){for(s=i.length;s--;i[s]*=t);for(i[0]+=r.indexOf(e.charAt(a++)),o=0;o<i.length;o++)i[o]>n-1&&(null==i[o+1]&&(i[o+1]=0),i[o+1]+=i[o]/n|0,i[o]%=n)}return i.reverse()}return function(r,o,s,i,a){var c,d,p,h,f,m,g,y,A=r.indexOf("."),v=u,T=l;for(A>=0&&(h=w,w=0,r=r.replace(".",""),m=(y=new b(o)).pow(r.length-A),w=h,y.c=t(Bn(vn(m.c),m.e,"0"),10,s,e),y.e=y.c.length),p=h=(g=t(r,o,s,a?(c=S,e):(c=e,S))).length;0==g[--h];g.pop());if(!g[0])return c.charAt(0);if(A<0?--p:(m.c=g,m.e=p,m.s=i,g=(m=n(m,y,v,T,s)).c,f=m.r,p=m.e),A=g[d=p+v+1],h=s/2,f=f||d<0||null!=g[d+1],f=T<4?(null!=A||f)&&(0==T||T==(m.s<0?3:2)):A>h||A==h&&(4==T||f||6==T&&1&g[d-1]||T==(m.s<0?8:7)),d<1||!g[0])r=f?Bn(c.charAt(1),-v,c.charAt(0)):c.charAt(0);else{if(d<g.length&&(g.length=d),f)for(--s;++g[--d]>s;)g[d]=0,d||(++p,g=[1].concat(g));for(h=g.length;!g[--h];);for(A=0,r="";A<=h;r+=c.charAt(g[A++]));r=Bn(r,p,c.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,o,s,i,a=0,c=e.length,u=t%An,l=t/An|0;for(e=e.slice();c--;)a=((o=u*(s=e[c]%An)+(r=l*s+(i=e[c]/An|0)*u)%An*An+a)/n|0)+(r/An|0)+l*i,e[c]=o%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var o,s;if(n!=r)s=n>r?1:-1;else for(o=s=0;o<n;o++)if(e[o]!=t[o]){s=e[o]>t[o]?1:-1;break}return s}function n(e,t,n,r){for(var o=0;n--;)e[n]-=o,o=e[n]<t[n]?1:0,e[n]=o*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,o,s,i,a){var c,u,l,d,p,h,f,m,g,y,w,A,S,v,T,E,k,I=r.s==o.s?1:-1,C=r.c,B=o.c;if(!(C&&C[0]&&B&&B[0]))return new b(r.s&&o.s&&(C?!B||C[0]!=B[0]:B)?C&&0==C[0]||!B?0*I:I/0:NaN);for(g=(m=new b(I)).c=[],I=s+(u=r.e-o.e)+1,a||(a=mn,u=bn(r.e/gn)-bn(o.e/gn),I=I/gn|0),l=0;B[l]==(C[l]||0);l++);if(B[l]>(C[l]||0)&&u--,I<0)g.push(1),d=!0;else{for(v=C.length,E=B.length,l=0,I+=2,(p=hn(a/(B[0]+1)))>1&&(B=e(B,p,a),C=e(C,p,a),E=B.length,v=C.length),S=E,w=(y=C.slice(0,E)).length;w<E;y[w++]=0);k=B.slice(),k=[0].concat(k),T=B[0],B[1]>=a/2&&T++;do{if(p=0,(c=t(B,y,E,w))<0){if(A=y[0],E!=w&&(A=A*a+(y[1]||0)),(p=hn(A/T))>1)for(p>=a&&(p=a-1),f=(h=e(B,p,a)).length,w=y.length;1==t(h,y,f,w);)p--,n(h,E<f?k:B,f,a),f=h.length,c=1;else 0==p&&(c=p=1),f=(h=B.slice()).length;if(f<w&&(h=[0].concat(h)),n(y,h,w,a),w=y.length,-1==c)for(;t(B,y,E,w)<1;)p++,n(y,E<w?k:B,w,a),w=y.length}else 0===c&&(p++,y=[0]);g[l++]=p,y[0]?y[w++]=C[S]||0:(y=[C[S]],w=1)}while((S++<v||null!=y[0])&&I--);d=null!=y[0],g[0]||g.splice(0,1)}if(a==mn){for(l=1,I=g[0];I>=10;I/=10,l++);x(m,s+(m.e=l+u*gn-1)+1,i,d)}else m.e=u,m.r=+d;return m}}(),a.absoluteValue=a.abs=function(){var e=new b(this);return e.s<0&&(e.s=1),e},a.comparedTo=function(e,t){return Tn(this,new b(e,t))},a.decimalPlaces=a.dp=function(e,t){var n,r,o,s=this;if(null!=e)return x(new b(s),En(e,-Sn,Sn)+s.e+1,null==t?l:En(t,0,8));if(!(n=s.c))return null;if(r=((o=n.length-1)-bn(this.e/gn))*gn,o=n[o])for(;o%10==0;o/=10,r--);return r<0&&(r=0),r},a.dividedBy=a.div=function(e,t){return n(this,new b(e,t),u,l)},a.dividedToIntegerBy=a.idiv=function(e,t){return n(this,new b(e,t),0,1)},a.exponentiatedBy=a.pow=function(e,t){var n,r,o,s,i,a,u,d,p=this;if((e=new b(e)).c&&!e.isInteger())throw Error(fn+"Exponent not an integer: "+R(e));if(null!=t&&(t=new b(t)),i=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return d=new b(Math.pow(+R(p),i?e.s*(2-In(e)):+R(e))),t?d.mod(t):d;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new b(NaN);(r=!a&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||i&&p.c[1]>=24e7:p.c[0]<8e13||i&&p.c[0]<=9999975e7)))return s=p.s<0&&In(e)?-0:0,p.e>-1&&(s=1/s),new b(a?1/s:s);w&&(s=pn(w/gn+2))}for(i?(n=new b(.5),a&&(e.s=1),u=In(e)):u=(o=Math.abs(+R(e)))%2,d=new b(c);;){if(u){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):r&&(d=d.mod(t))}if(o){if(0===(o=hn(o/2)))break;u=o%2}else if(x(e=e.times(n),e.e+1,1),e.e>14)u=In(e);else{if(0===(o=+R(e)))break;u=o%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):r&&(p=p.mod(t))}return r?d:(a&&(d=c.div(d)),t?d.mod(t):s?x(d,w,l,void 0):d)},a.integerValue=function(e){var t=new b(this);return x(t,t.e+1,null==e?l:En(e,0,8))},a.isEqualTo=a.eq=function(e,t){return 0===Tn(this,new b(e,t))},a.isFinite=function(){return!!this.c},a.isGreaterThan=a.gt=function(e,t){return Tn(this,new b(e,t))>0},a.isGreaterThanOrEqualTo=a.gte=function(e,t){return 1===(t=Tn(this,new b(e,t)))||0===t},a.isInteger=function(){return!!this.c&&bn(this.e/gn)>this.c.length-2},a.isLessThan=a.lt=function(e,t){return Tn(this,new b(e,t))<0},a.isLessThanOrEqualTo=a.lte=function(e,t){return-1===(t=Tn(this,new b(e,t)))||0===t},a.isNaN=function(){return!this.s},a.isNegative=function(){return this.s<0},a.isPositive=function(){return this.s>0},a.isZero=function(){return!!this.c&&0==this.c[0]},a.minus=function(e,t){var n,r,o,s,i=this,a=i.s;if(t=(e=new b(e,t)).s,!a||!t)return new b(NaN);if(a!=t)return e.s=-t,i.plus(e);var c=i.e/gn,u=e.e/gn,d=i.c,p=e.c;if(!c||!u){if(!d||!p)return d?(e.s=-t,e):new b(p?i:NaN);if(!d[0]||!p[0])return p[0]?(e.s=-t,e):new b(d[0]?i:3==l?-0:0)}if(c=bn(c),u=bn(u),d=d.slice(),a=c-u){for((s=a<0)?(a=-a,o=d):(u=c,o=p),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(r=(s=(a=d.length)<(t=p.length))?a:t,a=t=0;t<r;t++)if(d[t]!=p[t]){s=d[t]<p[t];break}if(s&&(o=d,d=p,p=o,e.s=-e.s),(t=(r=p.length)-(n=d.length))>0)for(;t--;d[n++]=0);for(t=mn-1;r>a;){if(d[--r]<p[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=mn}d[r]-=p[r]}for(;0==d[0];d.splice(0,1),--u);return d[0]?C(e,d,u):(e.s=3==l?-1:1,e.c=[e.e=0],e)},a.modulo=a.mod=function(e,t){var r,o,s=this;return e=new b(e,t),!s.c||!e.s||e.c&&!e.c[0]?new b(NaN):!e.c||s.c&&!s.c[0]?new b(s):(9==y?(o=e.s,e.s=1,r=n(s,e,0,3),e.s=o,r.s*=o):r=n(s,e,0,y),(e=s.minus(r.times(e))).c[0]||1!=y||(e.s=s.s),e)},a.multipliedBy=a.times=function(e,t){var n,r,o,s,i,a,c,u,l,d,p,h,f,m,g,y=this,w=y.c,A=(e=new b(e,t)).c;if(!(w&&A&&w[0]&&A[0]))return!y.s||!e.s||w&&!w[0]&&!A||A&&!A[0]&&!w?e.c=e.e=e.s=null:(e.s*=y.s,w&&A?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=bn(y.e/gn)+bn(e.e/gn),e.s*=y.s,(c=w.length)<(d=A.length)&&(f=w,w=A,A=f,o=c,c=d,d=o),o=c+d,f=[];o--;f.push(0));for(m=mn,g=An,o=d;--o>=0;){for(n=0,p=A[o]%g,h=A[o]/g|0,s=o+(i=c);s>o;)n=((u=p*(u=w[--i]%g)+(a=h*u+(l=w[i]/g|0)*p)%g*g+f[s]+n)/m|0)+(a/g|0)+h*l,f[s--]=u%m;f[s]=n}return n?++r:f.splice(0,1),C(e,f,r)},a.negated=function(){var e=new b(this);return e.s=-e.s||null,e},a.plus=function(e,t){var n,r=this,o=r.s;if(t=(e=new b(e,t)).s,!o||!t)return new b(NaN);if(o!=t)return e.s=-t,r.minus(e);var s=r.e/gn,i=e.e/gn,a=r.c,c=e.c;if(!s||!i){if(!a||!c)return new b(o/0);if(!a[0]||!c[0])return c[0]?e:new b(a[0]?r:0*o)}if(s=bn(s),i=bn(i),a=a.slice(),o=s-i){for(o>0?(i=s,n=c):(o=-o,n=a),n.reverse();o--;n.push(0));n.reverse()}for((o=a.length)-(t=c.length)<0&&(n=c,c=a,a=n,t=o),o=0;t;)o=(a[--t]=a[t]+c[t]+o)/mn|0,a[t]=mn===a[t]?0:a[t]%mn;return o&&(a=[o].concat(a),++i),C(e,a,i)},a.precision=a.sd=function(e,t){var n,r,o,s=this;if(null!=e&&e!==!!e)return x(new b(s),En(e,1,Sn),null==t?l:En(t,0,8));if(!(n=s.c))return null;if(r=(o=n.length-1)*gn+1,o=n[o]){for(;o%10==0;o/=10,r--);for(o=n[0];o>=10;o/=10,r++);}return e&&s.e+1>r&&(r=s.e+1),r},a.shiftedBy=function(e){return this.times("1e"+En(e,-yn,yn))},a.squareRoot=a.sqrt=function(){var e,t,r,o,s,i=this,a=i.c,c=i.s,d=i.e,p=u+4,h=new b("0.5");if(1!==c||!a||!a[0])return new b(!c||c<0&&(!a||a[0])?NaN:a?i:1/0);if(0==(c=Math.sqrt(+R(i)))||c==1/0?(((t=vn(a)).length+d)%2==0&&(t+="0"),c=Math.sqrt(+t),d=bn((d+1)/2)-(d<0||d%2),r=new b(t=c==1/0?"5e"+d:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+d)):r=new b(c+""),r.c[0])for((c=(d=r.e)+p)<3&&(c=0);;)if(s=r,r=h.times(s.plus(n(i,s,p,1))),vn(s.c).slice(0,c)===(t=vn(r.c)).slice(0,c)){if(r.e<d&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(x(r,r.e+u+2,1),e=!r.times(r).eq(i));break}if(!o&&(x(s,s.e+u+2,0),s.times(s).eq(i))){r=s;break}p+=4,c+=4,o=1}return x(r,r.e+u+1,l,e)},"function"==typeof BigInt&&(a.toBigInt=function(e){var t=this;return t.c?BigInt(E(t,t.e+1,e)):null});a.toExponential=function(e,t){return E(this,null==e?e:En(e,0,Sn)+1,t,1)},a.toFixed=function(e,t){return E(this,null==e?e:En(e,-Sn,Sn)+this.e+1,t)},a.toFormat=function(e,t,n){var r,o,s,i,a=this;if(null==n)n=A,null!=e&&(null!=t?"object"==typeof t&&(n=B(t),t=null):"object"!=typeof e||kn(e)||(n=B(e),e=t=null));else{if("object"!=typeof n)throw Error(fn+"Argument not an object: "+n);n=B(n)}if(null!=e)if(kn(e)&&e.length<=2){if(o=e[0],s=e[1],e=a.dp(),null!=s&&e>En(s,0,Sn)&&(e=s),null!=o&&0!==En(o,0,Sn)){if(null!=s&&o>s)throw Error(fn+"Minimum must not exceed maximum");e<o&&(e=o)}}else En(e,-Sn,Sn);if((r=45===(i=a.toFixed(e,t)).charCodeAt(0))&&(i=i.slice(1)),a.c){var c,u=i.split("."),l=+n.groupSize,d=+n.secondaryGroupSize,p=n.groupSeparator||"",h=u[0],f=u[1],m=h.length;if(d&&(c=l,l=d,d=c,m-=c),l>0&&m>0){for(c=m%l||l,i=h.substr(0,c);c<m;c+=l)i+=p+h.substr(c,l);d>0&&(i+=p+h.slice(c))}else i=h;f&&((c=+n.fractionGroupSize)&&(f=f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||""))),i+=(n.decimalSeparator||"")+f)}return(n.prefix||"")+(r?n.negativeSign||"":a.s>0&&n.positiveSign||"")+i+(n.suffix||"")},a.toFraction=function(e){var t,r,o,s,i,a,u,d,p,h,m,g,y=this,w=y.c;if(null!=e&&(!(u=new b(e)).isInteger()&&(u.c||1!==u.s)||u.lt(c)))throw Error(fn+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+R(u));if(!w)return[new b(y.s||0),new b(0)];for(t=new b(c),p=r=new b(c),o=d=new b(c),g=vn(w),i=t.e=g.length-y.e-1,t.c[0]=wn[(a=i%gn)<0?gn+a:a],e=!e||u.comparedTo(t)>0?i>0?t:p:u,a=f,f=1/0,u=new b(g),d.c[0]=0;h=n(u,t,0,1),1!=(s=r.plus(h.times(o))).comparedTo(e);)r=o,o=s,p=d.plus(h.times(s=p)),d=s,t=u.minus(h.times(s=t)),u=s;return s=n(e.minus(r),o,0,1),d=d.plus(s.times(p)),r=r.plus(s.times(o)),d.s=p.s=y.s,m=n(p,o,i*=2,l).minus(y).abs().comparedTo(n(d,r,i,l).minus(y).abs())<1?[p,o]:[d,r],f=a,m},a.toNumber=function(){return+R(this)},a.toObject=function(){var e=this;return{c:e.c?e.c.slice():null,e:e.e,s:e.s}},a.toPrecision=function(e,t){return E(this,null==e?e:En(e,1,Sn),t,2)},a.toString=function(e){var t,n=this,o=n.s,s=n.e;return null===s?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=s<=d||s>=p?Cn(vn(n.c),s):Bn(vn(n.c),s,"0"):(En(e,2,S.length,"Base"),t=r(Bn(vn(n.c),s,"0"),10,e,o,!0)),o<0&&n.c[0]&&(t="-"+t)),t},a.valueOf=a.toJSON=function(){return R(this)},a._isBigNumber=!0,null!=t&&b.set(t);return b}(),dn=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,pn=Math.ceil,hn=Math.floor,fn="[BigNumber Error] ",mn=1e14,gn=14,yn=9007199254740991,wn=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],An=1e7,Sn=1e9;function bn(e){var t=0|e;return e>0||e===t?t:t-1}function vn(e){for(var t,n,r=1,o=e.length,s=e[0]+"";r<o;){for(t=e[r++]+"",n=gn-t.length;n--;t="0"+t);s+=t}for(o=s.length;48===s.charCodeAt(--o););return s.slice(0,o+1||1)}function Tn(e,t){var n,r,o=e.c,s=t.c,i=e.s,a=t.s,c=e.e,u=t.e;if(!i||!a)return null;if(n=o&&!o[0],r=s&&!s[0],n||r)return n?r?0:-a:i;if(i!=a)return i;if(n=i<0,r=c==u,!o||!s)return r?0:!o^n?1:-1;if(!r)return c>u^n?1:-1;for(a=(c=o.length)<(u=s.length)?c:u,i=0;i<a;i++)if(o[i]!=s[i])return o[i]>s[i]^n?1:-1;return c==u?0:c>u^n?1:-1}function En(e,t,n,r){if(e<t||e>n||e!==hn(e))throw Error(fn+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e));return e}function kn(e){return"[object Array]"=={}.toString.call(e)}function In(e){var t=e.c.length-1;return bn(e.e/gn)==t&&e.c[t]%2!=0}function Cn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Bn(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(++t>(r=e.length)){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}const xn=ln.clone({STRICT:!0}),Rn=2147483647,_n=new xn(Rn);const Pn=1e7;function On(e,t){if(t.source)try{e.sourceAccount=sn(t.source)}catch{throw new Error("Source address is invalid")}}function Un(e,t,n=null){if(void 0===t)return;const r="string"==typeof t?""===t.trim()?NaN:Number(t):t;if("number"!=typeof r||!Number.isFinite(r)||r%1!=0)throw new Error(`${e} value is invalid`);if(r<0)throw new Error(`${e} value must be unsigned`);if(!n||n(r,e))return r;throw new Error(`${e} value is invalid`)}function Ln(e){const t=new xn(e).times(Pn);return P.Int64.fromString(t.toString())}function Nn(e){return new xn(e.toString()).div(Pn).toFixed(7)}function Vn(e){return new xn(e.n()).div(new xn(e.d())).toString()}function Fn(e){let t;if("object"==typeof e&&"n"in e&&"d"in e)t=new P.Price(e);else{const n=new xn(e);if(!n.gt(0)||!n.isFinite())throw new Error("price must be positive");const r=function(e){let t,n,r=new xn(e);const o=[[new xn(0),new xn(1)],[new xn(1),new xn(0)]];let s=2;for(;!r.gt(Rn);){t=r.integerValue(xn.ROUND_FLOOR),n=r.minus(t);const e=o[s-1],i=o[s-2];if(!e||!i)throw new Error(`Continued fraction approximation failed: missing fraction elements at indices ${s-1} and/or ${s-2}`);const a=t.times(e[0]).plus(i[0]),c=t.times(e[1]).plus(i[1]);if(a.gt(Rn)||c.gt(Rn))break;if(o.push([a,c]),n.eq(0))break;r=new xn(1).div(n),s+=1}const i=o[o.length-1];if(!i)throw new Error("Missing last fraction element in continued fraction approximation");const[a,c]=i;if(a.isZero()||c.isZero()){if(new xn(e).isZero())throw new Error("Couldn't find approximation");const t=o[o.length-1],n=o[o.length-2];if(t&&n){let e=_n;if(t[0].gt(0)&&(e=xn.min(e,_n.minus(n[0]).div(t[0]).integerValue(xn.ROUND_FLOOR))),t[1].gt(0)&&(e=xn.min(e,_n.minus(n[1]).div(t[1]).integerValue(xn.ROUND_FLOOR))),e.gte(1)){const r=e.times(t[0]).plus(n[0]),o=e.times(t[1]).plus(n[1]);if(!r.isZero()&&!o.isZero())return[r.toNumber(),o.toNumber()]}}throw new Error("Couldn't find approximation")}return[a.toNumber(),c.toNumber()]}(e);t=new P.Price({n:parseInt(String(r[0]),10),d:parseInt(String(r[1]),10)})}if(t.n()<0||t.d()<=0)throw new Error("price must be positive");return t}function Dn(e,t=!1){if("string"!=typeof e)return!1;let n;try{n=new xn(e)}catch{return!1}return!(!t&&n.isZero()||n.isNegative()||n.times(Pn).gt(new xn("9223372036854775807").toString())||(n.decimalPlaces()??0)>7||n.isNaN()||!n.isFinite())}function Mn(e){return`${e} argument must be of type String, represent a positive number and have at most 7 digits after the decimal`}function qn(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!Dn(e.amount,!0))throw new TypeError(Mn("amount"));const r=Ln(e.amount);if(void 0===e.price)throw new TypeError("price argument is required");const o=Fn(e.price),s=void 0!==e.offerId?e.offerId.toString():"0",i=P.Int64.fromString(s),a=new P.ManageSellOfferOp({selling:t,buying:n,amount:r,price:o,offerId:i}),c={sourceAccount:null,body:P.OperationBody.manageSellOffer(a)};return On(c,e),new P.Operation(c)}function Hn(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!Dn(e.amount))throw new TypeError(Mn("amount"));const r=Ln(e.amount);if(void 0===e.price)throw new TypeError("price argument is required");const o=Fn(e.price),s=new P.CreatePassiveSellOfferOp({selling:t,buying:n,amount:r,price:o}),i={sourceAccount:null,body:P.OperationBody.createPassiveSellOffer(s)};return On(i,e),new P.Operation(i)}function Gn(e){let t;try{t=P.OperationBody.accountMerge(sn(e.destination))}catch{throw new Error("destination is invalid")}const n={sourceAccount:null,body:t};return On(n,e),new P.Operation(n)}function $n(e){if(!$t.isValidEd25519PublicKey(e.trustor))throw new Error("trustor is invalid");const t=jt.fromPublicKey(e.trustor).xdrAccountId();let n,r;if(e.assetCode.length<=4){const t=q.Buffer.from(e.assetCode.padEnd(4,"\0"));n=P.AssetCode.assetTypeCreditAlphanum4(t)}else{if(!(e.assetCode.length<=12))throw new Error("Asset code must be 12 characters at max.");{const t=q.Buffer.from(e.assetCode.padEnd(12,"\0"));n=P.AssetCode.assetTypeCreditAlphanum12(t)}}if("boolean"==typeof e.authorize)r=e.authorize?P.TrustLineFlags.authorizedFlag().value:0;else{if(null==e.authorize)throw new Error("authorize is required");r=e.authorize}const o=new P.AllowTrustOp({trustor:t,asset:n,authorize:r}),s={sourceAccount:null,body:P.OperationBody.allowTrust(o)};return On(s,e),new P.Operation(s)}function Xn(e){if("string"!=typeof e.bumpTo)throw new Error("bumpTo must be a string");try{new xn(e.bumpTo)}catch{throw new Error("bumpTo must be a stringified number")}const t=P.Int64.fromString(e.bumpTo),n=new P.BumpSequenceOp({bumpTo:t}),r={sourceAccount:null,body:P.OperationBody.bumpSequence(n)};return On(r,e),new P.Operation(r)}function Kn(e){const t=e.asset??e.line;let n;if(t instanceof Qt)n=t.toChangeTrustXDRObject();else{if(!(t instanceof nn))throw new TypeError("asset must be Asset or LiquidityPoolAsset");n=t.toXDRObject()}if(void 0!==e.limit&&!Dn(e.limit,!0))throw new TypeError(Mn("limit"));const r=e.limit?Ln(e.limit):P.Int64.fromString("9223372036854775807"),o=new P.ChangeTrustOp({line:n,limit:r}),s={sourceAccount:null,body:P.OperationBody.changeTrust(o)};return On(s,e),new P.Operation(s)}function Wn(e){if(!$t.isValidEd25519PublicKey(e.destination))throw new Error("destination is invalid");if(!Dn(e.startingBalance,!0))throw new TypeError(Mn("startingBalance"));const t=new P.CreateAccountOp({destination:jt.fromPublicKey(e.destination).xdrAccountId(),startingBalance:Ln(e.startingBalance)}),n={sourceAccount:null,body:P.OperationBody.createAccount(t)};return On(n,e),new P.Operation(n)}function Zn(e){if(!(e.asset instanceof Qt))throw new Error("must provide an asset for create claimable balance operation");if(!Dn(e.amount))throw new TypeError(Mn("amount"));if(!Array.isArray(e.claimants)||0===e.claimants.length)throw new Error("must provide at least one claimant");const t=e.asset.toXDRObject(),n=Ln(e.amount),r=e.claimants.map(e=>e.toXDRObject()),o=new P.CreateClaimableBalanceOp({asset:t,amount:n,claimants:r}),s={sourceAccount:null,body:P.OperationBody.createClaimableBalance(o)};return On(s,e),new P.Operation(s)}function zn(e={}){jn(e.balanceId);const t=P.ClaimableBalanceId.fromXDR(e.balanceId,"hex"),n=new P.ClaimClaimableBalanceOp({balanceId:t}),r={sourceAccount:null,body:P.OperationBody.claimClaimableBalance(n)};return On(r,e),new P.Operation(r)}function jn(e){if("string"!=typeof e||72!==e.length)throw new Error("must provide a valid claimable balance id")}function Yn(e={}){jn(e.balanceId);const t=P.ClaimableBalanceId.fromXDR(e.balanceId,"hex"),n={sourceAccount:null,body:P.OperationBody.clawbackClaimableBalance(new P.ClawbackClaimableBalanceOp({balanceId:t}))};return On(n,e),new P.Operation(n)}function Jn(e={}){const t={sourceAccount:null,body:P.OperationBody.inflation()};return On(t,e),new P.Operation(t)}function Qn(e){if(!("string"==typeof e.name&&e.name.length<=64))throw new Error("name must be a string, up to 64 characters");if("string"!=typeof e.value&&!q.Buffer.isBuffer(e.value)&&null!==e.value&&void 0!==e.value)throw new Error("value must be a string, Buffer or null");let t;if(t="string"==typeof e.value?q.Buffer.from(e.value):e.value??null,null!==t&&t.length>64)throw new Error("value cannot be longer that 64 bytes");const n=new P.ManageDataOp({dataName:e.name,dataValue:t}),r={sourceAccount:null,body:P.OperationBody.manageData(n)};return On(r,e),new P.Operation(r)}function er(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!Dn(e.buyAmount,!0))throw new TypeError(Mn("buyAmount"));const r=Ln(e.buyAmount);if(void 0===e.price)throw new TypeError("price argument is required");const o=Fn(e.price),s=void 0!==e.offerId?e.offerId.toString():"0",i=P.Int64.fromString(s),a=new P.ManageBuyOfferOp({selling:t,buying:n,buyAmount:r,price:o,offerId:i}),c={sourceAccount:null,body:P.OperationBody.manageBuyOffer(a)};return On(c,e),new P.Operation(c)}function tr(e){if(!e.sendAsset)throw new Error("Must specify a send asset");if(!Dn(e.sendMax))throw new TypeError(Mn("sendMax"));if(!e.destAsset)throw new Error("Must provide a destAsset for a payment operation");if(!Dn(e.destAmount))throw new TypeError(Mn("destAmount"));let t;try{t=sn(e.destination)}catch{throw new Error("destination is invalid")}const n=e.path?e.path:[],r=new P.PathPaymentStrictReceiveOp({sendAsset:e.sendAsset.toXDRObject(),sendMax:Ln(e.sendMax),destination:t,destAsset:e.destAsset.toXDRObject(),destAmount:Ln(e.destAmount),path:n.map(e=>e.toXDRObject())}),o={sourceAccount:null,body:P.OperationBody.pathPaymentStrictReceive(r)};return On(o,e),new P.Operation(o)}function nr(e){if(!e.sendAsset)throw new Error("Must specify a send asset");if(!Dn(e.sendAmount))throw new TypeError(Mn("sendAmount"));if(!e.destAsset)throw new Error("Must provide a destAsset for a payment operation");if(!Dn(e.destMin))throw new TypeError(Mn("destMin"));const t=e.sendAsset.toXDRObject(),n=Ln(e.sendAmount);let r;try{r=sn(e.destination)}catch{throw new Error("destination is invalid")}const o=e.destAsset.toXDRObject(),s=Ln(e.destMin),i=(e.path??[]).map(e=>e.toXDRObject()),a=new P.PathPaymentStrictSendOp({sendAsset:t,sendAmount:n,destination:r,destAsset:o,destMin:s,path:i}),c={sourceAccount:null,body:P.OperationBody.pathPaymentStrictSend(a)};return On(c,e),new P.Operation(c)}function rr(e){if(!e.asset)throw new Error("Must provide an asset for a payment operation");if(!Dn(e.amount))throw new TypeError(Mn("amount"));let t;try{t=sn(e.destination)}catch{throw new Error("destination is invalid")}const n=new P.PaymentOp({destination:t,asset:e.asset.toXDRObject(),amount:Ln(e.amount)}),r={sourceAccount:null,body:P.OperationBody.payment(n)};return On(r,e),new P.Operation(r)}function or(e,t){if(e>=0&&e<=255)return!0;throw new Error(`${t} value must be between 0 and 255`)}function sr(e){let t=null;if(e.inflationDest){if(!$t.isValidEd25519PublicKey(e.inflationDest))throw new Error("inflationDest is invalid");t=jt.fromPublicKey(e.inflationDest).xdrAccountId()}const n=Un("clearFlags",e.clearFlags)??null,r=Un("setFlags",e.setFlags)??null,o=Un("masterWeight",e.masterWeight,or)??null,s=Un("lowThreshold",e.lowThreshold,or)??null,i=Un("medThreshold",e.medThreshold,or)??null,a=Un("highThreshold",e.highThreshold,or)??null;if(void 0!==e.homeDomain&&"string"!=typeof e.homeDomain)throw new TypeError("homeDomain argument must be of type String");const c=e.homeDomain;let u=null;if(e.signer){const t=Un("signer.weight",e.signer.weight,or);let n,r=0;if(e.signer.ed25519PublicKey){if(!$t.isValidEd25519PublicKey(e.signer.ed25519PublicKey))throw new Error("signer.ed25519PublicKey is invalid.");const t=$t.decodeEd25519PublicKey(e.signer.ed25519PublicKey);n=P.SignerKey.signerKeyTypeEd25519(t),r+=1}if(e.signer.preAuthTx){let t;if(t="string"==typeof e.signer.preAuthTx?q.Buffer.from(e.signer.preAuthTx,"hex"):e.signer.preAuthTx,!q.Buffer.isBuffer(t)||32!==t.length)throw new Error("signer.preAuthTx must be 32 bytes Buffer.");n=P.SignerKey.signerKeyTypePreAuthTx(t),r+=1}if(e.signer.sha256Hash){let t;if(t="string"==typeof e.signer.sha256Hash?q.Buffer.from(e.signer.sha256Hash,"hex"):e.signer.sha256Hash,!q.Buffer.isBuffer(t)||32!==t.length)throw new Error("signer.sha256Hash must be 32 bytes Buffer.");n=P.SignerKey.signerKeyTypeHashX(t),r+=1}if(e.signer.ed25519SignedPayload){if(!$t.isValidSignedPayload(e.signer.ed25519SignedPayload))throw new Error("signer.ed25519SignedPayload is invalid.");const t=$t.decodeSignedPayload(e.signer.ed25519SignedPayload),o=P.SignerKeyEd25519SignedPayload.fromXDR(t);n=P.SignerKey.signerKeyTypeEd25519SignedPayload(o),r+=1}if(1!==r)throw new Error("Signer object must contain exactly one of signer.ed25519PublicKey, signer.sha256Hash, signer.preAuthTx, or signer.ed25519SignedPayload.");if(void 0===t)throw new Error("signer weight is required.");if(void 0===n)throw new Error("signer key is required.");u=new P.Signer({key:n,weight:t})}const l=new P.SetOptionsOp({inflationDest:t,clearFlags:n,setFlags:r,masterWeight:o,lowThreshold:s,medThreshold:i,highThreshold:a,homeDomain:c,signer:u}),d={sourceAccount:null,body:P.OperationBody.setOptions(l)};return On(d,e),new P.Operation(d)}function ir(e){if(!$t.isValidEd25519PublicKey(e.sponsoredId))throw new Error("sponsoredId is invalid");const t=new P.BeginSponsoringFutureReservesOp({sponsoredId:jt.fromPublicKey(e.sponsoredId).xdrAccountId()}),n={sourceAccount:null,body:P.OperationBody.beginSponsoringFutureReserves(t)};return On(n,e),new P.Operation(n)}function ar(e={}){const t={sourceAccount:null,body:P.OperationBody.endSponsoringFutureReserves()};return On(t,e),new P.Operation(t)}function cr(e={}){if(!$t.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");const t=P.LedgerKey.account(new P.LedgerKeyAccount({accountId:jt.fromPublicKey(e.account).xdrAccountId()})),n=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:P.OperationBody.revokeSponsorship(n)};return On(r,e),new P.Operation(r)}function ur(e={}){if(!$t.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");let t;if(e.asset instanceof Qt)t=e.asset.toTrustLineXDRObject();else{if(!(e.asset instanceof on))throw new TypeError("asset must be an Asset or LiquidityPoolId");t=e.asset.toXDRObject()}const n=P.LedgerKey.trustline(new P.LedgerKeyTrustLine({accountId:jt.fromPublicKey(e.account).xdrAccountId(),asset:t})),r=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(n),o={sourceAccount:null,body:P.OperationBody.revokeSponsorship(r)};return On(o,e),new P.Operation(o)}function lr(e={}){if(!$t.isValidEd25519PublicKey(e.seller))throw new Error("seller is invalid");if("string"!=typeof e.offerId)throw new Error("offerId is invalid");const t=P.LedgerKey.offer(new P.LedgerKeyOffer({sellerId:jt.fromPublicKey(e.seller).xdrAccountId(),offerId:P.Int64.fromString(e.offerId)})),n=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:P.OperationBody.revokeSponsorship(n)};return On(r,e),new P.Operation(r)}function dr(e={}){if(!$t.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");if("string"!=typeof e.name||e.name.length>64)throw new Error("name must be a string, up to 64 characters");const t=P.LedgerKey.data(new P.LedgerKeyData({accountId:jt.fromPublicKey(e.account).xdrAccountId(),dataName:e.name})),n=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:P.OperationBody.revokeSponsorship(n)};return On(r,e),new P.Operation(r)}function pr(e={}){if("string"!=typeof e.balanceId)throw new Error("balanceId is invalid");const t=P.LedgerKey.claimableBalance(new P.LedgerKeyClaimableBalance({balanceId:P.ClaimableBalanceId.fromXDR(e.balanceId,"hex")})),n=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:P.OperationBody.revokeSponsorship(n)};return On(r,e),new P.Operation(r)}function hr(e={}){if("string"!=typeof e.liquidityPoolId)throw new Error("liquidityPoolId is invalid");const t=P.LedgerKey.liquidityPool(new P.LedgerKeyLiquidityPool({liquidityPoolId:q.Buffer.from(e.liquidityPoolId,"hex")})),n=P.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:P.OperationBody.revokeSponsorship(n)};return On(r,e),new P.Operation(r)}function fr(e={}){if(!$t.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");let t;if(e.signer.ed25519PublicKey){if(!$t.isValidEd25519PublicKey(e.signer.ed25519PublicKey))throw new Error("signer.ed25519PublicKey is invalid.");const n=$t.decodeEd25519PublicKey(e.signer.ed25519PublicKey);t=P.SignerKey.signerKeyTypeEd25519(n)}else if(e.signer.preAuthTx){let n;if(n="string"==typeof e.signer.preAuthTx?q.Buffer.from(e.signer.preAuthTx,"hex"):e.signer.preAuthTx,!q.Buffer.isBuffer(n)||32!==n.length)throw new Error("signer.preAuthTx must be 32 bytes Buffer.");t=P.SignerKey.signerKeyTypePreAuthTx(n)}else if(e.signer.sha256Hash){let n;if(n="string"==typeof e.signer.sha256Hash?q.Buffer.from(e.signer.sha256Hash,"hex"):e.signer.sha256Hash,!q.Buffer.isBuffer(n)||32!==n.length)throw new Error("signer.sha256Hash must be 32 bytes Buffer.");t=P.SignerKey.signerKeyTypeHashX(n)}else{if(!e.signer.ed25519SignedPayload)throw new Error("signer is invalid");{if(!$t.isValidSignedPayload(e.signer.ed25519SignedPayload))throw new Error("signer.ed25519SignedPayload is invalid.");const n=$t.decodeSignedPayload(e.signer.ed25519SignedPayload),r=P.SignerKeyEd25519SignedPayload.fromXDR(n);t=P.SignerKey.signerKeyTypeEd25519SignedPayload(r)}}const n=new P.RevokeSponsorshipOpSigner({accountId:jt.fromPublicKey(e.account).xdrAccountId(),signerKey:t}),r=P.RevokeSponsorshipOp.revokeSponsorshipSigner(n),o={sourceAccount:null,body:P.OperationBody.revokeSponsorship(r)};return On(o,e),new P.Operation(o)}function mr(e){if(!Dn(e.amount))throw new TypeError(Mn("amount"));let t;try{t=sn(e.from)}catch{throw new Error("from address is invalid")}const n=new P.ClawbackOp({amount:Ln(e.amount),asset:e.asset.toXDRObject(),from:t}),r={sourceAccount:null,body:P.OperationBody.clawback(n)};return On(r,e),new P.Operation(r)}function gr(e){if("object"!=typeof e.flags||0===Object.keys(e.flags).length)throw new Error("opts.flags must be a map of boolean flags to modify");const t={authorized:P.TrustLineFlags.authorizedFlag(),authorizedToMaintainLiabilities:P.TrustLineFlags.authorizedToMaintainLiabilitiesFlag(),clawbackEnabled:P.TrustLineFlags.trustlineClawbackEnabledFlag()};let n=0,r=0;Object.keys(e.flags).forEach(o=>{if(!Object.prototype.hasOwnProperty.call(t,o))throw new Error(`unsupported flag name specified: ${o}`);const s=e.flags[o],i=t[o];if(!i)throw new Error(`Invalid flag name: ${o}`);if("boolean"!=typeof s&&void 0!==s)throw new TypeError(`opts.flags.${o} must be a boolean (got ${typeof s})`);!0===s?r|=i.value:!1===s&&(n|=i.value)});const o=jt.fromPublicKey(e.trustor).xdrAccountId(),s=e.asset.toXDRObject(),i={sourceAccount:null,body:P.OperationBody.setTrustLineFlags(new P.SetTrustLineFlagsOp({trustor:o,asset:s,clearFlags:n,setFlags:r}))};return On(i,e),new P.Operation(i)}function yr(e={}){const{liquidityPoolId:t,maxAmountA:n,maxAmountB:r,minPrice:o,maxPrice:s}=e;if(!t)throw new TypeError("liquidityPoolId argument is required");const i=q.Buffer.from(t,"hex");if(!Dn(n,!0))throw new TypeError(Mn("maxAmountA"));const a=Ln(n);if(!Dn(r,!0))throw new TypeError(Mn("maxAmountB"));const c=Ln(r);if(void 0===o)throw new TypeError("minPrice argument is required");const u=Fn(o);if(void 0===s)throw new TypeError("maxPrice argument is required");const l=Fn(s),d=new P.LiquidityPoolDepositOp({liquidityPoolId:i,maxAmountA:a,maxAmountB:c,minPrice:u,maxPrice:l}),p={sourceAccount:null,body:P.OperationBody.liquidityPoolDeposit(d)};return On(p,e),new P.Operation(p)}function wr(e={}){if(!e.liquidityPoolId)throw new TypeError("liquidityPoolId argument is required");const t=q.Buffer.from(e.liquidityPoolId,"hex");if(!Dn(e.amount))throw new TypeError(Mn("amount"));const n=Ln(e.amount);if(!Dn(e.minAmountA,!0))throw new TypeError(Mn("minAmountA"));const r=Ln(e.minAmountA);if(!Dn(e.minAmountB,!0))throw new TypeError(Mn("minAmountB"));const o=Ln(e.minAmountB),s=new P.LiquidityPoolWithdrawOp({liquidityPoolId:t,amount:n,minAmountA:r,minAmountB:o}),i={sourceAccount:null,body:P.OperationBody.liquidityPoolWithdraw(s)};return On(i,e),new P.Operation(i)}class Ar{_type;_key;constructor(e){if($t.isValidEd25519PublicKey(e))this._type="account",this._key=$t.decodeEd25519PublicKey(e);else if($t.isValidContract(e))this._type="contract",this._key=$t.decodeContract(e);else if($t.isValidMed25519PublicKey(e))this._type="muxedAccount",this._key=$t.decodeMed25519PublicKey(e);else if($t.isValidClaimableBalance(e))this._type="claimableBalance",this._key=$t.decodeClaimableBalance(e);else{if(!$t.isValidLiquidityPool(e))throw new Error(`Unsupported address type: ${e}`);this._type="liquidityPool",this._key=$t.decodeLiquidityPool(e)}}static fromString(e){return new Ar(e)}static account(e){return new Ar($t.encodeEd25519PublicKey(e))}static contract(e){return new Ar($t.encodeContract(e))}static claimableBalance(e){return new Ar($t.encodeClaimableBalance(e))}static liquidityPool(e){return new Ar($t.encodeLiquidityPool(e))}static muxedAccount(e){return new Ar($t.encodeMed25519PublicKey(e))}static fromScVal(e){return Ar.fromScAddress(e.address())}static fromScAddress(e){switch(e.switch().value){case P.ScAddressType.scAddressTypeAccount().value:return Ar.account(e.accountId().ed25519());case P.ScAddressType.scAddressTypeContract().value:return Ar.contract(e.contractId());case P.ScAddressType.scAddressTypeMuxedAccount().value:{const t=q.Buffer.concat([e.muxedAccount().ed25519(),e.muxedAccount().id().toXDR("raw")]);return Ar.muxedAccount(t)}case P.ScAddressType.scAddressTypeClaimableBalance().value:{const t=e.claimableBalanceId();return Ar.claimableBalance(q.Buffer.concat([q.Buffer.from([t.switch().value]),t.v0()]))}case P.ScAddressType.scAddressTypeLiquidityPool().value:return Ar.liquidityPool(e.liquidityPoolId());default:throw new Error(`Unsupported address type: ${e.switch().name}`)}}toString(){switch(this._type){case"account":return $t.encodeEd25519PublicKey(this._key);case"contract":return $t.encodeContract(this._key);case"claimableBalance":return $t.encodeClaimableBalance(this._key);case"liquidityPool":return $t.encodeLiquidityPool(this._key);case"muxedAccount":return $t.encodeMed25519PublicKey(this._key);default:throw new Error("Unsupported address type")}}toScVal(){return P.ScVal.scvAddress(this.toScAddress())}toScAddress(){switch(this._type){case"account":return P.ScAddress.scAddressTypeAccount(P.PublicKey.publicKeyTypeEd25519(this._key));case"contract":return P.ScAddress.scAddressTypeContract(this._key);case"liquidityPool":return P.ScAddress.scAddressTypeLiquidityPool(this._key);case"claimableBalance":return P.ScAddress.scAddressTypeClaimableBalance(P.ClaimableBalanceId.claimableBalanceIdTypeV0(this._key.subarray(1)));case"muxedAccount":return P.ScAddress.scAddressTypeMuxedAccount(new P.MuxedEd25519Account({ed25519:this._key.subarray(0,32),id:P.Uint64.fromXDR(this._key.subarray(32,40),"raw")}));default:throw new Error("Unsupported address type")}}toBuffer(){return this._key}get type(){return this._type}}function Sr(e){if(!e.func)throw new TypeError(`host function invocation ('func') required (got ${JSON.stringify(e)})`);e.func.switch().value===P.HostFunctionType.hostFunctionTypeInvokeContract().value&&e.func.invokeContract().args().forEach(e=>{let t;try{t=Ar.fromScVal(e)}catch{return}switch(t.type){case"claimableBalance":case"liquidityPool":throw new TypeError("claimable balances and liquidity pools cannot be arguments to invokeHostFunction")}});const t=new P.InvokeHostFunctionOp({hostFunction:e.func,auth:e.auth||[]}),n={sourceAccount:null,body:P.OperationBody.invokeHostFunction(t)};return On(n,e),new P.Operation(n)}function br(e){const t=new Ar(e.contract);if("contract"!==t.type)throw new TypeError(`expected contract strkey instance, got ${t.toString()}`);return Sr({func:P.HostFunction.hostFunctionTypeInvokeContract(new P.InvokeContractArgs({contractAddress:t.toScAddress(),functionName:e.function,args:e.args})),...void 0!==e.source&&{source:e.source},...void 0!==e.auth&&{auth:e.auth}})}function vr(e){const t=q.Buffer.from(e.salt||jt.random().xdrPublicKey().value());if(!e.wasmHash||32!==e.wasmHash.length)throw new TypeError(`expected hash(contract WASM) in 'opts.wasmHash', got ${String(e.wasmHash)}`);if(32!==t.length)throw new TypeError(`expected 32-byte salt in 'opts.salt', got ${String(e.salt)}`);return Sr({func:P.HostFunction.hostFunctionTypeCreateContractV2(new P.CreateContractArgsV2({executable:P.ContractExecutable.contractExecutableWasm(q.Buffer.from(e.wasmHash)),contractIdPreimage:P.ContractIdPreimage.contractIdPreimageFromAddress(new P.ContractIdPreimageFromAddress({address:e.address.toScAddress(),salt:t})),constructorArgs:e.constructorArgs??[]})),...void 0!==e.source&&{source:e.source},...void 0!==e.auth&&{auth:e.auth}})}function Tr(e){let t=e.asset;if("string"==typeof t){const n=t.split(":"),r=n[0];if(void 0===r)throw new TypeError(`expected Asset in 'opts.asset', got ${String(e.asset)}`);t=new Qt(r,n[1])}if(!(t instanceof Qt))throw new TypeError(`expected Asset in 'opts.asset', got ${String(e.asset)}`);return Sr({func:P.HostFunction.hostFunctionTypeCreateContract(new P.CreateContractArgs({executable:P.ContractExecutable.contractExecutableStellarAsset(),contractIdPreimage:P.ContractIdPreimage.contractIdPreimageFromAsset(t.toXDRObject())})),auth:e.auth||[],...void 0!==e.source&&{source:e.source}})}function Er(e){return Sr({func:P.HostFunction.hostFunctionTypeUploadContractWasm(q.Buffer.from(e.wasm)),auth:e.auth||[],...void 0!==e.source&&{source:e.source}})}function kr(e){if((e.extendTo??-1)<=0)throw new RangeError("extendTo has to be positive");const t=new P.ExtendFootprintTtlOp({ext:new P.ExtensionPoint(0),extendTo:e.extendTo}),n={sourceAccount:null,body:P.OperationBody.extendFootprintTtl(t)};return On(n,e),new P.Operation(n)}function Ir(e={}){const t=new P.RestoreFootprintOp({ext:new P.ExtensionPoint(0)}),n={sourceAccount:null,body:P.OperationBody.restoreFootprint(t)};return On(n,e),new P.Operation(n)}class Cr{static fromXDRObject(e){const t={},n=e.sourceAccount();n&&(t.source=an(n));const r=e.body().value(),o=e.body().switch().name;switch(o){case"createAccount":t.type="createAccount",t.destination=Br(r.destination()),t.startingBalance=Nn(r.startingBalance());break;case"payment":t.type="payment",t.destination=an(r.destination()),t.asset=Qt.fromOperation(r.asset()),t.amount=Nn(r.amount());break;case"pathPaymentStrictReceive":{t.type="pathPaymentStrictReceive",t.sendAsset=Qt.fromOperation(r.sendAsset()),t.sendMax=Nn(r.sendMax()),t.destination=an(r.destination()),t.destAsset=Qt.fromOperation(r.destAsset()),t.destAmount=Nn(r.destAmount()),t.path=[];const e=r.path();Object.keys(e).forEach(n=>{t.path.push(Qt.fromOperation(e[n]))});break}case"pathPaymentStrictSend":{t.type="pathPaymentStrictSend",t.sendAsset=Qt.fromOperation(r.sendAsset()),t.sendAmount=Nn(r.sendAmount()),t.destination=an(r.destination()),t.destAsset=Qt.fromOperation(r.destAsset()),t.destMin=Nn(r.destMin()),t.path=[];const e=r.path();Object.keys(e).forEach(n=>{t.path.push(Qt.fromOperation(e[n]))});break}case"changeTrust":if(t.type="changeTrust",r.line().switch()===P.AssetType.assetTypePoolShare())t.line=nn.fromOperation(r.line());else t.line=Qt.fromOperation(r.line());t.limit=Nn(r.limit());break;case"allowTrust":t.type="allowTrust",t.trustor=Br(r.trustor()),t.assetCode=r.asset().value().toString(),t.assetCode=Nt(t.assetCode,"\0"),t.authorize=r.authorize();break;case"setOptions":if(t.type="setOptions",r.inflationDest()&&(t.inflationDest=Br(r.inflationDest())),t.clearFlags=r.clearFlags(),t.setFlags=r.setFlags(),t.masterWeight=r.masterWeight(),t.lowThreshold=r.lowThreshold(),t.medThreshold=r.medThreshold(),t.highThreshold=r.highThreshold(),t.homeDomain=void 0!==r.homeDomain()?r.homeDomain().toString("ascii"):void 0,r.signer()){const e={},n=r.signer().key().arm();if("ed25519"===n)e.ed25519PublicKey=Br(r.signer().key());else if("preAuthTx"===n)e.preAuthTx=r.signer().key().preAuthTx();else if("hashX"===n)e.sha256Hash=r.signer().key().hashX();else if("ed25519SignedPayload"===n){const t=r.signer().key().ed25519SignedPayload();e.ed25519SignedPayload=$t.encodeSignedPayload(t.toXDR())}e.weight=r.signer().weight(),t.signer=e}break;case"manageOffer":case"manageSellOffer":t.type="manageSellOffer",t.selling=Qt.fromOperation(r.selling()),t.buying=Qt.fromOperation(r.buying()),t.amount=Nn(r.amount()),t.price=Vn(r.price()),t.offerId=r.offerId().toString();break;case"manageBuyOffer":t.type="manageBuyOffer",t.selling=Qt.fromOperation(r.selling()),t.buying=Qt.fromOperation(r.buying()),t.buyAmount=Nn(r.buyAmount()),t.price=Vn(r.price()),t.offerId=r.offerId().toString();break;case"createPassiveOffer":case"createPassiveSellOffer":t.type="createPassiveSellOffer",t.selling=Qt.fromOperation(r.selling()),t.buying=Qt.fromOperation(r.buying()),t.amount=Nn(r.amount()),t.price=Vn(r.price());break;case"accountMerge":t.type="accountMerge",t.destination=an(r);break;case"manageData":t.type="manageData",t.name=r.dataName().toString("ascii"),t.value=r.dataValue();break;case"inflation":t.type="inflation";break;case"bumpSequence":t.type="bumpSequence",t.bumpTo=r.bumpTo().toString();break;case"createClaimableBalance":t.type="createClaimableBalance",t.asset=Qt.fromOperation(r.asset()),t.amount=Nn(r.amount()),t.claimants=[],r.claimants().forEach(e=>{t.claimants.push(rn.fromXDR(e))});break;case"claimClaimableBalance":t.type="claimClaimableBalance",t.balanceId=r.toXDR("hex");break;case"beginSponsoringFutureReserves":t.type="beginSponsoringFutureReserves",t.sponsoredId=Br(r.sponsoredId());break;case"endSponsoringFutureReserves":t.type="endSponsoringFutureReserves";break;case"revokeSponsorship":!function(e,t){switch(e.switch().name){case"revokeSponsorshipLedgerEntry":{const n=e.ledgerKey();switch(n.switch().name){case P.LedgerEntryType.account().name:t.type="revokeAccountSponsorship",t.account=Br(n.account().accountId());break;case P.LedgerEntryType.trustline().name:{t.type="revokeTrustlineSponsorship",t.account=Br(n.trustLine().accountId());const e=n.trustLine().asset();if(e.switch()===P.AssetType.assetTypePoolShare())t.asset=on.fromOperation(e);else t.asset=Qt.fromOperation(e);break}case P.LedgerEntryType.offer().name:t.type="revokeOfferSponsorship",t.seller=Br(n.offer().sellerId()),t.offerId=n.offer().offerId().toString();break;case P.LedgerEntryType.data().name:t.type="revokeDataSponsorship",t.account=Br(n.data().accountId()),t.name=n.data().dataName().toString("ascii");break;case P.LedgerEntryType.claimableBalance().name:t.type="revokeClaimableBalanceSponsorship",t.balanceId=n.claimableBalance().balanceId().toXDR("hex");break;case P.LedgerEntryType.liquidityPool().name:t.type="revokeLiquidityPoolSponsorship",t.liquidityPoolId=n.liquidityPool().liquidityPoolId().toString("hex");break;default:throw new Error(`Unknown ledgerKey: ${e.switch().name}`)}break}case"revokeSponsorshipSigner":t.type="revokeSignerSponsorship",t.account=Br(e.signer().accountId()),t.signer=function(e){const t={};switch(e.switch().name){case P.SignerKeyType.signerKeyTypeEd25519().name:t.ed25519PublicKey=$t.encodeEd25519PublicKey(e.ed25519());break;case P.SignerKeyType.signerKeyTypePreAuthTx().name:t.preAuthTx=e.preAuthTx().toString("hex");break;case P.SignerKeyType.signerKeyTypeHashX().name:t.sha256Hash=e.hashX().toString("hex");break;case P.SignerKeyType.signerKeyTypeEd25519SignedPayload().name:{const n=e.ed25519SignedPayload();t.ed25519SignedPayload=$t.encodeSignedPayload(n.toXDR());break}default:throw new Error(`Unknown signerKey: ${e.switch().name}`)}return t}(e.signer().signerKey());break;default:throw new Error(`Unknown revokeSponsorship: ${e.switch().name}`)}}(r,t);break;case"clawback":t.type="clawback",t.amount=Nn(r.amount()),t.from=an(r.from()),t.asset=Qt.fromOperation(r.asset());break;case"clawbackClaimableBalance":t.type="clawbackClaimableBalance",t.balanceId=r.toXDR("hex");break;case"setTrustLineFlags":{t.type="setTrustLineFlags",t.asset=Qt.fromOperation(r.asset()),t.trustor=Br(r.trustor());const e=r.clearFlags(),n=r.setFlags(),o={authorized:P.TrustLineFlags.authorizedFlag(),authorizedToMaintainLiabilities:P.TrustLineFlags.authorizedToMaintainLiabilitiesFlag(),clawbackEnabled:P.TrustLineFlags.trustlineClawbackEnabledFlag()},s=t=>{const r=o[t]?.value??0;return!!(n&r)||!(e&r)&&void 0},i={};Object.keys(o).forEach(e=>{i[e]=s(e)}),t.flags=i;break}case"liquidityPoolDeposit":t.type="liquidityPoolDeposit",t.liquidityPoolId=r.liquidityPoolId().toString("hex"),t.maxAmountA=Nn(r.maxAmountA()),t.maxAmountB=Nn(r.maxAmountB()),t.minPrice=Vn(r.minPrice()),t.maxPrice=Vn(r.maxPrice());break;case"liquidityPoolWithdraw":t.type="liquidityPoolWithdraw",t.liquidityPoolId=r.liquidityPoolId().toString("hex"),t.amount=Nn(r.amount()),t.minAmountA=Nn(r.minAmountA()),t.minAmountB=Nn(r.minAmountB());break;case"invokeHostFunction":t.type="invokeHostFunction",t.func=r.hostFunction(),t.auth=r.auth()??[];break;case"extendFootprintTtl":t.type="extendFootprintTtl",t.extendTo=r.extendTo();break;case"restoreFootprint":t.type="restoreFootprint";break;default:throw new Error(`Unknown operation: ${o}`)}return t}static accountMerge=Gn;static allowTrust=$n;static bumpSequence=Xn;static changeTrust=Kn;static createAccount=Wn;static createClaimableBalance=Zn;static claimClaimableBalance=zn;static clawbackClaimableBalance=Yn;static createPassiveSellOffer=Hn;static inflation=Jn;static manageData=Qn;static manageSellOffer=qn;static manageBuyOffer=er;static pathPaymentStrictReceive=tr;static pathPaymentStrictSend=nr;static payment=rr;static setOptions=sr;static beginSponsoringFutureReserves=ir;static endSponsoringFutureReserves=ar;static revokeAccountSponsorship=cr;static revokeTrustlineSponsorship=ur;static revokeOfferSponsorship=lr;static revokeDataSponsorship=dr;static revokeClaimableBalanceSponsorship=pr;static revokeLiquidityPoolSponsorship=hr;static revokeSignerSponsorship=fr;static clawback=mr;static setTrustLineFlags=gr;static liquidityPoolDeposit=yr;static liquidityPoolWithdraw=wr;static invokeHostFunction=Sr;static extendFootprintTtl=kr;static restoreFootprint=Ir;static createStellarAssetContract=Tr;static invokeContractFunction=br;static createCustomContract=vr;static uploadContractWasm=Er}function Br(e){return $t.encodeEd25519PublicKey(e.ed25519())}const xr="none",Rr="id",_r="text",Pr="hash",Or="return";class Ur{_type;_value;constructor(e,t=null){switch(this._type=e,this._value=t,this._type){case xr:break;case Rr:Ur._validateIdValue(t);break;case _r:Ur._validateTextValue(t);break;case Pr:case Or:Ur._validateHashValue(t),"string"==typeof t&&(this._value=q.Buffer.from(t,"hex"));break;default:throw new Error("Invalid memo type")}}get type(){return this._type}set type(e){throw new Error("Memo is immutable")}get value(){switch(this._type){case xr:return null;case Rr:case _r:return this._value;case Pr:case Or:return q.Buffer.from(this._value);default:throw new Error("Invalid memo type")}}set value(e){throw new Error("Memo is immutable")}static _validateIdValue(e){const t=new Error(`Expects a uint64 as a string. Got ${e}`);if("string"!=typeof e)throw t;if(!/^[0-9]+$/.test(e))throw t;let n;try{n=new xn(e)}catch{throw t}if(!n.isFinite())throw t;if(n.isNaN())throw t;if(n.isNegative())throw t;if(!n.isInteger())throw t;if(n.isGreaterThan("18446744073709551615"))throw t}static _validateTextValue(e){if("string"==typeof e){if(q.Buffer.byteLength(e,"utf8")>28)throw new Error("Expects string, array or buffer, max 28 bytes")}else if(q.Buffer.isBuffer(e)){if(e.length>28)throw new Error("Expects string, array or buffer, max 28 bytes")}else if(!P.Memo.armTypeForArm("text").isValid(e))throw new Error("Expects string, array or buffer, max 28 bytes")}static _validateHashValue(e){const t=new Error(`Expects a 32 byte hash value or hex encoded string. Got ${String(e)}`);if(null==e)throw t;let n;if("string"==typeof e){if(!/^[0-9A-Fa-f]{64}$/g.test(e))throw t;n=q.Buffer.from(e,"hex")}else{if(!q.Buffer.isBuffer(e))throw t;n=q.Buffer.from(e)}if(!n.length||32!==n.length)throw t}static none(){return new Ur(xr)}static text(e){return new Ur(_r,e)}static id(e){return new Ur(Rr,e)}static hash(e){return new Ur(Pr,e)}static return(e){return new Ur(Or,e)}toXDRObject(){switch(this._type){case xr:return P.Memo.memoNone();case Rr:return P.Memo.memoId(P.Uint64.fromString(_.UnsignedHyper.fromString(this._value).toString()));case _r:return P.Memo.memoText(this._value);case Pr:return P.Memo.memoHash(this._value);case Or:return P.Memo.memoReturn(this._value);default:throw new Error("Invalid memo type")}}static fromXDRObject(e){switch(e.switch()){case P.MemoType.memoId():return Ur.id(e.id().toString());case P.MemoType.memoText():return Ur.text(e.value());case P.MemoType.memoHash():return Ur.hash(e.hash());case P.MemoType.memoReturn():return Ur.return(e.retHash())}if(void 0===e.value())return Ur.none();throw new Error("Unknown type")}}class Lr extends tn{_envelopeType;_source="";_memo;_sequence;_operations;_timeBounds;_ledgerBounds;_minAccountSequence;_minAccountSequenceAge;_minAccountSequenceLedgerGap;_extraSigners;constructor(e,t){if("string"==typeof e){const t=q.Buffer.from(e,"base64");e=P.TransactionEnvelope.fromXDR(t)}const n=e.switch();if(n!==P.EnvelopeType.envelopeTypeTxV0()&&n!==P.EnvelopeType.envelopeTypeTx())throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxV0 or envelopeTypeTx but received an ${n.name}.`);const r=e.value(),o=r.tx(),s=o.fee().toString();if(super(o,(r.signatures()||[]).slice(),s,t),this._envelopeType=n,this._memo=o.memo(),this._sequence=o.seqNum().toString(),this._envelopeType===P.EnvelopeType.envelopeTypeTxV0())this._source=$t.encodeEd25519PublicKey(o.sourceAccountEd25519());else this._source=an(o.sourceAccount());let i=null,a=null;switch(this._envelopeType){case P.EnvelopeType.envelopeTypeTxV0():a=o.timeBounds();break;case P.EnvelopeType.envelopeTypeTx():switch(o.cond().switch()){case P.PreconditionType.precondTime():a=o.cond().timeBounds();break;case P.PreconditionType.precondV2():i=o.cond().v2(),a=i.timeBounds()}}if(a&&(this._timeBounds={minTime:a.minTime().toString(),maxTime:a.maxTime().toString()}),i){const e=i.ledgerBounds();e&&(this._ledgerBounds={minLedger:e.minLedger(),maxLedger:e.maxLedger()});const t=i.minSeqNum();t&&(this._minAccountSequence=t.toString()),this._minAccountSequenceAge=i.minSeqAge().toBigInt(),this._minAccountSequenceLedgerGap=i.minSeqLedgerGap(),this._extraSigners=i.extraSigners()}const c=o.operations()||[];this._operations=c.map(e=>Cr.fromXDRObject(e))}get timeBounds(){return this._timeBounds}set timeBounds(e){throw new Error("Transaction is immutable")}get ledgerBounds(){return this._ledgerBounds}set ledgerBounds(e){throw new Error("Transaction is immutable")}get minAccountSequence(){return this._minAccountSequence}set minAccountSequence(e){throw new Error("Transaction is immutable")}get minAccountSequenceAge(){return this._minAccountSequenceAge}set minAccountSequenceAge(e){throw new Error("Transaction is immutable")}get minAccountSequenceLedgerGap(){return this._minAccountSequenceLedgerGap}set minAccountSequenceLedgerGap(e){throw new Error("Transaction is immutable")}get extraSigners(){return this._extraSigners}set extraSigners(e){throw new Error("Transaction is immutable")}get sequence(){return this._sequence}set sequence(e){throw new Error("Transaction is immutable")}get source(){return this._source}set source(e){throw new Error("Transaction is immutable")}get operations(){return this._operations}set operations(e){throw new Error("Transaction is immutable")}get memo(){return Ur.fromXDRObject(this._memo)}set memo(e){throw new Error("Transaction is immutable")}signatureBase(){let e=this.tx;this._envelopeType===P.EnvelopeType.envelopeTypeTxV0()&&(e=P.Transaction.fromXDR(q.Buffer.concat([q.Buffer.alloc(4),e.toXDR()])));const t=P.TransactionSignaturePayloadTaggedTransaction.envelopeTypeTx(e);return new P.TransactionSignaturePayload({networkId:P.Hash.fromXDR(xe(this.networkPassphrase)),taggedTransaction:t}).toXDR()}toEnvelope(){const e=this.tx.toXDR(),t=this.signatures.slice();let n;switch(this._envelopeType){case P.EnvelopeType.envelopeTypeTxV0():n=P.TransactionEnvelope.envelopeTypeTxV0(new P.TransactionV0Envelope({tx:P.TransactionV0.fromXDR(e),signatures:t}));break;case P.EnvelopeType.envelopeTypeTx():n=P.TransactionEnvelope.envelopeTypeTx(new P.TransactionV1Envelope({tx:P.Transaction.fromXDR(e),signatures:t}));break;default:throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxV0 or envelopeTypeTx but received an ${this._envelopeType.name}.`)}return n}getClaimableBalanceId(e){if(!Number.isInteger(e)||e<0||e>=this.operations.length)throw new RangeError("invalid operation index");const t=this.operations[e];if(void 0===t)throw new RangeError("invalid operation index");try{Cr.createClaimableBalance(t)}catch(e){throw new TypeError(`expected createClaimableBalance, got ${t.type}: ${String(e)}`)}const n=$t.decodeEd25519PublicKey(un(this.source)),r=xe(P.HashIdPreimage.envelopeTypeOpId(new P.HashIdPreimageOperationId({sourceAccount:P.PublicKey.publicKeyTypeEd25519(n),seqNum:P.Int64.fromString(this.sequence),opNum:e})).toXDR("raw"));return P.ClaimableBalanceId.claimableBalanceIdTypeV0(r).toXDR("hex")}}class Nr extends tn{_feeSource;_innerTransaction;constructor(e,t){if("string"==typeof e){const t=q.Buffer.from(e,"base64");e=P.TransactionEnvelope.fromXDR(t)}const n=e.switch();if(n!==P.EnvelopeType.envelopeTypeTxFeeBump())throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxFeeBump but received an ${n.name}.`);const r=e.value(),o=r.tx(),s=o.fee().toString();super(o,(r.signatures()||[]).slice(),s,t);const i=P.TransactionEnvelope.envelopeTypeTx(o.innerTx().v1());this._feeSource=an(this.tx.feeSource()),this._innerTransaction=new Lr(i,t)}get innerTransaction(){return this._innerTransaction}get operations(){return this._innerTransaction.operations}get feeSource(){return this._feeSource}signatureBase(){const e=P.TransactionSignaturePayloadTaggedTransaction.envelopeTypeTxFeeBump(this.tx);return new P.TransactionSignaturePayload({networkId:P.Hash.fromXDR(xe(this.networkPassphrase)),taggedTransaction:e}).toXDR()}toEnvelope(){const e=new P.FeeBumpTransactionEnvelope({tx:P.FeeBumpTransaction.fromXDR(this.tx.toXDR()),signatures:this.signatures.slice()});return P.TransactionEnvelope.envelopeTypeTxFeeBump(e)}}class Vr{_accountId;sequence;constructor(e,t){if($t.isValidMed25519PublicKey(e))throw new Error("accountId is an M-address; use MuxedAccount instead");if(!$t.isValidEd25519PublicKey(e))throw new Error("accountId is invalid");if("string"!=typeof t)throw new Error("sequence must be of type string");let n;try{n=new xn(t)}catch{throw new Error("sequence is not a valid number")}if(n.isNaN())throw new Error("sequence is not a valid number");this._accountId=e,this.sequence=n}accountId(){return this._accountId}sequenceNumber(){return this.sequence.toString()}incrementSequenceNumber(){this.sequence=this.sequence.plus(1)}}const Fr=BigInt("18446744073709551615");function Dr(e){let t;try{t=BigInt(e)}catch{throw new Error(`id is not a valid uint64 string: ${e}`)}if(t<BigInt(0)||t>Fr)throw new Error(`id value out of range for uint64 [0, ${Fr}]: ${e}`)}class Mr{account;_muxedXdr;_mAddress;_id;constructor(e,t){const n=e.accountId();if(!$t.isValidEd25519PublicKey(n))throw new Error("accountId is invalid");Dr(t),this.account=e,this._muxedXdr=cn(n,t),this._mAddress=an(this._muxedXdr),this._id=t}static fromAddress(e,t){const n=sn(e),r=un(e),o=n.med25519().id().toString();return new Mr(new Vr(r,t),o)}baseAccount(){return this.account}accountId(){return this._mAddress}id(){return this._id}setId(e){if("string"!=typeof e)throw new Error("id should be a string representing a number (uint64)");return Dr(e),this._muxedXdr.med25519().id(P.Uint64.fromString(e)),this._mAddress=an(this._muxedXdr),this._id=e,this}sequenceNumber(){return this.account.sequenceNumber()}incrementSequenceNumber(){this.account.incrementSequenceNumber()}toXDRObject(){return this._muxedXdr}equals(e){return this.accountId()===e.accountId()}}class qr{_data;constructor(e){let t;t=e?"string"==typeof e||ArrayBuffer.isView(e)?qr.fromXDR(e):qr.fromXDR(e.toXDR()):new P.SorobanTransactionData({resources:new P.SorobanResources({footprint:new P.LedgerFootprint({readOnly:[],readWrite:[]}),instructions:0,diskReadBytes:0,writeBytes:0}),ext:new P.SorobanTransactionDataExt(0),resourceFee:new P.Int64(0)}),this._data=t}static fromXDR(e){return"string"==typeof e?P.SorobanTransactionData.fromXDR(e,"base64"):P.SorobanTransactionData.fromXDR(q.Buffer.from(e),"raw")}setResourceFee(e){return this._data.resourceFee(new P.Int64(e)),this}setResources(e,t,n){return this._data.resources().instructions(e),this._data.resources().diskReadBytes(t),this._data.resources().writeBytes(n),this}appendFootprint(e,t){return this.setFootprint(this.getReadOnly().concat(e),this.getReadWrite().concat(t))}setFootprint(e,t){return null!==e&&this.setReadOnly(e),null!==t&&this.setReadWrite(t),this}setReadOnly(e){return this._data.resources().footprint().readOnly(e??[]),this}setReadWrite(e){return this._data.resources().footprint().readWrite(e??[]),this}build(){return P.SorobanTransactionData.fromXDR(this._data.toXDR())}getReadOnly(){return this.getFootprint().readOnly()}getReadWrite(){return this.getFootprint().readWrite()}getFootprint(){return this._data.resources().footprint()}}class Hr{static decodeAddress(e){const t=$t.getVersionByteForPrefix(e);if(void 0===t)throw new Error(`invalid signer key type (${t})`);const n=Kt(t,e);switch(t){case"signedPayload":return P.SignerKey.signerKeyTypeEd25519SignedPayload(new P.SignerKeyEd25519SignedPayload({ed25519:n.subarray(0,32),payload:n.subarray(36,36+n.readUInt32BE(32))}));case"ed25519PublicKey":return P.SignerKey.signerKeyTypeEd25519(n);case"preAuthTx":return P.SignerKey.signerKeyTypePreAuthTx(n);case"sha256Hash":return P.SignerKey.signerKeyTypeHashX(n);default:throw new Error(`invalid signer key type (${t})`)}}static encodeSignerKey(e){let t,n;switch(e.switch()){case P.SignerKeyType.signerKeyTypeEd25519():t="ed25519PublicKey",n=e.value();break;case P.SignerKeyType.signerKeyTypePreAuthTx():t="preAuthTx",n=e.value();break;case P.SignerKeyType.signerKeyTypeHashX():t="sha256Hash",n=e.value();break;case P.SignerKeyType.signerKeyTypeEd25519SignedPayload():t="signedPayload",n=e.ed25519SignedPayload().toXDR("raw");break;default:throw new Error(`invalid SignerKey (type: ${e.switch().name})`)}return Wt(t,n)}}class Gr{_id;constructor(e){try{this._id=$t.decodeContract(e)}catch{throw new Error(`Invalid contract ID: ${e}`)}}contractId(){return $t.encodeContract(this._id)}toString(){return this.contractId()}address(){return Ar.contract(this._id)}call(e,...t){return Cr.invokeContractFunction({contract:this.address().toString(),function:e,args:t})}getFootprint(){return P.LedgerKey.contractData(new P.LedgerKeyContractData({contract:this.address().toScAddress(),key:P.ScVal.scvLedgerKeyContractInstance(),durability:P.ContractDataDurability.persistent()}))}}class $r extends _.LargeInt{constructor(...e){super(e)}get unsigned(){return!0}get size(){return 128}}$r.defineIntBoundaries();class Xr extends _.LargeInt{constructor(...e){super(e)}get unsigned(){return!0}get size(){return 256}}Xr.defineIntBoundaries();class Kr extends _.LargeInt{constructor(...e){super(e)}get unsigned(){return!1}get size(){return 128}}Kr.defineIntBoundaries();class Wr extends _.LargeInt{constructor(...e){super(e)}get unsigned(){return!1}get size(){return 256}}Wr.defineIntBoundaries();class Zr{int;type;constructor(e,t){t instanceof Array||(t=[t]);const n=t.map(e=>"bigint"==typeof e?e:"object"==typeof e&&null!==e&&"toBigInt"in e&&"function"==typeof e.toBigInt?e.toBigInt():BigInt(e));switch(e){case"i64":this.int=new _.Hyper(n);break;case"i128":this.int=new Kr(...n);break;case"i256":this.int=new Wr(...n);break;case"u64":case"timepoint":case"duration":this.int=new _.UnsignedHyper(n);break;case"u128":this.int=new $r(...n);break;case"u256":this.int=new Xr(...n);break;default:throw TypeError(`invalid type: ${e}`)}this.type=e}toNumber(){const e=this.int.toBigInt();if(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw RangeError(`value ${e} not in range for Number [${Number.MAX_SAFE_INTEGER}, ${Number.MIN_SAFE_INTEGER}]`);return Number(e)}toBigInt(){return this.int.toBigInt()}toI64(){this._sizeCheck(64);const e=this.toBigInt();if(BigInt.asIntN(64,e)!==e)throw RangeError(`value too large for i64: ${e}`);return P.ScVal.scvI64(new P.Int64(e))}toU64(){return this._sizeCheck(64),P.ScVal.scvU64(new P.Uint64(BigInt.asUintN(64,this.toBigInt())))}toTimepoint(){return this._sizeCheck(64),P.ScVal.scvTimepoint(new P.Uint64(BigInt.asUintN(64,this.toBigInt())))}toDuration(){return this._sizeCheck(64),P.ScVal.scvDuration(new P.Uint64(BigInt.asUintN(64,this.toBigInt())))}toI128(){this._sizeCheck(128);const e=this.int.toBigInt();if(BigInt.asIntN(128,e)!==e)throw RangeError(`value too large for i128: ${e}`);const t=BigInt.asIntN(64,e>>64n),n=BigInt.asUintN(64,e);return P.ScVal.scvI128(new P.Int128Parts({hi:new P.Int64(t),lo:new P.Uint64(n)}))}toU128(){this._sizeCheck(128);const e=this.int.toBigInt();return P.ScVal.scvU128(new P.UInt128Parts({hi:new P.Uint64(BigInt.asUintN(64,e>>64n)),lo:new P.Uint64(BigInt.asUintN(64,e))}))}toI256(){const e=this.int.toBigInt();if(BigInt.asIntN(256,e)!==e)throw RangeError(`value too large for i256: ${e}`);const t=BigInt.asIntN(64,e>>192n),n=BigInt.asUintN(64,e>>128n),r=BigInt.asUintN(64,e>>64n),o=BigInt.asUintN(64,e);return P.ScVal.scvI256(new P.Int256Parts({hiHi:new P.Int64(t),hiLo:new P.Uint64(n),loHi:new P.Uint64(r),loLo:new P.Uint64(o)}))}toU256(){const e=this.int.toBigInt(),t=BigInt.asUintN(64,e>>192n),n=BigInt.asUintN(64,e>>128n),r=BigInt.asUintN(64,e>>64n),o=BigInt.asUintN(64,e);return P.ScVal.scvU256(new P.UInt256Parts({hiHi:new P.Uint64(t),hiLo:new P.Uint64(n),loHi:new P.Uint64(r),loLo:new P.Uint64(o)}))}toScVal(){switch(this.type){case"i64":return this.toI64();case"i128":return this.toI128();case"i256":return this.toI256();case"u64":return this.toU64();case"u128":return this.toU128();case"u256":return this.toU256();case"timepoint":return this.toTimepoint();case"duration":return this.toDuration();default:throw TypeError(`invalid type: ${this.type}`)}}valueOf(){return this.int.valueOf()}toString(){return this.int.toString()}toJSON(){return{value:this.toBigInt().toString(),type:this.type}}_sizeCheck(e){if(this.int.size>e)throw RangeError(`value too large for ${e} bits (${this.type})`)}static isType(e){switch(e){case"i64":case"i128":case"i256":case"u64":case"u128":case"u256":case"timepoint":case"duration":return!0;default:return!1}}static getType(e){const t=e.slice(3).toLowerCase();if(this.isType(t))return t}}class zr extends Zr{constructor(e,t){const n=BigInt(e),r=n<0n;let o=t?.type??"";if(o.startsWith("u")&&r)throw TypeError(`specified type ${t?.type} yet negative (${e})`);if(""===o){o=r?"i":"u";const t=function(e){if(e<0n){const t=(-e-1n).toString(2).length+1;return[64,128,256].find(e=>t<=e)??t}const t=e.toString(2).length;return[64,128,256].find(e=>t<=e)??t}(n);switch(t){case 64:case 128:case 256:o+=t.toString();break;default:throw RangeError(`expected 64/128/256 bits for input (${e}), got ${t}`)}}super(o,n)}}function jr(e){const t=e.switch().name,n=Zr.getType(t),r=e.value();if(null===r)throw TypeError(`unexpected null value for ${t}`);switch(t){case"scvU32":case"scvI32":return BigInt(r);case"scvU64":case"scvI64":case"scvTimepoint":case"scvDuration":if(void 0===n)throw TypeError(`invalid integer type for ${t}`);return new Zr(n,r).toBigInt();case"scvU128":case"scvI128":{if(void 0===n)throw TypeError(`invalid integer type for ${t}`);const e=r;return new Zr(n,[e.lo(),e.hi()]).toBigInt()}case"scvU256":case"scvI256":{if(void 0===n)throw TypeError(`invalid integer type for ${t}`);const e=r;return new Zr(n,[e.loLo(),e.loHi(),e.hiLo(),e.hiHi()]).toBigInt()}default:throw TypeError(`expected integer type, got ${t}`)}}function Yr(e,t={}){switch(typeof e){case"object":{if(null===e)return P.ScVal.scvVoid();if(e instanceof P.ScVal)return e;if(e instanceof Ar)return e.toScVal();if(e instanceof jt)return Yr(e.publicKey(),{type:"address"});if(e instanceof Gr)return e.address().toScVal();if(e instanceof Uint8Array||q.Buffer.isBuffer(e)){const n=q.Buffer.from(e);switch(t?.type??"bytes"){case"bytes":return P.ScVal.scvBytes(n);case"symbol":return P.ScVal.scvSymbol(n);case"string":return P.ScVal.scvString(n);default:throw new TypeError(`invalid type (${JSON.stringify(t.type)}) specified for bytes-like value`)}}if(Array.isArray(e))return P.ScVal.scvVec(e.map((e,n)=>Array.isArray(t.type)?Yr(e,{...t.type.length>n&&{type:t.type[n]}}):Yr(e,t)));if(e instanceof Map){let n=null,r=null,o=null;if(Array.isArray(t.type)){if(t.type.length>2)throw new TypeError(`expected a [keyType, valType] pair for a Map, got ${JSON.stringify(t.type)}`);[n=null,r=null]=t.type}else if("object"==typeof t.type&&null!==t.type)o=t.type;else if(void 0!==t.type)throw new TypeError(`invalid type (${JSON.stringify(t.type)}) specified for a Map`);const s=[];for(const[t,i]of e){let e=n,a=r;o&&"string"==typeof t&&Object.hasOwn(o,t)&&([e=null,a=null]=o[t]??[]),s.push(new P.ScMapEntry({key:Yr(t,e?{type:e}:{}),val:Yr(i,a?{type:a}:{})}))}return P.scvSortedMap(s)}if(Object.getPrototypeOf(e)!==Object.prototype)throw new TypeError(`cannot interpret ${e.constructor?.name} value as ScVal (${JSON.stringify(e)})`);const n=t?.type??{};return P.ScVal.scvMap(Object.entries(e).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>{const[r,o]=Object.hasOwn(n,e)?n[e]??[null,null]:[null,null],s=r?{type:r}:{},i=o?{type:o}:{};return new P.ScMapEntry({key:Yr(e,s),val:Yr(t,i)})}))}case"number":case"bigint":{const n=BigInt(e);switch(t?.type){case"u32":if(n<BigInt(P.Uint32.MIN_VALUE)||n>BigInt(P.Uint32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type u32`);return P.ScVal.scvU32(Number(e));case"i32":if(n<-BigInt(P.Int32.MIN_VALUE)||n>BigInt(P.Int32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type i32`);return P.ScVal.scvI32(Number(e))}return new zr(e,{type:t?.type}).toScVal()}case"string":{const n=t?.type??"string";switch(n){case"string":return P.ScVal.scvString(e);case"symbol":return P.ScVal.scvSymbol(e);case"address":return new Ar(e).toScVal();case"u32":{const t=BigInt(e);if(t<BigInt(P.Uint32.MIN_VALUE)||t>BigInt(P.Uint32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type u32`);return P.ScVal.scvU32(Number(t))}case"i32":{const t=BigInt(e);if(t<-BigInt(P.Int32.MIN_VALUE)||t>BigInt(P.Int32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type i32`);return P.ScVal.scvI32(Number(t))}default:if(Zr.isType(n))return new Zr(n,e).toScVal();throw new TypeError(`invalid type (${JSON.stringify(t.type)}) specified for string value`)}}case"boolean":return P.ScVal.scvBool(e);case"undefined":return P.ScVal.scvVoid();case"function":return Yr(e());default:throw new TypeError(`failed to convert typeof ${typeof e} (${JSON.stringify(e)})`)}}function Jr(e){switch(e.switch().value){case P.ScValType.scvVoid().value:return null;case P.ScValType.scvU64().value:case P.ScValType.scvI64().value:return e.value().toBigInt();case P.ScValType.scvU128().value:case P.ScValType.scvI128().value:case P.ScValType.scvU256().value:case P.ScValType.scvI256().value:return jr(e);case P.ScValType.scvVec().value:return(e.vec()??[]).map(Jr);case P.ScValType.scvAddress().value:return Ar.fromScVal(e).toString();case P.ScValType.scvMap().value:return Object.fromEntries((e.map()??[]).map(e=>[Jr(e.key()),Jr(e.val())]));case P.ScValType.scvBool().value:case P.ScValType.scvU32().value:case P.ScValType.scvI32().value:case P.ScValType.scvBytes().value:return e.value();case P.ScValType.scvSymbol().value:{const t=e.sym();if(q.Buffer.isBuffer(t)||ArrayBuffer.isView(t)&&"string"!=typeof t)try{return(new TextDecoder).decode(t)}catch{return new Uint8Array(t.buffer)}return t}case P.ScValType.scvString().value:{const t=e.str();if(q.Buffer.isBuffer(t)||ArrayBuffer.isView(t)&&"string"!=typeof t)try{return(new TextDecoder).decode(t)}catch{return new Uint8Array(t.buffer)}return t}case P.ScValType.scvTimepoint().value:case P.ScValType.scvDuration().value:return e.value().toBigInt();case P.ScValType.scvError().value:if(e.error().switch().value===P.ScErrorType.sceContract().value)return{type:"contract",code:e.error().contractCode()};{const t=e.error();return{type:"system",code:t.code().value,value:t.code().name}}default:return e.value()}}function Qr(e){const t=Array.from(e).sort((e,t)=>{const n=Jr(e.key()),r=Jr(t.key());switch(typeof n){case"number":case"bigint":return n===r?0:n<r?-1:1;default:{const e=n.toString(),t=r.toString();return e<t?-1:e>t?1:0}}});return P.ScVal.scvMap(t)}P.scvSortedMap=Qr;const eo=_.Hyper.MAX_VALUE,to=4294967295,no="100";class ro{source;operations;baseFee;timebounds;ledgerbounds;minAccountSequence;minAccountSequenceAge;minAccountSequenceLedgerGap;extraSigners;memo;networkPassphrase;sorobanData;constructor(e,t={}){if(!e)throw new Error("must specify source account for the transaction");if(void 0===t.fee)throw new Error("must specify fee for the transaction (in stroops)");if(this.source=e,this.operations=[],this.baseFee=t.fee,t.timebounds){const e=so(t.timebounds.minTime),n=so(t.timebounds.maxTime);if(void 0!==e&&e<0)throw new Error("min_time cannot be negative");if(void 0!==n&&n<0)throw new Error("max_time cannot be negative");if(void 0!==e&&void 0!==n&&n>0&&e>n)throw new Error("min_time cannot be greater than max_time");this.timebounds={...t.timebounds}}else this.timebounds=null;if(t.ledgerbounds){const e=t.ledgerbounds.minLedger,n=t.ledgerbounds.maxLedger;if(void 0!==e&&e<0)throw new Error("min_ledger cannot be negative");if(void 0!==n&&n<0)throw new Error("max_ledger cannot be negative");if(void 0!==e&&void 0!==n&&n>0&&e>n)throw new Error("min_ledger cannot be greater than max_ledger");this.ledgerbounds={...t.ledgerbounds}}else this.ledgerbounds=null;this.minAccountSequence=t.minAccountSequence||null,this.minAccountSequenceAge=void 0!==t.minAccountSequenceAge?t.minAccountSequenceAge:null,this.minAccountSequenceLedgerGap=void 0!==t.minAccountSequenceLedgerGap?t.minAccountSequenceLedgerGap:null,this.extraSigners=t.extraSigners?[...t.extraSigners]:null,this.memo=t.memo||Ur.none(),this.networkPassphrase=t.networkPassphrase||null,this.sorobanData=t.sorobanData?new qr(t.sorobanData).build():null}static cloneFrom(e,t={}){if(!(e instanceof Lr))throw new TypeError(`expected a 'Transaction', got: ${String(e)}`);const n=(BigInt(e.sequence)-1n).toString();let r,o;if($t.isValidMed25519PublicKey(e.source))r=Mr.fromAddress(e.source,n);else{if(!$t.isValidEd25519PublicKey(e.source))throw new TypeError(`unsupported tx source account: ${e.source}`);r=new Vr(e.source,n)}if(0===e.operations.length)throw new Error("cannot clone a transaction with no operations: per-operation base fee cannot be determined");const s=e.toEnvelope();s.switch()===P.EnvelopeType.envelopeTypeTx()&&(o=s.v1().tx().ext().value()??void 0);let i=parseInt(e.fee,10);if(o){const e=Number(o.resourceFee().toBigInt());i-e>0&&(i-=e)}const a={fee:(Math.floor(i/e.operations.length)||no).toString(),memo:e.memo,networkPassphrase:e.networkPassphrase};e.timeBounds&&(a.timebounds=e.timeBounds),e.ledgerBounds&&(a.ledgerbounds=e.ledgerBounds),e.minAccountSequence&&(a.minAccountSequence=e.minAccountSequence),void 0!==e.minAccountSequenceAge&&(a.minAccountSequenceAge=e.minAccountSequenceAge),void 0!==e.minAccountSequenceLedgerGap&&(a.minAccountSequenceLedgerGap=e.minAccountSequenceLedgerGap),e.extraSigners&&(a.extraSigners=e.extraSigners.map(e=>Hr.encodeSignerKey(e))),Object.assign(a,t);const c=new ro(r,a);return e.tx.operations().forEach(e=>c.addOperation(e)),c}addOperation(e){return this.operations.push(e),this}addOperationAt(e,t){return this.operations.splice(t,0,e),this}clearOperations(){return this.operations=[],this}clearOperationAt(e){return this.operations.splice(e,1),this}addMemo(e){return this.memo=e,this}setTimeout(e){if(null!==this.timebounds&&Number(this.timebounds.maxTime)>0)throw new Error("TimeBounds.max_time has been already set - setting timeout would overwrite it.");if(e<0)throw new Error("timeout cannot be negative");if(e>0){const t=Math.floor(Date.now()/1e3)+e;null===this.timebounds?this.timebounds={minTime:0,maxTime:t}:this.timebounds={minTime:this.timebounds.minTime??0,maxTime:t}}else this.timebounds={minTime:0,maxTime:0};return this}setTimebounds(e,t){if("number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof t&&(t=new Date(1e3*t)),null!==this.timebounds)throw new Error("TimeBounds has been already set - setting timebounds would overwrite it.");const n=Math.floor(e.valueOf()/1e3),r=Math.floor(t.valueOf()/1e3);if(n<0)throw new Error("min_time cannot be negative");if(r<0)throw new Error("max_time cannot be negative");if(r>0&&n>r)throw new Error("min_time cannot be greater than max_time");return this.timebounds={minTime:n,maxTime:r},this}setLedgerbounds(e,t){if(null!==this.ledgerbounds)throw new Error("LedgerBounds has been already set - setting ledgerbounds would overwrite it.");if(e<0)throw new Error("min_ledger cannot be negative");if(t<0)throw new Error("max_ledger cannot be negative");if(t>0&&e>t)throw new Error("min_ledger cannot be greater than max_ledger");return this.ledgerbounds={minLedger:e,maxLedger:t},this}setMinAccountSequence(e){if(null!==this.minAccountSequence)throw new Error("min_account_sequence has been already set - setting min_account_sequence would overwrite it.");return this.minAccountSequence=e,this}setMinAccountSequenceAge(e){if("bigint"!=typeof e)throw new Error("min_account_sequence_age must be a bigint");if(null!==this.minAccountSequenceAge)throw new Error("min_account_sequence_age has been already set - setting min_account_sequence_age would overwrite it.");if(e<0)throw new Error("min_account_sequence_age cannot be negative");return this.minAccountSequenceAge=e,this}setMinAccountSequenceLedgerGap(e){if(null!==this.minAccountSequenceLedgerGap)throw new Error("min_account_sequence_ledger_gap has been already set - setting min_account_sequence_ledger_gap would overwrite it.");if(e<0)throw new Error("min_account_sequence_ledger_gap cannot be negative");return this.minAccountSequenceLedgerGap=e,this}setExtraSigners(e){if(!Array.isArray(e))throw new Error("extra_signers must be an array of strings.");if(null!==this.extraSigners)throw new Error("extra_signers has been already set - setting extra_signers would overwrite it.");if(e.length>2)throw new Error("extra_signers cannot be longer than 2 elements.");return this.extraSigners=[...e],this}setNetworkPassphrase(e){return this.networkPassphrase=e,this}setSorobanData(e){return this.sorobanData=new qr(e).build(),this}addSacTransferOperation(e,t,n,r){if(BigInt(n)<=0n)throw new Error("Amount must be a positive integer");if(BigInt(n)>eo)throw new Error("Amount exceeds maximum value for i64");if(r){const{instructions:e,readBytes:t,writeBytes:n,resourceFee:o}=r,s=4294967295;if(e<=0||e>s)throw new Error(`instructions must be greater than 0 and at most ${s}`);if(t<=0||t>s)throw new Error(`readBytes must be greater than 0 and at most ${s}`);if(n<=0||n>s)throw new Error(`writeBytes must be greater than 0 and at most ${s}`);if(o<=0n||o>eo)throw new Error("resourceFee must be greater than 0 and at most i64 max")}const o=$t.isValidContract(e);if(!o&&!$t.isValidEd25519PublicKey(e)&&!$t.isValidMed25519PublicKey(e))throw new Error("Invalid destination address. Must be a valid Stellar address or contract ID.");const s=o?e:un(e);if(s===un(this.source.accountId()))throw new Error("Destination cannot be the same as the source account.");if(null===this.networkPassphrase)throw new Error("networkPassphrase must be set to add a SAC transfer operation");const i=t.contractId(this.networkPassphrase),a="transfer",c=this.source.accountId(),u=un(c),l=[Yr(c,{type:"address"}),Yr(e,{type:"address"}),Yr(n,{type:"i128"})],d=t.isNative(),p=new P.SorobanAuthorizationEntry({credentials:P.SorobanCredentials.sorobanCredentialsSourceAccount(),rootInvocation:new P.SorobanAuthorizedInvocation({function:P.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeContractFn(new P.InvokeContractArgs({contractAddress:Ar.fromString(i).toScAddress(),functionName:a,args:l})),subInvocations:[]})}),h=new P.LedgerFootprint({readOnly:[P.LedgerKey.contractData(new P.LedgerKeyContractData({contract:Ar.fromString(i).toScAddress(),key:P.ScVal.scvLedgerKeyContractInstance(),durability:P.ContractDataDurability.persistent()}))],readWrite:[]});if(o){if(h.readWrite().push(P.LedgerKey.contractData(new P.LedgerKeyContractData({contract:Ar.fromString(i).toScAddress(),key:P.ScVal.scvVec([Yr("Balance",{type:"symbol"}),Yr(e,{type:"address"})]),durability:P.ContractDataDurability.persistent()}))),!d){const e=t.getIssuer();if(!e)throw new Error("Asset issuer must be set for non-native assets.");h.readOnly().push(P.LedgerKey.account(new P.LedgerKeyAccount({accountId:jt.fromPublicKey(e).xdrPublicKey()})))}}else d?h.readWrite().push(P.LedgerKey.account(new P.LedgerKeyAccount({accountId:jt.fromPublicKey(s).xdrPublicKey()}))):t.getIssuer()!==s&&h.readWrite().push(P.LedgerKey.trustline(new P.LedgerKeyTrustLine({accountId:jt.fromPublicKey(s).xdrPublicKey(),asset:t.toTrustLineXDRObject()})));t.isNative()?h.readWrite().push(P.LedgerKey.account(new P.LedgerKeyAccount({accountId:jt.fromPublicKey(u).xdrPublicKey()}))):t.getIssuer()!==u&&h.readWrite().push(P.LedgerKey.trustline(new P.LedgerKeyTrustLine({accountId:jt.fromPublicKey(u).xdrPublicKey(),asset:t.toTrustLineXDRObject()})));const f={instructions:4e5,readBytes:1e3,writeBytes:1e3,resourceFee:BigInt(5e6)},m=new P.SorobanTransactionData({resources:new P.SorobanResources({footprint:h,instructions:r?r.instructions:f.instructions,diskReadBytes:r?r.readBytes:f.readBytes,writeBytes:r?r.writeBytes:f.writeBytes}),ext:new P.SorobanTransactionDataExt(0),resourceFee:new P.Int64(r?r.resourceFee:f.resourceFee)}),g=Cr.invokeContractFunction({contract:i,function:a,args:l,auth:[p]});return this.setSorobanData(m),this.addOperation(g)}build(){const e=new xn(this.source.sequenceNumber()).plus(1),t=new xn(this.baseFee).times(this.operations.length).toNumber();if(t>to)throw new Error(`Total fee (baseFee * operations) exceeds the maximum uint32 value (4294967295). Got ${t} from baseFee=${this.baseFee} and ${this.operations.length} operation(s).`);const n={fee:t,seqNum:P.Int64.fromString(e.toString()),memo:this.memo?this.memo.toXDRObject():null};if(null===this.timebounds||void 0===this.timebounds.minTime||void 0===this.timebounds.maxTime)throw new Error("TimeBounds has to be set or you must call setTimeout(TimeoutInfinite).");oo(this.timebounds.minTime)&&(this.timebounds.minTime=Math.floor(this.timebounds.minTime.getTime()/1e3)),oo(this.timebounds.maxTime)&&(this.timebounds.maxTime=Math.floor(this.timebounds.maxTime.getTime()/1e3));const r=P.Uint64.fromString(this.timebounds.minTime.toString()),o=P.Uint64.fromString(this.timebounds.maxTime.toString()),s=new P.TimeBounds({minTime:r,maxTime:o});if(this.hasV2Preconditions()){let e=null;null!==this.ledgerbounds&&(e=new P.LedgerBounds({minLedger:this.ledgerbounds.minLedger??0,maxLedger:this.ledgerbounds.maxLedger??0}));const t=this.minAccountSequence?P.Int64.fromString(this.minAccountSequence):null,r=P.Uint64.fromString(null!==this.minAccountSequenceAge?this.minAccountSequenceAge.toString():"0"),o=this.minAccountSequenceLedgerGap||0,i=null!==this.extraSigners?this.extraSigners.map(e=>Hr.decodeAddress(e)):[];n.cond=P.Preconditions.precondV2(new P.PreconditionsV2({timeBounds:s,ledgerBounds:e,minSeqNum:t,minSeqAge:r,minSeqLedgerGap:o,extraSigners:i}))}else n.cond=P.Preconditions.precondTime(s);if(n.sourceAccount=sn(this.source.accountId()),this.sorobanData){if(n.ext=new P.TransactionExt(1,this.sorobanData),n.fee=new xn(n.fee).plus(this.sorobanData.resourceFee().toString()).toNumber(),n.fee>to)throw new Error(`Total fee (baseFee * operations + resourceFee) exceeds the maximum uint32 value (4294967295). Got ${n.fee}.`)}else n.ext=new P.TransactionExt(0);const i=new P.Transaction(n);i.operations(this.operations);const a=P.TransactionEnvelope.envelopeTypeTx(new P.TransactionV1Envelope({tx:i,signatures:[]}));if(null===this.networkPassphrase)throw new Error("networkPassphrase must be set to build a transaction");const c=new Lr(a,this.networkPassphrase);return this.source.incrementSequenceNumber(),c}hasV2Preconditions(){return null!==this.ledgerbounds||null!==this.minAccountSequence||null!==this.minAccountSequenceAge||null!==this.minAccountSequenceLedgerGap||null!==this.extraSigners&&this.extraSigners.length>0}static buildFeeBumpTransaction(e,t,n,r){const o=n.operations.length,s=new xn(no);let i=new xn(0);const a=n.toEnvelope();switch(a.switch().value){case P.EnvelopeType.envelopeTypeTx().value:{const e=a.v1().tx().ext().value();i=new xn(e?.resourceFee().toString()??0);break}}const c=new xn(n.fee).minus(i).div(o),u=new xn(t);if(u.lt(c))throw new Error(`Invalid baseFee, it should be at least ${c.toString()} stroops.`);if(u.lt(s))throw new Error(`Invalid baseFee, it should be at least ${s.toString()} stroops.`);let l,d=n.toEnvelope();if(d.switch()===P.EnvelopeType.envelopeTypeTxV0()){const e=d.v0().tx(),t=e.timeBounds();if(null===t)throw new Error("Inner transaction must have time bounds");const n=new P.Transaction({sourceAccount:P.MuxedAccount.keyTypeEd25519(e.sourceAccountEd25519()),fee:e.fee(),seqNum:e.seqNum(),cond:P.Preconditions.precondTime(t),memo:e.memo(),operations:e.operations(),ext:new P.TransactionExt(0)});d=P.TransactionEnvelope.envelopeTypeTx(new P.TransactionV1Envelope({tx:n,signatures:d.v0().signatures()}))}l="string"==typeof e?sn(e):e.xdrMuxedAccount();const p=new P.FeeBumpTransaction({feeSource:l,fee:P.Int64.fromString(u.times(o+1).plus(i).toString()),innerTx:P.FeeBumpTransactionInnerTx.envelopeTypeTx(d.v1()),ext:new P.FeeBumpTransactionExt(0)}),h=new P.FeeBumpTransactionEnvelope({tx:p,signatures:[]}),f=P.TransactionEnvelope.envelopeTypeTxFeeBump(h);return new Nr(f,r)}static fromXDR(e,t){return"string"==typeof e&&(e=P.TransactionEnvelope.fromXDR(e,"base64")),e.switch()===P.EnvelopeType.envelopeTypeTxFeeBump()?new Nr(e,t):new Lr(e,t)}}function oo(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function so(e){if(void 0===e)return;const t=e instanceof Date?Math.floor(e.getTime()/1e3):Number(e);if(!Number.isFinite(t)||t%1!=0)throw new Error("timebounds value must be a finite integer or Date");return t}var io=(e=>(e.PUBLIC="Public Global Stellar Network ; September 2015",e.TESTNET="Test SDF Network ; September 2015",e.FUTURENET="Test SDF Future Network ; October 2022",e.SANDBOX="Local Sandbox Stellar Network ; September 2022",e.STANDALONE="Standalone Network ; February 2017",e))(io||{});class ao{static formatTokenAmount(e,t){if(e.includes("."))throw new TypeError("No decimals are allowed");const n=e.startsWith("-");let r=n?e.slice(1):e;return t>0&&(r=t>r.length?["0",r.toString().padStart(t,"0")].join("."):[r.slice(0,-t),r.slice(-t)].join(".")),r.includes(".")&&(r=r.replace(/0+$/,""),r.endsWith(".")&&(r+="0")),r.startsWith(".")&&(r=`0${r}`),n?`-${r}`:r}static parseTokenAmount(e,t){const[n,r,...o]=e.split(".").slice();if(o.length)throw new Error(`Invalid decimal value: ${e}`);if(r?.length&&r.length>t)throw new Error(`Too many decimal places in "${e}": expected at most ${t}, got ${r.length}`);return BigInt(n+(r?.padEnd(t,"0")??"0".repeat(t))).toString()}}function co(e){const t="function"==typeof e.contractId?e.contractId():null;return{...null!=t&&{contractId:$t.encodeContract(t)},type:e.type().name,topics:e.body().value().topics().map(e=>Jr(e)),data:Jr(e.body().value().data())}}function uo(e){return e.map(e=>co("inSuccessfulContractCall"in e?e.event():e))}function lo(e){return e instanceof ArrayBuffer?q.Buffer.from(new Uint8Array(e)):q.Buffer.from(e)}async function po(e,t,n,r,o){if(e.credentials().switch().value===P.SorobanCredentialsType.sorobanCredentialsSourceAccount().value)return e;const s=P.SorobanAuthorizationEntry.fromXDR(e.toXDR()),i=s.credentials(),a=yo(i);if(null===a)throw new Error(`unsupported credential type ${i.switch().name}`);a.signatureExpirationLedger(n);const c=fo(s,n,r),u=xe(c.toXDR());let l,d;if("function"==typeof t){const e=await t(c);null!==e&&"object"==typeof e&&"signature"in e?(l=lo(e.signature),d=e.publicKey):(l=lo(e),d=Ar.fromScAddress(a.address()).toString())}else l=lo(t.sign(u)),d=t.publicKey();if(!jt.fromPublicKey(d).verify(u,l))throw new Error("signature doesn't match payload");const p=Yr({public_key:$t.decodeEd25519PublicKey(d),signature:l},{type:{public_key:["symbol",null],signature:["symbol",null]}}),h=P.ScVal.scvVec([p]),f=void 0===o?[a]:wo(i).filter(e=>Ar.fromScAddress(e.address()).toString()===o);if(0===f.length)throw new Error(`the authorization entry has no credential node for address ${o}`);return f.forEach(e=>e.signature(h)),s}function ho(e){const{signer:t,validUntilLedgerSeq:n,invocation:r,networkPassphrase:o,publicKey:s="",authV2:i=!1}=e,a=jt.random().rawPublicKey(),c=new P.Int64(function(e){const t=e.subarray(0,8);if(t.length<8)throw new Error(`need at least 8 bytes to convert to Int64, got ${e.length}`);const n=new DataView(t.buffer,t.byteOffset,8);return n.getBigInt64(0,!1)}(a)),u=s||(t instanceof jt?t.publicKey():null);if(!u)throw new Error("authorizeInvocation requires publicKey parameter");const l=new P.SorobanAddressCredentials({address:new Ar(u).toScAddress(),nonce:c,signatureExpirationLedger:0,signature:P.ScVal.scvVec([])});return po(new P.SorobanAuthorizationEntry({rootInvocation:r,credentials:i?P.SorobanCredentials.sorobanCredentialsAddressV2(l):P.SorobanCredentials.sorobanCredentialsAddress(l)}),t,n,o)}function fo(e,t,n){const r=e.credentials(),o=yo(r);if(null===o)throw new Error(`cannot build a signature payload for credential type ${r.switch().name}`);const s=xe(q.Buffer.from(n));switch(r.switch().value){case P.SorobanCredentialsType.sorobanCredentialsAddress().value:return P.HashIdPreimage.envelopeTypeSorobanAuthorization(new P.HashIdPreimageSorobanAuthorization({networkId:s,nonce:o.nonce(),invocation:e.rootInvocation(),signatureExpirationLedger:t}));case P.SorobanCredentialsType.sorobanCredentialsAddressV2().value:case P.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:return P.HashIdPreimage.envelopeTypeSorobanAuthorizationWithAddress(new P.HashIdPreimageSorobanAuthorizationWithAddress({networkId:s,nonce:o.nonce(),invocation:e.rootInvocation(),address:o.address(),signatureExpirationLedger:t}));default:throw new Error(`unsupported credential type ${r.switch().name}`)}}function mo(e){const{entry:t,validUntilLedgerSeq:n,delegates:r,signature:o}=e,s=t.credentials(),i=yo(s);if(null===i||s.switch().value===P.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value)throw new Error(`buildWithDelegatesEntry expects ADDRESS or ADDRESS_V2 credentials, got ${s.switch().name}`);return new P.SorobanAuthorizationEntry({rootInvocation:t.rootInvocation(),credentials:P.SorobanCredentials.sorobanCredentialsAddressWithDelegates(new P.SorobanAddressCredentialsWithDelegates({addressCredentials:new P.SorobanAddressCredentials({address:i.address(),nonce:i.nonce(),signatureExpirationLedger:n,signature:o??P.ScVal.scvVoid()}),delegates:go(r)}))})}function go(e){const t=e.map(e=>new P.SorobanDelegateSignature({address:new Ar(e.address).toScAddress(),signature:e.signature??P.ScVal.scvVoid(),nestedDelegates:go(e.nestedDelegates??[])}));t.sort((e,t)=>q.Buffer.compare(e.address().toXDR(),t.address().toXDR()));for(let e=1;e<t.length;e++)if(0===q.Buffer.compare(t[e-1].address().toXDR(),t[e].address().toXDR()))throw new Error(`duplicate delegate address ${Ar.fromScAddress(t[e].address()).toString()}`);return t}function yo(e){switch(e.switch().value){case P.SorobanCredentialsType.sorobanCredentialsAddress().value:return e.address();case P.SorobanCredentialsType.sorobanCredentialsAddressV2().value:return e.addressV2();case P.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:return e.addressWithDelegates().addressCredentials();default:return null}}function wo(e){switch(e.switch().value){case P.SorobanCredentialsType.sorobanCredentialsAddress().value:return[e.address()];case P.SorobanCredentialsType.sorobanCredentialsAddressV2().value:return[e.addressV2()];case P.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:{const t=e.addressWithDelegates(),n=[t.addressCredentials()],r=e=>{e.forEach(e=>{n.push(e),r(e.nestedDelegates())})};return r(t.delegates()),n}default:return[]}}function Ao(e){const t=e.credentials(),n=yo(t);let r;switch(t.switch().value){case P.SorobanCredentialsType.sorobanCredentialsSourceAccount().value:r="sourceAccount";break;case P.SorobanCredentialsType.sorobanCredentialsAddress().value:r="address";break;case P.SorobanCredentialsType.sorobanCredentialsAddressV2().value:r="addressV2";break;case P.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:r="addressWithDelegates";break;default:throw new Error(`unsupported credential type ${t.switch().name}`)}const o=wo(t).map(e=>{const t=e.signature();return{address:Ar.fromScAddress(e.address()).toString(),signed:bo(t),signatures:vo(t),rawSignature:t}});return{credentialType:r,address:null===n?null:Ar.fromScAddress(n.address()).toString(),nonce:null===n?null:n.nonce().toBigInt(),signatureExpirationLedger:null===n?null:n.signatureExpirationLedger(),signers:o,signed:o.length>0&&o.every(e=>e.signed),invocation:e.rootInvocation()}}function So(e,t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new Error(`currentLedgerSeq must be a uint32 ledger sequence, got ${t}`);const n=Ao(e);if("sourceAccount"===n.credentialType)return{ready:!0,expired:!1,unsignedBy:[]};const r=t>=(n.signatureExpirationLedger??0),o=n.signers.filter(e=>!e.signed).map(e=>e.address);return{ready:!r&&0===o.length,expired:r,unsignedBy:o}}function bo(e){switch(e.switch().value){case P.ScValType.scvVoid().value:return!1;case P.ScValType.scvVec().value:return(e.vec()??[]).length>0;default:return!0}}function vo(e){if(e.switch().value!==P.ScValType.scvVec().value)return null;const t=[];for(const n of e.vec()??[]){if(n.switch().value!==P.ScValType.scvMap().value)return null;let e=null,r=null;for(const t of n.map()??[]){const n=t.key(),o=t.val();if(n.switch().value!==P.ScValType.scvSymbol().value||o.switch().value!==P.ScValType.scvBytes().value)return null;switch(n.sym().toString()){case"public_key":e=o.bytes();break;case"signature":r=o.bytes();break;default:return null}}if(null===e||null===r||32!==e.length||64!==r.length)return null;t.push({publicKey:$t.encodeEd25519PublicKey(e),signature:r})}return t}function To(e){const t=e.function(),n={},r=t.value();switch(t.switch().value){case 0:{const e=t.contractFn();n.type="execute",n.args={source:Ar.fromScAddress(e.contractAddress()).toString(),function:e.functionName().toString(),args:e.args().map(e=>Jr(e))};break}case 1:case 2:{const e=r,o=2===t.switch().value;n.type="create";const s={},[i,a]=[e.executable(),e.contractIdPreimage()];if(!!i.switch().value!=!!a.switch().value)throw new Error(`creation function appears invalid: ${JSON.stringify(r)} (should be wasm+address or token+asset)`);switch(i.switch().value){case 0:{const e=a.fromAddress();s.type="wasm",s.wasm={salt:q.Buffer.from(e.salt()).toString("hex"),hash:i.wasmHash().toString("hex"),address:Ar.fromScAddress(e.address()).toString(),...o&&{constructorArgs:r.constructorArgs().map(e=>Jr(e))}};break}case 1:s.type="sac",s.asset=Qt.fromOperation(a.fromAsset()).toString();break;default:throw new Error(`unknown creation type: ${JSON.stringify(i)}`)}n.args=s;break}default:throw new Error(`unknown invocation type (${t.switch().value}): ${JSON.stringify(t)}`)}return n.invocations=e.subInvocations().map(e=>To(e)),n}function Eo(e,t){ko(e,1,t)}function ko(e,t,n,r){!1!==n(e,t,r)&&e.subInvocations().forEach(r=>ko(r,t+1,n,e))}var Io=Object.freeze({__proto__:null,Account:Vr,Address:Ar,Asset:Qt,AssetType:Yt,AuthClawbackEnabledFlag:8,AuthImmutableFlag:4,AuthRequiredFlag:1,AuthRevocableFlag:2,BASE_FEE:no,Claimant:rn,Contract:Gr,FeeBumpTransaction:Nr,Hyper:_.Hyper,Int128:Kr,Int256:Wr,Keypair:jt,LiquidityPoolAsset:nn,LiquidityPoolFeeV18:30,LiquidityPoolId:on,Memo:Ur,MemoHash:Pr,MemoID:Rr,MemoNone:xr,MemoReturn:Or,MemoText:_r,MuxedAccount:Mr,Networks:io,Operation:Cr,ScInt:zr,SignerKey:Hr,Soroban:ao,SorobanDataBuilder:qr,StrKey:$t,TimeoutInfinite:0,Transaction:Lr,TransactionBase:tn,TransactionBuilder:ro,Uint128:$r,Uint256:Xr,UnsignedHyper:_.UnsignedHyper,XdrLargeInt:Zr,authorizeEntry:po,authorizeInvocation:ho,buildAuthorizationEntryPreimage:fo,buildInvocationTree:To,buildWithDelegatesEntry:mo,cereal:O,checkAuthEntryReadiness:So,decodeAddressToMuxedAccount:sn,encodeMuxedAccount:cn,encodeMuxedAccountToAddress:an,extractBaseAddress:un,getLiquidityPoolId:en,hash:xe,humanizeEvents:uo,inspectAuthEntry:Ao,nativeToScVal:Yr,scValToBigInt:jr,scValToNative:Jr,scvSortedMap:Qr,sign:Ut,verify:Lt,walkInvocationTree:Eo,xdr:P});class Co extends C{getResultCodes(){const{transaction:e,operations:t=[]}=this.extras().result_codes;return{transaction:e,operations:t}}getTransactionResult(){const e=this.extras().result_xdr;return e?P.TransactionResult.fromXDR(e,"base64"):null}extras(){return this.response.data.extras}}class Bo extends Error{accountId;operationIndex;constructor(e,t,n){super(e),this.accountId=t,this.operationIndex=n}}const xo={allowHttp:!1,timeout:0};let Ro={...xo};class _o{static setAllowHttp(e){Ro.allowHttp=e}static setTimeout(e){Ro.timeout=e}static isAllowHttp(){return Ro.allowHttp}static getTimeout(){return Ro.timeout}static setDefault(){Ro={...xo}}}class Po{static validateTimebounds(e,t=0){if(!e.timeBounds)return!1;const n=Math.floor(Date.now()/1e3),{minTime:r,maxTime:o}=e.timeBounds;return n>=Number.parseInt(r,10)-t&&n<=Number.parseInt(o,10)+t}static sleep(e){return new Promise(t=>setTimeout(t,e))}}
|
|
2
11
|
/*!
|
|
3
12
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4
13
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -25,7 +34,7 @@
|
|
|
25
34
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
35
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
36
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/class
|
|
37
|
+
*/class Oo extends Error{line;column;codeblock;constructor(e,t){const[n,r]=function(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}(t.toml,t.ptr),o=function(e,t,n){let r=e.split(/\r\n|\n|\r/g),o="",s=1+(0|Math.log10(t+1));for(let e=t-1;e<=t+1;e++){let i=r[e-1];i&&(o+=e.toString().padEnd(s," "),o+=": ",o+=i,o+="\n",e===t&&(o+=" ".repeat(s+n+2),o+="^\n"))}return o}(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${o}`,t),this.line=n,this.column=r,this.codeblock=o}}
|
|
29
38
|
/*!
|
|
30
39
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
31
40
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -52,7 +61,7 @@
|
|
|
52
61
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
53
62
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
54
63
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
55
|
-
*/function
|
|
64
|
+
*/function Uo(e,t){let n=0;for(;"\\"===e[t-++n];);return--n&&n%2}function Lo(e,t=0,n=e.length){let r=e.indexOf("\n",t);return"\r"===e[r-1]&&r--,r<=n?r:-1}function No(e,t){for(let n=t;n<e.length;n++){let r=e[n];if("\n"===r)return n;if("\r"===r&&"\n"===e[n+1])return n+1;if(r<" "&&"\t"!==r||"\x7f"===r)throw new Oo("control characters are not allowed in comments",{toml:e,ptr:t})}return e.length}function Vo(e,t,n,r){let o;for(;;){for(;" "===(o=e[t])||"\t"===o||!n&&("\n"===o||"\r"===o&&"\n"===e[t+1]);)t++;if(r||"#"!==o)break;t=No(e,t)}return t}function Fo(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do{t=e.indexOf(r,++t)}while(t>-1&&"'"!==n&&Uo(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}
|
|
56
65
|
/*!
|
|
57
66
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
58
67
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -79,7 +88,7 @@
|
|
|
79
88
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
80
89
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
81
90
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
82
|
-
*/let
|
|
91
|
+
*/let Do=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class Mo extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r="Z";if("string"==typeof e){let o=e.match(Do);o?(o[1]||(t=!1,e=`0000-01-01T${e}`),n=!!o[2],n&&" "===e[10]&&(e=e.replace(" ","T")),o[2]&&+o[2]>23?e="":(r=o[3]||null,e=e.toUpperCase(),!r&&n&&(e+="Z"))):e=""}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(null===this.#n)return e.slice(0,-1);if("Z"===this.#n)return e;let t=60*+this.#n.slice(1,3)+ +this.#n.slice(4,6);return t="-"===this.#n[0]?t:-t,new Date(this.getTime()-6e4*t).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(e,t="Z"){let n=new Mo(e);return n.#n=t,n}static wrapAsLocalDateTime(e){let t=new Mo(e);return t.#n=null,t}static wrapAsLocalDate(e){let t=new Mo(e);return t.#t=!1,t.#n=null,t}static wrapAsLocalTime(e){let t=new Mo(e);return t.#e=!1,t.#n=null,t}}
|
|
83
92
|
/*!
|
|
84
93
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
85
94
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -106,7 +115,7 @@
|
|
|
106
115
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
107
116
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
108
117
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
109
|
-
*/let
|
|
118
|
+
*/let qo=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Ho=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Go=/^[+-]?0[0-9_]/,$o=/^[0-9a-f]{2,8}$/i,Xo={b:"\b",t:"\t",n:"\n",f:"\f",r:"\r",e:"\x1b",'"':'"',"\\":"\\"};function Ko(e,t=0,n=e.length){let r="'"===e[t],o=e[t++]===e[t]&&e[t]===e[t+1];o&&(n-=2,"\r"===e[t+=2]&&t++,"\n"===e[t]&&t++);let s,i=0,a="",c=t;for(;t<n-1;){let n=e[t++];if("\n"===n||"\r"===n&&"\n"===e[t]){if(!o)throw new Oo("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(n<" "&&"\t"!==n||"\x7f"===n)throw new Oo("control characters are not allowed in strings",{toml:e,ptr:t-1});if(s){if(s=!1,"x"===n||"u"===n||"U"===n){let r=e.slice(t,t+="x"===n?2:"u"===n?4:8);if(!$o.test(r))throw new Oo("invalid unicode escape",{toml:e,ptr:i});try{a+=String.fromCodePoint(parseInt(r,16))}catch{throw new Oo("invalid unicode escape",{toml:e,ptr:i})}}else if(!o||"\n"!==n&&" "!==n&&"\t"!==n&&"\r"!==n){if(!(n in Xo))throw new Oo("unrecognized escape sequence",{toml:e,ptr:i});a+=Xo[n]}else{if("\n"!==e[t=Vo(e,t-1,!0)]&&"\r"!==e[t])throw new Oo("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:i});t=Vo(e,t)}c=t}else r||"\\"!==n||(i=t-1,s=!0,a+=e.slice(c,i))}return a+e.slice(c,n-1)}function Wo(e,t,n,r){if("true"===e)return!0;if("false"===e)return!1;if("-inf"===e)return-1/0;if("inf"===e||"+inf"===e)return 1/0;if("nan"===e||"+nan"===e||"-nan"===e)return NaN;if("-0"===e)return r?0n:0;let o=qo.test(e);if(o||Ho.test(e)){if(Go.test(e))throw new Oo("leading zeroes are not allowed",{toml:t,ptr:n});let s=+(e=e.replace(/_/g,""));if(isNaN(s))throw new Oo("invalid number",{toml:t,ptr:n});if(o){if((o=!Number.isSafeInteger(s))&&!r)throw new Oo("integer value cannot be represented losslessly",{toml:t,ptr:n});(o||!0===r)&&(s=BigInt(e))}return s}const s=new Mo(e);if(!s.isValid())throw new Oo("invalid value",{toml:t,ptr:n});return s}
|
|
110
119
|
/*!
|
|
111
120
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
112
121
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -133,7 +142,7 @@
|
|
|
133
142
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
134
143
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
135
144
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
136
|
-
*/function
|
|
145
|
+
*/function Zo(e,t,n,r,o){if(0===r)throw new Oo("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let s,i=e[t];if("["===i||"{"===i){let[s,a]="["===i?function(e,t,n,r){let o,s=[];t++;for(;"]"!==(o=e[t++])&&o;){if(","===o)throw new Oo("expected value, found comma",{toml:e,ptr:t-1});if("#"===o)t=No(e,t);else if(" "!==o&&"\t"!==o&&"\n"!==o&&"\r"!==o){let o=Zo(e,t-1,"]",n-1,r);s.push(o[0]),t=o[1]}}if(!o)throw new Oo("unfinished array encountered",{toml:e,ptr:t});return[s,t]}
|
|
137
146
|
/*!
|
|
138
147
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
139
148
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -160,7 +169,7 @@
|
|
|
160
169
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
161
170
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
162
171
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
163
|
-
*/(e,t,r,o):function(e,t,n,r){let o,s={},i=new Set;t++;for(;"}"!==(o=e[t++])&&o;){if(","===o)throw new
|
|
172
|
+
*/(e,t,r,o):function(e,t,n,r){let o,s={},i=new Set;t++;for(;"}"!==(o=e[t++])&&o;){if(","===o)throw new Oo("expected value, found comma",{toml:e,ptr:t-1});if("#"===o)t=No(e,t);else if(" "!==o&&"\t"!==o&&"\n"!==o&&"\r"!==o){let o,a=s,c=!1,[u,l]=jo(e,t-1);for(let n=0;n<u.length;n++){if(n&&(a=c?a[o]:a[o]={}),o=u[n],(c=Object.hasOwn(a,o))&&("object"!=typeof a[o]||i.has(a[o])))throw new Oo("trying to redefine an already defined value",{toml:e,ptr:t});c||"__proto__"!==o||Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new Oo("trying to redefine an already defined value",{toml:e,ptr:t});let[d,p]=Zo(e,l,"}",n-1,r);i.add(d),a[o]=d,t=p}}if(!o)throw new Oo("unfinished table encountered",{toml:e,ptr:t});return[s,t]}(e,t,r,o);if(n)if(a=Vo(e,a),","===e[a])a++;else if(e[a]!==n)throw new Oo("expected comma or end of structure",{toml:e,ptr:a});return[s,a]}if('"'===i||"'"===i){s=Fo(e,t);let r=Ko(e,t,s);if(n){if(s=Vo(e,s),e[s]&&","!==e[s]&&e[s]!==n&&"\n"!==e[s]&&"\r"!==e[s])throw new Oo("unexpected character encountered",{toml:e,ptr:s});s+=+(","===e[s])}return[r,s]}s=function(e,t,n,r,o=!1){if(!r)return(t=Lo(e,t))<0?e.length:t;for(let s=t;s<e.length;s++){let t=e[s];if("#"===t)s=Lo(e,s);else{if(t===n)return s+1;if(t===r||o&&("\n"===t||"\r"===t&&"\n"===e[s+1]))return s}}throw new Oo("cannot find end of structure",{toml:e,ptr:t})}(e,t,",",n);let a=function(e,t,n){let r=e.slice(t,n),o=r.indexOf("#");return o>-1&&(No(e,o),r=r.slice(0,o)),[r.trimEnd(),o]}(e,t,s-+(","===e[s-1]));if(!a[0])throw new Oo("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return n&&a[1]>-1&&(s=Vo(e,t+a[1]),s+=+(","===e[s])),[Wo(a[0],e,t,o),s]}
|
|
164
173
|
/*!
|
|
165
174
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
166
175
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -187,14 +196,5 @@
|
|
|
187
196
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
188
197
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
189
198
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
190
|
-
*/let z=/^[a-zA-Z0-9-_]+[ \t]*$/;function j(e,t,n="="){let r=t-1,o=[],s=e.indexOf(n,t);if(s<0)throw new O("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let i=e[t=++r];if(" "!==i&&"\t"!==i)if('"'===i||"'"===i){if(i===e[t+1]&&i===e[t+2])throw new O("multiline strings are not allowed in keys",{toml:e,ptr:t});let a=F(e,t);if(a<0)throw new O("unfinished string encountered",{toml:e,ptr:t});r=e.indexOf(".",a);let c=e.slice(a,r<0||r>s?s:r),u=L(c);if(u>-1)throw new O("newlines are not allowed in keys",{toml:e,ptr:t+r+u});if(c.trimStart())throw new O("found extra tokens after the string part",{toml:e,ptr:a});if(s<a&&(s=e.indexOf(n,a),s<0))throw new O("incomplete key-value: cannot find end of key",{toml:e,ptr:t});o.push(K(e,t,a))}else{r=e.indexOf(".",t);let n=e.slice(t,r<0||r>s?s:r);if(!z.test(n))throw new O("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});o.push(n.trimEnd())}}while(r+1&&r<s);return[o,V(e,s+1,!0,!0)]}function Y(e,t,n,r){let o,s,i=t,a=n,c=!1;for(let t=0;t<e.length;t++){if(t){if(i=c?i[o]:i[o]={},a=(s=a[o]).c,0===r&&(1===s.t||2===s.t))return null;if(2===s.t){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(c=Object.hasOwn(i,o))&&0===a[o]?.t&&a[o]?.d)return null;c||("__proto__"===o&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&2===r?3:r,d:!1,i:0,c:{}})}if(s=a[o],s.t!==r&&(1!==r||3!==s.t))return null;if(2===r&&(s.d||(s.d=!0,i[o]=[]),i[o].push(i={}),s.c[s.i++]=s={t:1,d:!1,i:0,c:{}}),s.d)return null;if(s.d=!0,1===r)i=c?i[o]:i[o]={};else if(0===r&&c)return null;return[o,i,s.c]}const J=102400;class Q{static async resolve(e,t={}){const{CancelToken:n}=T,r=void 0===t.allowHttp?_.isAllowHttp():t.allowHttp,o=void 0===t.timeout?_.getTimeout():t.timeout,s=r?"http":"https";return T.get(`${s}://${e}/.well-known/stellar.toml`,{maxRedirects:t.allowedRedirects??0,maxContentLength:J,cancelToken:o?new n(e=>setTimeout(()=>e(`timeout of ${o}ms exceeded`),o)):void 0,timeout:o}).then(e=>{try{const t=function(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},o={},s=r,i=o;for(let a=V(e,0);a<e.length;){if("["===e[a]){let t="["===e[++a],n=j(e,a+=+t,"]");if(t){if("]"!==e[n[1]-1])throw new O("expected end of table declaration",{toml:e,ptr:n[1]-1});n[1]++}let c=Y(n[0],r,o,t?2:1);if(!c)throw new O("trying to redefine an already defined table or value",{toml:e,ptr:a});i=c[2],s=c[1],a=n[1]}else{let r=j(e,a),o=Y(r[0],s,i,0);if(!o)throw new O("trying to redefine an already defined table or value",{toml:e,ptr:a});let c=Z(e,r[1],void 0,t,n);o[1][o[0]]=c[0],a=c[1]}if(a=V(e,a,!0),e[a]&&"\n"!==e[a]&&"\r"!==e[a])throw new O("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:a});a=V(e,a)}return r}(e.data);return Promise.resolve(t)}catch(e){return Promise.reject(new Error(`stellar.toml is invalid - Parsing error on line ${e.line}, column ${e.column}: ${e.message}`))}}).catch(e=>{throw e.message.match(/^maxContentLength size/)?new Error("stellar.toml file exceeds allowed size of 102400"):e})}}var ee=Object.freeze({__proto__:null,Resolver:Q,STELLAR_TOML_MAX_SIZE:J});function te(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ne,re={exports:{}};
|
|
191
|
-
/*! For license information please see xdr.js.LICENSE.txt */var oe=(ne||(ne=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 K(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:K(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:A(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):A(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function A(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 S(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 b(e,t,n,r){return Z(K(t,e.length-n),e,n,r)}function v(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 S(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":case"latin1":case"binary":return v(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){H(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){H(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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){G(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||$(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 H(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){G(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||$(t,e.length-(n+1))}(r,o,s)}function G(e,t){if("number"!=typeof e)throw new D.ERR_INVALID_ARG_TYPE(t,"number",e)}function $(e,t,n){if(Math.floor(e)!==e)throw G(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 X=/[^+/0-9A-Za-z-_]/g;function K(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(X,"")).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:()=>H,Bool:()=>L,Double:()=>O,Enum:()=>K,Float:()=>P,Hyper:()=>B,Int:()=>T,LargeInt:()=>C,Opaque:()=>D,Option:()=>$,Quadruple:()=>U,Reference:()=>W,String:()=>V,Struct:()=>Z,Union:()=>j,UnsignedHyper:()=>_,UnsignedInt:()=>R,VarArray:()=>G,VarOpaque:()=>q,Void:()=>X,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(A(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(A(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 A(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 S(e,t){return null!=e&&(e instanceof t||b(e,t)&&"function"==typeof e.constructor.read&&"function"==typeof e.constructor.write&&b(e,"XdrType"))}function b(e,t){do{if(e.constructor.name===t)return!0}while(e=Object.getPrototypeOf(e));return!1}const v=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<=v}}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=v,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 H 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._length}`);for(const n of e)this._childType.write(n,t)}isValid(e){if(!(e instanceof n.g.Array)||e.length!==this._length)return!1;for(const t of e)if(!this._childType.isValid(t))return!1;return!0}}class G extends g{constructor(e,t=R.MAX_VALUE,n=g.DEFAULT_MAX_DEPTH){super(n),this._childType=e,this._maxLength=t}read(e,t=this._maxDepth){g.checkDepth(t);const n=R.read(e);if(n>this._maxLength)throw new o(`saw ${n} length VarArray, max allowed is ${this._maxLength}`);if(n>e.remainingBytes())throw new o(`VarArray length ${n} exceeds remaining ${e.remainingBytes()} bytes`);const r=[];for(let o=0;o<n;o++)r.push(this._childType.read(e,t-1));return r}write(e,t){if(!(e instanceof Array))throw new r("value is not array");if(e.length>this._maxLength)throw new r(`got array of size ${e.length}, max allowed is ${this._maxLength}`);R.write(e.length,t);for(const n of e)this._childType.write(n,t)}isValid(e){if(!(e instanceof Array)||e.length>this._maxLength)return!1;for(const t of e)if(!this._childType.isValid(t))return!1;return!0}}class $ extends g{constructor(e,t=g.DEFAULT_MAX_DEPTH){super(t),this._childType=e}read(e,t=this._maxDepth){if(g.checkDepth(t),L.read(e))return this._childType.read(e,t-1)}write(e,t){const n=null!=e;L.write(n,t),n&&this._childType.write(e,t)}isValid(e){return null==e||this._childType.isValid(e)}}class X extends f{static read(){}static write(e){if(void 0!==e)throw new r("trying to write value to a void slot")}static isValid(e){return void 0===e}}class K extends f{constructor(e,t){super(),this.name=e,this.value=t}static read(e){const t=T.read(e),n=this._byValue[t];if(void 0===n)throw new o(`unknown ${this.enumName} member for value ${t}`);return n}static write(e,t){if(!this.isValid(e))throw new r(`${e} has enum name ${e?.enumName}, not ${this.enumName}: ${JSON.stringify(e)}`);T.write(e.value,t)}static isValid(e){return e?.constructor?.enumName===this.enumName||S(e,this)}static members(){return this._members}static values(){return Object.values(this._members)}static fromName(e){const t=this._members[e];if(!t)throw new TypeError(`${e} is not a member of ${this.enumName}`);return t}static fromValue(e){const t=this._byValue[e];if(void 0===t)throw new TypeError(`${e} is not a value of any member of ${this.enumName}`);return t}static create(e,t,n){const r=class extends K{};r.enumName=t,e.results[t]=r,r._members={},r._byValue={};for(const[e,t]of Object.entries(n)){const n=new r(e,t);r._members[e]=n,r._byValue[t]=n,r[e]=()=>n}return r}}class W extends f{resolve(){throw new s('"resolve" method should be implemented in the descendant class')}}class Z extends g{constructor(e,t){super(t??new.target?._maxDepth),this._attributes=e||{}}static read(e,t=this._maxDepth){g.checkDepth(t);const n={};for(const[r,o]of this._fields)n[r]=o.read(e,t-1);return new this(n,this._maxDepth)}static write(e,t){if(!this.isValid(e))throw new r(`${e} has struct name ${e?.constructor?.structName}, not ${this.structName}: ${JSON.stringify(e)}`);for(const[n,r]of this._fields){const o=e._attributes[n];r.write(o,t)}}static isValid(e){return e?.constructor?.structName===this.structName||S(e,this)}static create(e,t,n,r=g.DEFAULT_MAX_DEPTH){const o=class extends Z{};o.structName=t,o._maxDepth=r,e.results[t]=o;const s=new Array(n.length);for(let t=0;t<n.length;t++){const r=n[t],i=r[0];let a=r[1];a instanceof W&&(a=a.resolve(e)),s[t]=[i,a],o.prototype[i]=z(i)}return o._fields=s,o}}function z(e){return function(t){return void 0!==t&&(this._attributes[e]=t),this._attributes[e]}}class j extends g{constructor(e,t,n){super(n??new.target?._maxDepth),this.set(e,t)}set(e,t){"string"==typeof e&&(e=this.constructor._switchOn.fromName(e)),this._switch=e;const n=this.constructor.armForSwitch(this._switch);this._arm=n,this._armType=n===X?X:this.constructor._arms[n],this._value=t}get(e=this._arm){if(this._arm!==X&&this._arm!==e)throw new TypeError(`${e} not set`);return this._value}switch(){return this._switch}arm(){return this._arm}armType(){return this._armType}value(){return this._value}static armForSwitch(e){const t=this._switches.get(e);if(void 0!==t)return t;if(this._defaultArm)return this._defaultArm;throw new TypeError(`Bad union switch: ${e}`)}static armTypeForArm(e){return e===X?X:this._arms[e]}static read(e,t=this._maxDepth){g.checkDepth(t);const n=this._switchOn.read(e,t-1),r=this.armForSwitch(n),o=r===X?X:this._arms[r];let s;return s=void 0!==o?o.read(e,t-1):r.read(e,t-1),new this(n,s,this._maxDepth)}static write(e,t){if(!this.isValid(e))throw new r(`${e} has union name ${e?.unionName}, not ${this.unionName}: ${JSON.stringify(e)}`);this._switchOn.write(e.switch(),t),e.armType().write(e.value(),t)}static isValid(e){return e?.constructor?.unionName===this.unionName||S(e,this)}static create(e,t,n,r=g.DEFAULT_MAX_DEPTH){const o=class extends j{};o.unionName=t,o._maxDepth=r,e.results[t]=o,n.switchOn instanceof W?o._switchOn=n.switchOn.resolve(e):o._switchOn=n.switchOn,o._switches=new Map,o._arms={};let s=n.defaultArm;s instanceof W&&(s=s.resolve(e)),o._defaultArm=s;for(const[e,t]of n.switches){const n="string"==typeof e?o._switchOn.fromName(e):e;o._switches.set(n,t)}if(void 0!==o._switchOn.values)for(const e of o._switchOn.values())o[e.name]=function(t){return new o(e,t)},o.prototype[e.name]=function(t){return this.set(e,t)};if(n.arms)for(const[t,r]of Object.entries(n.arms))o._arms[t]=r instanceof W?r.resolve(e):r,r!==X&&(o.prototype[t]=function(){return this.get(t)});return o}}class Y extends W{constructor(e){super(),this.name=e}resolve(e){return e.definitions[this.name].resolve(e)}}class J extends W{constructor(e,t,n=!1){super(),this.childReference=e,this.length=t,this.variable=n}resolve(e){let t=this.childReference,n=this.length;return t instanceof W&&(t=t.resolve(e)),n instanceof W&&(n=n.resolve(e)),this.variable?new G(t,n):new H(t,n)}}class Q extends W{constructor(e){super(),this.childReference=e,this.name=e.name}resolve(e){let t=this.childReference;return t instanceof W&&(t=t.resolve(e)),new $(t)}}class ee extends W{constructor(e,t){super(),this.sizedType=e,this.length=t}resolve(e){let t=this.length;return t instanceof W&&(t=t.resolve(e)),new this.sizedType(t)}}class te{constructor(e,t,n){this.constructor=e,this.name=t,this.config=n}resolve(e){return this.name in e.results?e.results[this.name]:this.constructor(e,this.name,this.config)}}function ne(e,t,n){return n instanceof W&&(n=n.resolve(e)),e.results[t]=n,n}function re(e,t,n){return e.results[t]=n,n}class oe{constructor(e){this._destination=e,this._definitions={}}enum(e,t){const n=new te(K.create,e,t);this.define(e,n)}struct(e,t){const n=new te(Z.create,e,t);this.define(e,n)}union(e,t){const n=new te(j.create,e,t);this.define(e,n)}typedef(e,t){const n=new te(ne,e,t);this.define(e,n)}const(e,t){const n=new te(re,e,t);this.define(e,n)}void(){return X}bool(){return L}int(){return T}hyper(){return B}uint(){return R}uhyper(){return _}float(){return P}double(){return O}quadruple(){return U}string(e){return new ee(V,e)}opaque(e){return new ee(D,e)}varOpaque(e){return new ee(q,e)}array(e,t){return new J(e,t)}varArray(e,t){return new J(e,t,!0)}option(e){return new Q(e)}define(e,t){if(void 0!==this._destination[e])throw new s(`${e} is already defined`);this._definitions[e]=t}lookup(e){return new Y(e)}resolve(){for(const e of Object.values(this._definitions))e.resolve({definitions:this._definitions,results:this._destination})}}function se(e,t={}){if(e){const n=new oe(t);e(n),n.resolve()}return t}},947(e,t){t.read=function(e,t,n,r,o){var s,i,a=8*o-r-1,c=(1<<a)-1,u=c>>1,l=-7,d=n?o-1:0,p=n?-1:1,h=e[t+d];for(d+=p,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=p,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=r;l>0;i=256*i+e[t+d],d+=p,l-=8);if(0===s)s=1-u;else{if(s===c)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,r),s-=u}return(h?-1:1)*i*Math.pow(2,s-r)},t.write=function(e,t,n,r,o,s){var i,a,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),(t+=i+d>=1?p/c:p*Math.pow(2,1-d))*c>=2&&(i++,c/=2),i+d>=l?(a=0,i=l):i+d>=1?(a=(t*c-1)*Math.pow(2,o),i+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(i=i<<o|a,u+=o;u>0;e[n+h]=255&i,h+=f,i/=256,u-=8);e[n+h-f]|=128*m}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(348)})(),e.exports=t()}(re)),re.exports),se=oe.config(e=>{const t=1024;e.typedef("Value",e.varOpaque()),e.struct("ScpBallot",[["counter",e.lookup("Uint32")],["value",e.lookup("Value")]]),e.enum("ScpStatementType",{scpStPrepare:0,scpStConfirm:1,scpStExternalize:2,scpStNominate:3}),e.struct("ScpNomination",[["quorumSetHash",e.lookup("Hash")],["votes",e.varArray(e.lookup("Value"),2147483647)],["accepted",e.varArray(e.lookup("Value"),2147483647)]]),e.struct("ScpStatementPrepare",[["quorumSetHash",e.lookup("Hash")],["ballot",e.lookup("ScpBallot")],["prepared",e.option(e.lookup("ScpBallot"))],["preparedPrime",e.option(e.lookup("ScpBallot"))],["nC",e.lookup("Uint32")],["nH",e.lookup("Uint32")]]),e.struct("ScpStatementConfirm",[["ballot",e.lookup("ScpBallot")],["nPrepared",e.lookup("Uint32")],["nCommit",e.lookup("Uint32")],["nH",e.lookup("Uint32")],["quorumSetHash",e.lookup("Hash")]]),e.struct("ScpStatementExternalize",[["commit",e.lookup("ScpBallot")],["nH",e.lookup("Uint32")],["commitQuorumSetHash",e.lookup("Hash")]]),e.union("ScpStatementPledges",{switchOn:e.lookup("ScpStatementType"),switchName:"type",switches:[["scpStPrepare","prepare"],["scpStConfirm","confirm"],["scpStExternalize","externalize"],["scpStNominate","nominate"]],arms:{prepare:e.lookup("ScpStatementPrepare"),confirm:e.lookup("ScpStatementConfirm"),externalize:e.lookup("ScpStatementExternalize"),nominate:e.lookup("ScpNomination")}}),e.struct("ScpStatement",[["nodeId",e.lookup("NodeId")],["slotIndex",e.lookup("Uint64")],["pledges",e.lookup("ScpStatementPledges")]]),e.struct("ScpEnvelope",[["statement",e.lookup("ScpStatement")],["signature",e.lookup("Signature")]]),e.struct("ScpQuorumSet",[["threshold",e.lookup("Uint32")],["validators",e.varArray(e.lookup("NodeId"),2147483647)],["innerSets",e.varArray(e.lookup("ScpQuorumSet"),2147483647)]]),e.typedef("Thresholds",e.opaque(4)),e.typedef("String32",e.string(32)),e.typedef("String64",e.string(64)),e.typedef("SequenceNumber",e.lookup("Int64")),e.typedef("DataValue",e.varOpaque(64)),e.typedef("AssetCode4",e.opaque(4)),e.typedef("AssetCode12",e.opaque(12)),e.enum("AssetType",{assetTypeNative:0,assetTypeCreditAlphanum4:1,assetTypeCreditAlphanum12:2,assetTypePoolShare:3}),e.union("AssetCode",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeCreditAlphanum4","assetCode4"],["assetTypeCreditAlphanum12","assetCode12"]],arms:{assetCode4:e.lookup("AssetCode4"),assetCode12:e.lookup("AssetCode12")}}),e.struct("AlphaNum4",[["assetCode",e.lookup("AssetCode4")],["issuer",e.lookup("AccountId")]]),e.struct("AlphaNum12",[["assetCode",e.lookup("AssetCode12")],["issuer",e.lookup("AccountId")]]),e.union("Asset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12")}}),e.struct("Price",[["n",e.lookup("Int32")],["d",e.lookup("Int32")]]),e.struct("Liabilities",[["buying",e.lookup("Int64")],["selling",e.lookup("Int64")]]),e.enum("ThresholdIndices",{thresholdMasterWeight:0,thresholdLow:1,thresholdMed:2,thresholdHigh:3}),e.enum("LedgerEntryType",{account:0,trustline:1,offer:2,data:3,claimableBalance:4,liquidityPool:5,contractData:6,contractCode:7,configSetting:8,ttl:9}),e.struct("Signer",[["key",e.lookup("SignerKey")],["weight",e.lookup("Uint32")]]),e.enum("AccountFlags",{authRequiredFlag:1,authRevocableFlag:2,authImmutableFlag:4,authClawbackEnabledFlag:8}),e.const("MASK_ACCOUNT_FLAGS",7),e.const("MASK_ACCOUNT_FLAGS_V17",15),e.const("MAX_SIGNERS",20),e.typedef("SponsorshipDescriptor",e.option(e.lookup("AccountId"))),e.struct("AccountEntryExtensionV3",[["ext",e.lookup("ExtensionPoint")],["seqLedger",e.lookup("Uint32")],["seqTime",e.lookup("TimePoint")]]),e.union("AccountEntryExtensionV2Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[3,"v3"]],arms:{v3:e.lookup("AccountEntryExtensionV3")}}),e.struct("AccountEntryExtensionV2",[["numSponsored",e.lookup("Uint32")],["numSponsoring",e.lookup("Uint32")],["signerSponsoringIDs",e.varArray(e.lookup("SponsorshipDescriptor"),e.lookup("MAX_SIGNERS"))],["ext",e.lookup("AccountEntryExtensionV2Ext")]]),e.union("AccountEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[2,"v2"]],arms:{v2:e.lookup("AccountEntryExtensionV2")}}),e.struct("AccountEntryExtensionV1",[["liabilities",e.lookup("Liabilities")],["ext",e.lookup("AccountEntryExtensionV1Ext")]]),e.union("AccountEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("AccountEntryExtensionV1")}}),e.struct("AccountEntry",[["accountId",e.lookup("AccountId")],["balance",e.lookup("Int64")],["seqNum",e.lookup("SequenceNumber")],["numSubEntries",e.lookup("Uint32")],["inflationDest",e.option(e.lookup("AccountId"))],["flags",e.lookup("Uint32")],["homeDomain",e.lookup("String32")],["thresholds",e.lookup("Thresholds")],["signers",e.varArray(e.lookup("Signer"),e.lookup("MAX_SIGNERS"))],["ext",e.lookup("AccountEntryExt")]]),e.enum("TrustLineFlags",{authorizedFlag:1,authorizedToMaintainLiabilitiesFlag:2,trustlineClawbackEnabledFlag:4}),e.const("MASK_TRUSTLINE_FLAGS",1),e.const("MASK_TRUSTLINE_FLAGS_V13",3),e.const("MASK_TRUSTLINE_FLAGS_V17",7),e.enum("LiquidityPoolType",{liquidityPoolConstantProduct:0}),e.union("TrustLineAsset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"],["assetTypePoolShare","liquidityPoolId"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12"),liquidityPoolId:e.lookup("PoolId")}}),e.union("TrustLineEntryExtensionV2Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TrustLineEntryExtensionV2",[["liquidityPoolUseCount",e.lookup("Int32")],["ext",e.lookup("TrustLineEntryExtensionV2Ext")]]),e.union("TrustLineEntryV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[2,"v2"]],arms:{v2:e.lookup("TrustLineEntryExtensionV2")}}),e.struct("TrustLineEntryV1",[["liabilities",e.lookup("Liabilities")],["ext",e.lookup("TrustLineEntryV1Ext")]]),e.union("TrustLineEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("TrustLineEntryV1")}}),e.struct("TrustLineEntry",[["accountId",e.lookup("AccountId")],["asset",e.lookup("TrustLineAsset")],["balance",e.lookup("Int64")],["limit",e.lookup("Int64")],["flags",e.lookup("Uint32")],["ext",e.lookup("TrustLineEntryExt")]]),e.enum("OfferEntryFlags",{passiveFlag:1}),e.const("MASK_OFFERENTRY_FLAGS",1),e.union("OfferEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("OfferEntry",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")],["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")],["flags",e.lookup("Uint32")],["ext",e.lookup("OfferEntryExt")]]),e.union("DataEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("DataEntry",[["accountId",e.lookup("AccountId")],["dataName",e.lookup("String64")],["dataValue",e.lookup("DataValue")],["ext",e.lookup("DataEntryExt")]]),e.enum("ClaimPredicateType",{claimPredicateUnconditional:0,claimPredicateAnd:1,claimPredicateOr:2,claimPredicateNot:3,claimPredicateBeforeAbsoluteTime:4,claimPredicateBeforeRelativeTime:5}),e.union("ClaimPredicate",{switchOn:e.lookup("ClaimPredicateType"),switchName:"type",switches:[["claimPredicateUnconditional",e.void()],["claimPredicateAnd","andPredicates"],["claimPredicateOr","orPredicates"],["claimPredicateNot","notPredicate"],["claimPredicateBeforeAbsoluteTime","absBefore"],["claimPredicateBeforeRelativeTime","relBefore"]],arms:{andPredicates:e.varArray(e.lookup("ClaimPredicate"),2),orPredicates:e.varArray(e.lookup("ClaimPredicate"),2),notPredicate:e.option(e.lookup("ClaimPredicate")),absBefore:e.lookup("Int64"),relBefore:e.lookup("Int64")}}),e.enum("ClaimantType",{claimantTypeV0:0}),e.struct("ClaimantV0",[["destination",e.lookup("AccountId")],["predicate",e.lookup("ClaimPredicate")]]),e.union("Claimant",{switchOn:e.lookup("ClaimantType"),switchName:"type",switches:[["claimantTypeV0","v0"]],arms:{v0:e.lookup("ClaimantV0")}}),e.enum("ClaimableBalanceFlags",{claimableBalanceClawbackEnabledFlag:1}),e.const("MASK_CLAIMABLE_BALANCE_FLAGS",1),e.union("ClaimableBalanceEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("ClaimableBalanceEntryExtensionV1",[["ext",e.lookup("ClaimableBalanceEntryExtensionV1Ext")],["flags",e.lookup("Uint32")]]),e.union("ClaimableBalanceEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("ClaimableBalanceEntryExtensionV1")}}),e.struct("ClaimableBalanceEntry",[["balanceId",e.lookup("ClaimableBalanceId")],["claimants",e.varArray(e.lookup("Claimant"),10)],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")],["ext",e.lookup("ClaimableBalanceEntryExt")]]),e.struct("LiquidityPoolConstantProductParameters",[["assetA",e.lookup("Asset")],["assetB",e.lookup("Asset")],["fee",e.lookup("Int32")]]),e.struct("LiquidityPoolEntryConstantProduct",[["params",e.lookup("LiquidityPoolConstantProductParameters")],["reserveA",e.lookup("Int64")],["reserveB",e.lookup("Int64")],["totalPoolShares",e.lookup("Int64")],["poolSharesTrustLineCount",e.lookup("Int64")]]),e.union("LiquidityPoolEntryBody",{switchOn:e.lookup("LiquidityPoolType"),switchName:"type",switches:[["liquidityPoolConstantProduct","constantProduct"]],arms:{constantProduct:e.lookup("LiquidityPoolEntryConstantProduct")}}),e.struct("LiquidityPoolEntry",[["liquidityPoolId",e.lookup("PoolId")],["body",e.lookup("LiquidityPoolEntryBody")]]),e.enum("ContractDataDurability",{temporary:0,persistent:1}),e.struct("ContractDataEntry",[["ext",e.lookup("ExtensionPoint")],["contract",e.lookup("ScAddress")],["key",e.lookup("ScVal")],["durability",e.lookup("ContractDataDurability")],["val",e.lookup("ScVal")]]),e.struct("ContractCodeCostInputs",[["ext",e.lookup("ExtensionPoint")],["nInstructions",e.lookup("Uint32")],["nFunctions",e.lookup("Uint32")],["nGlobals",e.lookup("Uint32")],["nTableEntries",e.lookup("Uint32")],["nTypes",e.lookup("Uint32")],["nDataSegments",e.lookup("Uint32")],["nElemSegments",e.lookup("Uint32")],["nImports",e.lookup("Uint32")],["nExports",e.lookup("Uint32")],["nDataSegmentBytes",e.lookup("Uint32")]]),e.struct("ContractCodeEntryV1",[["ext",e.lookup("ExtensionPoint")],["costInputs",e.lookup("ContractCodeCostInputs")]]),e.union("ContractCodeEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("ContractCodeEntryV1")}}),e.struct("ContractCodeEntry",[["ext",e.lookup("ContractCodeEntryExt")],["hash",e.lookup("Hash")],["code",e.varOpaque()]]),e.struct("TtlEntry",[["keyHash",e.lookup("Hash")],["liveUntilLedgerSeq",e.lookup("Uint32")]]),e.union("LedgerEntryExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerEntryExtensionV1",[["sponsoringId",e.lookup("SponsorshipDescriptor")],["ext",e.lookup("LedgerEntryExtensionV1Ext")]]),e.union("LedgerEntryData",{switchOn:e.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["data","data"],["claimableBalance","claimableBalance"],["liquidityPool","liquidityPool"],["contractData","contractData"],["contractCode","contractCode"],["configSetting","configSetting"],["ttl","ttl"]],arms:{account:e.lookup("AccountEntry"),trustLine:e.lookup("TrustLineEntry"),offer:e.lookup("OfferEntry"),data:e.lookup("DataEntry"),claimableBalance:e.lookup("ClaimableBalanceEntry"),liquidityPool:e.lookup("LiquidityPoolEntry"),contractData:e.lookup("ContractDataEntry"),contractCode:e.lookup("ContractCodeEntry"),configSetting:e.lookup("ConfigSettingEntry"),ttl:e.lookup("TtlEntry")}}),e.union("LedgerEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerEntryExtensionV1")}}),e.struct("LedgerEntry",[["lastModifiedLedgerSeq",e.lookup("Uint32")],["data",e.lookup("LedgerEntryData")],["ext",e.lookup("LedgerEntryExt")]]),e.struct("LedgerKeyAccount",[["accountId",e.lookup("AccountId")]]),e.struct("LedgerKeyTrustLine",[["accountId",e.lookup("AccountId")],["asset",e.lookup("TrustLineAsset")]]),e.struct("LedgerKeyOffer",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")]]),e.struct("LedgerKeyData",[["accountId",e.lookup("AccountId")],["dataName",e.lookup("String64")]]),e.struct("LedgerKeyClaimableBalance",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("LedgerKeyLiquidityPool",[["liquidityPoolId",e.lookup("PoolId")]]),e.struct("LedgerKeyContractData",[["contract",e.lookup("ScAddress")],["key",e.lookup("ScVal")],["durability",e.lookup("ContractDataDurability")]]),e.struct("LedgerKeyContractCode",[["hash",e.lookup("Hash")]]),e.struct("LedgerKeyConfigSetting",[["configSettingId",e.lookup("ConfigSettingId")]]),e.struct("LedgerKeyTtl",[["keyHash",e.lookup("Hash")]]),e.union("LedgerKey",{switchOn:e.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["data","data"],["claimableBalance","claimableBalance"],["liquidityPool","liquidityPool"],["contractData","contractData"],["contractCode","contractCode"],["configSetting","configSetting"],["ttl","ttl"]],arms:{account:e.lookup("LedgerKeyAccount"),trustLine:e.lookup("LedgerKeyTrustLine"),offer:e.lookup("LedgerKeyOffer"),data:e.lookup("LedgerKeyData"),claimableBalance:e.lookup("LedgerKeyClaimableBalance"),liquidityPool:e.lookup("LedgerKeyLiquidityPool"),contractData:e.lookup("LedgerKeyContractData"),contractCode:e.lookup("LedgerKeyContractCode"),configSetting:e.lookup("LedgerKeyConfigSetting"),ttl:e.lookup("LedgerKeyTtl")}}),e.enum("EnvelopeType",{envelopeTypeTxV0:0,envelopeTypeScp:1,envelopeTypeTx:2,envelopeTypeAuth:3,envelopeTypeScpvalue:4,envelopeTypeTxFeeBump:5,envelopeTypeOpId:6,envelopeTypePoolRevokeOpId:7,envelopeTypeContractId:8,envelopeTypeSorobanAuthorization:9,envelopeTypeSorobanAuthorizationWithAddress:10}),e.enum("BucketListType",{live:0,hotArchive:1}),e.enum("BucketEntryType",{metaentry:-1,liveentry:0,deadentry:1,initentry:2}),e.enum("HotArchiveBucketEntryType",{hotArchiveMetaentry:-1,hotArchiveArchived:0,hotArchiveLive:1}),e.union("BucketMetadataExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"bucketListType"]],arms:{bucketListType:e.lookup("BucketListType")}}),e.struct("BucketMetadata",[["ledgerVersion",e.lookup("Uint32")],["ext",e.lookup("BucketMetadataExt")]]),e.union("BucketEntry",{switchOn:e.lookup("BucketEntryType"),switchName:"type",switches:[["liveentry","liveEntry"],["initentry","liveEntry"],["deadentry","deadEntry"],["metaentry","metaEntry"]],arms:{liveEntry:e.lookup("LedgerEntry"),deadEntry:e.lookup("LedgerKey"),metaEntry:e.lookup("BucketMetadata")}}),e.union("HotArchiveBucketEntry",{switchOn:e.lookup("HotArchiveBucketEntryType"),switchName:"type",switches:[["hotArchiveArchived","archivedEntry"],["hotArchiveLive","key"],["hotArchiveMetaentry","metaEntry"]],arms:{archivedEntry:e.lookup("LedgerEntry"),key:e.lookup("LedgerKey"),metaEntry:e.lookup("BucketMetadata")}}),e.typedef("UpgradeType",e.varOpaque(128)),e.enum("StellarValueType",{stellarValueBasic:0,stellarValueSigned:1}),e.struct("LedgerCloseValueSignature",[["nodeId",e.lookup("NodeId")],["signature",e.lookup("Signature")]]),e.union("StellarValueExt",{switchOn:e.lookup("StellarValueType"),switchName:"v",switches:[["stellarValueBasic",e.void()],["stellarValueSigned","lcValueSignature"]],arms:{lcValueSignature:e.lookup("LedgerCloseValueSignature")}}),e.struct("StellarValue",[["txSetHash",e.lookup("Hash")],["closeTime",e.lookup("TimePoint")],["upgrades",e.varArray(e.lookup("UpgradeType"),6)],["ext",e.lookup("StellarValueExt")]]),e.const("MASK_LEDGER_HEADER_FLAGS",7),e.enum("LedgerHeaderFlags",{disableLiquidityPoolTradingFlag:1,disableLiquidityPoolDepositFlag:2,disableLiquidityPoolWithdrawalFlag:4}),e.union("LedgerHeaderExtensionV1Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerHeaderExtensionV1",[["flags",e.lookup("Uint32")],["ext",e.lookup("LedgerHeaderExtensionV1Ext")]]),e.union("LedgerHeaderExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerHeaderExtensionV1")}}),e.struct("LedgerHeader",[["ledgerVersion",e.lookup("Uint32")],["previousLedgerHash",e.lookup("Hash")],["scpValue",e.lookup("StellarValue")],["txSetResultHash",e.lookup("Hash")],["bucketListHash",e.lookup("Hash")],["ledgerSeq",e.lookup("Uint32")],["totalCoins",e.lookup("Int64")],["feePool",e.lookup("Int64")],["inflationSeq",e.lookup("Uint32")],["idPool",e.lookup("Uint64")],["baseFee",e.lookup("Uint32")],["baseReserve",e.lookup("Uint32")],["maxTxSetSize",e.lookup("Uint32")],["skipList",e.array(e.lookup("Hash"),4)],["ext",e.lookup("LedgerHeaderExt")]]),e.enum("LedgerUpgradeType",{ledgerUpgradeVersion:1,ledgerUpgradeBaseFee:2,ledgerUpgradeMaxTxSetSize:3,ledgerUpgradeBaseReserve:4,ledgerUpgradeFlags:5,ledgerUpgradeConfig:6,ledgerUpgradeMaxSorobanTxSetSize:7}),e.struct("ConfigUpgradeSetKey",[["contractId",e.lookup("ContractId")],["contentHash",e.lookup("Hash")]]),e.union("LedgerUpgrade",{switchOn:e.lookup("LedgerUpgradeType"),switchName:"type",switches:[["ledgerUpgradeVersion","newLedgerVersion"],["ledgerUpgradeBaseFee","newBaseFee"],["ledgerUpgradeMaxTxSetSize","newMaxTxSetSize"],["ledgerUpgradeBaseReserve","newBaseReserve"],["ledgerUpgradeFlags","newFlags"],["ledgerUpgradeConfig","newConfig"],["ledgerUpgradeMaxSorobanTxSetSize","newMaxSorobanTxSetSize"]],arms:{newLedgerVersion:e.lookup("Uint32"),newBaseFee:e.lookup("Uint32"),newMaxTxSetSize:e.lookup("Uint32"),newBaseReserve:e.lookup("Uint32"),newFlags:e.lookup("Uint32"),newConfig:e.lookup("ConfigUpgradeSetKey"),newMaxSorobanTxSetSize:e.lookup("Uint32")}}),e.struct("ConfigUpgradeSet",[["updatedEntry",e.varArray(e.lookup("ConfigSettingEntry"),2147483647)]]),e.enum("TxSetComponentType",{txsetCompTxsMaybeDiscountedFee:0}),e.typedef("DependentTxCluster",e.varArray(e.lookup("TransactionEnvelope"),2147483647)),e.typedef("ParallelTxExecutionStage",e.varArray(e.lookup("DependentTxCluster"),2147483647)),e.struct("ParallelTxsComponent",[["baseFee",e.option(e.lookup("Int64"))],["executionStages",e.varArray(e.lookup("ParallelTxExecutionStage"),2147483647)]]),e.struct("TxSetComponentTxsMaybeDiscountedFee",[["baseFee",e.option(e.lookup("Int64"))],["txes",e.varArray(e.lookup("TransactionEnvelope"),2147483647)]]),e.union("TxSetComponent",{switchOn:e.lookup("TxSetComponentType"),switchName:"type",switches:[["txsetCompTxsMaybeDiscountedFee","txsMaybeDiscountedFee"]],arms:{txsMaybeDiscountedFee:e.lookup("TxSetComponentTxsMaybeDiscountedFee")}}),e.union("TransactionPhase",{switchOn:e.int(),switchName:"v",switches:[[0,"v0Components"],[1,"parallelTxsComponent"]],arms:{v0Components:e.varArray(e.lookup("TxSetComponent"),2147483647),parallelTxsComponent:e.lookup("ParallelTxsComponent")}}),e.struct("TransactionSet",[["previousLedgerHash",e.lookup("Hash")],["txes",e.varArray(e.lookup("TransactionEnvelope"),2147483647)]]),e.struct("TransactionSetV1",[["previousLedgerHash",e.lookup("Hash")],["phases",e.varArray(e.lookup("TransactionPhase"),2147483647)]]),e.union("GeneralizedTransactionSet",{switchOn:e.int(),switchName:"v",switches:[[1,"v1TxSet"]],arms:{v1TxSet:e.lookup("TransactionSetV1")}}),e.struct("TransactionResultPair",[["transactionHash",e.lookup("Hash")],["result",e.lookup("TransactionResult")]]),e.struct("TransactionResultSet",[["results",e.varArray(e.lookup("TransactionResultPair"),2147483647)]]),e.union("TransactionHistoryEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"generalizedTxSet"]],arms:{generalizedTxSet:e.lookup("GeneralizedTransactionSet")}}),e.struct("TransactionHistoryEntry",[["ledgerSeq",e.lookup("Uint32")],["txSet",e.lookup("TransactionSet")],["ext",e.lookup("TransactionHistoryEntryExt")]]),e.union("TransactionHistoryResultEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionHistoryResultEntry",[["ledgerSeq",e.lookup("Uint32")],["txResultSet",e.lookup("TransactionResultSet")],["ext",e.lookup("TransactionHistoryResultEntryExt")]]),e.union("LedgerHeaderHistoryEntryExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("LedgerHeaderHistoryEntry",[["hash",e.lookup("Hash")],["header",e.lookup("LedgerHeader")],["ext",e.lookup("LedgerHeaderHistoryEntryExt")]]),e.struct("LedgerScpMessages",[["ledgerSeq",e.lookup("Uint32")],["messages",e.varArray(e.lookup("ScpEnvelope"),2147483647)]]),e.struct("ScpHistoryEntryV0",[["quorumSets",e.varArray(e.lookup("ScpQuorumSet"),2147483647)],["ledgerMessages",e.lookup("LedgerScpMessages")]]),e.union("ScpHistoryEntry",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("ScpHistoryEntryV0")}}),e.enum("LedgerEntryChangeType",{ledgerEntryCreated:0,ledgerEntryUpdated:1,ledgerEntryRemoved:2,ledgerEntryState:3,ledgerEntryRestored:4}),e.union("LedgerEntryChange",{switchOn:e.lookup("LedgerEntryChangeType"),switchName:"type",switches:[["ledgerEntryCreated","created"],["ledgerEntryUpdated","updated"],["ledgerEntryRemoved","removed"],["ledgerEntryState","state"],["ledgerEntryRestored","restored"]],arms:{created:e.lookup("LedgerEntry"),updated:e.lookup("LedgerEntry"),removed:e.lookup("LedgerKey"),state:e.lookup("LedgerEntry"),restored:e.lookup("LedgerEntry")}}),e.typedef("LedgerEntryChanges",e.varArray(e.lookup("LedgerEntryChange"),2147483647)),e.struct("OperationMeta",[["changes",e.lookup("LedgerEntryChanges")]]),e.struct("TransactionMetaV1",[["txChanges",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)]]),e.struct("TransactionMetaV2",[["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")]]),e.enum("ContractEventType",{system:0,contract:1,diagnostic:2}),e.struct("ContractEventV0",[["topics",e.varArray(e.lookup("ScVal"),2147483647)],["data",e.lookup("ScVal")]]),e.union("ContractEventBody",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("ContractEventV0")}}),e.struct("ContractEvent",[["ext",e.lookup("ExtensionPoint")],["contractId",e.option(e.lookup("ContractId"))],["type",e.lookup("ContractEventType")],["body",e.lookup("ContractEventBody")]]),e.struct("DiagnosticEvent",[["inSuccessfulContractCall",e.bool()],["event",e.lookup("ContractEvent")]]),e.struct("SorobanTransactionMetaExtV1",[["ext",e.lookup("ExtensionPoint")],["totalNonRefundableResourceFeeCharged",e.lookup("Int64")],["totalRefundableResourceFeeCharged",e.lookup("Int64")],["rentFeeCharged",e.lookup("Int64")]]),e.union("SorobanTransactionMetaExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("SorobanTransactionMetaExtV1")}}),e.struct("SorobanTransactionMeta",[["ext",e.lookup("SorobanTransactionMetaExt")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)],["returnValue",e.lookup("ScVal")],["diagnosticEvents",e.varArray(e.lookup("DiagnosticEvent"),2147483647)]]),e.struct("TransactionMetaV3",[["ext",e.lookup("ExtensionPoint")],["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMeta"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")],["sorobanMeta",e.option(e.lookup("SorobanTransactionMeta"))]]),e.struct("OperationMetaV2",[["ext",e.lookup("ExtensionPoint")],["changes",e.lookup("LedgerEntryChanges")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)]]),e.struct("SorobanTransactionMetaV2",[["ext",e.lookup("SorobanTransactionMetaExt")],["returnValue",e.option(e.lookup("ScVal"))]]),e.enum("TransactionEventStage",{transactionEventStageBeforeAllTxes:0,transactionEventStageAfterTx:1,transactionEventStageAfterAllTxes:2}),e.struct("TransactionEvent",[["stage",e.lookup("TransactionEventStage")],["event",e.lookup("ContractEvent")]]),e.struct("TransactionMetaV4",[["ext",e.lookup("ExtensionPoint")],["txChangesBefore",e.lookup("LedgerEntryChanges")],["operations",e.varArray(e.lookup("OperationMetaV2"),2147483647)],["txChangesAfter",e.lookup("LedgerEntryChanges")],["sorobanMeta",e.option(e.lookup("SorobanTransactionMetaV2"))],["events",e.varArray(e.lookup("TransactionEvent"),2147483647)],["diagnosticEvents",e.varArray(e.lookup("DiagnosticEvent"),2147483647)]]),e.struct("InvokeHostFunctionSuccessPreImage",[["returnValue",e.lookup("ScVal")],["events",e.varArray(e.lookup("ContractEvent"),2147483647)]]),e.union("TransactionMeta",{switchOn:e.int(),switchName:"v",switches:[[0,"operations"],[1,"v1"],[2,"v2"],[3,"v3"],[4,"v4"]],arms:{operations:e.varArray(e.lookup("OperationMeta"),2147483647),v1:e.lookup("TransactionMetaV1"),v2:e.lookup("TransactionMetaV2"),v3:e.lookup("TransactionMetaV3"),v4:e.lookup("TransactionMetaV4")}}),e.struct("TransactionResultMeta",[["result",e.lookup("TransactionResultPair")],["feeProcessing",e.lookup("LedgerEntryChanges")],["txApplyProcessing",e.lookup("TransactionMeta")]]),e.struct("TransactionResultMetaV1",[["ext",e.lookup("ExtensionPoint")],["result",e.lookup("TransactionResultPair")],["feeProcessing",e.lookup("LedgerEntryChanges")],["txApplyProcessing",e.lookup("TransactionMeta")],["postTxApplyFeeProcessing",e.lookup("LedgerEntryChanges")]]),e.struct("UpgradeEntryMeta",[["upgrade",e.lookup("LedgerUpgrade")],["changes",e.lookup("LedgerEntryChanges")]]),e.struct("LedgerCloseMetaV0",[["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("TransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMeta"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)]]),e.struct("LedgerCloseMetaExtV1",[["ext",e.lookup("ExtensionPoint")],["sorobanFeeWrite1Kb",e.lookup("Int64")]]),e.union("LedgerCloseMetaExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"v1"]],arms:{v1:e.lookup("LedgerCloseMetaExtV1")}}),e.struct("LedgerCloseMetaV1",[["ext",e.lookup("LedgerCloseMetaExt")],["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("GeneralizedTransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMeta"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)],["totalByteSizeOfLiveSorobanState",e.lookup("Uint64")],["evictedKeys",e.varArray(e.lookup("LedgerKey"),2147483647)],["unused",e.varArray(e.lookup("LedgerEntry"),2147483647)]]),e.struct("LedgerCloseMetaV2",[["ext",e.lookup("LedgerCloseMetaExt")],["ledgerHeader",e.lookup("LedgerHeaderHistoryEntry")],["txSet",e.lookup("GeneralizedTransactionSet")],["txProcessing",e.varArray(e.lookup("TransactionResultMetaV1"),2147483647)],["upgradesProcessing",e.varArray(e.lookup("UpgradeEntryMeta"),2147483647)],["scpInfo",e.varArray(e.lookup("ScpHistoryEntry"),2147483647)],["totalByteSizeOfLiveSorobanState",e.lookup("Uint64")],["evictedKeys",e.varArray(e.lookup("LedgerKey"),2147483647)]]),e.union("LedgerCloseMeta",{switchOn:e.int(),switchName:"v",switches:[[0,"v0"],[1,"v1"],[2,"v2"]],arms:{v0:e.lookup("LedgerCloseMetaV0"),v1:e.lookup("LedgerCloseMetaV1"),v2:e.lookup("LedgerCloseMetaV2")}}),e.enum("ErrorCode",{errMisc:0,errData:1,errConf:2,errAuth:3,errLoad:4}),e.struct("Error",[["code",e.lookup("ErrorCode")],["msg",e.string(100)]]),e.struct("SendMore",[["numMessages",e.lookup("Uint32")]]),e.struct("SendMoreExtended",[["numMessages",e.lookup("Uint32")],["numBytes",e.lookup("Uint32")]]),e.struct("AuthCert",[["pubkey",e.lookup("Curve25519Public")],["expiration",e.lookup("Uint64")],["sig",e.lookup("Signature")]]),e.struct("Hello",[["ledgerVersion",e.lookup("Uint32")],["overlayVersion",e.lookup("Uint32")],["overlayMinVersion",e.lookup("Uint32")],["networkId",e.lookup("Hash")],["versionStr",e.string(100)],["listeningPort",e.int()],["peerId",e.lookup("NodeId")],["cert",e.lookup("AuthCert")],["nonce",e.lookup("Uint256")]]),e.const("AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED",200),e.struct("Auth",[["flags",e.int()]]),e.enum("IpAddrType",{iPv4:0,iPv6:1}),e.union("PeerAddressIp",{switchOn:e.lookup("IpAddrType"),switchName:"type",switches:[["iPv4","ipv4"],["iPv6","ipv6"]],arms:{ipv4:e.opaque(4),ipv6:e.opaque(16)}}),e.struct("PeerAddress",[["ip",e.lookup("PeerAddressIp")],["port",e.lookup("Uint32")],["numFailures",e.lookup("Uint32")]]),e.enum("MessageType",{errorMsg:0,auth:2,dontHave:3,peers:5,getTxSet:6,txSet:7,generalizedTxSet:17,transaction:8,getScpQuorumset:9,scpQuorumset:10,scpMessage:11,getScpState:12,hello:13,sendMore:16,sendMoreExtended:20,floodAdvert:18,floodDemand:19,timeSlicedSurveyRequest:21,timeSlicedSurveyResponse:22,timeSlicedSurveyStartCollecting:23,timeSlicedSurveyStopCollecting:24}),e.struct("DontHave",[["type",e.lookup("MessageType")],["reqHash",e.lookup("Uint256")]]),e.enum("SurveyMessageCommandType",{timeSlicedSurveyTopology:1}),e.enum("SurveyMessageResponseType",{surveyTopologyResponseV2:2}),e.struct("TimeSlicedSurveyStartCollectingMessage",[["surveyorId",e.lookup("NodeId")],["nonce",e.lookup("Uint32")],["ledgerNum",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyStartCollectingMessage",[["signature",e.lookup("Signature")],["startCollecting",e.lookup("TimeSlicedSurveyStartCollectingMessage")]]),e.struct("TimeSlicedSurveyStopCollectingMessage",[["surveyorId",e.lookup("NodeId")],["nonce",e.lookup("Uint32")],["ledgerNum",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyStopCollectingMessage",[["signature",e.lookup("Signature")],["stopCollecting",e.lookup("TimeSlicedSurveyStopCollectingMessage")]]),e.struct("SurveyRequestMessage",[["surveyorPeerId",e.lookup("NodeId")],["surveyedPeerId",e.lookup("NodeId")],["ledgerNum",e.lookup("Uint32")],["encryptionKey",e.lookup("Curve25519Public")],["commandType",e.lookup("SurveyMessageCommandType")]]),e.struct("TimeSlicedSurveyRequestMessage",[["request",e.lookup("SurveyRequestMessage")],["nonce",e.lookup("Uint32")],["inboundPeersIndex",e.lookup("Uint32")],["outboundPeersIndex",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyRequestMessage",[["requestSignature",e.lookup("Signature")],["request",e.lookup("TimeSlicedSurveyRequestMessage")]]),e.typedef("EncryptedBody",e.varOpaque(64e3)),e.struct("SurveyResponseMessage",[["surveyorPeerId",e.lookup("NodeId")],["surveyedPeerId",e.lookup("NodeId")],["ledgerNum",e.lookup("Uint32")],["commandType",e.lookup("SurveyMessageCommandType")],["encryptedBody",e.lookup("EncryptedBody")]]),e.struct("TimeSlicedSurveyResponseMessage",[["response",e.lookup("SurveyResponseMessage")],["nonce",e.lookup("Uint32")]]),e.struct("SignedTimeSlicedSurveyResponseMessage",[["responseSignature",e.lookup("Signature")],["response",e.lookup("TimeSlicedSurveyResponseMessage")]]),e.struct("PeerStats",[["id",e.lookup("NodeId")],["versionStr",e.string(100)],["messagesRead",e.lookup("Uint64")],["messagesWritten",e.lookup("Uint64")],["bytesRead",e.lookup("Uint64")],["bytesWritten",e.lookup("Uint64")],["secondsConnected",e.lookup("Uint64")],["uniqueFloodBytesRecv",e.lookup("Uint64")],["duplicateFloodBytesRecv",e.lookup("Uint64")],["uniqueFetchBytesRecv",e.lookup("Uint64")],["duplicateFetchBytesRecv",e.lookup("Uint64")],["uniqueFloodMessageRecv",e.lookup("Uint64")],["duplicateFloodMessageRecv",e.lookup("Uint64")],["uniqueFetchMessageRecv",e.lookup("Uint64")],["duplicateFetchMessageRecv",e.lookup("Uint64")]]),e.struct("TimeSlicedNodeData",[["addedAuthenticatedPeers",e.lookup("Uint32")],["droppedAuthenticatedPeers",e.lookup("Uint32")],["totalInboundPeerCount",e.lookup("Uint32")],["totalOutboundPeerCount",e.lookup("Uint32")],["p75ScpFirstToSelfLatencyMs",e.lookup("Uint32")],["p75ScpSelfToOtherLatencyMs",e.lookup("Uint32")],["lostSyncCount",e.lookup("Uint32")],["isValidator",e.bool()],["maxInboundPeerCount",e.lookup("Uint32")],["maxOutboundPeerCount",e.lookup("Uint32")]]),e.struct("TimeSlicedPeerData",[["peerStats",e.lookup("PeerStats")],["averageLatencyMs",e.lookup("Uint32")]]),e.typedef("TimeSlicedPeerDataList",e.varArray(e.lookup("TimeSlicedPeerData"),25)),e.struct("TopologyResponseBodyV2",[["inboundPeers",e.lookup("TimeSlicedPeerDataList")],["outboundPeers",e.lookup("TimeSlicedPeerDataList")],["nodeData",e.lookup("TimeSlicedNodeData")]]),e.union("SurveyResponseBody",{switchOn:e.lookup("SurveyMessageResponseType"),switchName:"type",switches:[["surveyTopologyResponseV2","topologyResponseBodyV2"]],arms:{topologyResponseBodyV2:e.lookup("TopologyResponseBodyV2")}}),e.const("TX_ADVERT_VECTOR_MAX_SIZE",1e3),e.typedef("TxAdvertVector",e.varArray(e.lookup("Hash"),e.lookup("TX_ADVERT_VECTOR_MAX_SIZE"))),e.struct("FloodAdvert",[["txHashes",e.lookup("TxAdvertVector")]]),e.const("TX_DEMAND_VECTOR_MAX_SIZE",1e3),e.typedef("TxDemandVector",e.varArray(e.lookup("Hash"),e.lookup("TX_DEMAND_VECTOR_MAX_SIZE"))),e.struct("FloodDemand",[["txHashes",e.lookup("TxDemandVector")]]),e.union("StellarMessage",{switchOn:e.lookup("MessageType"),switchName:"type",switches:[["errorMsg","error"],["hello","hello"],["auth","auth"],["dontHave","dontHave"],["peers","peers"],["getTxSet","txSetHash"],["txSet","txSet"],["generalizedTxSet","generalizedTxSet"],["transaction","transaction"],["timeSlicedSurveyRequest","signedTimeSlicedSurveyRequestMessage"],["timeSlicedSurveyResponse","signedTimeSlicedSurveyResponseMessage"],["timeSlicedSurveyStartCollecting","signedTimeSlicedSurveyStartCollectingMessage"],["timeSlicedSurveyStopCollecting","signedTimeSlicedSurveyStopCollectingMessage"],["getScpQuorumset","qSetHash"],["scpQuorumset","qSet"],["scpMessage","envelope"],["getScpState","getScpLedgerSeq"],["sendMore","sendMoreMessage"],["sendMoreExtended","sendMoreExtendedMessage"],["floodAdvert","floodAdvert"],["floodDemand","floodDemand"]],arms:{error:e.lookup("Error"),hello:e.lookup("Hello"),auth:e.lookup("Auth"),dontHave:e.lookup("DontHave"),peers:e.varArray(e.lookup("PeerAddress"),100),txSetHash:e.lookup("Uint256"),txSet:e.lookup("TransactionSet"),generalizedTxSet:e.lookup("GeneralizedTransactionSet"),transaction:e.lookup("TransactionEnvelope"),signedTimeSlicedSurveyRequestMessage:e.lookup("SignedTimeSlicedSurveyRequestMessage"),signedTimeSlicedSurveyResponseMessage:e.lookup("SignedTimeSlicedSurveyResponseMessage"),signedTimeSlicedSurveyStartCollectingMessage:e.lookup("SignedTimeSlicedSurveyStartCollectingMessage"),signedTimeSlicedSurveyStopCollectingMessage:e.lookup("SignedTimeSlicedSurveyStopCollectingMessage"),qSetHash:e.lookup("Uint256"),qSet:e.lookup("ScpQuorumSet"),envelope:e.lookup("ScpEnvelope"),getScpLedgerSeq:e.lookup("Uint32"),sendMoreMessage:e.lookup("SendMore"),sendMoreExtendedMessage:e.lookup("SendMoreExtended"),floodAdvert:e.lookup("FloodAdvert"),floodDemand:e.lookup("FloodDemand")}}),e.struct("AuthenticatedMessageV0",[["sequence",e.lookup("Uint64")],["message",e.lookup("StellarMessage")],["mac",e.lookup("HmacSha256Mac")]]),e.union("AuthenticatedMessage",{switchOn:e.lookup("Uint32"),switchName:"v",switches:[[0,"v0"]],arms:{v0:e.lookup("AuthenticatedMessageV0")}}),e.const("MAX_OPS_PER_TX",100),e.union("LiquidityPoolParameters",{switchOn:e.lookup("LiquidityPoolType"),switchName:"type",switches:[["liquidityPoolConstantProduct","constantProduct"]],arms:{constantProduct:e.lookup("LiquidityPoolConstantProductParameters")}}),e.struct("MuxedAccountMed25519",[["id",e.lookup("Uint64")],["ed25519",e.lookup("Uint256")]]),e.union("MuxedAccount",{switchOn:e.lookup("CryptoKeyType"),switchName:"type",switches:[["keyTypeEd25519","ed25519"],["keyTypeMuxedEd25519","med25519"]],arms:{ed25519:e.lookup("Uint256"),med25519:e.lookup("MuxedAccountMed25519")}}),e.struct("DecoratedSignature",[["hint",e.lookup("SignatureHint")],["signature",e.lookup("Signature")]]),e.enum("OperationType",{createAccount:0,payment:1,pathPaymentStrictReceive:2,manageSellOffer:3,createPassiveSellOffer:4,setOptions:5,changeTrust:6,allowTrust:7,accountMerge:8,inflation:9,manageData:10,bumpSequence:11,manageBuyOffer:12,pathPaymentStrictSend:13,createClaimableBalance:14,claimClaimableBalance:15,beginSponsoringFutureReserves:16,endSponsoringFutureReserves:17,revokeSponsorship:18,clawback:19,clawbackClaimableBalance:20,setTrustLineFlags:21,liquidityPoolDeposit:22,liquidityPoolWithdraw:23,invokeHostFunction:24,extendFootprintTtl:25,restoreFootprint:26}),e.struct("CreateAccountOp",[["destination",e.lookup("AccountId")],["startingBalance",e.lookup("Int64")]]),e.struct("PaymentOp",[["destination",e.lookup("MuxedAccount")],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")]]),e.struct("PathPaymentStrictReceiveOp",[["sendAsset",e.lookup("Asset")],["sendMax",e.lookup("Int64")],["destination",e.lookup("MuxedAccount")],["destAsset",e.lookup("Asset")],["destAmount",e.lookup("Int64")],["path",e.varArray(e.lookup("Asset"),5)]]),e.struct("PathPaymentStrictSendOp",[["sendAsset",e.lookup("Asset")],["sendAmount",e.lookup("Int64")],["destination",e.lookup("MuxedAccount")],["destAsset",e.lookup("Asset")],["destMin",e.lookup("Int64")],["path",e.varArray(e.lookup("Asset"),5)]]),e.struct("ManageSellOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")],["offerId",e.lookup("Int64")]]),e.struct("ManageBuyOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["buyAmount",e.lookup("Int64")],["price",e.lookup("Price")],["offerId",e.lookup("Int64")]]),e.struct("CreatePassiveSellOfferOp",[["selling",e.lookup("Asset")],["buying",e.lookup("Asset")],["amount",e.lookup("Int64")],["price",e.lookup("Price")]]),e.struct("SetOptionsOp",[["inflationDest",e.option(e.lookup("AccountId"))],["clearFlags",e.option(e.lookup("Uint32"))],["setFlags",e.option(e.lookup("Uint32"))],["masterWeight",e.option(e.lookup("Uint32"))],["lowThreshold",e.option(e.lookup("Uint32"))],["medThreshold",e.option(e.lookup("Uint32"))],["highThreshold",e.option(e.lookup("Uint32"))],["homeDomain",e.option(e.lookup("String32"))],["signer",e.option(e.lookup("Signer"))]]),e.union("ChangeTrustAsset",{switchOn:e.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",e.void()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"],["assetTypePoolShare","liquidityPool"]],arms:{alphaNum4:e.lookup("AlphaNum4"),alphaNum12:e.lookup("AlphaNum12"),liquidityPool:e.lookup("LiquidityPoolParameters")}}),e.struct("ChangeTrustOp",[["line",e.lookup("ChangeTrustAsset")],["limit",e.lookup("Int64")]]),e.struct("AllowTrustOp",[["trustor",e.lookup("AccountId")],["asset",e.lookup("AssetCode")],["authorize",e.lookup("Uint32")]]),e.struct("ManageDataOp",[["dataName",e.lookup("String64")],["dataValue",e.option(e.lookup("DataValue"))]]),e.struct("BumpSequenceOp",[["bumpTo",e.lookup("SequenceNumber")]]),e.struct("CreateClaimableBalanceOp",[["asset",e.lookup("Asset")],["amount",e.lookup("Int64")],["claimants",e.varArray(e.lookup("Claimant"),10)]]),e.struct("ClaimClaimableBalanceOp",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("BeginSponsoringFutureReservesOp",[["sponsoredId",e.lookup("AccountId")]]),e.enum("RevokeSponsorshipType",{revokeSponsorshipLedgerEntry:0,revokeSponsorshipSigner:1}),e.struct("RevokeSponsorshipOpSigner",[["accountId",e.lookup("AccountId")],["signerKey",e.lookup("SignerKey")]]),e.union("RevokeSponsorshipOp",{switchOn:e.lookup("RevokeSponsorshipType"),switchName:"type",switches:[["revokeSponsorshipLedgerEntry","ledgerKey"],["revokeSponsorshipSigner","signer"]],arms:{ledgerKey:e.lookup("LedgerKey"),signer:e.lookup("RevokeSponsorshipOpSigner")}}),e.struct("ClawbackOp",[["asset",e.lookup("Asset")],["from",e.lookup("MuxedAccount")],["amount",e.lookup("Int64")]]),e.struct("ClawbackClaimableBalanceOp",[["balanceId",e.lookup("ClaimableBalanceId")]]),e.struct("SetTrustLineFlagsOp",[["trustor",e.lookup("AccountId")],["asset",e.lookup("Asset")],["clearFlags",e.lookup("Uint32")],["setFlags",e.lookup("Uint32")]]),e.const("LIQUIDITY_POOL_FEE_V18",30),e.struct("LiquidityPoolDepositOp",[["liquidityPoolId",e.lookup("PoolId")],["maxAmountA",e.lookup("Int64")],["maxAmountB",e.lookup("Int64")],["minPrice",e.lookup("Price")],["maxPrice",e.lookup("Price")]]),e.struct("LiquidityPoolWithdrawOp",[["liquidityPoolId",e.lookup("PoolId")],["amount",e.lookup("Int64")],["minAmountA",e.lookup("Int64")],["minAmountB",e.lookup("Int64")]]),e.enum("HostFunctionType",{hostFunctionTypeInvokeContract:0,hostFunctionTypeCreateContract:1,hostFunctionTypeUploadContractWasm:2,hostFunctionTypeCreateContractV2:3}),e.enum("ContractIdPreimageType",{contractIdPreimageFromAddress:0,contractIdPreimageFromAsset:1}),e.struct("ContractIdPreimageFromAddress",[["address",e.lookup("ScAddress")],["salt",e.lookup("Uint256")]]),e.union("ContractIdPreimage",{switchOn:e.lookup("ContractIdPreimageType"),switchName:"type",switches:[["contractIdPreimageFromAddress","fromAddress"],["contractIdPreimageFromAsset","fromAsset"]],arms:{fromAddress:e.lookup("ContractIdPreimageFromAddress"),fromAsset:e.lookup("Asset")}}),e.struct("CreateContractArgs",[["contractIdPreimage",e.lookup("ContractIdPreimage")],["executable",e.lookup("ContractExecutable")]]),e.struct("CreateContractArgsV2",[["contractIdPreimage",e.lookup("ContractIdPreimage")],["executable",e.lookup("ContractExecutable")],["constructorArgs",e.varArray(e.lookup("ScVal"),2147483647)]]),e.struct("InvokeContractArgs",[["contractAddress",e.lookup("ScAddress")],["functionName",e.lookup("ScSymbol")],["args",e.varArray(e.lookup("ScVal"),2147483647)]]),e.union("HostFunction",{switchOn:e.lookup("HostFunctionType"),switchName:"type",switches:[["hostFunctionTypeInvokeContract","invokeContract"],["hostFunctionTypeCreateContract","createContract"],["hostFunctionTypeUploadContractWasm","wasm"],["hostFunctionTypeCreateContractV2","createContractV2"]],arms:{invokeContract:e.lookup("InvokeContractArgs"),createContract:e.lookup("CreateContractArgs"),wasm:e.varOpaque(),createContractV2:e.lookup("CreateContractArgsV2")}}),e.enum("SorobanAuthorizedFunctionType",{sorobanAuthorizedFunctionTypeContractFn:0,sorobanAuthorizedFunctionTypeCreateContractHostFn:1,sorobanAuthorizedFunctionTypeCreateContractV2HostFn:2}),e.union("SorobanAuthorizedFunction",{switchOn:e.lookup("SorobanAuthorizedFunctionType"),switchName:"type",switches:[["sorobanAuthorizedFunctionTypeContractFn","contractFn"],["sorobanAuthorizedFunctionTypeCreateContractHostFn","createContractHostFn"],["sorobanAuthorizedFunctionTypeCreateContractV2HostFn","createContractV2HostFn"]],arms:{contractFn:e.lookup("InvokeContractArgs"),createContractHostFn:e.lookup("CreateContractArgs"),createContractV2HostFn:e.lookup("CreateContractArgsV2")}}),e.struct("SorobanAuthorizedInvocation",[["function",e.lookup("SorobanAuthorizedFunction")],["subInvocations",e.varArray(e.lookup("SorobanAuthorizedInvocation"),2147483647)]]),e.struct("SorobanAddressCredentials",[["address",e.lookup("ScAddress")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["signature",e.lookup("ScVal")]]),e.struct("SorobanDelegateSignature",[["address",e.lookup("ScAddress")],["signature",e.lookup("ScVal")],["nestedDelegates",e.varArray(e.lookup("SorobanDelegateSignature"),2147483647)]]),e.struct("SorobanAddressCredentialsWithDelegates",[["addressCredentials",e.lookup("SorobanAddressCredentials")],["delegates",e.varArray(e.lookup("SorobanDelegateSignature"),2147483647)]]),e.enum("SorobanCredentialsType",{sorobanCredentialsSourceAccount:0,sorobanCredentialsAddress:1,sorobanCredentialsAddressV2:2,sorobanCredentialsAddressWithDelegates:3}),e.union("SorobanCredentials",{switchOn:e.lookup("SorobanCredentialsType"),switchName:"type",switches:[["sorobanCredentialsSourceAccount",e.void()],["sorobanCredentialsAddress","address"],["sorobanCredentialsAddressV2","addressV2"],["sorobanCredentialsAddressWithDelegates","addressWithDelegates"]],arms:{address:e.lookup("SorobanAddressCredentials"),addressV2:e.lookup("SorobanAddressCredentials"),addressWithDelegates:e.lookup("SorobanAddressCredentialsWithDelegates")}}),e.struct("SorobanAuthorizationEntry",[["credentials",e.lookup("SorobanCredentials")],["rootInvocation",e.lookup("SorobanAuthorizedInvocation")]]),e.typedef("SorobanAuthorizationEntries",e.varArray(e.lookup("SorobanAuthorizationEntry"),2147483647)),e.struct("InvokeHostFunctionOp",[["hostFunction",e.lookup("HostFunction")],["auth",e.varArray(e.lookup("SorobanAuthorizationEntry"),2147483647)]]),e.struct("ExtendFootprintTtlOp",[["ext",e.lookup("ExtensionPoint")],["extendTo",e.lookup("Uint32")]]),e.struct("RestoreFootprintOp",[["ext",e.lookup("ExtensionPoint")]]),e.union("OperationBody",{switchOn:e.lookup("OperationType"),switchName:"type",switches:[["createAccount","createAccountOp"],["payment","paymentOp"],["pathPaymentStrictReceive","pathPaymentStrictReceiveOp"],["manageSellOffer","manageSellOfferOp"],["createPassiveSellOffer","createPassiveSellOfferOp"],["setOptions","setOptionsOp"],["changeTrust","changeTrustOp"],["allowTrust","allowTrustOp"],["accountMerge","destination"],["inflation",e.void()],["manageData","manageDataOp"],["bumpSequence","bumpSequenceOp"],["manageBuyOffer","manageBuyOfferOp"],["pathPaymentStrictSend","pathPaymentStrictSendOp"],["createClaimableBalance","createClaimableBalanceOp"],["claimClaimableBalance","claimClaimableBalanceOp"],["beginSponsoringFutureReserves","beginSponsoringFutureReservesOp"],["endSponsoringFutureReserves",e.void()],["revokeSponsorship","revokeSponsorshipOp"],["clawback","clawbackOp"],["clawbackClaimableBalance","clawbackClaimableBalanceOp"],["setTrustLineFlags","setTrustLineFlagsOp"],["liquidityPoolDeposit","liquidityPoolDepositOp"],["liquidityPoolWithdraw","liquidityPoolWithdrawOp"],["invokeHostFunction","invokeHostFunctionOp"],["extendFootprintTtl","extendFootprintTtlOp"],["restoreFootprint","restoreFootprintOp"]],arms:{createAccountOp:e.lookup("CreateAccountOp"),paymentOp:e.lookup("PaymentOp"),pathPaymentStrictReceiveOp:e.lookup("PathPaymentStrictReceiveOp"),manageSellOfferOp:e.lookup("ManageSellOfferOp"),createPassiveSellOfferOp:e.lookup("CreatePassiveSellOfferOp"),setOptionsOp:e.lookup("SetOptionsOp"),changeTrustOp:e.lookup("ChangeTrustOp"),allowTrustOp:e.lookup("AllowTrustOp"),destination:e.lookup("MuxedAccount"),manageDataOp:e.lookup("ManageDataOp"),bumpSequenceOp:e.lookup("BumpSequenceOp"),manageBuyOfferOp:e.lookup("ManageBuyOfferOp"),pathPaymentStrictSendOp:e.lookup("PathPaymentStrictSendOp"),createClaimableBalanceOp:e.lookup("CreateClaimableBalanceOp"),claimClaimableBalanceOp:e.lookup("ClaimClaimableBalanceOp"),beginSponsoringFutureReservesOp:e.lookup("BeginSponsoringFutureReservesOp"),revokeSponsorshipOp:e.lookup("RevokeSponsorshipOp"),clawbackOp:e.lookup("ClawbackOp"),clawbackClaimableBalanceOp:e.lookup("ClawbackClaimableBalanceOp"),setTrustLineFlagsOp:e.lookup("SetTrustLineFlagsOp"),liquidityPoolDepositOp:e.lookup("LiquidityPoolDepositOp"),liquidityPoolWithdrawOp:e.lookup("LiquidityPoolWithdrawOp"),invokeHostFunctionOp:e.lookup("InvokeHostFunctionOp"),extendFootprintTtlOp:e.lookup("ExtendFootprintTtlOp"),restoreFootprintOp:e.lookup("RestoreFootprintOp")}}),e.struct("Operation",[["sourceAccount",e.option(e.lookup("MuxedAccount"))],["body",e.lookup("OperationBody")]]),e.struct("HashIdPreimageOperationId",[["sourceAccount",e.lookup("AccountId")],["seqNum",e.lookup("SequenceNumber")],["opNum",e.lookup("Uint32")]]),e.struct("HashIdPreimageRevokeId",[["sourceAccount",e.lookup("AccountId")],["seqNum",e.lookup("SequenceNumber")],["opNum",e.lookup("Uint32")],["liquidityPoolId",e.lookup("PoolId")],["asset",e.lookup("Asset")]]),e.struct("HashIdPreimageContractId",[["networkId",e.lookup("Hash")],["contractIdPreimage",e.lookup("ContractIdPreimage")]]),e.struct("HashIdPreimageSorobanAuthorization",[["networkId",e.lookup("Hash")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["invocation",e.lookup("SorobanAuthorizedInvocation")]]),e.struct("HashIdPreimageSorobanAuthorizationWithAddress",[["networkId",e.lookup("Hash")],["nonce",e.lookup("Int64")],["signatureExpirationLedger",e.lookup("Uint32")],["address",e.lookup("ScAddress")],["invocation",e.lookup("SorobanAuthorizedInvocation")]]),e.union("HashIdPreimage",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeOpId","operationId"],["envelopeTypePoolRevokeOpId","revokeId"],["envelopeTypeContractId","contractId"],["envelopeTypeSorobanAuthorization","sorobanAuthorization"],["envelopeTypeSorobanAuthorizationWithAddress","sorobanAuthorizationWithAddress"]],arms:{operationId:e.lookup("HashIdPreimageOperationId"),revokeId:e.lookup("HashIdPreimageRevokeId"),contractId:e.lookup("HashIdPreimageContractId"),sorobanAuthorization:e.lookup("HashIdPreimageSorobanAuthorization"),sorobanAuthorizationWithAddress:e.lookup("HashIdPreimageSorobanAuthorizationWithAddress")}}),e.enum("MemoType",{memoNone:0,memoText:1,memoId:2,memoHash:3,memoReturn:4}),e.union("Memo",{switchOn:e.lookup("MemoType"),switchName:"type",switches:[["memoNone",e.void()],["memoText","text"],["memoId","id"],["memoHash","hash"],["memoReturn","retHash"]],arms:{text:e.string(28),id:e.lookup("Uint64"),hash:e.lookup("Hash"),retHash:e.lookup("Hash")}}),e.struct("TimeBounds",[["minTime",e.lookup("TimePoint")],["maxTime",e.lookup("TimePoint")]]),e.struct("LedgerBounds",[["minLedger",e.lookup("Uint32")],["maxLedger",e.lookup("Uint32")]]),e.struct("PreconditionsV2",[["timeBounds",e.option(e.lookup("TimeBounds"))],["ledgerBounds",e.option(e.lookup("LedgerBounds"))],["minSeqNum",e.option(e.lookup("SequenceNumber"))],["minSeqAge",e.lookup("Duration")],["minSeqLedgerGap",e.lookup("Uint32")],["extraSigners",e.varArray(e.lookup("SignerKey"),2)]]),e.enum("PreconditionType",{precondNone:0,precondTime:1,precondV2:2}),e.union("Preconditions",{switchOn:e.lookup("PreconditionType"),switchName:"type",switches:[["precondNone",e.void()],["precondTime","timeBounds"],["precondV2","v2"]],arms:{timeBounds:e.lookup("TimeBounds"),v2:e.lookup("PreconditionsV2")}}),e.struct("LedgerFootprint",[["readOnly",e.varArray(e.lookup("LedgerKey"),2147483647)],["readWrite",e.varArray(e.lookup("LedgerKey"),2147483647)]]),e.struct("SorobanResources",[["footprint",e.lookup("LedgerFootprint")],["instructions",e.lookup("Uint32")],["diskReadBytes",e.lookup("Uint32")],["writeBytes",e.lookup("Uint32")]]),e.struct("SorobanResourcesExtV0",[["archivedSorobanEntries",e.varArray(e.lookup("Uint32"),2147483647)]]),e.union("SorobanTransactionDataExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"resourceExt"]],arms:{resourceExt:e.lookup("SorobanResourcesExtV0")}}),e.struct("SorobanTransactionData",[["ext",e.lookup("SorobanTransactionDataExt")],["resources",e.lookup("SorobanResources")],["resourceFee",e.lookup("Int64")]]),e.union("TransactionV0Ext",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionV0",[["sourceAccountEd25519",e.lookup("Uint256")],["fee",e.lookup("Uint32")],["seqNum",e.lookup("SequenceNumber")],["timeBounds",e.option(e.lookup("TimeBounds"))],["memo",e.lookup("Memo")],["operations",e.varArray(e.lookup("Operation"),e.lookup("MAX_OPS_PER_TX"))],["ext",e.lookup("TransactionV0Ext")]]),e.struct("TransactionV0Envelope",[["tx",e.lookup("TransactionV0")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("TransactionExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()],[1,"sorobanData"]],arms:{sorobanData:e.lookup("SorobanTransactionData")}}),e.struct("Transaction",[["sourceAccount",e.lookup("MuxedAccount")],["fee",e.lookup("Uint32")],["seqNum",e.lookup("SequenceNumber")],["cond",e.lookup("Preconditions")],["memo",e.lookup("Memo")],["operations",e.varArray(e.lookup("Operation"),e.lookup("MAX_OPS_PER_TX"))],["ext",e.lookup("TransactionExt")]]),e.struct("TransactionV1Envelope",[["tx",e.lookup("Transaction")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("FeeBumpTransactionInnerTx",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTx","v1"]],arms:{v1:e.lookup("TransactionV1Envelope")}}),e.union("FeeBumpTransactionExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("FeeBumpTransaction",[["feeSource",e.lookup("MuxedAccount")],["fee",e.lookup("Int64")],["innerTx",e.lookup("FeeBumpTransactionInnerTx")],["ext",e.lookup("FeeBumpTransactionExt")]]),e.struct("FeeBumpTransactionEnvelope",[["tx",e.lookup("FeeBumpTransaction")],["signatures",e.varArray(e.lookup("DecoratedSignature"),20)]]),e.union("TransactionEnvelope",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTxV0","v0"],["envelopeTypeTx","v1"],["envelopeTypeTxFeeBump","feeBump"]],arms:{v0:e.lookup("TransactionV0Envelope"),v1:e.lookup("TransactionV1Envelope"),feeBump:e.lookup("FeeBumpTransactionEnvelope")}}),e.union("TransactionSignaturePayloadTaggedTransaction",{switchOn:e.lookup("EnvelopeType"),switchName:"type",switches:[["envelopeTypeTx","tx"],["envelopeTypeTxFeeBump","feeBump"]],arms:{tx:e.lookup("Transaction"),feeBump:e.lookup("FeeBumpTransaction")}}),e.struct("TransactionSignaturePayload",[["networkId",e.lookup("Hash")],["taggedTransaction",e.lookup("TransactionSignaturePayloadTaggedTransaction")]]),e.enum("ClaimAtomType",{claimAtomTypeV0:0,claimAtomTypeOrderBook:1,claimAtomTypeLiquidityPool:2}),e.struct("ClaimOfferAtomV0",[["sellerEd25519",e.lookup("Uint256")],["offerId",e.lookup("Int64")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.struct("ClaimOfferAtom",[["sellerId",e.lookup("AccountId")],["offerId",e.lookup("Int64")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.struct("ClaimLiquidityAtom",[["liquidityPoolId",e.lookup("PoolId")],["assetSold",e.lookup("Asset")],["amountSold",e.lookup("Int64")],["assetBought",e.lookup("Asset")],["amountBought",e.lookup("Int64")]]),e.union("ClaimAtom",{switchOn:e.lookup("ClaimAtomType"),switchName:"type",switches:[["claimAtomTypeV0","v0"],["claimAtomTypeOrderBook","orderBook"],["claimAtomTypeLiquidityPool","liquidityPool"]],arms:{v0:e.lookup("ClaimOfferAtomV0"),orderBook:e.lookup("ClaimOfferAtom"),liquidityPool:e.lookup("ClaimLiquidityAtom")}}),e.enum("CreateAccountResultCode",{createAccountSuccess:0,createAccountMalformed:-1,createAccountUnderfunded:-2,createAccountLowReserve:-3,createAccountAlreadyExist:-4}),e.union("CreateAccountResult",{switchOn:e.lookup("CreateAccountResultCode"),switchName:"code",switches:[["createAccountSuccess",e.void()],["createAccountMalformed",e.void()],["createAccountUnderfunded",e.void()],["createAccountLowReserve",e.void()],["createAccountAlreadyExist",e.void()]],arms:{}}),e.enum("PaymentResultCode",{paymentSuccess:0,paymentMalformed:-1,paymentUnderfunded:-2,paymentSrcNoTrust:-3,paymentSrcNotAuthorized:-4,paymentNoDestination:-5,paymentNoTrust:-6,paymentNotAuthorized:-7,paymentLineFull:-8,paymentNoIssuer:-9}),e.union("PaymentResult",{switchOn:e.lookup("PaymentResultCode"),switchName:"code",switches:[["paymentSuccess",e.void()],["paymentMalformed",e.void()],["paymentUnderfunded",e.void()],["paymentSrcNoTrust",e.void()],["paymentSrcNotAuthorized",e.void()],["paymentNoDestination",e.void()],["paymentNoTrust",e.void()],["paymentNotAuthorized",e.void()],["paymentLineFull",e.void()],["paymentNoIssuer",e.void()]],arms:{}}),e.enum("PathPaymentStrictReceiveResultCode",{pathPaymentStrictReceiveSuccess:0,pathPaymentStrictReceiveMalformed:-1,pathPaymentStrictReceiveUnderfunded:-2,pathPaymentStrictReceiveSrcNoTrust:-3,pathPaymentStrictReceiveSrcNotAuthorized:-4,pathPaymentStrictReceiveNoDestination:-5,pathPaymentStrictReceiveNoTrust:-6,pathPaymentStrictReceiveNotAuthorized:-7,pathPaymentStrictReceiveLineFull:-8,pathPaymentStrictReceiveNoIssuer:-9,pathPaymentStrictReceiveTooFewOffers:-10,pathPaymentStrictReceiveOfferCrossSelf:-11,pathPaymentStrictReceiveOverSendmax:-12}),e.struct("SimplePaymentResult",[["destination",e.lookup("AccountId")],["asset",e.lookup("Asset")],["amount",e.lookup("Int64")]]),e.struct("PathPaymentStrictReceiveResultSuccess",[["offers",e.varArray(e.lookup("ClaimAtom"),2147483647)],["last",e.lookup("SimplePaymentResult")]]),e.union("PathPaymentStrictReceiveResult",{switchOn:e.lookup("PathPaymentStrictReceiveResultCode"),switchName:"code",switches:[["pathPaymentStrictReceiveSuccess","success"],["pathPaymentStrictReceiveMalformed",e.void()],["pathPaymentStrictReceiveUnderfunded",e.void()],["pathPaymentStrictReceiveSrcNoTrust",e.void()],["pathPaymentStrictReceiveSrcNotAuthorized",e.void()],["pathPaymentStrictReceiveNoDestination",e.void()],["pathPaymentStrictReceiveNoTrust",e.void()],["pathPaymentStrictReceiveNotAuthorized",e.void()],["pathPaymentStrictReceiveLineFull",e.void()],["pathPaymentStrictReceiveNoIssuer","noIssuer"],["pathPaymentStrictReceiveTooFewOffers",e.void()],["pathPaymentStrictReceiveOfferCrossSelf",e.void()],["pathPaymentStrictReceiveOverSendmax",e.void()]],arms:{success:e.lookup("PathPaymentStrictReceiveResultSuccess"),noIssuer:e.lookup("Asset")}}),e.enum("PathPaymentStrictSendResultCode",{pathPaymentStrictSendSuccess:0,pathPaymentStrictSendMalformed:-1,pathPaymentStrictSendUnderfunded:-2,pathPaymentStrictSendSrcNoTrust:-3,pathPaymentStrictSendSrcNotAuthorized:-4,pathPaymentStrictSendNoDestination:-5,pathPaymentStrictSendNoTrust:-6,pathPaymentStrictSendNotAuthorized:-7,pathPaymentStrictSendLineFull:-8,pathPaymentStrictSendNoIssuer:-9,pathPaymentStrictSendTooFewOffers:-10,pathPaymentStrictSendOfferCrossSelf:-11,pathPaymentStrictSendUnderDestmin:-12}),e.struct("PathPaymentStrictSendResultSuccess",[["offers",e.varArray(e.lookup("ClaimAtom"),2147483647)],["last",e.lookup("SimplePaymentResult")]]),e.union("PathPaymentStrictSendResult",{switchOn:e.lookup("PathPaymentStrictSendResultCode"),switchName:"code",switches:[["pathPaymentStrictSendSuccess","success"],["pathPaymentStrictSendMalformed",e.void()],["pathPaymentStrictSendUnderfunded",e.void()],["pathPaymentStrictSendSrcNoTrust",e.void()],["pathPaymentStrictSendSrcNotAuthorized",e.void()],["pathPaymentStrictSendNoDestination",e.void()],["pathPaymentStrictSendNoTrust",e.void()],["pathPaymentStrictSendNotAuthorized",e.void()],["pathPaymentStrictSendLineFull",e.void()],["pathPaymentStrictSendNoIssuer","noIssuer"],["pathPaymentStrictSendTooFewOffers",e.void()],["pathPaymentStrictSendOfferCrossSelf",e.void()],["pathPaymentStrictSendUnderDestmin",e.void()]],arms:{success:e.lookup("PathPaymentStrictSendResultSuccess"),noIssuer:e.lookup("Asset")}}),e.enum("ManageSellOfferResultCode",{manageSellOfferSuccess:0,manageSellOfferMalformed:-1,manageSellOfferSellNoTrust:-2,manageSellOfferBuyNoTrust:-3,manageSellOfferSellNotAuthorized:-4,manageSellOfferBuyNotAuthorized:-5,manageSellOfferLineFull:-6,manageSellOfferUnderfunded:-7,manageSellOfferCrossSelf:-8,manageSellOfferSellNoIssuer:-9,manageSellOfferBuyNoIssuer:-10,manageSellOfferNotFound:-11,manageSellOfferLowReserve:-12}),e.enum("ManageOfferEffect",{manageOfferCreated:0,manageOfferUpdated:1,manageOfferDeleted:2}),e.union("ManageOfferSuccessResultOffer",{switchOn:e.lookup("ManageOfferEffect"),switchName:"effect",switches:[["manageOfferCreated","offer"],["manageOfferUpdated","offer"],["manageOfferDeleted",e.void()]],arms:{offer:e.lookup("OfferEntry")}}),e.struct("ManageOfferSuccessResult",[["offersClaimed",e.varArray(e.lookup("ClaimAtom"),2147483647)],["offer",e.lookup("ManageOfferSuccessResultOffer")]]),e.union("ManageSellOfferResult",{switchOn:e.lookup("ManageSellOfferResultCode"),switchName:"code",switches:[["manageSellOfferSuccess","success"],["manageSellOfferMalformed",e.void()],["manageSellOfferSellNoTrust",e.void()],["manageSellOfferBuyNoTrust",e.void()],["manageSellOfferSellNotAuthorized",e.void()],["manageSellOfferBuyNotAuthorized",e.void()],["manageSellOfferLineFull",e.void()],["manageSellOfferUnderfunded",e.void()],["manageSellOfferCrossSelf",e.void()],["manageSellOfferSellNoIssuer",e.void()],["manageSellOfferBuyNoIssuer",e.void()],["manageSellOfferNotFound",e.void()],["manageSellOfferLowReserve",e.void()]],arms:{success:e.lookup("ManageOfferSuccessResult")}}),e.enum("ManageBuyOfferResultCode",{manageBuyOfferSuccess:0,manageBuyOfferMalformed:-1,manageBuyOfferSellNoTrust:-2,manageBuyOfferBuyNoTrust:-3,manageBuyOfferSellNotAuthorized:-4,manageBuyOfferBuyNotAuthorized:-5,manageBuyOfferLineFull:-6,manageBuyOfferUnderfunded:-7,manageBuyOfferCrossSelf:-8,manageBuyOfferSellNoIssuer:-9,manageBuyOfferBuyNoIssuer:-10,manageBuyOfferNotFound:-11,manageBuyOfferLowReserve:-12}),e.union("ManageBuyOfferResult",{switchOn:e.lookup("ManageBuyOfferResultCode"),switchName:"code",switches:[["manageBuyOfferSuccess","success"],["manageBuyOfferMalformed",e.void()],["manageBuyOfferSellNoTrust",e.void()],["manageBuyOfferBuyNoTrust",e.void()],["manageBuyOfferSellNotAuthorized",e.void()],["manageBuyOfferBuyNotAuthorized",e.void()],["manageBuyOfferLineFull",e.void()],["manageBuyOfferUnderfunded",e.void()],["manageBuyOfferCrossSelf",e.void()],["manageBuyOfferSellNoIssuer",e.void()],["manageBuyOfferBuyNoIssuer",e.void()],["manageBuyOfferNotFound",e.void()],["manageBuyOfferLowReserve",e.void()]],arms:{success:e.lookup("ManageOfferSuccessResult")}}),e.enum("SetOptionsResultCode",{setOptionsSuccess:0,setOptionsLowReserve:-1,setOptionsTooManySigners:-2,setOptionsBadFlags:-3,setOptionsInvalidInflation:-4,setOptionsCantChange:-5,setOptionsUnknownFlag:-6,setOptionsThresholdOutOfRange:-7,setOptionsBadSigner:-8,setOptionsInvalidHomeDomain:-9,setOptionsAuthRevocableRequired:-10}),e.union("SetOptionsResult",{switchOn:e.lookup("SetOptionsResultCode"),switchName:"code",switches:[["setOptionsSuccess",e.void()],["setOptionsLowReserve",e.void()],["setOptionsTooManySigners",e.void()],["setOptionsBadFlags",e.void()],["setOptionsInvalidInflation",e.void()],["setOptionsCantChange",e.void()],["setOptionsUnknownFlag",e.void()],["setOptionsThresholdOutOfRange",e.void()],["setOptionsBadSigner",e.void()],["setOptionsInvalidHomeDomain",e.void()],["setOptionsAuthRevocableRequired",e.void()]],arms:{}}),e.enum("ChangeTrustResultCode",{changeTrustSuccess:0,changeTrustMalformed:-1,changeTrustNoIssuer:-2,changeTrustInvalidLimit:-3,changeTrustLowReserve:-4,changeTrustSelfNotAllowed:-5,changeTrustTrustLineMissing:-6,changeTrustCannotDelete:-7,changeTrustNotAuthMaintainLiabilities:-8}),e.union("ChangeTrustResult",{switchOn:e.lookup("ChangeTrustResultCode"),switchName:"code",switches:[["changeTrustSuccess",e.void()],["changeTrustMalformed",e.void()],["changeTrustNoIssuer",e.void()],["changeTrustInvalidLimit",e.void()],["changeTrustLowReserve",e.void()],["changeTrustSelfNotAllowed",e.void()],["changeTrustTrustLineMissing",e.void()],["changeTrustCannotDelete",e.void()],["changeTrustNotAuthMaintainLiabilities",e.void()]],arms:{}}),e.enum("AllowTrustResultCode",{allowTrustSuccess:0,allowTrustMalformed:-1,allowTrustNoTrustLine:-2,allowTrustTrustNotRequired:-3,allowTrustCantRevoke:-4,allowTrustSelfNotAllowed:-5,allowTrustLowReserve:-6}),e.union("AllowTrustResult",{switchOn:e.lookup("AllowTrustResultCode"),switchName:"code",switches:[["allowTrustSuccess",e.void()],["allowTrustMalformed",e.void()],["allowTrustNoTrustLine",e.void()],["allowTrustTrustNotRequired",e.void()],["allowTrustCantRevoke",e.void()],["allowTrustSelfNotAllowed",e.void()],["allowTrustLowReserve",e.void()]],arms:{}}),e.enum("AccountMergeResultCode",{accountMergeSuccess:0,accountMergeMalformed:-1,accountMergeNoAccount:-2,accountMergeImmutableSet:-3,accountMergeHasSubEntries:-4,accountMergeSeqnumTooFar:-5,accountMergeDestFull:-6,accountMergeIsSponsor:-7}),e.union("AccountMergeResult",{switchOn:e.lookup("AccountMergeResultCode"),switchName:"code",switches:[["accountMergeSuccess","sourceAccountBalance"],["accountMergeMalformed",e.void()],["accountMergeNoAccount",e.void()],["accountMergeImmutableSet",e.void()],["accountMergeHasSubEntries",e.void()],["accountMergeSeqnumTooFar",e.void()],["accountMergeDestFull",e.void()],["accountMergeIsSponsor",e.void()]],arms:{sourceAccountBalance:e.lookup("Int64")}}),e.enum("InflationResultCode",{inflationSuccess:0,inflationNotTime:-1}),e.struct("InflationPayout",[["destination",e.lookup("AccountId")],["amount",e.lookup("Int64")]]),e.union("InflationResult",{switchOn:e.lookup("InflationResultCode"),switchName:"code",switches:[["inflationSuccess","payouts"],["inflationNotTime",e.void()]],arms:{payouts:e.varArray(e.lookup("InflationPayout"),2147483647)}}),e.enum("ManageDataResultCode",{manageDataSuccess:0,manageDataNotSupportedYet:-1,manageDataNameNotFound:-2,manageDataLowReserve:-3,manageDataInvalidName:-4}),e.union("ManageDataResult",{switchOn:e.lookup("ManageDataResultCode"),switchName:"code",switches:[["manageDataSuccess",e.void()],["manageDataNotSupportedYet",e.void()],["manageDataNameNotFound",e.void()],["manageDataLowReserve",e.void()],["manageDataInvalidName",e.void()]],arms:{}}),e.enum("BumpSequenceResultCode",{bumpSequenceSuccess:0,bumpSequenceBadSeq:-1}),e.union("BumpSequenceResult",{switchOn:e.lookup("BumpSequenceResultCode"),switchName:"code",switches:[["bumpSequenceSuccess",e.void()],["bumpSequenceBadSeq",e.void()]],arms:{}}),e.enum("CreateClaimableBalanceResultCode",{createClaimableBalanceSuccess:0,createClaimableBalanceMalformed:-1,createClaimableBalanceLowReserve:-2,createClaimableBalanceNoTrust:-3,createClaimableBalanceNotAuthorized:-4,createClaimableBalanceUnderfunded:-5}),e.union("CreateClaimableBalanceResult",{switchOn:e.lookup("CreateClaimableBalanceResultCode"),switchName:"code",switches:[["createClaimableBalanceSuccess","balanceId"],["createClaimableBalanceMalformed",e.void()],["createClaimableBalanceLowReserve",e.void()],["createClaimableBalanceNoTrust",e.void()],["createClaimableBalanceNotAuthorized",e.void()],["createClaimableBalanceUnderfunded",e.void()]],arms:{balanceId:e.lookup("ClaimableBalanceId")}}),e.enum("ClaimClaimableBalanceResultCode",{claimClaimableBalanceSuccess:0,claimClaimableBalanceDoesNotExist:-1,claimClaimableBalanceCannotClaim:-2,claimClaimableBalanceLineFull:-3,claimClaimableBalanceNoTrust:-4,claimClaimableBalanceNotAuthorized:-5,claimClaimableBalanceTrustlineFrozen:-6}),e.union("ClaimClaimableBalanceResult",{switchOn:e.lookup("ClaimClaimableBalanceResultCode"),switchName:"code",switches:[["claimClaimableBalanceSuccess",e.void()],["claimClaimableBalanceDoesNotExist",e.void()],["claimClaimableBalanceCannotClaim",e.void()],["claimClaimableBalanceLineFull",e.void()],["claimClaimableBalanceNoTrust",e.void()],["claimClaimableBalanceNotAuthorized",e.void()],["claimClaimableBalanceTrustlineFrozen",e.void()]],arms:{}}),e.enum("BeginSponsoringFutureReservesResultCode",{beginSponsoringFutureReservesSuccess:0,beginSponsoringFutureReservesMalformed:-1,beginSponsoringFutureReservesAlreadySponsored:-2,beginSponsoringFutureReservesRecursive:-3}),e.union("BeginSponsoringFutureReservesResult",{switchOn:e.lookup("BeginSponsoringFutureReservesResultCode"),switchName:"code",switches:[["beginSponsoringFutureReservesSuccess",e.void()],["beginSponsoringFutureReservesMalformed",e.void()],["beginSponsoringFutureReservesAlreadySponsored",e.void()],["beginSponsoringFutureReservesRecursive",e.void()]],arms:{}}),e.enum("EndSponsoringFutureReservesResultCode",{endSponsoringFutureReservesSuccess:0,endSponsoringFutureReservesNotSponsored:-1}),e.union("EndSponsoringFutureReservesResult",{switchOn:e.lookup("EndSponsoringFutureReservesResultCode"),switchName:"code",switches:[["endSponsoringFutureReservesSuccess",e.void()],["endSponsoringFutureReservesNotSponsored",e.void()]],arms:{}}),e.enum("RevokeSponsorshipResultCode",{revokeSponsorshipSuccess:0,revokeSponsorshipDoesNotExist:-1,revokeSponsorshipNotSponsor:-2,revokeSponsorshipLowReserve:-3,revokeSponsorshipOnlyTransferable:-4,revokeSponsorshipMalformed:-5}),e.union("RevokeSponsorshipResult",{switchOn:e.lookup("RevokeSponsorshipResultCode"),switchName:"code",switches:[["revokeSponsorshipSuccess",e.void()],["revokeSponsorshipDoesNotExist",e.void()],["revokeSponsorshipNotSponsor",e.void()],["revokeSponsorshipLowReserve",e.void()],["revokeSponsorshipOnlyTransferable",e.void()],["revokeSponsorshipMalformed",e.void()]],arms:{}}),e.enum("ClawbackResultCode",{clawbackSuccess:0,clawbackMalformed:-1,clawbackNotClawbackEnabled:-2,clawbackNoTrust:-3,clawbackUnderfunded:-4}),e.union("ClawbackResult",{switchOn:e.lookup("ClawbackResultCode"),switchName:"code",switches:[["clawbackSuccess",e.void()],["clawbackMalformed",e.void()],["clawbackNotClawbackEnabled",e.void()],["clawbackNoTrust",e.void()],["clawbackUnderfunded",e.void()]],arms:{}}),e.enum("ClawbackClaimableBalanceResultCode",{clawbackClaimableBalanceSuccess:0,clawbackClaimableBalanceDoesNotExist:-1,clawbackClaimableBalanceNotIssuer:-2,clawbackClaimableBalanceNotClawbackEnabled:-3}),e.union("ClawbackClaimableBalanceResult",{switchOn:e.lookup("ClawbackClaimableBalanceResultCode"),switchName:"code",switches:[["clawbackClaimableBalanceSuccess",e.void()],["clawbackClaimableBalanceDoesNotExist",e.void()],["clawbackClaimableBalanceNotIssuer",e.void()],["clawbackClaimableBalanceNotClawbackEnabled",e.void()]],arms:{}}),e.enum("SetTrustLineFlagsResultCode",{setTrustLineFlagsSuccess:0,setTrustLineFlagsMalformed:-1,setTrustLineFlagsNoTrustLine:-2,setTrustLineFlagsCantRevoke:-3,setTrustLineFlagsInvalidState:-4,setTrustLineFlagsLowReserve:-5}),e.union("SetTrustLineFlagsResult",{switchOn:e.lookup("SetTrustLineFlagsResultCode"),switchName:"code",switches:[["setTrustLineFlagsSuccess",e.void()],["setTrustLineFlagsMalformed",e.void()],["setTrustLineFlagsNoTrustLine",e.void()],["setTrustLineFlagsCantRevoke",e.void()],["setTrustLineFlagsInvalidState",e.void()],["setTrustLineFlagsLowReserve",e.void()]],arms:{}}),e.enum("LiquidityPoolDepositResultCode",{liquidityPoolDepositSuccess:0,liquidityPoolDepositMalformed:-1,liquidityPoolDepositNoTrust:-2,liquidityPoolDepositNotAuthorized:-3,liquidityPoolDepositUnderfunded:-4,liquidityPoolDepositLineFull:-5,liquidityPoolDepositBadPrice:-6,liquidityPoolDepositPoolFull:-7,liquidityPoolDepositTrustlineFrozen:-8}),e.union("LiquidityPoolDepositResult",{switchOn:e.lookup("LiquidityPoolDepositResultCode"),switchName:"code",switches:[["liquidityPoolDepositSuccess",e.void()],["liquidityPoolDepositMalformed",e.void()],["liquidityPoolDepositNoTrust",e.void()],["liquidityPoolDepositNotAuthorized",e.void()],["liquidityPoolDepositUnderfunded",e.void()],["liquidityPoolDepositLineFull",e.void()],["liquidityPoolDepositBadPrice",e.void()],["liquidityPoolDepositPoolFull",e.void()],["liquidityPoolDepositTrustlineFrozen",e.void()]],arms:{}}),e.enum("LiquidityPoolWithdrawResultCode",{liquidityPoolWithdrawSuccess:0,liquidityPoolWithdrawMalformed:-1,liquidityPoolWithdrawNoTrust:-2,liquidityPoolWithdrawUnderfunded:-3,liquidityPoolWithdrawLineFull:-4,liquidityPoolWithdrawUnderMinimum:-5,liquidityPoolWithdrawTrustlineFrozen:-6}),e.union("LiquidityPoolWithdrawResult",{switchOn:e.lookup("LiquidityPoolWithdrawResultCode"),switchName:"code",switches:[["liquidityPoolWithdrawSuccess",e.void()],["liquidityPoolWithdrawMalformed",e.void()],["liquidityPoolWithdrawNoTrust",e.void()],["liquidityPoolWithdrawUnderfunded",e.void()],["liquidityPoolWithdrawLineFull",e.void()],["liquidityPoolWithdrawUnderMinimum",e.void()],["liquidityPoolWithdrawTrustlineFrozen",e.void()]],arms:{}}),e.enum("InvokeHostFunctionResultCode",{invokeHostFunctionSuccess:0,invokeHostFunctionMalformed:-1,invokeHostFunctionTrapped:-2,invokeHostFunctionResourceLimitExceeded:-3,invokeHostFunctionEntryArchived:-4,invokeHostFunctionInsufficientRefundableFee:-5}),e.union("InvokeHostFunctionResult",{switchOn:e.lookup("InvokeHostFunctionResultCode"),switchName:"code",switches:[["invokeHostFunctionSuccess","success"],["invokeHostFunctionMalformed",e.void()],["invokeHostFunctionTrapped",e.void()],["invokeHostFunctionResourceLimitExceeded",e.void()],["invokeHostFunctionEntryArchived",e.void()],["invokeHostFunctionInsufficientRefundableFee",e.void()]],arms:{success:e.lookup("Hash")}}),e.enum("ExtendFootprintTtlResultCode",{extendFootprintTtlSuccess:0,extendFootprintTtlMalformed:-1,extendFootprintTtlResourceLimitExceeded:-2,extendFootprintTtlInsufficientRefundableFee:-3}),e.union("ExtendFootprintTtlResult",{switchOn:e.lookup("ExtendFootprintTtlResultCode"),switchName:"code",switches:[["extendFootprintTtlSuccess",e.void()],["extendFootprintTtlMalformed",e.void()],["extendFootprintTtlResourceLimitExceeded",e.void()],["extendFootprintTtlInsufficientRefundableFee",e.void()]],arms:{}}),e.enum("RestoreFootprintResultCode",{restoreFootprintSuccess:0,restoreFootprintMalformed:-1,restoreFootprintResourceLimitExceeded:-2,restoreFootprintInsufficientRefundableFee:-3}),e.union("RestoreFootprintResult",{switchOn:e.lookup("RestoreFootprintResultCode"),switchName:"code",switches:[["restoreFootprintSuccess",e.void()],["restoreFootprintMalformed",e.void()],["restoreFootprintResourceLimitExceeded",e.void()],["restoreFootprintInsufficientRefundableFee",e.void()]],arms:{}}),e.enum("OperationResultCode",{opInner:0,opBadAuth:-1,opNoAccount:-2,opNotSupported:-3,opTooManySubentries:-4,opExceededWorkLimit:-5,opTooManySponsoring:-6}),e.union("OperationResultTr",{switchOn:e.lookup("OperationType"),switchName:"type",switches:[["createAccount","createAccountResult"],["payment","paymentResult"],["pathPaymentStrictReceive","pathPaymentStrictReceiveResult"],["manageSellOffer","manageSellOfferResult"],["createPassiveSellOffer","createPassiveSellOfferResult"],["setOptions","setOptionsResult"],["changeTrust","changeTrustResult"],["allowTrust","allowTrustResult"],["accountMerge","accountMergeResult"],["inflation","inflationResult"],["manageData","manageDataResult"],["bumpSequence","bumpSeqResult"],["manageBuyOffer","manageBuyOfferResult"],["pathPaymentStrictSend","pathPaymentStrictSendResult"],["createClaimableBalance","createClaimableBalanceResult"],["claimClaimableBalance","claimClaimableBalanceResult"],["beginSponsoringFutureReserves","beginSponsoringFutureReservesResult"],["endSponsoringFutureReserves","endSponsoringFutureReservesResult"],["revokeSponsorship","revokeSponsorshipResult"],["clawback","clawbackResult"],["clawbackClaimableBalance","clawbackClaimableBalanceResult"],["setTrustLineFlags","setTrustLineFlagsResult"],["liquidityPoolDeposit","liquidityPoolDepositResult"],["liquidityPoolWithdraw","liquidityPoolWithdrawResult"],["invokeHostFunction","invokeHostFunctionResult"],["extendFootprintTtl","extendFootprintTtlResult"],["restoreFootprint","restoreFootprintResult"]],arms:{createAccountResult:e.lookup("CreateAccountResult"),paymentResult:e.lookup("PaymentResult"),pathPaymentStrictReceiveResult:e.lookup("PathPaymentStrictReceiveResult"),manageSellOfferResult:e.lookup("ManageSellOfferResult"),createPassiveSellOfferResult:e.lookup("ManageSellOfferResult"),setOptionsResult:e.lookup("SetOptionsResult"),changeTrustResult:e.lookup("ChangeTrustResult"),allowTrustResult:e.lookup("AllowTrustResult"),accountMergeResult:e.lookup("AccountMergeResult"),inflationResult:e.lookup("InflationResult"),manageDataResult:e.lookup("ManageDataResult"),bumpSeqResult:e.lookup("BumpSequenceResult"),manageBuyOfferResult:e.lookup("ManageBuyOfferResult"),pathPaymentStrictSendResult:e.lookup("PathPaymentStrictSendResult"),createClaimableBalanceResult:e.lookup("CreateClaimableBalanceResult"),claimClaimableBalanceResult:e.lookup("ClaimClaimableBalanceResult"),beginSponsoringFutureReservesResult:e.lookup("BeginSponsoringFutureReservesResult"),endSponsoringFutureReservesResult:e.lookup("EndSponsoringFutureReservesResult"),revokeSponsorshipResult:e.lookup("RevokeSponsorshipResult"),clawbackResult:e.lookup("ClawbackResult"),clawbackClaimableBalanceResult:e.lookup("ClawbackClaimableBalanceResult"),setTrustLineFlagsResult:e.lookup("SetTrustLineFlagsResult"),liquidityPoolDepositResult:e.lookup("LiquidityPoolDepositResult"),liquidityPoolWithdrawResult:e.lookup("LiquidityPoolWithdrawResult"),invokeHostFunctionResult:e.lookup("InvokeHostFunctionResult"),extendFootprintTtlResult:e.lookup("ExtendFootprintTtlResult"),restoreFootprintResult:e.lookup("RestoreFootprintResult")}}),e.union("OperationResult",{switchOn:e.lookup("OperationResultCode"),switchName:"code",switches:[["opInner","tr"],["opBadAuth",e.void()],["opNoAccount",e.void()],["opNotSupported",e.void()],["opTooManySubentries",e.void()],["opExceededWorkLimit",e.void()],["opTooManySponsoring",e.void()]],arms:{tr:e.lookup("OperationResultTr")}}),e.enum("TransactionResultCode",{txFeeBumpInnerSuccess:1,txSuccess:0,txFailed:-1,txTooEarly:-2,txTooLate:-3,txMissingOperation:-4,txBadSeq:-5,txBadAuth:-6,txInsufficientBalance:-7,txNoAccount:-8,txInsufficientFee:-9,txBadAuthExtra:-10,txInternalError:-11,txNotSupported:-12,txFeeBumpInnerFailed:-13,txBadSponsorship:-14,txBadMinSeqAgeOrGap:-15,txMalformed:-16,txSorobanInvalid:-17,txFrozenKeyAccessed:-18}),e.union("InnerTransactionResultResult",{switchOn:e.lookup("TransactionResultCode"),switchName:"code",switches:[["txSuccess","results"],["txFailed","results"],["txTooEarly",e.void()],["txTooLate",e.void()],["txMissingOperation",e.void()],["txBadSeq",e.void()],["txBadAuth",e.void()],["txInsufficientBalance",e.void()],["txNoAccount",e.void()],["txInsufficientFee",e.void()],["txBadAuthExtra",e.void()],["txInternalError",e.void()],["txNotSupported",e.void()],["txBadSponsorship",e.void()],["txBadMinSeqAgeOrGap",e.void()],["txMalformed",e.void()],["txSorobanInvalid",e.void()],["txFrozenKeyAccessed",e.void()]],arms:{results:e.varArray(e.lookup("OperationResult"),2147483647)}}),e.union("InnerTransactionResultExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("InnerTransactionResult",[["feeCharged",e.lookup("Int64")],["result",e.lookup("InnerTransactionResultResult")],["ext",e.lookup("InnerTransactionResultExt")]]),e.struct("InnerTransactionResultPair",[["transactionHash",e.lookup("Hash")],["result",e.lookup("InnerTransactionResult")]]),e.union("TransactionResultResult",{switchOn:e.lookup("TransactionResultCode"),switchName:"code",switches:[["txFeeBumpInnerSuccess","innerResultPair"],["txFeeBumpInnerFailed","innerResultPair"],["txSuccess","results"],["txFailed","results"],["txTooEarly",e.void()],["txTooLate",e.void()],["txMissingOperation",e.void()],["txBadSeq",e.void()],["txBadAuth",e.void()],["txInsufficientBalance",e.void()],["txNoAccount",e.void()],["txInsufficientFee",e.void()],["txBadAuthExtra",e.void()],["txInternalError",e.void()],["txNotSupported",e.void()],["txBadSponsorship",e.void()],["txBadMinSeqAgeOrGap",e.void()],["txMalformed",e.void()],["txSorobanInvalid",e.void()],["txFrozenKeyAccessed",e.void()]],arms:{innerResultPair:e.lookup("InnerTransactionResultPair"),results:e.varArray(e.lookup("OperationResult"),2147483647)}}),e.union("TransactionResultExt",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.struct("TransactionResult",[["feeCharged",e.lookup("Int64")],["result",e.lookup("TransactionResultResult")],["ext",e.lookup("TransactionResultExt")]]),e.typedef("Hash",e.opaque(32)),e.typedef("Uint256",e.opaque(32)),e.typedef("Uint32",e.uint()),e.typedef("Int32",e.int()),e.typedef("Uint64",e.uhyper()),e.typedef("Int64",e.hyper()),e.typedef("TimePoint",e.lookup("Uint64")),e.typedef("Duration",e.lookup("Uint64")),e.union("ExtensionPoint",{switchOn:e.int(),switchName:"v",switches:[[0,e.void()]],arms:{}}),e.enum("CryptoKeyType",{keyTypeEd25519:0,keyTypePreAuthTx:1,keyTypeHashX:2,keyTypeEd25519SignedPayload:3,keyTypeMuxedEd25519:256}),e.enum("PublicKeyType",{publicKeyTypeEd25519:0}),e.enum("SignerKeyType",{signerKeyTypeEd25519:0,signerKeyTypePreAuthTx:1,signerKeyTypeHashX:2,signerKeyTypeEd25519SignedPayload:3}),e.union("PublicKey",{switchOn:e.lookup("PublicKeyType"),switchName:"type",switches:[["publicKeyTypeEd25519","ed25519"]],arms:{ed25519:e.lookup("Uint256")}}),e.struct("SignerKeyEd25519SignedPayload",[["ed25519",e.lookup("Uint256")],["payload",e.varOpaque(64)]]),e.union("SignerKey",{switchOn:e.lookup("SignerKeyType"),switchName:"type",switches:[["signerKeyTypeEd25519","ed25519"],["signerKeyTypePreAuthTx","preAuthTx"],["signerKeyTypeHashX","hashX"],["signerKeyTypeEd25519SignedPayload","ed25519SignedPayload"]],arms:{ed25519:e.lookup("Uint256"),preAuthTx:e.lookup("Uint256"),hashX:e.lookup("Uint256"),ed25519SignedPayload:e.lookup("SignerKeyEd25519SignedPayload")}}),e.typedef("Signature",e.varOpaque(64)),e.typedef("SignatureHint",e.opaque(4)),e.typedef("NodeId",e.lookup("PublicKey")),e.typedef("AccountId",e.lookup("PublicKey")),e.typedef("ContractId",e.lookup("Hash")),e.struct("Curve25519Secret",[["key",e.opaque(32)]]),e.struct("Curve25519Public",[["key",e.opaque(32)]]),e.struct("HmacSha256Key",[["key",e.opaque(32)]]),e.struct("HmacSha256Mac",[["mac",e.opaque(32)]]),e.struct("ShortHashSeed",[["seed",e.opaque(16)]]),e.enum("BinaryFuseFilterType",{binaryFuseFilter8Bit:0,binaryFuseFilter16Bit:1,binaryFuseFilter32Bit:2}),e.struct("SerializedBinaryFuseFilter",[["type",e.lookup("BinaryFuseFilterType")],["inputHashSeed",e.lookup("ShortHashSeed")],["filterSeed",e.lookup("ShortHashSeed")],["segmentLength",e.lookup("Uint32")],["segementLengthMask",e.lookup("Uint32")],["segmentCount",e.lookup("Uint32")],["segmentCountLength",e.lookup("Uint32")],["fingerprintLength",e.lookup("Uint32")],["fingerprints",e.varOpaque()]]),e.typedef("PoolId",e.lookup("Hash")),e.enum("ClaimableBalanceIdType",{claimableBalanceIdTypeV0:0}),e.union("ClaimableBalanceId",{switchOn:e.lookup("ClaimableBalanceIdType"),switchName:"type",switches:[["claimableBalanceIdTypeV0","v0"]],arms:{v0:e.lookup("Hash")}}),e.enum("ScValType",{scvBool:0,scvVoid:1,scvError:2,scvU32:3,scvI32:4,scvU64:5,scvI64:6,scvTimepoint:7,scvDuration:8,scvU128:9,scvI128:10,scvU256:11,scvI256:12,scvBytes:13,scvString:14,scvSymbol:15,scvVec:16,scvMap:17,scvAddress:18,scvContractInstance:19,scvLedgerKeyContractInstance:20,scvLedgerKeyNonce:21}),e.enum("ScErrorType",{sceContract:0,sceWasmVm:1,sceContext:2,sceStorage:3,sceObject:4,sceCrypto:5,sceEvents:6,sceBudget:7,sceValue:8,sceAuth:9}),e.enum("ScErrorCode",{scecArithDomain:0,scecIndexBounds:1,scecInvalidInput:2,scecMissingValue:3,scecExistingValue:4,scecExceededLimit:5,scecInvalidAction:6,scecInternalError:7,scecUnexpectedType:8,scecUnexpectedSize:9}),e.union("ScError",{switchOn:e.lookup("ScErrorType"),switchName:"type",switches:[["sceContract","contractCode"],["sceWasmVm","code"],["sceContext","code"],["sceStorage","code"],["sceObject","code"],["sceCrypto","code"],["sceEvents","code"],["sceBudget","code"],["sceValue","code"],["sceAuth","code"]],arms:{contractCode:e.lookup("Uint32"),code:e.lookup("ScErrorCode")}}),e.struct("UInt128Parts",[["hi",e.lookup("Uint64")],["lo",e.lookup("Uint64")]]),e.struct("Int128Parts",[["hi",e.lookup("Int64")],["lo",e.lookup("Uint64")]]),e.struct("UInt256Parts",[["hiHi",e.lookup("Uint64")],["hiLo",e.lookup("Uint64")],["loHi",e.lookup("Uint64")],["loLo",e.lookup("Uint64")]]),e.struct("Int256Parts",[["hiHi",e.lookup("Int64")],["hiLo",e.lookup("Uint64")],["loHi",e.lookup("Uint64")],["loLo",e.lookup("Uint64")]]),e.enum("ContractExecutableType",{contractExecutableWasm:0,contractExecutableStellarAsset:1}),e.union("ContractExecutable",{switchOn:e.lookup("ContractExecutableType"),switchName:"type",switches:[["contractExecutableWasm","wasmHash"],["contractExecutableStellarAsset",e.void()]],arms:{wasmHash:e.lookup("Hash")}}),e.enum("ScAddressType",{scAddressTypeAccount:0,scAddressTypeContract:1,scAddressTypeMuxedAccount:2,scAddressTypeClaimableBalance:3,scAddressTypeLiquidityPool:4}),e.struct("MuxedEd25519Account",[["id",e.lookup("Uint64")],["ed25519",e.lookup("Uint256")]]),e.union("ScAddress",{switchOn:e.lookup("ScAddressType"),switchName:"type",switches:[["scAddressTypeAccount","accountId"],["scAddressTypeContract","contractId"],["scAddressTypeMuxedAccount","muxedAccount"],["scAddressTypeClaimableBalance","claimableBalanceId"],["scAddressTypeLiquidityPool","liquidityPoolId"]],arms:{accountId:e.lookup("AccountId"),contractId:e.lookup("ContractId"),muxedAccount:e.lookup("MuxedEd25519Account"),claimableBalanceId:e.lookup("ClaimableBalanceId"),liquidityPoolId:e.lookup("PoolId")}}),e.const("SCSYMBOL_LIMIT",32),e.typedef("ScVec",e.varArray(e.lookup("ScVal"),2147483647)),e.typedef("ScMap",e.varArray(e.lookup("ScMapEntry"),2147483647)),e.typedef("ScBytes",e.varOpaque()),e.typedef("ScString",e.string()),e.typedef("ScSymbol",e.string(32)),e.struct("ScNonceKey",[["nonce",e.lookup("Int64")]]),e.struct("ScContractInstance",[["executable",e.lookup("ContractExecutable")],["storage",e.option(e.lookup("ScMap"))]]),e.union("ScVal",{switchOn:e.lookup("ScValType"),switchName:"type",switches:[["scvBool","b"],["scvVoid",e.void()],["scvError","error"],["scvU32","u32"],["scvI32","i32"],["scvU64","u64"],["scvI64","i64"],["scvTimepoint","timepoint"],["scvDuration","duration"],["scvU128","u128"],["scvI128","i128"],["scvU256","u256"],["scvI256","i256"],["scvBytes","bytes"],["scvString","str"],["scvSymbol","sym"],["scvVec","vec"],["scvMap","map"],["scvAddress","address"],["scvContractInstance","instance"],["scvLedgerKeyContractInstance",e.void()],["scvLedgerKeyNonce","nonceKey"]],arms:{b:e.bool(),error:e.lookup("ScError"),u32:e.lookup("Uint32"),i32:e.lookup("Int32"),u64:e.lookup("Uint64"),i64:e.lookup("Int64"),timepoint:e.lookup("TimePoint"),duration:e.lookup("Duration"),u128:e.lookup("UInt128Parts"),i128:e.lookup("Int128Parts"),u256:e.lookup("UInt256Parts"),i256:e.lookup("Int256Parts"),bytes:e.lookup("ScBytes"),str:e.lookup("ScString"),sym:e.lookup("ScSymbol"),vec:e.option(e.lookup("ScVec")),map:e.option(e.lookup("ScMap")),address:e.lookup("ScAddress"),instance:e.lookup("ScContractInstance"),nonceKey:e.lookup("ScNonceKey")}}),e.struct("ScMapEntry",[["key",e.lookup("ScVal")],["val",e.lookup("ScVal")]]),e.enum("ScEnvMetaKind",{scEnvMetaKindInterfaceVersion:0}),e.struct("ScEnvMetaEntryInterfaceVersion",[["protocol",e.lookup("Uint32")],["preRelease",e.lookup("Uint32")]]),e.union("ScEnvMetaEntry",{switchOn:e.lookup("ScEnvMetaKind"),switchName:"kind",switches:[["scEnvMetaKindInterfaceVersion","interfaceVersion"]],arms:{interfaceVersion:e.lookup("ScEnvMetaEntryInterfaceVersion")}}),e.struct("ScMetaV0",[["key",e.string()],["val",e.string()]]),e.enum("ScMetaKind",{scMetaV0:0}),e.union("ScMetaEntry",{switchOn:e.lookup("ScMetaKind"),switchName:"kind",switches:[["scMetaV0","v0"]],arms:{v0:e.lookup("ScMetaV0")}}),e.const("SC_SPEC_DOC_LIMIT",1024),e.enum("ScSpecType",{scSpecTypeVal:0,scSpecTypeBool:1,scSpecTypeVoid:2,scSpecTypeError:3,scSpecTypeU32:4,scSpecTypeI32:5,scSpecTypeU64:6,scSpecTypeI64:7,scSpecTypeTimepoint:8,scSpecTypeDuration:9,scSpecTypeU128:10,scSpecTypeI128:11,scSpecTypeU256:12,scSpecTypeI256:13,scSpecTypeBytes:14,scSpecTypeString:16,scSpecTypeSymbol:17,scSpecTypeAddress:19,scSpecTypeMuxedAddress:20,scSpecTypeOption:1e3,scSpecTypeResult:1001,scSpecTypeVec:1002,scSpecTypeMap:1004,scSpecTypeTuple:1005,scSpecTypeBytesN:1006,scSpecTypeUdt:2e3}),e.struct("ScSpecTypeOption",[["valueType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeResult",[["okType",e.lookup("ScSpecTypeDef")],["errorType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeVec",[["elementType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeMap",[["keyType",e.lookup("ScSpecTypeDef")],["valueType",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecTypeTuple",[["valueTypes",e.varArray(e.lookup("ScSpecTypeDef"),12)]]),e.struct("ScSpecTypeBytesN",[["n",e.lookup("Uint32")]]),e.struct("ScSpecTypeUdt",[["name",e.string(60)]]),e.union("ScSpecTypeDef",{switchOn:e.lookup("ScSpecType"),switchName:"type",switches:[["scSpecTypeVal",e.void()],["scSpecTypeBool",e.void()],["scSpecTypeVoid",e.void()],["scSpecTypeError",e.void()],["scSpecTypeU32",e.void()],["scSpecTypeI32",e.void()],["scSpecTypeU64",e.void()],["scSpecTypeI64",e.void()],["scSpecTypeTimepoint",e.void()],["scSpecTypeDuration",e.void()],["scSpecTypeU128",e.void()],["scSpecTypeI128",e.void()],["scSpecTypeU256",e.void()],["scSpecTypeI256",e.void()],["scSpecTypeBytes",e.void()],["scSpecTypeString",e.void()],["scSpecTypeSymbol",e.void()],["scSpecTypeAddress",e.void()],["scSpecTypeMuxedAddress",e.void()],["scSpecTypeOption","option"],["scSpecTypeResult","result"],["scSpecTypeVec","vec"],["scSpecTypeMap","map"],["scSpecTypeTuple","tuple"],["scSpecTypeBytesN","bytesN"],["scSpecTypeUdt","udt"]],arms:{option:e.lookup("ScSpecTypeOption"),result:e.lookup("ScSpecTypeResult"),vec:e.lookup("ScSpecTypeVec"),map:e.lookup("ScSpecTypeMap"),tuple:e.lookup("ScSpecTypeTuple"),bytesN:e.lookup("ScSpecTypeBytesN"),udt:e.lookup("ScSpecTypeUdt")}}),e.struct("ScSpecUdtStructFieldV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecUdtStructV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["fields",e.varArray(e.lookup("ScSpecUdtStructFieldV0"),2147483647)]]),e.struct("ScSpecUdtUnionCaseVoidV0",[["doc",e.string(t)],["name",e.string(60)]]),e.struct("ScSpecUdtUnionCaseTupleV0",[["doc",e.string(t)],["name",e.string(60)],["type",e.varArray(e.lookup("ScSpecTypeDef"),2147483647)]]),e.enum("ScSpecUdtUnionCaseV0Kind",{scSpecUdtUnionCaseVoidV0:0,scSpecUdtUnionCaseTupleV0:1}),e.union("ScSpecUdtUnionCaseV0",{switchOn:e.lookup("ScSpecUdtUnionCaseV0Kind"),switchName:"kind",switches:[["scSpecUdtUnionCaseVoidV0","voidCase"],["scSpecUdtUnionCaseTupleV0","tupleCase"]],arms:{voidCase:e.lookup("ScSpecUdtUnionCaseVoidV0"),tupleCase:e.lookup("ScSpecUdtUnionCaseTupleV0")}}),e.struct("ScSpecUdtUnionV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtUnionCaseV0"),2147483647)]]),e.struct("ScSpecUdtEnumCaseV0",[["doc",e.string(t)],["name",e.string(60)],["value",e.lookup("Uint32")]]),e.struct("ScSpecUdtEnumV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtEnumCaseV0"),2147483647)]]),e.struct("ScSpecUdtErrorEnumCaseV0",[["doc",e.string(t)],["name",e.string(60)],["value",e.lookup("Uint32")]]),e.struct("ScSpecUdtErrorEnumV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.string(60)],["cases",e.varArray(e.lookup("ScSpecUdtErrorEnumCaseV0"),2147483647)]]),e.struct("ScSpecFunctionInputV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")]]),e.struct("ScSpecFunctionV0",[["doc",e.string(t)],["name",e.lookup("ScSymbol")],["inputs",e.varArray(e.lookup("ScSpecFunctionInputV0"),2147483647)],["outputs",e.varArray(e.lookup("ScSpecTypeDef"),1)]]),e.enum("ScSpecEventParamLocationV0",{scSpecEventParamLocationData:0,scSpecEventParamLocationTopicList:1}),e.struct("ScSpecEventParamV0",[["doc",e.string(t)],["name",e.string(30)],["type",e.lookup("ScSpecTypeDef")],["location",e.lookup("ScSpecEventParamLocationV0")]]),e.enum("ScSpecEventDataFormat",{scSpecEventDataFormatSingleValue:0,scSpecEventDataFormatVec:1,scSpecEventDataFormatMap:2}),e.struct("ScSpecEventV0",[["doc",e.string(t)],["lib",e.string(80)],["name",e.lookup("ScSymbol")],["prefixTopics",e.varArray(e.lookup("ScSymbol"),2)],["params",e.varArray(e.lookup("ScSpecEventParamV0"),2147483647)],["dataFormat",e.lookup("ScSpecEventDataFormat")]]),e.enum("ScSpecEntryKind",{scSpecEntryFunctionV0:0,scSpecEntryUdtStructV0:1,scSpecEntryUdtUnionV0:2,scSpecEntryUdtEnumV0:3,scSpecEntryUdtErrorEnumV0:4,scSpecEntryEventV0:5}),e.union("ScSpecEntry",{switchOn:e.lookup("ScSpecEntryKind"),switchName:"kind",switches:[["scSpecEntryFunctionV0","functionV0"],["scSpecEntryUdtStructV0","udtStructV0"],["scSpecEntryUdtUnionV0","udtUnionV0"],["scSpecEntryUdtEnumV0","udtEnumV0"],["scSpecEntryUdtErrorEnumV0","udtErrorEnumV0"],["scSpecEntryEventV0","eventV0"]],arms:{functionV0:e.lookup("ScSpecFunctionV0"),udtStructV0:e.lookup("ScSpecUdtStructV0"),udtUnionV0:e.lookup("ScSpecUdtUnionV0"),udtEnumV0:e.lookup("ScSpecUdtEnumV0"),udtErrorEnumV0:e.lookup("ScSpecUdtErrorEnumV0"),eventV0:e.lookup("ScSpecEventV0")}}),e.typedef("EncodedLedgerKey",e.varOpaque()),e.struct("ConfigSettingContractExecutionLanesV0",[["ledgerMaxTxCount",e.lookup("Uint32")]]),e.struct("ConfigSettingContractComputeV0",[["ledgerMaxInstructions",e.lookup("Int64")],["txMaxInstructions",e.lookup("Int64")],["feeRatePerInstructionsIncrement",e.lookup("Int64")],["txMemoryLimit",e.lookup("Uint32")]]),e.struct("ConfigSettingContractParallelComputeV0",[["ledgerMaxDependentTxClusters",e.lookup("Uint32")]]),e.struct("ConfigSettingContractLedgerCostV0",[["ledgerMaxDiskReadEntries",e.lookup("Uint32")],["ledgerMaxDiskReadBytes",e.lookup("Uint32")],["ledgerMaxWriteLedgerEntries",e.lookup("Uint32")],["ledgerMaxWriteBytes",e.lookup("Uint32")],["txMaxDiskReadEntries",e.lookup("Uint32")],["txMaxDiskReadBytes",e.lookup("Uint32")],["txMaxWriteLedgerEntries",e.lookup("Uint32")],["txMaxWriteBytes",e.lookup("Uint32")],["feeDiskReadLedgerEntry",e.lookup("Int64")],["feeWriteLedgerEntry",e.lookup("Int64")],["feeDiskRead1Kb",e.lookup("Int64")],["sorobanStateTargetSizeBytes",e.lookup("Int64")],["rentFee1KbSorobanStateSizeLow",e.lookup("Int64")],["rentFee1KbSorobanStateSizeHigh",e.lookup("Int64")],["sorobanStateRentFeeGrowthFactor",e.lookup("Uint32")]]),e.struct("ConfigSettingContractLedgerCostExtV0",[["txMaxFootprintEntries",e.lookup("Uint32")],["feeWrite1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractHistoricalDataV0",[["feeHistorical1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractEventsV0",[["txMaxContractEventsSizeBytes",e.lookup("Uint32")],["feeContractEvents1Kb",e.lookup("Int64")]]),e.struct("ConfigSettingContractBandwidthV0",[["ledgerMaxTxsSizeBytes",e.lookup("Uint32")],["txMaxSizeBytes",e.lookup("Uint32")],["feeTxSize1Kb",e.lookup("Int64")]]),e.enum("ContractCostType",{wasmInsnExec:0,memAlloc:1,memCpy:2,memCmp:3,dispatchHostFunction:4,visitObject:5,valSer:6,valDeser:7,computeSha256Hash:8,computeEd25519PubKey:9,verifyEd25519Sig:10,vmInstantiation:11,vmCachedInstantiation:12,invokeVmFunction:13,computeKeccak256Hash:14,decodeEcdsaCurve256Sig:15,recoverEcdsaSecp256k1Key:16,int256AddSub:17,int256Mul:18,int256Div:19,int256Pow:20,int256Shift:21,chaCha20DrawBytes:22,parseWasmInstructions:23,parseWasmFunctions:24,parseWasmGlobals:25,parseWasmTableEntries:26,parseWasmTypes:27,parseWasmDataSegments:28,parseWasmElemSegments:29,parseWasmImports:30,parseWasmExports:31,parseWasmDataSegmentBytes:32,instantiateWasmInstructions:33,instantiateWasmFunctions:34,instantiateWasmGlobals:35,instantiateWasmTableEntries:36,instantiateWasmTypes:37,instantiateWasmDataSegments:38,instantiateWasmElemSegments:39,instantiateWasmImports:40,instantiateWasmExports:41,instantiateWasmDataSegmentBytes:42,sec1DecodePointUncompressed:43,verifyEcdsaSecp256r1Sig:44,bls12381EncodeFp:45,bls12381DecodeFp:46,bls12381G1CheckPointOnCurve:47,bls12381G1CheckPointInSubgroup:48,bls12381G2CheckPointOnCurve:49,bls12381G2CheckPointInSubgroup:50,bls12381G1ProjectiveToAffine:51,bls12381G2ProjectiveToAffine:52,bls12381G1Add:53,bls12381G1Mul:54,bls12381G1Msm:55,bls12381MapFpToG1:56,bls12381HashToG1:57,bls12381G2Add:58,bls12381G2Mul:59,bls12381G2Msm:60,bls12381MapFp2ToG2:61,bls12381HashToG2:62,bls12381Pairing:63,bls12381FrFromU256:64,bls12381FrToU256:65,bls12381FrAddSub:66,bls12381FrMul:67,bls12381FrPow:68,bls12381FrInv:69,bn254EncodeFp:70,bn254DecodeFp:71,bn254G1CheckPointOnCurve:72,bn254G2CheckPointOnCurve:73,bn254G2CheckPointInSubgroup:74,bn254G1ProjectiveToAffine:75,bn254G1Add:76,bn254G1Mul:77,bn254Pairing:78,bn254FrFromU256:79,bn254FrToU256:80,bn254FrAddSub:81,bn254FrMul:82,bn254FrPow:83,bn254FrInv:84,bn254G1Msm:85}),e.struct("ContractCostParamEntry",[["ext",e.lookup("ExtensionPoint")],["constTerm",e.lookup("Int64")],["linearTerm",e.lookup("Int64")]]),e.struct("StateArchivalSettings",[["maxEntryTtl",e.lookup("Uint32")],["minTemporaryTtl",e.lookup("Uint32")],["minPersistentTtl",e.lookup("Uint32")],["persistentRentRateDenominator",e.lookup("Int64")],["tempRentRateDenominator",e.lookup("Int64")],["maxEntriesToArchive",e.lookup("Uint32")],["liveSorobanStateSizeWindowSampleSize",e.lookup("Uint32")],["liveSorobanStateSizeWindowSamplePeriod",e.lookup("Uint32")],["evictionScanSize",e.lookup("Uint32")],["startingEvictionScanLevel",e.lookup("Uint32")]]),e.struct("EvictionIterator",[["bucketListLevel",e.lookup("Uint32")],["isCurrBucket",e.bool()],["bucketFileOffset",e.lookup("Uint64")]]),e.struct("ConfigSettingScpTiming",[["ledgerTargetCloseTimeMilliseconds",e.lookup("Uint32")],["nominationTimeoutInitialMilliseconds",e.lookup("Uint32")],["nominationTimeoutIncrementMilliseconds",e.lookup("Uint32")],["ballotTimeoutInitialMilliseconds",e.lookup("Uint32")],["ballotTimeoutIncrementMilliseconds",e.lookup("Uint32")]]),e.struct("FrozenLedgerKeys",[["keys",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)]]),e.struct("FrozenLedgerKeysDelta",[["keysToFreeze",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)],["keysToUnfreeze",e.varArray(e.lookup("EncodedLedgerKey"),2147483647)]]),e.struct("FreezeBypassTxes",[["txHashes",e.varArray(e.lookup("Hash"),2147483647)]]),e.struct("FreezeBypassTxsDelta",[["addTxes",e.varArray(e.lookup("Hash"),2147483647)],["removeTxes",e.varArray(e.lookup("Hash"),2147483647)]]),e.const("CONTRACT_COST_COUNT_LIMIT",1024),e.typedef("ContractCostParams",e.varArray(e.lookup("ContractCostParamEntry"),e.lookup("CONTRACT_COST_COUNT_LIMIT"))),e.enum("ConfigSettingId",{configSettingContractMaxSizeBytes:0,configSettingContractComputeV0:1,configSettingContractLedgerCostV0:2,configSettingContractHistoricalDataV0:3,configSettingContractEventsV0:4,configSettingContractBandwidthV0:5,configSettingContractCostParamsCpuInstructions:6,configSettingContractCostParamsMemoryBytes:7,configSettingContractDataKeySizeBytes:8,configSettingContractDataEntrySizeBytes:9,configSettingStateArchival:10,configSettingContractExecutionLanes:11,configSettingLiveSorobanStateSizeWindow:12,configSettingEvictionIterator:13,configSettingContractParallelComputeV0:14,configSettingContractLedgerCostExtV0:15,configSettingScpTiming:16,configSettingFrozenLedgerKeys:17,configSettingFrozenLedgerKeysDelta:18,configSettingFreezeBypassTxes:19,configSettingFreezeBypassTxsDelta:20}),e.union("ConfigSettingEntry",{switchOn:e.lookup("ConfigSettingId"),switchName:"configSettingId",switches:[["configSettingContractMaxSizeBytes","contractMaxSizeBytes"],["configSettingContractComputeV0","contractCompute"],["configSettingContractLedgerCostV0","contractLedgerCost"],["configSettingContractHistoricalDataV0","contractHistoricalData"],["configSettingContractEventsV0","contractEvents"],["configSettingContractBandwidthV0","contractBandwidth"],["configSettingContractCostParamsCpuInstructions","contractCostParamsCpuInsns"],["configSettingContractCostParamsMemoryBytes","contractCostParamsMemBytes"],["configSettingContractDataKeySizeBytes","contractDataKeySizeBytes"],["configSettingContractDataEntrySizeBytes","contractDataEntrySizeBytes"],["configSettingStateArchival","stateArchivalSettings"],["configSettingContractExecutionLanes","contractExecutionLanes"],["configSettingLiveSorobanStateSizeWindow","liveSorobanStateSizeWindow"],["configSettingEvictionIterator","evictionIterator"],["configSettingContractParallelComputeV0","contractParallelCompute"],["configSettingContractLedgerCostExtV0","contractLedgerCostExt"],["configSettingScpTiming","contractScpTiming"],["configSettingFrozenLedgerKeys","frozenLedgerKeys"],["configSettingFrozenLedgerKeysDelta","frozenLedgerKeysDelta"],["configSettingFreezeBypassTxes","freezeBypassTxes"],["configSettingFreezeBypassTxsDelta","freezeBypassTxsDelta"]],arms:{contractMaxSizeBytes:e.lookup("Uint32"),contractCompute:e.lookup("ConfigSettingContractComputeV0"),contractLedgerCost:e.lookup("ConfigSettingContractLedgerCostV0"),contractHistoricalData:e.lookup("ConfigSettingContractHistoricalDataV0"),contractEvents:e.lookup("ConfigSettingContractEventsV0"),contractBandwidth:e.lookup("ConfigSettingContractBandwidthV0"),contractCostParamsCpuInsns:e.lookup("ContractCostParams"),contractCostParamsMemBytes:e.lookup("ContractCostParams"),contractDataKeySizeBytes:e.lookup("Uint32"),contractDataEntrySizeBytes:e.lookup("Uint32"),stateArchivalSettings:e.lookup("StateArchivalSettings"),contractExecutionLanes:e.lookup("ConfigSettingContractExecutionLanesV0"),liveSorobanStateSizeWindow:e.varArray(e.lookup("Uint64"),2147483647),evictionIterator:e.lookup("EvictionIterator"),contractParallelCompute:e.lookup("ConfigSettingContractParallelComputeV0"),contractLedgerCostExt:e.lookup("ConfigSettingContractLedgerCostExtV0"),contractScpTiming:e.lookup("ConfigSettingScpTiming"),frozenLedgerKeys:e.lookup("FrozenLedgerKeys"),frozenLedgerKeysDelta:e.lookup("FrozenLedgerKeysDelta"),freezeBypassTxes:e.lookup("FreezeBypassTxes"),freezeBypassTxsDelta:e.lookup("FreezeBypassTxsDelta")}}),e.struct("LedgerCloseMetaBatch",[["startSequence",e.lookup("Uint32")],["endSequence",e.lookup("Uint32")],["ledgerCloseMeta",e.varArray(e.lookup("LedgerCloseMeta"),2147483647)]])});const ie={XdrWriter:oe.XdrWriter,XdrReader:oe.XdrReader};var ae,ce={},ue={};var le,de,pe={};
|
|
192
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function he(){return le||(le=1,pe.read=function(e,t,n,r,o){var s,i,a=8*o-r-1,c=(1<<a)-1,u=c>>1,l=-7,d=n?o-1:0,p=n?-1:1,h=e[t+d];for(d+=p,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=p,l-=8);for(i=s&(1<<-l)-1,s>>=-l,l+=r;l>0;i=256*i+e[t+d],d+=p,l-=8);if(0===s)s=1-u;else{if(s===c)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,r),s-=u}return(h?-1:1)*i*Math.pow(2,s-r)},pe.write=function(e,t,n,r,o,s){var i,a,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),(t+=i+d>=1?p/c:p*Math.pow(2,1-d))*c>=2&&(i++,c/=2),i+d>=l?(a=0,i=l):i+d>=1?(a=(t*c-1)*Math.pow(2,o),i+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(i=i<<o|a,u+=o;u>0;e[n+h]=255&i,h+=f,i/=256,u-=8);e[n+h-f]|=128*m}),pe}
|
|
193
|
-
/*!
|
|
194
|
-
* The buffer module from node.js, for the browser.
|
|
195
|
-
*
|
|
196
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
197
|
-
* @license MIT
|
|
198
|
-
*/var fe=(de||(de=1,function(e){const t=function(){if(ae)return ue;ae=1,ue.byteLength=function(e){var t=s(e),n=t[0],r=t[1];return 3*(n+r)/4-r},ue.toByteArray=function(e){var r,o,i=s(e),a=i[0],c=i[1],u=new n(function(e,t,n){return 3*(t+n)/4-n}(0,a,c)),l=0,d=c>0?a-4:a;for(o=0;o<d;o+=4)r=t[e.charCodeAt(o)]<<18|t[e.charCodeAt(o+1)]<<12|t[e.charCodeAt(o+2)]<<6|t[e.charCodeAt(o+3)],u[l++]=r>>16&255,u[l++]=r>>8&255,u[l++]=255&r;return 2===c&&(r=t[e.charCodeAt(o)]<<2|t[e.charCodeAt(o+1)]>>4,u[l++]=255&r),1===c&&(r=t[e.charCodeAt(o)]<<10|t[e.charCodeAt(o+1)]<<4|t[e.charCodeAt(o+2)]>>2,u[l++]=r>>8&255,u[l++]=255&r),u},ue.fromByteArray=function(t){for(var n,r=t.length,o=r%3,s=[],i=16383,c=0,u=r-o;c<u;c+=i)s.push(a(t,c,c+i>u?u:c+i));return 1===o?(n=t[r-1],s.push(e[n>>2]+e[n<<4&63]+"==")):2===o&&(n=(t[r-2]<<8)+t[r-1],s.push(e[n>>10]+e[n>>4&63]+e[n<<2&63]+"=")),s.join("")};for(var e=[],t=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)e[o]=r[o],t[r.charCodeAt(o)]=o;function s(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 i(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function a(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(i(r));return o.join("")}return t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63,ue}(),n=he(),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(e){return+e!=e&&(e=0),i.alloc(+e)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,i.prototype),t}function i(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 u(e)}return a(e,t,n)}function a(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|h(e,t);let r=s(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(W(e,Uint8Array)){const t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return l(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(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return d(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return d(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 i.from(r,t,n);const o=function(e){if(i.isBuffer(e)){const t=0|p(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||Z(e.length)?s(0):l(e):"Buffer"===e.type&&Array.isArray(e.data)?l(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return i.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 c(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 u(e){return c(e),s(e<0?0:0|p(e))}function l(e){const t=e.length<0?0:0|p(e.length),n=s(t);for(let r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(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,i.prototype),r}function p(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function h(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(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 $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(e).length;default:if(o)return r?-1:$(e).length;t=(""+t).toLowerCase(),o=!0}}function f(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 B(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function g(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),Z(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=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:y(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):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(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 w(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(Z(r))return i;e[n+i]=r}return i}function A(e,t,n,r){return K($(t,e.length-n),e,n,r)}function S(e,t,n,r){return K(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 b(e,t,n,r){return K(X(t),e,n,r)}function v(e,t,n,r){return K(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 T(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function E(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<=k)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=k));return n}(r)}e.kMaxLength=o,i.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}}(),i.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(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(e,t,n){return a(e,t,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(e,t,n){return function(e,t,n){return c(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}(e,t,n)},i.allocUnsafe=function(e){return u(e)},i.allocUnsafeSlow=function(e){return u(e)},i.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==i.prototype},i.compare=function(e,t){if(W(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),W(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(e)||!i.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},i.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}},i.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return i.alloc(0);let n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;const r=i.allocUnsafe(t);let o=0;for(n=0;n<e.length;++n){let t=e[n];if(W(t,Uint8Array))o+t.length>r.length?(i.isBuffer(t)||(t=i.from(t)),t.copy(r,o)):Uint8Array.prototype.set.call(r,t,o);else{if(!i.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,o)}o+=t.length}return r},i.byteLength=h,i.prototype._isBuffer=!0,i.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)m(this,t,t+1);return this},i.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)m(this,t,t+3),m(this,t+1,t+2);return this},i.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)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},i.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?E(this,0,e):f.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(e){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===i.compare(this,e)},i.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+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(e,t,n,r,o){if(W(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.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),a=(n>>>=0)-(t>>>=0);const c=Math.min(s,a),u=this.slice(r,o),l=e.slice(t,n);for(let e=0;e<c;++e)if(u[e]!==l[e]){s=u[e],a=l[e];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},i.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},i.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},i.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 w(this,e,t,n);case"utf8":case"utf-8":return A(this,e,t,n);case"ascii":case"latin1":case"binary":return S(this,e,t,n);case"base64":return b(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function I(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 C(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 B(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+=z[e[r]];return o}function x(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 R(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 _(e,t,n,r,o,s){if(!i.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 P(e,t,n,r,o){M(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 O(e,t,n,r,o){M(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 U(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 L(e,t,r,o,s){return t=+t,r>>>=0,s||U(e,0,r,4),n.write(e,t,r,o,23,4),r+4}function N(e,t,r,o,s){return t=+t,r>>>=0,s||U(e,0,r,8),n.write(e,t,r,o,52,8),r+8}i.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,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);let r=this[e],o=1,s=0;for(;++s<t&&(o*=256);)r+=this[e+s]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||R(e,t,this.length);let r=this[e+--t],o=1;for(;t>0&&(o*=256);)r+=this[e+--t]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readBigUInt64LE=j(function(e){q(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||H(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))}),i.prototype.readBigUInt64BE=j(function(e){q(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||H(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)}),i.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||R(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},i.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||R(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},i.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readBigInt64LE=j(function(e){q(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||H(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)}),i.prototype.readBigInt64BE=j(function(e){q(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||H(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)}),i.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),n.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),n.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),n.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),n.read(this,e,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||_(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},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||_(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},i.prototype.writeUint8=i.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeBigUInt64LE=j(function(e,t=0){return P(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=j(function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);_(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},i.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);_(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},i.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_(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},i.prototype.writeBigInt64LE=j(function(e,t=0){return P(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=j(function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(!i.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},i.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&&!i.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=i.isBuffer(e)?e:i.from(e,r),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};const V={};function F(e,t,n){V[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 D(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 M(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 V.ERR_OUT_OF_RANGE("value",r,e)}!function(e,t,n){q(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||H(t,e.length-(n+1))}(r,o,s)}function q(e,t){if("number"!=typeof e)throw new V.ERR_INVALID_ARG_TYPE(t,"number",e)}function H(e,t,n){if(Math.floor(e)!==e)throw q(e,n),new V.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new V.ERR_BUFFER_OUT_OF_BOUNDS;throw new V.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}F("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),F("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),F("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=D(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=D(o)),o+="n"),r+=` It must be ${t}. Received ${o}`,r},RangeError);const G=/[^+/0-9A-Za-z-_]/g;function $(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 X(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(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 W(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Z(e){return e!=e}const z=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?Y:e}function Y(){throw new Error("BigInt not supported")}}(ce)),ce);function me(e,t,n=""){const r=(o=e)instanceof Uint8Array||ArrayBuffer.isView(o)&&"Uint8Array"===o.constructor.name&&"BYTES_PER_ELEMENT"in o&&1===o.BYTES_PER_ELEMENT;var o;const s=e?.length;if(!r||void 0!==t){const t=(n&&`"${n}" `)+"expected Uint8Array"+""+", got "+(r?`length=${s}`:"type="+typeof e);if(!r)throw new TypeError(t);throw new RangeError(t)}return e}function ge(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ye(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function we(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ae(e,t){return e<<32-t|e>>>t}function Se(e,t={}){const n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}const be=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ve(e,t,n){return e&t^~e&n}function Te(e,t,n){return e&t^e&n^t&n}class Ee{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=we(this.buffer)}update(e){ge(this),me(e);const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i===r){const t=we(e);for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ge(this),function(e,t){me(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new RangeError('"digestInto() output" expected to be of length >='+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,ye(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(8*this.length),o),this.process(n,0);const i=we(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)i.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=i,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ce=BigInt(2**32-1),Be=BigInt(32);function xe(e,t=!1){return t?{h:Number(e&Ce),l:Number(e>>Be&Ce)}:{h:0|Number(e>>Be&Ce),l:0|Number(e&Ce)}}const Re=(e,t,n)=>e>>>n,_e=(e,t,n)=>e<<32-n|t>>>n,Pe=(e,t,n)=>e>>>n|t<<32-n,Oe=(e,t,n)=>e<<32-n|t>>>n,Ue=(e,t,n)=>e<<64-n|t>>>n-32,Le=(e,t,n)=>e>>>n-32|t<<64-n;function Ne(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}const Ve=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Fe=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,De=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Me=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,qe=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),He=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,Ge=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$e=new Uint32Array(64);class Xe extends Ee{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)$e[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=$e[e-15],n=$e[e-2],r=Ae(t,7)^Ae(t,18)^t>>>3,o=Ae(n,17)^Ae(n,19)^n>>>10;$e[e]=o+$e[e-7]+r+$e[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Ae(i,6)^Ae(i,11)^Ae(i,25))+ve(i,a,c)+Ge[e]+$e[e]|0,l=(Ae(n,2)^Ae(n,13)^Ae(n,22))+Te(n,r,o)|0;u=c,c=a,a=i,i=s+t|0,s=o,o=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,s,i,a,c,u)}roundClean(){ye($e)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ye(this.buffer)}}class Ke extends Xe{A=0|ke[0];B=0|ke[1];C=0|ke[2];D=0|ke[3];E=0|ke[4];F=0|ke[5];G=0|ke[6];H=0|ke[7];constructor(){super(32)}}const We=(()=>function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:i}=xe(e[s],t);[r[s],o[s]]=[n,i]}return[r,o]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),Ze=(()=>We[0])(),ze=(()=>We[1])(),je=new Uint32Array(80),Ye=new Uint32Array(80);class Je extends Ee{constructor(e){super(128,e,16,!1)}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:l,Fl:d,Gh:p,Gl:h,Hh:f,Hl:m}=this;return[e,t,n,r,o,s,i,a,c,u,l,d,p,h,f,m]}set(e,t,n,r,o,s,i,a,c,u,l,d,p,h,f,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|d,this.Gh=0|p,this.Gl=0|h,this.Hh=0|f,this.Hl=0|m}process(e,t){for(let n=0;n<16;n++,t+=4)je[n]=e.getUint32(t),Ye[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|je[e-15],n=0|Ye[e-15],r=Pe(t,n,1)^Pe(t,n,8)^Re(t,0,7),o=Oe(t,n,1)^Oe(t,n,8)^_e(t,n,7),s=0|je[e-2],i=0|Ye[e-2],a=Pe(s,i,19)^Ue(s,i,61)^Re(s,0,6),c=Oe(s,i,19)^Le(s,i,61)^_e(s,i,6),u=De(o,c,Ye[e-7],Ye[e-16]),l=Me(u,r,a,je[e-7],je[e-16]);je[e]=0|l,Ye[e]=0|u}let{Ah:n,Al:r,Bh:o,Bl:s,Ch:i,Cl:a,Dh:c,Dl:u,Eh:l,El:d,Fh:p,Fl:h,Gh:f,Gl:m,Hh:g,Hl:y}=this;for(let e=0;e<80;e++){const t=Pe(l,d,14)^Pe(l,d,18)^Ue(l,d,41),w=Oe(l,d,14)^Oe(l,d,18)^Le(l,d,41),A=l&p^~l&f,S=qe(y,w,d&h^~d&m,ze[e],Ye[e]),b=He(S,g,t,A,Ze[e],je[e]),v=0|S,T=Pe(n,r,28)^Ue(n,r,34)^Ue(n,r,39),E=Oe(n,r,28)^Le(n,r,34)^Le(n,r,39),k=n&o^n&i^o&i,I=r&s^r&a^s&a;g=0|f,y=0|m,f=0|p,m=0|h,p=0|l,h=0|d,({h:l,l:d}=Ne(0|c,0|u,0|b,0|v)),c=0|i,u=0|a,i=0|o,a=0|s,o=0|n,s=0|r;const C=Ve(v,E,I);n=Fe(C,b,T,k),r=0|C}({h:n,l:r}=Ne(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:s}=Ne(0|this.Bh,0|this.Bl,0|o,0|s)),({h:i,l:a}=Ne(0|this.Ch,0|this.Cl,0|i,0|a)),({h:c,l:u}=Ne(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:d}=Ne(0|this.Eh,0|this.El,0|l,0|d)),({h:p,l:h}=Ne(0|this.Fh,0|this.Fl,0|p,0|h)),({h:f,l:m}=Ne(0|this.Gh,0|this.Gl,0|f,0|m)),({h:g,l:y}=Ne(0|this.Hh,0|this.Hl,0|g,0|y)),this.set(n,r,o,s,i,a,c,u,l,d,p,h,f,m,g,y)}roundClean(){ye(je,Ye)}destroy(){this.destroyed=!0,ye(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Qe extends Je{Ah=0|Ie[0];Al=0|Ie[1];Bh=0|Ie[2];Bl=0|Ie[3];Ch=0|Ie[4];Cl=0|Ie[5];Dh=0|Ie[6];Dl=0|Ie[7];Eh=0|Ie[8];El=0|Ie[9];Fh=0|Ie[10];Fl=0|Ie[11];Gh=0|Ie[12];Gl=0|Ie[13];Hh=0|Ie[14];Hl=0|Ie[15];constructor(){super(64)}}const et=Se(()=>new Ke,be(1)),tt=Se(()=>new Qe,be(3));function nt(e){const t="string"==typeof e?fe.Buffer.from(e,"utf8"):e;return fe.Buffer.from(et(t))}
|
|
199
|
-
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const rt=Object.freeze({p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n}),{p:ot,n:st,Gx:it,Gy:at,a:ct,d:ut,h:lt}=rt,dt=32,pt=(e="")=>{const t=new Error(e);throw((...e)=>{"captureStackTrace"in Error&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(...e)})(t,pt),t},ht=(e,t,n="")=>{const r=(o=e)instanceof Uint8Array||ArrayBuffer.isView(o)&&"Uint8Array"===o.constructor.name&&"BYTES_PER_ELEMENT"in o&&1===o.BYTES_PER_ELEMENT;var o;const s=e?.length,i=void 0!==t;if(!r||i&&s!==t){const o=(n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(r?`length=${s}`:"type="+typeof e);throw r?new RangeError(o):new TypeError(o)}return e},ft=e=>new Uint8Array(e),mt=e=>Uint8Array.from(e),gt=(e,t)=>e.toString(16).padStart(t,"0"),yt=e=>Array.from(ht(e)).map(e=>gt(e,2)).join(""),wt=48,At=57,St=65,bt=70,vt=97,Tt=102,Et=e=>e>=wt&&e<=At?e-wt:e>=St&&e<=bt?e-(St-10):e>=vt&&e<=Tt?e-(vt-10):void 0,kt=e=>{const t="hex invalid";if("string"!=typeof e)return pt(t);const n=e.length,r=n/2;if(n%2)return pt(t);const o=ft(r);for(let n=0,s=0;n<r;n++,s+=2){const r=Et(e.charCodeAt(s)),i=Et(e.charCodeAt(s+1));if(void 0===r||void 0===i)return pt(t);o[n]=16*r+i}return o},It=()=>globalThis?.crypto,Ct=(...e)=>{let t=0;for(const n of e)t+=ht(n).length;const n=ft(t);let r=0;return e.forEach(e=>{n.set(e,r),r+=e.length}),n},Bt=BigInt,xt=(e,t,n,r="bad number: out of range")=>{if(!(e=>"bigint"==typeof e)(e))throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},Rt=(e,t=ot)=>{const n=e%t;return n>=0n?n:t+n},_t=(1n<<255n)-1n,Pt=e=>{e<0n&&pt("negative coordinate");let t=19n*(e>>255n)+(e&_t);return t=19n*(t>>255n)+(t&_t),t%ot},Ot=e=>Rt(e,st),Ut=e=>{const t=en[e];return"function"!=typeof t&&pt("hashes."+e+" not set"),t},Lt=e=>ht(e,64,"digest"),Nt=e=>e instanceof Ft?e:pt("Point expected"),Vt=2n**256n;class Ft{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){const o=Vt;this.X=xt(e,0n,o),this.Y=xt(t,0n,o),this.Z=xt(n,1n,o),this.T=xt(r,0n,o),Object.freeze(this)}static CURVE(){return rt}static fromAffine(e){return new Ft(e.x,e.y,1n,Pt(e.x*e.y))}static fromBytes(e,t=!1){const n=ut,r=mt(ht(e,dt)),o=e[31];r[31]=-129&o;const s=Ht(r);xt(s,0n,t?Vt:ot);const i=Pt(s*s),a=Rt(i-1n),c=Pt(n*i+1n);let{isValid:u,value:l}=Xt(a,c);u||pt("bad point: y not sqrt");const d=1n==(1n&l),p=!!(128&o);return!t&&0n===l&&p&&pt("bad point: x==0, isLastByteOdd"),p!==d&&(l=Rt(-l)),new Ft(l,s,1n,Pt(l*s))}static fromHex(e,t){return Ft.fromBytes(kt(e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=ct,t=ut;if(this.is0())return pt("bad point: ZERO");const{X:n,Y:r,Z:o,T:s}=this,i=Pt(n*n),a=Pt(r*r),c=Pt(o*o),u=Pt(c*c),l=Pt(i*e);if(Pt(c*(l+a))!==Rt(u+Pt(t*Pt(i*a))))return pt("bad point: equation left != right (1)");return Pt(n*r)!==Pt(o*s)?pt("bad point: equation left != right (2)"):this}equals(e){const{X:t,Y:n,Z:r}=this,{X:o,Y:s,Z:i}=Nt(e),a=Pt(t*i),c=Pt(o*r),u=Pt(n*i),l=Pt(s*r);return a===c&&u===l}is0(){return this.equals(Mt)}negate(){return new Ft(Rt(-this.X),this.Y,this.Z,Rt(-this.T))}double(){const{X:e,Y:t,Z:n}=this,r=ct,o=Pt(e*e),s=Pt(t*t),i=Pt(2n*n*n),a=Pt(r*o),c=Rt(e+t),u=Rt(Pt(c*c)-o-s),l=Rt(a+s),d=Rt(l-i),p=Rt(a-s),h=Pt(u*d),f=Pt(l*p),m=Pt(u*p),g=Pt(d*l);return new Ft(h,f,g,m)}add(e){const{X:t,Y:n,Z:r,T:o}=this,{X:s,Y:i,Z:a,T:c}=Nt(e),u=ct,l=ut,d=Pt(t*s),p=Pt(n*i),h=Pt(Pt(o*l)*c),f=Pt(r*a),m=Rt(Pt(Rt(t+n)*Rt(s+i))-d-p),g=Rt(f-h),y=Rt(f+h),w=Rt(p-Pt(u*d)),A=Pt(m*g),S=Pt(y*w),b=Pt(m*w),v=Pt(g*y);return new Ft(A,S,v,b)}subtract(e){return this.add(Nt(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return Mt;if(xt(e,1n,st),!t&&this.is0())return Mt;if(1n===e)return this;if(this.equals(Dt))return sn(e).p;let n=Mt,r=Dt;for(let o=this;e>0n;o=o.double(),e>>=1n)1n&e?n=n.add(o):t&&(r=r.add(o));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:n}=this;if(this.equals(Mt))return{x:0n,y:1n};const r=((e,t)=>{(0n===e||t<=0n)&&pt("no inverse n="+e+" mod="+t);let n=Rt(e,t),r=t,o=0n,s=1n;for(;0n!==n;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}return 1n===r?Rt(o,t):pt("no inverse")})(n,ot);1n!==Pt(n*r)&&pt("invalid inverse");return{x:Pt(e*r),y:Pt(t*r)}}toBytes(){const{x:e,y:t}=this.toAffine(),n=qt(t);return n[31]|=1n&e?128:0,n}toHex(){return yt(this.toBytes())}clearCofactor(){return this.multiply(Bt(lt),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(st/2n,!1).double();return st%2n&&(e=e.add(this)),e.is0()}}const Dt=new Ft(it,at,1n,Rt(it*at)),Mt=new Ft(0n,1n,1n,0n);Ft.BASE=Dt,Ft.ZERO=Mt;const qt=e=>kt(gt(xt(e,0n,Vt),64)).reverse(),Ht=e=>Bt("0x"+yt(mt(ht(e)).reverse())),Gt=(e,t)=>{let n=e;for(;t-- >0n;)n=Pt(n*n);return n},$t=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Xt=(e,t)=>{const n=Pt(t*Pt(t*t)),r=Pt(Pt(n*n)*t),o=(e=>{const t=Pt(e*e),n=Pt(t*e),r=Pt(Gt(n,2n)*n),o=Pt(Gt(r,1n)*e),s=Pt(Gt(o,5n)*o),i=Pt(Gt(s,10n)*s),a=Pt(Gt(i,20n)*i),c=Pt(Gt(a,40n)*a),u=Pt(Gt(c,80n)*c),l=Pt(Gt(u,80n)*c),d=Pt(Gt(l,10n)*s);return{pow_p_5_8:Pt(Gt(d,2n)*e),b2:n}})(Pt(e*r)).pow_p_5_8;let s=Pt(e*Pt(n*o));const i=Pt(t*Pt(s*s)),a=s,c=Pt(s*$t),u=i===e,l=i===Rt(-e),d=i===Rt(-e*$t);return u&&(s=a),(l||d)&&(s=c),1n==(1n&Rt(s))&&(s=Rt(-s)),{isValid:u||l,value:s}},Kt=e=>Ot(Ht(e)),Wt=(...e)=>Lt(Ut("sha512")(Ct(...e))),Zt=e=>{const t=mt(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;const r=t.slice(32,64),o=Kt(n),s=Dt.multiply(o),i=s.toBytes();return{head:n,prefix:r,scalar:o,point:s,pointBytes:i}},zt=e=>Zt(Wt(ht(e,dt))),jt=e=>e.finish(Wt(e.hashable)),Yt=(e,t)=>{const n=ht(e),r=zt(t),o=Wt(r.prefix,n);return jt(((e,t,n)=>{const{pointBytes:r,scalar:o}=e,s=Kt(t),i=Dt.multiply(s).toBytes();return{hashable:Ct(i,r,n),finish:e=>{const t=Ot(s+Kt(e)*o);return ht(Ct(i,qt(t)),64)}}})(r,o,n))},Jt={zip215:!0},Qt=(e,t,n,r=Jt)=>jt(((e,t,n,r=Jt)=>{e=ht(e,64),t=ht(t),n=ht(n,dt);const{zip215:o=!0}=r,s=e.subarray(0,dt),i=Ht(e.subarray(dt,64));let a,c,u,l=Uint8Array.of(),d=!1;try{a=Ft.fromBytes(n,o),c=Ft.fromBytes(s,o),u=Dt.multiply(i,!1),l=Ct(s,n,t),d=!0}catch(e){}return{hashable:l,finish:e=>{if(!d)return!1;if(!o&&a.isSmallOrder())return!1;const t=Kt(e);return c.add(a.multiply(t,!1)).subtract(u).clearCofactor().is0()}}})(e,t,n,r)),en={sha512Async:async e=>{const t=It()?.subtle??pt("crypto.subtle must be defined, consider polyfill"),n=Ct(e);return ft(await t.digest("SHA-512",n.buffer))},sha512:void 0},tn=Object.freeze({getExtendedPublicKeyAsync:e=>((...e)=>Promise.resolve(Ut("sha512Async")(Ct(...e))).then(Lt))(ht(e,dt)).then(Zt),getExtendedPublicKey:zt,randomSecretKey:e=>(e=void 0===e?((e=dt)=>It().getRandomValues(ft(e)))(dt):e,ht(e,dt))}),nn=Math.ceil(32)+1;let rn;const on=(e,t)=>{const n=t.negate();return e?n:t},sn=e=>{const t=rn||(rn=(()=>{const e=[];let t=Dt,n=t;for(let r=0;r<nn;r++){n=t,e.push(n);for(let r=1;r<128;r++)n=n.add(t),e.push(n);t=n.double()}return e})());let n=Mt,r=Dt;const o=Bt(255),s=Bt(8);for(let i=0;i<nn;i++){let a=Number(e&o);e>>=s,a>128&&(a-=256,e+=1n);const c=128*i,u=c,l=c+Math.abs(a)-1,d=i%2!=0,p=a<0;0===a?r=r.add(on(d,t[u])):n=n.add(on(p,t[l]))}return 0n!==e&&pt("invalid wnaf"),{p:n,f:r}};function an(e){return fe.Buffer.from(zt(e).pointBytes)}function cn(e,t){return fe.Buffer.from(Yt(fe.Buffer.from(e),t))}function un(e,t,n){return Qt(fe.Buffer.from(t),fe.Buffer.from(e),fe.Buffer.from(n),{zip215:!1})}en.sha512=tt;const ln=(e,t)=>{const n="number"==typeof e;let r=String(e);for(;r.endsWith(t);)r=r.slice(0,-1);return n?Number(r):r};var dn,pn={};var hn=(dn||(dn=1,function(e){var t=function(e,t){return t||(t={}),e.split("").forEach(function(e,n){e in t||(t[e]=n)}),t},n={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",charmap:{0:14,1:8}};n.charmap=t(n.alphabet,n.charmap);var r={alphabet:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",charmap:{O:0,I:1,L:1}};r.charmap=t(r.alphabet,r.charmap);var o={alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",charmap:{}};function s(t){if(this.buf=[],this.shift=8,this.carry=0,t){switch(t.type){case"rfc4648":this.charmap=e.rfc4648.charmap;break;case"crockford":this.charmap=e.crockford.charmap;break;case"base32hex":this.charmap=e.base32hex.charmap;break;default:throw new Error("invalid type")}t.charmap&&(this.charmap=t.charmap)}}function i(t){if(this.buf="",this.shift=3,this.carry=0,t){switch(t.type){case"rfc4648":this.alphabet=e.rfc4648.alphabet;break;case"crockford":this.alphabet=e.crockford.alphabet;break;case"base32hex":this.alphabet=e.base32hex.alphabet;break;default:throw new Error("invalid type")}t.alphabet?this.alphabet=t.alphabet:t.lc&&(this.alphabet=this.alphabet.toLowerCase())}}o.charmap=t(o.alphabet,o.charmap),s.prototype.charmap=n.charmap,s.prototype.write=function(e){var t=this.charmap,n=this.buf,r=this.shift,o=this.carry;return e.toUpperCase().split("").forEach(function(e){if("="!=e){var s=255&t[e];(r-=5)>0?o|=s<<r:r<0?(n.push(o|s>>-r),o=s<<(r+=8)&255):(n.push(o|s),r=8,o=0)}}),this.shift=r,this.carry=o,this},s.prototype.finalize=function(e){return e&&this.write(e),8!==this.shift&&0!==this.carry&&(this.buf.push(this.carry),this.shift=8,this.carry=0),this.buf},i.prototype.alphabet=n.alphabet,i.prototype.write=function(e){var t,n,r,o=this.shift,s=this.carry;for(r=0;r<e.length;r++)t=s|(n=e[r])>>o,this.buf+=this.alphabet[31&t],o>5&&(t=n>>(o-=5),this.buf+=this.alphabet[31&t]),s=n<<(o=5-o),o=8-o;return this.shift=o,this.carry=s,this},i.prototype.finalize=function(e){return e&&this.write(e),3!==this.shift&&(this.buf+=this.alphabet[31&this.carry],this.shift=3,this.carry=0),this.buf},e.encode=function(e,t){return new i(t).finalize(e)},e.decode=function(e,t){return new s(t).finalize(e)},e.Decoder=s,e.Encoder=i,e.charmap=t,e.crockford=r,e.rfc4648=n,e.base32hex=o}(pn)),pn),fn=te(hn);const mn={ed25519PublicKey:48,ed25519SecretSeed:144,med25519PublicKey:96,preAuthTx:152,sha256Hash:184,signedPayload:120,contract:16,liquidityPool:88,claimableBalance:8},gn={G:"ed25519PublicKey",S:"ed25519SecretSeed",M:"med25519PublicKey",T:"preAuthTx",X:"sha256Hash",P:"signedPayload",C:"contract",L:"liquidityPool",B:"claimableBalance"};function yn(e){return Object.prototype.hasOwnProperty.call(mn,e)}class wn{static types=gn;static encodeEd25519PublicKey(e){return bn("ed25519PublicKey",e)}static decodeEd25519PublicKey(e){return Sn("ed25519PublicKey",e)}static isValidEd25519PublicKey(e){return An("ed25519PublicKey",e)}static encodeEd25519SecretSeed(e){return bn("ed25519SecretSeed",e)}static decodeEd25519SecretSeed(e){return Sn("ed25519SecretSeed",e)}static isValidEd25519SecretSeed(e){return An("ed25519SecretSeed",e)}static encodeMed25519PublicKey(e){return bn("med25519PublicKey",e)}static decodeMed25519PublicKey(e){return Sn("med25519PublicKey",e)}static isValidMed25519PublicKey(e){return An("med25519PublicKey",e)}static encodePreAuthTx(e){return bn("preAuthTx",e)}static decodePreAuthTx(e){return Sn("preAuthTx",e)}static encodeSha256Hash(e){return bn("sha256Hash",e)}static decodeSha256Hash(e){return Sn("sha256Hash",e)}static encodeSignedPayload(e){return bn("signedPayload",e)}static decodeSignedPayload(e){return Sn("signedPayload",e)}static isValidSignedPayload(e){return An("signedPayload",e)}static encodeContract(e){return bn("contract",e)}static decodeContract(e){return Sn("contract",e)}static isValidContract(e){return An("contract",e)}static encodeClaimableBalance(e){return bn("claimableBalance",e)}static decodeClaimableBalance(e){return Sn("claimableBalance",e)}static isValidClaimableBalance(e){return An("claimableBalance",e)}static encodeLiquidityPool(e){return bn("liquidityPool",e)}static decodeLiquidityPool(e){return Sn("liquidityPool",e)}static isValidLiquidityPool(e){return An("liquidityPool",e)}static getVersionByteForPrefix(e){if(e.length<1)return;const t=e[0];return gn[t]}}function An(e,t){if("string"!=typeof t)return!1;switch(e){case"ed25519PublicKey":case"ed25519SecretSeed":case"preAuthTx":case"sha256Hash":case"contract":case"liquidityPool":if(56!==t.length)return!1;break;case"claimableBalance":if(58!==t.length)return!1;break;case"med25519PublicKey":if(69!==t.length)return!1;break;case"signedPayload":if(t.length<56||t.length>165)return!1;break;default:return!1}let n;try{n=Sn(e,t)}catch{return!1}switch(e){case"ed25519PublicKey":case"ed25519SecretSeed":case"preAuthTx":case"sha256Hash":case"contract":case"liquidityPool":return 32===n.length;case"claimableBalance":return 33===n.length;case"med25519PublicKey":return 40===n.length;case"signedPayload":return n.length>=40&&n.length<=100;default:return!1}}function Sn(e,t){if("string"!=typeof t)throw new TypeError("encoded argument must be of type String");const n=fn.decode(t),r=n[0],o=n.slice(0,-2),s=o.slice(1),i=n.slice(-2);if(t!==fn.encode(n))throw new Error("invalid encoded string");if(!yn(e))throw new Error(`${e} is not a valid version byte name. Expected one of ${Object.keys(mn).join(", ")}`);const a=mn[e];if(r!==a)throw new Error(`invalid version byte. expected ${a}, got ${r}`);if(!function(e,t){if(e.length!==t.length)return!1;if(0===e.length)return!0;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}(vn(o),i))throw new Error("invalid checksum");return fe.Buffer.from(s)}function bn(e,t){if(null==t)throw new Error("cannot encode null data");if(!yn(e))throw new Error(`${e} is not a valid version byte name. Expected one of ${Object.keys(mn).join(", ")}`);const n=mn[e];t=fe.Buffer.from(t);const r=fe.Buffer.from([n]),o=fe.Buffer.concat([r,t]),s=fe.Buffer.from(vn(o)),i=fe.Buffer.concat([o,s]);return fn.encode(i)}function vn(e){const t=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];let n=0;for(let r=0;r<e.length;r+=1){const o=e[r];if(void 0===o)continue;n=n<<8^(t[n>>8^o]??0),n&=65535}const r=new Uint8Array(2);return r[0]=255&n,r[1]=n>>8&255,r}en.sha512=tt;class Tn{type;_publicKey;_secretSeed;_secretKey;constructor(e){if("ed25519"!==e.type)throw new Error("Invalid keys type");if(this.type=e.type,"secretKey"in e){if(e.secretKey=fe.Buffer.from(e.secretKey),32!==e.secretKey.length)throw new Error("secretKey length is invalid");if(this._secretSeed=e.secretKey,this._publicKey=an(e.secretKey),this._secretKey=e.secretKey,e.publicKey&&!this._publicKey.equals(fe.Buffer.from(e.publicKey)))throw new Error("secretKey does not match publicKey")}else{if(!("publicKey"in e))throw new Error("At least one of publicKey or secretKey must be provided");if(this._publicKey=fe.Buffer.from(e.publicKey),32!==this._publicKey.length)throw new Error("publicKey length is invalid")}}static fromSecret(e){const t=wn.decodeEd25519SecretSeed(e);return this.fromRawEd25519Seed(t)}static fromRawEd25519Seed(e){return new this({type:"ed25519",secretKey:e})}static master(e){if(!e)throw new Error("No network selected. Please pass a network argument, e.g. `Keypair.master(Networks.PUBLIC)`.");return this.fromRawEd25519Seed(nt(e))}static fromPublicKey(e){const t=wn.decodeEd25519PublicKey(e);if(32!==t.length)throw new Error("Invalid Stellar public key");return new this({type:"ed25519",publicKey:t})}static random(){const e=tn.randomSecretKey();return this.fromRawEd25519Seed(fe.Buffer.from(e))}xdrAccountId(){return se.PublicKey.publicKeyTypeEd25519(this._publicKey)}xdrPublicKey(){return se.PublicKey.publicKeyTypeEd25519(this._publicKey)}xdrMuxedAccount(e){if(void 0!==e){if("string"!=typeof e)throw new TypeError("expected string for ID, got "+typeof e);return se.MuxedAccount.keyTypeMuxedEd25519(new se.MuxedAccountMed25519({id:se.Uint64.fromString(e),ed25519:this._publicKey}))}return se.MuxedAccount.keyTypeEd25519(this._publicKey)}rawPublicKey(){return this._publicKey}signatureHint(){const e=this.xdrAccountId().toXDR();return e.subarray(e.length-4)}publicKey(){return wn.encodeEd25519PublicKey(this._publicKey)}secret(){if(!this._secretSeed)throw new Error("no secret key available");if("ed25519"===this.type)return wn.encodeEd25519SecretSeed(this._secretSeed);throw new Error("Invalid Keypair type")}rawSecretKey(){if(!this._secretSeed)throw new Error("no secret seed available");return this._secretSeed}canSign(){return!!this._secretKey}sign(e){if(!this._secretKey)throw new Error("cannot sign: no secret key available");return cn(e,this._secretKey)}verify(e,t){try{return un(e,t,this._publicKey)}catch{return!1}}signDecorated(e){const t=this.sign(e),n=this.signatureHint();return new se.DecoratedSignature({hint:n,signature:t})}signPayloadDecorated(e){const t=fe.Buffer.isBuffer(e)?e:fe.Buffer.from(e),n=this.sign(t),r=this.signatureHint();let o=fe.Buffer.from(t.subarray(-4));o.length<4&&(o=fe.Buffer.concat([o,fe.Buffer.alloc(4-o.length,0)]));for(let e=0;e<o.length;e++)o[e]=o[e]^r[e];return new se.DecoratedSignature({hint:o,signature:n})}}const En={native:"native",credit4:"credit_alphanum4",credit12:"credit_alphanum12",liquidityPoolShares:"liquidity_pool_shares"};function kn(e,t){return fe.Buffer.compare(fe.Buffer.from(e,"ascii"),fe.Buffer.from(t,"ascii"))}class In{code;issuer;constructor(e,t){if(!/^[a-zA-Z0-9]{1,12}$/.test(e))throw new Error("Asset code is invalid (maximum alphanumeric, 12 characters at max)");if("xlm"!==String(e).toLowerCase()&&!t)throw new Error("Issuer cannot be null");if(t&&!wn.isValidEd25519PublicKey(t))throw new Error("Issuer is invalid");"xlm"===String(e).toLowerCase()?this.code="XLM":this.code=e,this.issuer=t}static native(){return new In("XLM")}static fromOperation(e){let t,n,r;switch(e.switch()){case se.AssetType.assetTypeNative():return this.native();case se.AssetType.assetTypeCreditAlphanum4():return t=e.alphaNum4(),r=wn.encodeEd25519PublicKey(t.issuer().ed25519()),n=ln(t.assetCode().toString(),"\0"),new this(n,r);case se.AssetType.assetTypeCreditAlphanum12():return t=e.alphaNum12(),r=wn.encodeEd25519PublicKey(t.issuer().ed25519()),n=ln(t.assetCode().toString(),"\0"),new this(n,r);default:throw new Error(`Invalid asset type: ${e.switch().name}`)}}toXDRObject(){return this._toXDRObject(se.Asset)}toChangeTrustXDRObject(){return this._toXDRObject(se.ChangeTrustAsset)}toTrustLineXDRObject(){return this._toXDRObject(se.TrustLineAsset)}contractId(e){const t=nt(fe.Buffer.from(e)),n=se.HashIdPreimage.envelopeTypeContractId(new se.HashIdPreimageContractId({networkId:t,contractIdPreimage:se.ContractIdPreimage.contractIdPreimageFromAsset(this.toXDRObject())}));return wn.encodeContract(nt(n.toXDR()))}_toXDRObject(e){if(this.isNative())return e.assetTypeNative();if(!this.issuer)throw new Error("Issuer cannot be null for non-native asset");let t,n;this.code.length<=4?(t=se.AlphaNum4,n="assetTypeCreditAlphanum4"):(t=se.AlphaNum12,n="assetTypeCreditAlphanum12");const r=this.code.length<=4?4:12;return new e(n,new t({assetCode:this.code.padEnd(r,"\0"),issuer:Tn.fromPublicKey(this.issuer).xdrAccountId()}))}getCode(){return String(this.code)}getIssuer(){if(void 0!==this.issuer)return String(this.issuer)}getAssetType(){switch(this.getRawAssetType().value){case se.AssetType.assetTypeNative().value:return En.native;case se.AssetType.assetTypeCreditAlphanum4().value:return En.credit4;case se.AssetType.assetTypeCreditAlphanum12().value:return En.credit12;default:throw new Error("Supported asset types are: native, credit_alphanum4, credit_alphanum12")}}getRawAssetType(){return this.isNative()?se.AssetType.assetTypeNative():this.code.length<=4?se.AssetType.assetTypeCreditAlphanum4():se.AssetType.assetTypeCreditAlphanum12()}isNative(){return!this.issuer}equals(e){return this.code===e.getCode()&&this.issuer===e.getIssuer()}toString(){return this.isNative()?"native":`${this.getCode()}:${this.getIssuer()}`}static compare(e,t){if(!(e&&e instanceof In))throw new Error("assetA is invalid");if(!(t&&t instanceof In))throw new Error("assetB is invalid");if(e.equals(t))return 0;const n=e.getRawAssetType().value,r=t.getRawAssetType().value;if(n!==r)return n<r?-1:1;const o=kn(e.getCode(),t.getCode());if(0!==o)return o;const s=e.getIssuer(),i=t.getIssuer();if(void 0===s||void 0===i)throw new Error("Issuer is undefined for non-native asset");return kn(s,i)}}function Cn(e,t){if("constant_product"!==e)throw new Error("liquidityPoolType is invalid");const{assetA:n,assetB:r,fee:o}=t??{};if(!(n&&n instanceof In))throw new Error("assetA is invalid");if(!(r&&r instanceof In))throw new Error("assetB is invalid");if(!o||30!==o)throw new Error("fee is invalid");if(-1!==In.compare(n,r))throw new Error("Assets are not in lexicographic order");return nt(se.LiquidityPoolParameters.liquidityPoolConstantProduct(new se.LiquidityPoolConstantProductParameters({assetA:n.toXDRObject(),assetB:r.toXDRObject(),fee:o})).toXDR())}class Bn{_tx;_signatures;_fee;_networkPassphrase;constructor(e,t,n,r){if("string"!=typeof r)throw new Error("Invalid passphrase provided to Transaction: expected a string but got a "+typeof r);this._networkPassphrase=r,this._tx=e,this._signatures=t,this._fee=n}get signatures(){return this._signatures}set signatures(e){throw new Error("Transaction is immutable")}get tx(){const e=this._tx.toXDR();if(this._tx instanceof se.Transaction)return se.Transaction.fromXDR(e);if(this._tx instanceof se.TransactionV0)return se.TransactionV0.fromXDR(e);if(this._tx instanceof se.FeeBumpTransaction)return se.FeeBumpTransaction.fromXDR(e);throw new Error("Unknown transaction type")}set tx(e){throw new Error("Transaction is immutable")}get fee(){return this._fee}set fee(e){throw new Error("Transaction is immutable")}get networkPassphrase(){return this._networkPassphrase}set networkPassphrase(e){throw new Error("Transaction is immutable")}sign(...e){const t=this.hash();e.forEach(e=>{const n=e.signDecorated(t);this.signatures.push(n)})}getKeypairSignature(e){return e.sign(this.hash()).toString("base64")}addSignature(e="",t=""){if(!t||"string"!=typeof t)throw new Error("Invalid signature");if(!e||"string"!=typeof e)throw new Error("Invalid publicKey");let n,r;const o=fe.Buffer.from(t,"base64");try{n=Tn.fromPublicKey(e),r=n.signatureHint()}catch{throw new Error("Invalid publicKey")}if(!n.verify(this.hash(),o))throw new Error("Invalid signature");this.signatures.push(new se.DecoratedSignature({hint:r,signature:o}))}addDecoratedSignature(e){this.signatures.push(e)}signHashX(e){if("string"==typeof e&&(e=fe.Buffer.from(e,"hex")),e.length>64)throw new Error("preimage cannot be longer than 64 bytes");const t=e,n=nt(e),r=n.subarray(n.length-4);this.signatures.push(new se.DecoratedSignature({hint:r,signature:t}))}hash(){return nt(this.signatureBase())}signatureBase(){throw new Error("Implement in subclass")}toEnvelope(){throw new Error("Implement in subclass")}toXDR(){return this.toEnvelope().toXDR().toString("base64")}}class xn{assetA;assetB;fee;constructor(e,t,n){if(!(e&&e instanceof In))throw new Error("assetA is invalid");if(!(t&&t instanceof In))throw new Error("assetB is invalid");if(-1!==In.compare(e,t))throw new Error("Assets are not in lexicographic order");if(!n||30!==n)throw new Error("fee is invalid");this.assetA=e,this.assetB=t,this.fee=n}static fromOperation(e){const t=e.switch();if(t===se.AssetType.assetTypePoolShare()){const t=e.liquidityPool().constantProduct();return new this(In.fromOperation(t.assetA()),In.fromOperation(t.assetB()),t.fee())}throw new Error(`Invalid asset type: ${t.name}`)}toXDRObject(){const e=new se.LiquidityPoolConstantProductParameters({assetA:this.assetA.toXDRObject(),assetB:this.assetB.toXDRObject(),fee:this.fee}),t=se.LiquidityPoolParameters.liquidityPoolConstantProduct(e);return se.ChangeTrustAsset.assetTypePoolShare(t)}getLiquidityPoolParameters(){return{...this,assetA:this.assetA,assetB:this.assetB,fee:this.fee}}getAssetType(){return"liquidity_pool_shares"}equals(e){return this.assetA.equals(e.assetA)&&this.assetB.equals(e.assetB)&&this.fee===e.fee}toString(){return`liquidity_pool:${Cn("constant_product",this.getLiquidityPoolParameters()).toString("hex")}`}}class Rn{_destination;_predicate;constructor(e,t){if(!wn.isValidEd25519PublicKey(e))throw new Error("Destination is invalid");if(this._destination=e,t){if(!(t instanceof se.ClaimPredicate))throw new Error("Predicate should be an xdr.ClaimPredicate");this._predicate=t}else this._predicate=se.ClaimPredicate.claimPredicateUnconditional()}static predicateUnconditional(){return se.ClaimPredicate.claimPredicateUnconditional()}static predicateAnd(e,t){if(!(e instanceof se.ClaimPredicate))throw new Error("left Predicate should be an xdr.ClaimPredicate");if(!(t instanceof se.ClaimPredicate))throw new Error("right Predicate should be an xdr.ClaimPredicate");return se.ClaimPredicate.claimPredicateAnd([e,t])}static predicateOr(e,t){if(!(e instanceof se.ClaimPredicate))throw new Error("left Predicate should be an xdr.ClaimPredicate");if(!(t instanceof se.ClaimPredicate))throw new Error("right Predicate should be an xdr.ClaimPredicate");return se.ClaimPredicate.claimPredicateOr([e,t])}static predicateNot(e){if(!(e instanceof se.ClaimPredicate))throw new Error("Predicate should be an xdr.ClaimPredicate");return se.ClaimPredicate.claimPredicateNot(e)}static predicateBeforeAbsoluteTime(e){return se.ClaimPredicate.claimPredicateBeforeAbsoluteTime(se.Int64.fromString(e))}static predicateBeforeRelativeTime(e){return se.ClaimPredicate.claimPredicateBeforeRelativeTime(se.Int64.fromString(e))}static fromXDR(e){let t;if(e.switch()===se.ClaimantType.claimantTypeV0())return t=e.v0(),new this(wn.encodeEd25519PublicKey(t.destination().ed25519()),t.predicate());throw new Error(`Invalid claimant type: ${e.switch().name}`)}toXDRObject(){const e=new se.ClaimantV0({destination:Tn.fromPublicKey(this._destination).xdrAccountId(),predicate:this._predicate});return se.Claimant.claimantTypeV0(e)}get destination(){return this._destination}set destination(e){throw new Error("Claimant is immutable")}get predicate(){return this._predicate}set predicate(e){throw new Error("Claimant is immutable")}}class _n{liquidityPoolId;constructor(e){if(!e)throw new Error("liquidityPoolId cannot be empty");if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Liquidity pool ID is not a valid hash");this.liquidityPoolId=e}static fromOperation(e){const t=e.switch();if(t===se.AssetType.assetTypePoolShare()){const t=e.liquidityPoolId().toString("hex");return new _n(t)}throw new Error(`Invalid asset type: ${t.name}`)}toXDRObject(){const e=fe.Buffer.from(this.liquidityPoolId,"hex");return se.TrustLineAsset.assetTypePoolShare(e)}getLiquidityPoolId(){return String(this.liquidityPoolId)}getAssetType(){return"liquidity_pool_shares"}equals(e){return this.liquidityPoolId===e.getLiquidityPoolId()}toString(){return`liquidity_pool:${this.liquidityPoolId}`}}function Pn(e){return wn.isValidMed25519PublicKey(e)?function(e){const t=wn.decodeMed25519PublicKey(e);return se.MuxedAccount.keyTypeMuxedEd25519(new se.MuxedAccountMed25519({id:se.Uint64.fromXDR(t.subarray(-8)),ed25519:t.subarray(0,-8)}))}(e):se.MuxedAccount.keyTypeEd25519(wn.decodeEd25519PublicKey(e))}function On(e){return e.switch().value===se.CryptoKeyType.keyTypeMuxedEd25519().value?function(e){if(e.switch()===se.CryptoKeyType.keyTypeEd25519())return On(e);const t=e.med25519();return wn.encodeMed25519PublicKey(fe.Buffer.concat([t.ed25519(),t.id().toXDR("raw")]))}(e):wn.encodeEd25519PublicKey(e.ed25519())}function Un(e,t){if(!wn.isValidEd25519PublicKey(e))throw new Error("address should be a Stellar account ID (G...)");if("string"!=typeof t)throw new Error("id should be a string representing a number (uint64)");return se.MuxedAccount.keyTypeMuxedEd25519(new se.MuxedAccountMed25519({id:se.Uint64.fromString(t),ed25519:wn.decodeEd25519PublicKey(e)}))}function Ln(e){if(wn.isValidEd25519PublicKey(e))return e;if(!wn.isValidMed25519PublicKey(e))throw new TypeError(`expected muxed account (M...), got ${e}`);const t=Pn(e);return wn.encodeEd25519PublicKey(t.med25519().ed25519())}var Nn=function e(t){var n,r,o=/^(-?)0([xbo])(?=[^.])/i,s=/^-?(Infinity|NaN)$/,i=/^\s*\+(?!-)|^\s+|\s+$/g,a=b.prototype={constructor:b,toString:null,valueOf:null},c=new b(1),u=20,l=4,d=-7,p=21,h=-1e7,f=1e7,m=!1,g=!0,y=1,w=0,A={prefix:"",negativeSign:"-",positiveSign:"",groupSeparator:",",groupSize:3,secondaryGroupSize:0,decimalSeparator:".",fractionGroupSeparator:"",fractionGroupSize:0,suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz";function b(e,t){var n,r,a,c,u=this;if(!(u instanceof b))return new b(e,t);if(c=typeof e,null==t){if(k(e))return u.s=e.s,void(!e.c||e.e>f?u.c=u.e=null:e.e<h?u.c=[u.e=0]:(u.e=e.e,u.c=e.c.slice()));if("number"==c){if(0*e!=0)return u.s=isNaN(e)?null:e<0?-1:1,void(u.c=u.e=null);if(u.s=1/e<0?(e=-e,-1):1,e===~~e){for(n=0,r=e;r>=10;r/=10,n++);return void(n>f?u.c=u.e=null:(u.e=n,u.c=[e]))}return v(u,String(e))}if("bigint"==c)return u.s=e<0?(e=-e,-1):1,v(u,String(e));if("string"==c)a=e;else{if(g)throw Error(Mn+"BigNumber, string, number, or BigInt expected: "+e);a=String(e)}if(Vn.test(a))return u.s=45==a.charCodeAt(0)?(a=a.slice(1),-1):1,v(u,a);if(a=a.replace(i,""),s.test(a))return u.s=isNaN(a)?null:a<0?-1:1,void(u.c=u.e=null);if(a=a.replace(o,function(e,n,r){return t="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n}),t)return T(u,a,t,e);if(a=a.replace(/(\d)_(?=\d)/g,"$1"),Vn.test(a))return u.s=45==a.charCodeAt(0)?(a=a.slice(1),-1):1,v(u,a);if(g)throw Error(Mn+"Not a number: "+e);u.s=u.c=u.e=null}else{if("string"!=c){if(g)throw Error(Mn+"String expected: "+e);e=String(e)}jn(t,2,S.length,"Base"),T(u,e.replace(i,""),t,e)}}function v(e,t){var n,r,o;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(o=t.length;48===t.charCodeAt(--o););if(t=t.slice(r,++o))if(o-=r,(n=n-r-1)>f)e.c=e.e=null;else if(n<h)e.c=[e.e=0];else{if(e.e=n,e.c=[],r=(n+1)%Hn,n<0&&(r+=Hn),r<o){for(r&&e.c.push(+t.slice(0,r)),o-=Hn;r<o;)e.c.push(+t.slice(r,r+=Hn));r=Hn-(t=t.slice(r)).length}else r-=o;for(;r--;t+="0");e.c.push(+t)}else e.c=[e.e=0]}function T(e,t,n,o){var s,i,a=S.slice(0,n),c=0,u="",l=!1,d=!1,p=!1;for(e.s=45===t.charCodeAt(0)?(t=t.slice(1),-1):1,i=t.length;c<i;c++){if(s=t.charAt(c),!(a.indexOf(s)>=0)){if("_"==s){if(d&&c+1<i){d=!1;continue}}else if("."==s){if(0==c||!l&&d){if(c+1==i)break;0==c&&(u="0"),u+=s,l=!0,d=!1;continue}}else if(!p&&(t==t.toUpperCase()&&a==a.toLowerCase()&&(t=t.toLowerCase())||t==t.toLowerCase()&&a==a.toUpperCase()&&(t=t.toUpperCase()))){c=-1,u="",p=!0,l=d=!1;continue}if(g)throw Error(Mn+"Not a base "+n+" number: "+o);return void(e.s=e.c=e.e=null)}u+=s,d=!0}v(e,r(u,n,10,e.s))}function E(e,t,n,r){var o,s,i,a,c;if(n=null==n?l:jn(n,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)c=Zn(e.c),c=1==r||2==r&&(i<=d||i>=p)?Qn(c,i):er(c,i,"0");else if(s=(e=x(new b(e),t,n)).e,a=(c=Zn(e.c)).length,1==r||2==r&&(t<=s||s<=d)){for(;a<t;c+="0",a++);c=Qn(c,s)}else if(t-=i+(2===r&&s>i),c=er(c,s,"0"),s+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=s-a)>0)for(s+1==a&&(c+=".");t--;c+="0");return e.s<0&&o?"-"+c:c}function k(e){return e instanceof b||!!e&&!0===e._isBigNumber}function I(e,t){for(var n,r,o=1,s=new b(e[0]);o<e.length;o++)(!(r=new b(e[o])).s||(n=zn(s,r))===t||0===n&&s.s===t)&&(s=r);return s}function C(e,t,n){for(var r=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,r++);return(n=r+n*Hn-1)>f?e.c=e.e=null:n<h?e.c=[e.e=0]:(e.e=n,e.c=t),e}function B(e){var t,n={};for(t in A)A.hasOwnProperty(t)&&(n[t]=e.hasOwnProperty(t)?e[t]:A[t]);return n}function x(e,t,n,r){var o,s,i,a,c,u,l,d=e.c,p=$n;if(d){e:{for(o=1,a=d[0];a>=10;a/=10,o++);if((s=t-o)<0)s+=Hn,i=t,c=d[u=0],l=Dn(c/p[o-i-1]%10);else if((u=Fn((s+1)/Hn))>=d.length){if(!r)break e;for(;d.length<=u;d.push(0));c=l=0,o=1,i=(s%=Hn)-Hn+1}else{for(c=a=d[u],o=1;a>=10;a/=10,o++);l=(i=(s%=Hn)-Hn+o)<0?0:Dn(c/p[o-i-1]%10)}if(r=r||t<0||null!=d[u+1]||(i<0?c:c%p[o-i-1]),r=n<4?(l||r)&&(0==n||n==(e.s<0?3:2)):l>5||5==l&&(4==n||r||6==n&&(s>0?i>0?c/p[o-i]:0:d[u-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,r?(t-=e.e+1,d[0]=p[(Hn-t%Hn)%Hn],e.e=-t||0):d[0]=e.e=0,e;if(0==s?(d.length=u,a=1,u--):(d.length=u+1,a=p[Hn-s],d[u]=i>0?Dn(c/p[o-i]%p[i])*a:0),r)for(;;){if(0==u){for(s=1,i=d[0];i>=10;i/=10,s++);for(i=d[0]+=a,a=1;i>=10;i/=10,a++);s!=a&&(e.e++,d[0]==qn&&(d[0]=1));break}if(d[u]+=a,d[u]!=qn)break;d[u--]=0,a=1}for(s=d.length;0===d[--s];d.pop());}e.e>f?e.c=e.e=null:e.e<h&&(e.c=[e.e=0])}return e}function R(e){var t,n=e.e;return null===n?e.toString():(t=Zn(e.c),t=n<=d||n>=p?Qn(t,n):er(t,n,"0"),e.s<0?"-"+t:t)}b.clone=e,b.ROUND_UP=0,b.ROUND_DOWN=1,b.ROUND_CEIL=2,b.ROUND_FLOOR=3,b.ROUND_HALF_UP=4,b.ROUND_HALF_DOWN=5,b.ROUND_HALF_EVEN=6,b.ROUND_HALF_CEIL=7,b.ROUND_HALF_FLOOR=8,b.EUCLID=9,b.config=b.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(Mn+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(u=jn(e[t],0,Kn,t)),e.hasOwnProperty(t="ROUNDING_MODE")&&(l=jn(e[t],0,8,t)),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(Yn(n=e[t])?(jn(n[0],-Kn,0,t),jn(n[1],0,Kn,t),d=n[0],p=n[1]):d=-(p=jn(n,-Kn,Kn,t)<0?-n:n)),e.hasOwnProperty(t="RANGE")){if(!(n=e[t]))throw Error(Mn+t+" cannot be zero: "+n);Yn(n)?(jn(n[0],-Kn,-1,t),jn(n[1],1,Kn,t),h=n[0],f=n[1]):h=-(f=jn(n,-Kn,Kn,t)<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(Mn+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw m=!n,Error(Mn+"crypto unavailable");m=n}else m=n}if(e.hasOwnProperty(t="STRICT")){if((n=e[t])!==!!n)throw Error(Mn+t+" not true or false: "+n);g=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(y=jn(e[t],0,9,t)),e.hasOwnProperty(t="POW_PRECISION")&&(w=jn(e[t],0,Kn,t)),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(Mn+t+" not an object: "+n);for(t in n)n.hasOwnProperty(t)&&A.hasOwnProperty(t)&&(A[t]=n[t])}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(Mn+t+" invalid: "+n);S=n}}return{DECIMAL_PLACES:u,ROUNDING_MODE:l,EXPONENTIAL_AT:[d,p],RANGE:[h,f],CRYPTO:m,STRICT:g,MODULO_MODE:y,POW_PRECISION:w,FORMAT:A,ALPHABET:S}},b.fromFormat=function(e,t){if("string"!=typeof e)throw Error(Mn+"Not a string: "+e);if(null==t)t=A;else{if("object"!=typeof t)throw Error(Mn+"Argument not an object: "+t);t=B(t)}var n,r,o,s,i=t.negativeSign||"-",a=t.positiveSign||"",c=t.prefix||"",u=t.suffix||"",l=t.groupSeparator||"",d=t.decimalSeparator||".",p=t.fractionGroupSeparator||"";if(c&&0===e.indexOf(c)&&(e=e.slice(c.length)),u&&e.lastIndexOf(u)===e.length-u.length&&(e=e.slice(0,-u.length)),0===e.indexOf(i)?(e=e.slice(i.length),r=!0):a&&0===e.indexOf(a)&&(e=e.slice(a.length)),(n=e.indexOf(d))<0){if(l)for(;e.indexOf(l)>-1;)e=e.replace(l,"")}else{if(o=e.slice(0,n),s=e.slice(n+d.length),l)for(;o.indexOf(l)>-1;)o=o.replace(l,"");if(p)for(;s.indexOf(p)>-1;)s=s.replace(p,"");e=o+"."+s}return new b(r?"-"+e:e)},b.isBigNumber=function(e){if(!k(e))return!1;var t,n,r=e.c,o=e.e,s=e.s;if(!Yn(r))return null===r&&null===o&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||o<-Kn||o>Kn||o!==Dn(o))return!1;if(0===r[0])return 0===o&&1===r.length;if((t=(o+1)%Hn)<1&&(t+=Hn),String(r[0]).length!==t)return!1;for(t=0;t<r.length;t++)if((n=r[t])<0||n>=qn||n!==Dn(n))return!1;return 0!==n},b.maximum=b.max=function(){return I(arguments,-1)},b.minimum=b.min=function(){return I(arguments,1)},b.random=function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return Dn(Math.random()*e)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(e){var n,r,o,s,i,a=0,l=[],d=new b(c);if(e=null==e?u:jn(e,0,Kn),s=Fn(e/Hn),m)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));a<s;)(i=131072*n[a]+(n[a+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[a]=r[0],n[a+1]=r[1]):(l.push(i%1e14),a+=2);a=s/2}else{if(!crypto.randomBytes)throw m=!1,Error(Mn+"crypto unavailable");for(n=crypto.randomBytes(s*=7);a<s;)(i=281474976710656*(31&n[a])+1099511627776*n[a+1]+4294967296*n[a+2]+16777216*n[a+3]+(n[a+4]<<16)+(n[a+5]<<8)+n[a+6])>=9e15?crypto.randomBytes(7).copy(n,a):(l.push(i%1e14),a+=7);a=s/7}if(!m)for(;a<s;)(i=t())<9e15&&(l[a++]=i%1e14);for(s=l[--a],e%=Hn,s&&e&&(i=$n[Hn-e],l[a]=Dn(s/i)*i);0===l[a];l.pop(),a--);if(a<0)l=[o=0];else{for(o=-1;0===l[0];l.splice(0,1),o-=Hn);for(a=1,i=l[0];i>=10;i/=10,a++);a<Hn&&(o-=Hn-a)}return d.e=o,d.c=l,d}}(),b.sum=function(){for(var e=0,t=new b(0);e<arguments.length;)t=t.plus(arguments[e++]);return t},r=function(){var e="0123456789";function t(e,t,n,r){for(var o,s,i=[0],a=0,c=e.length;a<c;){for(s=i.length;s--;i[s]*=t);for(i[0]+=r.indexOf(e.charAt(a++)),o=0;o<i.length;o++)i[o]>n-1&&(null==i[o+1]&&(i[o+1]=0),i[o+1]+=i[o]/n|0,i[o]%=n)}return i.reverse()}return function(r,o,s,i,a){var c,d,p,h,f,m,g,y,A=r.indexOf("."),v=u,T=l;for(A>=0&&(h=w,w=0,r=r.replace(".",""),m=(y=new b(o)).pow(r.length-A),w=h,y.c=t(er(Zn(m.c),m.e,"0"),10,s,e),y.e=y.c.length),p=h=(g=t(r,o,s,a?(c=S,e):(c=e,S))).length;0==g[--h];g.pop());if(!g[0])return c.charAt(0);if(A<0?--p:(m.c=g,m.e=p,m.s=i,g=(m=n(m,y,v,T,s)).c,f=m.r,p=m.e),A=g[d=p+v+1],h=s/2,f=f||d<0||null!=g[d+1],f=T<4?(null!=A||f)&&(0==T||T==(m.s<0?3:2)):A>h||A==h&&(4==T||f||6==T&&1&g[d-1]||T==(m.s<0?8:7)),d<1||!g[0])r=f?er(c.charAt(1),-v,c.charAt(0)):c.charAt(0);else{if(d<g.length&&(g.length=d),f)for(--s;++g[--d]>s;)g[d]=0,d||(++p,g=[1].concat(g));for(h=g.length;!g[--h];);for(A=0,r="";A<=h;r+=c.charAt(g[A++]));r=er(r,p,c.charAt(0))}return r}}(),n=function(){function e(e,t,n){var r,o,s,i,a=0,c=e.length,u=t%Xn,l=t/Xn|0;for(e=e.slice();c--;)a=((o=u*(s=e[c]%Xn)+(r=l*s+(i=e[c]/Xn|0)*u)%Xn*Xn+a)/n|0)+(r/Xn|0)+l*i,e[c]=o%n;return a&&(e=[a].concat(e)),e}function t(e,t,n,r){var o,s;if(n!=r)s=n>r?1:-1;else for(o=s=0;o<n;o++)if(e[o]!=t[o]){s=e[o]>t[o]?1:-1;break}return s}function n(e,t,n,r){for(var o=0;n--;)e[n]-=o,o=e[n]<t[n]?1:0,e[n]=o*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,o,s,i,a){var c,u,l,d,p,h,f,m,g,y,w,A,S,v,T,E,k,I=r.s==o.s?1:-1,C=r.c,B=o.c;if(!(C&&C[0]&&B&&B[0]))return new b(r.s&&o.s&&(C?!B||C[0]!=B[0]:B)?C&&0==C[0]||!B?0*I:I/0:NaN);for(g=(m=new b(I)).c=[],I=s+(u=r.e-o.e)+1,a||(a=qn,u=Wn(r.e/Hn)-Wn(o.e/Hn),I=I/Hn|0),l=0;B[l]==(C[l]||0);l++);if(B[l]>(C[l]||0)&&u--,I<0)g.push(1),d=!0;else{for(v=C.length,E=B.length,l=0,I+=2,(p=Dn(a/(B[0]+1)))>1&&(B=e(B,p,a),C=e(C,p,a),E=B.length,v=C.length),S=E,w=(y=C.slice(0,E)).length;w<E;y[w++]=0);k=B.slice(),k=[0].concat(k),T=B[0],B[1]>=a/2&&T++;do{if(p=0,(c=t(B,y,E,w))<0){if(A=y[0],E!=w&&(A=A*a+(y[1]||0)),(p=Dn(A/T))>1)for(p>=a&&(p=a-1),f=(h=e(B,p,a)).length,w=y.length;1==t(h,y,f,w);)p--,n(h,E<f?k:B,f,a),f=h.length,c=1;else 0==p&&(c=p=1),f=(h=B.slice()).length;if(f<w&&(h=[0].concat(h)),n(y,h,w,a),w=y.length,-1==c)for(;t(B,y,E,w)<1;)p++,n(y,E<w?k:B,w,a),w=y.length}else 0===c&&(p++,y=[0]);g[l++]=p,y[0]?y[w++]=C[S]||0:(y=[C[S]],w=1)}while((S++<v||null!=y[0])&&I--);d=null!=y[0],g[0]||g.splice(0,1)}if(a==qn){for(l=1,I=g[0];I>=10;I/=10,l++);x(m,s+(m.e=l+u*Hn-1)+1,i,d)}else m.e=u,m.r=+d;return m}}(),a.absoluteValue=a.abs=function(){var e=new b(this);return e.s<0&&(e.s=1),e},a.comparedTo=function(e,t){return zn(this,new b(e,t))},a.decimalPlaces=a.dp=function(e,t){var n,r,o,s=this;if(null!=e)return x(new b(s),jn(e,-Kn,Kn)+s.e+1,null==t?l:jn(t,0,8));if(!(n=s.c))return null;if(r=((o=n.length-1)-Wn(this.e/Hn))*Hn,o=n[o])for(;o%10==0;o/=10,r--);return r<0&&(r=0),r},a.dividedBy=a.div=function(e,t){return n(this,new b(e,t),u,l)},a.dividedToIntegerBy=a.idiv=function(e,t){return n(this,new b(e,t),0,1)},a.exponentiatedBy=a.pow=function(e,t){var n,r,o,s,i,a,u,d,p=this;if((e=new b(e)).c&&!e.isInteger())throw Error(Mn+"Exponent not an integer: "+R(e));if(null!=t&&(t=new b(t)),i=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return d=new b(Math.pow(+R(p),i?e.s*(2-Jn(e)):+R(e))),t?d.mod(t):d;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new b(NaN);(r=!a&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||i&&p.c[1]>=24e7:p.c[0]<8e13||i&&p.c[0]<=9999975e7)))return s=p.s<0&&Jn(e)?-0:0,p.e>-1&&(s=1/s),new b(a?1/s:s);w&&(s=Fn(w/Hn+2))}for(i?(n=new b(.5),a&&(e.s=1),u=Jn(e)):u=(o=Math.abs(+R(e)))%2,d=new b(c);;){if(u){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):r&&(d=d.mod(t))}if(o){if(0===(o=Dn(o/2)))break;u=o%2}else if(x(e=e.times(n),e.e+1,1),e.e>14)u=Jn(e);else{if(0===(o=+R(e)))break;u=o%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):r&&(p=p.mod(t))}return r?d:(a&&(d=c.div(d)),t?d.mod(t):s?x(d,w,l,void 0):d)},a.integerValue=function(e){var t=new b(this);return x(t,t.e+1,null==e?l:jn(e,0,8))},a.isEqualTo=a.eq=function(e,t){return 0===zn(this,new b(e,t))},a.isFinite=function(){return!!this.c},a.isGreaterThan=a.gt=function(e,t){return zn(this,new b(e,t))>0},a.isGreaterThanOrEqualTo=a.gte=function(e,t){return 1===(t=zn(this,new b(e,t)))||0===t},a.isInteger=function(){return!!this.c&&Wn(this.e/Hn)>this.c.length-2},a.isLessThan=a.lt=function(e,t){return zn(this,new b(e,t))<0},a.isLessThanOrEqualTo=a.lte=function(e,t){return-1===(t=zn(this,new b(e,t)))||0===t},a.isNaN=function(){return!this.s},a.isNegative=function(){return this.s<0},a.isPositive=function(){return this.s>0},a.isZero=function(){return!!this.c&&0==this.c[0]},a.minus=function(e,t){var n,r,o,s,i=this,a=i.s;if(t=(e=new b(e,t)).s,!a||!t)return new b(NaN);if(a!=t)return e.s=-t,i.plus(e);var c=i.e/Hn,u=e.e/Hn,d=i.c,p=e.c;if(!c||!u){if(!d||!p)return d?(e.s=-t,e):new b(p?i:NaN);if(!d[0]||!p[0])return p[0]?(e.s=-t,e):new b(d[0]?i:3==l?-0:0)}if(c=Wn(c),u=Wn(u),d=d.slice(),a=c-u){for((s=a<0)?(a=-a,o=d):(u=c,o=p),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(r=(s=(a=d.length)<(t=p.length))?a:t,a=t=0;t<r;t++)if(d[t]!=p[t]){s=d[t]<p[t];break}if(s&&(o=d,d=p,p=o,e.s=-e.s),(t=(r=p.length)-(n=d.length))>0)for(;t--;d[n++]=0);for(t=qn-1;r>a;){if(d[--r]<p[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=qn}d[r]-=p[r]}for(;0==d[0];d.splice(0,1),--u);return d[0]?C(e,d,u):(e.s=3==l?-1:1,e.c=[e.e=0],e)},a.modulo=a.mod=function(e,t){var r,o,s=this;return e=new b(e,t),!s.c||!e.s||e.c&&!e.c[0]?new b(NaN):!e.c||s.c&&!s.c[0]?new b(s):(9==y?(o=e.s,e.s=1,r=n(s,e,0,3),e.s=o,r.s*=o):r=n(s,e,0,y),(e=s.minus(r.times(e))).c[0]||1!=y||(e.s=s.s),e)},a.multipliedBy=a.times=function(e,t){var n,r,o,s,i,a,c,u,l,d,p,h,f,m,g,y=this,w=y.c,A=(e=new b(e,t)).c;if(!(w&&A&&w[0]&&A[0]))return!y.s||!e.s||w&&!w[0]&&!A||A&&!A[0]&&!w?e.c=e.e=e.s=null:(e.s*=y.s,w&&A?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=Wn(y.e/Hn)+Wn(e.e/Hn),e.s*=y.s,(c=w.length)<(d=A.length)&&(f=w,w=A,A=f,o=c,c=d,d=o),o=c+d,f=[];o--;f.push(0));for(m=qn,g=Xn,o=d;--o>=0;){for(n=0,p=A[o]%g,h=A[o]/g|0,s=o+(i=c);s>o;)n=((u=p*(u=w[--i]%g)+(a=h*u+(l=w[i]/g|0)*p)%g*g+f[s]+n)/m|0)+(a/g|0)+h*l,f[s--]=u%m;f[s]=n}return n?++r:f.splice(0,1),C(e,f,r)},a.negated=function(){var e=new b(this);return e.s=-e.s||null,e},a.plus=function(e,t){var n,r=this,o=r.s;if(t=(e=new b(e,t)).s,!o||!t)return new b(NaN);if(o!=t)return e.s=-t,r.minus(e);var s=r.e/Hn,i=e.e/Hn,a=r.c,c=e.c;if(!s||!i){if(!a||!c)return new b(o/0);if(!a[0]||!c[0])return c[0]?e:new b(a[0]?r:0*o)}if(s=Wn(s),i=Wn(i),a=a.slice(),o=s-i){for(o>0?(i=s,n=c):(o=-o,n=a),n.reverse();o--;n.push(0));n.reverse()}for((o=a.length)-(t=c.length)<0&&(n=c,c=a,a=n,t=o),o=0;t;)o=(a[--t]=a[t]+c[t]+o)/qn|0,a[t]=qn===a[t]?0:a[t]%qn;return o&&(a=[o].concat(a),++i),C(e,a,i)},a.precision=a.sd=function(e,t){var n,r,o,s=this;if(null!=e&&e!==!!e)return x(new b(s),jn(e,1,Kn),null==t?l:jn(t,0,8));if(!(n=s.c))return null;if(r=(o=n.length-1)*Hn+1,o=n[o]){for(;o%10==0;o/=10,r--);for(o=n[0];o>=10;o/=10,r++);}return e&&s.e+1>r&&(r=s.e+1),r},a.shiftedBy=function(e){return this.times("1e"+jn(e,-Gn,Gn))},a.squareRoot=a.sqrt=function(){var e,t,r,o,s,i=this,a=i.c,c=i.s,d=i.e,p=u+4,h=new b("0.5");if(1!==c||!a||!a[0])return new b(!c||c<0&&(!a||a[0])?NaN:a?i:1/0);if(0==(c=Math.sqrt(+R(i)))||c==1/0?(((t=Zn(a)).length+d)%2==0&&(t+="0"),c=Math.sqrt(+t),d=Wn((d+1)/2)-(d<0||d%2),r=new b(t=c==1/0?"5e"+d:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+d)):r=new b(c+""),r.c[0])for((c=(d=r.e)+p)<3&&(c=0);;)if(s=r,r=h.times(s.plus(n(i,s,p,1))),Zn(s.c).slice(0,c)===(t=Zn(r.c)).slice(0,c)){if(r.e<d&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(x(r,r.e+u+2,1),e=!r.times(r).eq(i));break}if(!o&&(x(s,s.e+u+2,0),s.times(s).eq(i))){r=s;break}p+=4,c+=4,o=1}return x(r,r.e+u+1,l,e)},"function"==typeof BigInt&&(a.toBigInt=function(e){var t=this;return t.c?BigInt(E(t,t.e+1,e)):null});a.toExponential=function(e,t){return E(this,null==e?e:jn(e,0,Kn)+1,t,1)},a.toFixed=function(e,t){return E(this,null==e?e:jn(e,-Kn,Kn)+this.e+1,t)},a.toFormat=function(e,t,n){var r,o,s,i=this;if(null==n)n=A,null!=e&&(null!=t?"object"==typeof t&&(n=B(t),t=null):"object"!=typeof e||Yn(e)||(n=B(e),e=t=null));else{if("object"!=typeof n)throw Error(Mn+"Argument not an object: "+n);n=B(n)}if(null!=e)if(Yn(e)&&e.length<=2){if(r=e[0],o=e[1],e=i.dp(),null!=o&&e>jn(o,0,Kn)&&(e=o),null!=r&&0!==jn(r,0,Kn)){if(null!=o&&r>o)throw Error(Mn+"Minimum must not exceed maximum");e<r&&(e=r)}}else jn(e,-Kn,Kn);if(s=i.toFixed(e,t),i.s<0&&(s=s.slice(1)),i.c){var a,c=s.split("."),u=+n.groupSize,l=+n.secondaryGroupSize,d=n.groupSeparator||"",p=c[0],h=c[1],f=p.length;if(l&&(a=u,u=l,l=a,f-=a),u>0&&f>0){for(a=f%u||u,s=p.substr(0,a);a<f;a+=u)s+=d+p.substr(a,u);l>0&&(s+=d+p.slice(a))}h&&((a=+n.fractionGroupSize)&&(h=h.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+(n.fractionGroupSeparator||""))),s+=(n.decimalSeparator||"")+h)}return(n.prefix||"")+(i.s<0?n.negativeSign||"":i.s>0&&n.positiveSign||"")+s+(n.suffix||"")},a.toFraction=function(e){var t,r,o,s,i,a,u,d,p,h,m,g,y=this,w=y.c;if(null!=e&&(!(u=new b(e)).isInteger()&&(u.c||1!==u.s)||u.lt(c)))throw Error(Mn+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+R(u));if(!w)return[new b(y.s||0),new b(0)];for(t=new b(c),p=r=new b(c),o=d=new b(c),g=Zn(w),i=t.e=g.length-y.e-1,t.c[0]=$n[(a=i%Hn)<0?Hn+a:a],e=!e||u.comparedTo(t)>0?i>0?t:p:u,a=f,f=1/0,u=new b(g),d.c[0]=0;h=n(u,t,0,1),1!=(s=r.plus(h.times(o))).comparedTo(e);)r=o,o=s,p=d.plus(h.times(s=p)),d=s,t=u.minus(h.times(s=t)),u=s;return s=n(e.minus(r),o,0,1),d=d.plus(s.times(p)),r=r.plus(s.times(o)),d.s=p.s=y.s,m=n(p,o,i*=2,l).minus(y).abs().comparedTo(n(d,r,i,l).minus(y).abs())<1?[p,o]:[d,r],f=a,m},a.toNumber=function(){return+R(this)},a.toObject=function(){var e=this;return{c:e.c?e.c.slice():null,e:e.e,s:e.s}},a.toPrecision=function(e,t){return E(this,null==e?e:jn(e,1,Kn),t,2)},a.toString=function(e){var t,n=this,o=n.s,s=n.e;return null===s?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=s<=d||s>=p?Qn(Zn(n.c),s):er(Zn(n.c),s,"0"):(jn(e,2,S.length,"Base"),t=r(er(Zn(n.c),s,"0"),10,e,o,!0)),o<0&&n.c[0]&&(t="-"+t)),t},a.valueOf=a.toJSON=function(){return R(this)},a._isBigNumber=!0,null!=t&&b.set(t);return b}(),Vn=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Fn=Math.ceil,Dn=Math.floor,Mn="[BigNumber Error] ",qn=1e14,Hn=14,Gn=9007199254740991,$n=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Xn=1e7,Kn=1e9;function Wn(e){var t=0|e;return e>0||e===t?t:t-1}function Zn(e){for(var t,n,r=1,o=e.length,s=e[0]+"";r<o;){for(t=e[r++]+"",n=Hn-t.length;n--;t="0"+t);s+=t}for(o=s.length;48===s.charCodeAt(--o););return s.slice(0,o+1||1)}function zn(e,t){var n,r,o=e.c,s=t.c,i=e.s,a=t.s,c=e.e,u=t.e;if(!i||!a)return null;if(n=o&&!o[0],r=s&&!s[0],n||r)return n?r?0:-a:i;if(i!=a)return i;if(n=i<0,r=c==u,!o||!s)return r?0:!o^n?1:-1;if(!r)return c>u^n?1:-1;for(a=(c=o.length)<(u=s.length)?c:u,i=0;i<a;i++)if(o[i]!=s[i])return o[i]>s[i]^n?1:-1;return c==u?0:c>u^n?1:-1}function jn(e,t,n,r){if(e<t||e>n||e!==Dn(e))throw Error(Mn+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e));return e}function Yn(e){return"[object Array]"=={}.toString.call(e)}function Jn(e){var t=e.c.length-1;return Wn(e.e/Hn)==t&&e.c[t]%2!=0}function Qn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function er(e,t,n){var r,o;if(t<0){for(o=n+".";++t;o+=n);e=o+e}else if(++t>(r=e.length)){for(o=n,t-=r;--t;o+=n);e+=o}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}const tr=Nn.clone({STRICT:!0}),nr=2147483647,rr=new tr(nr);const or=1e7;function sr(e,t){if(t.source)try{e.sourceAccount=Pn(t.source)}catch{throw new Error("Source address is invalid")}}function ir(e,t,n=null){if(void 0===t)return;const r="string"==typeof t?""===t.trim()?NaN:Number(t):t;if("number"!=typeof r||!Number.isFinite(r)||r%1!=0)throw new Error(`${e} value is invalid`);if(r<0)throw new Error(`${e} value must be unsigned`);if(!n||n(r,e))return r;throw new Error(`${e} value is invalid`)}function ar(e){const t=new tr(e).times(or);return se.Int64.fromString(t.toString())}function cr(e){return new tr(e.toString()).div(or).toFixed(7)}function ur(e){return new tr(e.n()).div(new tr(e.d())).toString()}function lr(e){let t;if("object"==typeof e&&"n"in e&&"d"in e)t=new se.Price(e);else{const n=new tr(e);if(!n.gt(0)||!n.isFinite())throw new Error("price must be positive");const r=function(e){let t,n,r=new tr(e);const o=[[new tr(0),new tr(1)],[new tr(1),new tr(0)]];let s=2;for(;!r.gt(nr);){t=r.integerValue(tr.ROUND_FLOOR),n=r.minus(t);const e=o[s-1],i=o[s-2];if(!e||!i)throw new Error(`Continued fraction approximation failed: missing fraction elements at indices ${s-1} and/or ${s-2}`);const a=t.times(e[0]).plus(i[0]),c=t.times(e[1]).plus(i[1]);if(a.gt(nr)||c.gt(nr))break;if(o.push([a,c]),n.eq(0))break;r=new tr(1).div(n),s+=1}const i=o[o.length-1];if(!i)throw new Error("Missing last fraction element in continued fraction approximation");const[a,c]=i;if(a.isZero()||c.isZero()){if(new tr(e).isZero())throw new Error("Couldn't find approximation");const t=o[o.length-1],n=o[o.length-2];if(t&&n){let e=rr;if(t[0].gt(0)&&(e=tr.min(e,rr.minus(n[0]).div(t[0]).integerValue(tr.ROUND_FLOOR))),t[1].gt(0)&&(e=tr.min(e,rr.minus(n[1]).div(t[1]).integerValue(tr.ROUND_FLOOR))),e.gte(1)){const r=e.times(t[0]).plus(n[0]),o=e.times(t[1]).plus(n[1]);if(!r.isZero()&&!o.isZero())return[r.toNumber(),o.toNumber()]}}throw new Error("Couldn't find approximation")}return[a.toNumber(),c.toNumber()]}(e);t=new se.Price({n:parseInt(String(r[0]),10),d:parseInt(String(r[1]),10)})}if(t.n()<0||t.d()<=0)throw new Error("price must be positive");return t}function dr(e,t=!1){if("string"!=typeof e)return!1;let n;try{n=new tr(e)}catch{return!1}return!(!t&&n.isZero()||n.isNegative()||n.times(or).gt(new tr("9223372036854775807").toString())||(n.decimalPlaces()??0)>7||n.isNaN()||!n.isFinite())}function pr(e){return`${e} argument must be of type String, represent a positive number and have at most 7 digits after the decimal`}function hr(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!dr(e.amount,!0))throw new TypeError(pr("amount"));const r=ar(e.amount);if(void 0===e.price)throw new TypeError("price argument is required");const o=lr(e.price),s=void 0!==e.offerId?e.offerId.toString():"0",i=se.Int64.fromString(s),a=new se.ManageSellOfferOp({selling:t,buying:n,amount:r,price:o,offerId:i}),c={sourceAccount:null,body:se.OperationBody.manageSellOffer(a)};return sr(c,e),new se.Operation(c)}function fr(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!dr(e.amount))throw new TypeError(pr("amount"));const r=ar(e.amount);if(void 0===e.price)throw new TypeError("price argument is required");const o=lr(e.price),s=new se.CreatePassiveSellOfferOp({selling:t,buying:n,amount:r,price:o}),i={sourceAccount:null,body:se.OperationBody.createPassiveSellOffer(s)};return sr(i,e),new se.Operation(i)}function mr(e){let t;try{t=se.OperationBody.accountMerge(Pn(e.destination))}catch{throw new Error("destination is invalid")}const n={sourceAccount:null,body:t};return sr(n,e),new se.Operation(n)}function gr(e){if(!wn.isValidEd25519PublicKey(e.trustor))throw new Error("trustor is invalid");const t=Tn.fromPublicKey(e.trustor).xdrAccountId();let n,r;if(e.assetCode.length<=4){const t=fe.Buffer.from(e.assetCode.padEnd(4,"\0"));n=se.AssetCode.assetTypeCreditAlphanum4(t)}else{if(!(e.assetCode.length<=12))throw new Error("Asset code must be 12 characters at max.");{const t=fe.Buffer.from(e.assetCode.padEnd(12,"\0"));n=se.AssetCode.assetTypeCreditAlphanum12(t)}}if("boolean"==typeof e.authorize)r=e.authorize?se.TrustLineFlags.authorizedFlag().value:0;else{if(null==e.authorize)throw new Error("authorize is required");r=e.authorize}const o=new se.AllowTrustOp({trustor:t,asset:n,authorize:r}),s={sourceAccount:null,body:se.OperationBody.allowTrust(o)};return sr(s,e),new se.Operation(s)}function yr(e){if("string"!=typeof e.bumpTo)throw new Error("bumpTo must be a string");try{new tr(e.bumpTo)}catch{throw new Error("bumpTo must be a stringified number")}const t=se.Int64.fromString(e.bumpTo),n=new se.BumpSequenceOp({bumpTo:t}),r={sourceAccount:null,body:se.OperationBody.bumpSequence(n)};return sr(r,e),new se.Operation(r)}function wr(e){const t=e.asset??e.line;let n;if(t instanceof In)n=t.toChangeTrustXDRObject();else{if(!(t instanceof xn))throw new TypeError("asset must be Asset or LiquidityPoolAsset");n=t.toXDRObject()}if(void 0!==e.limit&&!dr(e.limit,!0))throw new TypeError(pr("limit"));const r=e.limit?ar(e.limit):se.Int64.fromString("9223372036854775807"),o=new se.ChangeTrustOp({line:n,limit:r}),s={sourceAccount:null,body:se.OperationBody.changeTrust(o)};return sr(s,e),new se.Operation(s)}function Ar(e){if(!wn.isValidEd25519PublicKey(e.destination))throw new Error("destination is invalid");if(!dr(e.startingBalance,!0))throw new TypeError(pr("startingBalance"));const t=new se.CreateAccountOp({destination:Tn.fromPublicKey(e.destination).xdrAccountId(),startingBalance:ar(e.startingBalance)}),n={sourceAccount:null,body:se.OperationBody.createAccount(t)};return sr(n,e),new se.Operation(n)}function Sr(e){if(!(e.asset instanceof In))throw new Error("must provide an asset for create claimable balance operation");if(!dr(e.amount))throw new TypeError(pr("amount"));if(!Array.isArray(e.claimants)||0===e.claimants.length)throw new Error("must provide at least one claimant");const t=e.asset.toXDRObject(),n=ar(e.amount),r=e.claimants.map(e=>e.toXDRObject()),o=new se.CreateClaimableBalanceOp({asset:t,amount:n,claimants:r}),s={sourceAccount:null,body:se.OperationBody.createClaimableBalance(o)};return sr(s,e),new se.Operation(s)}function br(e={}){vr(e.balanceId);const t=se.ClaimableBalanceId.fromXDR(e.balanceId,"hex"),n=new se.ClaimClaimableBalanceOp({balanceId:t}),r={sourceAccount:null,body:se.OperationBody.claimClaimableBalance(n)};return sr(r,e),new se.Operation(r)}function vr(e){if("string"!=typeof e||72!==e.length)throw new Error("must provide a valid claimable balance id")}function Tr(e={}){vr(e.balanceId);const t=se.ClaimableBalanceId.fromXDR(e.balanceId,"hex"),n={sourceAccount:null,body:se.OperationBody.clawbackClaimableBalance(new se.ClawbackClaimableBalanceOp({balanceId:t}))};return sr(n,e),new se.Operation(n)}function Er(e={}){const t={sourceAccount:null,body:se.OperationBody.inflation()};return sr(t,e),new se.Operation(t)}function kr(e){if(!("string"==typeof e.name&&e.name.length<=64))throw new Error("name must be a string, up to 64 characters");if("string"!=typeof e.value&&!fe.Buffer.isBuffer(e.value)&&null!==e.value&&void 0!==e.value)throw new Error("value must be a string, Buffer or null");let t;if(t="string"==typeof e.value?fe.Buffer.from(e.value):e.value??null,null!==t&&t.length>64)throw new Error("value cannot be longer that 64 bytes");const n=new se.ManageDataOp({dataName:e.name,dataValue:t}),r={sourceAccount:null,body:se.OperationBody.manageData(n)};return sr(r,e),new se.Operation(r)}function Ir(e){const t=e.selling.toXDRObject(),n=e.buying.toXDRObject();if(!dr(e.buyAmount,!0))throw new TypeError(pr("buyAmount"));const r=ar(e.buyAmount);if(void 0===e.price)throw new TypeError("price argument is required");const o=lr(e.price),s=void 0!==e.offerId?e.offerId.toString():"0",i=se.Int64.fromString(s),a=new se.ManageBuyOfferOp({selling:t,buying:n,buyAmount:r,price:o,offerId:i}),c={sourceAccount:null,body:se.OperationBody.manageBuyOffer(a)};return sr(c,e),new se.Operation(c)}function Cr(e){if(!e.sendAsset)throw new Error("Must specify a send asset");if(!dr(e.sendMax))throw new TypeError(pr("sendMax"));if(!e.destAsset)throw new Error("Must provide a destAsset for a payment operation");if(!dr(e.destAmount))throw new TypeError(pr("destAmount"));let t;try{t=Pn(e.destination)}catch{throw new Error("destination is invalid")}const n=e.path?e.path:[],r=new se.PathPaymentStrictReceiveOp({sendAsset:e.sendAsset.toXDRObject(),sendMax:ar(e.sendMax),destination:t,destAsset:e.destAsset.toXDRObject(),destAmount:ar(e.destAmount),path:n.map(e=>e.toXDRObject())}),o={sourceAccount:null,body:se.OperationBody.pathPaymentStrictReceive(r)};return sr(o,e),new se.Operation(o)}function Br(e){if(!e.sendAsset)throw new Error("Must specify a send asset");if(!dr(e.sendAmount))throw new TypeError(pr("sendAmount"));if(!e.destAsset)throw new Error("Must provide a destAsset for a payment operation");if(!dr(e.destMin))throw new TypeError(pr("destMin"));const t=e.sendAsset.toXDRObject(),n=ar(e.sendAmount);let r;try{r=Pn(e.destination)}catch{throw new Error("destination is invalid")}const o=e.destAsset.toXDRObject(),s=ar(e.destMin),i=(e.path??[]).map(e=>e.toXDRObject()),a=new se.PathPaymentStrictSendOp({sendAsset:t,sendAmount:n,destination:r,destAsset:o,destMin:s,path:i}),c={sourceAccount:null,body:se.OperationBody.pathPaymentStrictSend(a)};return sr(c,e),new se.Operation(c)}function xr(e){if(!e.asset)throw new Error("Must provide an asset for a payment operation");if(!dr(e.amount))throw new TypeError(pr("amount"));let t;try{t=Pn(e.destination)}catch{throw new Error("destination is invalid")}const n=new se.PaymentOp({destination:t,asset:e.asset.toXDRObject(),amount:ar(e.amount)}),r={sourceAccount:null,body:se.OperationBody.payment(n)};return sr(r,e),new se.Operation(r)}function Rr(e,t){if(e>=0&&e<=255)return!0;throw new Error(`${t} value must be between 0 and 255`)}function _r(e){let t=null;if(e.inflationDest){if(!wn.isValidEd25519PublicKey(e.inflationDest))throw new Error("inflationDest is invalid");t=Tn.fromPublicKey(e.inflationDest).xdrAccountId()}const n=ir("clearFlags",e.clearFlags)??null,r=ir("setFlags",e.setFlags)??null,o=ir("masterWeight",e.masterWeight,Rr)??null,s=ir("lowThreshold",e.lowThreshold,Rr)??null,i=ir("medThreshold",e.medThreshold,Rr)??null,a=ir("highThreshold",e.highThreshold,Rr)??null;if(void 0!==e.homeDomain&&"string"!=typeof e.homeDomain)throw new TypeError("homeDomain argument must be of type String");const c=e.homeDomain;let u=null;if(e.signer){const t=ir("signer.weight",e.signer.weight,Rr);let n,r=0;if(e.signer.ed25519PublicKey){if(!wn.isValidEd25519PublicKey(e.signer.ed25519PublicKey))throw new Error("signer.ed25519PublicKey is invalid.");const t=wn.decodeEd25519PublicKey(e.signer.ed25519PublicKey);n=se.SignerKey.signerKeyTypeEd25519(t),r+=1}if(e.signer.preAuthTx){let t;if(t="string"==typeof e.signer.preAuthTx?fe.Buffer.from(e.signer.preAuthTx,"hex"):e.signer.preAuthTx,!fe.Buffer.isBuffer(t)||32!==t.length)throw new Error("signer.preAuthTx must be 32 bytes Buffer.");n=se.SignerKey.signerKeyTypePreAuthTx(t),r+=1}if(e.signer.sha256Hash){let t;if(t="string"==typeof e.signer.sha256Hash?fe.Buffer.from(e.signer.sha256Hash,"hex"):e.signer.sha256Hash,!fe.Buffer.isBuffer(t)||32!==t.length)throw new Error("signer.sha256Hash must be 32 bytes Buffer.");n=se.SignerKey.signerKeyTypeHashX(t),r+=1}if(e.signer.ed25519SignedPayload){if(!wn.isValidSignedPayload(e.signer.ed25519SignedPayload))throw new Error("signer.ed25519SignedPayload is invalid.");const t=wn.decodeSignedPayload(e.signer.ed25519SignedPayload),o=se.SignerKeyEd25519SignedPayload.fromXDR(t);n=se.SignerKey.signerKeyTypeEd25519SignedPayload(o),r+=1}if(1!==r)throw new Error("Signer object must contain exactly one of signer.ed25519PublicKey, signer.sha256Hash, signer.preAuthTx, or signer.ed25519SignedPayload.");if(void 0===t)throw new Error("signer weight is required.");if(void 0===n)throw new Error("signer key is required.");u=new se.Signer({key:n,weight:t})}const l=new se.SetOptionsOp({inflationDest:t,clearFlags:n,setFlags:r,masterWeight:o,lowThreshold:s,medThreshold:i,highThreshold:a,homeDomain:c,signer:u}),d={sourceAccount:null,body:se.OperationBody.setOptions(l)};return sr(d,e),new se.Operation(d)}function Pr(e){if(!wn.isValidEd25519PublicKey(e.sponsoredId))throw new Error("sponsoredId is invalid");const t=new se.BeginSponsoringFutureReservesOp({sponsoredId:Tn.fromPublicKey(e.sponsoredId).xdrAccountId()}),n={sourceAccount:null,body:se.OperationBody.beginSponsoringFutureReserves(t)};return sr(n,e),new se.Operation(n)}function Or(e={}){const t={sourceAccount:null,body:se.OperationBody.endSponsoringFutureReserves()};return sr(t,e),new se.Operation(t)}function Ur(e={}){if(!wn.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");const t=se.LedgerKey.account(new se.LedgerKeyAccount({accountId:Tn.fromPublicKey(e.account).xdrAccountId()})),n=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:se.OperationBody.revokeSponsorship(n)};return sr(r,e),new se.Operation(r)}function Lr(e={}){if(!wn.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");let t;if(e.asset instanceof In)t=e.asset.toTrustLineXDRObject();else{if(!(e.asset instanceof _n))throw new TypeError("asset must be an Asset or LiquidityPoolId");t=e.asset.toXDRObject()}const n=se.LedgerKey.trustline(new se.LedgerKeyTrustLine({accountId:Tn.fromPublicKey(e.account).xdrAccountId(),asset:t})),r=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(n),o={sourceAccount:null,body:se.OperationBody.revokeSponsorship(r)};return sr(o,e),new se.Operation(o)}function Nr(e={}){if(!wn.isValidEd25519PublicKey(e.seller))throw new Error("seller is invalid");if("string"!=typeof e.offerId)throw new Error("offerId is invalid");const t=se.LedgerKey.offer(new se.LedgerKeyOffer({sellerId:Tn.fromPublicKey(e.seller).xdrAccountId(),offerId:se.Int64.fromString(e.offerId)})),n=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:se.OperationBody.revokeSponsorship(n)};return sr(r,e),new se.Operation(r)}function Vr(e={}){if(!wn.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");if("string"!=typeof e.name||e.name.length>64)throw new Error("name must be a string, up to 64 characters");const t=se.LedgerKey.data(new se.LedgerKeyData({accountId:Tn.fromPublicKey(e.account).xdrAccountId(),dataName:e.name})),n=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:se.OperationBody.revokeSponsorship(n)};return sr(r,e),new se.Operation(r)}function Fr(e={}){if("string"!=typeof e.balanceId)throw new Error("balanceId is invalid");const t=se.LedgerKey.claimableBalance(new se.LedgerKeyClaimableBalance({balanceId:se.ClaimableBalanceId.fromXDR(e.balanceId,"hex")})),n=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:se.OperationBody.revokeSponsorship(n)};return sr(r,e),new se.Operation(r)}function Dr(e={}){if("string"!=typeof e.liquidityPoolId)throw new Error("liquidityPoolId is invalid");const t=se.LedgerKey.liquidityPool(new se.LedgerKeyLiquidityPool({liquidityPoolId:fe.Buffer.from(e.liquidityPoolId,"hex")})),n=se.RevokeSponsorshipOp.revokeSponsorshipLedgerEntry(t),r={sourceAccount:null,body:se.OperationBody.revokeSponsorship(n)};return sr(r,e),new se.Operation(r)}function Mr(e={}){if(!wn.isValidEd25519PublicKey(e.account))throw new Error("account is invalid");let t;if(e.signer.ed25519PublicKey){if(!wn.isValidEd25519PublicKey(e.signer.ed25519PublicKey))throw new Error("signer.ed25519PublicKey is invalid.");const n=wn.decodeEd25519PublicKey(e.signer.ed25519PublicKey);t=se.SignerKey.signerKeyTypeEd25519(n)}else if(e.signer.preAuthTx){let n;if(n="string"==typeof e.signer.preAuthTx?fe.Buffer.from(e.signer.preAuthTx,"hex"):e.signer.preAuthTx,!fe.Buffer.isBuffer(n)||32!==n.length)throw new Error("signer.preAuthTx must be 32 bytes Buffer.");t=se.SignerKey.signerKeyTypePreAuthTx(n)}else if(e.signer.sha256Hash){let n;if(n="string"==typeof e.signer.sha256Hash?fe.Buffer.from(e.signer.sha256Hash,"hex"):e.signer.sha256Hash,!fe.Buffer.isBuffer(n)||32!==n.length)throw new Error("signer.sha256Hash must be 32 bytes Buffer.");t=se.SignerKey.signerKeyTypeHashX(n)}else{if(!e.signer.ed25519SignedPayload)throw new Error("signer is invalid");{if(!wn.isValidSignedPayload(e.signer.ed25519SignedPayload))throw new Error("signer.ed25519SignedPayload is invalid.");const n=wn.decodeSignedPayload(e.signer.ed25519SignedPayload),r=se.SignerKeyEd25519SignedPayload.fromXDR(n);t=se.SignerKey.signerKeyTypeEd25519SignedPayload(r)}}const n=new se.RevokeSponsorshipOpSigner({accountId:Tn.fromPublicKey(e.account).xdrAccountId(),signerKey:t}),r=se.RevokeSponsorshipOp.revokeSponsorshipSigner(n),o={sourceAccount:null,body:se.OperationBody.revokeSponsorship(r)};return sr(o,e),new se.Operation(o)}function qr(e){if(!dr(e.amount))throw new TypeError(pr("amount"));let t;try{t=Pn(e.from)}catch{throw new Error("from address is invalid")}const n=new se.ClawbackOp({amount:ar(e.amount),asset:e.asset.toXDRObject(),from:t}),r={sourceAccount:null,body:se.OperationBody.clawback(n)};return sr(r,e),new se.Operation(r)}function Hr(e){if("object"!=typeof e.flags||0===Object.keys(e.flags).length)throw new Error("opts.flags must be a map of boolean flags to modify");const t={authorized:se.TrustLineFlags.authorizedFlag(),authorizedToMaintainLiabilities:se.TrustLineFlags.authorizedToMaintainLiabilitiesFlag(),clawbackEnabled:se.TrustLineFlags.trustlineClawbackEnabledFlag()};let n=0,r=0;Object.keys(e.flags).forEach(o=>{if(!Object.prototype.hasOwnProperty.call(t,o))throw new Error(`unsupported flag name specified: ${o}`);const s=e.flags[o],i=t[o];if(!i)throw new Error(`Invalid flag name: ${o}`);if("boolean"!=typeof s&&void 0!==s)throw new TypeError(`opts.flags.${o} must be a boolean (got ${typeof s})`);!0===s?r|=i.value:!1===s&&(n|=i.value)});const o=Tn.fromPublicKey(e.trustor).xdrAccountId(),s=e.asset.toXDRObject(),i={sourceAccount:null,body:se.OperationBody.setTrustLineFlags(new se.SetTrustLineFlagsOp({trustor:o,asset:s,clearFlags:n,setFlags:r}))};return sr(i,e),new se.Operation(i)}function Gr(e={}){const{liquidityPoolId:t,maxAmountA:n,maxAmountB:r,minPrice:o,maxPrice:s}=e;if(!t)throw new TypeError("liquidityPoolId argument is required");const i=fe.Buffer.from(t,"hex");if(!dr(n,!0))throw new TypeError(pr("maxAmountA"));const a=ar(n);if(!dr(r,!0))throw new TypeError(pr("maxAmountB"));const c=ar(r);if(void 0===o)throw new TypeError("minPrice argument is required");const u=lr(o);if(void 0===s)throw new TypeError("maxPrice argument is required");const l=lr(s),d=new se.LiquidityPoolDepositOp({liquidityPoolId:i,maxAmountA:a,maxAmountB:c,minPrice:u,maxPrice:l}),p={sourceAccount:null,body:se.OperationBody.liquidityPoolDeposit(d)};return sr(p,e),new se.Operation(p)}function $r(e={}){if(!e.liquidityPoolId)throw new TypeError("liquidityPoolId argument is required");const t=fe.Buffer.from(e.liquidityPoolId,"hex");if(!dr(e.amount))throw new TypeError(pr("amount"));const n=ar(e.amount);if(!dr(e.minAmountA,!0))throw new TypeError(pr("minAmountA"));const r=ar(e.minAmountA);if(!dr(e.minAmountB,!0))throw new TypeError(pr("minAmountB"));const o=ar(e.minAmountB),s=new se.LiquidityPoolWithdrawOp({liquidityPoolId:t,amount:n,minAmountA:r,minAmountB:o}),i={sourceAccount:null,body:se.OperationBody.liquidityPoolWithdraw(s)};return sr(i,e),new se.Operation(i)}class Xr{_type;_key;constructor(e){if(wn.isValidEd25519PublicKey(e))this._type="account",this._key=wn.decodeEd25519PublicKey(e);else if(wn.isValidContract(e))this._type="contract",this._key=wn.decodeContract(e);else if(wn.isValidMed25519PublicKey(e))this._type="muxedAccount",this._key=wn.decodeMed25519PublicKey(e);else if(wn.isValidClaimableBalance(e))this._type="claimableBalance",this._key=wn.decodeClaimableBalance(e);else{if(!wn.isValidLiquidityPool(e))throw new Error(`Unsupported address type: ${e}`);this._type="liquidityPool",this._key=wn.decodeLiquidityPool(e)}}static fromString(e){return new Xr(e)}static account(e){return new Xr(wn.encodeEd25519PublicKey(e))}static contract(e){return new Xr(wn.encodeContract(e))}static claimableBalance(e){return new Xr(wn.encodeClaimableBalance(e))}static liquidityPool(e){return new Xr(wn.encodeLiquidityPool(e))}static muxedAccount(e){return new Xr(wn.encodeMed25519PublicKey(e))}static fromScVal(e){return Xr.fromScAddress(e.address())}static fromScAddress(e){switch(e.switch().value){case se.ScAddressType.scAddressTypeAccount().value:return Xr.account(e.accountId().ed25519());case se.ScAddressType.scAddressTypeContract().value:return Xr.contract(e.contractId());case se.ScAddressType.scAddressTypeMuxedAccount().value:{const t=fe.Buffer.concat([e.muxedAccount().ed25519(),e.muxedAccount().id().toXDR("raw")]);return Xr.muxedAccount(t)}case se.ScAddressType.scAddressTypeClaimableBalance().value:{const t=e.claimableBalanceId();return Xr.claimableBalance(fe.Buffer.concat([fe.Buffer.from([t.switch().value]),t.v0()]))}case se.ScAddressType.scAddressTypeLiquidityPool().value:return Xr.liquidityPool(e.liquidityPoolId());default:throw new Error(`Unsupported address type: ${e.switch().name}`)}}toString(){switch(this._type){case"account":return wn.encodeEd25519PublicKey(this._key);case"contract":return wn.encodeContract(this._key);case"claimableBalance":return wn.encodeClaimableBalance(this._key);case"liquidityPool":return wn.encodeLiquidityPool(this._key);case"muxedAccount":return wn.encodeMed25519PublicKey(this._key);default:throw new Error("Unsupported address type")}}toScVal(){return se.ScVal.scvAddress(this.toScAddress())}toScAddress(){switch(this._type){case"account":return se.ScAddress.scAddressTypeAccount(se.PublicKey.publicKeyTypeEd25519(this._key));case"contract":return se.ScAddress.scAddressTypeContract(this._key);case"liquidityPool":return se.ScAddress.scAddressTypeLiquidityPool(this._key);case"claimableBalance":return se.ScAddress.scAddressTypeClaimableBalance(se.ClaimableBalanceId.claimableBalanceIdTypeV0(this._key.subarray(1)));case"muxedAccount":return se.ScAddress.scAddressTypeMuxedAccount(new se.MuxedEd25519Account({ed25519:this._key.subarray(0,32),id:se.Uint64.fromXDR(this._key.subarray(32,40),"raw")}));default:throw new Error("Unsupported address type")}}toBuffer(){return this._key}get type(){return this._type}}function Kr(e){if(!e.func)throw new TypeError(`host function invocation ('func') required (got ${JSON.stringify(e)})`);e.func.switch().value===se.HostFunctionType.hostFunctionTypeInvokeContract().value&&e.func.invokeContract().args().forEach(e=>{let t;try{t=Xr.fromScVal(e)}catch{return}switch(t.type){case"claimableBalance":case"liquidityPool":throw new TypeError("claimable balances and liquidity pools cannot be arguments to invokeHostFunction")}});const t=new se.InvokeHostFunctionOp({hostFunction:e.func,auth:e.auth||[]}),n={sourceAccount:null,body:se.OperationBody.invokeHostFunction(t)};return sr(n,e),new se.Operation(n)}function Wr(e){const t=new Xr(e.contract);if("contract"!==t.type)throw new TypeError(`expected contract strkey instance, got ${t.toString()}`);return Kr({func:se.HostFunction.hostFunctionTypeInvokeContract(new se.InvokeContractArgs({contractAddress:t.toScAddress(),functionName:e.function,args:e.args})),...void 0!==e.source&&{source:e.source},...void 0!==e.auth&&{auth:e.auth}})}function Zr(e){const t=fe.Buffer.from(e.salt||Tn.random().xdrPublicKey().value());if(!e.wasmHash||32!==e.wasmHash.length)throw new TypeError(`expected hash(contract WASM) in 'opts.wasmHash', got ${String(e.wasmHash)}`);if(32!==t.length)throw new TypeError(`expected 32-byte salt in 'opts.salt', got ${String(e.salt)}`);return Kr({func:se.HostFunction.hostFunctionTypeCreateContractV2(new se.CreateContractArgsV2({executable:se.ContractExecutable.contractExecutableWasm(fe.Buffer.from(e.wasmHash)),contractIdPreimage:se.ContractIdPreimage.contractIdPreimageFromAddress(new se.ContractIdPreimageFromAddress({address:e.address.toScAddress(),salt:t})),constructorArgs:e.constructorArgs??[]})),...void 0!==e.source&&{source:e.source},...void 0!==e.auth&&{auth:e.auth}})}function zr(e){let t=e.asset;if("string"==typeof t){const n=t.split(":"),r=n[0];if(void 0===r)throw new TypeError(`expected Asset in 'opts.asset', got ${String(e.asset)}`);t=new In(r,n[1])}if(!(t instanceof In))throw new TypeError(`expected Asset in 'opts.asset', got ${String(e.asset)}`);return Kr({func:se.HostFunction.hostFunctionTypeCreateContract(new se.CreateContractArgs({executable:se.ContractExecutable.contractExecutableStellarAsset(),contractIdPreimage:se.ContractIdPreimage.contractIdPreimageFromAsset(t.toXDRObject())})),auth:e.auth||[],...void 0!==e.source&&{source:e.source}})}function jr(e){return Kr({func:se.HostFunction.hostFunctionTypeUploadContractWasm(fe.Buffer.from(e.wasm)),auth:e.auth||[],...void 0!==e.source&&{source:e.source}})}function Yr(e){if((e.extendTo??-1)<=0)throw new RangeError("extendTo has to be positive");const t=new se.ExtendFootprintTtlOp({ext:new se.ExtensionPoint(0),extendTo:e.extendTo}),n={sourceAccount:null,body:se.OperationBody.extendFootprintTtl(t)};return sr(n,e),new se.Operation(n)}function Jr(e={}){const t=new se.RestoreFootprintOp({ext:new se.ExtensionPoint(0)}),n={sourceAccount:null,body:se.OperationBody.restoreFootprint(t)};return sr(n,e),new se.Operation(n)}class Qr{static fromXDRObject(e){const t={},n=e.sourceAccount();n&&(t.source=On(n));const r=e.body().value(),o=e.body().switch().name;switch(o){case"createAccount":t.type="createAccount",t.destination=eo(r.destination()),t.startingBalance=cr(r.startingBalance());break;case"payment":t.type="payment",t.destination=On(r.destination()),t.asset=In.fromOperation(r.asset()),t.amount=cr(r.amount());break;case"pathPaymentStrictReceive":{t.type="pathPaymentStrictReceive",t.sendAsset=In.fromOperation(r.sendAsset()),t.sendMax=cr(r.sendMax()),t.destination=On(r.destination()),t.destAsset=In.fromOperation(r.destAsset()),t.destAmount=cr(r.destAmount()),t.path=[];const e=r.path();Object.keys(e).forEach(n=>{t.path.push(In.fromOperation(e[n]))});break}case"pathPaymentStrictSend":{t.type="pathPaymentStrictSend",t.sendAsset=In.fromOperation(r.sendAsset()),t.sendAmount=cr(r.sendAmount()),t.destination=On(r.destination()),t.destAsset=In.fromOperation(r.destAsset()),t.destMin=cr(r.destMin()),t.path=[];const e=r.path();Object.keys(e).forEach(n=>{t.path.push(In.fromOperation(e[n]))});break}case"changeTrust":if(t.type="changeTrust",r.line().switch()===se.AssetType.assetTypePoolShare())t.line=xn.fromOperation(r.line());else t.line=In.fromOperation(r.line());t.limit=cr(r.limit());break;case"allowTrust":t.type="allowTrust",t.trustor=eo(r.trustor()),t.assetCode=r.asset().value().toString(),t.assetCode=ln(t.assetCode,"\0"),t.authorize=r.authorize();break;case"setOptions":if(t.type="setOptions",r.inflationDest()&&(t.inflationDest=eo(r.inflationDest())),t.clearFlags=r.clearFlags(),t.setFlags=r.setFlags(),t.masterWeight=r.masterWeight(),t.lowThreshold=r.lowThreshold(),t.medThreshold=r.medThreshold(),t.highThreshold=r.highThreshold(),t.homeDomain=void 0!==r.homeDomain()?r.homeDomain().toString("ascii"):void 0,r.signer()){const e={},n=r.signer().key().arm();if("ed25519"===n)e.ed25519PublicKey=eo(r.signer().key());else if("preAuthTx"===n)e.preAuthTx=r.signer().key().preAuthTx();else if("hashX"===n)e.sha256Hash=r.signer().key().hashX();else if("ed25519SignedPayload"===n){const t=r.signer().key().ed25519SignedPayload();e.ed25519SignedPayload=wn.encodeSignedPayload(t.toXDR())}e.weight=r.signer().weight(),t.signer=e}break;case"manageOffer":case"manageSellOffer":t.type="manageSellOffer",t.selling=In.fromOperation(r.selling()),t.buying=In.fromOperation(r.buying()),t.amount=cr(r.amount()),t.price=ur(r.price()),t.offerId=r.offerId().toString();break;case"manageBuyOffer":t.type="manageBuyOffer",t.selling=In.fromOperation(r.selling()),t.buying=In.fromOperation(r.buying()),t.buyAmount=cr(r.buyAmount()),t.price=ur(r.price()),t.offerId=r.offerId().toString();break;case"createPassiveOffer":case"createPassiveSellOffer":t.type="createPassiveSellOffer",t.selling=In.fromOperation(r.selling()),t.buying=In.fromOperation(r.buying()),t.amount=cr(r.amount()),t.price=ur(r.price());break;case"accountMerge":t.type="accountMerge",t.destination=On(r);break;case"manageData":t.type="manageData",t.name=r.dataName().toString("ascii"),t.value=r.dataValue();break;case"inflation":t.type="inflation";break;case"bumpSequence":t.type="bumpSequence",t.bumpTo=r.bumpTo().toString();break;case"createClaimableBalance":t.type="createClaimableBalance",t.asset=In.fromOperation(r.asset()),t.amount=cr(r.amount()),t.claimants=[],r.claimants().forEach(e=>{t.claimants.push(Rn.fromXDR(e))});break;case"claimClaimableBalance":t.type="claimClaimableBalance",t.balanceId=r.toXDR("hex");break;case"beginSponsoringFutureReserves":t.type="beginSponsoringFutureReserves",t.sponsoredId=eo(r.sponsoredId());break;case"endSponsoringFutureReserves":t.type="endSponsoringFutureReserves";break;case"revokeSponsorship":!function(e,t){switch(e.switch().name){case"revokeSponsorshipLedgerEntry":{const n=e.ledgerKey();switch(n.switch().name){case se.LedgerEntryType.account().name:t.type="revokeAccountSponsorship",t.account=eo(n.account().accountId());break;case se.LedgerEntryType.trustline().name:{t.type="revokeTrustlineSponsorship",t.account=eo(n.trustLine().accountId());const e=n.trustLine().asset();if(e.switch()===se.AssetType.assetTypePoolShare())t.asset=_n.fromOperation(e);else t.asset=In.fromOperation(e);break}case se.LedgerEntryType.offer().name:t.type="revokeOfferSponsorship",t.seller=eo(n.offer().sellerId()),t.offerId=n.offer().offerId().toString();break;case se.LedgerEntryType.data().name:t.type="revokeDataSponsorship",t.account=eo(n.data().accountId()),t.name=n.data().dataName().toString("ascii");break;case se.LedgerEntryType.claimableBalance().name:t.type="revokeClaimableBalanceSponsorship",t.balanceId=n.claimableBalance().balanceId().toXDR("hex");break;case se.LedgerEntryType.liquidityPool().name:t.type="revokeLiquidityPoolSponsorship",t.liquidityPoolId=n.liquidityPool().liquidityPoolId().toString("hex");break;default:throw new Error(`Unknown ledgerKey: ${e.switch().name}`)}break}case"revokeSponsorshipSigner":t.type="revokeSignerSponsorship",t.account=eo(e.signer().accountId()),t.signer=function(e){const t={};switch(e.switch().name){case se.SignerKeyType.signerKeyTypeEd25519().name:t.ed25519PublicKey=wn.encodeEd25519PublicKey(e.ed25519());break;case se.SignerKeyType.signerKeyTypePreAuthTx().name:t.preAuthTx=e.preAuthTx().toString("hex");break;case se.SignerKeyType.signerKeyTypeHashX().name:t.sha256Hash=e.hashX().toString("hex");break;case se.SignerKeyType.signerKeyTypeEd25519SignedPayload().name:{const n=e.ed25519SignedPayload();t.ed25519SignedPayload=wn.encodeSignedPayload(n.toXDR());break}default:throw new Error(`Unknown signerKey: ${e.switch().name}`)}return t}(e.signer().signerKey());break;default:throw new Error(`Unknown revokeSponsorship: ${e.switch().name}`)}}(r,t);break;case"clawback":t.type="clawback",t.amount=cr(r.amount()),t.from=On(r.from()),t.asset=In.fromOperation(r.asset());break;case"clawbackClaimableBalance":t.type="clawbackClaimableBalance",t.balanceId=r.toXDR("hex");break;case"setTrustLineFlags":{t.type="setTrustLineFlags",t.asset=In.fromOperation(r.asset()),t.trustor=eo(r.trustor());const e=r.clearFlags(),n=r.setFlags(),o={authorized:se.TrustLineFlags.authorizedFlag(),authorizedToMaintainLiabilities:se.TrustLineFlags.authorizedToMaintainLiabilitiesFlag(),clawbackEnabled:se.TrustLineFlags.trustlineClawbackEnabledFlag()},s=t=>{const r=o[t]?.value??0;return!!(n&r)||!(e&r)&&void 0},i={};Object.keys(o).forEach(e=>{i[e]=s(e)}),t.flags=i;break}case"liquidityPoolDeposit":t.type="liquidityPoolDeposit",t.liquidityPoolId=r.liquidityPoolId().toString("hex"),t.maxAmountA=cr(r.maxAmountA()),t.maxAmountB=cr(r.maxAmountB()),t.minPrice=ur(r.minPrice()),t.maxPrice=ur(r.maxPrice());break;case"liquidityPoolWithdraw":t.type="liquidityPoolWithdraw",t.liquidityPoolId=r.liquidityPoolId().toString("hex"),t.amount=cr(r.amount()),t.minAmountA=cr(r.minAmountA()),t.minAmountB=cr(r.minAmountB());break;case"invokeHostFunction":t.type="invokeHostFunction",t.func=r.hostFunction(),t.auth=r.auth()??[];break;case"extendFootprintTtl":t.type="extendFootprintTtl",t.extendTo=r.extendTo();break;case"restoreFootprint":t.type="restoreFootprint";break;default:throw new Error(`Unknown operation: ${o}`)}return t}static accountMerge=mr;static allowTrust=gr;static bumpSequence=yr;static changeTrust=wr;static createAccount=Ar;static createClaimableBalance=Sr;static claimClaimableBalance=br;static clawbackClaimableBalance=Tr;static createPassiveSellOffer=fr;static inflation=Er;static manageData=kr;static manageSellOffer=hr;static manageBuyOffer=Ir;static pathPaymentStrictReceive=Cr;static pathPaymentStrictSend=Br;static payment=xr;static setOptions=_r;static beginSponsoringFutureReserves=Pr;static endSponsoringFutureReserves=Or;static revokeAccountSponsorship=Ur;static revokeTrustlineSponsorship=Lr;static revokeOfferSponsorship=Nr;static revokeDataSponsorship=Vr;static revokeClaimableBalanceSponsorship=Fr;static revokeLiquidityPoolSponsorship=Dr;static revokeSignerSponsorship=Mr;static clawback=qr;static setTrustLineFlags=Hr;static liquidityPoolDeposit=Gr;static liquidityPoolWithdraw=$r;static invokeHostFunction=Kr;static extendFootprintTtl=Yr;static restoreFootprint=Jr;static createStellarAssetContract=zr;static invokeContractFunction=Wr;static createCustomContract=Zr;static uploadContractWasm=jr}function eo(e){return wn.encodeEd25519PublicKey(e.ed25519())}const to="none",no="id",ro="text",oo="hash",so="return";class io{_type;_value;constructor(e,t=null){switch(this._type=e,this._value=t,this._type){case to:break;case no:io._validateIdValue(t);break;case ro:io._validateTextValue(t);break;case oo:case so:io._validateHashValue(t),"string"==typeof t&&(this._value=fe.Buffer.from(t,"hex"));break;default:throw new Error("Invalid memo type")}}get type(){return this._type}set type(e){throw new Error("Memo is immutable")}get value(){switch(this._type){case to:return null;case no:case ro:return this._value;case oo:case so:return fe.Buffer.from(this._value);default:throw new Error("Invalid memo type")}}set value(e){throw new Error("Memo is immutable")}static _validateIdValue(e){const t=new Error(`Expects a uint64 as a string. Got ${e}`);if("string"!=typeof e)throw t;if(!/^[0-9]+$/.test(e))throw t;let n;try{n=new tr(e)}catch{throw t}if(!n.isFinite())throw t;if(n.isNaN())throw t;if(n.isNegative())throw t;if(!n.isInteger())throw t;if(n.isGreaterThan("18446744073709551615"))throw t}static _validateTextValue(e){if("string"==typeof e){if(fe.Buffer.byteLength(e,"utf8")>28)throw new Error("Expects string, array or buffer, max 28 bytes")}else if(fe.Buffer.isBuffer(e)){if(e.length>28)throw new Error("Expects string, array or buffer, max 28 bytes")}else if(!se.Memo.armTypeForArm("text").isValid(e))throw new Error("Expects string, array or buffer, max 28 bytes")}static _validateHashValue(e){const t=new Error(`Expects a 32 byte hash value or hex encoded string. Got ${String(e)}`);if(null==e)throw t;let n;if("string"==typeof e){if(!/^[0-9A-Fa-f]{64}$/g.test(e))throw t;n=fe.Buffer.from(e,"hex")}else{if(!fe.Buffer.isBuffer(e))throw t;n=fe.Buffer.from(e)}if(!n.length||32!==n.length)throw t}static none(){return new io(to)}static text(e){return new io(ro,e)}static id(e){return new io(no,e)}static hash(e){return new io(oo,e)}static return(e){return new io(so,e)}toXDRObject(){switch(this._type){case to:return se.Memo.memoNone();case no:return se.Memo.memoId(se.Uint64.fromString(oe.UnsignedHyper.fromString(this._value).toString()));case ro:return se.Memo.memoText(this._value);case oo:return se.Memo.memoHash(this._value);case so:return se.Memo.memoReturn(this._value);default:throw new Error("Invalid memo type")}}static fromXDRObject(e){switch(e.switch()){case se.MemoType.memoId():return io.id(e.id().toString());case se.MemoType.memoText():return io.text(e.value());case se.MemoType.memoHash():return io.hash(e.hash());case se.MemoType.memoReturn():return io.return(e.retHash())}if(void 0===e.value())return io.none();throw new Error("Unknown type")}}class ao extends Bn{_envelopeType;_source="";_memo;_sequence;_operations;_timeBounds;_ledgerBounds;_minAccountSequence;_minAccountSequenceAge;_minAccountSequenceLedgerGap;_extraSigners;constructor(e,t){if("string"==typeof e){const t=fe.Buffer.from(e,"base64");e=se.TransactionEnvelope.fromXDR(t)}const n=e.switch();if(n!==se.EnvelopeType.envelopeTypeTxV0()&&n!==se.EnvelopeType.envelopeTypeTx())throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxV0 or envelopeTypeTx but received an ${n.name}.`);const r=e.value(),o=r.tx(),s=o.fee().toString();if(super(o,(r.signatures()||[]).slice(),s,t),this._envelopeType=n,this._memo=o.memo(),this._sequence=o.seqNum().toString(),this._envelopeType===se.EnvelopeType.envelopeTypeTxV0())this._source=wn.encodeEd25519PublicKey(o.sourceAccountEd25519());else this._source=On(o.sourceAccount());let i=null,a=null;switch(this._envelopeType){case se.EnvelopeType.envelopeTypeTxV0():a=o.timeBounds();break;case se.EnvelopeType.envelopeTypeTx():switch(o.cond().switch()){case se.PreconditionType.precondTime():a=o.cond().timeBounds();break;case se.PreconditionType.precondV2():i=o.cond().v2(),a=i.timeBounds()}}if(a&&(this._timeBounds={minTime:a.minTime().toString(),maxTime:a.maxTime().toString()}),i){const e=i.ledgerBounds();e&&(this._ledgerBounds={minLedger:e.minLedger(),maxLedger:e.maxLedger()});const t=i.minSeqNum();t&&(this._minAccountSequence=t.toString()),this._minAccountSequenceAge=i.minSeqAge().toBigInt(),this._minAccountSequenceLedgerGap=i.minSeqLedgerGap(),this._extraSigners=i.extraSigners()}const c=o.operations()||[];this._operations=c.map(e=>Qr.fromXDRObject(e))}get timeBounds(){return this._timeBounds}set timeBounds(e){throw new Error("Transaction is immutable")}get ledgerBounds(){return this._ledgerBounds}set ledgerBounds(e){throw new Error("Transaction is immutable")}get minAccountSequence(){return this._minAccountSequence}set minAccountSequence(e){throw new Error("Transaction is immutable")}get minAccountSequenceAge(){return this._minAccountSequenceAge}set minAccountSequenceAge(e){throw new Error("Transaction is immutable")}get minAccountSequenceLedgerGap(){return this._minAccountSequenceLedgerGap}set minAccountSequenceLedgerGap(e){throw new Error("Transaction is immutable")}get extraSigners(){return this._extraSigners}set extraSigners(e){throw new Error("Transaction is immutable")}get sequence(){return this._sequence}set sequence(e){throw new Error("Transaction is immutable")}get source(){return this._source}set source(e){throw new Error("Transaction is immutable")}get operations(){return this._operations}set operations(e){throw new Error("Transaction is immutable")}get memo(){return io.fromXDRObject(this._memo)}set memo(e){throw new Error("Transaction is immutable")}signatureBase(){let e=this.tx;this._envelopeType===se.EnvelopeType.envelopeTypeTxV0()&&(e=se.Transaction.fromXDR(fe.Buffer.concat([fe.Buffer.alloc(4),e.toXDR()])));const t=se.TransactionSignaturePayloadTaggedTransaction.envelopeTypeTx(e);return new se.TransactionSignaturePayload({networkId:se.Hash.fromXDR(nt(this.networkPassphrase)),taggedTransaction:t}).toXDR()}toEnvelope(){const e=this.tx.toXDR(),t=this.signatures.slice();let n;switch(this._envelopeType){case se.EnvelopeType.envelopeTypeTxV0():n=se.TransactionEnvelope.envelopeTypeTxV0(new se.TransactionV0Envelope({tx:se.TransactionV0.fromXDR(e),signatures:t}));break;case se.EnvelopeType.envelopeTypeTx():n=se.TransactionEnvelope.envelopeTypeTx(new se.TransactionV1Envelope({tx:se.Transaction.fromXDR(e),signatures:t}));break;default:throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxV0 or envelopeTypeTx but received an ${this._envelopeType.name}.`)}return n}getClaimableBalanceId(e){if(!Number.isInteger(e)||e<0||e>=this.operations.length)throw new RangeError("invalid operation index");const t=this.operations[e];if(void 0===t)throw new RangeError("invalid operation index");try{Qr.createClaimableBalance(t)}catch(e){throw new TypeError(`expected createClaimableBalance, got ${t.type}: ${String(e)}`)}const n=wn.decodeEd25519PublicKey(Ln(this.source)),r=nt(se.HashIdPreimage.envelopeTypeOpId(new se.HashIdPreimageOperationId({sourceAccount:se.PublicKey.publicKeyTypeEd25519(n),seqNum:se.Int64.fromString(this.sequence),opNum:e})).toXDR("raw"));return se.ClaimableBalanceId.claimableBalanceIdTypeV0(r).toXDR("hex")}}class co extends Bn{_feeSource;_innerTransaction;constructor(e,t){if("string"==typeof e){const t=fe.Buffer.from(e,"base64");e=se.TransactionEnvelope.fromXDR(t)}const n=e.switch();if(n!==se.EnvelopeType.envelopeTypeTxFeeBump())throw new Error(`Invalid TransactionEnvelope: expected an envelopeTypeTxFeeBump but received an ${n.name}.`);const r=e.value(),o=r.tx(),s=o.fee().toString();super(o,(r.signatures()||[]).slice(),s,t);const i=se.TransactionEnvelope.envelopeTypeTx(o.innerTx().v1());this._feeSource=On(this.tx.feeSource()),this._innerTransaction=new ao(i,t)}get innerTransaction(){return this._innerTransaction}get operations(){return this._innerTransaction.operations}get feeSource(){return this._feeSource}signatureBase(){const e=se.TransactionSignaturePayloadTaggedTransaction.envelopeTypeTxFeeBump(this.tx);return new se.TransactionSignaturePayload({networkId:se.Hash.fromXDR(nt(this.networkPassphrase)),taggedTransaction:e}).toXDR()}toEnvelope(){const e=new se.FeeBumpTransactionEnvelope({tx:se.FeeBumpTransaction.fromXDR(this.tx.toXDR()),signatures:this.signatures.slice()});return se.TransactionEnvelope.envelopeTypeTxFeeBump(e)}}class uo{_accountId;sequence;constructor(e,t){if(wn.isValidMed25519PublicKey(e))throw new Error("accountId is an M-address; use MuxedAccount instead");if(!wn.isValidEd25519PublicKey(e))throw new Error("accountId is invalid");if("string"!=typeof t)throw new Error("sequence must be of type string");let n;try{n=new tr(t)}catch{throw new Error("sequence is not a valid number")}if(n.isNaN())throw new Error("sequence is not a valid number");this._accountId=e,this.sequence=n}accountId(){return this._accountId}sequenceNumber(){return this.sequence.toString()}incrementSequenceNumber(){this.sequence=this.sequence.plus(1)}}const lo=BigInt("18446744073709551615");function po(e){let t;try{t=BigInt(e)}catch{throw new Error(`id is not a valid uint64 string: ${e}`)}if(t<BigInt(0)||t>lo)throw new Error(`id value out of range for uint64 [0, ${lo}]: ${e}`)}class ho{account;_muxedXdr;_mAddress;_id;constructor(e,t){const n=e.accountId();if(!wn.isValidEd25519PublicKey(n))throw new Error("accountId is invalid");po(t),this.account=e,this._muxedXdr=Un(n,t),this._mAddress=On(this._muxedXdr),this._id=t}static fromAddress(e,t){const n=Pn(e),r=Ln(e),o=n.med25519().id().toString();return new ho(new uo(r,t),o)}baseAccount(){return this.account}accountId(){return this._mAddress}id(){return this._id}setId(e){if("string"!=typeof e)throw new Error("id should be a string representing a number (uint64)");return po(e),this._muxedXdr.med25519().id(se.Uint64.fromString(e)),this._mAddress=On(this._muxedXdr),this._id=e,this}sequenceNumber(){return this.account.sequenceNumber()}incrementSequenceNumber(){this.account.incrementSequenceNumber()}toXDRObject(){return this._muxedXdr}equals(e){return this.accountId()===e.accountId()}}class fo{_data;constructor(e){let t;t=e?"string"==typeof e||ArrayBuffer.isView(e)?fo.fromXDR(e):fo.fromXDR(e.toXDR()):new se.SorobanTransactionData({resources:new se.SorobanResources({footprint:new se.LedgerFootprint({readOnly:[],readWrite:[]}),instructions:0,diskReadBytes:0,writeBytes:0}),ext:new se.SorobanTransactionDataExt(0),resourceFee:new se.Int64(0)}),this._data=t}static fromXDR(e){return"string"==typeof e?se.SorobanTransactionData.fromXDR(e,"base64"):se.SorobanTransactionData.fromXDR(fe.Buffer.from(e),"raw")}setResourceFee(e){return this._data.resourceFee(new se.Int64(e)),this}setResources(e,t,n){return this._data.resources().instructions(e),this._data.resources().diskReadBytes(t),this._data.resources().writeBytes(n),this}appendFootprint(e,t){return this.setFootprint(this.getReadOnly().concat(e),this.getReadWrite().concat(t))}setFootprint(e,t){return null!==e&&this.setReadOnly(e),null!==t&&this.setReadWrite(t),this}setReadOnly(e){return this._data.resources().footprint().readOnly(e??[]),this}setReadWrite(e){return this._data.resources().footprint().readWrite(e??[]),this}build(){return se.SorobanTransactionData.fromXDR(this._data.toXDR())}getReadOnly(){return this.getFootprint().readOnly()}getReadWrite(){return this.getFootprint().readWrite()}getFootprint(){return this._data.resources().footprint()}}class mo{static decodeAddress(e){const t=wn.getVersionByteForPrefix(e);if(void 0===t)throw new Error(`invalid signer key type (${t})`);const n=Sn(t,e);switch(t){case"signedPayload":return se.SignerKey.signerKeyTypeEd25519SignedPayload(new se.SignerKeyEd25519SignedPayload({ed25519:n.subarray(0,32),payload:n.subarray(36,36+n.readUInt32BE(32))}));case"ed25519PublicKey":return se.SignerKey.signerKeyTypeEd25519(n);case"preAuthTx":return se.SignerKey.signerKeyTypePreAuthTx(n);case"sha256Hash":return se.SignerKey.signerKeyTypeHashX(n);default:throw new Error(`invalid signer key type (${t})`)}}static encodeSignerKey(e){let t,n;switch(e.switch()){case se.SignerKeyType.signerKeyTypeEd25519():t="ed25519PublicKey",n=e.value();break;case se.SignerKeyType.signerKeyTypePreAuthTx():t="preAuthTx",n=e.value();break;case se.SignerKeyType.signerKeyTypeHashX():t="sha256Hash",n=e.value();break;case se.SignerKeyType.signerKeyTypeEd25519SignedPayload():t="signedPayload",n=e.ed25519SignedPayload().toXDR("raw");break;default:throw new Error(`invalid SignerKey (type: ${e.switch().name})`)}return bn(t,n)}}class go{_id;constructor(e){try{this._id=wn.decodeContract(e)}catch{throw new Error(`Invalid contract ID: ${e}`)}}contractId(){return wn.encodeContract(this._id)}toString(){return this.contractId()}address(){return Xr.contract(this._id)}call(e,...t){return Qr.invokeContractFunction({contract:this.address().toString(),function:e,args:t})}getFootprint(){return se.LedgerKey.contractData(new se.LedgerKeyContractData({contract:this.address().toScAddress(),key:se.ScVal.scvLedgerKeyContractInstance(),durability:se.ContractDataDurability.persistent()}))}}class yo extends oe.LargeInt{constructor(...e){super(e)}get unsigned(){return!0}get size(){return 128}}yo.defineIntBoundaries();class wo extends oe.LargeInt{constructor(...e){super(e)}get unsigned(){return!0}get size(){return 256}}wo.defineIntBoundaries();class Ao extends oe.LargeInt{constructor(...e){super(e)}get unsigned(){return!1}get size(){return 128}}Ao.defineIntBoundaries();class So extends oe.LargeInt{constructor(...e){super(e)}get unsigned(){return!1}get size(){return 256}}So.defineIntBoundaries();class bo{int;type;constructor(e,t){t instanceof Array||(t=[t]);const n=t.map(e=>"bigint"==typeof e?e:"object"==typeof e&&null!==e&&"toBigInt"in e&&"function"==typeof e.toBigInt?e.toBigInt():BigInt(e));switch(e){case"i64":this.int=new oe.Hyper(n);break;case"i128":this.int=new Ao(...n);break;case"i256":this.int=new So(...n);break;case"u64":case"timepoint":case"duration":this.int=new oe.UnsignedHyper(n);break;case"u128":this.int=new yo(...n);break;case"u256":this.int=new wo(...n);break;default:throw TypeError(`invalid type: ${e}`)}this.type=e}toNumber(){const e=this.int.toBigInt();if(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw RangeError(`value ${e} not in range for Number [${Number.MAX_SAFE_INTEGER}, ${Number.MIN_SAFE_INTEGER}]`);return Number(e)}toBigInt(){return this.int.toBigInt()}toI64(){this._sizeCheck(64);const e=this.toBigInt();if(BigInt.asIntN(64,e)!==e)throw RangeError(`value too large for i64: ${e}`);return se.ScVal.scvI64(new se.Int64(e))}toU64(){return this._sizeCheck(64),se.ScVal.scvU64(new se.Uint64(BigInt.asUintN(64,this.toBigInt())))}toTimepoint(){return this._sizeCheck(64),se.ScVal.scvTimepoint(new se.Uint64(BigInt.asUintN(64,this.toBigInt())))}toDuration(){return this._sizeCheck(64),se.ScVal.scvDuration(new se.Uint64(BigInt.asUintN(64,this.toBigInt())))}toI128(){this._sizeCheck(128);const e=this.int.toBigInt();if(BigInt.asIntN(128,e)!==e)throw RangeError(`value too large for i128: ${e}`);const t=BigInt.asIntN(64,e>>64n),n=BigInt.asUintN(64,e);return se.ScVal.scvI128(new se.Int128Parts({hi:new se.Int64(t),lo:new se.Uint64(n)}))}toU128(){this._sizeCheck(128);const e=this.int.toBigInt();return se.ScVal.scvU128(new se.UInt128Parts({hi:new se.Uint64(BigInt.asUintN(64,e>>64n)),lo:new se.Uint64(BigInt.asUintN(64,e))}))}toI256(){const e=this.int.toBigInt();if(BigInt.asIntN(256,e)!==e)throw RangeError(`value too large for i256: ${e}`);const t=BigInt.asIntN(64,e>>192n),n=BigInt.asUintN(64,e>>128n),r=BigInt.asUintN(64,e>>64n),o=BigInt.asUintN(64,e);return se.ScVal.scvI256(new se.Int256Parts({hiHi:new se.Int64(t),hiLo:new se.Uint64(n),loHi:new se.Uint64(r),loLo:new se.Uint64(o)}))}toU256(){const e=this.int.toBigInt(),t=BigInt.asUintN(64,e>>192n),n=BigInt.asUintN(64,e>>128n),r=BigInt.asUintN(64,e>>64n),o=BigInt.asUintN(64,e);return se.ScVal.scvU256(new se.UInt256Parts({hiHi:new se.Uint64(t),hiLo:new se.Uint64(n),loHi:new se.Uint64(r),loLo:new se.Uint64(o)}))}toScVal(){switch(this.type){case"i64":return this.toI64();case"i128":return this.toI128();case"i256":return this.toI256();case"u64":return this.toU64();case"u128":return this.toU128();case"u256":return this.toU256();case"timepoint":return this.toTimepoint();case"duration":return this.toDuration();default:throw TypeError(`invalid type: ${this.type}`)}}valueOf(){return this.int.valueOf()}toString(){return this.int.toString()}toJSON(){return{value:this.toBigInt().toString(),type:this.type}}_sizeCheck(e){if(this.int.size>e)throw RangeError(`value too large for ${e} bits (${this.type})`)}static isType(e){switch(e){case"i64":case"i128":case"i256":case"u64":case"u128":case"u256":case"timepoint":case"duration":return!0;default:return!1}}static getType(e){const t=e.slice(3).toLowerCase();if(this.isType(t))return t}}class vo extends bo{constructor(e,t){const n=BigInt(e),r=n<0n;let o=t?.type??"";if(o.startsWith("u")&&r)throw TypeError(`specified type ${t?.type} yet negative (${e})`);if(""===o){o=r?"i":"u";const t=function(e){if(e<0n){const t=(-e-1n).toString(2).length+1;return[64,128,256].find(e=>t<=e)??t}const t=e.toString(2).length;return[64,128,256].find(e=>t<=e)??t}(n);switch(t){case 64:case 128:case 256:o+=t.toString();break;default:throw RangeError(`expected 64/128/256 bits for input (${e}), got ${t}`)}}super(o,n)}}function To(e){const t=e.switch().name,n=bo.getType(t),r=e.value();if(null===r)throw TypeError(`unexpected null value for ${t}`);switch(t){case"scvU32":case"scvI32":return BigInt(r);case"scvU64":case"scvI64":case"scvTimepoint":case"scvDuration":if(void 0===n)throw TypeError(`invalid integer type for ${t}`);return new bo(n,r).toBigInt();case"scvU128":case"scvI128":{if(void 0===n)throw TypeError(`invalid integer type for ${t}`);const e=r;return new bo(n,[e.lo(),e.hi()]).toBigInt()}case"scvU256":case"scvI256":{if(void 0===n)throw TypeError(`invalid integer type for ${t}`);const e=r;return new bo(n,[e.loLo(),e.loHi(),e.hiLo(),e.hiHi()]).toBigInt()}default:throw TypeError(`expected integer type, got ${t}`)}}function Eo(e,t={}){switch(typeof e){case"object":{if(null===e)return se.ScVal.scvVoid();if(e instanceof se.ScVal)return e;if(e instanceof Xr)return e.toScVal();if(e instanceof Tn)return Eo(e.publicKey(),{type:"address"});if(e instanceof go)return e.address().toScVal();if(e instanceof Uint8Array||fe.Buffer.isBuffer(e)){const n=fe.Buffer.from(e);switch(t?.type??"bytes"){case"bytes":return se.ScVal.scvBytes(n);case"symbol":return se.ScVal.scvSymbol(n);case"string":return se.ScVal.scvString(n);default:throw new TypeError(`invalid type (${JSON.stringify(t.type)}) specified for bytes-like value`)}}if(Array.isArray(e))return se.ScVal.scvVec(e.map((e,n)=>Array.isArray(t.type)?Eo(e,{...t.type.length>n&&{type:t.type[n]}}):Eo(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype)throw new TypeError(`cannot interpret ${e.constructor?.name} value as ScVal (${JSON.stringify(e)})`);const n=t?.type??{};return se.ScVal.scvMap(Object.entries(e).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>{const[r,o]=Object.hasOwn(n,e)?n[e]??[null,null]:[null,null],s=r?{type:r}:{},i=o?{type:o}:{};return new se.ScMapEntry({key:Eo(e,s),val:Eo(t,i)})}))}case"number":case"bigint":{const n=BigInt(e);switch(t?.type){case"u32":if(n<BigInt(se.Uint32.MIN_VALUE)||n>BigInt(se.Uint32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type u32`);return se.ScVal.scvU32(Number(e));case"i32":if(n<-BigInt(se.Int32.MIN_VALUE)||n>BigInt(se.Int32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type i32`);return se.ScVal.scvI32(Number(e))}return new vo(e,{type:t?.type}).toScVal()}case"string":{const n=t?.type??"string";switch(n){case"string":return se.ScVal.scvString(e);case"symbol":return se.ScVal.scvSymbol(e);case"address":return new Xr(e).toScVal();case"u32":{const t=BigInt(e);if(t<BigInt(se.Uint32.MIN_VALUE)||t>BigInt(se.Uint32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type u32`);return se.ScVal.scvU32(Number(t))}case"i32":{const t=BigInt(e);if(t<-BigInt(se.Int32.MIN_VALUE)||t>BigInt(se.Int32.MAX_VALUE))throw new TypeError(`invalid value (${e}) for type i32`);return se.ScVal.scvI32(Number(t))}default:if(bo.isType(n))return new bo(n,e).toScVal();throw new TypeError(`invalid type (${JSON.stringify(t.type)}) specified for string value`)}}case"boolean":return se.ScVal.scvBool(e);case"undefined":return se.ScVal.scvVoid();case"function":return Eo(e());default:throw new TypeError(`failed to convert typeof ${typeof e} (${JSON.stringify(e)})`)}}function ko(e){switch(e.switch().value){case se.ScValType.scvVoid().value:return null;case se.ScValType.scvU64().value:case se.ScValType.scvI64().value:return e.value().toBigInt();case se.ScValType.scvU128().value:case se.ScValType.scvI128().value:case se.ScValType.scvU256().value:case se.ScValType.scvI256().value:return To(e);case se.ScValType.scvVec().value:return(e.vec()??[]).map(ko);case se.ScValType.scvAddress().value:return Xr.fromScVal(e).toString();case se.ScValType.scvMap().value:return Object.fromEntries((e.map()??[]).map(e=>[ko(e.key()),ko(e.val())]));case se.ScValType.scvBool().value:case se.ScValType.scvU32().value:case se.ScValType.scvI32().value:case se.ScValType.scvBytes().value:return e.value();case se.ScValType.scvSymbol().value:{const t=e.sym();if(fe.Buffer.isBuffer(t)||ArrayBuffer.isView(t)&&"string"!=typeof t)try{return(new TextDecoder).decode(t)}catch{return new Uint8Array(t.buffer)}return t}case se.ScValType.scvString().value:{const t=e.str();if(fe.Buffer.isBuffer(t)||ArrayBuffer.isView(t)&&"string"!=typeof t)try{return(new TextDecoder).decode(t)}catch{return new Uint8Array(t.buffer)}return t}case se.ScValType.scvTimepoint().value:case se.ScValType.scvDuration().value:return e.value().toBigInt();case se.ScValType.scvError().value:if(e.error().switch().value===se.ScErrorType.sceContract().value)return{type:"contract",code:e.error().contractCode()};{const t=e.error();return{type:"system",code:t.code().value,value:t.code().name}}default:return e.value()}}function Io(e){const t=Array.from(e).sort((e,t)=>{const n=ko(e.key()),r=ko(t.key());switch(typeof n){case"number":case"bigint":return n===r?0:n<r?-1:1;default:{const e=n.toString(),t=r.toString();return e<t?-1:e>t?1:0}}});return se.ScVal.scvMap(t)}se.scvSortedMap=Io;const Co=oe.Hyper.MAX_VALUE,Bo=4294967295,xo="100";class Ro{source;operations;baseFee;timebounds;ledgerbounds;minAccountSequence;minAccountSequenceAge;minAccountSequenceLedgerGap;extraSigners;memo;networkPassphrase;sorobanData;constructor(e,t={}){if(!e)throw new Error("must specify source account for the transaction");if(void 0===t.fee)throw new Error("must specify fee for the transaction (in stroops)");if(this.source=e,this.operations=[],this.baseFee=t.fee,t.timebounds){const e=Po(t.timebounds.minTime),n=Po(t.timebounds.maxTime);if(void 0!==e&&e<0)throw new Error("min_time cannot be negative");if(void 0!==n&&n<0)throw new Error("max_time cannot be negative");if(void 0!==e&&void 0!==n&&n>0&&e>n)throw new Error("min_time cannot be greater than max_time");this.timebounds={...t.timebounds}}else this.timebounds=null;if(t.ledgerbounds){const e=t.ledgerbounds.minLedger,n=t.ledgerbounds.maxLedger;if(void 0!==e&&e<0)throw new Error("min_ledger cannot be negative");if(void 0!==n&&n<0)throw new Error("max_ledger cannot be negative");if(void 0!==e&&void 0!==n&&n>0&&e>n)throw new Error("min_ledger cannot be greater than max_ledger");this.ledgerbounds={...t.ledgerbounds}}else this.ledgerbounds=null;this.minAccountSequence=t.minAccountSequence||null,this.minAccountSequenceAge=void 0!==t.minAccountSequenceAge?t.minAccountSequenceAge:null,this.minAccountSequenceLedgerGap=void 0!==t.minAccountSequenceLedgerGap?t.minAccountSequenceLedgerGap:null,this.extraSigners=t.extraSigners?[...t.extraSigners]:null,this.memo=t.memo||io.none(),this.networkPassphrase=t.networkPassphrase||null,this.sorobanData=t.sorobanData?new fo(t.sorobanData).build():null}static cloneFrom(e,t={}){if(!(e instanceof ao))throw new TypeError(`expected a 'Transaction', got: ${String(e)}`);const n=(BigInt(e.sequence)-1n).toString();let r,o;if(wn.isValidMed25519PublicKey(e.source))r=ho.fromAddress(e.source,n);else{if(!wn.isValidEd25519PublicKey(e.source))throw new TypeError(`unsupported tx source account: ${e.source}`);r=new uo(e.source,n)}if(0===e.operations.length)throw new Error("cannot clone a transaction with no operations: per-operation base fee cannot be determined");const s=e.toEnvelope();s.switch()===se.EnvelopeType.envelopeTypeTx()&&(o=s.v1().tx().ext().value()??void 0);let i=parseInt(e.fee,10);if(o){const e=Number(o.resourceFee().toBigInt());i-e>0&&(i-=e)}const a={fee:(Math.floor(i/e.operations.length)||xo).toString(),memo:e.memo,networkPassphrase:e.networkPassphrase};e.timeBounds&&(a.timebounds=e.timeBounds),e.ledgerBounds&&(a.ledgerbounds=e.ledgerBounds),e.minAccountSequence&&(a.minAccountSequence=e.minAccountSequence),void 0!==e.minAccountSequenceAge&&(a.minAccountSequenceAge=e.minAccountSequenceAge),void 0!==e.minAccountSequenceLedgerGap&&(a.minAccountSequenceLedgerGap=e.minAccountSequenceLedgerGap),e.extraSigners&&(a.extraSigners=e.extraSigners.map(e=>mo.encodeSignerKey(e))),Object.assign(a,t);const c=new Ro(r,a);return e.tx.operations().forEach(e=>c.addOperation(e)),c}addOperation(e){return this.operations.push(e),this}addOperationAt(e,t){return this.operations.splice(t,0,e),this}clearOperations(){return this.operations=[],this}clearOperationAt(e){return this.operations.splice(e,1),this}addMemo(e){return this.memo=e,this}setTimeout(e){if(null!==this.timebounds&&Number(this.timebounds.maxTime)>0)throw new Error("TimeBounds.max_time has been already set - setting timeout would overwrite it.");if(e<0)throw new Error("timeout cannot be negative");if(e>0){const t=Math.floor(Date.now()/1e3)+e;null===this.timebounds?this.timebounds={minTime:0,maxTime:t}:this.timebounds={minTime:this.timebounds.minTime??0,maxTime:t}}else this.timebounds={minTime:0,maxTime:0};return this}setTimebounds(e,t){if("number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof t&&(t=new Date(1e3*t)),null!==this.timebounds)throw new Error("TimeBounds has been already set - setting timebounds would overwrite it.");const n=Math.floor(e.valueOf()/1e3),r=Math.floor(t.valueOf()/1e3);if(n<0)throw new Error("min_time cannot be negative");if(r<0)throw new Error("max_time cannot be negative");if(r>0&&n>r)throw new Error("min_time cannot be greater than max_time");return this.timebounds={minTime:n,maxTime:r},this}setLedgerbounds(e,t){if(null!==this.ledgerbounds)throw new Error("LedgerBounds has been already set - setting ledgerbounds would overwrite it.");if(e<0)throw new Error("min_ledger cannot be negative");if(t<0)throw new Error("max_ledger cannot be negative");if(t>0&&e>t)throw new Error("min_ledger cannot be greater than max_ledger");return this.ledgerbounds={minLedger:e,maxLedger:t},this}setMinAccountSequence(e){if(null!==this.minAccountSequence)throw new Error("min_account_sequence has been already set - setting min_account_sequence would overwrite it.");return this.minAccountSequence=e,this}setMinAccountSequenceAge(e){if("bigint"!=typeof e)throw new Error("min_account_sequence_age must be a bigint");if(null!==this.minAccountSequenceAge)throw new Error("min_account_sequence_age has been already set - setting min_account_sequence_age would overwrite it.");if(e<0)throw new Error("min_account_sequence_age cannot be negative");return this.minAccountSequenceAge=e,this}setMinAccountSequenceLedgerGap(e){if(null!==this.minAccountSequenceLedgerGap)throw new Error("min_account_sequence_ledger_gap has been already set - setting min_account_sequence_ledger_gap would overwrite it.");if(e<0)throw new Error("min_account_sequence_ledger_gap cannot be negative");return this.minAccountSequenceLedgerGap=e,this}setExtraSigners(e){if(!Array.isArray(e))throw new Error("extra_signers must be an array of strings.");if(null!==this.extraSigners)throw new Error("extra_signers has been already set - setting extra_signers would overwrite it.");if(e.length>2)throw new Error("extra_signers cannot be longer than 2 elements.");return this.extraSigners=[...e],this}setNetworkPassphrase(e){return this.networkPassphrase=e,this}setSorobanData(e){return this.sorobanData=new fo(e).build(),this}addSacTransferOperation(e,t,n,r){if(BigInt(n)<=0n)throw new Error("Amount must be a positive integer");if(BigInt(n)>Co)throw new Error("Amount exceeds maximum value for i64");if(r){const{instructions:e,readBytes:t,writeBytes:n,resourceFee:o}=r,s=4294967295;if(e<=0||e>s)throw new Error(`instructions must be greater than 0 and at most ${s}`);if(t<=0||t>s)throw new Error(`readBytes must be greater than 0 and at most ${s}`);if(n<=0||n>s)throw new Error(`writeBytes must be greater than 0 and at most ${s}`);if(o<=0n||o>Co)throw new Error("resourceFee must be greater than 0 and at most i64 max")}const o=wn.isValidContract(e);if(!o&&!wn.isValidEd25519PublicKey(e)&&!wn.isValidMed25519PublicKey(e))throw new Error("Invalid destination address. Must be a valid Stellar address or contract ID.");const s=o?e:Ln(e);if(s===Ln(this.source.accountId()))throw new Error("Destination cannot be the same as the source account.");if(null===this.networkPassphrase)throw new Error("networkPassphrase must be set to add a SAC transfer operation");const i=t.contractId(this.networkPassphrase),a="transfer",c=this.source.accountId(),u=Ln(c),l=[Eo(c,{type:"address"}),Eo(e,{type:"address"}),Eo(n,{type:"i128"})],d=t.isNative(),p=new se.SorobanAuthorizationEntry({credentials:se.SorobanCredentials.sorobanCredentialsSourceAccount(),rootInvocation:new se.SorobanAuthorizedInvocation({function:se.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeContractFn(new se.InvokeContractArgs({contractAddress:Xr.fromString(i).toScAddress(),functionName:a,args:l})),subInvocations:[]})}),h=new se.LedgerFootprint({readOnly:[se.LedgerKey.contractData(new se.LedgerKeyContractData({contract:Xr.fromString(i).toScAddress(),key:se.ScVal.scvLedgerKeyContractInstance(),durability:se.ContractDataDurability.persistent()}))],readWrite:[]});if(o){if(h.readWrite().push(se.LedgerKey.contractData(new se.LedgerKeyContractData({contract:Xr.fromString(i).toScAddress(),key:se.ScVal.scvVec([Eo("Balance",{type:"symbol"}),Eo(e,{type:"address"})]),durability:se.ContractDataDurability.persistent()}))),!d){const e=t.getIssuer();if(!e)throw new Error("Asset issuer must be set for non-native assets.");h.readOnly().push(se.LedgerKey.account(new se.LedgerKeyAccount({accountId:Tn.fromPublicKey(e).xdrPublicKey()})))}}else d?h.readWrite().push(se.LedgerKey.account(new se.LedgerKeyAccount({accountId:Tn.fromPublicKey(s).xdrPublicKey()}))):t.getIssuer()!==s&&h.readWrite().push(se.LedgerKey.trustline(new se.LedgerKeyTrustLine({accountId:Tn.fromPublicKey(s).xdrPublicKey(),asset:t.toTrustLineXDRObject()})));t.isNative()?h.readWrite().push(se.LedgerKey.account(new se.LedgerKeyAccount({accountId:Tn.fromPublicKey(u).xdrPublicKey()}))):t.getIssuer()!==u&&h.readWrite().push(se.LedgerKey.trustline(new se.LedgerKeyTrustLine({accountId:Tn.fromPublicKey(u).xdrPublicKey(),asset:t.toTrustLineXDRObject()})));const f={instructions:4e5,readBytes:1e3,writeBytes:1e3,resourceFee:BigInt(5e6)},m=new se.SorobanTransactionData({resources:new se.SorobanResources({footprint:h,instructions:r?r.instructions:f.instructions,diskReadBytes:r?r.readBytes:f.readBytes,writeBytes:r?r.writeBytes:f.writeBytes}),ext:new se.SorobanTransactionDataExt(0),resourceFee:new se.Int64(r?r.resourceFee:f.resourceFee)}),g=Qr.invokeContractFunction({contract:i,function:a,args:l,auth:[p]});return this.setSorobanData(m),this.addOperation(g)}build(){const e=new tr(this.source.sequenceNumber()).plus(1),t=new tr(this.baseFee).times(this.operations.length).toNumber();if(t>Bo)throw new Error(`Total fee (baseFee * operations) exceeds the maximum uint32 value (4294967295). Got ${t} from baseFee=${this.baseFee} and ${this.operations.length} operation(s).`);const n={fee:t,seqNum:se.Int64.fromString(e.toString()),memo:this.memo?this.memo.toXDRObject():null};if(null===this.timebounds||void 0===this.timebounds.minTime||void 0===this.timebounds.maxTime)throw new Error("TimeBounds has to be set or you must call setTimeout(TimeoutInfinite).");_o(this.timebounds.minTime)&&(this.timebounds.minTime=Math.floor(this.timebounds.minTime.getTime()/1e3)),_o(this.timebounds.maxTime)&&(this.timebounds.maxTime=Math.floor(this.timebounds.maxTime.getTime()/1e3));const r=se.Uint64.fromString(this.timebounds.minTime.toString()),o=se.Uint64.fromString(this.timebounds.maxTime.toString()),s=new se.TimeBounds({minTime:r,maxTime:o});if(this.hasV2Preconditions()){let e=null;null!==this.ledgerbounds&&(e=new se.LedgerBounds({minLedger:this.ledgerbounds.minLedger??0,maxLedger:this.ledgerbounds.maxLedger??0}));const t=this.minAccountSequence?se.Int64.fromString(this.minAccountSequence):null,r=se.Uint64.fromString(null!==this.minAccountSequenceAge?this.minAccountSequenceAge.toString():"0"),o=this.minAccountSequenceLedgerGap||0,i=null!==this.extraSigners?this.extraSigners.map(e=>mo.decodeAddress(e)):[];n.cond=se.Preconditions.precondV2(new se.PreconditionsV2({timeBounds:s,ledgerBounds:e,minSeqNum:t,minSeqAge:r,minSeqLedgerGap:o,extraSigners:i}))}else n.cond=se.Preconditions.precondTime(s);if(n.sourceAccount=Pn(this.source.accountId()),this.sorobanData){if(n.ext=new se.TransactionExt(1,this.sorobanData),n.fee=new tr(n.fee).plus(this.sorobanData.resourceFee().toString()).toNumber(),n.fee>Bo)throw new Error(`Total fee (baseFee * operations + resourceFee) exceeds the maximum uint32 value (4294967295). Got ${n.fee}.`)}else n.ext=new se.TransactionExt(0);const i=new se.Transaction(n);i.operations(this.operations);const a=se.TransactionEnvelope.envelopeTypeTx(new se.TransactionV1Envelope({tx:i,signatures:[]}));if(null===this.networkPassphrase)throw new Error("networkPassphrase must be set to build a transaction");const c=new ao(a,this.networkPassphrase);return this.source.incrementSequenceNumber(),c}hasV2Preconditions(){return null!==this.ledgerbounds||null!==this.minAccountSequence||null!==this.minAccountSequenceAge||null!==this.minAccountSequenceLedgerGap||null!==this.extraSigners&&this.extraSigners.length>0}static buildFeeBumpTransaction(e,t,n,r){const o=n.operations.length,s=new tr(xo);let i=new tr(0);const a=n.toEnvelope();switch(a.switch().value){case se.EnvelopeType.envelopeTypeTx().value:{const e=a.v1().tx().ext().value();i=new tr(e?.resourceFee().toString()??0);break}}const c=new tr(n.fee).minus(i).div(o),u=new tr(t);if(u.lt(c))throw new Error(`Invalid baseFee, it should be at least ${c.toString()} stroops.`);if(u.lt(s))throw new Error(`Invalid baseFee, it should be at least ${s.toString()} stroops.`);let l,d=n.toEnvelope();if(d.switch()===se.EnvelopeType.envelopeTypeTxV0()){const e=d.v0().tx(),t=e.timeBounds();if(null===t)throw new Error("Inner transaction must have time bounds");const n=new se.Transaction({sourceAccount:se.MuxedAccount.keyTypeEd25519(e.sourceAccountEd25519()),fee:e.fee(),seqNum:e.seqNum(),cond:se.Preconditions.precondTime(t),memo:e.memo(),operations:e.operations(),ext:new se.TransactionExt(0)});d=se.TransactionEnvelope.envelopeTypeTx(new se.TransactionV1Envelope({tx:n,signatures:d.v0().signatures()}))}l="string"==typeof e?Pn(e):e.xdrMuxedAccount();const p=new se.FeeBumpTransaction({feeSource:l,fee:se.Int64.fromString(u.times(o+1).plus(i).toString()),innerTx:se.FeeBumpTransactionInnerTx.envelopeTypeTx(d.v1()),ext:new se.FeeBumpTransactionExt(0)}),h=new se.FeeBumpTransactionEnvelope({tx:p,signatures:[]}),f=se.TransactionEnvelope.envelopeTypeTxFeeBump(h);return new co(f,r)}static fromXDR(e,t){return"string"==typeof e&&(e=se.TransactionEnvelope.fromXDR(e,"base64")),e.switch()===se.EnvelopeType.envelopeTypeTxFeeBump()?new co(e,t):new ao(e,t)}}function _o(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function Po(e){if(void 0===e)return;const t=e instanceof Date?Math.floor(e.getTime()/1e3):Number(e);if(!Number.isFinite(t)||t%1!=0)throw new Error("timebounds value must be a finite integer or Date");return t}var Oo=(e=>(e.PUBLIC="Public Global Stellar Network ; September 2015",e.TESTNET="Test SDF Network ; September 2015",e.FUTURENET="Test SDF Future Network ; October 2022",e.SANDBOX="Local Sandbox Stellar Network ; September 2022",e.STANDALONE="Standalone Network ; February 2017",e))(Oo||{});class Uo{static formatTokenAmount(e,t){if(e.includes("."))throw new TypeError("No decimals are allowed");const n=e.startsWith("-");let r=n?e.slice(1):e;return t>0&&(r=t>r.length?["0",r.toString().padStart(t,"0")].join("."):[r.slice(0,-t),r.slice(-t)].join(".")),r.includes(".")&&(r=r.replace(/0+$/,""),r.endsWith(".")&&(r+="0")),r.startsWith(".")&&(r=`0${r}`),n?`-${r}`:r}static parseTokenAmount(e,t){const[n,r,...o]=e.split(".").slice();if(o.length)throw new Error(`Invalid decimal value: ${e}`);if(r?.length&&r.length>t)throw new Error(`Too many decimal places in "${e}": expected at most ${t}, got ${r.length}`);return BigInt(n+(r?.padEnd(t,"0")??"0".repeat(t))).toString()}}function Lo(e){const t="function"==typeof e.contractId?e.contractId():null;return{...null!=t&&{contractId:wn.encodeContract(t)},type:e.type().name,topics:e.body().value().topics().map(e=>ko(e)),data:ko(e.body().value().data())}}function No(e){return e.map(e=>Lo("inSuccessfulContractCall"in e?e.event():e))}function Vo(e){return e instanceof ArrayBuffer?fe.Buffer.from(new Uint8Array(e)):fe.Buffer.from(e)}async function Fo(e,t,n,r,o){if(e.credentials().switch().value===se.SorobanCredentialsType.sorobanCredentialsSourceAccount().value)return e;const s=se.SorobanAuthorizationEntry.fromXDR(e.toXDR()),i=s.credentials(),a=Go(i);if(null===a)throw new Error(`unsupported credential type ${i.switch().name}`);a.signatureExpirationLedger(n);const c=Mo(s,n,r),u=nt(c.toXDR());let l,d;if("function"==typeof t){const e=await t(c);null!==e&&"object"==typeof e&&"signature"in e?(l=Vo(e.signature),d=e.publicKey):(l=Vo(e),d=Xr.fromScAddress(a.address()).toString())}else l=Vo(t.sign(u)),d=t.publicKey();if(!Tn.fromPublicKey(d).verify(u,l))throw new Error("signature doesn't match payload");const p=Eo({public_key:wn.decodeEd25519PublicKey(d),signature:l},{type:{public_key:["symbol",null],signature:["symbol",null]}}),h=se.ScVal.scvVec([p]),f=void 0===o?[a]:function(e){switch(e.switch().value){case se.SorobanCredentialsType.sorobanCredentialsAddress().value:return[e.address()];case se.SorobanCredentialsType.sorobanCredentialsAddressV2().value:return[e.addressV2()];case se.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:{const t=e.addressWithDelegates(),n=[t.addressCredentials()],r=e=>{e.forEach(e=>{n.push(e),r(e.nestedDelegates())})};return r(t.delegates()),n}default:return[]}}(i).filter(e=>Xr.fromScAddress(e.address()).toString()===o);if(0===f.length)throw new Error(`the authorization entry has no credential node for address ${o}`);return f.forEach(e=>e.signature(h)),s}function Do(e){const{signer:t,validUntilLedgerSeq:n,invocation:r,networkPassphrase:o,publicKey:s="",authV2:i=!1}=e,a=Tn.random().rawPublicKey(),c=new se.Int64(function(e){const t=e.subarray(0,8);if(t.length<8)throw new Error(`need at least 8 bytes to convert to Int64, got ${e.length}`);const n=new DataView(t.buffer,t.byteOffset,8);return n.getBigInt64(0,!1)}(a)),u=s||(t instanceof Tn?t.publicKey():null);if(!u)throw new Error("authorizeInvocation requires publicKey parameter");const l=new se.SorobanAddressCredentials({address:new Xr(u).toScAddress(),nonce:c,signatureExpirationLedger:0,signature:se.ScVal.scvVec([])});return Fo(new se.SorobanAuthorizationEntry({rootInvocation:r,credentials:i?se.SorobanCredentials.sorobanCredentialsAddressV2(l):se.SorobanCredentials.sorobanCredentialsAddress(l)}),t,n,o)}function Mo(e,t,n){const r=e.credentials(),o=Go(r);if(null===o)throw new Error(`cannot build a signature payload for credential type ${r.switch().name}`);const s=nt(fe.Buffer.from(n));switch(r.switch().value){case se.SorobanCredentialsType.sorobanCredentialsAddress().value:return se.HashIdPreimage.envelopeTypeSorobanAuthorization(new se.HashIdPreimageSorobanAuthorization({networkId:s,nonce:o.nonce(),invocation:e.rootInvocation(),signatureExpirationLedger:t}));case se.SorobanCredentialsType.sorobanCredentialsAddressV2().value:case se.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:return se.HashIdPreimage.envelopeTypeSorobanAuthorizationWithAddress(new se.HashIdPreimageSorobanAuthorizationWithAddress({networkId:s,nonce:o.nonce(),invocation:e.rootInvocation(),address:o.address(),signatureExpirationLedger:t}));default:throw new Error(`unsupported credential type ${r.switch().name}`)}}function qo(e){const{entry:t,validUntilLedgerSeq:n,delegates:r,signature:o}=e,s=t.credentials(),i=Go(s);if(null===i||s.switch().value===se.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value)throw new Error(`buildWithDelegatesEntry expects ADDRESS or ADDRESS_V2 credentials, got ${s.switch().name}`);return new se.SorobanAuthorizationEntry({rootInvocation:t.rootInvocation(),credentials:se.SorobanCredentials.sorobanCredentialsAddressWithDelegates(new se.SorobanAddressCredentialsWithDelegates({addressCredentials:new se.SorobanAddressCredentials({address:i.address(),nonce:i.nonce(),signatureExpirationLedger:n,signature:o??se.ScVal.scvVoid()}),delegates:Ho(r)}))})}function Ho(e){const t=e.map(e=>new se.SorobanDelegateSignature({address:new Xr(e.address).toScAddress(),signature:e.signature??se.ScVal.scvVoid(),nestedDelegates:Ho(e.nestedDelegates??[])}));t.sort((e,t)=>fe.Buffer.compare(e.address().toXDR(),t.address().toXDR()));for(let e=1;e<t.length;e++)if(0===fe.Buffer.compare(t[e-1].address().toXDR(),t[e].address().toXDR()))throw new Error(`duplicate delegate address ${Xr.fromScAddress(t[e].address()).toString()}`);return t}function Go(e){switch(e.switch().value){case se.SorobanCredentialsType.sorobanCredentialsAddress().value:return e.address();case se.SorobanCredentialsType.sorobanCredentialsAddressV2().value:return e.addressV2();case se.SorobanCredentialsType.sorobanCredentialsAddressWithDelegates().value:return e.addressWithDelegates().addressCredentials();default:return null}}function $o(e){const t=e.function(),n={},r=t.value();switch(t.switch().value){case 0:{const e=t.contractFn();n.type="execute",n.args={source:Xr.fromScAddress(e.contractAddress()).toString(),function:e.functionName().toString(),args:e.args().map(e=>ko(e))};break}case 1:case 2:{const e=r,o=2===t.switch().value;n.type="create";const s={},[i,a]=[e.executable(),e.contractIdPreimage()];if(!!i.switch().value!=!!a.switch().value)throw new Error(`creation function appears invalid: ${JSON.stringify(r)} (should be wasm+address or token+asset)`);switch(i.switch().value){case 0:{const e=a.fromAddress();s.type="wasm",s.wasm={salt:fe.Buffer.from(e.salt()).toString("hex"),hash:i.wasmHash().toString("hex"),address:Xr.fromScAddress(e.address()).toString(),...o&&{constructorArgs:r.constructorArgs().map(e=>ko(e))}};break}case 1:s.type="sac",s.asset=In.fromOperation(a.fromAsset()).toString();break;default:throw new Error(`unknown creation type: ${JSON.stringify(i)}`)}n.args=s;break}default:throw new Error(`unknown invocation type (${t.switch().value}): ${JSON.stringify(t)}`)}return n.invocations=e.subInvocations().map(e=>$o(e)),n}function Xo(e,t){Ko(e,1,t)}function Ko(e,t,n,r){!1!==n(e,t,r)&&e.subInvocations().forEach(r=>Ko(r,t+1,n,e))}var Wo=Object.freeze({__proto__:null,Account:uo,Address:Xr,Asset:In,AssetType:En,AuthClawbackEnabledFlag:8,AuthImmutableFlag:4,AuthRequiredFlag:1,AuthRevocableFlag:2,BASE_FEE:xo,Claimant:Rn,Contract:go,FeeBumpTransaction:co,Hyper:oe.Hyper,Int128:Ao,Int256:So,Keypair:Tn,LiquidityPoolAsset:xn,LiquidityPoolFeeV18:30,LiquidityPoolId:_n,Memo:io,MemoHash:oo,MemoID:no,MemoNone:to,MemoReturn:so,MemoText:ro,MuxedAccount:ho,Networks:Oo,Operation:Qr,ScInt:vo,SignerKey:mo,Soroban:Uo,SorobanDataBuilder:fo,StrKey:wn,TimeoutInfinite:0,Transaction:ao,TransactionBase:Bn,TransactionBuilder:Ro,Uint128:yo,Uint256:wo,UnsignedHyper:oe.UnsignedHyper,XdrLargeInt:bo,authorizeEntry:Fo,authorizeInvocation:Do,buildAuthorizationEntryPreimage:Mo,buildInvocationTree:$o,buildWithDelegatesEntry:qo,cereal:ie,decodeAddressToMuxedAccount:Pn,encodeMuxedAccount:Un,encodeMuxedAccountToAddress:On,extractBaseAddress:Ln,getLiquidityPoolId:Cn,hash:nt,humanizeEvents:No,nativeToScVal:Eo,scValToBigInt:To,scValToNative:ko,scvSortedMap:Io,sign:cn,verify:un,walkInvocationTree:Xo,xdr:se});function Zo(e){if(!/^(?:[A-Za-z](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)*[A-Za-z](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?::\d+)?$/.test(e))throw new Error("The provided domain is invalid. Ensure that the domain adheres to RFC 1035")}const zo=102400;class jo{serverURL;domain;timeout;static async resolve(e,t={}){if(e.indexOf("*")<0)return wn.isValidEd25519PublicKey(e)?Promise.resolve({account_id:e}):Promise.reject(new Error("Invalid Account ID"));const n=e.split("*"),[,r]=n;if(2!==n.length||!r)return Promise.reject(new Error("Invalid Stellar address"));return(await jo.createForDomain(r,t)).resolveAddress(e)}static async createForDomain(e,t={}){Zo(e);const n=await Q.resolve(e,t);return n.FEDERATION_SERVER?new jo(n.FEDERATION_SERVER,e,t):Promise.reject(new Error("stellar.toml does not contain FEDERATION_SERVER field"))}constructor(e,t,n={}){this.serverURL=new URL(e),this.domain=t,Zo(t);const r=void 0===n.allowHttp?_.isAllowHttp():n.allowHttp;if(this.timeout=void 0===n.timeout?_.getTimeout():n.timeout,"https:"!==this.serverURL.protocol&&!r)throw new Error("Cannot connect to insecure federation server")}async resolveAddress(e){let t=e;if(e.indexOf("*")<0){if(!this.domain)return Promise.reject(new Error("Unknown domain. Make sure `address` contains a domain (ex. `bob*stellar.org`) or pass `domain` parameter when instantiating the server object."));t=`${e}*${this.domain}`}const n=new URL(this.serverURL);return n.search="",n.searchParams.set("type","name"),n.searchParams.set("q",t),this._sendRequest(n)}async resolveAccountId(e){const t=new URL(this.serverURL);return t.search="",t.searchParams.set("type","id"),t.searchParams.set("q",e),this._sendRequest(t)}async resolveTransactionId(e){const t=new URL(this.serverURL);return t.search="",t.searchParams.set("type","txid"),t.searchParams.set("q",e),this._sendRequest(t)}async _sendRequest(e){const t=this.timeout;return T.get(e.toString(),{maxContentLength:zo,timeout:t}).then(e=>{if(void 0!==e.data.memo&&"string"!=typeof e.data.memo)throw new Error("memo value should be of type string");return e.data}).catch(e=>{if(e instanceof Error){if(e.message.match(/^maxContentLength size/))throw new Error("federation response exceeds allowed size of 102400");return Promise.reject(e)}return Promise.reject(new C(`Server query failed. Server responded: ${e.status} ${e.statusText}`,e.data))})}}var Yo=Object.freeze({__proto__:null,FEDERATION_RESPONSE_MAX_SIZE:zo,Server:jo});class Jo extends Error{}function Qo(e,t){const n=e.hash(),r=[...e.signatures],o=new Set;for(const e of t){if(0===r.length)break;let t;try{t=Tn.fromPublicKey(e)}catch(e){throw new Jo(`Signer is not a valid address: ${e.message}`)}for(let s=0;s<r.length;s++){const i=r[s];if(i.hint().equals(t.signatureHint())&&t.verify(n,i.signature())){o.add(e),r.splice(s,1);break}}}return Array.from(o)}function es(e,t){return 0!==Qo(e,[t]).length}const ts=Object.prototype.toString;function ns(e){return function(e,t,n){return!!e&&(e.constructor===t||ts.call(e)===n)}(e,Uint8Array,"[object Uint8Array]")}new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder;function rs(e,{urlSafe:t=!1}={}){!function(e){if(!ns(e))throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}(e);let n="";for(let t=0;t<e.length;t+=65535){const r=e.subarray(t,t+65535);n+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return t?function(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}(n):n}function os(e,t,n,r,o){if(t.startsWith("M"))throw Error("Invalid serverAccountID: multiplexed accounts are not supported.");let s;try{s=new ao(e,n)}catch{try{s=new co(e,n)}catch{throw new Jo("Invalid challenge: unable to deserialize challengeTx transaction string")}throw new Jo("Invalid challenge: expected a Transaction but received a FeeBumpTransaction")}if(0!==Number.parseInt(s.sequence,10))throw new Jo("The transaction sequence number should be zero");if(s.source!==t)throw new Jo("The transaction source account is not equal to the server's account");if(s.operations.length<1)throw new Jo("The transaction should contain at least one operation");const[i,...a]=s.operations;if(!i.source)throw new Jo("The transaction's operation should contain a source account");const c=i.source;let u,l=null;if(s.memo.type!==to){if(c.startsWith("M"))throw new Jo("The transaction has a memo but the client account ID is a muxed account");if(s.memo.type!==no)throw new Jo("The transaction's memo must be of type `id`");l=s.memo.value}if("manageData"!==i.type)throw new Jo("The transaction's operation type should be 'manageData'");if(s.timeBounds&&0===Number.parseInt(s.timeBounds?.maxTime,10))throw new Jo("The transaction requires non-infinite timebounds");if(!P.validateTimebounds(s,300))throw new Jo("The transaction has expired");if(void 0===i.value)throw new Jo("The transaction's operation values should not be null");if(!i.value)throw new Jo("The transaction's operation value should not be null");if(48!==fe.Buffer.from(i.value.toString(),"base64").length)throw new Jo("The transaction's operation value should be a 64 bytes base64 random string");if(!r)throw new Jo("Invalid homeDomains: a home domain must be provided for verification");if("string"==typeof r)`${r} auth`===i.name&&(u=r);else{if(!Array.isArray(r))throw new Jo(`Invalid homeDomains: homeDomains type is ${typeof r} but should be a string or an array`);u=r.find(e=>`${e} auth`===i.name)}if(!u)throw new Jo("Invalid homeDomains: the transaction's operation key name does not match the expected home domain");for(const e of a){if("manageData"!==e.type)throw new Jo("The transaction has operations that are not of type 'manageData'");if(e.source!==t&&"client_domain"!==e.name)throw new Jo("The transaction has operations that are unrecognized");if("web_auth_domain"===e.name){if(void 0===e.value)throw new Jo("'web_auth_domain' operation value should not be null");if(e.value.compare(fe.Buffer.from(o)))throw new Jo(`'web_auth_domain' operation value does not match ${o}`)}}if(!es(s,t))throw new Jo(`Transaction not signed by server: '${t}'`);return{tx:s,clientAccountID:c,matchedHomeDomain:u,memo:l}}function ss(e,t,n,r,o,s){const{tx:i}=os(e,t,n,o,s);let a;try{a=Tn.fromPublicKey(t)}catch(e){throw new Error(`Couldn't infer keypair from the provided 'serverAccountID': ${e.message}`)}const c=new Set;for(const e of r)e!==a.publicKey()&&"G"===e.charAt(0)&&c.add(e);if(0===c.size)throw new Jo("No verifiable client signers provided, at least one G... address must be provided");let u;for(const e of i.operations)if("manageData"===e.type&&"client_domain"===e.name){if(u)throw new Jo("Found more than one client_domain operation");u=e.source}const l=[a.publicKey(),...Array.from(c)];u&&l.push(u);const d=Qo(i,l);let p=!1,h=!1;for(const e of d)e===a.publicKey()&&(p=!0),e===u&&(h=!0);if(!p)throw new Jo(`Transaction not signed by server: '${a.publicKey()}'`);if(u&&!h)throw new Jo("Transaction not signed by the source account of the 'client_domain' ManageData operation");if(1===d.length)throw new Jo("None of the given signers match the transaction signatures");if(d.length!==i.signatures.length)throw new Jo("Transaction has unrecognized signatures");if(d.splice(d.indexOf(a.publicKey()),1),u&&d.splice(d.indexOf(u),1),0===d.length)throw new Jo("None of the given signers match the transaction signatures");return d}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));var is,as,cs,us,ls,ds=Object.freeze({__proto__:null,InvalidChallengeError:Jo,buildChallengeTx:function(e,t,n,r=300,o,s,i=null,a=null,c=null){if(t.startsWith("M")&&i)throw Error("memo cannot be used if clientAccountID is a muxed account");const u=new uo(e.publicKey(),"-1"),l=Math.floor(Date.now()/1e3),d=rs(crypto.getRandomValues(new Uint8Array(48))),p=new Ro(u,{fee:xo,networkPassphrase:o,timebounds:{minTime:l,maxTime:l+r}}).addOperation(Qr.manageData({name:`${n} auth`,value:d,source:t})).addOperation(Qr.manageData({name:"web_auth_domain",value:s,source:u.accountId()}));if(a){if(!c)throw Error("clientSigningKey is required if clientDomain is provided");p.addOperation(Qr.manageData({name:"client_domain",value:a,source:c}))}i&&p.addMemo(io.id(i));const h=p.build();return h.sign(e),h.toEnvelope().toXDR("base64").toString()},gatherTxSigners:Qo,readChallengeTx:os,verifyChallengeTxSigners:ss,verifyChallengeTxThreshold:function(e,t,n,r,o,s,i){const a=ss(e,t,n,o.map(e=>e.key),s,i);let c=0;for(const e of a){c+=o.find(t=>t.key===e)?.weight||0}if(c<r)throw new Jo(`signers with weight ${c} do not meet threshold ${r}"`);return a},verifyTxSignedBy:es}),ps=Object.freeze({__proto__:null});((as=is||(is={})).LiquidityPoolType||(as.LiquidityPoolType={})).constantProduct="constant_product",(cs=as.OperationResponseType||(as.OperationResponseType={})).createAccount="create_account",cs.payment="payment",cs.pathPayment="path_payment_strict_receive",cs.createPassiveOffer="create_passive_sell_offer",cs.manageOffer="manage_sell_offer",cs.setOptions="set_options",cs.changeTrust="change_trust",cs.allowTrust="allow_trust",cs.accountMerge="account_merge",cs.inflation="inflation",cs.manageData="manage_data",cs.bumpSequence="bump_sequence",cs.manageBuyOffer="manage_buy_offer",cs.pathPaymentStrictSend="path_payment_strict_send",cs.createClaimableBalance="create_claimable_balance",cs.claimClaimableBalance="claim_claimable_balance",cs.beginSponsoringFutureReserves="begin_sponsoring_future_reserves",cs.endSponsoringFutureReserves="end_sponsoring_future_reserves",cs.revokeSponsorship="revoke_sponsorship",cs.clawback="clawback",cs.clawbackClaimableBalance="clawback_claimable_balance",cs.setTrustLineFlags="set_trust_line_flags",cs.liquidityPoolDeposit="liquidity_pool_deposit",cs.liquidityPoolWithdraw="liquidity_pool_withdraw",cs.invokeHostFunction="invoke_host_function",cs.bumpFootprintExpiration="bump_footprint_expiration",cs.restoreFootprint="restore_footprint",(us=as.OperationResponseTypeI||(as.OperationResponseTypeI={}))[us.createAccount=0]="createAccount",us[us.payment=1]="payment",us[us.pathPayment=2]="pathPayment",us[us.createPassiveOffer=3]="createPassiveOffer",us[us.manageOffer=4]="manageOffer",us[us.setOptions=5]="setOptions",us[us.changeTrust=6]="changeTrust",us[us.allowTrust=7]="allowTrust",us[us.accountMerge=8]="accountMerge",us[us.inflation=9]="inflation",us[us.manageData=10]="manageData",us[us.bumpSequence=11]="bumpSequence",us[us.manageBuyOffer=12]="manageBuyOffer",us[us.pathPaymentStrictSend=13]="pathPaymentStrictSend",us[us.createClaimableBalance=14]="createClaimableBalance",us[us.claimClaimableBalance=15]="claimClaimableBalance",us[us.beginSponsoringFutureReserves=16]="beginSponsoringFutureReserves",us[us.endSponsoringFutureReserves=17]="endSponsoringFutureReserves",us[us.revokeSponsorship=18]="revokeSponsorship",us[us.clawback=19]="clawback",us[us.clawbackClaimableBalance=20]="clawbackClaimableBalance",us[us.setTrustLineFlags=21]="setTrustLineFlags",us[us.liquidityPoolDeposit=22]="liquidityPoolDeposit",us[us.liquidityPoolWithdraw=23]="liquidityPoolWithdraw",us[us.invokeHostFunction=24]="invokeHostFunction",us[us.bumpFootprintExpiration=25]="bumpFootprintExpiration",us[us.restoreFootprint=26]="restoreFootprint",(ls=as.TransactionFailedResultCodes||(as.TransactionFailedResultCodes={})).TX_FAILED="tx_failed",ls.TX_BAD_SEQ="tx_bad_seq",ls.TX_BAD_AUTH="tx_bad_auth",ls.TX_BAD_AUTH_EXTRA="tx_bad_auth_extra",ls.TX_FEE_BUMP_INNER_SUCCESS="tx_fee_bump_inner_success",ls.TX_FEE_BUMP_INNER_FAILED="tx_fee_bump_inner_failed",ls.TX_NOT_SUPPORTED="tx_not_supported",ls.TX_SUCCESS="tx_success",ls.TX_TOO_EARLY="tx_too_early",ls.TX_TOO_LATE="tx_too_late",ls.TX_MISSING_OPERATION="tx_missing_operation",ls.TX_INSUFFICIENT_BALANCE="tx_insufficient_balance",ls.TX_NO_SOURCE_ACCOUNT="tx_no_source_account",ls.TX_INSUFFICIENT_FEE="tx_insufficient_fee",ls.TX_INTERNAL_ERROR="tx_internal_error";var hs,fs,ms,gs=(e=>(e[e.account_created=0]="account_created",e[e.account_removed=1]="account_removed",e[e.account_credited=2]="account_credited",e[e.account_debited=3]="account_debited",e[e.account_thresholds_updated=4]="account_thresholds_updated",e[e.account_home_domain_updated=5]="account_home_domain_updated",e[e.account_flags_updated=6]="account_flags_updated",e[e.account_inflation_destination_updated=7]="account_inflation_destination_updated",e[e.signer_created=10]="signer_created",e[e.signer_removed=11]="signer_removed",e[e.signer_updated=12]="signer_updated",e[e.trustline_created=20]="trustline_created",e[e.trustline_removed=21]="trustline_removed",e[e.trustline_updated=22]="trustline_updated",e[e.trustline_authorized=23]="trustline_authorized",e[e.trustline_deauthorized=24]="trustline_deauthorized",e[e.trustline_authorized_to_maintain_liabilities=25]="trustline_authorized_to_maintain_liabilities",e[e.trustline_flags_updated=26]="trustline_flags_updated",e[e.offer_created=30]="offer_created",e[e.offer_removed=31]="offer_removed",e[e.offer_updated=32]="offer_updated",e[e.trade=33]="trade",e[e.data_created=40]="data_created",e[e.data_removed=41]="data_removed",e[e.data_updated=42]="data_updated",e[e.sequence_bumped=43]="sequence_bumped",e[e.claimable_balance_created=50]="claimable_balance_created",e[e.claimable_balance_claimant_created=51]="claimable_balance_claimant_created",e[e.claimable_balance_claimed=52]="claimable_balance_claimed",e[e.account_sponsorship_created=60]="account_sponsorship_created",e[e.account_sponsorship_updated=61]="account_sponsorship_updated",e[e.account_sponsorship_removed=62]="account_sponsorship_removed",e[e.trustline_sponsorship_created=63]="trustline_sponsorship_created",e[e.trustline_sponsorship_updated=64]="trustline_sponsorship_updated",e[e.trustline_sponsorship_removed=65]="trustline_sponsorship_removed",e[e.data_sponsorship_created=66]="data_sponsorship_created",e[e.data_sponsorship_updated=67]="data_sponsorship_updated",e[e.data_sponsorship_removed=68]="data_sponsorship_removed",e[e.claimable_balance_sponsorship_created=69]="claimable_balance_sponsorship_created",e[e.claimable_balance_sponsorship_updated=70]="claimable_balance_sponsorship_updated",e[e.claimable_balance_sponsorship_removed=71]="claimable_balance_sponsorship_removed",e[e.signer_sponsorship_created=72]="signer_sponsorship_created",e[e.signer_sponsorship_updated=73]="signer_sponsorship_updated",e[e.signer_sponsorship_removed=74]="signer_sponsorship_removed",e[e.claimable_balance_clawed_back=80]="claimable_balance_clawed_back",e[e.liquidity_pool_deposited=90]="liquidity_pool_deposited",e[e.liquidity_pool_withdrew=91]="liquidity_pool_withdrew",e[e.liquidity_pool_trade=92]="liquidity_pool_trade",e[e.liquidity_pool_created=93]="liquidity_pool_created",e[e.liquidity_pool_removed=94]="liquidity_pool_removed",e[e.liquidity_pool_revoked=95]="liquidity_pool_revoked",e[e.contract_credited=96]="contract_credited",e[e.contract_debited=97]="contract_debited",e))(gs||{});(fs=hs||(hs={})).EffectType=gs,(ms=fs.TradeType||(fs.TradeType={})).all="all",ms.liquidityPools="liquidity_pool",ms.orderbook="orderbook",is.OperationResponseType,is.OperationResponseTypeI;class ys{id;paging_token;account_id;sequence;sequence_ledger;sequence_time;subentry_count;home_domain;inflation_destination;last_modified_ledger;last_modified_time;thresholds;flags;balances;signers;num_sponsoring;num_sponsored;sponsor;data;data_attr;effects;offers;operations;payments;trades;transactions;_baseAccount;constructor(e){this._baseAccount=new uo(e.account_id,e.sequence),this.effects=e.effects,this.offers=e.offers,this.operations=e.operations,this.payments=e.payments,this.trades=e.trades,this.data=e.data,this.transactions=e.transactions,this.id=e.id,this.paging_token=e.paging_token,this.account_id=e.account_id,this.sequence=e.sequence,this.sequence_ledger=e.sequence_ledger,this.sequence_time=e.sequence_time,this.subentry_count=e.subentry_count,this.home_domain=e.home_domain,this.inflation_destination=e.inflation_destination,this.last_modified_ledger=e.last_modified_ledger,this.last_modified_time=e.last_modified_time,this.thresholds=e.thresholds,this.flags=e.flags,this.balances=e.balances,this.signers=e.signers,this.data_attr=e.data_attr,this.sponsor=e.sponsor,this.num_sponsoring=e.num_sponsoring,this.num_sponsored=e.num_sponsored}accountId(){return this._baseAccount.accountId()}sequenceNumber(){return this._baseAccount.sequenceNumber()}incrementSequenceNumber(){this._baseAccount.incrementSequenceNumber(),this.sequence=this._baseAccount.sequenceNumber()}}class ws extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const As=32;function Ss(e){}function bs(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ss,onError:n=Ss,onRetry:r=Ss,onComment:o}=e,s=[];let i,a,c=!0,u="",l=0;function d(e){let n=0;if(-1===e.indexOf("\r")){let r=e.indexOf("\n",n);for(;-1!==r;){if(n===r){l>0&&t({id:i,event:a,data:u}),i=void 0,u="",l=0,a=void 0,n=r+1,r=e.indexOf("\n",n);continue}const o=e.charCodeAt(n);if(vs(e,n,o)){const o=e.charCodeAt(n+5)===As?n+6:n+5,s=e.slice(o,r);if(0===l&&10===e.charCodeAt(r+1)){t({id:i,event:a,data:s}),i=void 0,u="",a=void 0,n=r+2,r=e.indexOf("\n",n);continue}u=0===l?s:`${u}\n${s}`,l++}else Ts(e,n,o)?a=e.slice(e.charCodeAt(n+6)===As?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf("\n",n)}return e.slice(n)}for(;n<e.length;){const t=e.indexOf("\r",n),r=e.indexOf("\n",n);let o=-1;if(-1!==t&&-1!==r?o=t<r?t:r:-1!==t?o=t===e.length-1?-1:t:-1!==r&&(o=r),-1===o)break;p(e,n,o),n=o+1,13===e.charCodeAt(n-1)&&10===e.charCodeAt(n)&&n++}return e.slice(n)}function p(e,n,r){if(n===r)return l>0&&t({id:i,event:a,data:u}),i=void 0,u="",l=0,void(a=void 0);const s=e.charCodeAt(n);if(vs(e,n,s)){const t=e.charCodeAt(n+5)===As?n+6:n+5,o=e.slice(t,r);return u=0===l?o:`${u}\n${o}`,void l++}if(Ts(e,n,s))return void(a=e.slice(e.charCodeAt(n+6)===As?n+7:n+6,r)||void 0);if(105===s&&100===e.charCodeAt(n+1)&&58===e.charCodeAt(n+2)){const t=e.slice(e.charCodeAt(n+3)===As?n+4:n+3,r);return void(i=t.includes("\0")?void 0:t)}if(58===s){if(o){const t=e.slice(n,r);o(t.slice(e.charCodeAt(n+1)===As?2:1))}return}const c=e.slice(n,r),d=c.indexOf(":");if(-1===d)return void h(c,"",c);const p=c.slice(0,d),f=c.charCodeAt(d+1)===As?2:1;h(p,c.slice(d+f),c)}function h(e,t,o){switch(e){case"event":a=t||void 0;break;case"data":u=0===l?t:`${u}\n${t}`,l++;break;case"id":i=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?r(parseInt(t,10)):n(new ws(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:o}));break;default:n(new ws(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:"unknown-field",field:e,value:t,line:o}))}}return{feed:function(e){if(c&&(c=!1,239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)&&(e=e.slice(3))),0===s.length){const t=d(e);return void(""!==t&&s.push(t))}if(-1===e.indexOf("\n")&&-1===e.indexOf("\r"))return void s.push(e);s.push(e);const t=s.join("");s.length=0;const n=d(t);""!==n&&s.push(n)},reset:function(e={}){if(e.consume&&s.length>0){const e=s.join("");p(e,0,e.length)}c=!0,i=void 0,u="",l=0,a=void 0,s.length=0}}}function vs(e,t,n){return 100===n&&97===e.charCodeAt(t+1)&&116===e.charCodeAt(t+2)&&97===e.charCodeAt(t+3)&&58===e.charCodeAt(t+4)}function Ts(e,t,n){return 101===n&&118===e.charCodeAt(t+1)&&101===e.charCodeAt(t+2)&&110===e.charCodeAt(t+3)&&116===e.charCodeAt(t+4)&&58===e.charCodeAt(t+5)}class Es extends Event{constructor(e,t){var n,r;super(e),this.code=null!=(n=null==t?void 0:t.code)?n:void 0,this.message=null!=(r=null==t?void 0:t.message)?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return n(Is(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Is(this),t)}}function ks(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(ks).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${ks(e.cause)}`:e.message:`${e}`}function Is(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Cs,Bs,xs,Rs,_s,Ps,Os,Us,Ls,Ns,Vs,Fs,Ds,Ms,qs,Hs,Gs,$s,Xs,Ks,Ws,Zs,zs,js=e=>{throw TypeError(e)},Ys=(e,t,n)=>t.has(e)||js("Cannot "+n),Js=(e,t,n)=>(Ys(e,t,"read from private field"),n?n.call(e):t.get(e)),Qs=(e,t,n)=>t.has(e)?js("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ei=(e,t,n,r)=>(Ys(e,t,"write to private field"),t.set(e,n),n),ti=(e,t,n)=>(Ys(e,t,"access private method"),n);class ni extends EventTarget{constructor(e,t){var n,r;super(),Qs(this,Ms),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Qs(this,Cs),Qs(this,Bs),Qs(this,xs),Qs(this,Rs),Qs(this,_s),Qs(this,Ps),Qs(this,Os),Qs(this,Us,null),Qs(this,Ls),Qs(this,Ns),Qs(this,Vs,null),Qs(this,Fs,null),Qs(this,Ds,null),Qs(this,Hs,async e=>{var t;Js(this,Ns).reset();const{body:n,redirected:r,status:o,headers:s}=e;if(204===o)return ti(this,Ms,Ws).call(this,"Server sent HTTP 204, not reconnecting",204),void this.close();if(ei(this,xs,r?new URL(e.url):void 0),200!==o)return void ti(this,Ms,Ws).call(this,`Non-200 status code (${o})`,o);if(!(s.get("content-type")||"").startsWith("text/event-stream"))return void ti(this,Ms,Ws).call(this,'Invalid content type, expected "text/event-stream"',o);if(Js(this,Cs)===this.CLOSED)return;ei(this,Cs,this.OPEN);const i=new Event("open");if(null==(t=Js(this,Ds))||t.call(this,i),this.dispatchEvent(i),"object"!=typeof n||!n||!("getReader"in n))return ti(this,Ms,Ws).call(this,"Invalid response body, expected a web ReadableStream",o),void this.close();const a=new TextDecoder,c=n.getReader();let u=!0;do{const{done:e,value:t}=await c.read();t&&Js(this,Ns).feed(a.decode(t,{stream:!e})),e&&(u=!1,Js(this,Ns).reset(),ti(this,Ms,Zs).call(this))}while(u)}),Qs(this,Gs,e=>{ei(this,Ls,void 0),"AbortError"!==e.name&&"aborted"!==e.type&&ti(this,Ms,Zs).call(this,ks(e))}),Qs(this,Xs,e=>{"string"==typeof e.id&&ei(this,Us,e.id);const t=new MessageEvent(e.event||"message",{data:e.data,origin:Js(this,xs)?Js(this,xs).origin:Js(this,Bs).origin,lastEventId:e.id||""});Js(this,Fs)&&(!e.event||"message"===e.event)&&Js(this,Fs).call(this,t),this.dispatchEvent(t)}),Qs(this,Ks,e=>{ei(this,Ps,e)}),Qs(this,zs,()=>{ei(this,Os,void 0),Js(this,Cs)===this.CONNECTING&&ti(this,Ms,qs).call(this)});try{if(e instanceof URL)ei(this,Bs,e);else{if("string"!=typeof e)throw new Error("Invalid URL");ei(this,Bs,new URL(e,function(){const e="document"in globalThis?globalThis.document:void 0;return e&&"object"==typeof e&&"baseURI"in e&&"string"==typeof e.baseURI?e.baseURI:void 0}()))}}catch{throw function(e){const t=globalThis.DOMException;return"function"==typeof t?new t(e,"SyntaxError"):new SyntaxError(e)}("An invalid or illegal string was specified")}ei(this,Ns,bs({onEvent:Js(this,Xs),onRetry:Js(this,Ks)})),ei(this,Cs,this.CONNECTING),ei(this,Ps,3e3),ei(this,_s,null!=(n=null==t?void 0:t.fetch)?n:globalThis.fetch),ei(this,Rs,null!=(r=null==t?void 0:t.withCredentials)&&r),ti(this,Ms,qs).call(this)}get readyState(){return Js(this,Cs)}get url(){return Js(this,Bs).href}get withCredentials(){return Js(this,Rs)}get onerror(){return Js(this,Vs)}set onerror(e){ei(this,Vs,e)}get onmessage(){return Js(this,Fs)}set onmessage(e){ei(this,Fs,e)}get onopen(){return Js(this,Ds)}set onopen(e){ei(this,Ds,e)}addEventListener(e,t,n){const r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){const r=t;super.removeEventListener(e,r,n)}close(){Js(this,Os)&&clearTimeout(Js(this,Os)),Js(this,Cs)!==this.CLOSED&&(Js(this,Ls)&&Js(this,Ls).abort(),ei(this,Cs,this.CLOSED),ei(this,Ls,void 0))}}Cs=new WeakMap,Bs=new WeakMap,xs=new WeakMap,Rs=new WeakMap,_s=new WeakMap,Ps=new WeakMap,Os=new WeakMap,Us=new WeakMap,Ls=new WeakMap,Ns=new WeakMap,Vs=new WeakMap,Fs=new WeakMap,Ds=new WeakMap,Ms=new WeakSet,qs=function(){ei(this,Cs,this.CONNECTING),ei(this,Ls,new AbortController),Js(this,_s)(Js(this,Bs),ti(this,Ms,$s).call(this)).then(Js(this,Hs)).catch(Js(this,Gs))},Hs=new WeakMap,Gs=new WeakMap,$s=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Js(this,Us)?{"Last-Event-ID":Js(this,Us)}:void 0},cache:"no-store",signal:null==(e=Js(this,Ls))?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Xs=new WeakMap,Ks=new WeakMap,Ws=function(e,t){var n;Js(this,Cs)!==this.CLOSED&&ei(this,Cs,this.CLOSED);const r=new Es("error",{code:t,message:e});null==(n=Js(this,Vs))||n.call(this,r),this.dispatchEvent(r)},Zs=function(e,t){var n;if(Js(this,Cs)===this.CLOSED)return;ei(this,Cs,this.CONNECTING);const r=new Es("error",{code:t,message:e});null==(n=Js(this,Vs))||n.call(this,r),this.dispatchEvent(r),ei(this,Os,setTimeout(Js(this,zs),Js(this,Ps)))},zs=new WeakMap,ni.CONNECTING=0,ni.OPEN=1,ni.CLOSED=2,Object.defineProperty(ni,Symbol.for("eventsource.supports-fetch-override"),{value:!0,writable:!1,configurable:!1,enumerable:!1});const ri="16.0.1",oi={};function si(e){return Math.floor(e/1e3)}function ii(e){const t=oi[e];if(!t||!t.localTimeRecorded||!t.serverTime)return null;const{serverTime:n,localTimeRecorded:r}=t,o=si((new Date).getTime());return o-r>300?null:o-r+n}function ai(e){return Array.isArray(e)?e.join(","):e.toString()}const ci=["transaction"];class ui{url;filter;originalSegments;neighborRoot;httpClient;constructor(e,t,n=""){this.url=new URL(e),this.filter=[],this.originalSegments=this.url.pathname.split("/").filter(e=>e.length>0),this.neighborRoot=n,this.httpClient=t}setPath(...e){const t=e.flatMap(e=>e.split("/").filter(e=>e.length>0));this.url.pathname=this.originalSegments.concat(t).join("/")}call(){return this.checkFilter(),this._sendNormalRequest(this.url).then(e=>this._parseResponse(e))}stream(e={}){this.checkFilter();const t=new URL(this.url);t.searchParams.set("X-Client-Name","js-stellar-sdk"),t.searchParams.set("X-Client-Version",ri);const{headers:n}=this.httpClient.defaults;if(n){["X-App-Name","X-App-Version"].forEach(e=>{let r;if(n instanceof Headers)r=n.get(e)??void 0;else if(Array.isArray(n)){const t=n.find(([t])=>t===e);r=t?.[1]}else r=n[e];r&&t.searchParams.set(e,r)})}let r,o;const s=()=>{o=setTimeout(()=>{r?.close(),r=i()},e.reconnectTimeout||15e3)},i=()=>{try{r=new ni(t.toString())}catch(t){e.onerror&&e.onerror(t)}if(s(),!r)return r;let n=!1;const a=()=>{n||(clearTimeout(o),r.close(),i(),n=!0)},c=n=>{if("close"===n.type)return void a();const r=n.data?this._parseRecord(JSON.parse(n.data)):n;r.paging_token&&t.searchParams.set("cursor",r.paging_token),clearTimeout(o),s(),void 0!==e.onmessage&&e.onmessage(r)},u=t=>{e.onerror&&e.onerror(t)};return r.addEventListener?(r.addEventListener("message",c.bind(this)),r.addEventListener("error",u.bind(this)),r.addEventListener("close",a.bind(this))):(r.onmessage=c.bind(this),r.onerror=u.bind(this)),r};return i(),()=>{clearTimeout(o),r?.close()}}cursor(e){return this.url.searchParams.set("cursor",e),this}limit(e){return this.url.searchParams.set("limit",e.toString()),this}order(e){return this.url.searchParams.set("order",e),this}join(e){return this.url.searchParams.set("join",e),this}forEndpoint(e,t){if(""===this.neighborRoot)throw new Error("Invalid usage: neighborRoot not set in constructor");return this.filter.push([e,t,this.neighborRoot]),this}checkFilter(){if(this.filter.length>=2)throw new I("Too many filters specified",this.filter);if(1===this.filter.length){const e=this.originalSegments.concat(this.filter[0]);this.url.pathname=e.join("/")}}_requestFnForLink(e){return async(t={})=>{let n;n=e.templated?new URL(function(e,t,n){const r=[],o=e.replace(/\{\?([^}]+)\}/g,(e,t)=>(r.push(...t.split(",")),"")).replace(/\{([^?][^}]*)\}/g,(e,n)=>{const r=t[n];return void 0===r?"":encodeURIComponent(ai(r))}),s=new URL(o,n);return r.forEach(e=>{const n=t[e];void 0!==n&&s.searchParams.set(e,ai(n))}),s.toString()}(e.href,t),this.url):new URL(e.href,this.url);const r=await this._sendNormalRequest(n);return this._parseResponse(r)}}_parseRecord(e){return e._links?(Object.keys(e._links).forEach(t=>{const n=e._links[t];let r=!1;if(void 0!==e[t]&&(e[`${t}_attr`]=e[t],r=!0),r&&ci.indexOf(t)>=0){const n=this._parseRecord(e[t]);e[t]=async()=>n}else e[t]=this._requestFnForLink(n)}),e):e}async _sendNormalRequest(e){const t=new URL(e);return t.protocol=this.url.protocol,t.host=this.url.host,this.httpClient.get(t.toString()).then(e=>e.data).catch(this._handleNetworkError)}_parseResponse(e){return e._embedded&&e._embedded.records?this._toCollectionPage(e):this._parseRecord(e)}_toCollectionPage(e){for(let t=0;t<e._embedded.records.length;t+=1)e._embedded.records[t]=this._parseRecord(e._embedded.records[t]);return{records:e._embedded.records,next:async()=>{const t=await this._sendNormalRequest(new URL(e._links.next.href,this.url));return this._toCollectionPage(t)},prev:async()=>{const t=await this._sendNormalRequest(new URL(e._links.prev.href,this.url));return this._toCollectionPage(t)}}}async _handleNetworkError(e){return e.response&&e.response.status?404===e.response.status?Promise.reject(new k(e.response.statusText??"Not Found",e.response.data)):Promise.reject(new E(e.response.statusText??"Unknown",e.response.data)):Promise.reject(new Error(e.message))}}class li extends ui{constructor(e,t){super(e,t),this.setPath("accounts")}accountId(e){const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forSigner(e){return this.url.searchParams.set("signer",e),this}forAsset(e){return this.url.searchParams.set("asset",`${e}`),this}sponsor(e){return this.url.searchParams.set("sponsor",e),this}forLiquidityPool(e){return this.url.searchParams.set("liquidity_pool",e),this}}class di extends ui{constructor(e,t){super(e,t),this.setPath("assets")}forCode(e){return this.url.searchParams.set("asset_code",e),this}forIssuer(e){return this.url.searchParams.set("asset_issuer",e),this}}class pi extends ui{constructor(e,t){super(e,t),this.setPath("claimable_balances")}claimableBalance(e){const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e]),t}sponsor(e){return this.url.searchParams.set("sponsor",e),this}claimant(e){return this.url.searchParams.set("claimant",e),this}asset(e){return this.url.searchParams.set("asset",e.toString()),this}}class hi extends ui{constructor(e,t){super(e,t,"effects"),this.setPath("effects")}forAccount(e){return this.forEndpoint("accounts",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}forOperation(e){return this.forEndpoint("operations",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}}class fi extends ui{constructor(e,t,n){super(e,t),this.setPath("friendbot"),this.url.searchParams.set("addr",n)}}class mi extends ui{constructor(e,t){super(e,t),this.setPath("ledgers")}ledger(e){return this.filter.push(["ledgers",e.toString()]),this}}class gi extends ui{constructor(e,t){super(e,t),this.setPath("liquidity_pools")}forAssets(...e){const t=e.map(e=>e.toString()).join(",");return this.url.searchParams.set("reserves",t),this}forAccount(e){return this.url.searchParams.set("account",e),this}liquidityPoolId(e){if(!e.match(/[a-fA-F0-9]{64}/))throw new TypeError(`${e} does not look like a liquidity pool ID`);const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e.toLowerCase()]),t}}class yi extends ui{constructor(e,t){super(e,t,"offers"),this.setPath("offers")}offer(e){const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}buying(e){const t=e.getIssuer();return e.isNative()||void 0===t?this.url.searchParams.set("buying_asset_type","native"):(this.url.searchParams.set("buying_asset_type",e.getAssetType()),this.url.searchParams.set("buying_asset_code",e.getCode()),this.url.searchParams.set("buying_asset_issuer",t)),this}selling(e){const t=e.getIssuer();return e.isNative()||void 0===t?this.url.searchParams.set("selling_asset_type","native"):(this.url.searchParams.set("selling_asset_type",e.getAssetType()),this.url.searchParams.set("selling_asset_code",e.getCode()),this.url.searchParams.set("selling_asset_issuer",t)),this}sponsor(e){return this.url.searchParams.set("sponsor",e),this}seller(e){return this.url.searchParams.set("seller",e),this}}class wi extends ui{constructor(e,t){super(e,t,"operations"),this.setPath("operations")}operation(e){const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}forClaimableBalance(e){return this.forEndpoint("claimable_balances",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}class Ai extends ui{constructor(e,t,n,r){super(e,t),this.setPath("order_book");const o=n.getIssuer();n.isNative()||void 0===o?this.url.searchParams.set("selling_asset_type","native"):(this.url.searchParams.set("selling_asset_type",n.getAssetType()),this.url.searchParams.set("selling_asset_code",n.getCode()),this.url.searchParams.set("selling_asset_issuer",o));const s=r.getIssuer();r.isNative()||void 0===s?this.url.searchParams.set("buying_asset_type","native"):(this.url.searchParams.set("buying_asset_type",r.getAssetType()),this.url.searchParams.set("buying_asset_code",r.getCode()),this.url.searchParams.set("buying_asset_issuer",s))}}class Si extends ui{constructor(e,t){super(e,t,"payments"),this.setPath("payments")}forAccount(e){return this.forEndpoint("accounts",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}class bi extends ui{constructor(e,t,n,r,o){if(super(e,t),this.setPath("paths/strict-receive"),"string"==typeof n)this.url.searchParams.set("source_account",n);else{const e=n.map(e=>e.isNative()?"native":`${e.getCode()}:${e.getIssuer()}`).join(",");this.url.searchParams.set("source_assets",e)}this.url.searchParams.set("destination_amount",o);const s=r.getIssuer();r.isNative()||void 0===s?this.url.searchParams.set("destination_asset_type","native"):(this.url.searchParams.set("destination_asset_type",r.getAssetType()),this.url.searchParams.set("destination_asset_code",r.getCode()),this.url.searchParams.set("destination_asset_issuer",s))}}class vi extends ui{constructor(e,t,n,r,o){super(e,t),this.setPath("paths/strict-send");const s=n.getIssuer();if(n.isNative()?this.url.searchParams.set("source_asset_type","native"):void 0!==s&&(this.url.searchParams.set("source_asset_type",n.getAssetType()),this.url.searchParams.set("source_asset_code",n.getCode()),this.url.searchParams.set("source_asset_issuer",s)),this.url.searchParams.set("source_amount",r),"string"==typeof o)this.url.searchParams.set("destination_account",o);else{const e=o.map(e=>e.isNative()?"native":`${e.getCode()}:${e.getIssuer()}`).join(",");this.url.searchParams.set("destination_assets",e)}}}const Ti=[6e4,3e5,9e5,36e5,864e5,6048e5];class Ei extends ui{constructor(e,t,n,r,o,s,i,a){super(e,t),this.setPath("trade_aggregations");const c=n.getIssuer();n.isNative()||void 0===c?this.url.searchParams.set("base_asset_type","native"):(this.url.searchParams.set("base_asset_type",n.getAssetType()),this.url.searchParams.set("base_asset_code",n.getCode()),this.url.searchParams.set("base_asset_issuer",c));const u=r.getIssuer();if(r.isNative()||void 0===u?this.url.searchParams.set("counter_asset_type","native"):(this.url.searchParams.set("counter_asset_type",r.getAssetType()),this.url.searchParams.set("counter_asset_code",r.getCode()),this.url.searchParams.set("counter_asset_issuer",u)),"number"!=typeof o||"number"!=typeof s)throw new I("Invalid time bounds",[o,s]);if(this.url.searchParams.set("start_time",o.toString()),this.url.searchParams.set("end_time",s.toString()),!this.isValidResolution(i))throw new I("Invalid resolution",i);if(this.url.searchParams.set("resolution",i.toString()),!this.isValidOffset(a,i))throw new I("Invalid offset",a);this.url.searchParams.set("offset",a.toString())}isValidResolution(e){return Ti.some(t=>t===e)}isValidOffset(e,t){const n=36e5;return!(e>t||e>=24*n||e%n!==0)}}class ki extends ui{constructor(e,t){super(e,t,"trades"),this.setPath("trades")}forAssetPair(e,t){const n=e.getIssuer();e.isNative()||void 0===n?this.url.searchParams.set("base_asset_type","native"):(this.url.searchParams.set("base_asset_type",e.getAssetType()),this.url.searchParams.set("base_asset_code",e.getCode()),this.url.searchParams.set("base_asset_issuer",n));const r=t.getIssuer();return t.isNative()||void 0===r?this.url.searchParams.set("counter_asset_type","native"):(this.url.searchParams.set("counter_asset_type",t.getAssetType()),this.url.searchParams.set("counter_asset_code",t.getCode()),this.url.searchParams.set("counter_asset_issuer",r)),this}forOffer(e){return this.url.searchParams.set("offer_id",e),this}forType(e){return this.url.searchParams.set("trade_type",e),this}forAccount(e){return this.forEndpoint("accounts",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}}class Ii extends ui{constructor(e,t){super(e,t,"transactions"),this.setPath("transactions")}transaction(e){const t=new ui(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}forClaimableBalance(e){return this.forEndpoint("claimable_balances",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}function Ci(e){return new tr(e).div(1e7).toString()}var Bi,xi=Object.freeze({__proto__:null,AccountResponse:ys,get HorizonApi(){return is},SERVER_TIME_MAP:oi,Server:class{serverURL;httpClient;constructor(e,t={}){this.serverURL=new URL(e);const n=void 0===t.allowHttp?_.isAllowHttp():t.allowHttp,r={};if(t.appName&&(r["X-App-Name"]=t.appName),t.appVersion&&(r["X-App-Version"]=t.appVersion),t.authToken&&(r["X-Auth-Token"]=t.authToken),t.headers&&Object.assign(r,t.headers),this.httpClient=function(e){const t=v({headers:{...e,"X-Client-Name":"js-stellar-sdk","X-Client-Version":ri}});return t.interceptors.response.use(e=>{const t=e.config.url;if(!t)return e;const n=new URL(t),r=n.port,o=r?`${n.hostname}:${r}`:n.hostname;let s=0;if(e.headers instanceof Headers){const t=e.headers.get("date");t&&(s=si(Date.parse(t)))}else if("object"==typeof e.headers&&"date"in e.headers){const t=e.headers;"string"==typeof t.date&&(s=si(Date.parse(t.date)))}const i=si((new Date).getTime());return Number.isNaN(s)||(oi[o]={serverTime:s,localTimeRecorded:i}),e}),t}(r),"https:"!==this.serverURL.protocol&&!n)throw new Error("Cannot connect to insecure horizon server")}async fetchTimebounds(e,t=!1){const n=this.serverURL.port,r=ii(n?`${this.serverURL.hostname}:${n}`:this.serverURL.hostname);return r?{minTime:0,maxTime:r+e}:t?{minTime:0,maxTime:Math.floor((new Date).getTime()/1e3)+e}:(await this.httpClient.get(this.serverURL.toString()),this.fetchTimebounds(e,!0))}async fetchBaseFee(){const e=await this.feeStats();return parseInt(e.last_ledger_base_fee,10)||100}async feeStats(){const e=new ui(this.serverURL,this.httpClient);return e.filter.push(["fee_stats"]),e.call()}async root(){return new ui(this.serverURL,this.httpClient).call()}async submitTransaction(e,t={skipMemoRequiredCheck:!1}){t.skipMemoRequiredCheck||await this.checkMemoRequired(e);const n=encodeURIComponent(e.toEnvelope().toXDR().toString("base64")),r=new URL(this.serverURL);return r.pathname=r.pathname.split("/").concat(["transactions"]).filter(e=>e.length>0).join("/"),this.httpClient.post(r.toString(),`tx=${n}`,{timeout:6e4,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(e=>{if(!e.data.result_xdr)return e.data;const t=se.TransactionResult.fromXDR(e.data.result_xdr,"base64").result().value();let n,r;return t.length&&(n=t.map((e,t)=>{if("manageBuyOffer"!==e.value().switch().name&&"manageSellOffer"!==e.value().switch().name)return null;r=!0;let n=new tr(0),o=new tr(0);const s=e.value().value().success(),i=s.offersClaimed().map(e=>{const t=e.value();let r="";switch(e.switch()){case se.ClaimAtomType.claimAtomTypeV0():r=wn.encodeEd25519PublicKey(t.sellerEd25519());break;case se.ClaimAtomType.claimAtomTypeOrderBook():r=wn.encodeEd25519PublicKey(t.sellerId().ed25519());break;default:throw new Error(`Invalid offer result type: ${e.switch()}`)}const s=new tr(t.amountBought().toString()),i=new tr(t.amountSold().toString());n=n.plus(i),o=o.plus(s);const a=In.fromOperation(t.assetSold()),c=In.fromOperation(t.assetBought()),u={type:a.getAssetType(),assetCode:a.getCode(),issuer:a.getIssuer()},l={type:c.getAssetType(),assetCode:c.getCode(),issuer:c.getIssuer()};return{sellerId:r,offerId:t.offerId().toString(),assetSold:u,amountSold:Ci(i),assetBought:l,amountBought:Ci(s)}}),a=s.offer().switch().name;let c;if("function"==typeof s.offer().value&&s.offer().value()){const e=s.offer().value();c={offerId:e.offerId().toString(),selling:{},buying:{},amount:Ci(e.amount().toString()),price:{n:e.price().n(),d:e.price().d()}};const t=In.fromOperation(e.selling());c.selling={type:t.getAssetType(),assetCode:t.getCode(),issuer:t.getIssuer()};const n=In.fromOperation(e.buying());c.buying={type:n.getAssetType(),assetCode:n.getCode(),issuer:n.getIssuer()}}return{offersClaimed:i,effect:a,operationIndex:t,currentOffer:c,amountBought:Ci(n),amountSold:Ci(o),isFullyOpen:!i.length&&"manageOfferDeleted"!==a,wasPartiallyFilled:!!i.length&&"manageOfferDeleted"!==a,wasImmediatelyFilled:!!i.length&&"manageOfferDeleted"===a,wasImmediatelyDeleted:!i.length&&"manageOfferDeleted"===a}}).filter(e=>!!e)),{...e.data,offerResults:r?n:void 0}}).catch(e=>e instanceof Error?Promise.reject(e):Promise.reject(new C(`Transaction submission failed. Server responded: ${e.status} ${e.statusText}`,e.data)))}async submitAsyncTransaction(e,t={skipMemoRequiredCheck:!1}){t.skipMemoRequiredCheck||await this.checkMemoRequired(e);const n=encodeURIComponent(e.toEnvelope().toXDR().toString("base64")),r=new URL(this.serverURL);return r.pathname=r.pathname.split("/").concat(["transactions_async"]).filter(e=>e.length>0).join("/"),this.httpClient.post(r.toString(),`tx=${n}`,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(e=>e.data).catch(e=>e instanceof Error?Promise.reject(e):Promise.reject(new C(`Transaction submission failed. Server responded: ${e.status} ${e.statusText}`,e.data)))}accounts(){return new li(this.serverURL,this.httpClient)}claimableBalances(){return new pi(this.serverURL,this.httpClient)}ledgers(){return new mi(this.serverURL,this.httpClient)}transactions(){return new Ii(this.serverURL,this.httpClient)}offers(){return new yi(this.serverURL,this.httpClient)}orderbook(e,t){return new Ai(this.serverURL,this.httpClient,e,t)}trades(){return new ki(this.serverURL,this.httpClient)}operations(){return new wi(this.serverURL,this.httpClient)}liquidityPools(){return new gi(this.serverURL,this.httpClient)}strictReceivePaths(e,t,n){return new bi(this.serverURL,this.httpClient,e,t,n)}strictSendPaths(e,t,n){return new vi(this.serverURL,this.httpClient,e,t,n)}payments(){return new Si(this.serverURL,this.httpClient)}effects(){return new hi(this.serverURL,this.httpClient)}friendbot(e){return new fi(this.serverURL,this.httpClient,e)}assets(){return new di(this.serverURL,this.httpClient)}async loadAccount(e){const t=await this.accounts().accountId(e).call();return new ys(t)}tradeAggregation(e,t,n,r,o,s){return new Ei(this.serverURL,this.httpClient,e,t,n,r,o,s)}async checkMemoRequired(e){if(e instanceof co&&(e=e.innerTransaction),"none"!==e.memo.type)return;const t=new Set;for(let n=0;n<e.operations.length;n+=1){const r=e.operations[n];switch(r.type){case"payment":case"pathPaymentStrictReceive":case"pathPaymentStrictSend":case"accountMerge":break;default:continue}const o=r.destination;if(!t.has(o)&&(t.add(o),!o.startsWith("M")))try{if("MQ=="===(await this.loadAccount(o)).data_attr["config.memo_required"])throw new B("account requires memo",o,n)}catch(e){if(e instanceof B)throw e;if(!(e instanceof k))throw e;continue}}}},get ServerApi(){return hs},getCurrentServerTime:ii});(e=>{var t;function n(e){return"transactionData"in e}(t=e.GetTransactionStatus||(e.GetTransactionStatus={})).SUCCESS="SUCCESS",t.NOT_FOUND="NOT_FOUND",t.FAILED="FAILED",e.isSimulationError=function(e){return"error"in e},e.isSimulationSuccess=n,e.isSimulationRestore=function(e){return n(e)&&"restorePreamble"in e&&!!e.restorePreamble.transactionData},e.isSimulationRaw=function(e){return!e._parsed}})(Bi||(Bi={}));async function Ri(e,t,n,r=null){const o=await e.post(t,{jsonrpc:"2.0",id:1,method:n,params:r});if(s=o.data,i="error",Object.prototype.hasOwnProperty.call(s,i))throw o.data.error;return o.data?.result;var s,i}function _i(e){const{errorResultXdr:t,diagnosticEventsXdr:n}=e;return delete e.errorResultXdr,delete e.diagnosticEventsXdr,t?{...e,...void 0!==n&&n.length>0&&{diagnosticEvents:n.map(e=>se.DiagnosticEvent.fromXDR(e,"base64"))},errorResult:se.TransactionResult.fromXDR(t,"base64")}:{...e}}function Pi(e){const t=se.TransactionMeta.fromXDR(e.resultMetaXdr,"base64"),n={ledger:e.ledger,createdAt:e.createdAt,applicationOrder:e.applicationOrder,feeBump:e.feeBump,envelopeXdr:se.TransactionEnvelope.fromXDR(e.envelopeXdr,"base64"),resultXdr:se.TransactionResult.fromXDR(e.resultXdr,"base64"),resultMetaXdr:t,events:{contractEventsXdr:(e.events?.contractEventsXdr??[]).map(e=>e.map(e=>se.ContractEvent.fromXDR(e,"base64"))),transactionEventsXdr:(e.events?.transactionEventsXdr??[]).map(e=>se.TransactionEvent.fromXDR(e,"base64"))}};switch(t.switch()){case 3:case 4:{const e=t.value();null!==e.sorobanMeta()&&(n.returnValue=e.sorobanMeta()?.returnValue()??void 0)}}return e.diagnosticEventsXdr&&(n.diagnosticEventsXdr=e.diagnosticEventsXdr.map(e=>se.DiagnosticEvent.fromXDR(e,"base64"))),n}function Oi(e){return{status:e.status,txHash:e.txHash,...Pi(e)}}function Ui(e){return{latestLedger:e.latestLedger,oldestLedger:e.oldestLedger,latestLedgerCloseTime:e.latestLedgerCloseTime,oldestLedgerCloseTime:e.oldestLedgerCloseTime,cursor:e.cursor,events:(e.events??[]).map(e=>{const t={...e};return delete t.contractId,{...t,...""!==e.contractId&&{contractId:new go(e.contractId)},topic:(e.topic??[]).map(e=>se.ScVal.fromXDR(e,"base64")),value:se.ScVal.fromXDR(e.value,"base64")}})}}function Li(e){return{latestLedger:e.latestLedger,entries:(e.entries??[]).map(e=>{if(!e.key||!e.xdr)throw new TypeError(`invalid ledger entry: ${JSON.stringify(e)}`);return{lastModifiedLedgerSeq:e.lastModifiedLedgerSeq,key:se.LedgerKey.fromXDR(e.key,"base64"),val:se.LedgerEntryData.fromXDR(e.xdr,"base64"),...void 0!==e.liveUntilLedgerSeq&&{liveUntilLedgerSeq:e.liveUntilLedgerSeq}}})}}function Ni(e){if(!Bi.isSimulationRaw(e))return e;const t={_parsed:!0,id:e.id,latestLedger:e.latestLedger,events:e.events?.map(e=>se.DiagnosticEvent.fromXDR(e,"base64"))??[]};return"string"==typeof e.error?{...t,error:e.error}:function(e,t){const n={...t,transactionData:new fo(e.transactionData),minResourceFee:e.minResourceFee,...(e.results?.length??0)>0&&{result:e.results.map(e=>({auth:(e.auth??[]).map(e=>se.SorobanAuthorizationEntry.fromXDR(e,"base64")),retval:e.xdr?se.ScVal.fromXDR(e.xdr,"base64"):se.ScVal.scvVoid()}))[0]},...(e.stateChanges?.length??0)>0&&{stateChanges:e.stateChanges?.map(e=>({type:e.type,key:se.LedgerKey.fromXDR(e.key,"base64"),before:e.before?se.LedgerEntry.fromXDR(e.before,"base64"):null,after:e.after?se.LedgerEntry.fromXDR(e.after,"base64"):null}))}};return e.restorePreamble&&""!==e.restorePreamble.transactionData?{...n,restorePreamble:{minResourceFee:e.restorePreamble.minResourceFee,transactionData:new fo(e.restorePreamble.transactionData)}}:n}(e,t)}function Vi(e){if(!e.metadataXdr||!e.headerXdr){let t;throw t=e.metadataXdr||e.headerXdr?e.metadataXdr?"headerXdr":"metadataXdr":"metadataXdr and headerXdr",new TypeError(`invalid ledger missing fields: ${t}`)}const t=se.LedgerCloseMeta.fromXDR(e.metadataXdr,"base64"),n=se.LedgerHeaderHistoryEntry.fromXDR(e.headerXdr,"base64");return{hash:e.hash,sequence:e.sequence,ledgerCloseTime:e.ledgerCloseTime,metadataXdr:t,headerXdr:n}}function Fi(e){const t=se.LedgerHeader.fromXDR(e.headerXdr,"base64"),n=se.LedgerCloseMeta.fromXDR(e.metadataXdr,"base64");let r;if(e.metadataXdr||e.headerXdr?e.metadataXdr?e.headerXdr||(r="headerXdr"):r="metadataXdr":r="metadataXdr and headerXdr",r)throw new TypeError(`invalid getLatestLedger response missing fields: ${r}`);return{id:e.id,sequence:e.sequence,protocolVersion:e.protocolVersion,closeTime:e.closeTime,headerXdr:t,metadataXdr:n}}function Di(e,t){if("innerTransaction"in e)return Di(e.innerTransaction,t);if(!function(e){if(1!==e.operations.length)return!1;switch(e.operations[0].type){case"invokeHostFunction":case"extendFootprintTtl":case"restoreFootprint":return!0;default:return!1}}(e))throw new TypeError("unsupported transaction: must contain exactly one invokeHostFunction, extendFootprintTtl, or restoreFootprint operation");const n=Ni(t);if(!Bi.isSimulationSuccess(n))throw new Error(`simulation incorrect: ${JSON.stringify(n)}`);let r;try{r=BigInt(e.fee)}catch{r=BigInt(0)}const o=e.toEnvelope().v1().tx().ext().value();o&&r-o.resourceFee().toBigInt()>BigInt(0)&&(r-=o.resourceFee().toBigInt());const s=Ro.cloneFrom(e,{fee:r.toString(),sorobanData:n.transactionData.build(),networkPassphrase:e.networkPassphrase});if("invokeHostFunction"===e.operations[0].type){s.clearOperations();const t=e.operations[0],r=t.auth??[];s.addOperation(Qr.invokeHostFunction({source:t.source,func:t.func,auth:r.length>0?r:n.result.auth}))}return s}var Mi=(e=>(e.Temporary="temporary",e.Persistent="persistent",e))(Mi||{});const qi=e=>1e3;class Hi{serverURL;httpClient;constructor(e,t={}){var n;if(this.serverURL=new URL(e),this.httpClient=(n=t.headers,v({headers:{...n,"X-Client-Name":"js-stellar-sdk","X-Client-Version":"16.0.1"}})),"https:"!==this.serverURL.protocol&&!t.allowHttp)throw new Error("Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set")}async getAccount(e){const t=await this.getAccountEntry(e);return new uo(e,t.seqNum().toString())}async getAccountEntry(e){const t=se.LedgerKey.account(new se.LedgerKeyAccount({accountId:Tn.fromPublicKey(e).xdrPublicKey()}));try{return(await this.getLedgerEntry(t)).val.account()}catch{throw new Error(`Account not found: ${e}`)}}async getTrustline(e,t){const n=se.LedgerKey.trustline(new se.LedgerKeyTrustLine({accountId:Tn.fromPublicKey(e).xdrAccountId(),asset:t.toTrustLineXDRObject()}));try{return(await this.getLedgerEntry(n)).val.trustLine()}catch{throw new Error(`Trustline for ${t.getCode()}:${t.getIssuer()} not found for ${e}`)}}async getClaimableBalance(e){let t;if(wn.isValidClaimableBalance(e)){const n=wn.decodeClaimableBalance(e),r=fe.Buffer.concat([fe.Buffer.from("\0\0\0"),n.subarray(0,1)]);t=se.ClaimableBalanceId.fromXDR(fe.Buffer.concat([r,n.subarray(1)]))}else if(e.match(/[a-f0-9]{72}/i))t=se.ClaimableBalanceId.fromXDR(e,"hex");else{if(!e.match(/[a-f0-9]{64}/i))throw new TypeError(`expected 72-char hex ID or strkey, not ${e}`);t=se.ClaimableBalanceId.fromXDR(e.padStart(72,"0"),"hex")}const n=se.LedgerKey.claimableBalance(new se.LedgerKeyClaimableBalance({balanceId:t}));try{return(await this.getLedgerEntry(n)).val.claimableBalance()}catch{throw new Error(`Claimable balance ${e} not found`)}}async getAssetBalance(e,t,n){let r=e;if("string"==typeof e)r=e;else if(e instanceof Xr)r=e.toString();else{if(!(e instanceof go))throw new TypeError(`invalid address: ${e}`);r=e.toString()}if(wn.isValidEd25519PublicKey(r)){const[e,n]=await Promise.all([this.getTrustline(r,t),this.getLatestLedger()]);return{latestLedger:n.sequence,balanceEntry:{amount:e.balance().toString(),authorized:Boolean(1&e.flags()),clawback:Boolean(4&e.flags()),authorizedToMaintainLiabilities:Boolean(2&e.flags()),revocable:Boolean(2&e.flags())}}}if(wn.isValidContract(r))return this.getSACBalance(r,t,n);throw new Error(`invalid address: ${e}`)}async getHealth(){return Ri(this.httpClient,this.serverURL.toString(),"getHealth")}async getContractData(e,t,n="persistent"){let r,o;if("string"==typeof e)r=new go(e).address().toScAddress();else if(e instanceof Xr)r=e.toScAddress();else{if(!(e instanceof go))throw new TypeError(`unknown contract type: ${e}`);r=e.address().toScAddress()}switch(n){case"temporary":o=se.ContractDataDurability.temporary();break;case"persistent":o=se.ContractDataDurability.persistent();break;default:throw new TypeError(`invalid durability: ${n}`)}const s=se.LedgerKey.contractData(new se.LedgerKeyContractData({key:t,contract:r,durability:o}));try{return await this.getLedgerEntry(s)}catch{throw{code:404,message:`Contract data not found for ${Xr.fromScAddress(r).toString()} with key ${t.toXDR("base64")} and durability: ${n}`}}}async getContractWasmByContractId(e){const t=new go(e).getFootprint(),n=await this.getLedgerEntries(t);if(!n.entries.length||!n.entries[0]?.val)return Promise.reject({code:404,message:"Could not obtain contract hash from server"});const r=n.entries[0].val.contractData().val().instance().executable().wasmHash();return this.getContractWasmByHash(r)}async getContractWasmByHash(e,t=void 0){const n="string"==typeof e?fe.Buffer.from(e,t):e,r=se.LedgerKey.contractCode(new se.LedgerKeyContractCode({hash:n})),o=await this.getLedgerEntries(r);if(!o.entries.length||!o.entries[0]?.val)return Promise.reject({code:404,message:"Could not obtain contract wasm from server"});return o.entries[0].val.contractCode().code()}getLedgerEntries(...e){return this._getLedgerEntries(...e).then(Li)}_getLedgerEntries(...e){return Ri(this.httpClient,this.serverURL.toString(),"getLedgerEntries",{keys:e.map(e=>e.toXDR("base64"))})}async getLedgerEntry(e){const t=await this._getLedgerEntries(e).then(Li);if(1!==t.entries.length)throw new Error(`failed to find an entry for key ${e.toXDR("base64")}`);return t.entries[0]}async pollTransaction(e,t){const n=(t?.attempts??0)<1?30:t?.attempts??30;let r;for(let o=1;o<=n;o++){if(r=await this.getTransaction(e),r.status!==Bi.GetTransactionStatus.NOT_FOUND)return r;await P.sleep((t?.sleepStrategy??qi)(o))}return r}async getTransaction(e){return this._getTransaction(e).then(t=>{const n={};t.status!==Bi.GetTransactionStatus.NOT_FOUND&&Object.assign(n,Pi(t));return{status:t.status,txHash:e,latestLedger:t.latestLedger,latestLedgerCloseTime:t.latestLedgerCloseTime,oldestLedger:t.oldestLedger,oldestLedgerCloseTime:t.oldestLedgerCloseTime,...n}})}async _getTransaction(e){return Ri(this.httpClient,this.serverURL.toString(),"getTransaction",{hash:e})}async getTransactions(e){return this._getTransactions(e).then(e=>({transactions:(e.transactions||[]).map(Oi),latestLedger:e.latestLedger,latestLedgerCloseTimestamp:e.latestLedgerCloseTimestamp,oldestLedger:e.oldestLedger,oldestLedgerCloseTimestamp:e.oldestLedgerCloseTimestamp,cursor:e.cursor}))}async _getTransactions(e){return Ri(this.httpClient,this.serverURL.toString(),"getTransactions",e)}async getEvents(e){return this._getEvents(e).then(Ui)}async _getEvents(e){return Ri(this.httpClient,this.serverURL.toString(),"getEvents",{filters:e.filters??[],pagination:{...e.cursor&&{cursor:e.cursor},...e.limit&&{limit:e.limit}},...e.startLedger&&{startLedger:e.startLedger},...e.endLedger&&{endLedger:e.endLedger}})}async getNetwork(){return Ri(this.httpClient,this.serverURL.toString(),"getNetwork")}async getLatestLedger(){return this._getLatestLedger().then(Fi)}async _getLatestLedger(){return Ri(this.httpClient,this.serverURL.toString(),"getLatestLedger")}async simulateTransaction(e,t,n){return this._simulateTransaction(e,t,n).then(Ni)}async _simulateTransaction(e,t,n){return Ri(this.httpClient,this.serverURL.toString(),"simulateTransaction",{transaction:e.toXDR(),authMode:n,...void 0!==t&&{resourceConfig:{instructionLeeway:t.cpuInstructions}}})}async prepareTransaction(e){const t=await this.simulateTransaction(e);if(Bi.isSimulationError(t))throw new Error(t.error);return Di(e,t).build()}async sendTransaction(e){return this._sendTransaction(e).then(_i)}async _sendTransaction(e){return Ri(this.httpClient,this.serverURL.toString(),"sendTransaction",{transaction:e.toXDR()})}async requestAirdrop(e,t){const n="string"==typeof e?e:e.accountId();if(!(t=t||(await this.getNetwork()).friendbotUrl))throw new Error("No friendbot URL configured for current network");try{const r=await this.httpClient.post(`${t}?addr=${encodeURIComponent(n)}`);let o;if(r.data.result_meta_xdr)o=se.TransactionMeta.fromXDR(r.data.result_meta_xdr,"base64");else{const t=await this.getTransaction(r.data.hash);if(t.status!==Bi.GetTransactionStatus.SUCCESS)throw new Error(`Funding account ${e} failed`);o=t.resultMetaXdr}const s=function(e){let t=[];switch(e.switch()){case 0:t=e.operations();break;case 1:case 2:case 3:case 4:t=e.value().operations();break;default:throw new Error("Unexpected transaction meta switch value")}const n=t.flatMap(e=>e.changes()).find(e=>e.switch()===se.LedgerEntryChangeType.ledgerEntryCreated()&&e.created().data().switch()===se.LedgerEntryType.account())?.created()?.data()?.account()?.seqNum()?.toString();if(n)return n;throw new Error("No account created in transaction")}(o);return new uo(n,s)}catch(e){if(400===e.response?.status&&e.response.data?.detail?.includes("createAccountAlreadyExist"))return this.getAccount(n);throw e}}async fundAddress(e,t){if(!wn.isValidEd25519PublicKey(e)&&!wn.isValidContract(e))throw new Error(`Invalid address: ${e}. Expected a Stellar account (G...) or contract (C...) address.`);if(!(t=t||(await this.getNetwork()).friendbotUrl))throw new Error("No friendbot URL configured for current network");try{const n=await this.httpClient.post(`${t}?addr=${encodeURIComponent(e)}`),r=await this.getTransaction(n.data.hash);if(r.status!==Bi.GetTransactionStatus.SUCCESS)throw new Error(`Funding address ${e} failed: transaction status ${r.status}`);return r}catch(e){if(400===e.response?.status)throw new Error(e.response.data?.detail??"Bad Request");throw e}}async getFeeStats(){return Ri(this.httpClient,this.serverURL.toString(),"getFeeStats")}async getVersionInfo(){return Ri(this.httpClient,this.serverURL.toString(),"getVersionInfo")}async getSACBalance(e,t,n){const r=e instanceof Xr?e.toString():e;if(!wn.isValidContract(r))throw new TypeError(`expected contract ID, got ${r}`);const o=n??await this.getNetwork().then(e=>e.passphrase),s=t.contractId(o),i=Eo(["Balance",r],{type:["symbol","address"]}),a=se.LedgerKey.contractData(new se.LedgerKeyContractData({contract:new Xr(s).toScAddress(),durability:se.ContractDataDurability.persistent(),key:i})),c=await this.getLedgerEntries(a);if(0===c.entries.length)return{latestLedger:c.latestLedger};const{lastModifiedLedgerSeq:u,liveUntilLedgerSeq:l,val:d}=c.entries[0];if(d.switch().value!==se.LedgerEntryType.contractData().value)return{latestLedger:c.latestLedger};const p=ko(d.contractData().val());return{latestLedger:c.latestLedger,balanceEntry:{liveUntilLedgerSeq:l,lastModifiedLedgerSeq:u,amount:p.amount.toString(),authorized:p.authorized,clawback:p.clawback}}}async getLedgers(e){return this._getLedgers(e).then(e=>({ledgers:(e.ledgers||[]).map(Vi),latestLedger:e.latestLedger,latestLedgerCloseTime:e.latestLedgerCloseTime,oldestLedger:e.oldestLedger,oldestLedgerCloseTime:e.oldestLedgerCloseTime,cursor:e.cursor}))}async _getLedgers(e){return Ri(this.httpClient,this.serverURL.toString(),"getLedgers",e)}}var Gi=Object.freeze({__proto__:null,get Api(){return Bi},BasicSleepStrategy:qi,Durability:Mi,LinearSleepStrategy:e=>1e3*e,Server:Hi,assembleTransaction:Di,parseRawEvents:Ui,parseRawSimulation:Ni});class $i{constructor(e){this.value=e}value;unwrapErr(){throw new Error("No error")}unwrap(){return this.value}isOk(){return!0}isErr(){return!1}}class Xi{constructor(e){this.error=e}error;unwrapErr(){return this.error}unwrap(){throw new Error(this.error.message)}isOk(){return!1}isErr(){return!0}}const Ki=300,Wi="GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";const Zi=/Error\(Contract, #(\d+)\)/;function zi(e){const t=new ie.XdrReader(e),n=[];for(;!t.eof;)n.push(se.ScSpecEntry.read(t));return n}async function ji(e,t){return e.publicKey?t.getAccount(e.publicKey):new uo(Wi,"0")}class Yi{constructor(e){this.assembled=e;const{server:t,allowHttp:n,headers:r,rpcUrl:o}=this.assembled.options;this.server=t??new Hi(o,{allowHttp:n,headers:r})}assembled;server;sendTransactionResponse;getTransactionResponseAll;getTransactionResponse;static Errors={SendFailed:class extends Error{},SendResultOnly:class extends Error{},TransactionStillPending:class extends Error{}};static init=async(e,t)=>{const n=new Yi(e);return await n.send(t)};send=async e=>{if(this.sendTransactionResponse=await this.server.sendTransaction(this.assembled.signed),"PENDING"!==this.sendTransactionResponse.status)throw new Yi.Errors.SendFailed(`Sending the transaction to the network failed!\n${JSON.stringify(this.sendTransactionResponse,null,2)}`);e?.onSubmitted&&e.onSubmitted(this.sendTransactionResponse);const{hash:t}=this.sendTransactionResponse,n=this.assembled.options.timeoutInSeconds??Ki;if(this.getTransactionResponseAll=await async function(e,t,n,r=1.5,o=!1){const s=[];let i=0;if(s.push(await e()),!t(s[s.length-1]))return s;const a=new Date(Date.now()+1e3*n).valueOf();let c=1e3,u=c;for(;Date.now()<a&&t(s[s.length-1]);)i+=1,o&&console.info(`Waiting ${c}ms before trying again (bringing the total wait time to ${u}ms so far, of total ${1e3*n}ms)`),await new Promise(e=>setTimeout(e,c)),c*=r,new Date(Date.now()+c).valueOf()>a&&(c=a-Date.now(),o&&console.info(`was gonna wait too long; new waitTime: ${c}ms`)),u=c+u,s.push(await e(s[s.length-1])),o&&t(s[s.length-1])&&console.info(`${i}. Called ${e}; ${s.length} prev attempts. Most recent: ${JSON.stringify(s[s.length-1],null,2)}`);return s}(async()=>{const n=await this.server.getTransaction(t);return e?.onProgress&&e.onProgress(n),n},e=>e.status===Bi.GetTransactionStatus.NOT_FOUND,n),this.getTransactionResponse=this.getTransactionResponseAll[this.getTransactionResponseAll.length-1],this.getTransactionResponse.status===Bi.GetTransactionStatus.NOT_FOUND)throw new Yi.Errors.TransactionStillPending(`Waited ${n} seconds for transaction to complete, but it did not. Returning anyway. Check the transaction status manually. Sent transaction: ${JSON.stringify(this.sendTransactionResponse,null,2)}\nAll attempts to get the result: ${JSON.stringify(this.getTransactionResponseAll,null,2)}`);return this};get result(){if("getTransactionResponse"in this&&this.getTransactionResponse){if("returnValue"in this.getTransactionResponse)return this.assembled.options.parseResultXdr(this.getTransactionResponse.returnValue);throw new Error("Transaction failed! Cannot parse result.")}if(this.sendTransactionResponse){const e=this.sendTransactionResponse.errorResult?.result();if(e)throw new Yi.Errors.SendFailed(`Transaction simulation looked correct, but attempting to send the transaction failed. Check \`simulation\` and \`sendTransactionResponseAll\` to troubleshoot. Decoded \`sendTransactionResponse.errorResultXdr\`: ${e}`);throw new Yi.Errors.SendResultOnly("Transaction was sent to the network, but not yet awaited. No result to show. Await transaction completion with `getTransaction(sendTransactionResponse.hash)`")}throw new Error(`Sending transaction failed: ${JSON.stringify(this.assembled.signed)}`)}}class Ji extends Error{}class Qi extends Error{}class ea extends Error{}class ta extends Error{}class na extends Error{}class ra extends Error{}class oa extends Error{}class sa extends Error{}class ia extends Error{}class aa extends Error{}class ca extends Error{}class ua extends Error{}class la extends Error{}class da{constructor(e){this.options=e,this.options.simulate=this.options.simulate??!0;const{server:t,allowHttp:n,headers:r,rpcUrl:o}=this.options;this.server=t??new Hi(o,{allowHttp:n,headers:r})}options;raw;originalOp;built;simulation;simulationResult;simulationTransactionData;server;signed;static Errors={ExpiredState:Ji,RestorationFailure:Qi,NeedsMoreSignatures:ea,NoSignatureNeeded:ta,NoUnsignedNonInvokerAuthEntries:na,NoSigner:ra,NotYetSimulated:oa,FakeAccount:sa,SimulationFailed:ia,InternalWalletError:aa,ExternalServiceError:ca,InvalidClientRequest:ua,UserRejected:la};toJSON(){return JSON.stringify({method:this.options.method,tx:this.built?.toXDR(),simulationResult:{auth:this.simulationData.result.auth.map(e=>e.toXDR("base64")),retval:this.simulationData.result.retval.toXDR("base64")},simulationTransactionData:this.simulationData.transactionData.toXDR("base64")})}static validateInvokeContractOp(e,t){if(1!==e.operations.length)throw new Error("Transaction envelope must contain exactly one operation.");const n=e.operations[0];if("invokeHostFunction"!==n.type)throw new Error("Transaction envelope does not contain an invokeHostFunction operation.");const r=n;if("hostFunctionTypeInvokeContract"!==r.func.switch().name)throw new Error("Transaction envelope does not contain an invokeContract host function.");const o=r.func.value();let s,i;try{s=o.contractAddress(),i=o.functionName().toString("utf-8")}catch{throw new Error("Could not extract contract address or method name from the transaction envelope.")}if(!s||!i)throw new Error("Could not extract contract address or method name from the transaction envelope.");const a=Xr.fromScAddress(s).toString();if(a!==t)throw new Error(`Transaction envelope targets contract ${a}, but this Client is configured for ${t}.`);return o}static fromJSON(e,{tx:t,simulationResult:n,simulationTransactionData:r}){const o=new da(e);o.built=Ro.fromXDR(t,e.networkPassphrase);const s=da.validateInvokeContractOp(o.built,e.contractId).functionName().toString("utf-8");if(s!==e.method)throw new Error(`Transaction envelope calls method '${s}', but the provided method is '${e.method}'.`);return o.simulationResult={auth:n.auth.map(e=>se.SorobanAuthorizationEntry.fromXDR(e,"base64")),retval:se.ScVal.fromXDR(n.retval,"base64")},o.simulationTransactionData=se.SorobanTransactionData.fromXDR(r,"base64"),o}toXDR(){if(!this.built)throw new Error("Transaction has not yet been simulated; call `AssembledTransaction.simulate` first.");return this.built?.toEnvelope().toXDR("base64")}static fromXDR(e,t,n){const r=se.TransactionEnvelope.fromXDR(t,"base64"),o=Ro.fromXDR(r,e.networkPassphrase),s=da.validateInvokeContractOp(o,e.contractId).functionName().toString("utf-8"),i=new da({...e,method:s,parseResultXdr:e=>n.funcResToNative(s,e)});return i.built=o,i}handleWalletError(e){if(!e)return;const{message:t,code:n}=e,r=`${t}${e.ext?` (${e.ext.join(", ")})`:""}`;switch(n){case-1:throw new da.Errors.InternalWalletError(r);case-2:throw new da.Errors.ExternalServiceError(r);case-3:throw new da.Errors.InvalidClientRequest(r);case-4:throw new da.Errors.UserRejected(r);default:throw new Error(`Unhandled error: ${r}`)}}static build(e){const t=new go(e.contractId);return da.buildWithOp(t.call(e.method,...e.args??[]),e)}static async buildWithOp(e,t){const n=new da(t);n.originalOp=e;const r=await ji(t,n.server);return n.raw=new Ro(r,{fee:t.fee??xo,networkPassphrase:t.networkPassphrase}).setTimeout(t.timeoutInSeconds??Ki).addOperation(e),t.simulate&&await n.simulate(),n}static async buildFootprintRestoreTransaction(e,t,n,r){const o=new da(e);return o.raw=new Ro(n,{fee:r,networkPassphrase:e.networkPassphrase}).setSorobanData(t instanceof fo?t.build():t).addOperation(Qr.restoreFootprint({})).setTimeout(e.timeoutInSeconds??Ki),await o.simulate({restore:!1}),o}simulate=async({restore:e}={})=>{if(!this.built){if(!this.raw)throw new Error("Transaction has not yet been assembled; call `AssembledTransaction.build` first.");this.built=this.raw.build()}if(e=e??this.options.restore,delete this.simulationResult,delete this.simulationTransactionData,this.simulation=await this.server.simulateTransaction(this.built),e&&Bi.isSimulationRestore(this.simulation)){const e=await ji(this.options,this.server),t=await this.restoreFootprint(this.simulation.restorePreamble,e);if(t.status===Bi.GetTransactionStatus.SUCCESS){const t=this.originalOp?this.originalOp:new go(this.options.contractId).call(this.options.method,...this.options.args??[]);return this.raw=new Ro(e,{fee:this.options.fee??xo,networkPassphrase:this.options.networkPassphrase}).addOperation(t).setTimeout(this.options.timeoutInSeconds??Ki),delete this.built,await this.simulate(),this}throw new da.Errors.RestorationFailure(`Automatic restore failed! You set 'restore: true' but the attempted restore did not work. Result:\n${JSON.stringify(t)}`)}return Bi.isSimulationSuccess(this.simulation)&&(this.built=Di(this.built,this.simulation).build()),this};get simulationData(){if(this.simulationResult&&this.simulationTransactionData)return{result:this.simulationResult,transactionData:this.simulationTransactionData};const e=this.simulation;if(!e)throw new da.Errors.NotYetSimulated("Transaction has not yet been simulated");if(Bi.isSimulationError(e))throw new da.Errors.SimulationFailed(`Transaction simulation failed: "${e.error}"`);if(Bi.isSimulationRestore(e))throw new da.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\nYou can set `restore` to true in the method options in order to automatically restore the contract state when needed.");return this.simulationResult=e.result??{auth:[],retval:se.ScVal.scvVoid()},this.simulationTransactionData=e.transactionData.build(),{result:this.simulationResult,transactionData:this.simulationTransactionData}}get result(){try{if(!this.simulationData.result)throw new Error("No simulation result!");return this.options.parseResultXdr(this.simulationData.result.retval)}catch(t){if("object"!=typeof(e=t)||null===e||!("toString"in e))throw t;const n=this.parseError(t.toString());if(n)return n;throw t}var e}parseError(e){if(!this.options.errorTypes)return;const t=e.match(Zi);if(!t)return;const n=parseInt(t[1],10),r=this.options.errorTypes[n];return r?new Xi(r):void 0}sign=async({force:e=!1,signTransaction:t=this.options.signTransaction}={})=>{if(!this.built)throw new Error("Transaction has not yet been simulated");if(!e&&this.isReadCall)throw new da.Errors.NoSignatureNeeded("This is a read call. It requires no signature or sending. Use `force: true` to sign and send anyway.");if(!t)throw new da.Errors.NoSigner("You must provide a signTransaction function, either when calling `signAndSend` or when initializing your Client");if(!this.options.publicKey)throw new da.Errors.FakeAccount("This transaction was constructed using a default account. Provide a valid publicKey in the AssembledTransactionOptions.");const n=this.needsNonInvokerSigningBy().filter(e=>!e.startsWith("C"));if(n.length)throw new da.Errors.NeedsMoreSignatures(`Transaction requires signatures from ${n}. See \`needsNonInvokerSigningBy\` for details.`);const r=this.options.timeoutInSeconds??Ki;this.built=Ro.cloneFrom(this.built,{fee:this.built.fee,timebounds:void 0,sorobanData:this.simulationData.transactionData}).setTimeout(r).build();const o={networkPassphrase:this.options.networkPassphrase};this.options.address&&(o.address=this.options.address),void 0!==this.options.submit&&(o.submit=this.options.submit),this.options.submitUrl&&(o.submitUrl=this.options.submitUrl);const{signedTxXdr:s,error:i}=await t(this.built.toXDR(),o);this.handleWalletError(i),this.signed=Ro.fromXDR(s,this.options.networkPassphrase)};async send(e){if(!this.signed)throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");return await Yi.init(this,e)}signAndSend=async({force:e=!1,signTransaction:t=this.options.signTransaction,watcher:n}={})=>{if(!this.signed){const n=t||this.options.signTransaction,r=this.options.submit&&n?(e,t)=>n(e,{...t,submit:!1}):t;await this.sign({force:e,signTransaction:r})}return this.send(n)};needsNonInvokerSigningBy=({includeAlreadySigned:e=!1}={})=>{if(!this.built)throw new Error("Transaction has not yet been simulated");if(!("operations"in this.built))throw new Error(`Unexpected Transaction type; no operations: ${JSON.stringify(this.built)}`);const t=this.built.operations[0];return[...new Set((t.auth??[]).map(e=>Go(e.credentials())).filter(t=>null!==t&&(e||"scvVoid"===t.signature().switch().name)).map(e=>Xr.fromScAddress(e.address()).toString()))]};signAuthEntries=async({expiration:e=(async()=>(await this.server.getLatestLedger()).sequence+100)(),signAuthEntry:t=this.options.signAuthEntry,address:n=this.options.publicKey,authorizeEntry:r=Fo}={})=>{if(!this.built)throw new Error("Transaction has not yet been assembled or simulated");if(r===Fo){const e=this.needsNonInvokerSigningBy();if(0===e.length)throw new da.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");if(-1===e.indexOf(n??""))throw new da.Errors.NoSignatureNeeded(`No auth entries for public key "${n}"`);if(!t)throw new da.Errors.NoSigner("You must provide `signAuthEntry` or a custom `authorizeEntry`")}const o=this.built.operations[0].auth??[];for(const[s,i]of o.entries()){const a=Go(se.SorobanCredentials.fromXDR(i.credentials().toXDR()));if(null===a)continue;if(Xr.fromScAddress(a.address()).toString()!==n)continue;const c=t??Promise.resolve;o[s]=await r(i,async e=>{const{signedAuthEntry:t,error:r}=await c(e.toXDR("base64"),{address:n});return this.handleWalletError(r),fe.Buffer.from(t,"base64")},await e,this.options.networkPassphrase)}};get isReadCall(){const e=this.simulationData.result.auth.length,t=this.simulationData.transactionData.resources().footprint().readWrite().length;return 0===e&&0===t}async restoreFootprint(e,t){if(!this.options.signTransaction)throw new Error("For automatic restore to work you must provide a signTransaction function when initializing your Client");t=t??await ji(this.options,this.server);const n=await da.buildFootprintRestoreTransaction({...this.options},e.transactionData,t,e.minResourceFee),r=await n.signAndSend();if(!r.getTransactionResponse)throw new da.Errors.RestorationFailure(`The attempt at automatic restore failed. \n${JSON.stringify(r)}`);return r.getTransactionResponse}}function pa(e){const t=function(e){const t=new Map,n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let r=0;const o=t=>{if(r+t>e.byteLength)throw new Error("Buffer overflow");const o=new Uint8Array(n,r,t);return r+=t,o};function s(){let e=0,t=0;for(;;){const n=o(1)[0];if(e|=(127&n)<<t,!(128&n))break;if((t+=7)>=32)throw new Error("Invalid WASM value")}return e>>>0}if("0,97,115,109"!==[...o(4)].join())throw new Error("Invalid WASM magic");if("1,0,0,0"!==[...o(4)].join())throw new Error("Invalid WASM version");for(;r<e.byteLength;){const e=o(1)[0],n=s(),i=r;if(0===e){const e=s();if(e>0&&r+e<=i+n){const s=o(e),a=o(n-(r-i));try{const e=new TextDecoder("utf-8",{fatal:!0}).decode(s);a.length>0&&t.set(e,(t.get(e)||[]).concat(a))}catch{}}}r=i+n}return t}(e),n=t.get("contractspecv0");if(!n||0===n.length)throw new Error("Could not obtain contract spec from wasm");return fe.Buffer.from(n[0])}function ha(e){return/^\d+$/.test(e.name().toString())}const fa={U32:{type:"integer",minimum:0,maximum:4294967295},I32:{type:"integer",minimum:-2147483648,maximum:2147483647},U64:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},Timepoint:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},Duration:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},I64:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:21},U128:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:39},I128:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:40},U256:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:78},I256:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:79},Address:{type:"string",format:"address",description:"Address can be a public key or contract id"},MuxedAddress:{type:"string",format:"address",description:"Stellar public key with M prefix combining a G address and unique ID"},ScString:{type:"string",description:"ScString is a string"},ScSymbol:{type:"string",description:"ScSymbol is a string"},DataUrl:{type:"string",pattern:"^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$"}};function ma(e){let t;switch(e.switch().value){case se.ScSpecType.scSpecTypeVal().value:t="Val";break;case se.ScSpecType.scSpecTypeBool().value:return{type:"boolean"};case se.ScSpecType.scSpecTypeVoid().value:return{type:"null"};case se.ScSpecType.scSpecTypeError().value:t="Error";break;case se.ScSpecType.scSpecTypeU32().value:t="U32";break;case se.ScSpecType.scSpecTypeI32().value:t="I32";break;case se.ScSpecType.scSpecTypeU64().value:t="U64";break;case se.ScSpecType.scSpecTypeI64().value:t="I64";break;case se.ScSpecType.scSpecTypeTimepoint().value:t="Timepoint";break;case se.ScSpecType.scSpecTypeDuration().value:t="Duration";break;case se.ScSpecType.scSpecTypeU128().value:t="U128";break;case se.ScSpecType.scSpecTypeI128().value:t="I128";break;case se.ScSpecType.scSpecTypeU256().value:t="U256";break;case se.ScSpecType.scSpecTypeI256().value:t="I256";break;case se.ScSpecType.scSpecTypeBytes().value:t="DataUrl";break;case se.ScSpecType.scSpecTypeString().value:t="ScString";break;case se.ScSpecType.scSpecTypeSymbol().value:t="ScSymbol";break;case se.ScSpecType.scSpecTypeAddress().value:t="Address";break;case se.ScSpecType.scSpecTypeMuxedAddress().value:t="MuxedAddress";break;case se.ScSpecType.scSpecTypeOption().value:return ma(e.option().valueType());case se.ScSpecType.scSpecTypeResult().value:return ma(e.result().okType());case se.ScSpecType.scSpecTypeVec().value:return{type:"array",items:ma(e.vec().elementType())};case se.ScSpecType.scSpecTypeMap().value:{const t=e.map();return{type:"array",items:{type:"array",items:[ma(t.keyType()),ma(t.valueType())],minItems:2,maxItems:2}}}case se.ScSpecType.scSpecTypeTuple().value:{const t=e.tuple(),n=t.valueTypes().length,r=n;return{type:"array",items:t.valueTypes().map(ma),minItems:n,maxItems:r}}case se.ScSpecType.scSpecTypeBytesN().value:return{$ref:"#/definitions/DataUrl",maxLength:e.bytesN().n()};case se.ScSpecType.scSpecTypeUdt().value:t=e.udt().name().toString();break}return{$ref:`#/definitions/${t}`}}function ga(e){const t={},n=[];e.forEach(e=>{const r=e.type(),o=e.name().toString();t[o]=ma(r),r.switch().value!==se.ScSpecType.scSpecTypeOption().value&&n.push(o)});const r={properties:t};return n.length>0&&(r.required=n),r}class ya{entries=[];static fromWasm(e){const t=pa(e);return new ya(t)}constructor(e){if(fe.Buffer.isBuffer(e))this.entries=zi(e);else if("string"==typeof e)this.entries=zi(fe.Buffer.from(e,"base64"));else{if(0===e.length)throw new Error("Contract spec must have at least one entry");const t=e[0];this.entries="string"==typeof t?e.map(e=>se.ScSpecEntry.fromXDR(e,"base64")):e}}funcs(){return this.entries.filter(e=>e.switch().value===se.ScSpecEntryKind.scSpecEntryFunctionV0().value).map(e=>e.functionV0())}getFunc(e){const t=this.findEntry(e);if(t.switch().value!==se.ScSpecEntryKind.scSpecEntryFunctionV0().value)throw new Error(`${e} is not a function`);return t.functionV0()}funcArgsToScVals(e,t){return this.getFunc(e).inputs().map(e=>this.nativeToScVal(function(e,t){const n=t.name().toString(),r=Object.entries(e).find(([e])=>e===n);if(!r)throw new Error(`Missing field ${n}`);return r[1]}(t,e),e.type()))}funcResToNative(e,t){const n="string"==typeof t?se.ScVal.fromXDR(t,"base64"):t,r=this.getFunc(e).outputs();if(0===r.length){const e=n.switch();if(e.value!==se.ScValType.scvVoid().value)throw new Error(`Expected void, got ${e.name}`);return null}if(r.length>1)throw new Error("Multiple outputs not supported");const o=r[0];return o.switch().value===se.ScSpecType.scSpecTypeResult().value?n.switch().value===se.ScValType.scvError().value?new Xi({message:n.error().toXDR("base64")}):new $i(this.scValToNative(n,o.result().okType())):this.scValToNative(n,o)}findEntry(e){const t=this.entries.find(t=>t.value().name().toString()===e);if(!t)throw new Error(`no such entry: ${e}`);return t}nativeToScVal(e,t){const n=t.switch(),r=n.value;if(n.value===se.ScSpecType.scSpecTypeUdt().value){const n=t.udt();return this.nativeToUdt(e,n.name().toString())}if(r===se.ScSpecType.scSpecTypeOption().value){const n=t.option();return null==e?se.ScVal.scvVoid():this.nativeToScVal(e,n.valueType())}switch(typeof e){case"object":if(null===e){if(r===se.ScSpecType.scSpecTypeVoid().value)return se.ScVal.scvVoid();throw new TypeError(`Type ${t} was not void, but value was null`)}if(e instanceof se.ScVal)return e;if(e instanceof Xr){if(t.switch().value!==se.ScSpecType.scSpecTypeAddress().value)throw new TypeError(`Type ${t} was not address, but value was Address`);return e.toScVal()}if(e instanceof go){if(t.switch().value!==se.ScSpecType.scSpecTypeAddress().value)throw new TypeError(`Type ${t} was not address, but value was Address`);return e.address().toScVal()}if(e instanceof Uint8Array||fe.Buffer.isBuffer(e)){const n=Uint8Array.from(e);switch(r){case se.ScSpecType.scSpecTypeBytesN().value:{const e=t.bytesN();if(n.length!==e.n())throw new TypeError(`expected ${e.n()} bytes, but got ${n.length}`);return se.ScVal.scvBytes(n)}case se.ScSpecType.scSpecTypeBytes().value:return se.ScVal.scvBytes(n);default:throw new TypeError(`invalid type (${t}) specified for Bytes and BytesN`)}}if(Array.isArray(e))switch(r){case se.ScSpecType.scSpecTypeVec().value:{const n=t.vec().elementType();return se.ScVal.scvVec(e.map(e=>this.nativeToScVal(e,n)))}case se.ScSpecType.scSpecTypeTuple().value:{const n=t.tuple().valueTypes();if(e.length!==n.length)throw new TypeError(`Tuple expects ${n.length} values, but ${e.length} were provided`);return se.ScVal.scvVec(e.map((e,t)=>this.nativeToScVal(e,n[t])))}case se.ScSpecType.scSpecTypeMap().value:{const n=t.map(),r=n.keyType(),o=n.valueType();return se.ScVal.scvMap(e.map(e=>{const t=this.nativeToScVal(e[0],r),n=this.nativeToScVal(e[1],o);return new se.ScMapEntry({key:t,val:n})}))}default:throw new TypeError(`Type ${t} was not vec, but value was Array`)}if(e.constructor===Map){if(r!==se.ScSpecType.scSpecTypeMap().value)throw new TypeError(`Type ${t} was not map, but value was Map`);const n=t.map(),o=[],s=e.entries();let i=s.next();for(;!i.done;){const[e,t]=i.value,r=this.nativeToScVal(e,n.keyType()),a=this.nativeToScVal(t,n.valueType());o.push(new se.ScMapEntry({key:r,val:a})),i=s.next()}return se.ScVal.scvMap(o)}if("Object"!==(e.constructor?.name??""))throw new TypeError(`cannot interpret ${e.constructor?.name} value as ScVal (${JSON.stringify(e)})`);throw new TypeError(`Received object ${e} did not match the provided type ${t}`);case"number":case"bigint":switch(r){case se.ScSpecType.scSpecTypeU32().value:if(BigInt(e)<BigInt(se.Uint32.MIN_VALUE)||BigInt(e)>BigInt(se.Uint32.MAX_VALUE))throw new RangeError(`Value ${e} is out of range for U32`);return se.ScVal.scvU32(Number(e));case se.ScSpecType.scSpecTypeI32().value:if(BigInt(e)<-BigInt(se.Int32.MIN_VALUE)||BigInt(e)>BigInt(se.Int32.MAX_VALUE))throw new RangeError(`Value ${e} is out of range for I32`);return se.ScVal.scvI32(Number(e));case se.ScSpecType.scSpecTypeU64().value:case se.ScSpecType.scSpecTypeI64().value:case se.ScSpecType.scSpecTypeU128().value:case se.ScSpecType.scSpecTypeI128().value:case se.ScSpecType.scSpecTypeU256().value:case se.ScSpecType.scSpecTypeI256().value:case se.ScSpecType.scSpecTypeTimepoint().value:case se.ScSpecType.scSpecTypeDuration().value:{const t=n.name.substring(10).toLowerCase();return new bo(t,e).toScVal()}default:throw new TypeError(`invalid type (${t}) specified for integer`)}case"string":return function(e,t){switch(t.value){case se.ScSpecType.scSpecTypeString().value:return se.ScVal.scvString(e);case se.ScSpecType.scSpecTypeSymbol().value:return se.ScVal.scvSymbol(e);case se.ScSpecType.scSpecTypeAddress().value:case se.ScSpecType.scSpecTypeMuxedAddress().value:return Xr.fromString(e).toScVal();case se.ScSpecType.scSpecTypeU64().value:return new bo("u64",e).toScVal();case se.ScSpecType.scSpecTypeI64().value:return new bo("i64",e).toScVal();case se.ScSpecType.scSpecTypeU128().value:return new bo("u128",e).toScVal();case se.ScSpecType.scSpecTypeI128().value:return new bo("i128",e).toScVal();case se.ScSpecType.scSpecTypeU256().value:return new bo("u256",e).toScVal();case se.ScSpecType.scSpecTypeI256().value:return new bo("i256",e).toScVal();case se.ScSpecType.scSpecTypeBytes().value:case se.ScSpecType.scSpecTypeBytesN().value:return se.ScVal.scvBytes(fe.Buffer.from(e,"base64"));case se.ScSpecType.scSpecTypeTimepoint().value:return se.ScVal.scvTimepoint(new se.Uint64(e));case se.ScSpecType.scSpecTypeDuration().value:return se.ScVal.scvDuration(new se.Uint64(e));default:throw new TypeError(`invalid type ${t.name} specified for string value`)}}(e,n);case"boolean":if(r!==se.ScSpecType.scSpecTypeBool().value)throw TypeError(`Type ${t} was not bool, but value was bool`);return se.ScVal.scvBool(e);case"undefined":if(!t)return se.ScVal.scvVoid();switch(r){case se.ScSpecType.scSpecTypeVoid().value:case se.ScSpecType.scSpecTypeOption().value:return se.ScVal.scvVoid();default:throw new TypeError(`Type ${t} was not void, but value was undefined`)}case"function":return this.nativeToScVal(e(),t);default:throw new TypeError(`failed to convert typeof ${typeof e} (${e})`)}}nativeToUdt(e,t){const n=this.findEntry(t);switch(n.switch()){case se.ScSpecEntryKind.scSpecEntryUdtEnumV0():if("number"!=typeof e)throw new TypeError(`expected number for enum ${t}, but got ${typeof e}`);return this.nativeToEnum(e,n.udtEnumV0());case se.ScSpecEntryKind.scSpecEntryUdtStructV0():return this.nativeToStruct(e,n.udtStructV0());case se.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.nativeToUnion(e,n.udtUnionV0());default:throw new Error(`failed to parse udt ${t}`)}}nativeToUnion(e,t){const n=e.tag,r=t.cases().find(e=>e.value().name().toString()===n);if(!r)throw new TypeError(`no such enum entry: ${n} in ${t}`);const o=se.ScVal.scvSymbol(n);switch(r.switch()){case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0():return se.ScVal.scvVec([o]);case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0():{const n=r.tupleCase().type();if(Array.isArray(e.values)){if(e.values.length!==n.length)throw new TypeError(`union ${t} expects ${n.length} values, but got ${e.values.length}`);const r=e.values.map((e,t)=>this.nativeToScVal(e,n[t]));return r.unshift(o),se.ScVal.scvVec(r)}throw new Error(`failed to parse union case ${r} with ${e}`)}default:throw new Error(`failed to parse union ${t} with ${e}`)}}nativeToStruct(e,t){const n=t.fields();if(n.some(ha)){if(!n.every(ha))throw new Error("mixed numeric and non-numeric field names are not allowed");return se.ScVal.scvVec(n.map((t,r)=>this.nativeToScVal(e[r],n[r].type())))}return se.ScVal.scvMap(n.map(t=>{const n=t.name().toString();return new se.ScMapEntry({key:this.nativeToScVal(n,se.ScSpecTypeDef.scSpecTypeSymbol()),val:this.nativeToScVal(e[n],t.type())})}))}nativeToEnum(e,t){if(t.cases().some(t=>t.value()===e))return se.ScVal.scvU32(e);throw new TypeError(`no such enum entry: ${e} in ${t}`)}scValStrToNative(e,t){return this.scValToNative(se.ScVal.fromXDR(e,"base64"),t)}scValToNative(e,t){const n=t.switch(),r=n.value;if(r===se.ScSpecType.scSpecTypeOption().value)return e.switch().value===se.ScValType.scvVoid().value?null:this.scValToNative(e,t.option().valueType());if(r===se.ScSpecType.scSpecTypeUdt().value)return this.scValUdtToNative(e,t.udt());switch(e.switch().value){case se.ScValType.scvVoid().value:return null;case se.ScValType.scvU64().value:case se.ScValType.scvI64().value:case se.ScValType.scvTimepoint().value:case se.ScValType.scvDuration().value:case se.ScValType.scvU128().value:case se.ScValType.scvI128().value:case se.ScValType.scvU256().value:case se.ScValType.scvI256().value:return To(e);case se.ScValType.scvVec().value:if(r===se.ScSpecType.scSpecTypeVec().value){const n=t.vec();return(e.vec()??[]).map(e=>this.scValToNative(e,n.elementType()))}if(r===se.ScSpecType.scSpecTypeTuple().value){const n=t.tuple().valueTypes();return(e.vec()??[]).map((e,t)=>this.scValToNative(e,n[t]))}throw new TypeError(`Type ${t} was not vec, but ${e} is`);case se.ScValType.scvAddress().value:return Xr.fromScVal(e).toString();case se.ScValType.scvMap().value:{const o=e.map()??[];if(r===se.ScSpecType.scSpecTypeMap().value){const e=t.map(),n=e.keyType(),r=e.valueType();return o.map(e=>[this.scValToNative(e.key(),n),this.scValToNative(e.val(),r)])}throw new TypeError(`ScSpecType ${n.name} was not map, but ${JSON.stringify(e,null,2)} is`)}case se.ScValType.scvBool().value:case se.ScValType.scvU32().value:case se.ScValType.scvI32().value:case se.ScValType.scvBytes().value:return e.value();case se.ScValType.scvString().value:case se.ScValType.scvSymbol().value:if(r!==se.ScSpecType.scSpecTypeString().value&&r!==se.ScSpecType.scSpecTypeSymbol().value)throw new Error(`ScSpecType ${n.name} was not string or symbol, but ${JSON.stringify(e,null,2)} is`);return e.value()?.toString();default:throw new TypeError(`failed to convert ${JSON.stringify(e,null,2)} to native type from type ${n.name}`)}}scValUdtToNative(e,t){const n=this.findEntry(t.name().toString());switch(n.switch()){case se.ScSpecEntryKind.scSpecEntryUdtEnumV0():return this.enumToNative(e);case se.ScSpecEntryKind.scSpecEntryUdtStructV0():return this.structToNative(e,n.udtStructV0());case se.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.unionToNative(e,n.udtUnionV0());default:throw new Error(`failed to parse udt ${t.name().toString()}: ${n}`)}}unionToNative(e,t){const n=e.vec();if(!n)throw new Error(`${JSON.stringify(e,null,2)} is not a vec`);if(0===n.length&&0!==t.cases.length)throw new Error(`${e} has length 0, but the there are at least one case in the union`);const r=n[0].sym().toString();if(n[0].switch().value!==se.ScValType.scvSymbol().value)throw new Error(`${n[0]} is not a symbol`);const o=t.cases().find(function(e){return function(t){switch(t.switch().value){case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value:return t.tupleCase().name().toString()===e;case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value:return t.voidCase().name().toString()===e;default:return!1}}}(r));if(!o)throw new Error(`failed to find entry ${r} in union ${t.name().toString()}`);const s={tag:r};if(o.switch().value===se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value){const e=o.tupleCase().type().map((e,t)=>this.scValToNative(n[t+1],e));s.values=e}return s}structToNative(e,t){const n={},r=t.fields();if(r.some(ha)){const t=e.vec()?.map((e,t)=>this.scValToNative(e,r[t].type()));return t}return e.map()?.forEach((e,t)=>{const o=r[t];n[o.name().toString()]=this.scValToNative(e.val(),o.type())}),n}enumToNative(e){if(e.switch().value!==se.ScValType.scvU32().value)throw new Error("Enum must have a u32 value");return e.u32()}errorCases(){return this.entries.filter(e=>e.switch().value===se.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value).flatMap(e=>e.value().cases())}jsonSchema(e){const t={};this.entries.forEach(e=>{switch(e.switch().value){case se.ScSpecEntryKind.scSpecEntryUdtEnumV0().value:{const n=e.udtEnumV0();t[n.name().toString()]=function(e){const t=e.doc().toString(),n=e.cases(),r=[];n.forEach(e=>{const t=e.name().toString(),n=e.doc().toString();r.push({description:n,title:t,enum:[e.value()],type:"number"})});const o={oneOf:r};return t.length>0&&(o.description=t),o}(n);break}case se.ScSpecEntryKind.scSpecEntryUdtStructV0().value:{const n=e.udtStructV0();t[n.name().toString()]=function(e){const t=e.fields();if(t.some(ha)){if(!t.every(ha))throw new Error("mixed numeric and non-numeric field names are not allowed");return{type:"array",items:t.map((e,n)=>ma(t[n].type())),minItems:t.length,maxItems:t.length}}const n=e.doc().toString(),{properties:r,required:o}=ga(t);return{description:n,properties:r,required:o,additionalProperties:!1,type:"object"}}(n);break}case se.ScSpecEntryKind.scSpecEntryUdtUnionV0().value:{const n=e.udtUnionV0();t[n.name().toString()]=function(e){const t=e.doc().toString(),n=e.cases(),r=[];n.forEach(e=>{switch(e.switch().value){case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value:{const t=e.voidCase().name().toString();r.push({type:"object",title:t,properties:{tag:t},additionalProperties:!1,required:["tag"]});break}case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value:{const t=e.tupleCase(),n=t.name().toString();r.push({type:"object",title:n,properties:{tag:n,values:{type:"array",items:t.type().map(ma)}},required:["tag","values"],additionalProperties:!1})}}});const o={oneOf:r};return t.length>0&&(o.description=t),o}(n);break}case se.ScSpecEntryKind.scSpecEntryFunctionV0().value:{const n=e.functionV0(),r=n.name().toString(),{input:o}=function(e){const{properties:t,required:n}=ga(e.inputs()),r={additionalProperties:!1,properties:t,type:"object"};n?.length>0&&(r.required=n);const o={properties:{args:r}},s=e.outputs(),i=s.length>0?ma(s[0]):ma(se.ScSpecTypeDef.scSpecTypeVoid()),a=e.doc().toString();return a.length>0&&(o.description=a),o.additionalProperties=!1,i.additionalProperties=!1,{input:o,output:i}}(n);t[r]=o;break}case se.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value:}});const n={$schema:"http://json-schema.org/draft-07/schema#",definitions:{...fa,...t}};return e&&(n.$ref=`#/definitions/${e}`),n}}function wa(e){const t=e.replace(/[^a-zA-Z0-9_$]/g,"_");return["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","implements","interface","let","package","private","protected","public","static","async","await","constructor","null","true","false"].includes(t)?t+"_":/^\d/.test(t)?"_"+t:""===t||/^_+$/.test(t)?"_unnamed":t}function Aa(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Sa(e,t=!1){switch(e.switch()){case se.ScSpecType.scSpecTypeVal():return"any";case se.ScSpecType.scSpecTypeBool():return"boolean";case se.ScSpecType.scSpecTypeVoid():return"null";case se.ScSpecType.scSpecTypeError():return"Error";case se.ScSpecType.scSpecTypeU32():case se.ScSpecType.scSpecTypeI32():return"number";case se.ScSpecType.scSpecTypeU64():case se.ScSpecType.scSpecTypeI64():case se.ScSpecType.scSpecTypeTimepoint():case se.ScSpecType.scSpecTypeDuration():case se.ScSpecType.scSpecTypeU128():case se.ScSpecType.scSpecTypeI128():case se.ScSpecType.scSpecTypeU256():case se.ScSpecType.scSpecTypeI256():return"bigint";case se.ScSpecType.scSpecTypeBytes():case se.ScSpecType.scSpecTypeBytesN():return"Buffer";case se.ScSpecType.scSpecTypeString():case se.ScSpecType.scSpecTypeSymbol():return"string";case se.ScSpecType.scSpecTypeAddress():case se.ScSpecType.scSpecTypeMuxedAddress():return t?"string | Address":"string";case se.ScSpecType.scSpecTypeVec():return`Array<${Sa(e.vec().elementType(),t)}>`;case se.ScSpecType.scSpecTypeMap():return`Map<${Sa(e.map().keyType(),t)}, ${Sa(e.map().valueType(),t)}>`;case se.ScSpecType.scSpecTypeTuple():return`[${e.tuple().valueTypes().map(e=>Sa(e,t)).join(", ")}]`;case se.ScSpecType.scSpecTypeOption():for(;e.option().valueType().switch()===se.ScSpecType.scSpecTypeOption();)e=e.option().valueType();return`${Sa(e.option().valueType(),t)} | null`;case se.ScSpecType.scSpecTypeResult():return`Result<${Sa(e.result().okType(),t)}, ${Sa(e.result().errorType(),t)}>`;case se.ScSpecType.scSpecTypeUdt():return wa(e.udt().name().toString());default:return"unknown"}}function ba(e,t){switch(e.switch()){case se.ScSpecType.scSpecTypeUdt():return void t.typeFileImports.add(wa(e.udt().name().toString()));case se.ScSpecType.scSpecTypeAddress():case se.ScSpecType.scSpecTypeMuxedAddress():return void t.stellarImports.add("Address");case se.ScSpecType.scSpecTypeBytes():case se.ScSpecType.scSpecTypeBytesN():return void(t.needsBufferImport=!0);case se.ScSpecType.scSpecTypeVal():return void t.stellarImports.add("xdr");case se.ScSpecType.scSpecTypeResult():t.stellarContractImports.add("Result");break;case se.ScSpecType.scSpecTypeBool():case se.ScSpecType.scSpecTypeVoid():case se.ScSpecType.scSpecTypeError():case se.ScSpecType.scSpecTypeU32():case se.ScSpecType.scSpecTypeI32():case se.ScSpecType.scSpecTypeU64():case se.ScSpecType.scSpecTypeI64():case se.ScSpecType.scSpecTypeTimepoint():case se.ScSpecType.scSpecTypeDuration():case se.ScSpecType.scSpecTypeU128():case se.ScSpecType.scSpecTypeI128():case se.ScSpecType.scSpecTypeU256():case se.ScSpecType.scSpecTypeI256():case se.ScSpecType.scSpecTypeString():case se.ScSpecType.scSpecTypeSymbol():return}const n=function(e){switch(e.switch()){case se.ScSpecType.scSpecTypeVec():return[e.vec().elementType()];case se.ScSpecType.scSpecTypeMap():return[e.map().keyType(),e.map().valueType()];case se.ScSpecType.scSpecTypeTuple():return e.tuple().valueTypes();case se.ScSpecType.scSpecTypeOption():return[e.option().valueType()];case se.ScSpecType.scSpecTypeResult():return[e.result().okType(),e.result().errorType()];default:return[]}}(e);n.forEach(e=>ba(e,t))}function va(e){const t={typeFileImports:new Set,stellarContractImports:new Set,stellarImports:new Set,needsBufferImport:!1};return e.forEach(e=>ba(e,t)),t}function Ta(e,t){const n=[],r=e.typeFileImports,o=[...e.stellarContractImports,...t?.additionalStellarContractImports||[]],s=[...e.stellarImports,...t?.additionalStellarImports||[]];if(t?.includeTypeFileImports&&r.size>0&&n.push(`import {${Array.from(r).join(", ")}} from './types.js';`),o.length>0){const e=Array.from(new Set(o));n.push(`import {${e.join(", ")}} from '@stellar/stellar-sdk/contract';`)}if(s.length>0){const e=Array.from(new Set(s));n.push(`import {${e.join(", ")}} from '@stellar/stellar-sdk';`)}return e.needsBufferImport&&n.push("import { Buffer } from 'buffer';"),n.join("\n")}function Ea(e,t=0){if(""===e.trim())return"";const n=" ".repeat(t);const r=e.replace(/\*\//g,"* /").replace(/@(?!(param|returns?|type|throws?|example|deprecated|see|link|since|author|version|description|summary)\b)/g,"\\@").split("\n").map(e=>`${n} * ${e}`.trimEnd());return`${n}/**\n${r.join("\n")}\n${n} */\n`}const ka="__constructor";class Ia{constructor(e,t){if(this.spec=e,this.options=t,void 0===t.server){const{allowHttp:e,headers:n}=t;t.server=new Hi(t.rpcUrl,{allowHttp:e,headers:n})}this.spec.funcs().forEach(n=>{const r=n.name().toString();if(r===ka)return;const o=(n,o)=>da.build({method:r,args:n&&e.funcArgsToScVals(r,n),...t,...o,errorTypes:e.errorCases().reduce((e,t)=>({...e,[t.value()]:{message:t.doc().toString()}}),{}),parseResultXdr:t=>e.funcResToNative(r,t)});this[wa(r)]=0===e.getFunc(r).inputs().length?e=>o(void 0,e):o})}spec;options;static async deploy(e,t){const{wasmHash:n,salt:r,format:o,fee:s,timeoutInSeconds:i,simulate:a,...c}=t,u=await async function(e,t,n="hex"){if(!t||!t.rpcUrl)throw new TypeError("options must contain rpcUrl");const{rpcUrl:r,allowHttp:o,headers:s}=t,i=new Hi(r,{allowHttp:o,headers:s}),a=await i.getContractWasmByHash(e,n);return ya.fromWasm(a)}(n,c,o),l=Qr.createCustomContract({address:new Xr(t.address||t.publicKey),wasmHash:"string"==typeof n?fe.Buffer.from(n,o??"hex"):n,salt:r,constructorArgs:e?u.funcArgsToScVals(ka,e):[]});return da.buildWithOp(l,{fee:s,timeoutInSeconds:i,simulate:a,...c,contractId:"ignored",method:ka,parseResultXdr:e=>new Ia(u,{...c,contractId:Xr.fromScVal(e).toString()})})}static async fromWasmHash(e,t,n="hex"){if(!t||!t.rpcUrl)throw new TypeError("options must contain rpcUrl");const{rpcUrl:r,allowHttp:o,headers:s}=t,i=t.server??new Hi(r,{allowHttp:o,headers:s}),a=await i.getContractWasmByHash(e,n);return Ia.fromWasm(a,t)}static async fromWasm(e,t){const n=await ya.fromWasm(e);return new Ia(n,t)}static async from(e){if(!e||!e.rpcUrl||!e.contractId)throw new TypeError("options must contain rpcUrl and contractId");const{rpcUrl:t,contractId:n,allowHttp:r,headers:o}=e,s=new Hi(t,{allowHttp:r,headers:o}),i=await s.getContractWasmByContractId(n);return Ia.fromWasm(i,e)}txFromJSON=e=>{const{method:t,...n}=JSON.parse(e);return da.fromJSON({...this.options,method:t,parseResultXdr:e=>this.spec.funcResToNative(t,e)},n)};txFromXDR=e=>da.fromXDR(this.options,e,this.spec)}var Ca=Object.freeze({__proto__:null,AssembledTransaction:da,Client:Ia,DEFAULT_TIMEOUT:Ki,Err:Xi,NULL_ACCOUNT:Wi,Ok:$i,SentTransaction:Yi,Spec:ya,Watcher:class{},basicNodeSigner:(e,t)=>({signTransaction:async(n,r)=>{const o=Ro.fromXDR(n,r?.networkPassphrase||t);return o.sign(e),{signedTxXdr:o.toXDR(),signerAddress:e.publicKey()}},signAuthEntry:async t=>({signedAuthEntry:e.sign(nt(fe.Buffer.from(t,"base64"))).toString("base64"),signerAddress:e.publicKey()})})});class Ba{generate(e){const{contractName:t}=e;return{packageJson:this.generatePackageJson(t),tsConfig:this.generateTsConfig(),gitignore:this.generateGitignore(),readme:this.generateReadme(t)}}generatePackageJson(e){const t={name:e.toLowerCase().replace(/[^a-z0-9-]/g,"-"),version:"0.0.1",description:`Generated TypeScript bindings for ${e} Stellar contract`,type:"module",main:"dist/index.js",types:"dist/index.d.ts",scripts:{build:"tsc"},dependencies:{"@stellar/stellar-sdk":"^16.0.1",buffer:"6.0.3"},devDependencies:{typescript:"^5.6.3"}};return JSON.stringify(t,null,2)}generateTsConfig(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"NodeNext",moduleResolution:"nodenext",declaration:!0,outDir:"./dist",strictNullChecks:!0,skipLibCheck:!0},include:["src/*"]},null,2)}generateGitignore(){return["# Dependencies","node_modules/","","# Build outputs","dist/","*.tgz","","# IDE",".vscode/",".idea/","","# OS",".DS_Store","Thumbs.db","","# Logs","*.log","npm-debug.log*","","# Runtime data","*.pid","*.seed"].join("\n")}generateReadme(e){return[`# ${e} Contract Bindings`,"",`TypeScript bindings for the ${e} Stellar smart contract.`,"","## Installation","","```bash","npm install","```","","## Build","","```bash","npm run build","```","","## Usage","","```typescript",'import { Client } from "./src";',"","const client = new Client({",' contractId: "YOUR_CONTRACT_ID",',' rpcUrl: "https://soroban-testnet.stellar.org:443",',' networkPassphrase: "Test SDF Network ; September 2015",',"});","","// Call contract methods","// const result = await client.methodName();","```","","## Generated Files","","- `src/index.ts` - Entry point exporting the Client","- `src/types.ts` - Type definitions for contract structs, enums, and unions","- `src/contract.ts` - Client implementation","- `tsconfig.json` - TypeScript configuration","- `package.json` - NPM package configuration","","This package was generated using the Js-Stellar-SDK contract binding generator."].join("\n")}}class xa{spec;constructor(e){this.spec=e}generate(){const e=this.spec.entries.map(e=>this.generateEntry(e)).filter(e=>e).join("\n\n");return`${this.generateImports()}\n\n ${e}\n `}generateEntry(e){switch(e.switch()){case se.ScSpecEntryKind.scSpecEntryUdtStructV0():return e.udtStructV0().fields().every((e,t)=>e.name().toString().trim()===t.toString())?this.generateTupleStruct(e.udtStructV0()):this.generateStruct(e.udtStructV0());case se.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.generateUnion(e.udtUnionV0());case se.ScSpecEntryKind.scSpecEntryUdtEnumV0():return this.generateEnum(e.udtEnumV0());case se.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0():return this.generateErrorEnum(e.udtErrorEnumV0());default:return null}}generateImports(){return Ta(va(this.spec.entries.flatMap(e=>{switch(e.switch()){case se.ScSpecEntryKind.scSpecEntryUdtStructV0():return e.udtStructV0().fields().map(e=>e.type());case se.ScSpecEntryKind.scSpecEntryUdtUnionV0():return e.udtUnionV0().cases().flatMap(e=>e.switch()===se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0()?e.tupleCase().type():[]);case se.ScSpecEntryKind.scSpecEntryUdtEnumV0():case se.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0():default:return[]}})),{includeTypeFileImports:!1})}generateStruct(e){const t=wa(e.name().toString());return`${Ea(e.doc().toString()||`Struct: ${t}`,0)}export interface ${t} {\n${e.fields().map(e=>{const t=wa(e.name().toString()),n=Sa(e.type());return`${Ea(e.doc().toString(),2)} ${t}: ${n};`}).join("\n")}\n}`}generateUnion(e){const t=wa(e.name().toString());return`${Ea(e.doc().toString()||`Union: ${t}`,0)} export type ${t} =\n${e.cases().map(e=>this.generateUnionCase(e)).map(e=>e.types.length>0?`${Ea(e.doc,2)} { tag: "${Aa(e.name)}"; values: readonly [${e.types.join(", ")}] }`:`${Ea(e.doc,2)} { tag: "${Aa(e.name)}"; values: void }`).join(" |\n")};`}generateEnum(e){const t=wa(e.name().toString());return`${Ea(e.doc().toString()||`Enum: ${t}`,0)}export enum ${t} {\n${e.cases().map(e=>{const t=wa(e.name().toString()),n=e.value();return`${Ea(e.doc().toString()||`Enum Case: ${t}`,2)} ${t} = ${n}`}).join(",\n")}\n}`}generateErrorEnum(e){const t=wa(e.name().toString());return`${Ea(e.doc().toString()||`Error Enum: ${t}`,0)}export const ${t} = {\n${e.cases().map(e=>this.generateEnumCase(e)).map(e=>`${Ea(e.doc,2)} ${e.value} : { message: "${Aa(e.name)}" }`).join(",\n")}\n}`}generateUnionCase(e){switch(e.switch()){case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0():{const t=e.voidCase();return{doc:t.doc().toString(),name:t.name().toString(),types:[]}}case se.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0():{const t=e.tupleCase();return{doc:t.doc().toString(),name:t.name().toString(),types:t.type().map(e=>Sa(e))}}default:throw new Error(`Unknown union case kind: ${e.switch()}`)}}generateEnumCase(e){return{doc:e.doc().toString(),name:e.name().toString(),value:e.value()}}generateTupleStruct(e){const t=wa(e.name().toString());return`${Ea(e.doc().toString()||`Tuple Struct: ${t}`,0)}export type ${t} = readonly [${e.fields().map(e=>Sa(e.type())).join(", ")}];`}}class Ra{spec;constructor(e){this.spec=e}generate(){let e="";try{const t=this.spec.getFunc("__constructor");e=this.generateDeployMethod(t)}catch{e=this.generateDeployMethod(void 0)}const t=this.spec.funcs().filter(e=>"__constructor"!==e.name().toString()).map(e=>this.generateInterfaceMethod(e)).join("\n"),n=this.generateImports(),r=this.spec.entries.map(e=>`"${e.toXDR("base64")}"`),o=this.spec.funcs().filter(e=>"__constructor"!==e.name().toString()).map(e=>this.generateFromJSONMethod(e)).join(",");return`${n}\n\nexport interface Client {\n${t}\n}\n\nexport class Client extends ContractClient {\n constructor(public readonly options: ContractClientOptions) {\n super(\n new Spec([${r.join(", ")}]),\n options\n );\n }\n\n ${e}\n public readonly fromJSON = {\n ${o}\n };\n}`}generateImports(){return Ta(va(this.spec.funcs().flatMap(e=>{const t=e.inputs(),n=e.outputs();return t.map(e=>e.type()).concat(n)})),{includeTypeFileImports:!0,additionalStellarContractImports:["Spec","AssembledTransaction","Client as ContractClient","ClientOptions as ContractClientOptions","MethodOptions"]})}generateInterfaceMethod(e){const t=wa(e.name().toString()),n=e.inputs().map(e=>({name:wa(e.name().toString()),type:Sa(e.type(),!0)})),r=e.outputs().length>0?Sa(e.outputs()[0]):"void";return`${Ea(e.doc().toString(),2)} ${t}(${this.formatMethodParameters(n)}): Promise<AssembledTransaction<${r}>>;`}generateFromJSONMethod(e){return` ${wa(e.name().toString())} : this.txFromJSON<${e.outputs().length>0?Sa(e.outputs()[0]):"void"}>`}generateDeployMethod(e){if(!e){return` static deploy<T = Client>(${this.formatConstructorParameters([])}): Promise<AssembledTransaction<T>> {\n return ContractClient.deploy(null, options);\n }`}const t=e.inputs().map(e=>({name:wa(e.name().toString()),type:Sa(e.type(),!0)}));return` static deploy<T = Client>(${this.formatConstructorParameters(t)}): Promise<AssembledTransaction<T>> {\n return ContractClient.deploy(${t.length>0?`{ ${t.map(e=>e.name).join(", ")} }, `:""}options);\n }`}formatMethodParameters(e){const t=[];if(e.length>0){const n=`{ ${e.map(e=>`${e.name}: ${e.type}`).join("; ")} }`;t.push(`{ ${e.map(e=>e.name).join(", ")} }: ${n}`)}return t.push("options?: MethodOptions"),t.join(", ")}formatConstructorParameters(e){const t=[];if(e.length>0){const n=`{ ${e.map(e=>`${e.name}: ${e.type}`).join("; ")} }`;t.push(`{ ${e.map(e=>e.name).join(", ")} }: ${n}`)}return t.push('options: MethodOptions & Omit<ContractClientOptions, \'contractId\'> & { wasmHash: Buffer | string; salt?: Buffer | Uint8Array; format?: "hex" | "base64"; address?: string; }'),t.join(", ")}}class _a extends Error{constructor(e,t){super(e),this.cause=t,this.name="WasmFetchError"}cause}async function Pa(e,t){try{const n=se.LedgerKey.contractCode(new se.LedgerKeyContractCode({hash:se.Hash.fromXDR(t,"raw")})),r=await e.getLedgerEntries(n);if(!r.entries||0===r.entries.length)throw new _a("WASM not found for the given hash");const o=r.entries[0];if(o.key.switch()!==se.LedgerEntryType.contractCode())throw new _a("Invalid ledger entry type returned");const s=o.val.contractCode();return fe.Buffer.from(s.code())}catch(e){if(e instanceof _a)throw e;throw new _a("Failed to fetch WASM from hash",e)}}async function Oa(e,t){try{const n=new go(t.toString()),r=await e.getLedgerEntries(n.getFootprint());if(!r.entries||0===r.entries.length)throw new _a("Contract instance not found");const o=r.entries[0];if(o.key.switch()!==se.LedgerEntryType.contractData())throw new _a("Invalid ledger entry type returned");const s=o.val.contractData().val().instance();if(function(e){return e.executable().switch()===se.ContractExecutableType.contractExecutableStellarAsset()}(s))return{type:"stellar-asset-contract"};const i=s.executable().wasmHash();return{type:"wasm",wasmBytes:await Pa(e,i)}}catch(e){if(e instanceof _a)throw e;throw new _a("Failed to fetch WASM from contract",e)}}class Ua{spec;constructor(e){this.spec=e}static fromSpec(e){return new Ua(e)}static fromWasm(e){const t=new ya(pa(e));return new Ua(t)}static async fromWasmHash(e,t){const n=await async function(e,t){try{const n=fe.Buffer.from(e,"hex");if(32!==n.length)throw new _a(`Invalid WASM hash length: expected 32 bytes, got ${n.length}`);return{type:"wasm",wasmBytes:await Pa(t,n)}}catch(t){throw new _a(`Failed to fetch WASM from hash ${e}`,t)}}(e,t);if("wasm"!==n.type)throw new Error("Fetched contract is not of type 'wasm'");return Ua.fromWasm(n.wasmBytes)}static async fromContractId(e,t){const n=await async function(e,t){try{if(!wn.isValidContract(e))throw new _a(`Invalid contract ID: ${e}`);const n=Xr.fromString(e);return await Oa(t,n)}catch(t){throw new _a(`Failed to fetch WASM from contract ${e}`,t)}}(e,t);if("wasm"===n.type)return Ua.fromWasm(n.wasmBytes);const r=new ya("AAAAAAAAAYpSZXR1cm5zIHRoZSBhbGxvd2FuY2UgZm9yIGBzcGVuZGVyYCB0byB0cmFuc2ZlciBmcm9tIGBmcm9tYC4KClRoZSBhbW91bnQgcmV0dXJuZWQgaXMgdGhlIGFtb3VudCB0aGF0IHNwZW5kZXIgaXMgYWxsb3dlZCB0byB0cmFuc2ZlcgpvdXQgb2YgZnJvbSdzIGJhbGFuY2UuIFdoZW4gdGhlIHNwZW5kZXIgdHJhbnNmZXJzIGFtb3VudHMsIHRoZSBhbGxvd2FuY2UKd2lsbCBiZSByZWR1Y2VkIGJ5IHRoZSBhbW91bnQgdHJhbnNmZXJyZWQuCgojIEFyZ3VtZW50cwoKKiBgZnJvbWAgLSBUaGUgYWRkcmVzcyBob2xkaW5nIHRoZSBiYWxhbmNlIG9mIHRva2VucyB0byBiZSBkcmF3biBmcm9tLgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIHNwZW5kaW5nIHRoZSB0b2tlbnMgaGVsZCBieSBgZnJvbWAuAAAAAAAJYWxsb3dhbmNlAAAAAAAAAgAAAAAAAAAEZnJvbQAAABMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAEAAAALAAAAAAAAAIlSZXR1cm5zIHRydWUgaWYgYGlkYCBpcyBhdXRob3JpemVkIHRvIHVzZSBpdHMgYmFsYW5jZS4KCiMgQXJndW1lbnRzCgoqIGBpZGAgLSBUaGUgYWRkcmVzcyBmb3Igd2hpY2ggdG9rZW4gYXV0aG9yaXphdGlvbiBpcyBiZWluZyBjaGVja2VkLgAAAAAAAAphdXRob3JpemVkAAAAAAABAAAAAAAAAAJpZAAAAAAAEwAAAAEAAAABAAAAAAAAA59TZXQgdGhlIGFsbG93YW5jZSBieSBgYW1vdW50YCBmb3IgYHNwZW5kZXJgIHRvIHRyYW5zZmVyL2J1cm4gZnJvbQpgZnJvbWAuCgpUaGUgYW1vdW50IHNldCBpcyB0aGUgYW1vdW50IHRoYXQgc3BlbmRlciBpcyBhcHByb3ZlZCB0byB0cmFuc2ZlciBvdXQgb2YKZnJvbSdzIGJhbGFuY2UuIFRoZSBzcGVuZGVyIHdpbGwgYmUgYWxsb3dlZCB0byB0cmFuc2ZlciBhbW91bnRzLCBhbmQKd2hlbiBhbiBhbW91bnQgaXMgdHJhbnNmZXJyZWQgdGhlIGFsbG93YW5jZSB3aWxsIGJlIHJlZHVjZWQgYnkgdGhlCmFtb3VudCB0cmFuc2ZlcnJlZC4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHRvIGJlIGRyYXduIGZyb20uCiogYHNwZW5kZXJgIC0gVGhlIGFkZHJlc3MgYmVpbmcgYXV0aG9yaXplZCB0byBzcGVuZCB0aGUgdG9rZW5zIGhlbGQgYnkKYGZyb21gLgoqIGBhbW91bnRgIC0gVGhlIHRva2VucyB0byBiZSBtYWRlIGF2YWlsYWJsZSB0byBgc3BlbmRlcmAuCiogYGV4cGlyYXRpb25fbGVkZ2VyYCAtIFRoZSBsZWRnZXIgbnVtYmVyIHdoZXJlIHRoaXMgYWxsb3dhbmNlIGV4cGlyZXMuIENhbm5vdApiZSBsZXNzIHRoYW4gdGhlIGN1cnJlbnQgbGVkZ2VyIG51bWJlciB1bmxlc3MgdGhlIGFtb3VudCBpcyBiZWluZyBzZXQgdG8gMC4KQW4gZXhwaXJlZCBlbnRyeSAod2hlcmUgZXhwaXJhdGlvbl9sZWRnZXIgPCB0aGUgY3VycmVudCBsZWRnZXIgbnVtYmVyKQpzaG91bGQgYmUgdHJlYXRlZCBhcyBhIDAgYW1vdW50IGFsbG93YW5jZS4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJhcHByb3ZlIiwgZnJvbTogQWRkcmVzcywKc3BlbmRlcjogQWRkcmVzc10sIGRhdGEgPSBbYW1vdW50OiBpMTI4LCBleHBpcmF0aW9uX2xlZGdlcjogdTMyXWAAAAAAB2FwcHJvdmUAAAAABAAAAAAAAAAEZnJvbQAAABMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAABFleHBpcmF0aW9uX2xlZGdlcgAAAAAAAAQAAAAAAAAAAAAAAJhSZXR1cm5zIHRoZSBiYWxhbmNlIG9mIGBpZGAuCgojIEFyZ3VtZW50cwoKKiBgaWRgIC0gVGhlIGFkZHJlc3MgZm9yIHdoaWNoIGEgYmFsYW5jZSBpcyBiZWluZyBxdWVyaWVkLiBJZiB0aGUKYWRkcmVzcyBoYXMgbm8gZXhpc3RpbmcgYmFsYW5jZSwgcmV0dXJucyAwLgAAAAdiYWxhbmNlAAAAAAEAAAAAAAAAAmlkAAAAAAATAAAAAQAAAAsAAAAAAAABYkJ1cm4gYGFtb3VudGAgZnJvbSBgZnJvbWAuCgpSZWR1Y2VzIGZyb20ncyBiYWxhbmNlIGJ5IHRoZSBhbW91bnQsIHdpdGhvdXQgdHJhbnNmZXJyaW5nIHRoZSBiYWxhbmNlCnRvIGFub3RoZXIgaG9sZGVyJ3MgYmFsYW5jZS4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKYnVybmVkIGZyb20uCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSBidXJuZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsiYnVybiIsIGZyb206IEFkZHJlc3NdLCBkYXRhID0gYW1vdW50OgppMTI4YAAAAAAABGJ1cm4AAAACAAAAAAAAAARmcm9tAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAALaQnVybiBgYW1vdW50YCBmcm9tIGBmcm9tYCwgY29uc3VtaW5nIHRoZSBhbGxvd2FuY2Ugb2YgYHNwZW5kZXJgLgoKUmVkdWNlcyBmcm9tJ3MgYmFsYW5jZSBieSB0aGUgYW1vdW50LCB3aXRob3V0IHRyYW5zZmVycmluZyB0aGUgYmFsYW5jZQp0byBhbm90aGVyIGhvbGRlcidzIGJhbGFuY2UuCgpUaGUgc3BlbmRlciB3aWxsIGJlIGFsbG93ZWQgdG8gYnVybiB0aGUgYW1vdW50IGZyb20gZnJvbSdzIGJhbGFuY2UsIGlmCnRoZSBhbW91bnQgaXMgbGVzcyB0aGFuIG9yIGVxdWFsIHRvIHRoZSBhbGxvd2FuY2UgdGhhdCB0aGUgc3BlbmRlciBoYXMKb24gdGhlIGZyb20ncyBiYWxhbmNlLiBUaGUgc3BlbmRlcidzIGFsbG93YW5jZSBvbiBmcm9tJ3MgYmFsYW5jZSB3aWxsIGJlCnJlZHVjZWQgYnkgdGhlIGFtb3VudC4KCiMgQXJndW1lbnRzCgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIGF1dGhvcml6aW5nIHRoZSBidXJuLCBhbmQgaGF2aW5nIGl0cyBhbGxvd2FuY2UKY29uc3VtZWQgZHVyaW5nIHRoZSBidXJuLgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKYnVybmVkIGZyb20uCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSBidXJuZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsiYnVybiIsIGZyb206IEFkZHJlc3NdLCBkYXRhID0gYW1vdW50OgppMTI4YAAAAAAACWJ1cm5fZnJvbQAAAAAAAAMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAEZnJvbQAAABMAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAABUUNsYXdiYWNrIGBhbW91bnRgIGZyb20gYGZyb21gIGFjY291bnQuIGBhbW91bnRgIGlzIGJ1cm5lZCBpbiB0aGUKY2xhd2JhY2sgcHJvY2Vzcy4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2UgZnJvbSB3aGljaCB0aGUgY2xhd2JhY2sgd2lsbAp0YWtlIHRva2Vucy4KKiBgYW1vdW50YCAtIFRoZSBhbW91bnQgb2YgdG9rZW5zIHRvIGJlIGNsYXdlZCBiYWNrLgoKIyBFdmVudHMKCkVtaXRzIGFuIGV2ZW50IHdpdGggdG9waWNzIGBbImNsYXdiYWNrIiwgYWRtaW46IEFkZHJlc3MsIHRvOiBBZGRyZXNzXSwKZGF0YSA9IGFtb3VudDogaTEyOGAAAAAAAAAIY2xhd2JhY2sAAAACAAAAAAAAAARmcm9tAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAACAUmV0dXJucyB0aGUgbnVtYmVyIG9mIGRlY2ltYWxzIHVzZWQgdG8gcmVwcmVzZW50IGFtb3VudHMgb2YgdGhpcyB0b2tlbi4KCiMgUGFuaWNzCgpJZiB0aGUgY29udHJhY3QgaGFzIG5vdCB5ZXQgYmVlbiBpbml0aWFsaXplZC4AAAAIZGVjaW1hbHMAAAAAAAAAAQAAAAQAAAAAAAAA801pbnRzIGBhbW91bnRgIHRvIGB0b2AuCgojIEFyZ3VtZW50cwoKKiBgdG9gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCByZWNlaXZlIHRoZSBtaW50ZWQgdG9rZW5zLgoqIGBhbW91bnRgIC0gVGhlIGFtb3VudCBvZiB0b2tlbnMgdG8gYmUgbWludGVkLgoKIyBFdmVudHMKCkVtaXRzIGFuIGV2ZW50IHdpdGggdG9waWNzIGBbIm1pbnQiLCBhZG1pbjogQWRkcmVzcywgdG86IEFkZHJlc3NdLCBkYXRhCj0gYW1vdW50OiBpMTI4YAAAAAAEbWludAAAAAIAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAFlSZXR1cm5zIHRoZSBuYW1lIGZvciB0aGlzIHRva2VuLgoKIyBQYW5pY3MKCklmIHRoZSBjb250cmFjdCBoYXMgbm90IHlldCBiZWVuIGluaXRpYWxpemVkLgAAAAAAAARuYW1lAAAAAAAAAAEAAAAQAAAAAAAAAQxTZXRzIHRoZSBhZG1pbmlzdHJhdG9yIHRvIHRoZSBzcGVjaWZpZWQgYWRkcmVzcyBgbmV3X2FkbWluYC4KCiMgQXJndW1lbnRzCgoqIGBuZXdfYWRtaW5gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCBoZW5jZWZvcnRoIGJlIHRoZSBhZG1pbmlzdHJhdG9yCm9mIHRoaXMgdG9rZW4gY29udHJhY3QuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsic2V0X2FkbWluIiwgYWRtaW46IEFkZHJlc3NdLCBkYXRhID0KW25ld19hZG1pbjogQWRkcmVzc11gAAAACXNldF9hZG1pbgAAAAAAAAEAAAAAAAAACW5ld19hZG1pbgAAAAAAABMAAAAAAAAAAAAAAEZSZXR1cm5zIHRoZSBhZG1pbiBvZiB0aGUgY29udHJhY3QuCgojIFBhbmljcwoKSWYgdGhlIGFkbWluIGlzIG5vdCBzZXQuAAAAAAAFYWRtaW4AAAAAAAAAAAAAAQAAABMAAAAAAAABUFNldHMgd2hldGhlciB0aGUgYWNjb3VudCBpcyBhdXRob3JpemVkIHRvIHVzZSBpdHMgYmFsYW5jZS4gSWYKYGF1dGhvcml6ZWRgIGlzIHRydWUsIGBpZGAgc2hvdWxkIGJlIGFibGUgdG8gdXNlIGl0cyBiYWxhbmNlLgoKIyBBcmd1bWVudHMKCiogYGlkYCAtIFRoZSBhZGRyZXNzIGJlaW5nIChkZS0pYXV0aG9yaXplZC4KKiBgYXV0aG9yaXplYCAtIFdoZXRoZXIgb3Igbm90IGBpZGAgY2FuIHVzZSBpdHMgYmFsYW5jZS4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJzZXRfYXV0aG9yaXplZCIsIGlkOiBBZGRyZXNzXSwgZGF0YSA9ClthdXRob3JpemU6IGJvb2xdYAAAAA5zZXRfYXV0aG9yaXplZAAAAAAAAgAAAAAAAAACaWQAAAAAABMAAAAAAAAACWF1dGhvcml6ZQAAAAAAAAEAAAAAAAAAAAAAAFtSZXR1cm5zIHRoZSBzeW1ib2wgZm9yIHRoaXMgdG9rZW4uCgojIFBhbmljcwoKSWYgdGhlIGNvbnRyYWN0IGhhcyBub3QgeWV0IGJlZW4gaW5pdGlhbGl6ZWQuAAAAAAZzeW1ib2wAAAAAAAAAAAABAAAAEAAAAAAAAAFiVHJhbnNmZXIgYGFtb3VudGAgZnJvbSBgZnJvbWAgdG8gYHRvYC4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKd2l0aGRyYXduIGZyb20uCiogYHRvYCAtIFRoZSBhZGRyZXNzIHdoaWNoIHdpbGwgcmVjZWl2ZSB0aGUgdHJhbnNmZXJyZWQgdG9rZW5zLgoqIGBhbW91bnRgIC0gVGhlIGFtb3VudCBvZiB0b2tlbnMgdG8gYmUgdHJhbnNmZXJyZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsidHJhbnNmZXIiLCBmcm9tOiBBZGRyZXNzLCB0bzogQWRkcmVzc10sCmRhdGEgPSBhbW91bnQ6IGkxMjhgAAAAAAAIdHJhbnNmZXIAAAADAAAAAAAAAARmcm9tAAAAEwAAAAAAAAACdG8AAAAAABMAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAADMVRyYW5zZmVyIGBhbW91bnRgIGZyb20gYGZyb21gIHRvIGB0b2AsIGNvbnN1bWluZyB0aGUgYWxsb3dhbmNlIHRoYXQKYHNwZW5kZXJgIGhhcyBvbiBgZnJvbWAncyBiYWxhbmNlLiBBdXRob3JpemVkIGJ5IHNwZW5kZXIKKGBzcGVuZGVyLnJlcXVpcmVfYXV0aCgpYCkuCgpUaGUgc3BlbmRlciB3aWxsIGJlIGFsbG93ZWQgdG8gdHJhbnNmZXIgdGhlIGFtb3VudCBmcm9tIGZyb20ncyBiYWxhbmNlCmlmIHRoZSBhbW91bnQgaXMgbGVzcyB0aGFuIG9yIGVxdWFsIHRvIHRoZSBhbGxvd2FuY2UgdGhhdCB0aGUgc3BlbmRlcgpoYXMgb24gdGhlIGZyb20ncyBiYWxhbmNlLiBUaGUgc3BlbmRlcidzIGFsbG93YW5jZSBvbiBmcm9tJ3MgYmFsYW5jZQp3aWxsIGJlIHJlZHVjZWQgYnkgdGhlIGFtb3VudC4KCiMgQXJndW1lbnRzCgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIGF1dGhvcml6aW5nIHRoZSB0cmFuc2ZlciwgYW5kIGhhdmluZyBpdHMKYWxsb3dhbmNlIGNvbnN1bWVkIGR1cmluZyB0aGUgdHJhbnNmZXIuCiogYGZyb21gIC0gVGhlIGFkZHJlc3MgaG9sZGluZyB0aGUgYmFsYW5jZSBvZiB0b2tlbnMgd2hpY2ggd2lsbCBiZQp3aXRoZHJhd24gZnJvbS4KKiBgdG9gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCByZWNlaXZlIHRoZSB0cmFuc2ZlcnJlZCB0b2tlbnMuCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSB0cmFuc2ZlcnJlZC4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJ0cmFuc2ZlciIsIGZyb206IEFkZHJlc3MsIHRvOiBBZGRyZXNzXSwKZGF0YSA9IGFtb3VudDogaTEyOGAAAAAAAAANdHJhbnNmZXJfZnJvbQAAAAAAAAQAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAEZnJvbQAAABMAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAABQAAAAAAAAAAAAAAB0FwcHJvdmUAAAAAAQAAAAdhcHByb3ZlAAAAAAQAAAAAAAAABGZyb20AAAATAAAAAQAAAAAAAAAHc3BlbmRlcgAAAAATAAAAAQAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAAARZXhwaXJhdGlvbl9sZWRnZXIAAAAAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAIVHJhbnNmZXIAAAABAAAACHRyYW5zZmVyAAAAAwAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAJ0bwAAAAAAEwAAAAEAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAAABQAAAAAAAAAAAAAADVRyYW5zZmVyTXV4ZWQAAAAAAAABAAAACHRyYW5zZmVyAAAABAAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAJ0bwAAAAAAEwAAAAEAAAAAAAAAC3RvX211eGVkX2lkAAAAAAQAAAAAAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAgAAAAUAAAAAAAAAAAAAAARCdXJuAAAAAQAAAARidXJuAAAAAgAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAARNaW50AAAAAQAAAARtaW50AAAAAgAAAAAAAAACdG8AAAAAABMAAAABAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAhDbGF3YmFjawAAAAEAAAAIY2xhd2JhY2sAAAACAAAAAAAAAARmcm9tAAAAEwAAAAEAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAAABQAAAAAAAAAAAAAACFNldEFkbWluAAAAAQAAAAlzZXRfYWRtaW4AAAAAAAABAAAAAAAAAAluZXdfYWRtaW4AAAAAAAATAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAANU2V0QXV0aG9yaXplZAAAAAAAAAEAAAAOc2V0X2F1dGhvcml6ZWQAAAAAAAIAAAAAAAAAAmlkAAAAAAATAAAAAQAAAAAAAAAJYXV0aG9yaXplAAAAAAAAAQAAAAAAAAAA");return Ua.fromSpec(r)}generate(e){this.validateOptions(e);const t=new xa(this.spec),n=new Ra(this.spec),r=t.generate(),o=n.generate();let s='export { Client } from "./client.js";';""!==r.trim()&&(s=s.concat('\nexport * from "./types.js";'));const i=new Ba,{packageJson:a,tsConfig:c,readme:u,gitignore:l}=i.generate(e);return{index:s,types:r,client:o,packageJson:a,tsConfig:c,readme:u,gitignore:l}}validateOptions(e){if(!e.contractName||""===e.contractName.trim())throw new Error("contractName is required and cannot be empty")}}e.Account=uo,e.AccountRequiresMemoError=B,e.Address=Xr,e.Asset=In,e.AssetType=En,e.AuthClawbackEnabledFlag=8,e.AuthImmutableFlag=4,e.AuthRequiredFlag=1,e.AuthRevocableFlag=2,e.BASE_FEE=xo,e.BadRequestError=I,e.BadResponseError=C,e.BindingGenerator=Ua,e.Claimant=Rn,e.Config=_,e.Contract=go,e.Federation=Yo,e.FeeBumpTransaction=co,e.Friendbot=ps,e.Horizon=xi,e.Hyper=oe.Hyper,e.Int128=Ao,e.Int256=So,e.Keypair=Tn,e.LiquidityPoolAsset=xn,e.LiquidityPoolFeeV18=30,e.LiquidityPoolId=_n,e.Memo=io,e.MemoHash=oo,e.MemoID=no,e.MemoNone=to,e.MemoReturn=so,e.MemoText=ro,e.MuxedAccount=ho,e.NetworkError=E,e.Networks=Oo,e.NotFoundError=k,e.Operation=Qr,e.ScInt=vo,e.SignerKey=mo,e.Soroban=Uo,e.SorobanDataBuilder=fo,e.StellarBase=Wo,e.StellarToml=ee,e.StrKey=wn,e.TimeoutInfinite=0,e.Transaction=ao,e.TransactionBase=Bn,e.TransactionBuilder=Ro,e.Uint128=yo,e.Uint256=wo,e.UnsignedHyper=oe.UnsignedHyper,e.Utils=P,e.WebAuth=ds,e.XdrLargeInt=bo,e.authorizeEntry=Fo,e.authorizeInvocation=Do,e.buildAuthorizationEntryPreimage=Mo,e.buildInvocationTree=$o,e.buildWithDelegatesEntry=qo,e.cereal=ie,e.contract=Ca,e.decodeAddressToMuxedAccount=Pn,e.encodeMuxedAccount=Un,e.encodeMuxedAccountToAddress=On,e.extractBaseAddress=Ln,e.getLiquidityPoolId=Cn,e.hash=nt,e.httpClient=T,e.humanizeEvents=No,e.nativeToScVal=Eo,e.rpc=Gi,e.scValToBigInt=To,e.scValToNative=ko,e.scvSortedMap=Io,e.sign=cn,e.verify=un,e.walkInvocationTree=Xo,e.xdr=se});
|
|
199
|
+
*/let zo=/^[a-zA-Z0-9-_]+[ \t]*$/;function jo(e,t,n="="){let r=t-1,o=[],s=e.indexOf(n,t);if(s<0)throw new Oo("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let i=e[t=++r];if(" "!==i&&"\t"!==i)if('"'===i||"'"===i){if(i===e[t+1]&&i===e[t+2])throw new Oo("multiline strings are not allowed in keys",{toml:e,ptr:t});let a=Fo(e,t);if(a<0)throw new Oo("unfinished string encountered",{toml:e,ptr:t});r=e.indexOf(".",a);let c=e.slice(a,r<0||r>s?s:r),u=Lo(c);if(u>-1)throw new Oo("newlines are not allowed in keys",{toml:e,ptr:t+r+u});if(c.trimStart())throw new Oo("found extra tokens after the string part",{toml:e,ptr:a});if(s<a&&(s=e.indexOf(n,a),s<0))throw new Oo("incomplete key-value: cannot find end of key",{toml:e,ptr:t});o.push(Ko(e,t,a))}else{r=e.indexOf(".",t);let n=e.slice(t,r<0||r>s?s:r);if(!zo.test(n))throw new Oo("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});o.push(n.trimEnd())}}while(r+1&&r<s);return[o,Vo(e,s+1,!0,!0)]}function Yo(e,t,n,r){let o,s,i=t,a=n,c=!1;for(let t=0;t<e.length;t++){if(t){if(i=c?i[o]:i[o]={},a=(s=a[o]).c,0===r&&(1===s.t||2===s.t))return null;if(2===s.t){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(c=Object.hasOwn(i,o))&&0===a[o]?.t&&a[o]?.d)return null;c||("__proto__"===o&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&2===r?3:r,d:!1,i:0,c:{}})}if(s=a[o],s.t!==r&&(1!==r||3!==s.t))return null;if(2===r&&(s.d||(s.d=!0,i[o]=[]),i[o].push(i={}),s.c[s.i++]=s={t:1,d:!1,i:0,c:{}}),s.d)return null;if(s.d=!0,1===r)i=c?i[o]:i[o]={};else if(0===r&&c)return null;return[o,i,s.c]}const Jo=102400;class Qo{static async resolve(e,t={}){const{CancelToken:n}=T,r=void 0===t.allowHttp?_o.isAllowHttp():t.allowHttp,o=void 0===t.timeout?_o.getTimeout():t.timeout,s=r?"http":"https";return T.get(`${s}://${e}/.well-known/stellar.toml`,{maxRedirects:t.allowedRedirects??0,maxContentLength:Jo,cancelToken:o?new n(e=>setTimeout(()=>e(`timeout of ${o}ms exceeded`),o)):void 0,timeout:o}).then(e=>{try{const t=function(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},o={},s=r,i=o;for(let a=Vo(e,0);a<e.length;){if("["===e[a]){let t="["===e[++a],n=jo(e,a+=+t,"]");if(t){if("]"!==e[n[1]-1])throw new Oo("expected end of table declaration",{toml:e,ptr:n[1]-1});n[1]++}let c=Yo(n[0],r,o,t?2:1);if(!c)throw new Oo("trying to redefine an already defined table or value",{toml:e,ptr:a});i=c[2],s=c[1],a=n[1]}else{let r=jo(e,a),o=Yo(r[0],s,i,0);if(!o)throw new Oo("trying to redefine an already defined table or value",{toml:e,ptr:a});let c=Zo(e,r[1],void 0,t,n);o[1][o[0]]=c[0],a=c[1]}if(a=Vo(e,a,!0),e[a]&&"\n"!==e[a]&&"\r"!==e[a])throw new Oo("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:a});a=Vo(e,a)}return r}(e.data);return Promise.resolve(t)}catch(e){return Promise.reject(new Error(`stellar.toml is invalid - Parsing error on line ${e.line}, column ${e.column}: ${e.message}`))}}).catch(e=>{throw e.message.match(/^maxContentLength size/)?new Error("stellar.toml file exceeds allowed size of 102400"):e})}}var es=Object.freeze({__proto__:null,Resolver:Qo,STELLAR_TOML_MAX_SIZE:Jo});function ts(e,t){const n=e?.response??e;if(n&&"number"==typeof n.status){const r=t({data:n.data,status:n.status,statusText:n.statusText});return e instanceof Error&&(r.cause=e),r}return e instanceof Error?e:new Error(String(e))}function ns(e){if(!/^(?:[A-Za-z](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)*[A-Za-z](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?::\d+)?$/.test(e))throw new Error("The provided domain is invalid. Ensure that the domain adheres to RFC 1035")}const rs=102400;class os{serverURL;domain;timeout;static async resolve(e,t={}){if(e.indexOf("*")<0)return $t.isValidEd25519PublicKey(e)?Promise.resolve({account_id:e}):Promise.reject(new Error("Invalid Account ID"));const n=e.split("*"),[,r]=n;if(2!==n.length||!r)return Promise.reject(new Error("Invalid Stellar address"));return(await os.createForDomain(r,t)).resolveAddress(e)}static async createForDomain(e,t={}){ns(e);const n=await Qo.resolve(e,t);return n.FEDERATION_SERVER?new os(n.FEDERATION_SERVER,e,t):Promise.reject(new Error("stellar.toml does not contain FEDERATION_SERVER field"))}constructor(e,t,n={}){this.serverURL=new URL(e),this.domain=t,ns(t);const r=void 0===n.allowHttp?_o.isAllowHttp():n.allowHttp;if(this.timeout=void 0===n.timeout?_o.getTimeout():n.timeout,"https:"!==this.serverURL.protocol&&!r)throw new Error("Cannot connect to insecure federation server")}async resolveAddress(e){let t=e;if(e.indexOf("*")<0){if(!this.domain)return Promise.reject(new Error("Unknown domain. Make sure `address` contains a domain (ex. `bob*stellar.org`) or pass `domain` parameter when instantiating the server object."));t=`${e}*${this.domain}`}const n=new URL(this.serverURL);return n.search="",n.searchParams.set("type","name"),n.searchParams.set("q",t),this._sendRequest(n)}async resolveAccountId(e){const t=new URL(this.serverURL);return t.search="",t.searchParams.set("type","id"),t.searchParams.set("q",e),this._sendRequest(t)}async resolveTransactionId(e){const t=new URL(this.serverURL);return t.search="",t.searchParams.set("type","txid"),t.searchParams.set("q",e),this._sendRequest(t)}async _sendRequest(e){const t=this.timeout;return T.get(e.toString(),{maxContentLength:rs,timeout:t}).then(e=>{if(void 0!==e.data.memo&&"string"!=typeof e.data.memo)throw new Error("memo value should be of type string");return e.data}).catch(e=>{if(e instanceof Error&&e.message.match(/^maxContentLength size/))throw new Error("federation response exceeds allowed size of 102400");return Promise.reject(ts(e,e=>new C(`Server query failed. Server responded: ${e.status} ${e.statusText}`,e)))})}}var ss=Object.freeze({__proto__:null,FEDERATION_RESPONSE_MAX_SIZE:rs,Server:os});class is extends Error{}function as(e,t){const n=e.hash(),r=[...e.signatures],o=new Set;for(const e of t){if(0===r.length)break;let t;try{t=jt.fromPublicKey(e)}catch(e){throw new is(`Signer is not a valid address: ${e.message}`)}for(let s=0;s<r.length;s++){const i=r[s];if(i.hint().equals(t.signatureHint())&&t.verify(n,i.signature())){o.add(e),r.splice(s,1);break}}}return Array.from(o)}function cs(e,t){return 0!==as(e,[t]).length}const us=Object.prototype.toString;function ls(e){return function(e,t,n){return!!e&&(e.constructor===t||us.call(e)===n)}(e,Uint8Array,"[object Uint8Array]")}new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder;function ds(e,{urlSafe:t=!1}={}){!function(e){if(!ls(e))throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}(e);let n="";for(let t=0;t<e.length;t+=65535){const r=e.subarray(t,t+65535);n+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return t?function(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}(n):n}function ps(e,t,n,r,o){if(t.startsWith("M"))throw Error("Invalid serverAccountID: multiplexed accounts are not supported.");let s;try{s=new Lr(e,n)}catch{try{s=new Nr(e,n)}catch{throw new is("Invalid challenge: unable to deserialize challengeTx transaction string")}throw new is("Invalid challenge: expected a Transaction but received a FeeBumpTransaction")}if(0!==Number.parseInt(s.sequence,10))throw new is("The transaction sequence number should be zero");if(s.source!==t)throw new is("The transaction source account is not equal to the server's account");if(s.operations.length<1)throw new is("The transaction should contain at least one operation");const[i,...a]=s.operations;if(!i.source)throw new is("The transaction's operation should contain a source account");const c=i.source;let u,l=null;if(s.memo.type!==xr){if(c.startsWith("M"))throw new is("The transaction has a memo but the client account ID is a muxed account");if(s.memo.type!==Rr)throw new is("The transaction's memo must be of type `id`");l=s.memo.value}if("manageData"!==i.type)throw new is("The transaction's operation type should be 'manageData'");if(s.timeBounds&&0===Number.parseInt(s.timeBounds?.maxTime,10))throw new is("The transaction requires non-infinite timebounds");if(!Po.validateTimebounds(s,300))throw new is("The transaction has expired");if(void 0===i.value)throw new is("The transaction's operation values should not be null");if(!i.value)throw new is("The transaction's operation value should not be null");if(48!==q.Buffer.from(i.value.toString(),"base64").length)throw new is("The transaction's operation value should be a 64 bytes base64 random string");if(!r)throw new is("Invalid homeDomains: a home domain must be provided for verification");if("string"==typeof r)`${r} auth`===i.name&&(u=r);else{if(!Array.isArray(r))throw new is(`Invalid homeDomains: homeDomains type is ${typeof r} but should be a string or an array`);u=r.find(e=>`${e} auth`===i.name)}if(!u)throw new is("Invalid homeDomains: the transaction's operation key name does not match the expected home domain");for(const e of a){if("manageData"!==e.type)throw new is("The transaction has operations that are not of type 'manageData'");if(e.source!==t&&"client_domain"!==e.name)throw new is("The transaction has operations that are unrecognized");if("web_auth_domain"===e.name){if(void 0===e.value)throw new is("'web_auth_domain' operation value should not be null");if(e.value.compare(q.Buffer.from(o)))throw new is(`'web_auth_domain' operation value does not match ${o}`)}}if(!cs(s,t))throw new is(`Transaction not signed by server: '${t}'`);return{tx:s,clientAccountID:c,matchedHomeDomain:u,memo:l}}function hs(e,t,n,r,o,s){const{tx:i}=ps(e,t,n,o,s);let a;try{a=jt.fromPublicKey(t)}catch(e){throw new Error(`Couldn't infer keypair from the provided 'serverAccountID': ${e.message}`)}const c=new Set;for(const e of r)e!==a.publicKey()&&"G"===e.charAt(0)&&c.add(e);if(0===c.size)throw new is("No verifiable client signers provided, at least one G... address must be provided");let u;for(const e of i.operations)if("manageData"===e.type&&"client_domain"===e.name){if(u)throw new is("Found more than one client_domain operation");u=e.source}const l=[a.publicKey(),...Array.from(c)];u&&l.push(u);const d=as(i,l);let p=!1,h=!1;for(const e of d)e===a.publicKey()&&(p=!0),e===u&&(h=!0);if(!p)throw new is(`Transaction not signed by server: '${a.publicKey()}'`);if(u&&!h)throw new is("Transaction not signed by the source account of the 'client_domain' ManageData operation");if(1===d.length)throw new is("None of the given signers match the transaction signatures");if(d.length!==i.signatures.length)throw new is("Transaction has unrecognized signatures");if(d.splice(d.indexOf(a.publicKey()),1),u&&d.splice(d.indexOf(u),1),0===d.length)throw new is("None of the given signers match the transaction signatures");return d}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));var fs,ms,gs,ys,ws,As=Object.freeze({__proto__:null,InvalidChallengeError:is,buildChallengeTx:function(e,t,n,r=300,o,s,i=null,a=null,c=null){if(t.startsWith("M")&&i)throw Error("memo cannot be used if clientAccountID is a muxed account");const u=new Vr(e.publicKey(),"-1"),l=Math.floor(Date.now()/1e3),d=ds(crypto.getRandomValues(new Uint8Array(48))),p=new ro(u,{fee:no,networkPassphrase:o,timebounds:{minTime:l,maxTime:l+r}}).addOperation(Cr.manageData({name:`${n} auth`,value:d,source:t})).addOperation(Cr.manageData({name:"web_auth_domain",value:s,source:u.accountId()}));if(a){if(!c)throw Error("clientSigningKey is required if clientDomain is provided");p.addOperation(Cr.manageData({name:"client_domain",value:a,source:c}))}i&&p.addMemo(Ur.id(i));const h=p.build();return h.sign(e),h.toEnvelope().toXDR("base64").toString()},gatherTxSigners:as,readChallengeTx:ps,verifyChallengeTxSigners:hs,verifyChallengeTxThreshold:function(e,t,n,r,o,s,i){const a=hs(e,t,n,o.map(e=>e.key),s,i);let c=0;for(const e of a){c+=o.find(t=>t.key===e)?.weight||0}if(c<r)throw new is(`signers with weight ${c} do not meet threshold ${r}"`);return a},verifyTxSignedBy:cs}),Ss=Object.freeze({__proto__:null});((ms=fs||(fs={})).LiquidityPoolType||(ms.LiquidityPoolType={})).constantProduct="constant_product",(gs=ms.OperationResponseType||(ms.OperationResponseType={})).createAccount="create_account",gs.payment="payment",gs.pathPayment="path_payment_strict_receive",gs.createPassiveOffer="create_passive_sell_offer",gs.manageOffer="manage_sell_offer",gs.setOptions="set_options",gs.changeTrust="change_trust",gs.allowTrust="allow_trust",gs.accountMerge="account_merge",gs.inflation="inflation",gs.manageData="manage_data",gs.bumpSequence="bump_sequence",gs.manageBuyOffer="manage_buy_offer",gs.pathPaymentStrictSend="path_payment_strict_send",gs.createClaimableBalance="create_claimable_balance",gs.claimClaimableBalance="claim_claimable_balance",gs.beginSponsoringFutureReserves="begin_sponsoring_future_reserves",gs.endSponsoringFutureReserves="end_sponsoring_future_reserves",gs.revokeSponsorship="revoke_sponsorship",gs.clawback="clawback",gs.clawbackClaimableBalance="clawback_claimable_balance",gs.setTrustLineFlags="set_trust_line_flags",gs.liquidityPoolDeposit="liquidity_pool_deposit",gs.liquidityPoolWithdraw="liquidity_pool_withdraw",gs.invokeHostFunction="invoke_host_function",gs.bumpFootprintExpiration="bump_footprint_expiration",gs.restoreFootprint="restore_footprint",(ys=ms.OperationResponseTypeI||(ms.OperationResponseTypeI={}))[ys.createAccount=0]="createAccount",ys[ys.payment=1]="payment",ys[ys.pathPayment=2]="pathPayment",ys[ys.createPassiveOffer=3]="createPassiveOffer",ys[ys.manageOffer=4]="manageOffer",ys[ys.setOptions=5]="setOptions",ys[ys.changeTrust=6]="changeTrust",ys[ys.allowTrust=7]="allowTrust",ys[ys.accountMerge=8]="accountMerge",ys[ys.inflation=9]="inflation",ys[ys.manageData=10]="manageData",ys[ys.bumpSequence=11]="bumpSequence",ys[ys.manageBuyOffer=12]="manageBuyOffer",ys[ys.pathPaymentStrictSend=13]="pathPaymentStrictSend",ys[ys.createClaimableBalance=14]="createClaimableBalance",ys[ys.claimClaimableBalance=15]="claimClaimableBalance",ys[ys.beginSponsoringFutureReserves=16]="beginSponsoringFutureReserves",ys[ys.endSponsoringFutureReserves=17]="endSponsoringFutureReserves",ys[ys.revokeSponsorship=18]="revokeSponsorship",ys[ys.clawback=19]="clawback",ys[ys.clawbackClaimableBalance=20]="clawbackClaimableBalance",ys[ys.setTrustLineFlags=21]="setTrustLineFlags",ys[ys.liquidityPoolDeposit=22]="liquidityPoolDeposit",ys[ys.liquidityPoolWithdraw=23]="liquidityPoolWithdraw",ys[ys.invokeHostFunction=24]="invokeHostFunction",ys[ys.bumpFootprintExpiration=25]="bumpFootprintExpiration",ys[ys.restoreFootprint=26]="restoreFootprint",(ws=ms.TransactionFailedResultCodes||(ms.TransactionFailedResultCodes={})).TX_FAILED="tx_failed",ws.TX_BAD_SEQ="tx_bad_seq",ws.TX_BAD_AUTH="tx_bad_auth",ws.TX_BAD_AUTH_EXTRA="tx_bad_auth_extra",ws.TX_FEE_BUMP_INNER_SUCCESS="tx_fee_bump_inner_success",ws.TX_FEE_BUMP_INNER_FAILED="tx_fee_bump_inner_failed",ws.TX_NOT_SUPPORTED="tx_not_supported",ws.TX_SUCCESS="tx_success",ws.TX_TOO_EARLY="tx_too_early",ws.TX_TOO_LATE="tx_too_late",ws.TX_MISSING_OPERATION="tx_missing_operation",ws.TX_INSUFFICIENT_BALANCE="tx_insufficient_balance",ws.TX_NO_SOURCE_ACCOUNT="tx_no_source_account",ws.TX_INSUFFICIENT_FEE="tx_insufficient_fee",ws.TX_INTERNAL_ERROR="tx_internal_error",ws.TX_BAD_SPONSORSHIP="tx_bad_sponsorship",ws.TX_BAD_MIN_SEQ_AGE_OR_GAP="tx_bad_min_seq_age_or_gap",ws.TX_MALFORMED="tx_malformed",ws.TX_SOROBAN_INVALID="tx_soroban_invalid",ws.TX_FROZEN_KEY_ACCESSED="tx_frozen_key_accessed";var bs,vs,Ts,Es=(e=>(e[e.account_created=0]="account_created",e[e.account_removed=1]="account_removed",e[e.account_credited=2]="account_credited",e[e.account_debited=3]="account_debited",e[e.account_thresholds_updated=4]="account_thresholds_updated",e[e.account_home_domain_updated=5]="account_home_domain_updated",e[e.account_flags_updated=6]="account_flags_updated",e[e.account_inflation_destination_updated=7]="account_inflation_destination_updated",e[e.signer_created=10]="signer_created",e[e.signer_removed=11]="signer_removed",e[e.signer_updated=12]="signer_updated",e[e.trustline_created=20]="trustline_created",e[e.trustline_removed=21]="trustline_removed",e[e.trustline_updated=22]="trustline_updated",e[e.trustline_authorized=23]="trustline_authorized",e[e.trustline_deauthorized=24]="trustline_deauthorized",e[e.trustline_authorized_to_maintain_liabilities=25]="trustline_authorized_to_maintain_liabilities",e[e.trustline_flags_updated=26]="trustline_flags_updated",e[e.offer_created=30]="offer_created",e[e.offer_removed=31]="offer_removed",e[e.offer_updated=32]="offer_updated",e[e.trade=33]="trade",e[e.data_created=40]="data_created",e[e.data_removed=41]="data_removed",e[e.data_updated=42]="data_updated",e[e.sequence_bumped=43]="sequence_bumped",e[e.claimable_balance_created=50]="claimable_balance_created",e[e.claimable_balance_claimant_created=51]="claimable_balance_claimant_created",e[e.claimable_balance_claimed=52]="claimable_balance_claimed",e[e.account_sponsorship_created=60]="account_sponsorship_created",e[e.account_sponsorship_updated=61]="account_sponsorship_updated",e[e.account_sponsorship_removed=62]="account_sponsorship_removed",e[e.trustline_sponsorship_created=63]="trustline_sponsorship_created",e[e.trustline_sponsorship_updated=64]="trustline_sponsorship_updated",e[e.trustline_sponsorship_removed=65]="trustline_sponsorship_removed",e[e.data_sponsorship_created=66]="data_sponsorship_created",e[e.data_sponsorship_updated=67]="data_sponsorship_updated",e[e.data_sponsorship_removed=68]="data_sponsorship_removed",e[e.claimable_balance_sponsorship_created=69]="claimable_balance_sponsorship_created",e[e.claimable_balance_sponsorship_updated=70]="claimable_balance_sponsorship_updated",e[e.claimable_balance_sponsorship_removed=71]="claimable_balance_sponsorship_removed",e[e.signer_sponsorship_created=72]="signer_sponsorship_created",e[e.signer_sponsorship_updated=73]="signer_sponsorship_updated",e[e.signer_sponsorship_removed=74]="signer_sponsorship_removed",e[e.claimable_balance_clawed_back=80]="claimable_balance_clawed_back",e[e.liquidity_pool_deposited=90]="liquidity_pool_deposited",e[e.liquidity_pool_withdrew=91]="liquidity_pool_withdrew",e[e.liquidity_pool_trade=92]="liquidity_pool_trade",e[e.liquidity_pool_created=93]="liquidity_pool_created",e[e.liquidity_pool_removed=94]="liquidity_pool_removed",e[e.liquidity_pool_revoked=95]="liquidity_pool_revoked",e[e.contract_credited=96]="contract_credited",e[e.contract_debited=97]="contract_debited",e))(Es||{});(vs=bs||(bs={})).EffectType=Es,(Ts=vs.TradeType||(vs.TradeType={})).all="all",Ts.liquidityPools="liquidity_pool",Ts.orderbook="orderbook",fs.OperationResponseType,fs.OperationResponseTypeI;class ks{id;paging_token;account_id;sequence;sequence_ledger;sequence_time;subentry_count;home_domain;inflation_destination;last_modified_ledger;last_modified_time;thresholds;flags;balances;signers;num_sponsoring;num_sponsored;sponsor;data;data_attr;effects;offers;operations;payments;trades;transactions;_baseAccount;constructor(e){this._baseAccount=new Vr(e.account_id,e.sequence),this.effects=e.effects,this.offers=e.offers,this.operations=e.operations,this.payments=e.payments,this.trades=e.trades,this.data=e.data,this.transactions=e.transactions,this.id=e.id,this.paging_token=e.paging_token,this.account_id=e.account_id,this.sequence=e.sequence,this.sequence_ledger=e.sequence_ledger,this.sequence_time=e.sequence_time,this.subentry_count=e.subentry_count,this.home_domain=e.home_domain,this.inflation_destination=e.inflation_destination,this.last_modified_ledger=e.last_modified_ledger,this.last_modified_time=e.last_modified_time,this.thresholds=e.thresholds,this.flags=e.flags,this.balances=e.balances,this.signers=e.signers,this.data_attr=e.data_attr,this.sponsor=e.sponsor,this.num_sponsoring=e.num_sponsoring,this.num_sponsored=e.num_sponsored}accountId(){return this._baseAccount.accountId()}sequenceNumber(){return this._baseAccount.sequenceNumber()}incrementSequenceNumber(){this._baseAccount.incrementSequenceNumber(),this.sequence=this._baseAccount.sequenceNumber()}}class Is extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const Cs=32;function Bs(e){}function xs(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Bs,onError:n=Bs,onRetry:r=Bs,onComment:o}=e,s=[];let i,a,c=!0,u="",l=0;function d(e){let n=0;if(-1===e.indexOf("\r")){let r=e.indexOf("\n",n);for(;-1!==r;){if(n===r){l>0&&t({id:i,event:a,data:u}),i=void 0,u="",l=0,a=void 0,n=r+1,r=e.indexOf("\n",n);continue}const o=e.charCodeAt(n);if(Rs(e,n,o)){const o=e.charCodeAt(n+5)===Cs?n+6:n+5,s=e.slice(o,r);if(0===l&&10===e.charCodeAt(r+1)){t({id:i,event:a,data:s}),i=void 0,u="",a=void 0,n=r+2,r=e.indexOf("\n",n);continue}u=0===l?s:`${u}\n${s}`,l++}else _s(e,n,o)?a=e.slice(e.charCodeAt(n+6)===Cs?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf("\n",n)}return e.slice(n)}for(;n<e.length;){const t=e.indexOf("\r",n),r=e.indexOf("\n",n);let o=-1;if(-1!==t&&-1!==r?o=t<r?t:r:-1!==t?o=t===e.length-1?-1:t:-1!==r&&(o=r),-1===o)break;p(e,n,o),n=o+1,13===e.charCodeAt(n-1)&&10===e.charCodeAt(n)&&n++}return e.slice(n)}function p(e,n,r){if(n===r)return l>0&&t({id:i,event:a,data:u}),i=void 0,u="",l=0,void(a=void 0);const s=e.charCodeAt(n);if(Rs(e,n,s)){const t=e.charCodeAt(n+5)===Cs?n+6:n+5,o=e.slice(t,r);return u=0===l?o:`${u}\n${o}`,void l++}if(_s(e,n,s))return void(a=e.slice(e.charCodeAt(n+6)===Cs?n+7:n+6,r)||void 0);if(105===s&&100===e.charCodeAt(n+1)&&58===e.charCodeAt(n+2)){const t=e.slice(e.charCodeAt(n+3)===Cs?n+4:n+3,r);return void(i=t.includes("\0")?void 0:t)}if(58===s){if(o){const t=e.slice(n,r);o(t.slice(e.charCodeAt(n+1)===Cs?2:1))}return}const c=e.slice(n,r),d=c.indexOf(":");if(-1===d)return void h(c,"",c);const p=c.slice(0,d),f=c.charCodeAt(d+1)===Cs?2:1;h(p,c.slice(d+f),c)}function h(e,t,o){switch(e){case"event":a=t||void 0;break;case"data":u=0===l?t:`${u}\n${t}`,l++;break;case"id":i=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?r(parseInt(t,10)):n(new Is(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:o}));break;default:n(new Is(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:"unknown-field",field:e,value:t,line:o}))}}return{feed:function(e){if(c&&(c=!1,239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)&&(e=e.slice(3))),0===s.length){const t=d(e);return void(""!==t&&s.push(t))}if(-1===e.indexOf("\n")&&-1===e.indexOf("\r"))return void s.push(e);s.push(e);const t=s.join("");s.length=0;const n=d(t);""!==n&&s.push(n)},reset:function(e={}){if(e.consume&&s.length>0){const e=s.join("");p(e,0,e.length)}c=!0,i=void 0,u="",l=0,a=void 0,s.length=0}}}function Rs(e,t,n){return 100===n&&97===e.charCodeAt(t+1)&&116===e.charCodeAt(t+2)&&97===e.charCodeAt(t+3)&&58===e.charCodeAt(t+4)}function _s(e,t,n){return 101===n&&118===e.charCodeAt(t+1)&&101===e.charCodeAt(t+2)&&110===e.charCodeAt(t+3)&&116===e.charCodeAt(t+4)&&58===e.charCodeAt(t+5)}class Ps extends Event{constructor(e,t){var n,r;super(e),this.code=null!=(n=null==t?void 0:t.code)?n:void 0,this.message=null!=(r=null==t?void 0:t.message)?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return n(Us(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(Us(this),t)}}function Os(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(Os).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${Os(e.cause)}`:e.message:`${e}`}function Us(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Ls,Ns,Vs,Fs,Ds,Ms,qs,Hs,Gs,$s,Xs,Ks,Ws,Zs,zs,js,Ys,Js,Qs,ei,ti,ni,ri,oi=e=>{throw TypeError(e)},si=(e,t,n)=>t.has(e)||oi("Cannot "+n),ii=(e,t,n)=>(si(e,t,"read from private field"),n?n.call(e):t.get(e)),ai=(e,t,n)=>t.has(e)?oi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ci=(e,t,n,r)=>(si(e,t,"write to private field"),t.set(e,n),n),ui=(e,t,n)=>(si(e,t,"access private method"),n);class li extends EventTarget{constructor(e,t){var n,r;super(),ai(this,Zs),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ai(this,Ls),ai(this,Ns),ai(this,Vs),ai(this,Fs),ai(this,Ds),ai(this,Ms),ai(this,qs),ai(this,Hs,null),ai(this,Gs),ai(this,$s),ai(this,Xs,null),ai(this,Ks,null),ai(this,Ws,null),ai(this,js,async e=>{var t;ii(this,$s).reset();const{body:n,redirected:r,status:o,headers:s}=e;if(204===o)return ui(this,Zs,ti).call(this,"Server sent HTTP 204, not reconnecting",204),void this.close();if(ci(this,Vs,r?new URL(e.url):void 0),200!==o)return void ui(this,Zs,ti).call(this,`Non-200 status code (${o})`,o);if(!(s.get("content-type")||"").startsWith("text/event-stream"))return void ui(this,Zs,ti).call(this,'Invalid content type, expected "text/event-stream"',o);if(ii(this,Ls)===this.CLOSED)return;ci(this,Ls,this.OPEN);const i=new Event("open");if(null==(t=ii(this,Ws))||t.call(this,i),this.dispatchEvent(i),"object"!=typeof n||!n||!("getReader"in n))return ui(this,Zs,ti).call(this,"Invalid response body, expected a web ReadableStream",o),void this.close();const a=new TextDecoder,c=n.getReader();let u=!0;do{const{done:e,value:t}=await c.read();t&&ii(this,$s).feed(a.decode(t,{stream:!e})),e&&(u=!1,ii(this,$s).reset(),ui(this,Zs,ni).call(this))}while(u)}),ai(this,Ys,e=>{ci(this,Gs,void 0),"AbortError"!==e.name&&"aborted"!==e.type&&ui(this,Zs,ni).call(this,Os(e))}),ai(this,Qs,e=>{"string"==typeof e.id&&ci(this,Hs,e.id);const t=new MessageEvent(e.event||"message",{data:e.data,origin:ii(this,Vs)?ii(this,Vs).origin:ii(this,Ns).origin,lastEventId:e.id||""});ii(this,Ks)&&(!e.event||"message"===e.event)&&ii(this,Ks).call(this,t),this.dispatchEvent(t)}),ai(this,ei,e=>{ci(this,Ms,e)}),ai(this,ri,()=>{ci(this,qs,void 0),ii(this,Ls)===this.CONNECTING&&ui(this,Zs,zs).call(this)});try{if(e instanceof URL)ci(this,Ns,e);else{if("string"!=typeof e)throw new Error("Invalid URL");ci(this,Ns,new URL(e,function(){const e="document"in globalThis?globalThis.document:void 0;return e&&"object"==typeof e&&"baseURI"in e&&"string"==typeof e.baseURI?e.baseURI:void 0}()))}}catch{throw function(e){const t=globalThis.DOMException;return"function"==typeof t?new t(e,"SyntaxError"):new SyntaxError(e)}("An invalid or illegal string was specified")}ci(this,$s,xs({onEvent:ii(this,Qs),onRetry:ii(this,ei)})),ci(this,Ls,this.CONNECTING),ci(this,Ms,3e3),ci(this,Ds,null!=(n=null==t?void 0:t.fetch)?n:globalThis.fetch),ci(this,Fs,null!=(r=null==t?void 0:t.withCredentials)&&r),ui(this,Zs,zs).call(this)}get readyState(){return ii(this,Ls)}get url(){return ii(this,Ns).href}get withCredentials(){return ii(this,Fs)}get onerror(){return ii(this,Xs)}set onerror(e){ci(this,Xs,e)}get onmessage(){return ii(this,Ks)}set onmessage(e){ci(this,Ks,e)}get onopen(){return ii(this,Ws)}set onopen(e){ci(this,Ws,e)}addEventListener(e,t,n){const r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){const r=t;super.removeEventListener(e,r,n)}close(){ii(this,qs)&&clearTimeout(ii(this,qs)),ii(this,Ls)!==this.CLOSED&&(ii(this,Gs)&&ii(this,Gs).abort(),ci(this,Ls,this.CLOSED),ci(this,Gs,void 0))}}Ls=new WeakMap,Ns=new WeakMap,Vs=new WeakMap,Fs=new WeakMap,Ds=new WeakMap,Ms=new WeakMap,qs=new WeakMap,Hs=new WeakMap,Gs=new WeakMap,$s=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,Ws=new WeakMap,Zs=new WeakSet,zs=function(){ci(this,Ls,this.CONNECTING),ci(this,Gs,new AbortController),ii(this,Ds)(ii(this,Ns),ui(this,Zs,Js).call(this)).then(ii(this,js)).catch(ii(this,Ys))},js=new WeakMap,Ys=new WeakMap,Js=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...ii(this,Hs)?{"Last-Event-ID":ii(this,Hs)}:void 0},cache:"no-store",signal:null==(e=ii(this,Gs))?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Qs=new WeakMap,ei=new WeakMap,ti=function(e,t){var n;ii(this,Ls)!==this.CLOSED&&ci(this,Ls,this.CLOSED);const r=new Ps("error",{code:t,message:e});null==(n=ii(this,Xs))||n.call(this,r),this.dispatchEvent(r)},ni=function(e,t){var n;if(ii(this,Ls)===this.CLOSED)return;ci(this,Ls,this.CONNECTING);const r=new Ps("error",{code:t,message:e});null==(n=ii(this,Xs))||n.call(this,r),this.dispatchEvent(r),ci(this,qs,setTimeout(ii(this,ri),ii(this,Ms)))},ri=new WeakMap,li.CONNECTING=0,li.OPEN=1,li.CLOSED=2,Object.defineProperty(li,Symbol.for("eventsource.supports-fetch-override"),{value:!0,writable:!1,configurable:!1,enumerable:!1});const di="16.1.0",pi={};function hi(e){return Math.floor(e/1e3)}function fi(e){const t=pi[e];if(!t||!t.localTimeRecorded||!t.serverTime)return null;const{serverTime:n,localTimeRecorded:r}=t,o=hi((new Date).getTime());return o-r>300?null:o-r+n}function mi(e){return Array.isArray(e)?e.join(","):e.toString()}const gi=["transaction"];class yi{url;filter;originalSegments;neighborRoot;httpClient;constructor(e,t,n=""){this.url=new URL(e),this.filter=[],this.originalSegments=this.url.pathname.split("/").filter(e=>e.length>0),this.neighborRoot=n,this.httpClient=t}setPath(...e){const t=e.flatMap(e=>e.split("/").filter(e=>e.length>0));this.url.pathname=this.originalSegments.concat(t).join("/")}call(){return this.checkFilter(),this._sendNormalRequest(this.url).then(e=>this._parseResponse(e))}stream(e={}){this.checkFilter();const t=new URL(this.url);t.searchParams.set("X-Client-Name","js-stellar-sdk"),t.searchParams.set("X-Client-Version",di);const{headers:n}=this.httpClient.defaults;if(n){["X-App-Name","X-App-Version"].forEach(e=>{let r;if(n instanceof Headers)r=n.get(e)??void 0;else if(Array.isArray(n)){const t=n.find(([t])=>t===e);r=t?.[1]}else r=n[e];r&&t.searchParams.set(e,r)})}let r,o;const s=()=>{o=setTimeout(()=>{r?.close(),r=i()},e.reconnectTimeout||15e3)},i=()=>{try{r=new li(t.toString())}catch(t){e.onerror&&e.onerror(t)}if(s(),!r)return r;let n=!1;const a=()=>{n||(clearTimeout(o),r.close(),i(),n=!0)},c=n=>{if("close"===n.type)return void a();const r=n.data?this._parseRecord(JSON.parse(n.data)):n;r.paging_token&&t.searchParams.set("cursor",r.paging_token),clearTimeout(o),s(),void 0!==e.onmessage&&e.onmessage(r)},u=t=>{e.onerror&&e.onerror(t)};return r.addEventListener?(r.addEventListener("message",c.bind(this)),r.addEventListener("error",u.bind(this)),r.addEventListener("close",a.bind(this))):(r.onmessage=c.bind(this),r.onerror=u.bind(this)),r};return i(),()=>{clearTimeout(o),r?.close()}}cursor(e){return this.url.searchParams.set("cursor",e),this}limit(e){return this.url.searchParams.set("limit",e.toString()),this}order(e){return this.url.searchParams.set("order",e),this}join(e){return this.url.searchParams.set("join",e),this}forEndpoint(e,t){if(""===this.neighborRoot)throw new Error("Invalid usage: neighborRoot not set in constructor");return this.filter.push([e,t,this.neighborRoot]),this}checkFilter(){if(this.filter.length>=2)throw new I("Too many filters specified",this.filter);if(1===this.filter.length){const e=this.originalSegments.concat(this.filter[0]);this.url.pathname=e.join("/")}}_requestFnForLink(e){return async(t={})=>{let n;n=e.templated?new URL(function(e,t,n){const r=[],o=e.replace(/\{\?([^}]+)\}/g,(e,t)=>(r.push(...t.split(",")),"")).replace(/\{([^?][^}]*)\}/g,(e,n)=>{const r=t[n];return void 0===r?"":encodeURIComponent(mi(r))}),s=new URL(o,n);return r.forEach(e=>{const n=t[e];void 0!==n&&s.searchParams.set(e,mi(n))}),s.toString()}(e.href,t),this.url):new URL(e.href,this.url);const r=await this._sendNormalRequest(n);return this._parseResponse(r)}}_parseRecord(e){return e._links?(Object.keys(e._links).forEach(t=>{const n=e._links[t];let r=!1;if(void 0!==e[t]&&(e[`${t}_attr`]=e[t],r=!0),r&&gi.indexOf(t)>=0){const n=this._parseRecord(e[t]);e[t]=async()=>n}else e[t]=this._requestFnForLink(n)}),e):e}async _sendNormalRequest(e){const t=new URL(e);return t.protocol=this.url.protocol,t.host=this.url.host,this.httpClient.get(t.toString()).then(e=>e.data).catch(this._handleNetworkError)}_parseResponse(e){return e._embedded&&e._embedded.records?this._toCollectionPage(e):this._parseRecord(e)}_toCollectionPage(e){for(let t=0;t<e._embedded.records.length;t+=1)e._embedded.records[t]=this._parseRecord(e._embedded.records[t]);return{records:e._embedded.records,next:async()=>{const t=await this._sendNormalRequest(new URL(e._links.next.href,this.url));return this._toCollectionPage(t)},prev:async()=>{const t=await this._sendNormalRequest(new URL(e._links.prev.href,this.url));return this._toCollectionPage(t)}}}async _handleNetworkError(e){return e.response&&e.response.status?404===e.response.status?Promise.reject(new k(e.response.statusText??"Not Found",e.response.data)):Promise.reject(new E(e.response.statusText??"Unknown",e.response.data)):Promise.reject(new Error(e.message))}}class wi extends yi{constructor(e,t){super(e,t),this.setPath("accounts")}accountId(e){const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forSigner(e){return this.url.searchParams.set("signer",e),this}forAsset(e){return this.url.searchParams.set("asset",`${e}`),this}sponsor(e){return this.url.searchParams.set("sponsor",e),this}forLiquidityPool(e){return this.url.searchParams.set("liquidity_pool",e),this}}class Ai extends yi{constructor(e,t){super(e,t),this.setPath("assets")}forCode(e){return this.url.searchParams.set("asset_code",e),this}forIssuer(e){return this.url.searchParams.set("asset_issuer",e),this}}class Si extends yi{constructor(e,t){super(e,t),this.setPath("claimable_balances")}claimableBalance(e){const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e]),t}sponsor(e){return this.url.searchParams.set("sponsor",e),this}claimant(e){return this.url.searchParams.set("claimant",e),this}asset(e){return this.url.searchParams.set("asset",e.toString()),this}}class bi extends yi{constructor(e,t){super(e,t,"effects"),this.setPath("effects")}forAccount(e){return this.forEndpoint("accounts",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}forOperation(e){return this.forEndpoint("operations",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}}class vi extends yi{constructor(e,t,n){super(e,t),this.setPath("friendbot"),this.url.searchParams.set("addr",n)}}class Ti extends yi{constructor(e,t){super(e,t),this.setPath("ledgers")}ledger(e){return this.filter.push(["ledgers",e.toString()]),this}}class Ei extends yi{constructor(e,t){super(e,t),this.setPath("liquidity_pools")}forAssets(...e){const t=e.map(e=>e.toString()).join(",");return this.url.searchParams.set("reserves",t),this}forAccount(e){return this.url.searchParams.set("account",e),this}liquidityPoolId(e){if(!e.match(/[a-fA-F0-9]{64}/))throw new TypeError(`${e} does not look like a liquidity pool ID`);const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e.toLowerCase()]),t}}class ki extends yi{constructor(e,t){super(e,t,"offers"),this.setPath("offers")}offer(e){const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}buying(e){const t=e.getIssuer();return e.isNative()||void 0===t?this.url.searchParams.set("buying_asset_type","native"):(this.url.searchParams.set("buying_asset_type",e.getAssetType()),this.url.searchParams.set("buying_asset_code",e.getCode()),this.url.searchParams.set("buying_asset_issuer",t)),this}selling(e){const t=e.getIssuer();return e.isNative()||void 0===t?this.url.searchParams.set("selling_asset_type","native"):(this.url.searchParams.set("selling_asset_type",e.getAssetType()),this.url.searchParams.set("selling_asset_code",e.getCode()),this.url.searchParams.set("selling_asset_issuer",t)),this}sponsor(e){return this.url.searchParams.set("sponsor",e),this}seller(e){return this.url.searchParams.set("seller",e),this}}class Ii extends yi{constructor(e,t){super(e,t,"operations"),this.setPath("operations")}operation(e){const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}forClaimableBalance(e){return this.forEndpoint("claimable_balances",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}class Ci extends yi{constructor(e,t,n,r){super(e,t),this.setPath("order_book");const o=n.getIssuer();n.isNative()||void 0===o?this.url.searchParams.set("selling_asset_type","native"):(this.url.searchParams.set("selling_asset_type",n.getAssetType()),this.url.searchParams.set("selling_asset_code",n.getCode()),this.url.searchParams.set("selling_asset_issuer",o));const s=r.getIssuer();r.isNative()||void 0===s?this.url.searchParams.set("buying_asset_type","native"):(this.url.searchParams.set("buying_asset_type",r.getAssetType()),this.url.searchParams.set("buying_asset_code",r.getCode()),this.url.searchParams.set("buying_asset_issuer",s))}}class Bi extends yi{constructor(e,t){super(e,t,"payments"),this.setPath("payments")}forAccount(e){return this.forEndpoint("accounts",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forTransaction(e){return this.forEndpoint("transactions",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}class xi extends yi{constructor(e,t,n,r,o){if(super(e,t),this.setPath("paths/strict-receive"),"string"==typeof n)this.url.searchParams.set("source_account",n);else{const e=n.map(e=>e.isNative()?"native":`${e.getCode()}:${e.getIssuer()}`).join(",");this.url.searchParams.set("source_assets",e)}this.url.searchParams.set("destination_amount",o);const s=r.getIssuer();r.isNative()||void 0===s?this.url.searchParams.set("destination_asset_type","native"):(this.url.searchParams.set("destination_asset_type",r.getAssetType()),this.url.searchParams.set("destination_asset_code",r.getCode()),this.url.searchParams.set("destination_asset_issuer",s))}}class Ri extends yi{constructor(e,t,n,r,o){super(e,t),this.setPath("paths/strict-send");const s=n.getIssuer();if(n.isNative()?this.url.searchParams.set("source_asset_type","native"):void 0!==s&&(this.url.searchParams.set("source_asset_type",n.getAssetType()),this.url.searchParams.set("source_asset_code",n.getCode()),this.url.searchParams.set("source_asset_issuer",s)),this.url.searchParams.set("source_amount",r),"string"==typeof o)this.url.searchParams.set("destination_account",o);else{const e=o.map(e=>e.isNative()?"native":`${e.getCode()}:${e.getIssuer()}`).join(",");this.url.searchParams.set("destination_assets",e)}}}const _i=[6e4,3e5,9e5,36e5,864e5,6048e5];class Pi extends yi{constructor(e,t,n,r,o,s,i,a){super(e,t),this.setPath("trade_aggregations");const c=n.getIssuer();n.isNative()||void 0===c?this.url.searchParams.set("base_asset_type","native"):(this.url.searchParams.set("base_asset_type",n.getAssetType()),this.url.searchParams.set("base_asset_code",n.getCode()),this.url.searchParams.set("base_asset_issuer",c));const u=r.getIssuer();if(r.isNative()||void 0===u?this.url.searchParams.set("counter_asset_type","native"):(this.url.searchParams.set("counter_asset_type",r.getAssetType()),this.url.searchParams.set("counter_asset_code",r.getCode()),this.url.searchParams.set("counter_asset_issuer",u)),"number"!=typeof o||"number"!=typeof s)throw new I("Invalid time bounds",[o,s]);if(this.url.searchParams.set("start_time",o.toString()),this.url.searchParams.set("end_time",s.toString()),!this.isValidResolution(i))throw new I("Invalid resolution",i);if(this.url.searchParams.set("resolution",i.toString()),!this.isValidOffset(a,i))throw new I("Invalid offset",a);this.url.searchParams.set("offset",a.toString())}isValidResolution(e){return _i.some(t=>t===e)}isValidOffset(e,t){const n=36e5;return!(e>t||e>=24*n||e%n!==0)}}class Oi extends yi{constructor(e,t){super(e,t,"trades"),this.setPath("trades")}forAssetPair(e,t){const n=e.getIssuer();e.isNative()||void 0===n?this.url.searchParams.set("base_asset_type","native"):(this.url.searchParams.set("base_asset_type",e.getAssetType()),this.url.searchParams.set("base_asset_code",e.getCode()),this.url.searchParams.set("base_asset_issuer",n));const r=t.getIssuer();return t.isNative()||void 0===r?this.url.searchParams.set("counter_asset_type","native"):(this.url.searchParams.set("counter_asset_type",t.getAssetType()),this.url.searchParams.set("counter_asset_code",t.getCode()),this.url.searchParams.set("counter_asset_issuer",r)),this}forOffer(e){return this.url.searchParams.set("offer_id",e),this}forType(e){return this.url.searchParams.set("trade_type",e),this}forAccount(e){return this.forEndpoint("accounts",e)}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}}class Ui extends yi{constructor(e,t){super(e,t,"transactions"),this.setPath("transactions")}transaction(e){const t=new yi(new URL(this.url),this.httpClient);return t.filter.push([e]),t}forAccount(e){return this.forEndpoint("accounts",e)}forClaimableBalance(e){return this.forEndpoint("claimable_balances",e)}forLedger(e){return this.forEndpoint("ledgers",e.toString())}forLiquidityPool(e){return this.forEndpoint("liquidity_pools",e)}includeFailed(e){return this.url.searchParams.set("include_failed",e.toString()),this}}function Li(e){return new xn(e).div(1e7).toString()}function Ni(e){return ts(e,e=>{const t=`Transaction submission failed. Server responded: ${e.status} ${e.statusText}`;return e.data?.extras?.result_codes?new Co(t,e):new C(t,e)})}var Vi,Fi=Object.freeze({__proto__:null,AccountResponse:ks,get HorizonApi(){return fs},SERVER_TIME_MAP:pi,Server:class{serverURL;httpClient;constructor(e,t={}){this.serverURL=new URL(e);const n=void 0===t.allowHttp?_o.isAllowHttp():t.allowHttp,r={};if(t.appName&&(r["X-App-Name"]=t.appName),t.appVersion&&(r["X-App-Version"]=t.appVersion),t.authToken&&(r["X-Auth-Token"]=t.authToken),t.headers&&Object.assign(r,t.headers),this.httpClient=function(e){const t=v({headers:{...e,"X-Client-Name":"js-stellar-sdk","X-Client-Version":di}});return t.interceptors.response.use(e=>{const t=e.config.url;if(!t)return e;const n=new URL(t),r=n.port,o=r?`${n.hostname}:${r}`:n.hostname;let s=0;if(e.headers instanceof Headers){const t=e.headers.get("date");t&&(s=hi(Date.parse(t)))}else if("object"==typeof e.headers&&"date"in e.headers){const t=e.headers;"string"==typeof t.date&&(s=hi(Date.parse(t.date)))}const i=hi((new Date).getTime());return Number.isNaN(s)||(pi[o]={serverTime:s,localTimeRecorded:i}),e}),t}(r),"https:"!==this.serverURL.protocol&&!n)throw new Error("Cannot connect to insecure horizon server")}async fetchTimebounds(e,t=!1){const n=this.serverURL.port,r=fi(n?`${this.serverURL.hostname}:${n}`:this.serverURL.hostname);return r?{minTime:0,maxTime:r+e}:t?{minTime:0,maxTime:Math.floor((new Date).getTime()/1e3)+e}:(await this.httpClient.get(this.serverURL.toString()),this.fetchTimebounds(e,!0))}async fetchBaseFee(){const e=await this.feeStats();return parseInt(e.last_ledger_base_fee,10)||100}async feeStats(){const e=new yi(this.serverURL,this.httpClient);return e.filter.push(["fee_stats"]),e.call()}async root(){return new yi(this.serverURL,this.httpClient).call()}async submitTransaction(e,t={skipMemoRequiredCheck:!1}){t.skipMemoRequiredCheck||await this.checkMemoRequired(e);const n=encodeURIComponent(e.toEnvelope().toXDR().toString("base64")),r=new URL(this.serverURL);return r.pathname=r.pathname.split("/").concat(["transactions"]).filter(e=>e.length>0).join("/"),this.httpClient.post(r.toString(),`tx=${n}`,{timeout:6e4,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(e=>{if(!e.data.result_xdr)return e.data;const t=P.TransactionResult.fromXDR(e.data.result_xdr,"base64").result().value();let n,r;return t.length&&(n=t.map((e,t)=>{if("manageBuyOffer"!==e.value().switch().name&&"manageSellOffer"!==e.value().switch().name)return null;r=!0;let n=new xn(0),o=new xn(0);const s=e.value().value().success(),i=s.offersClaimed().map(e=>{const t=e.value();let r="";switch(e.switch()){case P.ClaimAtomType.claimAtomTypeV0():r=$t.encodeEd25519PublicKey(t.sellerEd25519());break;case P.ClaimAtomType.claimAtomTypeOrderBook():r=$t.encodeEd25519PublicKey(t.sellerId().ed25519());break;default:throw new Error(`Invalid offer result type: ${e.switch()}`)}const s=new xn(t.amountBought().toString()),i=new xn(t.amountSold().toString());n=n.plus(i),o=o.plus(s);const a=Qt.fromOperation(t.assetSold()),c=Qt.fromOperation(t.assetBought()),u={type:a.getAssetType(),assetCode:a.getCode(),issuer:a.getIssuer()},l={type:c.getAssetType(),assetCode:c.getCode(),issuer:c.getIssuer()};return{sellerId:r,offerId:t.offerId().toString(),assetSold:u,amountSold:Li(i),assetBought:l,amountBought:Li(s)}}),a=s.offer().switch().name;let c;if("function"==typeof s.offer().value&&s.offer().value()){const e=s.offer().value();c={offerId:e.offerId().toString(),selling:{},buying:{},amount:Li(e.amount().toString()),price:{n:e.price().n(),d:e.price().d()}};const t=Qt.fromOperation(e.selling());c.selling={type:t.getAssetType(),assetCode:t.getCode(),issuer:t.getIssuer()};const n=Qt.fromOperation(e.buying());c.buying={type:n.getAssetType(),assetCode:n.getCode(),issuer:n.getIssuer()}}return{offersClaimed:i,effect:a,operationIndex:t,currentOffer:c,amountBought:Li(n),amountSold:Li(o),isFullyOpen:!i.length&&"manageOfferDeleted"!==a,wasPartiallyFilled:!!i.length&&"manageOfferDeleted"!==a,wasImmediatelyFilled:!!i.length&&"manageOfferDeleted"===a,wasImmediatelyDeleted:!i.length&&"manageOfferDeleted"===a}}).filter(e=>!!e)),{...e.data,offerResults:r?n:void 0}}).catch(e=>Promise.reject(Ni(e)))}async submitAsyncTransaction(e,t={skipMemoRequiredCheck:!1}){t.skipMemoRequiredCheck||await this.checkMemoRequired(e);const n=encodeURIComponent(e.toEnvelope().toXDR().toString("base64")),r=new URL(this.serverURL);return r.pathname=r.pathname.split("/").concat(["transactions_async"]).filter(e=>e.length>0).join("/"),this.httpClient.post(r.toString(),`tx=${n}`,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(e=>e.data).catch(e=>Promise.reject(Ni(e)))}accounts(){return new wi(this.serverURL,this.httpClient)}claimableBalances(){return new Si(this.serverURL,this.httpClient)}ledgers(){return new Ti(this.serverURL,this.httpClient)}transactions(){return new Ui(this.serverURL,this.httpClient)}offers(){return new ki(this.serverURL,this.httpClient)}orderbook(e,t){return new Ci(this.serverURL,this.httpClient,e,t)}trades(){return new Oi(this.serverURL,this.httpClient)}operations(){return new Ii(this.serverURL,this.httpClient)}liquidityPools(){return new Ei(this.serverURL,this.httpClient)}strictReceivePaths(e,t,n){return new xi(this.serverURL,this.httpClient,e,t,n)}strictSendPaths(e,t,n){return new Ri(this.serverURL,this.httpClient,e,t,n)}payments(){return new Bi(this.serverURL,this.httpClient)}effects(){return new bi(this.serverURL,this.httpClient)}friendbot(e){return new vi(this.serverURL,this.httpClient,e)}assets(){return new Ai(this.serverURL,this.httpClient)}async loadAccount(e){const t=await this.accounts().accountId(e).call();return new ks(t)}tradeAggregation(e,t,n,r,o,s){return new Pi(this.serverURL,this.httpClient,e,t,n,r,o,s)}async checkMemoRequired(e){if(e instanceof Nr&&(e=e.innerTransaction),"none"!==e.memo.type)return;const t=new Set;for(let n=0;n<e.operations.length;n+=1){const r=e.operations[n];switch(r.type){case"payment":case"pathPaymentStrictReceive":case"pathPaymentStrictSend":case"accountMerge":break;default:continue}const o=r.destination;if(!t.has(o)&&(t.add(o),!o.startsWith("M")))try{if("MQ=="===(await this.loadAccount(o)).data_attr["config.memo_required"])throw new Bo("account requires memo",o,n)}catch(e){if(e instanceof Bo)throw e;if(!(e instanceof k))throw e;continue}}}},get ServerApi(){return bs},getCurrentServerTime:fi});(e=>{var t;function n(e){return"transactionData"in e}(t=e.GetTransactionStatus||(e.GetTransactionStatus={})).SUCCESS="SUCCESS",t.NOT_FOUND="NOT_FOUND",t.FAILED="FAILED",e.isSimulationError=function(e){return"error"in e},e.isSimulationSuccess=n,e.isSimulationRestore=function(e){return n(e)&&"restorePreamble"in e&&!!e.restorePreamble.transactionData},e.isSimulationRaw=function(e){return!e._parsed}})(Vi||(Vi={}));async function Di(e,t,n,r=null){const o=await e.post(t,{jsonrpc:"2.0",id:1,method:n,params:r});if(s=o.data,i="error",Object.prototype.hasOwnProperty.call(s,i))throw o.data.error;return o.data?.result;var s,i}function Mi(e){const{errorResultXdr:t,diagnosticEventsXdr:n}=e;return delete e.errorResultXdr,delete e.diagnosticEventsXdr,t?{...e,...void 0!==n&&n.length>0&&{diagnosticEvents:n.map(e=>P.DiagnosticEvent.fromXDR(e,"base64"))},errorResult:P.TransactionResult.fromXDR(t,"base64")}:{...e}}function qi(e){const t=P.TransactionMeta.fromXDR(e.resultMetaXdr,"base64"),n={ledger:e.ledger,createdAt:e.createdAt,applicationOrder:e.applicationOrder,feeBump:e.feeBump,envelopeXdr:P.TransactionEnvelope.fromXDR(e.envelopeXdr,"base64"),resultXdr:P.TransactionResult.fromXDR(e.resultXdr,"base64"),resultMetaXdr:t,events:{contractEventsXdr:(e.events?.contractEventsXdr??[]).map(e=>e.map(e=>P.ContractEvent.fromXDR(e,"base64"))),transactionEventsXdr:(e.events?.transactionEventsXdr??[]).map(e=>P.TransactionEvent.fromXDR(e,"base64"))}};switch(t.switch()){case 3:case 4:{const e=t.value();null!==e.sorobanMeta()&&(n.returnValue=e.sorobanMeta()?.returnValue()??void 0)}}return e.diagnosticEventsXdr&&(n.diagnosticEventsXdr=e.diagnosticEventsXdr.map(e=>P.DiagnosticEvent.fromXDR(e,"base64"))),n}function Hi(e){return{status:e.status,txHash:e.txHash,...qi(e)}}function Gi(e){return{latestLedger:e.latestLedger,oldestLedger:e.oldestLedger,latestLedgerCloseTime:e.latestLedgerCloseTime,oldestLedgerCloseTime:e.oldestLedgerCloseTime,cursor:e.cursor,events:(e.events??[]).map(e=>{const t={...e};return delete t.contractId,{...t,...""!==e.contractId&&{contractId:new Gr(e.contractId)},topic:(e.topic??[]).map(e=>P.ScVal.fromXDR(e,"base64")),value:P.ScVal.fromXDR(e.value,"base64")}})}}function $i(e){return{latestLedger:e.latestLedger,entries:(e.entries??[]).map(e=>{if(!e.key||!e.xdr)throw new TypeError(`invalid ledger entry: ${JSON.stringify(e)}`);return{lastModifiedLedgerSeq:e.lastModifiedLedgerSeq,key:P.LedgerKey.fromXDR(e.key,"base64"),val:P.LedgerEntryData.fromXDR(e.xdr,"base64"),...void 0!==e.liveUntilLedgerSeq&&{liveUntilLedgerSeq:e.liveUntilLedgerSeq}}})}}function Xi(e){if(!Vi.isSimulationRaw(e))return e;const t={_parsed:!0,id:e.id,latestLedger:e.latestLedger,events:e.events?.map(e=>P.DiagnosticEvent.fromXDR(e,"base64"))??[]};return"string"==typeof e.error?{...t,error:e.error}:function(e,t){const n={...t,transactionData:new qr(e.transactionData),minResourceFee:e.minResourceFee,...(e.results?.length??0)>0&&{result:e.results.map(e=>({auth:(e.auth??[]).map(e=>P.SorobanAuthorizationEntry.fromXDR(e,"base64")),retval:e.xdr?P.ScVal.fromXDR(e.xdr,"base64"):P.ScVal.scvVoid()}))[0]},...(e.stateChanges?.length??0)>0&&{stateChanges:e.stateChanges?.map(e=>({type:e.type,key:P.LedgerKey.fromXDR(e.key,"base64"),before:e.before?P.LedgerEntry.fromXDR(e.before,"base64"):null,after:e.after?P.LedgerEntry.fromXDR(e.after,"base64"):null}))}};return e.restorePreamble&&""!==e.restorePreamble.transactionData?{...n,restorePreamble:{minResourceFee:e.restorePreamble.minResourceFee,transactionData:new qr(e.restorePreamble.transactionData)}}:n}(e,t)}function Ki(e){if(!e.metadataXdr||!e.headerXdr){let t;throw t=e.metadataXdr||e.headerXdr?e.metadataXdr?"headerXdr":"metadataXdr":"metadataXdr and headerXdr",new TypeError(`invalid ledger missing fields: ${t}`)}const t=P.LedgerCloseMeta.fromXDR(e.metadataXdr,"base64"),n=P.LedgerHeaderHistoryEntry.fromXDR(e.headerXdr,"base64");return{hash:e.hash,sequence:e.sequence,ledgerCloseTime:e.ledgerCloseTime,metadataXdr:t,headerXdr:n}}function Wi(e){const t=P.LedgerHeader.fromXDR(e.headerXdr,"base64"),n=P.LedgerCloseMeta.fromXDR(e.metadataXdr,"base64");let r;if(e.metadataXdr||e.headerXdr?e.metadataXdr?e.headerXdr||(r="headerXdr"):r="metadataXdr":r="metadataXdr and headerXdr",r)throw new TypeError(`invalid getLatestLedger response missing fields: ${r}`);return{id:e.id,sequence:e.sequence,protocolVersion:e.protocolVersion,closeTime:e.closeTime,headerXdr:t,metadataXdr:n}}function Zi(e,t){if("innerTransaction"in e)return Zi(e.innerTransaction,t);if(!function(e){if(1!==e.operations.length)return!1;switch(e.operations[0].type){case"invokeHostFunction":case"extendFootprintTtl":case"restoreFootprint":return!0;default:return!1}}(e))throw new TypeError("unsupported transaction: must contain exactly one invokeHostFunction, extendFootprintTtl, or restoreFootprint operation");const n=Xi(t);if(!Vi.isSimulationSuccess(n))throw new Error(`simulation incorrect: ${JSON.stringify(n)}`);let r;try{r=BigInt(e.fee)}catch{r=BigInt(0)}const o=e.toEnvelope().v1().tx().ext().value();o&&r-o.resourceFee().toBigInt()>BigInt(0)&&(r-=o.resourceFee().toBigInt());const s=ro.cloneFrom(e,{fee:r.toString(),sorobanData:n.transactionData.build(),networkPassphrase:e.networkPassphrase});if("invokeHostFunction"===e.operations[0].type){s.clearOperations();const t=e.operations[0],r=t.auth??[];s.addOperation(Cr.invokeHostFunction({source:t.source,func:t.func,auth:r.length>0?r:n.result.auth}))}return s}var zi=(e=>(e.Temporary="temporary",e.Persistent="persistent",e))(zi||{});const ji=e=>1e3;function Yi(e){return e.switch().value===P.ScSpecType.scSpecTypeUdt().value?e.udt().name().toString():e.switch().name.replace(/^scSpecType/,"")}class Ji{serverURL;httpClient;constructor(e,t={}){var n;if(this.serverURL=new URL(e),this.httpClient=(n=t.headers,v({headers:{...n,"X-Client-Name":"js-stellar-sdk","X-Client-Version":"16.1.0"}})),"https:"!==this.serverURL.protocol&&!t.allowHttp)throw new Error("Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set")}async getAccount(e){const t=await this.getAccountEntry(e);return new Vr(e,t.seqNum().toString())}async getAccountEntry(e){const t=P.LedgerKey.account(new P.LedgerKeyAccount({accountId:jt.fromPublicKey(e).xdrPublicKey()}));try{return(await this.getLedgerEntry(t)).val.account()}catch{throw new Error(`Account not found: ${e}`)}}async getTrustline(e,t){const n=P.LedgerKey.trustline(new P.LedgerKeyTrustLine({accountId:jt.fromPublicKey(e).xdrAccountId(),asset:t.toTrustLineXDRObject()}));try{return(await this.getLedgerEntry(n)).val.trustLine()}catch{throw new Error(`Trustline for ${t.getCode()}:${t.getIssuer()} not found for ${e}`)}}async getClaimableBalance(e){let t;if($t.isValidClaimableBalance(e)){const n=$t.decodeClaimableBalance(e),r=q.Buffer.concat([q.Buffer.from("\0\0\0"),n.subarray(0,1)]);t=P.ClaimableBalanceId.fromXDR(q.Buffer.concat([r,n.subarray(1)]))}else if(e.match(/[a-f0-9]{72}/i))t=P.ClaimableBalanceId.fromXDR(e,"hex");else{if(!e.match(/[a-f0-9]{64}/i))throw new TypeError(`expected 72-char hex ID or strkey, not ${e}`);t=P.ClaimableBalanceId.fromXDR(e.padStart(72,"0"),"hex")}const n=P.LedgerKey.claimableBalance(new P.LedgerKeyClaimableBalance({balanceId:t}));try{return(await this.getLedgerEntry(n)).val.claimableBalance()}catch{throw new Error(`Claimable balance ${e} not found`)}}async getAssetBalance(e,t,n){let r=e;if("string"==typeof e)r=e;else if(e instanceof Ar)r=e.toString();else{if(!(e instanceof Gr))throw new TypeError(`invalid address: ${e}`);r=e.toString()}if($t.isValidEd25519PublicKey(r)){const[e,n]=await Promise.all([this.getTrustline(r,t),this.getLatestLedger()]);return{latestLedger:n.sequence,balanceEntry:{amount:e.balance().toString(),authorized:Boolean(1&e.flags()),clawback:Boolean(4&e.flags()),authorizedToMaintainLiabilities:Boolean(2&e.flags()),revocable:Boolean(2&e.flags())}}}if($t.isValidContract(r))return this.getSACBalance(r,t,n);throw new Error(`invalid address: ${e}`)}async getHealth(){return Di(this.httpClient,this.serverURL.toString(),"getHealth")}async getContractData(e,t,n="persistent"){let r,o;if("string"==typeof e)r=new Gr(e).address().toScAddress();else if(e instanceof Ar)r=e.toScAddress();else{if(!(e instanceof Gr))throw new TypeError(`unknown contract type: ${e}`);r=e.address().toScAddress()}switch(n){case"temporary":o=P.ContractDataDurability.temporary();break;case"persistent":o=P.ContractDataDurability.persistent();break;default:throw new TypeError(`invalid durability: ${n}`)}const s=P.LedgerKey.contractData(new P.LedgerKeyContractData({key:t,contract:r,durability:o}));try{return await this.getLedgerEntry(s)}catch{throw{code:404,message:`Contract data not found for ${Ar.fromScAddress(r).toString()} with key ${t.toXDR("base64")} and durability: ${n}`}}}async getContractInstance(e){const t=new Gr(e).getFootprint(),n=await this.getLedgerEntries(t);return n.entries.length&&n.entries[0]?.val?n.entries[0].val.contractData().val().instance():Promise.reject({code:404,message:"Could not obtain contract instance from server"})}async getContractWasmByContractId(e){const t=await this.getContractInstance(e);return t.executable().switch()===P.ContractExecutableType.contractExecutableStellarAsset()?Promise.reject({code:400,message:`Contract ${e} is a Stellar Asset Contract (SAC), which has no Wasm bytecode. Use contract.Client.from() to build a client from the built-in SAC spec instead.`}):this.getContractWasmByHash(t.executable().wasmHash())}async getContractWasmByHash(e,t=void 0){const n="string"==typeof e?q.Buffer.from(e,t):e,r=P.LedgerKey.contractCode(new P.LedgerKeyContractCode({hash:n})),o=await this.getLedgerEntries(r);if(!o.entries.length||!o.entries[0]?.val)return Promise.reject({code:404,message:"Could not obtain contract wasm from server"});return o.entries[0].val.contractCode().code()}async queryContract(e,t,n={},r){const o=r??(await this.getNetwork()).passphrase,{Client:s}=await Promise.resolve().then(function(){return Ma}),i=await s.from({contractId:e,rpcUrl:this.serverURL.toString(),networkPassphrase:o,server:this}),a=i.spec.funcs().some(e=>e.name().toString()===t),{sanitizeIdentifier:c}=await Promise.resolve().then(function(){return Va}),u=i[c(t)];if(!a||"function"!=typeof u)throw new TypeError(`Contract ${e} has no method '${t}'`);const l=await u(n);return{result:l.result,isReadCall:l.isReadCall}}async getContractMethods(e,t){const n=t??(await this.getNetwork()).passphrase,{Client:r}=await Promise.resolve().then(function(){return Ma});return(await r.from({contractId:e,rpcUrl:this.serverURL.toString(),networkPassphrase:n,server:this})).spec.funcs().map(e=>{const t=e.doc().toString(),n={name:e.name().toString(),inputs:e.inputs().map(e=>({name:e.name().toString(),type:Yi(e.type())})),outputs:e.outputs().map(Yi)};return t&&(n.doc=t),n})}getLedgerEntries(...e){return this._getLedgerEntries(...e).then($i)}_getLedgerEntries(...e){return Di(this.httpClient,this.serverURL.toString(),"getLedgerEntries",{keys:e.map(e=>e.toXDR("base64"))})}async getLedgerEntry(e){const t=await this._getLedgerEntries(e).then($i);if(1!==t.entries.length)throw new Error(`failed to find an entry for key ${e.toXDR("base64")}`);return t.entries[0]}async pollTransaction(e,t){const n=(t?.attempts??0)<1?30:t?.attempts??30;let r;for(let o=1;o<=n;o++){if(r=await this.getTransaction(e),r.status!==Vi.GetTransactionStatus.NOT_FOUND)return r;await Po.sleep((t?.sleepStrategy??ji)(o))}return r}async getTransaction(e){return this._getTransaction(e).then(t=>{const n={};t.status!==Vi.GetTransactionStatus.NOT_FOUND&&Object.assign(n,qi(t));return{status:t.status,txHash:e,latestLedger:t.latestLedger,latestLedgerCloseTime:t.latestLedgerCloseTime,oldestLedger:t.oldestLedger,oldestLedgerCloseTime:t.oldestLedgerCloseTime,...n}})}async _getTransaction(e){return Di(this.httpClient,this.serverURL.toString(),"getTransaction",{hash:e})}async getTransactions(e){return this._getTransactions(e).then(e=>({transactions:(e.transactions||[]).map(Hi),latestLedger:e.latestLedger,latestLedgerCloseTimestamp:e.latestLedgerCloseTimestamp,oldestLedger:e.oldestLedger,oldestLedgerCloseTimestamp:e.oldestLedgerCloseTimestamp,cursor:e.cursor}))}async _getTransactions(e){return Di(this.httpClient,this.serverURL.toString(),"getTransactions",e)}async getEvents(e){return this._getEvents(e).then(Gi)}async _getEvents(e){return Di(this.httpClient,this.serverURL.toString(),"getEvents",{filters:e.filters??[],pagination:{...e.cursor&&{cursor:e.cursor},...e.limit&&{limit:e.limit}},...e.startLedger&&{startLedger:e.startLedger},...e.endLedger&&{endLedger:e.endLedger}})}async getNetwork(){return Di(this.httpClient,this.serverURL.toString(),"getNetwork")}async getLatestLedger(){return this._getLatestLedger().then(Wi)}async _getLatestLedger(){return Di(this.httpClient,this.serverURL.toString(),"getLatestLedger")}async simulateTransaction(e,t,n){return this._simulateTransaction(e,t,n).then(Xi)}async _simulateTransaction(e,t,n){return Di(this.httpClient,this.serverURL.toString(),"simulateTransaction",{transaction:e.toXDR(),authMode:n,...void 0!==t&&{resourceConfig:{instructionLeeway:t.cpuInstructions}}})}async prepareTransaction(e){const t=await this.simulateTransaction(e);if(Vi.isSimulationError(t))throw new Error(t.error);return Zi(e,t).build()}async sendTransaction(e){return this._sendTransaction(e).then(Mi)}async _sendTransaction(e){return Di(this.httpClient,this.serverURL.toString(),"sendTransaction",{transaction:e.toXDR()})}async requestAirdrop(e,t){const n="string"==typeof e?e:e.accountId();if(!(t=t||(await this.getNetwork()).friendbotUrl))throw new Error("No friendbot URL configured for current network");try{const r=await this.httpClient.post(`${t}?addr=${encodeURIComponent(n)}`);let o;if(r.data.result_meta_xdr)o=P.TransactionMeta.fromXDR(r.data.result_meta_xdr,"base64");else{const t=await this.getTransaction(r.data.hash);if(t.status!==Vi.GetTransactionStatus.SUCCESS)throw new Error(`Funding account ${e} failed`);o=t.resultMetaXdr}const s=function(e){let t=[];switch(e.switch()){case 0:t=e.operations();break;case 1:case 2:case 3:case 4:t=e.value().operations();break;default:throw new Error("Unexpected transaction meta switch value")}const n=t.flatMap(e=>e.changes()).find(e=>e.switch()===P.LedgerEntryChangeType.ledgerEntryCreated()&&e.created().data().switch()===P.LedgerEntryType.account())?.created()?.data()?.account()?.seqNum()?.toString();if(n)return n;throw new Error("No account created in transaction")}(o);return new Vr(n,s)}catch(e){if(400===e.response?.status&&e.response.data?.detail?.includes("createAccountAlreadyExist"))return this.getAccount(n);throw e}}async fundAddress(e,t){if(!$t.isValidEd25519PublicKey(e)&&!$t.isValidContract(e))throw new Error(`Invalid address: ${e}. Expected a Stellar account (G...) or contract (C...) address.`);if(!(t=t||(await this.getNetwork()).friendbotUrl))throw new Error("No friendbot URL configured for current network");try{const n=await this.httpClient.post(`${t}?addr=${encodeURIComponent(e)}`),r=await this.getTransaction(n.data.hash);if(r.status!==Vi.GetTransactionStatus.SUCCESS)throw new Error(`Funding address ${e} failed: transaction status ${r.status}`);return r}catch(e){if(400===e.response?.status)throw new Error(e.response.data?.detail??"Bad Request");throw e}}async getFeeStats(){return Di(this.httpClient,this.serverURL.toString(),"getFeeStats")}async getVersionInfo(){return Di(this.httpClient,this.serverURL.toString(),"getVersionInfo")}async getSACBalance(e,t,n){const r=e instanceof Ar?e.toString():e;if(!$t.isValidContract(r))throw new TypeError(`expected contract ID, got ${r}`);const o=n??await this.getNetwork().then(e=>e.passphrase),s=t.contractId(o),i=Yr(["Balance",r],{type:["symbol","address"]}),a=P.LedgerKey.contractData(new P.LedgerKeyContractData({contract:new Ar(s).toScAddress(),durability:P.ContractDataDurability.persistent(),key:i})),c=await this.getLedgerEntries(a);if(0===c.entries.length)return{latestLedger:c.latestLedger};const{lastModifiedLedgerSeq:u,liveUntilLedgerSeq:l,val:d}=c.entries[0];if(d.switch().value!==P.LedgerEntryType.contractData().value)return{latestLedger:c.latestLedger};const p=Jr(d.contractData().val());return{latestLedger:c.latestLedger,balanceEntry:{liveUntilLedgerSeq:l,lastModifiedLedgerSeq:u,amount:p.amount.toString(),authorized:p.authorized,clawback:p.clawback}}}async getLedgers(e){return this._getLedgers(e).then(e=>({ledgers:(e.ledgers||[]).map(Ki),latestLedger:e.latestLedger,latestLedgerCloseTime:e.latestLedgerCloseTime,oldestLedger:e.oldestLedger,oldestLedgerCloseTime:e.oldestLedgerCloseTime,cursor:e.cursor}))}async _getLedgers(e){return Di(this.httpClient,this.serverURL.toString(),"getLedgers",e)}}var Qi=Object.freeze({__proto__:null,get Api(){return Vi},BasicSleepStrategy:ji,Durability:zi,LinearSleepStrategy:e=>1e3*e,Server:Ji,assembleTransaction:Zi,parseRawEvents:Gi,parseRawSimulation:Xi});class ea{constructor(e){this.value=e}value;unwrapErr(){throw new Error("No error")}unwrap(){return this.value}isOk(){return!0}isErr(){return!1}}class ta{constructor(e){this.error=e}error;unwrapErr(){return this.error}unwrap(){throw new Error(this.error.message)}isOk(){return!1}isErr(){return!0}}const na=300,ra="GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";const oa=/Error\(Contract, #(\d+)\)/;function sa(e){const t=new O.XdrReader(e),n=[];for(;!t.eof;)n.push(P.ScSpecEntry.read(t));return n}async function ia(e,t){return e.publicKey?t.getAccount(e.publicKey):new Vr(ra,"0")}class aa{constructor(e){this.assembled=e;const{server:t,allowHttp:n,headers:r,rpcUrl:o}=this.assembled.options;this.server=t??new Ji(o,{allowHttp:n,headers:r})}assembled;server;sendTransactionResponse;getTransactionResponseAll;getTransactionResponse;static Errors={SendFailed:class extends Error{},SendResultOnly:class extends Error{},TransactionStillPending:class extends Error{}};static init=async(e,t)=>{const n=new aa(e);return await n.send(t)};send=async e=>{if(this.sendTransactionResponse=await this.server.sendTransaction(this.assembled.signed),"PENDING"!==this.sendTransactionResponse.status)throw new aa.Errors.SendFailed(`Sending the transaction to the network failed!\n${JSON.stringify(this.sendTransactionResponse,null,2)}`);e?.onSubmitted&&e.onSubmitted(this.sendTransactionResponse);const{hash:t}=this.sendTransactionResponse,n=this.assembled.options.timeoutInSeconds??na;if(this.getTransactionResponseAll=await async function(e,t,n,r=1.5,o=!1){const s=[];let i=0;if(s.push(await e()),!t(s[s.length-1]))return s;const a=new Date(Date.now()+1e3*n).valueOf();let c=1e3,u=c;for(;Date.now()<a&&t(s[s.length-1]);)i+=1,o&&console.info(`Waiting ${c}ms before trying again (bringing the total wait time to ${u}ms so far, of total ${1e3*n}ms)`),await new Promise(e=>setTimeout(e,c)),c*=r,new Date(Date.now()+c).valueOf()>a&&(c=a-Date.now(),o&&console.info(`was gonna wait too long; new waitTime: ${c}ms`)),u=c+u,s.push(await e(s[s.length-1])),o&&t(s[s.length-1])&&console.info(`${i}. Called ${e}; ${s.length} prev attempts. Most recent: ${JSON.stringify(s[s.length-1],null,2)}`);return s}(async()=>{const n=await this.server.getTransaction(t);return e?.onProgress&&e.onProgress(n),n},e=>e.status===Vi.GetTransactionStatus.NOT_FOUND,n),this.getTransactionResponse=this.getTransactionResponseAll[this.getTransactionResponseAll.length-1],this.getTransactionResponse.status===Vi.GetTransactionStatus.NOT_FOUND)throw new aa.Errors.TransactionStillPending(`Waited ${n} seconds for transaction to complete, but it did not. Returning anyway. Check the transaction status manually. Sent transaction: ${JSON.stringify(this.sendTransactionResponse,null,2)}\nAll attempts to get the result: ${JSON.stringify(this.getTransactionResponseAll,null,2)}`);return this};get result(){if("getTransactionResponse"in this&&this.getTransactionResponse){if("returnValue"in this.getTransactionResponse)return this.assembled.options.parseResultXdr(this.getTransactionResponse.returnValue);throw new Error("Transaction failed! Cannot parse result.")}if(this.sendTransactionResponse){const e=this.sendTransactionResponse.errorResult?.result();if(e)throw new aa.Errors.SendFailed(`Transaction simulation looked correct, but attempting to send the transaction failed. Check \`simulation\` and \`sendTransactionResponseAll\` to troubleshoot. Decoded \`sendTransactionResponse.errorResultXdr\`: ${e}`);throw new aa.Errors.SendResultOnly("Transaction was sent to the network, but not yet awaited. No result to show. Await transaction completion with `getTransaction(sendTransactionResponse.hash)`")}throw new Error(`Sending transaction failed: ${JSON.stringify(this.assembled.signed)}`)}}class ca extends Error{}class ua extends Error{}class la extends Error{}class da extends Error{}class pa extends Error{}class ha extends Error{}class fa extends Error{}class ma extends Error{}class ga extends Error{}class ya extends Error{}class wa extends Error{}class Aa extends Error{}class Sa extends Error{}class ba{constructor(e){this.options=e,this.options.simulate=this.options.simulate??!0;const{server:t,allowHttp:n,headers:r,rpcUrl:o}=this.options;this.server=t??new Ji(o,{allowHttp:n,headers:r})}options;raw;originalOp;built;simulation;simulationResult;simulationTransactionData;server;signed;static Errors={ExpiredState:ca,RestorationFailure:ua,NeedsMoreSignatures:la,NoSignatureNeeded:da,NoUnsignedNonInvokerAuthEntries:pa,NoSigner:ha,NotYetSimulated:fa,FakeAccount:ma,SimulationFailed:ga,InternalWalletError:ya,ExternalServiceError:wa,InvalidClientRequest:Aa,UserRejected:Sa};toJSON(){return JSON.stringify({method:this.options.method,tx:this.built?.toXDR(),simulationResult:{auth:this.simulationData.result.auth.map(e=>e.toXDR("base64")),retval:this.simulationData.result.retval.toXDR("base64")},simulationTransactionData:this.simulationData.transactionData.toXDR("base64")})}static validateInvokeContractOp(e,t){if(1!==e.operations.length)throw new Error("Transaction envelope must contain exactly one operation.");const n=e.operations[0];if("invokeHostFunction"!==n.type)throw new Error("Transaction envelope does not contain an invokeHostFunction operation.");const r=n;if("hostFunctionTypeInvokeContract"!==r.func.switch().name)throw new Error("Transaction envelope does not contain an invokeContract host function.");const o=r.func.value();let s,i;try{s=o.contractAddress(),i=o.functionName().toString("utf-8")}catch{throw new Error("Could not extract contract address or method name from the transaction envelope.")}if(!s||!i)throw new Error("Could not extract contract address or method name from the transaction envelope.");const a=Ar.fromScAddress(s).toString();if(a!==t)throw new Error(`Transaction envelope targets contract ${a}, but this Client is configured for ${t}.`);return o}static fromJSON(e,{tx:t,simulationResult:n,simulationTransactionData:r}){const o=new ba(e);o.built=ro.fromXDR(t,e.networkPassphrase);const s=ba.validateInvokeContractOp(o.built,e.contractId).functionName().toString("utf-8");if(s!==e.method)throw new Error(`Transaction envelope calls method '${s}', but the provided method is '${e.method}'.`);return o.simulationResult={auth:n.auth.map(e=>P.SorobanAuthorizationEntry.fromXDR(e,"base64")),retval:P.ScVal.fromXDR(n.retval,"base64")},o.simulationTransactionData=P.SorobanTransactionData.fromXDR(r,"base64"),o}toXDR(){if(!this.built)throw new Error("Transaction has not yet been simulated; call `AssembledTransaction.simulate` first.");return this.built?.toEnvelope().toXDR("base64")}static fromXDR(e,t,n){const r=P.TransactionEnvelope.fromXDR(t,"base64"),o=ro.fromXDR(r,e.networkPassphrase),s=ba.validateInvokeContractOp(o,e.contractId).functionName().toString("utf-8"),i=new ba({...e,method:s,parseResultXdr:e=>n.funcResToNative(s,e)});return i.built=o,i}handleWalletError(e){if(!e)return;const{message:t,code:n}=e,r=`${t}${e.ext?` (${e.ext.join(", ")})`:""}`;switch(n){case-1:throw new ba.Errors.InternalWalletError(r);case-2:throw new ba.Errors.ExternalServiceError(r);case-3:throw new ba.Errors.InvalidClientRequest(r);case-4:throw new ba.Errors.UserRejected(r);default:throw new Error(`Unhandled error: ${r}`)}}static build(e){const t=new Gr(e.contractId);return ba.buildWithOp(t.call(e.method,...e.args??[]),e)}static async buildWithOp(e,t){const n=new ba(t);n.originalOp=e;const r=await ia(t,n.server);return n.raw=new ro(r,{fee:t.fee??no,networkPassphrase:t.networkPassphrase}).setTimeout(t.timeoutInSeconds??na).addOperation(e),t.simulate&&await n.simulate(),n}static async buildFootprintRestoreTransaction(e,t,n,r){const o=new ba(e);return o.raw=new ro(n,{fee:r,networkPassphrase:e.networkPassphrase}).setSorobanData(t instanceof qr?t.build():t).addOperation(Cr.restoreFootprint({})).setTimeout(e.timeoutInSeconds??na),await o.simulate({restore:!1}),o}simulate=async({restore:e}={})=>{if(!this.built){if(!this.raw)throw new Error("Transaction has not yet been assembled; call `AssembledTransaction.build` first.");this.built=this.raw.build()}if(e=e??this.options.restore,delete this.simulationResult,delete this.simulationTransactionData,this.simulation=await this.server.simulateTransaction(this.built),e&&Vi.isSimulationRestore(this.simulation)){const e=await ia(this.options,this.server),t=await this.restoreFootprint(this.simulation.restorePreamble,e);if(t.status===Vi.GetTransactionStatus.SUCCESS){const t=this.originalOp?this.originalOp:new Gr(this.options.contractId).call(this.options.method,...this.options.args??[]);return this.raw=new ro(e,{fee:this.options.fee??no,networkPassphrase:this.options.networkPassphrase}).addOperation(t).setTimeout(this.options.timeoutInSeconds??na),delete this.built,await this.simulate(),this}throw new ba.Errors.RestorationFailure(`Automatic restore failed! You set 'restore: true' but the attempted restore did not work. Result:\n${JSON.stringify(t)}`)}return Vi.isSimulationSuccess(this.simulation)&&(this.built=Zi(this.built,this.simulation).build()),this};get simulationData(){if(this.simulationResult&&this.simulationTransactionData)return{result:this.simulationResult,transactionData:this.simulationTransactionData};const e=this.simulation;if(!e)throw new ba.Errors.NotYetSimulated("Transaction has not yet been simulated");if(Vi.isSimulationError(e))throw new ba.Errors.SimulationFailed(`Transaction simulation failed: "${e.error}"`);if(Vi.isSimulationRestore(e))throw new ba.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\nYou can set `restore` to true in the method options in order to automatically restore the contract state when needed.");return this.simulationResult=e.result??{auth:[],retval:P.ScVal.scvVoid()},this.simulationTransactionData=e.transactionData.build(),{result:this.simulationResult,transactionData:this.simulationTransactionData}}get result(){try{if(!this.simulationData.result)throw new Error("No simulation result!");return this.options.parseResultXdr(this.simulationData.result.retval)}catch(t){if("object"!=typeof(e=t)||null===e||!("toString"in e))throw t;const n=this.parseError(t.toString());if(n)return n;throw t}var e}parseError(e){if(!this.options.errorTypes)return;const t=e.match(oa);if(!t)return;const n=parseInt(t[1],10),r=this.options.errorTypes[n];return r?new ta(r):void 0}sign=async({force:e=!1,signTransaction:t=this.options.signTransaction}={})=>{if(!this.built)throw new Error("Transaction has not yet been simulated");if(!e&&this.isReadCall)throw new ba.Errors.NoSignatureNeeded("This is a read call. It requires no signature or sending. Use `force: true` to sign and send anyway.");if(!t)throw new ba.Errors.NoSigner("You must provide a signTransaction function, either when calling `signAndSend` or when initializing your Client");if(!this.options.publicKey)throw new ba.Errors.FakeAccount("This transaction was constructed using a default account. Provide a valid publicKey in the AssembledTransactionOptions.");const n=this.needsNonInvokerSigningBy().filter(e=>!e.startsWith("C"));if(n.length)throw new ba.Errors.NeedsMoreSignatures(`Transaction requires signatures from ${n}. See \`needsNonInvokerSigningBy\` for details.`);const r=this.options.timeoutInSeconds??na;this.built=ro.cloneFrom(this.built,{fee:this.built.fee,timebounds:void 0,sorobanData:this.simulationData.transactionData}).setTimeout(r).build();const o={networkPassphrase:this.options.networkPassphrase};this.options.address&&(o.address=this.options.address),void 0!==this.options.submit&&(o.submit=this.options.submit),this.options.submitUrl&&(o.submitUrl=this.options.submitUrl);const{signedTxXdr:s,error:i}=await t(this.built.toXDR(),o);this.handleWalletError(i),this.signed=ro.fromXDR(s,this.options.networkPassphrase)};async send(e){if(!this.signed)throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");return await aa.init(this,e)}signAndSend=async({force:e=!1,signTransaction:t=this.options.signTransaction,watcher:n}={})=>{if(!this.signed){const n=t||this.options.signTransaction,r=this.options.submit&&n?(e,t)=>n(e,{...t,submit:!1}):t;await this.sign({force:e,signTransaction:r})}return this.send(n)};needsNonInvokerSigningBy=({includeAlreadySigned:e=!1}={})=>{if(!this.built)throw new Error("Transaction has not yet been simulated");if(!("operations"in this.built))throw new Error(`Unexpected Transaction type; no operations: ${JSON.stringify(this.built)}`);const t=this.built.operations[0];return[...new Set((t.auth??[]).map(e=>Ao(e)).filter(t=>null!==t.address&&(e||!t.signers[0].signed)).map(e=>e.address))]};signAuthEntries=async({expiration:e=(async()=>(await this.server.getLatestLedger()).sequence+100)(),signAuthEntry:t=this.options.signAuthEntry,address:n=this.options.publicKey,authorizeEntry:r=po}={})=>{if(!this.built)throw new Error("Transaction has not yet been assembled or simulated");if(r===po){const e=this.needsNonInvokerSigningBy();if(0===e.length)throw new ba.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");if(-1===e.indexOf(n??""))throw new ba.Errors.NoSignatureNeeded(`No auth entries for public key "${n}"`);if(!t)throw new ba.Errors.NoSigner("You must provide `signAuthEntry` or a custom `authorizeEntry`")}const o=this.built.operations[0].auth??[];for(const[s,i]of o.entries()){const a=yo(P.SorobanCredentials.fromXDR(i.credentials().toXDR()));if(null===a)continue;if(Ar.fromScAddress(a.address()).toString()!==n)continue;const c=t??Promise.resolve;o[s]=await r(i,async e=>{const{signedAuthEntry:t,error:r}=await c(e.toXDR("base64"),{address:n});return this.handleWalletError(r),q.Buffer.from(t,"base64")},await e,this.options.networkPassphrase)}};get isReadCall(){const e=this.simulationData.result.auth.length,t=this.simulationData.transactionData.resources().footprint().readWrite().length;return 0===e&&0===t}async restoreFootprint(e,t){if(!this.options.signTransaction)throw new Error("For automatic restore to work you must provide a signTransaction function when initializing your Client");t=t??await ia(this.options,this.server);const n=await ba.buildFootprintRestoreTransaction({...this.options},e.transactionData,t,e.minResourceFee),r=await n.signAndSend();if(!r.getTransactionResponse)throw new ba.Errors.RestorationFailure(`The attempt at automatic restore failed. \n${JSON.stringify(r)}`);return r.getTransactionResponse}}function va(e){const t=function(e){const t=new Map,n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let r=0;const o=t=>{if(r+t>e.byteLength)throw new Error("Buffer overflow");const o=new Uint8Array(n,r,t);return r+=t,o};function s(){let e=0,t=0;for(;;){const n=o(1)[0];if(e|=(127&n)<<t,!(128&n))break;if((t+=7)>=32)throw new Error("Invalid WASM value")}return e>>>0}if("0,97,115,109"!==[...o(4)].join())throw new Error("Invalid WASM magic");if("1,0,0,0"!==[...o(4)].join())throw new Error("Invalid WASM version");for(;r<e.byteLength;){const e=o(1)[0],n=s(),i=r;if(0===e){const e=s();if(e>0&&r+e<=i+n){const s=o(e),a=o(n-(r-i));try{const e=new TextDecoder("utf-8",{fatal:!0}).decode(s);a.length>0&&t.set(e,(t.get(e)||[]).concat(a))}catch{}}}r=i+n}return t}(e),n=t.get("contractspecv0");if(!n||0===n.length)throw new Error("Could not obtain contract spec from wasm");return q.Buffer.from(n[0])}function Ta(e){return/^\d+$/.test(e.name().toString())}const Ea={U32:{type:"integer",minimum:0,maximum:4294967295},I32:{type:"integer",minimum:-2147483648,maximum:2147483647},U64:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},Timepoint:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},Duration:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:20},I64:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:21},U128:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:39},I128:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:40},U256:{type:"string",pattern:"^([1-9][0-9]*|0)$",minLength:1,maxLength:78},I256:{type:"string",pattern:"^(-?[1-9][0-9]*|0)$",minLength:1,maxLength:79},Address:{type:"string",format:"address",description:"Address can be a public key or contract id"},MuxedAddress:{type:"string",format:"address",description:"Stellar public key with M prefix combining a G address and unique ID"},ScString:{type:"string",description:"ScString is a string"},ScSymbol:{type:"string",description:"ScSymbol is a string"},DataUrl:{type:"string",pattern:"^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$"}};function ka(e){let t;switch(e.switch().value){case P.ScSpecType.scSpecTypeVal().value:t="Val";break;case P.ScSpecType.scSpecTypeBool().value:return{type:"boolean"};case P.ScSpecType.scSpecTypeVoid().value:return{type:"null"};case P.ScSpecType.scSpecTypeError().value:t="Error";break;case P.ScSpecType.scSpecTypeU32().value:t="U32";break;case P.ScSpecType.scSpecTypeI32().value:t="I32";break;case P.ScSpecType.scSpecTypeU64().value:t="U64";break;case P.ScSpecType.scSpecTypeI64().value:t="I64";break;case P.ScSpecType.scSpecTypeTimepoint().value:t="Timepoint";break;case P.ScSpecType.scSpecTypeDuration().value:t="Duration";break;case P.ScSpecType.scSpecTypeU128().value:t="U128";break;case P.ScSpecType.scSpecTypeI128().value:t="I128";break;case P.ScSpecType.scSpecTypeU256().value:t="U256";break;case P.ScSpecType.scSpecTypeI256().value:t="I256";break;case P.ScSpecType.scSpecTypeBytes().value:t="DataUrl";break;case P.ScSpecType.scSpecTypeString().value:t="ScString";break;case P.ScSpecType.scSpecTypeSymbol().value:t="ScSymbol";break;case P.ScSpecType.scSpecTypeAddress().value:t="Address";break;case P.ScSpecType.scSpecTypeMuxedAddress().value:t="MuxedAddress";break;case P.ScSpecType.scSpecTypeOption().value:return ka(e.option().valueType());case P.ScSpecType.scSpecTypeResult().value:return ka(e.result().okType());case P.ScSpecType.scSpecTypeVec().value:return{type:"array",items:ka(e.vec().elementType())};case P.ScSpecType.scSpecTypeMap().value:{const t=e.map();return{type:"array",items:{type:"array",items:[ka(t.keyType()),ka(t.valueType())],minItems:2,maxItems:2}}}case P.ScSpecType.scSpecTypeTuple().value:{const t=e.tuple(),n=t.valueTypes().length,r=n;return{type:"array",items:t.valueTypes().map(ka),minItems:n,maxItems:r}}case P.ScSpecType.scSpecTypeBytesN().value:return{$ref:"#/definitions/DataUrl",maxLength:e.bytesN().n()};case P.ScSpecType.scSpecTypeUdt().value:t=e.udt().name().toString();break}return{$ref:`#/definitions/${t}`}}function Ia(e){const t={},n=[];e.forEach(e=>{const r=e.type(),o=e.name().toString();t[o]=ka(r),r.switch().value!==P.ScSpecType.scSpecTypeOption().value&&n.push(o)});const r={properties:t};return n.length>0&&(r.required=n),r}class Ca{entries=[];static fromWasm(e){const t=va(e);return new Ca(t)}constructor(e){if(q.Buffer.isBuffer(e))this.entries=sa(e);else if("string"==typeof e)this.entries=sa(q.Buffer.from(e,"base64"));else{if(0===e.length)throw new Error("Contract spec must have at least one entry");const t=e[0];this.entries="string"==typeof t?e.map(e=>P.ScSpecEntry.fromXDR(e,"base64")):e}}funcs(){return this.entries.filter(e=>e.switch().value===P.ScSpecEntryKind.scSpecEntryFunctionV0().value).map(e=>e.functionV0())}getFunc(e){const t=this.findEntry(e);if(t.switch().value!==P.ScSpecEntryKind.scSpecEntryFunctionV0().value)throw new Error(`${e} is not a function`);return t.functionV0()}funcArgsToScVals(e,t){return this.getFunc(e).inputs().map(e=>this.nativeToScVal(function(e,t){const n=t.name().toString(),r=Object.entries(e).find(([e])=>e===n);if(!r)throw new Error(`Missing field ${n}`);return r[1]}(t,e),e.type()))}funcResToNative(e,t){const n="string"==typeof t?P.ScVal.fromXDR(t,"base64"):t,r=this.getFunc(e).outputs();if(0===r.length){const e=n.switch();if(e.value!==P.ScValType.scvVoid().value)throw new Error(`Expected void, got ${e.name}`);return null}if(r.length>1)throw new Error("Multiple outputs not supported");const o=r[0];return o.switch().value===P.ScSpecType.scSpecTypeResult().value?n.switch().value===P.ScValType.scvError().value?new ta({message:n.error().toXDR("base64")}):new ea(this.scValToNative(n,o.result().okType())):this.scValToNative(n,o)}findEntry(e){const t=this.entries.find(t=>t.value().name().toString()===e);if(!t)throw new Error(`no such entry: ${e}`);return t}nativeToScVal(e,t){const n=t.switch(),r=n.value;if(n.value===P.ScSpecType.scSpecTypeUdt().value){const n=t.udt();return this.nativeToUdt(e,n.name().toString())}if(r===P.ScSpecType.scSpecTypeOption().value){const n=t.option();return null==e?P.ScVal.scvVoid():this.nativeToScVal(e,n.valueType())}if(r===P.ScSpecType.scSpecTypeVal().value)return Yr(e);switch(typeof e){case"object":{if(null===e){if(r===P.ScSpecType.scSpecTypeVoid().value)return P.ScVal.scvVoid();throw new TypeError(`Type ${t} was not void, but value was null`)}if(e instanceof P.ScVal)return e;if(e instanceof Ar){if(t.switch().value!==P.ScSpecType.scSpecTypeAddress().value)throw new TypeError(`Type ${t} was not address, but value was Address`);return e.toScVal()}if(e instanceof Gr){if(t.switch().value!==P.ScSpecType.scSpecTypeAddress().value)throw new TypeError(`Type ${t} was not address, but value was Address`);return e.address().toScVal()}if(e instanceof Uint8Array||q.Buffer.isBuffer(e)){const n=Uint8Array.from(e);switch(r){case P.ScSpecType.scSpecTypeBytesN().value:{const e=t.bytesN();if(n.length!==e.n())throw new TypeError(`expected ${e.n()} bytes, but got ${n.length}`);return P.ScVal.scvBytes(n)}case P.ScSpecType.scSpecTypeBytes().value:return P.ScVal.scvBytes(n);default:throw new TypeError(`invalid type (${t}) specified for Bytes and BytesN`)}}if(Array.isArray(e))switch(r){case P.ScSpecType.scSpecTypeVec().value:{const n=t.vec().elementType();return P.ScVal.scvVec(e.map(e=>this.nativeToScVal(e,n)))}case P.ScSpecType.scSpecTypeTuple().value:{const n=t.tuple().valueTypes();if(e.length!==n.length)throw new TypeError(`Tuple expects ${n.length} values, but ${e.length} were provided`);return P.ScVal.scvVec(e.map((e,t)=>this.nativeToScVal(e,n[t])))}case P.ScSpecType.scSpecTypeMap().value:{const n=t.map(),r=n.keyType(),o=n.valueType();return P.ScVal.scvMap(e.map(e=>{const t=this.nativeToScVal(e[0],r),n=this.nativeToScVal(e[1],o);return new P.ScMapEntry({key:t,val:n})}))}default:throw new TypeError(`Type ${t} was not vec, but value was Array`)}if(e instanceof Map){if(r!==P.ScSpecType.scSpecTypeMap().value)throw new TypeError(`Type ${t} was not map, but value was Map`);const n=t.map(),o=[],s=e.entries();let i=s.next();for(;!i.done;){const[e,t]=i.value,r=this.nativeToScVal(e,n.keyType()),a=this.nativeToScVal(t,n.valueType());o.push(new P.ScMapEntry({key:r,val:a})),i=s.next()}return P.ScVal.scvMap(o)}const n=Object.getPrototypeOf(e);if(n!==Object.prototype&&null!==n)throw new TypeError(`cannot interpret ${e.constructor?.name} value as ScVal (${JSON.stringify(e)})`);throw new TypeError(`Received object ${e} did not match the provided type ${t}`)}case"number":case"bigint":switch(r){case P.ScSpecType.scSpecTypeU32().value:if(BigInt(e)<BigInt(P.Uint32.MIN_VALUE)||BigInt(e)>BigInt(P.Uint32.MAX_VALUE))throw new RangeError(`Value ${e} is out of range for U32`);return P.ScVal.scvU32(Number(e));case P.ScSpecType.scSpecTypeI32().value:if(BigInt(e)<-BigInt(P.Int32.MIN_VALUE)||BigInt(e)>BigInt(P.Int32.MAX_VALUE))throw new RangeError(`Value ${e} is out of range for I32`);return P.ScVal.scvI32(Number(e));case P.ScSpecType.scSpecTypeU64().value:case P.ScSpecType.scSpecTypeI64().value:case P.ScSpecType.scSpecTypeU128().value:case P.ScSpecType.scSpecTypeI128().value:case P.ScSpecType.scSpecTypeU256().value:case P.ScSpecType.scSpecTypeI256().value:case P.ScSpecType.scSpecTypeTimepoint().value:case P.ScSpecType.scSpecTypeDuration().value:{const t=n.name.substring(10).toLowerCase();return new Zr(t,e).toScVal()}default:throw new TypeError(`invalid type (${t}) specified for integer`)}case"string":return function(e,t){switch(t.value){case P.ScSpecType.scSpecTypeString().value:return P.ScVal.scvString(e);case P.ScSpecType.scSpecTypeSymbol().value:return P.ScVal.scvSymbol(e);case P.ScSpecType.scSpecTypeAddress().value:case P.ScSpecType.scSpecTypeMuxedAddress().value:return Ar.fromString(e).toScVal();case P.ScSpecType.scSpecTypeU64().value:return new Zr("u64",e).toScVal();case P.ScSpecType.scSpecTypeI64().value:return new Zr("i64",e).toScVal();case P.ScSpecType.scSpecTypeU128().value:return new Zr("u128",e).toScVal();case P.ScSpecType.scSpecTypeI128().value:return new Zr("i128",e).toScVal();case P.ScSpecType.scSpecTypeU256().value:return new Zr("u256",e).toScVal();case P.ScSpecType.scSpecTypeI256().value:return new Zr("i256",e).toScVal();case P.ScSpecType.scSpecTypeBytes().value:case P.ScSpecType.scSpecTypeBytesN().value:return P.ScVal.scvBytes(q.Buffer.from(e,"base64"));case P.ScSpecType.scSpecTypeTimepoint().value:return P.ScVal.scvTimepoint(new P.Uint64(e));case P.ScSpecType.scSpecTypeDuration().value:return P.ScVal.scvDuration(new P.Uint64(e));default:throw new TypeError(`invalid type ${t.name} specified for string value`)}}(e,n);case"boolean":if(r!==P.ScSpecType.scSpecTypeBool().value)throw TypeError(`Type ${t} was not bool, but value was bool`);return P.ScVal.scvBool(e);case"undefined":if(!t)return P.ScVal.scvVoid();switch(r){case P.ScSpecType.scSpecTypeVoid().value:case P.ScSpecType.scSpecTypeOption().value:return P.ScVal.scvVoid();default:throw new TypeError(`Type ${t} was not void, but value was undefined`)}case"function":return this.nativeToScVal(e(),t);default:throw new TypeError(`failed to convert typeof ${typeof e} (${e})`)}}nativeToUdt(e,t){const n=this.findEntry(t);switch(n.switch()){case P.ScSpecEntryKind.scSpecEntryUdtEnumV0():if("number"!=typeof e)throw new TypeError(`expected number for enum ${t}, but got ${typeof e}`);return this.nativeToEnum(e,n.udtEnumV0());case P.ScSpecEntryKind.scSpecEntryUdtStructV0():return this.nativeToStruct(e,n.udtStructV0());case P.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.nativeToUnion(e,n.udtUnionV0());default:throw new Error(`failed to parse udt ${t}`)}}nativeToUnion(e,t){const n=e.tag,r=t.cases().find(e=>e.value().name().toString()===n);if(!r)throw new TypeError(`no such enum entry: ${n} in ${t}`);const o=P.ScVal.scvSymbol(n);switch(r.switch()){case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0():return P.ScVal.scvVec([o]);case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0():{const n=r.tupleCase().type();if(Array.isArray(e.values)){if(e.values.length!==n.length)throw new TypeError(`union ${t} expects ${n.length} values, but got ${e.values.length}`);const r=e.values.map((e,t)=>this.nativeToScVal(e,n[t]));return r.unshift(o),P.ScVal.scvVec(r)}throw new Error(`failed to parse union case ${r} with ${e}`)}default:throw new Error(`failed to parse union ${t} with ${e}`)}}nativeToStruct(e,t){const n=t.fields();if(n.some(Ta)){if(!n.every(Ta))throw new Error("mixed numeric and non-numeric field names are not allowed");return P.ScVal.scvVec(n.map((t,r)=>this.nativeToScVal(e[r],n[r].type())))}return P.ScVal.scvMap(n.map(t=>{const n=t.name().toString();return new P.ScMapEntry({key:this.nativeToScVal(n,P.ScSpecTypeDef.scSpecTypeSymbol()),val:this.nativeToScVal(e[n],t.type())})}))}nativeToEnum(e,t){if(t.cases().some(t=>t.value()===e))return P.ScVal.scvU32(e);throw new TypeError(`no such enum entry: ${e} in ${t}`)}scValStrToNative(e,t){return this.scValToNative(P.ScVal.fromXDR(e,"base64"),t)}scValToNative(e,t){const n=t.switch(),r=n.value;if(r===P.ScSpecType.scSpecTypeOption().value)return e.switch().value===P.ScValType.scvVoid().value?null:this.scValToNative(e,t.option().valueType());if(r===P.ScSpecType.scSpecTypeUdt().value)return this.scValUdtToNative(e,t.udt());switch(e.switch().value){case P.ScValType.scvVoid().value:return null;case P.ScValType.scvU64().value:case P.ScValType.scvI64().value:case P.ScValType.scvTimepoint().value:case P.ScValType.scvDuration().value:case P.ScValType.scvU128().value:case P.ScValType.scvI128().value:case P.ScValType.scvU256().value:case P.ScValType.scvI256().value:return jr(e);case P.ScValType.scvVec().value:if(r===P.ScSpecType.scSpecTypeVec().value){const n=t.vec();return(e.vec()??[]).map(e=>this.scValToNative(e,n.elementType()))}if(r===P.ScSpecType.scSpecTypeTuple().value){const n=t.tuple().valueTypes();return(e.vec()??[]).map((e,t)=>this.scValToNative(e,n[t]))}throw new TypeError(`Type ${t} was not vec, but ${e} is`);case P.ScValType.scvAddress().value:return Ar.fromScVal(e).toString();case P.ScValType.scvMap().value:{const o=e.map()??[];if(r===P.ScSpecType.scSpecTypeMap().value){const e=t.map(),n=e.keyType(),r=e.valueType();return o.map(e=>[this.scValToNative(e.key(),n),this.scValToNative(e.val(),r)])}throw new TypeError(`ScSpecType ${n.name} was not map, but ${JSON.stringify(e,null,2)} is`)}case P.ScValType.scvBool().value:case P.ScValType.scvU32().value:case P.ScValType.scvI32().value:case P.ScValType.scvBytes().value:return e.value();case P.ScValType.scvString().value:case P.ScValType.scvSymbol().value:if(r!==P.ScSpecType.scSpecTypeString().value&&r!==P.ScSpecType.scSpecTypeSymbol().value)throw new Error(`ScSpecType ${n.name} was not string or symbol, but ${JSON.stringify(e,null,2)} is`);return e.value()?.toString();default:throw new TypeError(`failed to convert ${JSON.stringify(e,null,2)} to native type from type ${n.name}`)}}scValUdtToNative(e,t){const n=this.findEntry(t.name().toString());switch(n.switch()){case P.ScSpecEntryKind.scSpecEntryUdtEnumV0():return this.enumToNative(e);case P.ScSpecEntryKind.scSpecEntryUdtStructV0():return this.structToNative(e,n.udtStructV0());case P.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.unionToNative(e,n.udtUnionV0());default:throw new Error(`failed to parse udt ${t.name().toString()}: ${n}`)}}unionToNative(e,t){const n=e.vec();if(!n)throw new Error(`${JSON.stringify(e,null,2)} is not a vec`);if(0===n.length&&0!==t.cases.length)throw new Error(`${e} has length 0, but the there are at least one case in the union`);const r=n[0].sym().toString();if(n[0].switch().value!==P.ScValType.scvSymbol().value)throw new Error(`${n[0]} is not a symbol`);const o=t.cases().find(function(e){return function(t){switch(t.switch().value){case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value:return t.tupleCase().name().toString()===e;case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value:return t.voidCase().name().toString()===e;default:return!1}}}(r));if(!o)throw new Error(`failed to find entry ${r} in union ${t.name().toString()}`);const s={tag:r};if(o.switch().value===P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value){const e=o.tupleCase().type().map((e,t)=>this.scValToNative(n[t+1],e));s.values=e}return s}structToNative(e,t){const n={},r=t.fields();if(r.some(Ta)){const t=e.vec()?.map((e,t)=>this.scValToNative(e,r[t].type()));return t}return e.map()?.forEach((e,t)=>{const o=r[t];n[o.name().toString()]=this.scValToNative(e.val(),o.type())}),n}enumToNative(e){if(e.switch().value!==P.ScValType.scvU32().value)throw new Error("Enum must have a u32 value");return e.u32()}errorCases(){return this.entries.filter(e=>e.switch().value===P.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value).flatMap(e=>e.value().cases())}jsonSchema(e){const t={};this.entries.forEach(e=>{switch(e.switch().value){case P.ScSpecEntryKind.scSpecEntryUdtEnumV0().value:{const n=e.udtEnumV0();t[n.name().toString()]=function(e){const t=e.doc().toString(),n=e.cases(),r=[];n.forEach(e=>{const t=e.name().toString(),n=e.doc().toString();r.push({description:n,title:t,enum:[e.value()],type:"number"})});const o={oneOf:r};return t.length>0&&(o.description=t),o}(n);break}case P.ScSpecEntryKind.scSpecEntryUdtStructV0().value:{const n=e.udtStructV0();t[n.name().toString()]=function(e){const t=e.fields();if(t.some(Ta)){if(!t.every(Ta))throw new Error("mixed numeric and non-numeric field names are not allowed");return{type:"array",items:t.map((e,n)=>ka(t[n].type())),minItems:t.length,maxItems:t.length}}const n=e.doc().toString(),{properties:r,required:o}=Ia(t);return{description:n,properties:r,required:o,additionalProperties:!1,type:"object"}}(n);break}case P.ScSpecEntryKind.scSpecEntryUdtUnionV0().value:{const n=e.udtUnionV0();t[n.name().toString()]=function(e){const t=e.doc().toString(),n=e.cases(),r=[];n.forEach(e=>{switch(e.switch().value){case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value:{const t=e.voidCase().name().toString();r.push({type:"object",title:t,properties:{tag:t},additionalProperties:!1,required:["tag"]});break}case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value:{const t=e.tupleCase(),n=t.name().toString();r.push({type:"object",title:n,properties:{tag:n,values:{type:"array",items:t.type().map(ka)}},required:["tag","values"],additionalProperties:!1})}}});const o={oneOf:r};return t.length>0&&(o.description=t),o}(n);break}case P.ScSpecEntryKind.scSpecEntryFunctionV0().value:{const n=e.functionV0(),r=n.name().toString(),{input:o}=function(e){const{properties:t,required:n}=Ia(e.inputs()),r={additionalProperties:!1,properties:t,type:"object"};n?.length>0&&(r.required=n);const o={properties:{args:r}},s=e.outputs(),i=s.length>0?ka(s[0]):ka(P.ScSpecTypeDef.scSpecTypeVoid()),a=e.doc().toString();return a.length>0&&(o.description=a),o.additionalProperties=!1,i.additionalProperties=!1,{input:o,output:i}}(n);t[r]=o;break}case P.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value:}});const n={$schema:"http://json-schema.org/draft-07/schema#",definitions:{...Ea,...t}};return e&&(n.$ref=`#/definitions/${e}`),n}}function Ba(e){return["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","implements","interface","let","package","private","protected","public","static","async","await","constructor","null","true","false"].includes(e)}function xa(e){const t=e.replace(/[^a-zA-Z0-9_$]/g,"_");return Ba(t)?t+"_":/^\d/.test(t)?"_"+t:""===t||/^_+$/.test(t)?"_unnamed":t}function Ra(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function _a(e,t=!1){switch(e.switch()){case P.ScSpecType.scSpecTypeVal():return"any";case P.ScSpecType.scSpecTypeBool():return"boolean";case P.ScSpecType.scSpecTypeVoid():return"null";case P.ScSpecType.scSpecTypeError():return"Error";case P.ScSpecType.scSpecTypeU32():case P.ScSpecType.scSpecTypeI32():return"number";case P.ScSpecType.scSpecTypeU64():case P.ScSpecType.scSpecTypeI64():case P.ScSpecType.scSpecTypeTimepoint():case P.ScSpecType.scSpecTypeDuration():case P.ScSpecType.scSpecTypeU128():case P.ScSpecType.scSpecTypeI128():case P.ScSpecType.scSpecTypeU256():case P.ScSpecType.scSpecTypeI256():return"bigint";case P.ScSpecType.scSpecTypeBytes():case P.ScSpecType.scSpecTypeBytesN():return"Buffer";case P.ScSpecType.scSpecTypeString():case P.ScSpecType.scSpecTypeSymbol():return"string";case P.ScSpecType.scSpecTypeAddress():case P.ScSpecType.scSpecTypeMuxedAddress():return t?"string | Address":"string";case P.ScSpecType.scSpecTypeVec():return`Array<${_a(e.vec().elementType(),t)}>`;case P.ScSpecType.scSpecTypeMap():return`Map<${_a(e.map().keyType(),t)}, ${_a(e.map().valueType(),t)}>`;case P.ScSpecType.scSpecTypeTuple():return`[${e.tuple().valueTypes().map(e=>_a(e,t)).join(", ")}]`;case P.ScSpecType.scSpecTypeOption():for(;e.option().valueType().switch()===P.ScSpecType.scSpecTypeOption();)e=e.option().valueType();return`${_a(e.option().valueType(),t)} | null`;case P.ScSpecType.scSpecTypeResult():return`Result<${_a(e.result().okType(),t)}, ${_a(e.result().errorType(),t)}>`;case P.ScSpecType.scSpecTypeUdt():return xa(e.udt().name().toString());default:return"unknown"}}function Pa(e,t){switch(e.switch()){case P.ScSpecType.scSpecTypeUdt():return void t.typeFileImports.add(xa(e.udt().name().toString()));case P.ScSpecType.scSpecTypeAddress():case P.ScSpecType.scSpecTypeMuxedAddress():return void t.stellarImports.add("Address");case P.ScSpecType.scSpecTypeBytes():case P.ScSpecType.scSpecTypeBytesN():return void(t.needsBufferImport=!0);case P.ScSpecType.scSpecTypeVal():return void t.stellarImports.add("xdr");case P.ScSpecType.scSpecTypeResult():t.stellarContractImports.add("Result");break;case P.ScSpecType.scSpecTypeBool():case P.ScSpecType.scSpecTypeVoid():case P.ScSpecType.scSpecTypeError():case P.ScSpecType.scSpecTypeU32():case P.ScSpecType.scSpecTypeI32():case P.ScSpecType.scSpecTypeU64():case P.ScSpecType.scSpecTypeI64():case P.ScSpecType.scSpecTypeTimepoint():case P.ScSpecType.scSpecTypeDuration():case P.ScSpecType.scSpecTypeU128():case P.ScSpecType.scSpecTypeI128():case P.ScSpecType.scSpecTypeU256():case P.ScSpecType.scSpecTypeI256():case P.ScSpecType.scSpecTypeString():case P.ScSpecType.scSpecTypeSymbol():return}const n=function(e){switch(e.switch()){case P.ScSpecType.scSpecTypeVec():return[e.vec().elementType()];case P.ScSpecType.scSpecTypeMap():return[e.map().keyType(),e.map().valueType()];case P.ScSpecType.scSpecTypeTuple():return e.tuple().valueTypes();case P.ScSpecType.scSpecTypeOption():return[e.option().valueType()];case P.ScSpecType.scSpecTypeResult():return[e.result().okType(),e.result().errorType()];default:return[]}}(e);n.forEach(e=>Pa(e,t))}function Oa(e){const t={typeFileImports:new Set,stellarContractImports:new Set,stellarImports:new Set,needsBufferImport:!1};return e.forEach(e=>Pa(e,t)),t}function Ua(e,t){const n=[],r=e.typeFileImports,o=[...e.stellarContractImports,...t?.additionalStellarContractImports||[]],s=[...e.stellarImports,...t?.additionalStellarImports||[]];if(t?.includeTypeFileImports&&r.size>0&&n.push(`import {${Array.from(r).join(", ")}} from './types.js';`),o.length>0){const e=Array.from(new Set(o));n.push(`import {${e.join(", ")}} from '@stellar/stellar-sdk/contract';`)}if(s.length>0){const e=Array.from(new Set(s));n.push(`import {${e.join(", ")}} from '@stellar/stellar-sdk';`)}return e.needsBufferImport&&n.push("import { Buffer } from 'buffer';"),n.join("\n")}function La(e,t=0){if(""===e.trim())return"";const n=" ".repeat(t);const r=e.replace(/\*\//g,"* /").replace(/@(?!(param|returns?|type|throws?|example|deprecated|see|link|since|author|version|description|summary)\b)/g,"\\@").split("\n").map(e=>`${n} * ${e}`.trimEnd());return`${n}/**\n${r.join("\n")}\n${n} */\n`}function Na(e){return e.fields().every((e,t)=>e.name().toString().trim()===t.toString())}var Va=Object.freeze({__proto__:null,escapeStringLiteral:Ra,formatImports:Ua,formatJSDocComment:La,generateTypeImports:Oa,isNameReserved:Ba,isTupleStruct:Na,parseTypeFromTypeDef:_a,sanitizeIdentifier:xa});const Fa="__constructor";class Da{constructor(e,t){if(this.spec=e,this.options=t,void 0===t.server){const{allowHttp:e,headers:n}=t;t.server=new Ji(t.rpcUrl,{allowHttp:e,headers:n})}this.spec.funcs().forEach(n=>{const r=n.name().toString();if(r===Fa)return;const o=(n,o)=>ba.build({method:r,args:n&&e.funcArgsToScVals(r,n),...t,...o,errorTypes:e.errorCases().reduce((e,t)=>({...e,[t.value()]:{message:t.doc().toString()}}),{}),parseResultXdr:t=>e.funcResToNative(r,t)});this[xa(r)]=0===e.getFunc(r).inputs().length?e=>o(void 0,e):o})}spec;options;static async deploy(e,t){const{wasmHash:n,salt:r,format:o,fee:s,timeoutInSeconds:i,simulate:a,...c}=t,u=await async function(e,t,n="hex"){if(!t||!t.rpcUrl)throw new TypeError("options must contain rpcUrl");const{rpcUrl:r,allowHttp:o,headers:s}=t,i=new Ji(r,{allowHttp:o,headers:s}),a=await i.getContractWasmByHash(e,n);return Ca.fromWasm(a)}(n,c,o),l=Cr.createCustomContract({address:new Ar(t.address||t.publicKey),wasmHash:"string"==typeof n?q.Buffer.from(n,o??"hex"):n,salt:r,constructorArgs:e?u.funcArgsToScVals(Fa,e):[]});return ba.buildWithOp(l,{fee:s,timeoutInSeconds:i,simulate:a,...c,contractId:"ignored",method:Fa,parseResultXdr:e=>new Da(u,{...c,contractId:Ar.fromScVal(e).toString()})})}static async fromWasmHash(e,t,n="hex"){if(!t||!t.rpcUrl)throw new TypeError("options must contain rpcUrl");const{rpcUrl:r,allowHttp:o,headers:s}=t,i=t.server??new Ji(r,{allowHttp:o,headers:s}),a=await i.getContractWasmByHash(e,n);return Da.fromWasm(a,t)}static async fromWasm(e,t){const n=await Ca.fromWasm(e);return new Da(n,t)}static async from(e){if(!e||!e.rpcUrl||!e.contractId)throw new TypeError("options must contain rpcUrl and contractId");const{rpcUrl:t,contractId:n,allowHttp:r,headers:o}=e,s=e.server??new Ji(t,{allowHttp:r,headers:o}),i=await s.getContractInstance(n);if(i.executable().switch()===P.ContractExecutableType.contractExecutableStellarAsset()){const{SAC_SPEC:t}=await Promise.resolve().then(function(){return za});return new Da(new Ca(t),e)}const a=await s.getContractWasmByHash(i.executable().wasmHash());return Da.fromWasm(a,e)}txFromJSON=e=>{const{method:t,...n}=JSON.parse(e);return ba.fromJSON({...this.options,method:t,parseResultXdr:e=>this.spec.funcResToNative(t,e)},n)};txFromXDR=e=>ba.fromXDR(this.options,e,this.spec)}var Ma=Object.freeze({__proto__:null,Client:Da}),qa=Object.freeze({__proto__:null,AssembledTransaction:ba,Client:Da,DEFAULT_TIMEOUT:na,Err:ta,NULL_ACCOUNT:ra,Ok:ea,SentTransaction:aa,Spec:Ca,Watcher:class{},basicNodeSigner:(e,t)=>({signTransaction:async(n,r)=>{const o=ro.fromXDR(n,r?.networkPassphrase||t);return o.sign(e),{signedTxXdr:o.toXDR(),signerAddress:e.publicKey()}},signAuthEntry:async t=>({signedAuthEntry:e.sign(xe(q.Buffer.from(t,"base64"))).toString("base64"),signerAddress:e.publicKey()})})});class Ha{generate(e){const{contractName:t}=e;return{packageJson:this.generatePackageJson(t),tsConfig:this.generateTsConfig(),gitignore:this.generateGitignore(),readme:this.generateReadme(t)}}generatePackageJson(e){const t={name:e.toLowerCase().replace(/[^a-z0-9-]/g,"-"),version:"0.0.1",description:`Generated TypeScript bindings for ${e} Stellar contract`,type:"module",main:"dist/index.js",types:"dist/index.d.ts",scripts:{build:"tsc"},dependencies:{"@stellar/stellar-sdk":"^16.1.0",buffer:"6.0.3"},devDependencies:{typescript:"^5.6.3"}};return JSON.stringify(t,null,2)}generateTsConfig(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"NodeNext",moduleResolution:"nodenext",declaration:!0,outDir:"./dist",strictNullChecks:!0,skipLibCheck:!0},include:["src/*"]},null,2)}generateGitignore(){return["# Dependencies","node_modules/","","# Build outputs","dist/","*.tgz","","# IDE",".vscode/",".idea/","","# OS",".DS_Store","Thumbs.db","","# Logs","*.log","npm-debug.log*","","# Runtime data","*.pid","*.seed"].join("\n")}generateReadme(e){return[`# ${e} Contract Bindings`,"",`TypeScript bindings for the ${e} Stellar smart contract.`,"","## Installation","","```bash","npm install","```","","## Build","","```bash","npm run build","```","","## Usage","","```typescript",'import { Client } from "./src";',"","const client = new Client({",' contractId: "YOUR_CONTRACT_ID",',' rpcUrl: "https://soroban-testnet.stellar.org:443",',' networkPassphrase: "Test SDF Network ; September 2015",',"});","","// Call contract methods","// const result = await client.methodName();","```","","## Generated Files","","- `src/index.ts` - Entry point exporting the Client","- `src/types.ts` - Type definitions for contract structs, enums, and unions","- `src/contract.ts` - Client implementation","- `tsconfig.json` - TypeScript configuration","- `package.json` - NPM package configuration","","This package was generated using the Js-Stellar-SDK contract binding generator."].join("\n")}}class Ga{spec;constructor(e){this.spec=e}generate(){const e=this.spec.entries.map(e=>this.generateEntry(e)).filter(e=>e).join("\n\n");return`${this.generateImports()}\n\n ${e}\n `}generateEntry(e){switch(e.switch()){case P.ScSpecEntryKind.scSpecEntryUdtStructV0():return Na(e.udtStructV0())?this.generateTupleStruct(e.udtStructV0()):this.generateStruct(e.udtStructV0());case P.ScSpecEntryKind.scSpecEntryUdtUnionV0():return this.generateUnion(e.udtUnionV0());case P.ScSpecEntryKind.scSpecEntryUdtEnumV0():return this.generateEnum(e.udtEnumV0());case P.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0():return this.generateErrorEnum(e.udtErrorEnumV0());default:return null}}generateImports(){return Ua(Oa(this.spec.entries.flatMap(e=>{switch(e.switch()){case P.ScSpecEntryKind.scSpecEntryUdtStructV0():return e.udtStructV0().fields().map(e=>e.type());case P.ScSpecEntryKind.scSpecEntryUdtUnionV0():return e.udtUnionV0().cases().flatMap(e=>e.switch()===P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0()?e.tupleCase().type():[]);case P.ScSpecEntryKind.scSpecEntryUdtEnumV0():case P.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0():default:return[]}})),{includeTypeFileImports:!1})}generateStruct(e){const t=xa(e.name().toString());return`${La(e.doc().toString()||`Struct: ${t}`,0)}export interface ${t} {\n${e.fields().map(e=>{const t=xa(e.name().toString()),n=_a(e.type());return`${La(e.doc().toString(),2)} ${t}: ${n};`}).join("\n")}\n}`}generateUnion(e){const t=xa(e.name().toString());return`${La(e.doc().toString()||`Union: ${t}`,0)} export type ${t} =\n${e.cases().map(e=>this.generateUnionCase(e)).map(e=>e.types.length>0?`${La(e.doc,2)} { tag: "${Ra(e.name)}"; values: readonly [${e.types.join(", ")}] }`:`${La(e.doc,2)} { tag: "${Ra(e.name)}"; values: void }`).join(" |\n")};`}generateEnum(e){const t=xa(e.name().toString());return`${La(e.doc().toString()||`Enum: ${t}`,0)}export enum ${t} {\n${e.cases().map(e=>{const t=xa(e.name().toString()),n=e.value();return`${La(e.doc().toString()||`Enum Case: ${t}`,2)} ${t} = ${n}`}).join(",\n")}\n}`}generateErrorEnum(e){const t=xa(e.name().toString());return`${La(e.doc().toString()||`Error Enum: ${t}`,0)}export const ${t} = {\n${e.cases().map(e=>this.generateEnumCase(e)).map(e=>`${La(e.doc,2)} ${e.value} : { message: "${Ra(e.name)}" }`).join(",\n")}\n}`}generateUnionCase(e){switch(e.switch()){case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0():{const t=e.voidCase();return{doc:t.doc().toString(),name:t.name().toString(),types:[]}}case P.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0():{const t=e.tupleCase();return{doc:t.doc().toString(),name:t.name().toString(),types:t.type().map(e=>_a(e))}}default:throw new Error(`Unknown union case kind: ${e.switch()}`)}}generateEnumCase(e){return{doc:e.doc().toString(),name:e.name().toString(),value:e.value()}}generateTupleStruct(e){const t=xa(e.name().toString());return`${La(e.doc().toString()||`Tuple Struct: ${t}`,0)}export type ${t} = readonly [${e.fields().map(e=>_a(e.type())).join(", ")}];`}}class $a{spec;constructor(e){this.spec=e}generate(){let e="";try{const t=this.spec.getFunc("__constructor");e=this.generateDeployMethod(t)}catch{e=this.generateDeployMethod(void 0)}const t=this.spec.funcs().filter(e=>"__constructor"!==e.name().toString()).map(e=>this.generateInterfaceMethod(e)).join("\n"),n=this.generateImports(),r=this.spec.entries.map(e=>`"${e.toXDR("base64")}"`),o=this.spec.funcs().filter(e=>"__constructor"!==e.name().toString()).map(e=>this.generateFromJSONMethod(e)).join(",");return`${n}\n\nexport interface Client {\n${t}\n}\n\nexport class Client extends ContractClient {\n constructor(public readonly options: ContractClientOptions) {\n super(\n new Spec([${r.join(", ")}]),\n options\n );\n }\n\n ${e}\n public readonly fromJSON = {\n ${o}\n };\n}`}generateImports(){return Ua(Oa(this.spec.funcs().flatMap(e=>{const t=e.inputs(),n=e.outputs();return t.map(e=>e.type()).concat(n)})),{includeTypeFileImports:!0,additionalStellarContractImports:["Spec","AssembledTransaction","Client as ContractClient","ClientOptions as ContractClientOptions","MethodOptions"]})}generateInterfaceMethod(e){const t=xa(e.name().toString()),n=e.inputs().map(e=>({name:xa(e.name().toString()),type:_a(e.type(),!0)})),r=e.outputs().length>0?_a(e.outputs()[0]):"void";return`${La(e.doc().toString(),2)} ${t}(${this.formatMethodParameters(n)}): Promise<AssembledTransaction<${r}>>;`}generateFromJSONMethod(e){return` ${xa(e.name().toString())} : this.txFromJSON<${e.outputs().length>0?_a(e.outputs()[0]):"void"}>`}generateDeployMethod(e){if(!e){return` static deploy<T = Client>(${this.formatConstructorParameters([])}): Promise<AssembledTransaction<T>> {\n return ContractClient.deploy(null, options);\n }`}const t=e.inputs().map(e=>({name:xa(e.name().toString()),type:_a(e.type(),!0)}));return` static deploy<T = Client>(${this.formatConstructorParameters(t)}): Promise<AssembledTransaction<T>> {\n return ContractClient.deploy(${t.length>0?`{ ${t.map(e=>e.name).join(", ")} }, `:""}options);\n }`}formatMethodParameters(e){const t=[];if(e.length>0){const n=`{ ${e.map(e=>`${e.name}: ${e.type}`).join("; ")} }`;t.push(`{ ${e.map(e=>e.name).join(", ")} }: ${n}`)}return t.push("options?: MethodOptions"),t.join(", ")}formatConstructorParameters(e){const t=[];if(e.length>0){const n=`{ ${e.map(e=>`${e.name}: ${e.type}`).join("; ")} }`;t.push(`{ ${e.map(e=>e.name).join(", ")} }: ${n}`)}return t.push('options: MethodOptions & Omit<ContractClientOptions, \'contractId\'> & { wasmHash: Buffer | string; salt?: Buffer | Uint8Array; format?: "hex" | "base64"; address?: string; }'),t.join(", ")}}class Xa extends Error{constructor(e,t){super(e),this.cause=t,this.name="WasmFetchError"}cause}async function Ka(e,t){try{const n=P.LedgerKey.contractCode(new P.LedgerKeyContractCode({hash:P.Hash.fromXDR(t,"raw")})),r=await e.getLedgerEntries(n);if(!r.entries||0===r.entries.length)throw new Xa("WASM not found for the given hash");const o=r.entries[0];if(o.key.switch()!==P.LedgerEntryType.contractCode())throw new Xa("Invalid ledger entry type returned");const s=o.val.contractCode();return q.Buffer.from(s.code())}catch(e){if(e instanceof Xa)throw e;throw new Xa("Failed to fetch WASM from hash",e)}}async function Wa(e,t){try{const n=new Gr(t.toString()),r=await e.getLedgerEntries(n.getFootprint());if(!r.entries||0===r.entries.length)throw new Xa("Contract instance not found");const o=r.entries[0];if(o.key.switch()!==P.LedgerEntryType.contractData())throw new Xa("Invalid ledger entry type returned");const s=o.val.contractData().val().instance();if(function(e){return e.executable().switch()===P.ContractExecutableType.contractExecutableStellarAsset()}(s))return{type:"stellar-asset-contract"};const i=s.executable().wasmHash();return{type:"wasm",wasmBytes:await Ka(e,i)}}catch(e){if(e instanceof Xa)throw e;throw new Xa("Failed to fetch WASM from contract",e)}}const Za="AAAAAAAAAYpSZXR1cm5zIHRoZSBhbGxvd2FuY2UgZm9yIGBzcGVuZGVyYCB0byB0cmFuc2ZlciBmcm9tIGBmcm9tYC4KClRoZSBhbW91bnQgcmV0dXJuZWQgaXMgdGhlIGFtb3VudCB0aGF0IHNwZW5kZXIgaXMgYWxsb3dlZCB0byB0cmFuc2ZlcgpvdXQgb2YgZnJvbSdzIGJhbGFuY2UuIFdoZW4gdGhlIHNwZW5kZXIgdHJhbnNmZXJzIGFtb3VudHMsIHRoZSBhbGxvd2FuY2UKd2lsbCBiZSByZWR1Y2VkIGJ5IHRoZSBhbW91bnQgdHJhbnNmZXJyZWQuCgojIEFyZ3VtZW50cwoKKiBgZnJvbWAgLSBUaGUgYWRkcmVzcyBob2xkaW5nIHRoZSBiYWxhbmNlIG9mIHRva2VucyB0byBiZSBkcmF3biBmcm9tLgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIHNwZW5kaW5nIHRoZSB0b2tlbnMgaGVsZCBieSBgZnJvbWAuAAAAAAAJYWxsb3dhbmNlAAAAAAAAAgAAAAAAAAAEZnJvbQAAABMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAEAAAALAAAAAAAAAIlSZXR1cm5zIHRydWUgaWYgYGlkYCBpcyBhdXRob3JpemVkIHRvIHVzZSBpdHMgYmFsYW5jZS4KCiMgQXJndW1lbnRzCgoqIGBpZGAgLSBUaGUgYWRkcmVzcyBmb3Igd2hpY2ggdG9rZW4gYXV0aG9yaXphdGlvbiBpcyBiZWluZyBjaGVja2VkLgAAAAAAAAphdXRob3JpemVkAAAAAAABAAAAAAAAAAJpZAAAAAAAEwAAAAEAAAABAAAAAAAAA59TZXQgdGhlIGFsbG93YW5jZSBieSBgYW1vdW50YCBmb3IgYHNwZW5kZXJgIHRvIHRyYW5zZmVyL2J1cm4gZnJvbQpgZnJvbWAuCgpUaGUgYW1vdW50IHNldCBpcyB0aGUgYW1vdW50IHRoYXQgc3BlbmRlciBpcyBhcHByb3ZlZCB0byB0cmFuc2ZlciBvdXQgb2YKZnJvbSdzIGJhbGFuY2UuIFRoZSBzcGVuZGVyIHdpbGwgYmUgYWxsb3dlZCB0byB0cmFuc2ZlciBhbW91bnRzLCBhbmQKd2hlbiBhbiBhbW91bnQgaXMgdHJhbnNmZXJyZWQgdGhlIGFsbG93YW5jZSB3aWxsIGJlIHJlZHVjZWQgYnkgdGhlCmFtb3VudCB0cmFuc2ZlcnJlZC4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHRvIGJlIGRyYXduIGZyb20uCiogYHNwZW5kZXJgIC0gVGhlIGFkZHJlc3MgYmVpbmcgYXV0aG9yaXplZCB0byBzcGVuZCB0aGUgdG9rZW5zIGhlbGQgYnkKYGZyb21gLgoqIGBhbW91bnRgIC0gVGhlIHRva2VucyB0byBiZSBtYWRlIGF2YWlsYWJsZSB0byBgc3BlbmRlcmAuCiogYGV4cGlyYXRpb25fbGVkZ2VyYCAtIFRoZSBsZWRnZXIgbnVtYmVyIHdoZXJlIHRoaXMgYWxsb3dhbmNlIGV4cGlyZXMuIENhbm5vdApiZSBsZXNzIHRoYW4gdGhlIGN1cnJlbnQgbGVkZ2VyIG51bWJlciB1bmxlc3MgdGhlIGFtb3VudCBpcyBiZWluZyBzZXQgdG8gMC4KQW4gZXhwaXJlZCBlbnRyeSAod2hlcmUgZXhwaXJhdGlvbl9sZWRnZXIgPCB0aGUgY3VycmVudCBsZWRnZXIgbnVtYmVyKQpzaG91bGQgYmUgdHJlYXRlZCBhcyBhIDAgYW1vdW50IGFsbG93YW5jZS4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJhcHByb3ZlIiwgZnJvbTogQWRkcmVzcywKc3BlbmRlcjogQWRkcmVzc10sIGRhdGEgPSBbYW1vdW50OiBpMTI4LCBleHBpcmF0aW9uX2xlZGdlcjogdTMyXWAAAAAAB2FwcHJvdmUAAAAABAAAAAAAAAAEZnJvbQAAABMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAABFleHBpcmF0aW9uX2xlZGdlcgAAAAAAAAQAAAAAAAAAAAAAAJhSZXR1cm5zIHRoZSBiYWxhbmNlIG9mIGBpZGAuCgojIEFyZ3VtZW50cwoKKiBgaWRgIC0gVGhlIGFkZHJlc3MgZm9yIHdoaWNoIGEgYmFsYW5jZSBpcyBiZWluZyBxdWVyaWVkLiBJZiB0aGUKYWRkcmVzcyBoYXMgbm8gZXhpc3RpbmcgYmFsYW5jZSwgcmV0dXJucyAwLgAAAAdiYWxhbmNlAAAAAAEAAAAAAAAAAmlkAAAAAAATAAAAAQAAAAsAAAAAAAABYkJ1cm4gYGFtb3VudGAgZnJvbSBgZnJvbWAuCgpSZWR1Y2VzIGZyb20ncyBiYWxhbmNlIGJ5IHRoZSBhbW91bnQsIHdpdGhvdXQgdHJhbnNmZXJyaW5nIHRoZSBiYWxhbmNlCnRvIGFub3RoZXIgaG9sZGVyJ3MgYmFsYW5jZS4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKYnVybmVkIGZyb20uCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSBidXJuZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsiYnVybiIsIGZyb206IEFkZHJlc3NdLCBkYXRhID0gYW1vdW50OgppMTI4YAAAAAAABGJ1cm4AAAACAAAAAAAAAARmcm9tAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAALaQnVybiBgYW1vdW50YCBmcm9tIGBmcm9tYCwgY29uc3VtaW5nIHRoZSBhbGxvd2FuY2Ugb2YgYHNwZW5kZXJgLgoKUmVkdWNlcyBmcm9tJ3MgYmFsYW5jZSBieSB0aGUgYW1vdW50LCB3aXRob3V0IHRyYW5zZmVycmluZyB0aGUgYmFsYW5jZQp0byBhbm90aGVyIGhvbGRlcidzIGJhbGFuY2UuCgpUaGUgc3BlbmRlciB3aWxsIGJlIGFsbG93ZWQgdG8gYnVybiB0aGUgYW1vdW50IGZyb20gZnJvbSdzIGJhbGFuY2UsIGlmCnRoZSBhbW91bnQgaXMgbGVzcyB0aGFuIG9yIGVxdWFsIHRvIHRoZSBhbGxvd2FuY2UgdGhhdCB0aGUgc3BlbmRlciBoYXMKb24gdGhlIGZyb20ncyBiYWxhbmNlLiBUaGUgc3BlbmRlcidzIGFsbG93YW5jZSBvbiBmcm9tJ3MgYmFsYW5jZSB3aWxsIGJlCnJlZHVjZWQgYnkgdGhlIGFtb3VudC4KCiMgQXJndW1lbnRzCgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIGF1dGhvcml6aW5nIHRoZSBidXJuLCBhbmQgaGF2aW5nIGl0cyBhbGxvd2FuY2UKY29uc3VtZWQgZHVyaW5nIHRoZSBidXJuLgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKYnVybmVkIGZyb20uCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSBidXJuZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsiYnVybiIsIGZyb206IEFkZHJlc3NdLCBkYXRhID0gYW1vdW50OgppMTI4YAAAAAAACWJ1cm5fZnJvbQAAAAAAAAMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAEZnJvbQAAABMAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAABUUNsYXdiYWNrIGBhbW91bnRgIGZyb20gYGZyb21gIGFjY291bnQuIGBhbW91bnRgIGlzIGJ1cm5lZCBpbiB0aGUKY2xhd2JhY2sgcHJvY2Vzcy4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2UgZnJvbSB3aGljaCB0aGUgY2xhd2JhY2sgd2lsbAp0YWtlIHRva2Vucy4KKiBgYW1vdW50YCAtIFRoZSBhbW91bnQgb2YgdG9rZW5zIHRvIGJlIGNsYXdlZCBiYWNrLgoKIyBFdmVudHMKCkVtaXRzIGFuIGV2ZW50IHdpdGggdG9waWNzIGBbImNsYXdiYWNrIiwgYWRtaW46IEFkZHJlc3MsIHRvOiBBZGRyZXNzXSwKZGF0YSA9IGFtb3VudDogaTEyOGAAAAAAAAAIY2xhd2JhY2sAAAACAAAAAAAAAARmcm9tAAAAEwAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAACAUmV0dXJucyB0aGUgbnVtYmVyIG9mIGRlY2ltYWxzIHVzZWQgdG8gcmVwcmVzZW50IGFtb3VudHMgb2YgdGhpcyB0b2tlbi4KCiMgUGFuaWNzCgpJZiB0aGUgY29udHJhY3QgaGFzIG5vdCB5ZXQgYmVlbiBpbml0aWFsaXplZC4AAAAIZGVjaW1hbHMAAAAAAAAAAQAAAAQAAAAAAAAA801pbnRzIGBhbW91bnRgIHRvIGB0b2AuCgojIEFyZ3VtZW50cwoKKiBgdG9gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCByZWNlaXZlIHRoZSBtaW50ZWQgdG9rZW5zLgoqIGBhbW91bnRgIC0gVGhlIGFtb3VudCBvZiB0b2tlbnMgdG8gYmUgbWludGVkLgoKIyBFdmVudHMKCkVtaXRzIGFuIGV2ZW50IHdpdGggdG9waWNzIGBbIm1pbnQiLCBhZG1pbjogQWRkcmVzcywgdG86IEFkZHJlc3NdLCBkYXRhCj0gYW1vdW50OiBpMTI4YAAAAAAEbWludAAAAAIAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAFlSZXR1cm5zIHRoZSBuYW1lIGZvciB0aGlzIHRva2VuLgoKIyBQYW5pY3MKCklmIHRoZSBjb250cmFjdCBoYXMgbm90IHlldCBiZWVuIGluaXRpYWxpemVkLgAAAAAAAARuYW1lAAAAAAAAAAEAAAAQAAAAAAAAAQxTZXRzIHRoZSBhZG1pbmlzdHJhdG9yIHRvIHRoZSBzcGVjaWZpZWQgYWRkcmVzcyBgbmV3X2FkbWluYC4KCiMgQXJndW1lbnRzCgoqIGBuZXdfYWRtaW5gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCBoZW5jZWZvcnRoIGJlIHRoZSBhZG1pbmlzdHJhdG9yCm9mIHRoaXMgdG9rZW4gY29udHJhY3QuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsic2V0X2FkbWluIiwgYWRtaW46IEFkZHJlc3NdLCBkYXRhID0KW25ld19hZG1pbjogQWRkcmVzc11gAAAACXNldF9hZG1pbgAAAAAAAAEAAAAAAAAACW5ld19hZG1pbgAAAAAAABMAAAAAAAAAAAAAAEZSZXR1cm5zIHRoZSBhZG1pbiBvZiB0aGUgY29udHJhY3QuCgojIFBhbmljcwoKSWYgdGhlIGFkbWluIGlzIG5vdCBzZXQuAAAAAAAFYWRtaW4AAAAAAAAAAAAAAQAAABMAAAAAAAABUFNldHMgd2hldGhlciB0aGUgYWNjb3VudCBpcyBhdXRob3JpemVkIHRvIHVzZSBpdHMgYmFsYW5jZS4gSWYKYGF1dGhvcml6ZWRgIGlzIHRydWUsIGBpZGAgc2hvdWxkIGJlIGFibGUgdG8gdXNlIGl0cyBiYWxhbmNlLgoKIyBBcmd1bWVudHMKCiogYGlkYCAtIFRoZSBhZGRyZXNzIGJlaW5nIChkZS0pYXV0aG9yaXplZC4KKiBgYXV0aG9yaXplYCAtIFdoZXRoZXIgb3Igbm90IGBpZGAgY2FuIHVzZSBpdHMgYmFsYW5jZS4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJzZXRfYXV0aG9yaXplZCIsIGlkOiBBZGRyZXNzXSwgZGF0YSA9ClthdXRob3JpemU6IGJvb2xdYAAAAA5zZXRfYXV0aG9yaXplZAAAAAAAAgAAAAAAAAACaWQAAAAAABMAAAAAAAAACWF1dGhvcml6ZQAAAAAAAAEAAAAAAAAAAAAAAFtSZXR1cm5zIHRoZSBzeW1ib2wgZm9yIHRoaXMgdG9rZW4uCgojIFBhbmljcwoKSWYgdGhlIGNvbnRyYWN0IGhhcyBub3QgeWV0IGJlZW4gaW5pdGlhbGl6ZWQuAAAAAAZzeW1ib2wAAAAAAAAAAAABAAAAEAAAAAAAAAFiVHJhbnNmZXIgYGFtb3VudGAgZnJvbSBgZnJvbWAgdG8gYHRvYC4KCiMgQXJndW1lbnRzCgoqIGBmcm9tYCAtIFRoZSBhZGRyZXNzIGhvbGRpbmcgdGhlIGJhbGFuY2Ugb2YgdG9rZW5zIHdoaWNoIHdpbGwgYmUKd2l0aGRyYXduIGZyb20uCiogYHRvYCAtIFRoZSBhZGRyZXNzIHdoaWNoIHdpbGwgcmVjZWl2ZSB0aGUgdHJhbnNmZXJyZWQgdG9rZW5zLgoqIGBhbW91bnRgIC0gVGhlIGFtb3VudCBvZiB0b2tlbnMgdG8gYmUgdHJhbnNmZXJyZWQuCgojIEV2ZW50cwoKRW1pdHMgYW4gZXZlbnQgd2l0aCB0b3BpY3MgYFsidHJhbnNmZXIiLCBmcm9tOiBBZGRyZXNzLCB0bzogQWRkcmVzc10sCmRhdGEgPSBhbW91bnQ6IGkxMjhgAAAAAAAIdHJhbnNmZXIAAAADAAAAAAAAAARmcm9tAAAAEwAAAAAAAAACdG8AAAAAABMAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAADMVRyYW5zZmVyIGBhbW91bnRgIGZyb20gYGZyb21gIHRvIGB0b2AsIGNvbnN1bWluZyB0aGUgYWxsb3dhbmNlIHRoYXQKYHNwZW5kZXJgIGhhcyBvbiBgZnJvbWAncyBiYWxhbmNlLiBBdXRob3JpemVkIGJ5IHNwZW5kZXIKKGBzcGVuZGVyLnJlcXVpcmVfYXV0aCgpYCkuCgpUaGUgc3BlbmRlciB3aWxsIGJlIGFsbG93ZWQgdG8gdHJhbnNmZXIgdGhlIGFtb3VudCBmcm9tIGZyb20ncyBiYWxhbmNlCmlmIHRoZSBhbW91bnQgaXMgbGVzcyB0aGFuIG9yIGVxdWFsIHRvIHRoZSBhbGxvd2FuY2UgdGhhdCB0aGUgc3BlbmRlcgpoYXMgb24gdGhlIGZyb20ncyBiYWxhbmNlLiBUaGUgc3BlbmRlcidzIGFsbG93YW5jZSBvbiBmcm9tJ3MgYmFsYW5jZQp3aWxsIGJlIHJlZHVjZWQgYnkgdGhlIGFtb3VudC4KCiMgQXJndW1lbnRzCgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIGF1dGhvcml6aW5nIHRoZSB0cmFuc2ZlciwgYW5kIGhhdmluZyBpdHMKYWxsb3dhbmNlIGNvbnN1bWVkIGR1cmluZyB0aGUgdHJhbnNmZXIuCiogYGZyb21gIC0gVGhlIGFkZHJlc3MgaG9sZGluZyB0aGUgYmFsYW5jZSBvZiB0b2tlbnMgd2hpY2ggd2lsbCBiZQp3aXRoZHJhd24gZnJvbS4KKiBgdG9gIC0gVGhlIGFkZHJlc3Mgd2hpY2ggd2lsbCByZWNlaXZlIHRoZSB0cmFuc2ZlcnJlZCB0b2tlbnMuCiogYGFtb3VudGAgLSBUaGUgYW1vdW50IG9mIHRva2VucyB0byBiZSB0cmFuc2ZlcnJlZC4KCiMgRXZlbnRzCgpFbWl0cyBhbiBldmVudCB3aXRoIHRvcGljcyBgWyJ0cmFuc2ZlciIsIGZyb206IEFkZHJlc3MsIHRvOiBBZGRyZXNzXSwKZGF0YSA9IGFtb3VudDogaTEyOGAAAAAAAAANdHJhbnNmZXJfZnJvbQAAAAAAAAQAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAAAAAAEZnJvbQAAABMAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAABQAAAAAAAAAAAAAAB0FwcHJvdmUAAAAAAQAAAAdhcHByb3ZlAAAAAAQAAAAAAAAABGZyb20AAAATAAAAAQAAAAAAAAAHc3BlbmRlcgAAAAATAAAAAQAAAAAAAAAGYW1vdW50AAAAAAALAAAAAAAAAAAAAAARZXhwaXJhdGlvbl9sZWRnZXIAAAAAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAIVHJhbnNmZXIAAAABAAAACHRyYW5zZmVyAAAAAwAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAJ0bwAAAAAAEwAAAAEAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAAABQAAAAAAAAAAAAAADVRyYW5zZmVyTXV4ZWQAAAAAAAABAAAACHRyYW5zZmVyAAAABAAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAJ0bwAAAAAAEwAAAAEAAAAAAAAAC3RvX211eGVkX2lkAAAAAAQAAAAAAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAgAAAAUAAAAAAAAAAAAAAARCdXJuAAAAAQAAAARidXJuAAAAAgAAAAAAAAAEZnJvbQAAABMAAAABAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAARNaW50AAAAAQAAAARtaW50AAAAAgAAAAAAAAACdG8AAAAAABMAAAABAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAhDbGF3YmFjawAAAAEAAAAIY2xhd2JhY2sAAAACAAAAAAAAAARmcm9tAAAAEwAAAAEAAAAAAAAABmFtb3VudAAAAAAACwAAAAAAAAAAAAAABQAAAAAAAAAAAAAACFNldEFkbWluAAAAAQAAAAlzZXRfYWRtaW4AAAAAAAABAAAAAAAAAAluZXdfYWRtaW4AAAAAAAATAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAANU2V0QXV0aG9yaXplZAAAAAAAAAEAAAAOc2V0X2F1dGhvcml6ZWQAAAAAAAIAAAAAAAAAAmlkAAAAAAATAAAAAQAAAAAAAAAJYXV0aG9yaXplAAAAAAAAAQAAAAAAAAAA";var za=Object.freeze({__proto__:null,SAC_SPEC:Za});class ja{spec;constructor(e){this.spec=e}static fromSpec(e){return new ja(e)}static fromWasm(e){const t=new Ca(va(e));return new ja(t)}static async fromWasmHash(e,t){const n=await async function(e,t){try{const n=q.Buffer.from(e,"hex");if(32!==n.length)throw new Xa(`Invalid WASM hash length: expected 32 bytes, got ${n.length}`);return{type:"wasm",wasmBytes:await Ka(t,n)}}catch(t){throw new Xa(`Failed to fetch WASM from hash ${e}`,t)}}(e,t);if("wasm"!==n.type)throw new Error("Fetched contract is not of type 'wasm'");return ja.fromWasm(n.wasmBytes)}static async fromContractId(e,t){const n=await async function(e,t){try{if(!$t.isValidContract(e))throw new Xa(`Invalid contract ID: ${e}`);const n=Ar.fromString(e);return await Wa(t,n)}catch(t){throw new Xa(`Failed to fetch WASM from contract ${e}`,t)}}(e,t);if("wasm"===n.type)return ja.fromWasm(n.wasmBytes);const r=new Ca(Za);return ja.fromSpec(r)}generate(e){this.validateOptions(e);const t=new Ga(this.spec),n=new $a(this.spec),r=t.generate(),o=n.generate();let s='export { Client } from "./client.js";';""!==r.trim()&&(s=s.concat('\nexport * from "./types.js";'));const i=new Ha,{packageJson:a,tsConfig:c,readme:u,gitignore:l}=i.generate(e);return{index:s,types:r,client:o,packageJson:a,tsConfig:c,readme:u,gitignore:l}}validateOptions(e){if(!e.contractName||""===e.contractName.trim())throw new Error("contractName is required and cannot be empty")}}e.Account=Vr,e.AccountRequiresMemoError=Bo,e.Address=Ar,e.Asset=Qt,e.AssetType=Yt,e.AuthClawbackEnabledFlag=8,e.AuthImmutableFlag=4,e.AuthRequiredFlag=1,e.AuthRevocableFlag=2,e.BASE_FEE=no,e.BadRequestError=I,e.BadResponseError=C,e.BindingGenerator=ja,e.Claimant=rn,e.Config=_o,e.Contract=Gr,e.Federation=ss,e.FeeBumpTransaction=Nr,e.Friendbot=Ss,e.Horizon=Fi,e.Hyper=_.Hyper,e.Int128=Kr,e.Int256=Wr,e.Keypair=jt,e.LiquidityPoolAsset=nn,e.LiquidityPoolFeeV18=30,e.LiquidityPoolId=on,e.Memo=Ur,e.MemoHash=Pr,e.MemoID=Rr,e.MemoNone=xr,e.MemoReturn=Or,e.MemoText=_r,e.MuxedAccount=Mr,e.NetworkError=E,e.Networks=io,e.NotFoundError=k,e.Operation=Cr,e.ScInt=zr,e.SignerKey=Hr,e.Soroban=ao,e.SorobanDataBuilder=qr,e.StellarBase=Io,e.StellarToml=es,e.StrKey=$t,e.TimeoutInfinite=0,e.Transaction=Lr,e.TransactionBase=tn,e.TransactionBuilder=ro,e.TransactionFailedError=Co,e.Uint128=$r,e.Uint256=Xr,e.UnsignedHyper=_.UnsignedHyper,e.Utils=Po,e.WebAuth=As,e.XdrLargeInt=Zr,e.authorizeEntry=po,e.authorizeInvocation=ho,e.buildAuthorizationEntryPreimage=fo,e.buildInvocationTree=To,e.buildWithDelegatesEntry=mo,e.cereal=O,e.checkAuthEntryReadiness=So,e.contract=qa,e.decodeAddressToMuxedAccount=sn,e.encodeMuxedAccount=cn,e.encodeMuxedAccountToAddress=an,e.extractBaseAddress=un,e.getLiquidityPoolId=en,e.hash=xe,e.httpClient=T,e.humanizeEvents=uo,e.inspectAuthEntry=Ao,e.nativeToScVal=Yr,e.rpc=Qi,e.scValToBigInt=jr,e.scValToNative=Jr,e.scvSortedMap=Qr,e.sign=Ut,e.verify=Lt,e.walkInvocationTree=Eo,e.xdr=P});
|
|
200
200
|
//# sourceMappingURL=stellar-sdk.min.js.map
|