@stakekit/widget 0.0.293 → 0.0.294
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/dist/bundle/{DateTime-BBRIKkPv.js → DateTime-CMMZj2i-.js} +54 -54
- package/dist/bundle/{assets-vw12jo1v.js → assets-Bc9gJ-IT.js} +6 -6
- package/dist/bundle/{cardano-connector-DCWdS4Lt.js → cardano-connector-4FH7sm5s.js} +2 -2
- package/dist/bundle/{configured-chains-Bc6_pgMo.js → configured-chains-DF5IpaPp.js} +1 -1
- package/dist/bundle/{cosmos-connector-meta-Br67nymZ.js → cosmos-connector-meta-BKRBGzAs.js} +1 -1
- package/dist/bundle/index.bundle.js +13834 -13695
- package/dist/bundle/{ledger-connector-wZ-AWITi.js → ledger-connector-Em3Ex6Ns.js} +5 -5
- package/dist/bundle/{network-D8-Flo2u.js → network-D2ajkWp0.js} +1 -1
- package/dist/bundle/{reward-rate-chart-B41r4AU4.js → reward-rate-chart-6q6gJawR.js} +4 -4
- package/dist/bundle/{solana-connector-CXe_nU4I.js → solana-connector-DHrdMGZC.js} +3 -3
- package/dist/bundle/{stellar-connector-Cdl9Hnba.js → stellar-connector-DkR_jg41.js} +2 -2
- package/dist/bundle/{styles.css-BJ7-ORZP.js → styles.css-DQG3ba8V.js} +6 -6
- package/dist/bundle/{substrate-connector-DFeFqV_q.js → substrate-connector-CzewVoQ6.js} +1 -1
- package/dist/bundle/{ton-connector-CWmOukzn.js → ton-connector-CcahoFeW.js} +3 -3
- package/dist/bundle/{transaction-BwhgjU0e.js → transaction-BGiGADTK.js} +1 -1
- package/dist/bundle/{transaction-CUoDE6CU.js → transaction-BvpQWKqm.js} +1 -1
- package/dist/bundle/{transaction-B8S7Vgaq.js → transaction-CD_QhA6u.js} +2 -2
- package/dist/bundle/{transaction-DxrR2BHC.js → transaction-CiEShf7a.js} +1 -1
- package/dist/bundle/{tron-connector--M_0_Iy7.js → tron-connector-Dy_36o_J.js} +3 -3
- package/dist/bundle/{utils-CoW929-6.js → utils-BMTuLksW.js} +1 -1
- package/dist/bundle/{wallet-manager-C3rmOq7t.js → wallet-manager-BLaLHs2U.js} +11 -11
- package/dist/package/{DateTime-DJZXpaqx.js → DateTime-CGVpQQm9.js} +24 -2
- package/dist/package/{assets-BuIo5TOF.js → assets-CEn8BPdT.js} +1 -1
- package/dist/package/{cardano-connector-DIZuipB7.js → cardano-connector-BDWTBXaS.js} +2 -2
- package/dist/package/{configured-chains-B6PD9hvx.js → configured-chains-CRuy8tse.js} +1 -1
- package/dist/package/{cosmos-connector-meta-CgvZWkLV.js → cosmos-connector-meta-B-ke1Dvw.js} +1 -1
- package/dist/package/index.package.js +1682 -1449
- package/dist/package/{ledger-connector-B3kEcKjM.js → ledger-connector-BQDRUjOJ.js} +5 -5
- package/dist/package/{network-B4Qs3uRl.js → network-K03Uj00V.js} +1 -1
- package/dist/package/{reward-rate-chart-B42ZCby7.js → reward-rate-chart-DBx39GdL.js} +2 -2
- package/dist/package/{solana-connector-VG2pC1EJ.js → solana-connector-fL70NOkD.js} +3 -3
- package/dist/package/{stellar-connector-DO9tJUOg.js → stellar-connector-C_33sqO5.js} +2 -2
- package/dist/package/{styles.css-DwJjrmLr.js → styles.css-BOghDWGq.js} +1 -1
- package/dist/package/{substrate-connector-P80MVt5T.js → substrate-connector-Cr7LEt2o.js} +1 -1
- package/dist/package/{ton-connector-3rqiqNZO.js → ton-connector-81-rUhzX.js} +3 -3
- package/dist/package/{transaction-DTbU7sxm.js → transaction-BHIZ9rKF.js} +1 -1
- package/dist/package/{transaction-CuMGfUeE.js → transaction-C5e_gCK6.js} +1 -1
- package/dist/package/{transaction-V39s0qKU.js → transaction-DMMfLvk1.js} +2 -2
- package/dist/package/{transaction-Do_oUKxl.js → transaction-DgdU5pHH.js} +1 -1
- package/dist/package/{tron-connector-CKUZFHDh.js → tron-connector-Cuez3U16.js} +3 -3
- package/dist/package/{wallet-manager-CioQJQ5H.js → wallet-manager-DWFwmdLb.js} +2 -2
- package/dist/website/assets/AlertController-Dd3t1FDe.js +1 -0
- package/dist/website/assets/{CaipNetworkUtil-CIgzbD6k.js → CaipNetworkUtil-CyIDQhS0.js} +1 -1
- package/dist/website/assets/DateTime-ByC3zr_K.js +1 -0
- package/dist/website/assets/{HelpersUtil-BokHy7la.js → HelpersUtil-Bpil3MMz.js} +1 -1
- package/dist/website/assets/ModalController-BhWRBcfd.js +5 -0
- package/dist/website/assets/{albedo.module-Dn9vkw3f.js → albedo.module-DkOe0Unb.js} +1 -1
- package/dist/website/assets/assets-DXO6qW6R.js +2 -0
- package/dist/website/assets/{axios-Dl6BaS8Y.js → axios-rFNl7rAx.js} +2 -2
- package/dist/website/assets/{base-signer-b1ff2VPI-DF_m1Hx-.js → base-signer-b1ff2VPI-DEykpag5.js} +1 -1
- package/dist/website/assets/{basic-Bt_YnOIC.js → basic-By5_muQ4.js} +1 -1
- package/dist/website/assets/bignumber-FohbSRh0.js +1 -0
- package/dist/website/assets/blakejs-x6iaQxOd.js +3 -0
- package/dist/website/assets/bn-Ck4DeaX2.js +1 -0
- package/dist/website/assets/{browser-ponyfill-_v4sZCld.js → browser-ponyfill-lHyeX8iJ.js} +1 -1
- package/dist/website/assets/{bs58-CiFyCgrv.js → bs58-gzsgdke5.js} +1 -1
- package/dist/website/assets/{build-DM4Sawu1.js → build-ClRxYQRR.js} +1 -1
- package/dist/website/assets/{build-Butjcagw.js → build-TBrHU398.js} +1 -1
- package/dist/website/assets/{build-B5AnTSOq.js → build-Tl3I8dhV.js} +1 -1
- package/dist/website/assets/{cardano-connector-BC5bF4Y2.js → cardano-connector-8El4Ztf_.js} +9 -9
- package/dist/website/assets/{configured-chains-Bp7rWkOZ.js → configured-chains-DQ_M8-li.js} +1 -1
- package/dist/website/assets/core-BiDQVY37.js +2 -0
- package/dist/website/assets/{cosmos-connector-meta-CZFaunIB.js → cosmos-connector-meta-DRTieEt0.js} +1 -1
- package/dist/website/assets/dist-BVuLBvyS.js +7 -0
- package/dist/website/assets/{dist-BKdXTi2f.js → dist-Bo7ZdXT8.js} +3 -3
- package/dist/website/assets/{dist-7PipG_eL.js → dist-DlLKQSrv.js} +3 -3
- package/dist/website/assets/dist-ZKTSEBXW.js +1 -0
- package/dist/website/assets/{elliptic-j9CClrcl.js → elliptic-BdE4gFqn.js} +2 -2
- package/dist/website/assets/{esm-DVfwo40P.js → esm-BjyHrLEJ.js} +1 -1
- package/dist/website/assets/events-CMzhc0tf.js +1 -0
- package/dist/website/assets/{extrinsic-encoding-B3zynq2U.js → extrinsic-encoding-BIj1XBpl.js} +1 -1
- package/dist/website/assets/{features-LE43LGiF.js → features-Cy1CFK9a.js} +1 -1
- package/dist/website/assets/{fhevm-relayer-DXLb4mIw-bVmGMiQn.js → fhevm-relayer-DXLb4mIw-Bbrz0cha.js} +5 -3
- package/dist/website/assets/freighter.module-DsmrpiWT.js +1 -0
- package/dist/website/assets/index-7hHJ2eI5.js +558 -0
- package/dist/website/assets/index-zFAIWvcU.css +1 -0
- package/dist/website/assets/{index.es-D6B6PG3M.js → index.es-BGzDKZr_.js} +1 -1
- package/dist/website/assets/index.es-BHs2-Pa6.js +1 -0
- package/dist/website/assets/{index.es-wqX1ruQA.js → index.es-Bpga9r91.js} +5 -5
- package/dist/website/assets/{kms_lib-mPebVu09.js → kms_lib-BgnOy0xU.js} +1 -1
- package/dist/website/assets/{kms_lib-Bh_Z1nH6.js → kms_lib-w0jRi8cP.js} +1 -1
- package/dist/website/assets/{ledger-connector-BOOoTKx_.js → ledger-connector-CNNjVgC1.js} +3 -3
- package/dist/website/assets/{lib-es-5LFNYQ9J.js → lib-es-DmH9FYVZ.js} +1 -1
- package/dist/website/assets/lobstr.module-BUAItZUt.js +1 -0
- package/dist/website/assets/{nacl-fast-BI97gFtf.js → nacl-fast-B5R4wpqG.js} +1 -1
- package/dist/website/assets/{nacl-util-DCWJejqG.js → nacl-util-6167mj42.js} +1 -1
- package/dist/website/assets/{network-CEcIzsgc.js → network-BVzpe0Ii.js} +1 -1
- package/dist/website/assets/{polkadot-ledger-transaction-DaDP252u.js → polkadot-ledger-transaction-Dp6EFfyV.js} +1 -1
- package/dist/website/assets/registry-BgQw-qJW.js +1 -0
- package/dist/website/assets/{reward-rate-chart-COP_M115.js → reward-rate-chart-CO_yI4og.js} +4 -4
- package/dist/website/assets/{safe-buffer-Dz6e-rwu.js → safe-buffer-BUgQmBOp.js} +1 -1
- package/dist/website/assets/{safe-connector-DG2cXEO5.js → safe-connector-BObu9WgG.js} +2 -2
- package/dist/website/assets/{solana-connector-DSpWnxwA.js → solana-connector-CVuV_EKp.js} +1 -1
- package/dist/website/assets/{src-Zq1Jw-Sn.js → src-DbdC_Alu.js} +1 -1
- package/dist/website/assets/{src-hSPfFTzN.js → src-Dl7INWvU.js} +1 -1
- package/dist/website/assets/state-D5Nw1L4F.js +1 -0
- package/dist/website/assets/{stellar-connector-BAbbdkSK.js → stellar-connector-Ba7Jcrbg.js} +1 -1
- package/dist/website/assets/styles.css-NtRiu07M.js +1 -0
- package/dist/website/assets/substrate-connector-hQ3vc47X.js +2 -0
- package/dist/website/assets/tfhe-BACovsAk.js +1 -0
- package/dist/website/assets/{tfhe-DuWT_ao1.js → tfhe-BSAXrnM6.js} +1 -1
- package/dist/website/assets/ton-connector-CU1xiP2u.js +2264 -0
- package/dist/website/assets/tracking-variants-CtfEiKNR.js +93 -0
- package/dist/website/assets/{transaction-BH4ssPh3.js → transaction-B5hUD0AE.js} +1 -1
- package/dist/website/assets/{transaction-BVuftLt1.js → transaction-BWEzzOww.js} +1 -1
- package/dist/website/assets/transaction-BmFUkzQv.js +2 -0
- package/dist/website/assets/{transaction-1KdJeqcp.js → transaction-C_iyacpP.js} +1 -1
- package/dist/website/assets/{tron-connector-CJURHEQe.js → tron-connector-gXtlAAuG.js} +7 -7
- package/dist/website/assets/{tx-Bkou_ALe.js → tx-Cosvp39i.js} +1 -1
- package/dist/website/assets/{utils-CH0e59XB.js → utils-meUBO1X1.js} +1 -1
- package/dist/website/assets/{viem-BQ_7aeKB.js → viem-8-EtcU49.js} +1 -1
- package/dist/website/assets/{w3m-modal-BLY--NNS.js → w3m-modal-HS9RLkN8.js} +2 -2
- package/dist/website/assets/wallet-manager-BQrZx180.js +5 -0
- package/dist/website/assets/{web-4qAQ-Ymk.js → web-azgm2Psf.js} +1 -1
- package/dist/website/assets/{wui-list-item-1gzb5UQJ.js → wui-list-item-CfZ1WQql.js} +1 -1
- package/dist/website/assets/{xbull.module-B4N1LGQD.js → xbull.module-DQx6rh7x.js} +1 -1
- package/dist/website/index.html +19 -19
- package/package.json +2 -2
- package/dist/website/assets/AlertController-CH5fpr36.js +0 -1
- package/dist/website/assets/DateTime-DR7XeJxF.js +0 -1
- package/dist/website/assets/ModalController-CWwEAkfw.js +0 -5
- package/dist/website/assets/assets-Dk5ppLtc.js +0 -2
- package/dist/website/assets/bignumber-CziKLYjt.js +0 -1
- package/dist/website/assets/blakejs-Dx-Zt5zT.js +0 -3
- package/dist/website/assets/bn-CJG5j3KW.js +0 -1
- package/dist/website/assets/core-uatW2d6Y.js +0 -2
- package/dist/website/assets/dist-CELdgNh9.js +0 -1
- package/dist/website/assets/dist-omv2KNC4.js +0 -5
- package/dist/website/assets/events-D2w4OsQJ.js +0 -1
- package/dist/website/assets/freighter.module-CaBNS6Y-.js +0 -1
- package/dist/website/assets/index-CRRnuuvK.js +0 -540
- package/dist/website/assets/index-mVJBJZFp.css +0 -1
- package/dist/website/assets/index.es-DCi2xZ1b.js +0 -1
- package/dist/website/assets/lobstr.module-GQjJAf8P.js +0 -1
- package/dist/website/assets/registry-DVfYVrCY.js +0 -1
- package/dist/website/assets/state-B8Vu3fYx.js +0 -1
- package/dist/website/assets/styles.css-BK5OO2Hh.js +0 -1
- package/dist/website/assets/substrate-connector-CwnGlD2K.js +0 -2
- package/dist/website/assets/tfhe-PDJAG8Bv.js +0 -1
- package/dist/website/assets/ton-connector-DMNOeieX.js +0 -2264
- package/dist/website/assets/tracking-variants-CuRpr0B_.js +0 -85
- package/dist/website/assets/transaction-CbxrIerN.js +0 -2
- package/dist/website/assets/wallet-manager-D8tOJ1jy.js +0 -5
- package/dist/website/mockServiceWorker.js +0 -460
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,o as t,r as n,s as r,t as i}from"./rolldown-runtime-BcKkbAw3.js";import{Bt as a}from"./Result-DQM8aaFz.js";import{A as o,k as s,o as c,z as l}from"./assets-DXO6qW6R.js";import{$ as u,k as d}from"./Effect-Cu_VlOsF.js";import{n as f,t as p}from"./sha256-DmRqOOd6.js";import{n as m,t as h}from"./sha3-DRlIjSdj.js";import{n as g,r as ee,t as _}from"./dist-ZKTSEBXW.js";import{n as v,r as te,t as ne}from"./eventemitter3-CTnouYki.js";import{n as re,t as ie}from"./ed25519-DWgFEKI3.js";import{n as ae,t as oe}from"./bn-Ck4DeaX2.js";import{t as se}from"./bs58-gzsgdke5.js";import{n as ce,t as le}from"./secp256k1-BcfUQvi6.js";import{t as ue}from"./esm-DhvlA6gG.js";te();var y=class extends Error{constructor(e,t){super(e),this.error=t}},de=class extends y{constructor(){super(...arguments),this.name=`WalletNotReadyError`}},fe=class extends y{constructor(){super(...arguments),this.name=`WalletConfigError`}},pe=class extends y{constructor(){super(...arguments),this.name=`WalletConnectionError`}},me=class extends y{constructor(){super(...arguments),this.name=`WalletDisconnectedError`}},he=class extends y{constructor(){super(...arguments),this.name=`WalletDisconnectionError`}},ge=class extends y{constructor(){super(...arguments),this.name=`WalletAccountError`}},_e=class extends y{constructor(){super(...arguments),this.name=`WalletPublicKeyError`}},ve=class extends y{constructor(){super(...arguments),this.name=`WalletNotConnectedError`}},ye=class extends y{constructor(){super(...arguments),this.name=`WalletSendTransactionError`}},be=class extends y{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},xe=class extends y{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Se=class extends y{constructor(){super(...arguments),this.name=`WalletSignInError`}},Ce;(function(e){e.Installed=`Installed`,e.NotDetected=`NotDetected`,e.Loadable=`Loadable`,e.Unsupported=`Unsupported`})(Ce||={});var we=class extends ne{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){let r=this.publicKey;if(!r)throw new ve;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}};function Te(e){if(typeof window>`u`||typeof document>`u`)return;let t=[];function n(){if(e())for(let e of t)e()}let r=setInterval(n,1e3);t.push(()=>clearInterval(r)),document.readyState===`loading`&&(document.addEventListener(`DOMContentLoaded`,n,{once:!0}),t.push(()=>document.removeEventListener(`DOMContentLoaded`,n))),document.readyState!==`complete`&&(window.addEventListener(`load`,n,{once:!0}),t.push(()=>window.removeEventListener(`load`,n))),n()}function Ee(){if(!navigator)return!1;let e=navigator.userAgent.toLowerCase(),t=e.includes(`iphone`)||e.includes(`ipad`),n=e.includes(`safari`);return t&&n}function De(e){return`version`in e}var Oe=class extends we{async sendTransaction(e,t,n={}){let r=!0;try{if(De(e)){if(!this.supportedTransactionVersions)throw new ye(`Sending versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(e.version))throw new ye(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);let r=e.serialize();return await t.sendRawTransaction(r,n)}catch(e){throw e instanceof be?(r=!1,e):new ye(e?.message,e)}}try{let{signers:r,...i}=n;e=await this.prepareTransaction(e,t,i),r?.length&&e.partialSign(...r),e=await this.signTransaction(e);let a=e.serialize();return await t.sendRawTransaction(a,i)}catch(e){throw e instanceof be?(r=!1,e):new ye(e?.message,e)}}catch(e){throw r&&this.emit(`error`,e),e}}async signAllTransactions(e){for(let t of e)if(De(t)){if(!this.supportedTransactionVersions)throw new be(`Signing versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(t.version))throw new be(`Signing transaction version ${t.version} isn't supported by this wallet`)}let t=[];for(let n of e)t.push(await this.signTransaction(n));return t}},ke=class extends Oe{},Ae=class extends ke{},je;(function(e){e.Mainnet=`mainnet-beta`,e.Testnet=`testnet`,e.Devnet=`devnet`})(je||={});var Me=n({TextDecoder:()=>ze,TextEncoder:()=>Be});function Ne(e,t,n){return t<=e&&e<=n}function Pe(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function Fe(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319){if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}}r+=1}return i}function Ie(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function Le(e){this.tokens=[].slice.call(e)}function Re(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function ze(e,t){if(!(this instanceof ze))return new ze(e,t);if(e=e===void 0?Ge:String(e).toLowerCase(),e!==Ge)throw Error(`Encoding not supported. Only utf-8 is supported`);t=Pe(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Be(e,t){if(!(this instanceof Be))return new Be(e,t);if(e=e===void 0?Ge:String(e).toLowerCase(),e!==Ge)throw Error(`Encoding not supported. Only utf-8 is supported`);t=Pe(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function Ve(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Ue&&i!==0)return i=0,Re(t);if(s===Ue)return We;if(i===0){if(Ne(s,0,127))return s;if(Ne(s,194,223))i=1,n=s-192;else if(Ne(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(Ne(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return Re(t);return n<<=6*i,null}if(!Ne(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),Re(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function He(e){e.fatal,this.handler=function(e,t){if(t===Ue)return We;if(Ne(t,0,127))return t;var n,r;Ne(t,128,2047)?(n=1,r=192):Ne(t,2048,65535)?(n=2,r=224):Ne(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Ue,We,Ge,Ke=e((()=>{Ue=-1,Le.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Ue},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},We=-1,Ge=`utf-8`,ze.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=Pe(t),this._streaming||(this._decoder=new Ve({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new Le(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==We);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===We)break;a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a))}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Ie(i)}},Be.prototype={encode:function(e,t){e=e?String(e):``,t=Pe(t),this._streaming||(this._encoder=new He(this._options)),this._streaming=!!t.stream;for(var n=[],r=new Le(Fe(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==We);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==We;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),qe=i((e=>{ee();var n=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!=="default"&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.deserializeUnchecked=e.deserialize=e.serialize=e.BinaryReader=e.BinaryWriter=e.BorshError=e.baseDecode=e.baseEncode=void 0;var s=o(oe()),c=o(se()),l=a((Ke(),t(Me))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=_.from(e,`utf8`)),c.default.encode(_.from(e))}e.baseEncode=d;function f(e){return _.from(c.default.decode(e))}e.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};e.BorshError=m;var h=class{constructor(){this.buf=_.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=_.concat([this.buf,_.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(_.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(_.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(_.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(_.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=_.concat([_.from(this.buf.subarray(0,this.length)),e,_.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=_.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(_.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};e.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var v=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],v.prototype,`readU8`,null),i([g],v.prototype,`readU16`,null),i([g],v.prototype,`readU32`,null),i([g],v.prototype,`readU64`,null),i([g],v.prototype,`readU128`,null),i([g],v.prototype,`readU256`,null),i([g],v.prototype,`readU512`,null),i([g],v.prototype,`readString`,null),i([g],v.prototype,`readFixedArray`,null),i([g],v.prototype,`readArray`,null),e.BinaryReader=v;function te(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ne(e,t,n,r,i){try{if(typeof r==`string`)i[`write${te(r)}`](n);else if(r instanceof Array){if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)ne(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{ne(e,t,n,r[0],i)})}else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),ne(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{ne(e,t,a,r.key,i),ne(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else re(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function re(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{ne(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),ne(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function ie(e,t,n=h){let r=new n;return re(e,t,r),r.toArray()}e.serialize=ie;function ae(e,t,n,r){try{if(typeof n==`string`)return r[`read${te(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(ae(e,null,n[0],r));return t}return r.readArray(()=>ae(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?ae(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=ae(e,t,n.key,r),o=ae(e,t,n.value,r);i.set(a,o)}return i}return ce(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function ce(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=ae(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=ae(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function le(e,t,n,r=v){let i=new r(n),a=ce(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}e.deserialize=le;function ue(e,t,n,r=v){return ce(e,t,new r(n))}e.deserializeUnchecked=ue})),Je=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=ae();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var s=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=s;var c=class extends s{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=c;var l=class extends s{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof u||this.layout instanceof d}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=l;var u=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=p;var m=2**32;function h(e){let t=Math.floor(e/m);return{hi32:t,lo32:e-t*m}}function g(e,t){return e*m+t}var ee=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=ee;var _=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=_;var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=v;var te=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=te;var ne=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=ne;var re=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=re;var ie=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=ie;var oe=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=oe;var se=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof s&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof s)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof s&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof s&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof s&&this.count.encode(e.length,t,n),i}};e.Sequence=se;var ce=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=ce;var le=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=le;var ue=class extends le{constructor(e,t){if(!(e instanceof s&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=ue;var y=class extends i{constructor(e,t,n){let r;if(e instanceof u||e instanceof d)r=new ue(new l(e));else if(e instanceof s&&e.isCount())r=new ue(e);else if(e instanceof le)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof u||e instanceof d)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof u||e instanceof d,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new de(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=y;var de=class extends i{constructor(e,t,n,r){if(!(e instanceof y))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=de;function fe(e){return 0>e&&(e+=4294967296),e}var pe=class extends i{constructor(e,t,n){if(!(e instanceof u||e instanceof d))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=fe(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new me(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new he(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=pe;var me=class{constructor(e,t,n){if(!(e instanceof pe))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=fe(this.valueMask<<this.start),this.property=n}decode(e,t){return fe(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==fe(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=fe(e<<this.start);this.container._packedSetValue(fe(t&~this.wordMask)|n)}};e.BitField=me;var he=class extends me{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=he;var ge=class extends i{constructor(e,t){if(!(e instanceof s&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof s||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof s&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof s&&this.length.encode(i,t,n),i}};e.Blob=ge;var _e=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=_e;var ve=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ve;var ye=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=ye,e.greedy=((e,t)=>new c(e,t)),e.offset=((e,t,n)=>new l(e,t,n)),e.u8=(e=>new u(1,e)),e.u16=(e=>new u(2,e)),e.u24=(e=>new u(3,e)),e.u32=(e=>new u(4,e)),e.u40=(e=>new u(5,e)),e.u48=(e=>new u(6,e)),e.nu64=(e=>new ee(e)),e.u16be=(e=>new d(2,e)),e.u24be=(e=>new d(3,e)),e.u32be=(e=>new d(4,e)),e.u40be=(e=>new d(5,e)),e.u48be=(e=>new d(6,e)),e.nu64be=(e=>new _(e)),e.s8=(e=>new f(1,e)),e.s16=(e=>new f(2,e)),e.s24=(e=>new f(3,e)),e.s32=(e=>new f(4,e)),e.s40=(e=>new f(5,e)),e.s48=(e=>new f(6,e)),e.ns64=(e=>new v(e)),e.s16be=(e=>new p(2,e)),e.s24be=(e=>new p(3,e)),e.s32be=(e=>new p(4,e)),e.s40be=(e=>new p(5,e)),e.s48be=(e=>new p(6,e)),e.ns64be=(e=>new te(e)),e.f32=(e=>new ne(e)),e.f32be=(e=>new re(e)),e.f64=(e=>new ie(e)),e.f64be=(e=>new oe(e)),e.struct=((e,t,n)=>new ce(e,t,n)),e.bits=((e,t,n)=>new pe(e,t,n)),e.seq=((e,t,n)=>new se(e,t,n)),e.union=((e,t,n)=>new y(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new ue(e,t)),e.blob=((e,t)=>new ge(e,t)),e.cstr=(e=>new _e(e)),e.utf8=((e,t)=>new ve(e,t)),e.constant=((e,t)=>new ye(e,t))}));function Ye(e){return Array.isArray(e)?`%5B`+e.map(Ye).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Xe([e,t]){return`${e}=${Ye(t)}`}function Ze(e){let t=Object.entries(e).map(Xe).join(`&`);return btoa(t)}function Qe(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Ze(t)}'`),`${n}\``}}var $e,et,tt,nt,rt,it,at,ot=e((()=>{$e=8078e3,et=8078001,tt=8078004,nt=8078005,rt=8078006,it=8078011,at=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([t,i])=>{t===`cause`?r={cause:i.value}:(n===void 0&&(n={__code:e}),Object.defineProperty(n,t,i))});let i=Qe(e,n);super(i,r),this.context=Object.freeze(n===void 0?{__code:e}:n),this.name=`SolanaError`}}}));function st(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function ct(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(st(t,e));return e.write(t,n,0),n}})}function lt(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function ut(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function dt(e,t){if(ut(e)!==ut(t))throw new at(tt);if(ut(e)&&ut(t)&&e.fixedSize!==t.fixedSize)throw new at(nt,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!ut(e)&&!ut(t)&&e.maxSize!==t.maxSize)throw new at(rt,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function ft(e,t,n=0){if(t.length-n<=0)throw new at($e,{codecDescription:e})}function pt(e,t,n,r=0){let i=n.length-r;if(i<t)throw new at(et,{bytesLength:i,codecDescription:e,expected:t})}function mt(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength,a;return typeof SharedArrayBuffer>`u`?a=e.buffer:e.buffer instanceof SharedArrayBuffer?(a=new ArrayBuffer(e.length),new Uint8Array(a).set(new Uint8Array(e))):a=e.buffer,(r===0||r===-e.byteLength)&&i===e.byteLength?a:a.slice(r,r+i)}var ht=e((()=>{ot()}));function gt(e,t,n,r){if(r<t||r>n)throw new at(it,{codecDescription:e,max:n,min:t,value:r})}function _t(e){return e?.endian!==1}function vt(e){return ct({fixedSize:e.size,write(t,n,r){e.range&>(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,_t(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function yt(e){return lt({fixedSize:e.size,read(t,n=0){ft(e.name,t,n),pt(e.name,e.size,t,n);let r=new DataView(mt(t,n,e.size));return[e.get(r,_t(e.config)),n+e.size]}})}var bt,xt,St,Ct=e((()=>{ot(),ht(),bt=(e={})=>vt({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),xt=(e={})=>yt({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),St=(e={})=>dt(bt(e),xt(e))}));function wt(e){return Tt(e)&&typeof e[Symbol.iterator]==`function`}function Tt(e){return typeof e==`object`&&!!e}function Et(e){return Tt(e)&&!Array.isArray(e)}function Dt(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function Ot(e){let{done:t,value:n}=e.next();return t?void 0:n}function kt(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${Dt(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*At(e,t,n,r){wt(e)||(e=[e]);for(let i of e){let e=kt(i,t,n,r);e&&(yield e)}}function*jt(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=jt(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):Tt(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}function Mt(e,t,n){let r=Ft(e,t,{message:n});if(r[0])throw r[0]}function b(e,t,n){let r=Ft(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function Nt(e,t,n){let r=Ft(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Pt(e,t){return!Ft(e,t)[0]}function Ft(e,t,n={}){let r=jt(e,t,n),i=Ot(r);return i[0]?[new Gt(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function It(e,t){return new Kt({type:e,schema:null,validator:t})}function Lt(){return It(`any`,()=>!0)}function x(e){return new Kt({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Dt(e)}`}})}function Rt(){return It(`boolean`,e=>typeof e==`boolean`)}function zt(e){return It(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Dt(t)}`)}function S(e){let t=Dt(e),n=typeof e;return new Kt({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${Dt(n)}`}})}function Bt(){return It(`never`,()=>!1)}function C(e){return new Kt({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function w(){return It(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${Dt(e)}`)}function T(e){return new Kt({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Vt(e,t){return new Kt({type:`record`,schema:null,*entries(n){if(Tt(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return Et(e)||`Expected an object, but received: ${Dt(e)}`},coercer(e){return Et(e)?{...e}:e}})}function E(){return It(`string`,e=>typeof e==`string`||`Expected a string, but received: ${Dt(e)}`)}function Ht(e){let t=Bt();return new Kt({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Dt(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function D(e){let t=Object.keys(e);return new Kt({type:`type`,schema:e,*entries(n){if(Tt(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return Et(e)||`Expected an object, but received: ${Dt(e)}`},coercer(e){return Et(e)?{...e}:e}})}function O(e){let t=e.map(e=>e.type).join(` | `);return new Kt({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=jt(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Dt(n)}`,...i]}})}function Ut(){return It(`unknown`,()=>!0)}function Wt(e,t,n){return new Kt({...e,coercer:(r,i)=>Pt(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}var Gt,Kt,qt=e((()=>{Gt=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}},Kt=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,this.validator=r?(e,t)=>At(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>At(i(e,t),t,this,e):()=>[]}assert(e,t){return Mt(e,this,t)}create(e,t){return b(e,this,t)}is(e){return Pt(e,this)}mask(e,t){return Nt(e,this,t)}validate(e,t={}){return Ft(e,this,t)}}}));function Jt(){if(!Yt&&(Yt=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!Yt))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return Yt(Xt)}var Yt,Xt,Zt=e((()=>{Xt=new Uint8Array(16)})),Qt,$t=e((()=>{Qt=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function en(e){return typeof e==`string`&&Qt.test(e)}var tn=e((()=>{$t()}));function nn(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(k[e[t+0]]+k[e[t+1]]+k[e[t+2]]+k[e[t+3]]+`-`+k[e[t+4]]+k[e[t+5]]+`-`+k[e[t+6]]+k[e[t+7]]+`-`+k[e[t+8]]+k[e[t+9]]+`-`+k[e[t+10]]+k[e[t+11]]+k[e[t+12]]+k[e[t+13]]+k[e[t+14]]+k[e[t+15]]).toLowerCase();if(!en(n))throw TypeError(`Stringified UUID is invalid`);return n}var k,rn,an=e((()=>{for(tn(),k=[],rn=0;rn<256;++rn)k.push((rn+256).toString(16).substr(1))}));function on(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||sn,o=e.clockseq===void 0?cn:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||Jt)();a??=sn=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=cn=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?un+1:e.nsecs,u=c-ln+(l-un)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>ln)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);ln=c,un=l,cn=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||nn(i)}var sn,cn,ln,un,dn=e((()=>{Zt(),an(),ln=0,un=0}));function fn(e){if(!en(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var pn=e((()=>{tn()}));function mn(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function hn(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=mn(e)),typeof r==`string`&&(r=fn(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return nn(o)}try{r.name=e}catch{}return r.DNS=gn,r.URL=_n,r}var gn,_n,vn=e((()=>{an(),pn(),gn=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,_n=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function yn(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return bn(Sn(Cn(e),e.length*8))}function bn(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function xn(e){return(e+64>>>9<<4)+14+1}function Sn(e,t){e[t>>5]|=128<<t%32,e[xn(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=A(n,r,i,a,e[o],7,-680876936),a=A(a,n,r,i,e[o+1],12,-389564586),i=A(i,a,n,r,e[o+2],17,606105819),r=A(r,i,a,n,e[o+3],22,-1044525330),n=A(n,r,i,a,e[o+4],7,-176418897),a=A(a,n,r,i,e[o+5],12,1200080426),i=A(i,a,n,r,e[o+6],17,-1473231341),r=A(r,i,a,n,e[o+7],22,-45705983),n=A(n,r,i,a,e[o+8],7,1770035416),a=A(a,n,r,i,e[o+9],12,-1958414417),i=A(i,a,n,r,e[o+10],17,-42063),r=A(r,i,a,n,e[o+11],22,-1990404162),n=A(n,r,i,a,e[o+12],7,1804603682),a=A(a,n,r,i,e[o+13],12,-40341101),i=A(i,a,n,r,e[o+14],17,-1502002290),r=A(r,i,a,n,e[o+15],22,1236535329),n=j(n,r,i,a,e[o+1],5,-165796510),a=j(a,n,r,i,e[o+6],9,-1069501632),i=j(i,a,n,r,e[o+11],14,643717713),r=j(r,i,a,n,e[o],20,-373897302),n=j(n,r,i,a,e[o+5],5,-701558691),a=j(a,n,r,i,e[o+10],9,38016083),i=j(i,a,n,r,e[o+15],14,-660478335),r=j(r,i,a,n,e[o+4],20,-405537848),n=j(n,r,i,a,e[o+9],5,568446438),a=j(a,n,r,i,e[o+14],9,-1019803690),i=j(i,a,n,r,e[o+3],14,-187363961),r=j(r,i,a,n,e[o+8],20,1163531501),n=j(n,r,i,a,e[o+13],5,-1444681467),a=j(a,n,r,i,e[o+2],9,-51403784),i=j(i,a,n,r,e[o+7],14,1735328473),r=j(r,i,a,n,e[o+12],20,-1926607734),n=M(n,r,i,a,e[o+5],4,-378558),a=M(a,n,r,i,e[o+8],11,-2022574463),i=M(i,a,n,r,e[o+11],16,1839030562),r=M(r,i,a,n,e[o+14],23,-35309556),n=M(n,r,i,a,e[o+1],4,-1530992060),a=M(a,n,r,i,e[o+4],11,1272893353),i=M(i,a,n,r,e[o+7],16,-155497632),r=M(r,i,a,n,e[o+10],23,-1094730640),n=M(n,r,i,a,e[o+13],4,681279174),a=M(a,n,r,i,e[o],11,-358537222),i=M(i,a,n,r,e[o+3],16,-722521979),r=M(r,i,a,n,e[o+6],23,76029189),n=M(n,r,i,a,e[o+9],4,-640364487),a=M(a,n,r,i,e[o+12],11,-421815835),i=M(i,a,n,r,e[o+15],16,530742520),r=M(r,i,a,n,e[o+2],23,-995338651),n=N(n,r,i,a,e[o],6,-198630844),a=N(a,n,r,i,e[o+7],10,1126891415),i=N(i,a,n,r,e[o+14],15,-1416354905),r=N(r,i,a,n,e[o+5],21,-57434055),n=N(n,r,i,a,e[o+12],6,1700485571),a=N(a,n,r,i,e[o+3],10,-1894986606),i=N(i,a,n,r,e[o+10],15,-1051523),r=N(r,i,a,n,e[o+1],21,-2054922799),n=N(n,r,i,a,e[o+8],6,1873313359),a=N(a,n,r,i,e[o+15],10,-30611744),i=N(i,a,n,r,e[o+6],15,-1560198380),r=N(r,i,a,n,e[o+13],21,1309151649),n=N(n,r,i,a,e[o+4],6,-145523070),a=N(a,n,r,i,e[o+11],10,-1120210379),i=N(i,a,n,r,e[o+2],15,718787259),r=N(r,i,a,n,e[o+9],21,-343485551),n=wn(n,s),r=wn(r,c),i=wn(i,l),a=wn(a,u)}return[n,r,i,a]}function Cn(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(xn(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function wn(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function Tn(e,t){return e<<t|e>>>32-t}function En(e,t,n,r,i,a){return wn(Tn(wn(wn(t,e),wn(r,a)),i),n)}function A(e,t,n,r,i,a,o){return En(t&n|~t&r,e,t,i,a,o)}function j(e,t,n,r,i,a,o){return En(t&r|n&~r,e,t,i,a,o)}function M(e,t,n,r,i,a,o){return En(t^n^r,e,t,i,a,o)}function N(e,t,n,r,i,a,o){return En(n^(t|~r),e,t,i,a,o)}var Dn=e((()=>{})),On,kn=e((()=>{vn(),Dn(),On=hn(`v3`,48,yn)}));function An(e,t,n){e||={};var r=e.random||(e.rng||Jt)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return nn(r)}var jn=e((()=>{Zt(),an()}));function Mn(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function Nn(e,t){return e<<t|e>>>32-t}function Pn(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=Nn(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],ee=n[2],_=n[3],v=n[4],te=0;te<80;++te){var ne=Math.floor(te/20),re=Nn(h,5)+Mn(ne,g,ee,_)+v+t[ne]+f[te]>>>0;v=_,_=ee,ee=Nn(g,30)>>>0,g=h,h=re}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+ee>>>0,n[3]=n[3]+_>>>0,n[4]=n[4]+v>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var Fn=e((()=>{})),In,Ln=e((()=>{vn(),Fn(),In=hn(`v5`,80,Pn)})),Rn,zn=e((()=>{Rn=`00000000-0000-0000-0000-000000000000`}));function Bn(e){if(!en(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var Vn=e((()=>{tn()})),Hn=n({NIL:()=>Rn,parse:()=>fn,stringify:()=>nn,v1:()=>on,v3:()=>On,v4:()=>An,v5:()=>In,validate:()=>en,version:()=>Bn}),Un=e((()=>{dn(),kn(),jn(),Ln(),zn(),Vn(),tn(),an(),pn()})),Wn=i(((e,n)=>{var r=(Un(),t(Hn)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),Gn=i(((e,n)=>{var r=(Un(),t(Hn)).v4,i=Wn(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`&&t.notificationIdNull},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3){if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}n(null,r.error,r.result);return}n(null,r)}}));function Kn(e,t){return new qn(e,t)}var qn,Jn,Yn,Xn=e((()=>{ee(),te(),qn=class extends v.default{socket;constructor(e,t,n){super(),this.socket=new window.WebSocket(e,n),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}},Jn=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Yn=class extends v.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),this.dataPack=c||new Jn,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=g.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}}}));function Zn(e){try{return ie.ExtendedPoint.fromHex(e),!0}catch{return!1}}function Qn(e){return e._bn!==void 0}function $n(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return $n({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function P(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function F(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}t|=128,e.push(t)}}function I(e,t){if(!e)throw Error(t||`Assertion failed`)}function L(e){if(e.length===0)throw Error(Wr);return e.shift()}function R(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(Wr);return e.splice(...t)}function er(e){let t=R(e,0,4);return t[0]+t[1]*256+t[2]*2**16+t[3]*2**24}function tr(e){let t=R(e,0,8),n=BigInt(0);for(let e=t.length-1;e>=0;e--)n=n<<BigInt(8)|BigInt(t[e]);return I(n<=BigInt(2**53-1),`Expected u64 value to be within the safe integer range`),Number(n)}async function nr(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new si({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function rr(e){return new Promise(t=>setTimeout(t,e))}function z(e,t){let n=e.layout.span>=0?e.layout.span:$n(e,t),r=g.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function ir(e){let t=(0,Sr.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=St();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>{let i=a.encode(e);return r(i,t,n)},i}function ar(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function or(){if(hi)return mi;hi=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return mi=function(e){var t=n(e,!1);if(t!==void 0)return``+t},mi}function sr(e){let t=0;for(;e>1;)e/=2,t++;return t}function cr(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}function lr(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}function ur(e){let t=e.match(wi);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}function dr(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function B(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function fr(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function pr(e){return O([D({jsonrpc:S(`2.0`),id:E(),result:e}),D({jsonrpc:S(`2.0`),id:E(),error:D({code:Ut(),message:E(),data:T(Lt())})})])}function V(e){return Wt(pr(e),Oi,t=>`error`in t?t:{...t,result:b(t.result,e)})}function H(e){return V(D({context:D({slot:w()}),value:e}))}function mr(e){return D({context:D({slot:w()}),value:e})}function hr(e,t){if(e===0)return new Kr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new K(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:U.default.decode(e.data)})),addressTableLookups:t.addressTableLookups});if(e===1){let e=t.transactionConfig;if(e==null)throw Error("Expected a version 1 transaction message response to have a `transactionConfig`");return new Zr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new K(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:U.default.decode(e.data)})),transactionConfig:e})}return new Gr(t)}function gr(e,t,n,r,i,a){let o=n||yi,s;a!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let c;return r&&(c=async(e,t)=>{let n=await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}});return await o(...n)}),new Cr.default(async(n,r)=>{let a={method:`POST`,body:n,agent:s,headers:Object.assign({"Content-Type":`application/json`},t||{},uo)};try{let t=5,n,s=500;for(;n=c?await c(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${s}ms delay...`),await rr(s),s*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function _r(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function vr(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}function yr(e,t){let n=t===!1?`http`:`https`;if(!e)return Lo[n].devnet;let r=Lo[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}var br,U,xr,W,Sr,Cr,wr,Tr,Er,Dr,G,Or,kr,Ar,jr,K,Mr,Nr,Pr,Fr,Ir,q,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,J,Y,ti,ni,ri,ii,ai,oi,si,X,ci,li,ui,di,Z,Q,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,$,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro=e((()=>{ee(),re(),br=r(oe()),U=r(se()),p(),xr=qe(),W=r(Je()),Sr=r(Je()),Ct(),qt(),Cr=r(Gn()),Xn(),h(),le(),ie.utils.randomPrivateKey,wr=()=>{let e=ie.utils.randomPrivateKey(),t=Tr(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},Tr=ie.getPublicKey,Er=(e,t)=>ie.sign(e,t.slice(0,32)),Dr=ie.verify,G=e=>g.isBuffer(e)?e:e instanceof Uint8Array?g.from(e.buffer,e.byteOffset,e.byteLength):g.from(e),Or=class{constructor(e){Object.assign(this,e)}encode(){return g.from((0,xr.serialize)(kr,this))}static decode(e){return(0,xr.deserialize)(kr,this,e)}static decodeUnchecked(e){return(0,xr.deserializeUnchecked)(kr,this,e)}},kr=new Map,jr=1,K=class e extends Or{constructor(e){if(super({}),this._bn=void 0,Qn(e))this._bn=e._bn;else{if(typeof e==`string`){let t=U.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new br.default(t)}else this._bn=new br.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(jr);return jr+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return U.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(g);if(e.length===32)return e;let t=g.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){let i=g.concat([t.toBuffer(),g.from(n),r.toBuffer()]),a=f(i);return new e(a)}static createProgramAddressSync(t,n){let r=g.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=g.concat([r,G(e)])}),r=g.concat([r,n.toBuffer(),g.from(`ProgramDerivedAddress`)]);let i=f(r);if(Zn(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(g.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return Zn(new e(t).toBytes())}},Ar=K,K.default=new Ar(`11111111111111111111111111111111`),kr.set(K,{kind:`struct`,fields:[[`_bn`,`u256`]]}),new K(`BPFLoader1111111111111111111111111111111111`),Mr=1232,Nr=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Nr.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`}),Pr=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Pr.prototype,"name",{value:`TransactionExpiredTimeoutError`}),Fr=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Fr.prototype,"name",{value:`TransactionExpiredNonceInvalidError`}),Ir=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},q=(e=`publicKey`)=>W.blob(32,e),Lr=(e=`signature`)=>W.blob(64,e),Rr=(e=`string`)=>{let t=W.struct([W.u32(`length`),W.u32(`lengthPadding`),W.blob(W.offset(W.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>{let i={chars:g.from(e,`utf8`)};return r(i,t,n)},i.alloc=e=>W.u32().span+W.u32().span+g.from(e,`utf8`).length,i},zr=(e=`authorized`)=>W.struct([q(`staker`),q(`withdrawer`)],e),Br=(e=`lockup`)=>W.struct([W.ns64(`unixTimestamp`),W.ns64(`epoch`),q(`custodian`)],e),Vr=(e=`voteInit`)=>W.struct([q(`nodePubkey`),q(`authorizedVoter`),q(`authorizedWithdrawer`),W.u8(`commission`)],e),Hr=(e=`voteAuthorizeWithSeedArgs`)=>W.struct([W.u32(`voteAuthorizationType`),q(`currentAuthorityDerivedKeyOwnerPubkey`),Rr(`currentAuthorityDerivedKeySeed`),q(`newAuthorized`)],e),Ur=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];I(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{I(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];I(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new K(e)),...n.map(([e])=>new K(e)),...r.map(([e])=>new K(e)),...i.map(([e])=>new K(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(t.length!==0||r.length!==0)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new K(i),a=e.findIndex(e=>e.equals(t));a>=0&&(I(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},Wr=`Reached end of buffer unexpectedly`,Gr=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new K(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:U.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Ir(this.staticAccountKeys)}static compile(t){let[n,r]=Ur.compile(t.instructions,t.payerKey).getMessageComponents(),i=new Ir(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:U.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];F(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(U.default.decode(e.data)),i=[];F(i,t.length);let a=[];return F(a,r.length),{programIdIndex:n,keyIndicesCount:g.from(i),keyIndices:t,dataLength:g.from(a),data:r}}),r=[];F(r,n.length);let i=g.alloc(Mr);g.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=W.struct([W.u8(`programIdIndex`),W.blob(e.keyIndicesCount.length,`keyIndicesCount`),W.seq(W.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),W.blob(e.dataLength.length,`dataLength`),W.seq(W.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=W.struct([W.blob(1,`numRequiredSignatures`),W.blob(1,`numReadonlySignedAccounts`),W.blob(1,`numReadonlyUnsignedAccounts`),W.blob(t.length,`keyCount`),W.seq(q(`key`),e,`keys`),q(`recentBlockhash`)]),s={numRequiredSignatures:g.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:g.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:g.from([this.header.numReadonlyUnsignedAccounts]),keyCount:g.from(t),keys:this.accountKeys.map(e=>G(e.toBytes())),recentBlockhash:U.default.decode(this.recentBlockhash)},c=g.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=L(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=L(n),a=L(n),o=P(n),s=[];for(let e=0;e<o;e++){let e=R(n,0,32);s.push(new K(g.from(e)))}let c=R(n,0,32),l=P(n),u=[];for(let e=0;e<l;e++){let e=L(n),t=R(n,0,P(n)),r=R(n,0,P(n)),i=U.default.encode(g.from(r));u.push({programIdIndex:e,accounts:t,data:i})}let d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:U.default.encode(g.from(c)),accountKeys:s,instructions:u};return new e(d)}},Kr=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new Ir(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=Ur.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new Ir(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];F(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];F(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];F(i,this.addressTableLookups.length);let a=W.struct([W.u8(`prefix`),W.struct([W.u8(`numRequiredSignatures`),W.u8(`numReadonlySignedAccounts`),W.u8(`numReadonlyUnsignedAccounts`)],`header`),W.blob(e.length,`staticAccountKeysLength`),W.seq(q(),this.staticAccountKeys.length,`staticAccountKeys`),q(`recentBlockhash`),W.blob(n.length,`instructionsLength`),W.blob(t.length,`serializedInstructions`),W.blob(i.length,`addressTableLookupsLength`),W.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(Mr),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:U.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(Mr);for(let n of this.compiledInstructions){let r=[];F(r,n.accountKeyIndexes.length);let i=[];F(i,n.data.length);let a=W.struct([W.u8(`programIdIndex`),W.blob(r.length,`encodedAccountKeyIndexesLength`),W.seq(W.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),W.blob(i.length,`encodedDataLength`),W.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Mr);for(let n of this.addressTableLookups){let r=[];F(r,n.writableIndexes.length);let i=[];F(i,n.readonlyIndexes.length);let a=W.struct([q(`accountKey`),W.blob(r.length,`encodedWritableIndexesLength`),W.seq(W.u8(),n.writableIndexes.length,`writableIndexes`),W.blob(i.length,`encodedReadonlyIndexesLength`),W.seq(W.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=L(n),i=r&127;I(r!==i,`Expected versioned message but received legacy message`);let a=i;I(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:L(n),numReadonlySignedAccounts:L(n),numReadonlyUnsignedAccounts:L(n)},s=[],c=P(n);for(let e=0;e<c;e++)s.push(new K(R(n,0,32)));let l=U.default.encode(R(n,0,32)),u=P(n),d=[];for(let e=0;e<u;e++){let e=L(n),t=R(n,0,P(n)),r=P(n),i=new Uint8Array(R(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=P(n),p=[];for(let e=0;e<f;e++){let e=new K(R(n,0,32)),t=R(n,0,P(n)),r=R(n,0,P(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},qr=3,Jr=4,Yr=8,Xr=16,Zr=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.transactionConfig=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.transactionConfig=e.transactionConfig??{computeUnitLimit:null,heapSize:null,loadedAccountsDataSizeLimit:null,priorityFee:null}}get version(){return 1}get addressTableLookups(){return[]}getAccountKeys(){return new Ir(this.staticAccountKeys)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?!1:e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}serialize(){throw Error(`Serialization of version 1 transaction messages is not supported`)}static deserialize(t){let n=[...t],r=L(n),i=r&127;I(r!==i,`Expected versioned message but received legacy message`);let a=i;I(a===1,`Expected versioned message with version 1 but found version ${a}`);let o={numRequiredSignatures:L(n),numReadonlySignedAccounts:L(n),numReadonlyUnsignedAccounts:L(n)},s=er(n);I(!(s&-32),`Unexpected bits set in the transaction config mask`);let c=s&qr;I(c===0||c===qr,`Expected both or neither of the priority fee bits to be set in the transaction config mask`);let l=U.default.encode(R(n,0,32)),u=L(n),d=L(n),f=[];for(let e=0;e<d;e++)f.push(new K(R(n,0,32)));let p={computeUnitLimit:null,heapSize:null,loadedAccountsDataSizeLimit:null,priorityFee:null};c!==0&&(p.priorityFee=tr(n)),s&Jr&&(p.computeUnitLimit=er(n)),s&Yr&&(p.loadedAccountsDataSizeLimit=er(n)),s&Xr&&(p.heapSize=er(n));let m=[];for(let e=0;e<u;e++){let e=L(n),t=L(n),r=L(n)+L(n)*256;m.push({accountKeyIndexesLength:t,dataLength:r,programIdIndex:e})}let h=[];for(let e of m)h.push({programIdIndex:e.programIdIndex,accountKeyIndexes:R(n,0,e.accountKeyIndexesLength),data:new Uint8Array(R(n,0,e.dataLength))});return I(n.length===0,`Expected no bytes to remain after deserializing a version 1 message`),new e({header:o,staticAccountKeys:f,recentBlockhash:l,compiledInstructions:h,transactionConfig:p})}},Qr={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Qr.deserializeMessageVersion(e);if(t===`legacy`)return Gr.from(e);if(t===0)return Kr.deserialize(e);if(t===1)return Zr.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},$r=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),ei=g.alloc(64).fill(0),J=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=g.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Y=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e){if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new J(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<1&&console.warn(`No instructions provided`);let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new K(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,console.warn(`Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.`));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:U.default.encode(t)}});return p.forEach(e=>{I(e.programIdIndex>=0),e.accounts.forEach(e=>I(e>=0))}),new Gr({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return!t.has(n)&&(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=Er(n,e.secretKey);this._addSignature(e.publicKey,G(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){I(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=g.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):Dr(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];F(n,t.length);let r=n.length+t.length*64+e.length,i=g.alloc(r);return I(t.length<256),g.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(I(e.length===64,`signature has invalid length`),g.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),I(i.length<=Mr,`Transaction too large: ${i.length} > ${Mr}`),i}get keys(){return I(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return I(this.instructions.length===1),this.instructions[0].programId}get data(){return I(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=P(n),i=[];for(let e=0;e<r;e++){let e=R(n,0,64);i.push(U.default.encode(g.from(e)))}return e.populate(Gr.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==U.default.encode(ei)?null:U.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new J({keys:n,programId:t.accountKeys[e.programIdIndex],data:U.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},ti=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)I(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];F(t,this.signatures.length);let n=W.struct([W.blob(t.length,`encodedSignaturesLength`),W.seq(Lr(),this.signatures.length,`signatures`),W.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){if(t[0]===129)return this.deserializeV1(t);let n=[...t],r=[],i=P(n);for(let e=0;e<i;e++)r.push(new Uint8Array(R(n,0,64)));let a=Qr.deserialize(new Uint8Array(n));return new e(a,r)}static deserializeV1(t){let n=t[1],r=n*64,i=t.length-r;I(i>0,`Expected transaction to have enough bytes for its signatures`);let a=Qr.deserialize(t.slice(0,i)),o=[];for(let e=0;e<n;e++){let n=i+e*64;o.push(t.slice(n,n+64))}return new e(a,o)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));I(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=Er(t,r.secretKey)}}addSignature(e,t){I(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));I(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},ni=1e3/(160/64),ri=new K(`SysvarC1ock11111111111111111111111111111111`),new K(`SysvarEpochSchedu1e111111111111111111111111`),new K(`Sysvar1nstructions1111111111111111111111111`),ii=new K(`SysvarRecentB1ockHashes11111111111111111111`),ai=new K(`SysvarRent111111111111111111111111111111111`),new K(`SysvarRewards111111111111111111111111111111`),new K(`SysvarS1otHashes111111111111111111111111111`),new K(`SysvarS1otHistory11111111111111111111111111`),oi=new K(`SysvarStakeHistory1111111111111111111111111`),si=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},X=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}},ci=W.nu64(`lamportsPerSignature`),li=W.struct([W.u32(`version`),W.u32(`state`),q(`authorizedPubkey`),q(`nonce`),W.struct([ci],`feeCalculator`)]),ui=li.span,di=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=li.decode(G(t),0);return new e({authorizedPubkey:new K(n.authorizedPubkey),nonce:new K(n.nonce).toString(),feeCalculator:n.feeCalculator})}},Z=Object.freeze({Create:{index:0,layout:W.struct([W.u32(`instruction`),W.ns64(`lamports`),W.ns64(`space`),q(`programId`)])},Assign:{index:1,layout:W.struct([W.u32(`instruction`),q(`programId`)])},Transfer:{index:2,layout:W.struct([W.u32(`instruction`),ir(`lamports`)])},CreateWithSeed:{index:3,layout:W.struct([W.u32(`instruction`),q(`base`),Rr(`seed`),W.ns64(`lamports`),W.ns64(`space`),q(`programId`)])},AdvanceNonceAccount:{index:4,layout:W.struct([W.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:W.struct([W.u32(`instruction`),W.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:W.struct([W.u32(`instruction`),q(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:W.struct([W.u32(`instruction`),q(`authorized`)])},Allocate:{index:8,layout:W.struct([W.u32(`instruction`),W.ns64(`space`)])},AllocateWithSeed:{index:9,layout:W.struct([W.u32(`instruction`),q(`base`),Rr(`seed`),W.ns64(`space`),q(`programId`)])},AssignWithSeed:{index:10,layout:W.struct([W.u32(`instruction`),q(`base`),Rr(`seed`),q(`programId`)])},TransferWithSeed:{index:11,layout:W.struct([W.u32(`instruction`),ir(`lamports`),Rr(`seed`),q(`programId`)])},UpgradeNonceAccount:{index:12,layout:W.struct([W.u32(`instruction`)])}}),Q=class e{constructor(){}static createAccount(e){let t=Z.Create,n=z(t,{lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())});return new J({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=Z.TransferWithSeed;t=z(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=Z.Transfer;t=z(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=Z.AssignWithSeed;t=z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Z.Assign;t=z(r,{programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=Z.CreateWithSeed,n=z(t,{base:G(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new J({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new Y;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ui,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ui,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=Z.InitializeNonceAccount,n=z(t,{authorized:G(e.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ii,isSigner:!1,isWritable:!1},{pubkey:ai,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new J(r)}static nonceAdvance(e){let t=Z.AdvanceNonceAccount,n=z(t),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ii,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new J(r)}static nonceWithdraw(e){let t=Z.WithdrawNonceAccount,n=z(t,{lamports:e.lamports});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ii,isSigner:!1,isWritable:!1},{pubkey:ai,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=Z.AuthorizeNonceAccount,n=z(t,{authorized:G(e.newAuthorizedPubkey.toBuffer())});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=Z.AllocateWithSeed;t=z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Z.Allocate;t=z(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}},Q.programId=new K(`11111111111111111111111111111111`),fi=932,pi=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new Y,s.add(Q.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new Y,s.add(Q.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new Y,s.add(Q.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new Y().add(Q.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await nr(t,s,[n,r],{commitment:`confirmed`})}let o=W.struct([W.u32(`instruction`),W.u32(`offset`),W.u32(`bytesLength`),W.u32(`bytesLengthPadding`),W.seq(W.u8(`byte`),W.offset(W.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=g.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(nr(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await rr(250),c+=s,l=l.slice(s)}await Promise.all(u);{let e=W.struct([W.u32(`instruction`)]),a=g.alloc(e.span);e.encode({instruction:1},a);let o=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ai,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(ni/2)))}}return!0}},pi.chunkSize=fi,new K(`BPFLoader2111111111111111111111111111111111`),gi=ar(or()),_i=32,vi=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=sr(cr(e+_i+1))-sr(_i)-1;return[t,e-(this.getSlotsInEpoch(t)-_i)]}{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*_i:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+sr(_i)):this.slotsPerEpoch}},yi=globalThis.fetch,bi=class extends Yn{constructor(e,t,n){super(e=>{let n=Kn(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}},xi=56,Si=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=lr(Ci,e),n=e.length-xi;I(n>=0,`lookup table is invalid`),I(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=W.struct([W.seq(q(),r,`addresses`)]).decode(e.slice(xi));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new K(t.authority[0]),addresses:i.map(e=>new K(e))}}},Ci={index:1,layout:W.struct([W.u32(`typeIndex`),ir(`deactivationSlot`),W.nu64(`lastExtendedSlot`),W.u8(`lastExtendedStartIndex`),W.u8(),W.seq(q(),W.offset(W.u8(),-1),`authority`)])},wi=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,$=Wt(zt(K),E(),e=>new K(e)),Ti=Ht([E(),S(`base64`)]),Ei=Wt(zt(g),Ti,e=>g.from(e[0],`base64`)),Di=3e4,Oi=pr(Ut()),ki=D({foundation:w(),foundationTerm:w(),initial:w(),taper:w(),terminal:w()}),Ai=V(x(C(D({epoch:w(),effectiveSlot:w(),amount:w(),postBalance:w(),commission:T(C(w()))})))),ji=x(D({slot:w(),prioritizationFee:w()})),Mi=D({total:w(),validator:w(),foundation:w(),epoch:w()}),Ni=D({epoch:w(),slotIndex:w(),slotsInEpoch:w(),absoluteSlot:w(),blockHeight:T(w()),transactionCount:T(w())}),Pi=D({slotsPerEpoch:w(),leaderScheduleSlotOffset:w(),warmup:Rt(),firstNormalEpoch:w(),firstNormalSlot:w()}),Fi=Vt(E(),x(w())),Ii=C(O([D({}),E()])),Li=D({err:Ii}),Ri=S(`receivedSignature`),zi=D({"solana-core":E(),"feature-set":T(w())}),Bi=D({program:E(),programId:$,parsed:Ut()}),Vi=D({programId:$,accounts:x($),data:E()}),Hi=H(D({err:C(O([D({}),E()])),logs:C(x(E())),accounts:T(C(x(C(D({executable:Rt(),owner:E(),lamports:w(),data:x(E()),rentEpoch:T(w())}))))),unitsConsumed:T(w()),returnData:T(C(D({programId:E(),data:Ht([E(),S(`base64`)])}))),innerInstructions:T(C(x(D({index:w(),instructions:x(O([Bi,Vi]))}))))})),Ui=H(D({byIdentity:Vt(E(),x(w())),range:D({firstSlot:w(),lastSlot:w()})})),Wi=V(ki),Gi=V(Mi),Ki=V(ji),qi=V(Ni),Ji=V(Pi),Yi=V(Fi),Xi=V(w()),Zi=H(D({total:w(),circulating:w(),nonCirculating:w(),nonCirculatingAccounts:x($)})),Qi=D({amount:E(),uiAmount:C(w()),decimals:w(),uiAmountString:T(E())}),$i=H(x(D({address:$,amount:E(),uiAmount:C(w()),decimals:w(),uiAmountString:T(E())}))),ea=H(x(D({pubkey:$,account:D({executable:Rt(),owner:$,lamports:w(),data:Ei,rentEpoch:w()})}))),ta=D({program:E(),parsed:Ut(),space:w()}),na=H(x(D({pubkey:$,account:D({executable:Rt(),owner:$,lamports:w(),data:ta,rentEpoch:w()})}))),ra=H(x(D({lamports:w(),address:$}))),ia=D({executable:Rt(),owner:$,lamports:w(),data:Ei,rentEpoch:w()}),aa=D({pubkey:$,account:ia}),oa=Wt(O([zt(g),ta]),O([Ti,ta]),e=>Array.isArray(e)?b(e,Ei):e),sa=D({executable:Rt(),owner:$,lamports:w(),data:oa,rentEpoch:w()}),ca=D({pubkey:$,account:sa}),la=D({state:O([S(`active`),S(`inactive`),S(`activating`),S(`deactivating`)]),active:w(),inactive:w()}),ua=V(x(D({signature:E(),slot:w(),err:Ii,memo:C(E()),blockTime:T(C(w()))}))),da=V(x(D({signature:E(),slot:w(),err:Ii,memo:C(E()),blockTime:T(C(w()))}))),fa=D({subscription:w(),result:mr(ia)}),pa=D({pubkey:$,account:ia}),ma=D({subscription:w(),result:mr(pa)}),ha=D({parent:w(),slot:w(),root:w()}),ga=D({subscription:w(),result:ha}),_a=O([D({type:O([S(`firstShredReceived`),S(`completed`),S(`optimisticConfirmation`),S(`root`)]),slot:w(),timestamp:w()}),D({type:S(`createdBank`),parent:w(),slot:w(),timestamp:w()}),D({type:S(`frozen`),slot:w(),timestamp:w(),stats:D({numTransactionEntries:w(),numSuccessfulTransactions:w(),numFailedTransactions:w(),maxTransactionsPerEntry:w()})}),D({type:S(`dead`),slot:w(),timestamp:w(),err:E()})]),va=D({subscription:w(),result:_a}),ya=D({subscription:w(),result:mr(O([Li,Ri]))}),ba=D({subscription:w(),result:w()}),xa=D({pubkey:E(),gossip:C(E()),tpu:C(E()),rpc:C(E()),version:C(E())}),Sa=D({votePubkey:E(),nodePubkey:E(),activatedStake:w(),epochVoteAccount:Rt(),epochCredits:x(Ht([w(),w(),w()])),commission:w(),lastVote:w(),rootSlot:C(w())}),Ca=V(D({current:x(Sa),delinquent:x(Sa)})),wa=O([S(`processed`),S(`confirmed`),S(`finalized`)]),Ta=D({slot:w(),confirmations:C(w()),err:Ii,confirmationStatus:T(wa)}),Ea=H(x(C(Ta))),Da=V(w()),Oa=D({accountKey:$,writableIndexes:x(w()),readonlyIndexes:x(w())}),ka=D({computeUnitLimit:C(w()),heapSize:C(w()),loadedAccountsDataSizeLimit:C(w()),priorityFee:C(w())}),Aa=D({signatures:x(E()),message:D({accountKeys:x(E()),header:D({numRequiredSignatures:w(),numReadonlySignedAccounts:w(),numReadonlyUnsignedAccounts:w()}),instructions:x(D({accounts:x(w()),data:E(),programIdIndex:w()})),recentBlockhash:E(),addressTableLookups:T(x(Oa)),transactionConfig:T(C(ka))})}),ja=D({pubkey:$,signer:Rt(),writable:Rt(),source:T(O([S(`transaction`),S(`lookupTable`)]))}),Ma=D({accountKeys:x(ja),signatures:x(E())}),Na=D({parsed:Ut(),program:E(),programId:$}),Pa=D({accounts:x($),data:E(),programId:$}),Fa=O([Pa,Na]),Ia=O([D({parsed:Ut(),program:E(),programId:E()}),D({accounts:x(E()),data:E(),programId:E()})]),La=Wt(Fa,Ia,e=>`accounts`in e?b(e,Pa):b(e,Na)),Ra=D({signatures:x(E()),message:D({accountKeys:x(ja),instructions:x(La),recentBlockhash:E(),addressTableLookups:T(C(x(Oa))),transactionConfig:T(C(ka))})}),za=D({accountIndex:w(),mint:E(),owner:T(E()),programId:T(E()),uiTokenAmount:Qi}),Ba=D({writable:x($),readonly:x($)}),Va=D({err:Ii,fee:w(),innerInstructions:T(C(x(D({index:w(),instructions:x(D({accounts:x(w()),data:E(),programIdIndex:w()}))})))),preBalances:x(w()),postBalances:x(w()),logMessages:T(C(x(E()))),preTokenBalances:T(C(x(za))),postTokenBalances:T(C(x(za))),loadedAddresses:T(Ba),computeUnitsConsumed:T(w()),costUnits:T(w())}),Ha=D({err:Ii,fee:w(),innerInstructions:T(C(x(D({index:w(),instructions:x(La)})))),preBalances:x(w()),postBalances:x(w()),logMessages:T(C(x(E()))),preTokenBalances:T(C(x(za))),postTokenBalances:T(C(x(za))),loadedAddresses:T(Ba),computeUnitsConsumed:T(w()),costUnits:T(w())}),Ua=O([S(0),S(1),S(`legacy`)]),Wa=D({pubkey:E(),lamports:w(),postBalance:C(w()),rewardType:C(E()),commission:T(C(w()))}),Ga=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),transactions:x(D({transaction:Aa,meta:C(Va),version:T(Ua)})),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),Ka=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),qa=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),transactions:x(D({transaction:Ma,meta:C(Va),version:T(Ua)})),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),Ja=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),transactions:x(D({transaction:Ra,meta:C(Ha),version:T(Ua)})),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),Ya=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),transactions:x(D({transaction:Ma,meta:C(Ha),version:T(Ua)})),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),Xa=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),rewards:T(x(Wa)),blockTime:C(w()),blockHeight:C(w())}))),Za=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),transactions:x(D({transaction:Aa,meta:C(Va)})),rewards:T(x(Wa)),blockTime:C(w())}))),Qa=V(C(D({blockhash:E(),previousBlockhash:E(),parentSlot:w(),signatures:x(E()),blockTime:C(w())}))),$a=V(C(D({slot:w(),meta:C(Va),blockTime:T(C(w())),transaction:Aa,version:T(Ua)}))),eo=V(C(D({slot:w(),transaction:Ra,meta:C(Ha),blockTime:T(C(w())),version:T(Ua)}))),to=H(D({blockhash:E(),lastValidBlockHeight:w()})),no=H(Rt()),ro=D({slot:w(),numTransactions:w(),numSlots:w(),samplePeriodSecs:w()}),io=V(x(ro)),ao=H(C(D({feeCalculator:D({lamportsPerSignature:w()})}))),oo=V(E()),so=V(E()),co=D({err:Ii,logs:x(E()),signature:E()}),lo=D({result:mr(co),subscription:w()}),uo={"solana-client":`js/1.99.0`},fo=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=B(t),i=this._buildArgs([],n,void 0,r),a=gi(i);return e[a]=e[a]??(async()=>{try{let e=b(await this._rpcRequest(`getBlockHeight`,i),V(w()));if(`error`in e)throw new X(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=dr(e),this._rpcWsEndpoint=n||ur(e),this._rpcClient=gr(e,r,i,a,o,s),this._rpcRequest=_r(this._rpcClient),this._rpcBatchRequest=vr(this._rpcClient),this._rpcWebSocket=new bi(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=b(await this._rpcRequest(`getBalance`,i),H(w()));if(`error`in a)throw new X(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=b(await this._rpcRequest(`getBlockTime`,[e]),V(C(w())));if(`error`in t)throw new X(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=b(await this._rpcRequest(`minimumLedgerSlot`,[]),V(w()));if(`error`in e)throw new X(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=b(await this._rpcRequest(`getFirstAvailableBlock`,[]),Xi);if(`error`in e)throw new X(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=b(await this._rpcRequest(`getSupply`,[t]),Zi);if(`error`in n)throw new X(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=b(await this._rpcRequest(`getTokenSupply`,n),H(Qi));if(`error`in r)throw new X(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=b(await this._rpcRequest(`getTokenAccountBalance`,n),H(Qi));if(`error`in r)throw new X(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=B(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=b(await this._rpcRequest(`getTokenAccountsByOwner`,o),ea);if(`error`in s)throw new X(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=b(await this._rpcRequest(`getTokenAccountsByOwner`,i),na);if(`error`in a)throw new X(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=b(await this._rpcRequest(`getLargestAccounts`,n),ra);if(`error`in r)throw new X(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=b(await this._rpcRequest(`getTokenLargestAccounts`,n),$i);if(`error`in r)throw new X(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=b(await this._rpcRequest(`getAccountInfo`,i),H(C(ia)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=b(await this._rpcRequest(`getAccountInfo`,i),H(C(sa)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=B(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=b(await this._rpcRequest(`getMultipleAccounts`,a),H(x(C(sa))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=B(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=b(await this._rpcRequest(`getMultipleAccounts`,a),H(x(C(ia))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=B(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=b(await this._rpcRequest(`getStakeActivation`,a),V(la));if(`error`in o)throw new X(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=B(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:fr(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=x(aa),l=a.withContext===!0?b(s,H(c)):b(s,V(c));if(`error`in l)throw new X(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=b(await this._rpcRequest(`getProgramAccounts`,i),V(x(ca)));if(`error`in a)throw new X(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=U.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return I(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:$r.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null){if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return}i=!0,a({__type:$r.PROCESSED,response:{context:r,value:c}})}}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await rr(1e3),i||(e=await r(),i))return;t({__type:$r.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===$r.PROCESSED)l=e.response;else throw new Nr(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:$r.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await rr(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===$r.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await rr(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Fr(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Fr(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Fr(a)}d={context:r.context,value:{err:r.value.err}}}else throw new Fr(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||6e4;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||3e4}n=setTimeout(()=>t({__type:$r.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===$r.PROCESSED)o=e.response;else throw new Pr(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=b(await this._rpcRequest(`getClusterNodes`,[]),V(x(xa)));if(`error`in e)throw new X(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=b(await this._rpcRequest(`getVoteAccounts`,t),Ca);if(`error`in n)throw new X(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,void 0,n),i=b(await this._rpcRequest(`getSlot`,r),V(w()));if(`error`in i)throw new X(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,void 0,n),i=b(await this._rpcRequest(`getSlotLeader`,r),V(E()));if(`error`in i)throw new X(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=b(await this._rpcRequest(`getSlotLeaders`,n),V(x($)));if(`error`in r)throw new X(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return I(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=b(await this._rpcRequest(`getSignatureStatuses`,n),Ea);if(`error`in r)throw new X(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,void 0,n),i=b(await this._rpcRequest(`getTransactionCount`,r),V(w()));if(`error`in i)throw new X(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=b(await this._rpcRequest(`getInflationGovernor`,t),Wi);if(`error`in n)throw new X(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=B(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=b(await this._rpcRequest(`getInflationReward`,a),Ai);if(`error`in o)throw new X(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=b(await this._rpcRequest(`getInflationRate`,[]),Gi);if(`error`in e)throw new X(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,void 0,n),i=b(await this._rpcRequest(`getEpochInfo`,r),qi);if(`error`in i)throw new X(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=b(await this._rpcRequest(`getEpochSchedule`,[]),Ji);if(`error`in e)throw new X(e.error,`failed to get epoch schedule`);let t=e.result;return new vi(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=b(await this._rpcRequest(`getLeaderSchedule`,[]),Yi);if(`error`in e)throw new X(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=b(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Da);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=b(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),io);if(`error`in t)throw new X(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=b(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),ao);if(`error`in r)throw new X(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=G(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=b(await this._rpcRequest(`getFeeForMessage`,r),H(C(w())));if(`error`in i)throw new X(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=b(await this._rpcRequest(`getRecentPrioritizationFees`,n),Ki);if(`error`in r)throw new X(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,void 0,n),i=b(await this._rpcRequest(`getLatestBlockhash`,r),to);if(`error`in i)throw new X(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgs([e],n,void 0,r),a=b(await this._rpcRequest(`isBlockhashValid`,i),no);if(`error`in a)throw new X(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=b(await this._rpcRequest(`getVersion`,[]),V(zi));if(`error`in e)throw new X(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=b(await this._rpcRequest(`getGenesisHash`,[]),V(E()));if(`error`in e)throw new X(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=b(a,qa);if(`error`in e)throw e.error;return e.result}case`none`:{let e=b(a,Ka);if(`error`in e)throw e.error;return e.result}default:{let e=b(a,Ga);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:hr(n,e.message)},version:n}))}:null}}}catch(e){throw new X(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=b(a,Ya);if(`error`in e)throw e.error;return e.result}case`none`:{let e=b(a,Xa);if(`error`in e)throw e.error;return e.result}default:{let e=b(a,Ja);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new X(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=b(await this._rpcRequest(`getBlockProduction`,r),Ui);if(`error`in i)throw new X(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=b(await this._rpcRequest(`getTransaction`,i),$a);if(`error`in a)throw new X(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:hr(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=B(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=b(await this._rpcRequest(`getTransaction`,i),eo);if(`error`in a)throw new X(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=B(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=b(e,eo);if(`error`in t)throw new X(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=B(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=b(e,$a);if(`error`in t)throw new X(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:hr(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=b(await this._rpcRequest(`getBlock`,n),Za);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Gr(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Y.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=b(await this._rpcRequest(`getBlocks`,r),V(x(w())));if(`error`in i)throw new X(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=b(await this._rpcRequest(`getBlock`,n),Qa);if(`error`in r)throw new X(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=b(await this._rpcRequest(`getBlock`,n),Qa);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=b(await this._rpcRequest(`getTransaction`,n),$a);if(`error`in r)throw new X(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Gr(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:Y.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=b(await this._rpcRequest(`getTransaction`,n),eo);if(`error`in r)throw new X(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=b(e,eo);if(`error`in t)throw new X(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=b(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),ua);if(`error`in i)throw new X(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=b(await this._rpcRequest(`getSignaturesForAddress`,r),da);if(`error`in i)throw new X(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Si({key:e,state:Si.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=di.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=b(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),oo);if(`error`in n)throw new X(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await rr(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Di;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await rr(ni/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=B(e),r=this._buildArgs([],t,`base64`,n),i=b(await this._rpcRequest(`getStakeMinimumDelegation`,r),H(w()));if(`error`in i)throw new X(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=g.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=b(await this._rpcRequest(`simulateTransaction`,o),Hi);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof Y){let t=e;r=new Y,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=Y.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=b(await this._rpcRequest(`simulateTransaction`,l),Hi);if(`error`in u){let e;if(`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))){let t=`
|
|
2
|
+
`,n=t+e.join(t);console.error(u.error.message,n)}throw new si({action:`simulate`,signature:``,transactionMessage:u.error.message,logs:e})}return u.result}async sendTransaction(e,t,n){if(`version`in e){if(t&&Array.isArray(t))throw Error(`Invalid arguments`);let n=e.serialize();return await this.sendRawTransaction(n,t)}if(t===void 0||!Array.isArray(t))throw Error(`Invalid arguments`);let r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){let n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw Error(`!signature`);let i=e.signature.toString(`base64`);if(this._blockhashInfo.transactionSignatures.includes(i))t=!0;else{this._blockhashInfo.transactionSignatures.push(i);break}}}let i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=G(e).toString(`base64`);return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:`base64`},r=t&&t.skipPreflight,i=r===!0?`processed`:t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);let a=[e,n],o=b(await this._rpcRequest(`sendTransaction`,a),so);if(`error`in o){let e;throw`data`in o.error&&(e=o.error.data.logs),new si({action:r?`send`:`simulate`,signature:``,transactionMessage:o.error.message,logs:e})}return o.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify(`ping`)}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error(`ws error:`,e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%(2**53-1),this._rpcWebSocketIdleTimeout&&=(clearTimeout(this._rpcWebSocketIdleTimeout),null),this._rpcWebSocketHeartbeat&&=(clearInterval(this._rpcWebSocketHeartbeat),null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:`pending`})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),r.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let n=this._subscriptionsByHash[e];if(n!==void 0)switch(n.state){case`pending`:case`unsubscribed`:if(n.callbacks.size===0){delete this._subscriptionsByHash[e],n.state===`unsubscribed`&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:`subscribing`});let t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:`subscribed`}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?``:`JSON-RPC `}error calling \`${i}\``,{args:r,error:a}),!t())return;this._setSubscription(e,{...n,state:`pending`}),await this._updateSubscriptions()}})();break;case`subscribed`:n.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:`unsubscribing`}),this._setSubscription(e,{...n,state:`unsubscribing`});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error&&console.error(`${i} error:`,r.message),!t())return;this._setSubscription(e,{...n,state:`subscribed`}),await this._updateSubscriptions();return}}this._setSubscription(e,{...n,state:`unsubscribed`}),await this._updateSubscriptions()})()}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=b(e,fa);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,r=gi([e.method,t]),i=this._subscriptionsByHash[r];return i===void 0?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:`pending`}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let t=this._subscriptionsByHash[r];I(t!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:r,config:i}=B(n),a=this._buildArgs([e.toBase58()],r||this._commitment||`finalized`,`base64`,i);return this._makeSubscription({callback:t,method:`accountSubscribe`,unsubscribeMethod:`accountUnsubscribe`},a)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`account change`)}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=b(e,ma);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){let{commitment:i,config:a}=B(n),o=this._buildArgs([e.toBase58()],i||this._commitment||`finalized`,`base64`,a||(r?{filters:fr(r)}:void 0));return this._makeSubscription({callback:t,method:`programSubscribe`,unsubscribeMethod:`programUnsubscribe`},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`program account change`)}onLogs(e,t,n){let r=this._buildArgs([typeof e==`object`?{mentions:[e.toString()]}:e],n||this._commitment||`finalized`);return this._makeSubscription({callback:t,method:`logsSubscribe`,unsubscribeMethod:`logsUnsubscribe`},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,`logs`)}_wsOnLogsNotification(e){let{result:t,subscription:n}=b(e,lo);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=b(e,ga);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:`slotSubscribe`,unsubscribeMethod:`slotUnsubscribe`},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,`slot change`)}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=b(e,va);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:`slotsUpdatesSubscribe`,unsubscribeMethod:`slotsUpdatesUnsubscribe`},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,`slot update`)}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,r){let i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){let i=t||this._commitment;if(i&&![`confirmed`,`finalized`].includes(i))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=b(e,ya);t.value!==`receivedSignature`&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value===`receivedSignature`?[{type:`received`},t.context]:[{type:`status`,result:t.value},t.context])}onSignature(e,t,n){let r=this._buildArgs([e],n||this._commitment||`finalized`),i=this._makeSubscription({callback:(e,n)=>{if(e.type===`status`){t(e.result,n);try{this.removeSignatureListener(i)}catch{}}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},r);return i}onSignatureWithOptions(e,t,n){let{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||`finalized`},a=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch{}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},a);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,`signature result`)}_wsOnRootNotification(e){let{result:t,subscription:n}=b(e,ba);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:`rootSubscribe`,unsubscribeMethod:`rootUnsubscribe`},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,`root change`)}},po=class e{constructor(e){this._keypair=void 0,this._keypair=e??wr()}static generate(){return new e(wr())}static fromSecretKey(t,n){if(t.byteLength!==64)throw Error(`bad secret key size`);let r=t.slice(32,64);if(!n||!n.skipValidation){let e=t.slice(0,32),n=Tr(e);for(let e=0;e<32;e++)if(r[e]!==n[e])throw Error(`provided secretKey is invalid`)}return new e({publicKey:r,secretKey:t})}static fromSeed(t){let n=Tr(t),r=new Uint8Array(64);return r.set(t),r.set(n,32),new e({publicKey:n,secretKey:r})}get publicKey(){return new K(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},mo=Object.freeze({CreateLookupTable:{index:0,layout:W.struct([W.u32(`instruction`),ir(`recentSlot`),W.u8(`bumpSeed`)])},FreezeLookupTable:{index:1,layout:W.struct([W.u32(`instruction`)])},ExtendLookupTable:{index:2,layout:W.struct([W.u32(`instruction`),ir(),W.seq(q(),W.offset(W.u32(),-8),`addresses`)])},DeactivateLookupTable:{index:3,layout:W.struct([W.u32(`instruction`)])},CloseLookupTable:{index:4,layout:W.struct([W.u32(`instruction`)])}}),ho=class{constructor(){}static createLookupTable(e){let[t,n]=K.findProgramAddressSync([e.authority.toBuffer(),bt().encode(e.recentSlot)],this.programId),r=mo.CreateLookupTable,i=z(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Q.programId,isSigner:!1,isWritable:!1}];return[new J({programId:this.programId,keys:a,data:i}),t]}static freezeLookupTable(e){let t=mo.FreezeLookupTable,n=z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new J({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){let t=mo.ExtendLookupTable,n=z(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Q.programId,isSigner:!1,isWritable:!1}),new J({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){let t=mo.DeactivateLookupTable,n=z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new J({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){let t=mo.CloseLookupTable,n=z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new J({programId:this.programId,keys:r,data:n})}},ho.programId=new K(`AddressLookupTab1e1111111111111111111111111`),go=Object.freeze({RequestUnits:{index:0,layout:W.struct([W.u8(`instruction`),W.u32(`units`),W.u32(`additionalFee`)])},RequestHeapFrame:{index:1,layout:W.struct([W.u8(`instruction`),W.u32(`bytes`)])},SetComputeUnitLimit:{index:2,layout:W.struct([W.u8(`instruction`),W.u32(`units`)])},SetComputeUnitPrice:{index:3,layout:W.struct([W.u8(`instruction`),ir(`microLamports`)])}}),_o=class{constructor(){}static requestUnits(e){let t=go.RequestUnits,n=z(t,e);return new J({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=go.RequestHeapFrame,n=z(t,e);return new J({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=go.SetComputeUnitLimit,n=z(t,e);return new J({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=go.SetComputeUnitPrice,n=z(t,{microLamports:BigInt(e.microLamports)});return new J({keys:[],programId:this.programId,data:n})}},_o.programId=new K(`ComputeBudget111111111111111111111111111111`),vo=64,yo=32,bo=64,xo=W.struct([W.u8(`numSignatures`),W.u8(`padding`),W.u16(`signatureOffset`),W.u16(`signatureInstructionIndex`),W.u16(`publicKeyOffset`),W.u16(`publicKeyInstructionIndex`),W.u16(`messageDataOffset`),W.u16(`messageDataSize`),W.u16(`messageInstructionIndex`)]),So=class e{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,instructionIndex:a}=t;I(n.length===yo,`Public Key must be ${yo} bytes but received ${n.length} bytes`),I(i.length===bo,`Signature must be ${bo} bytes but received ${i.length} bytes`);let o=xo.span,s=o+n.length,c=s+i.length,l=g.alloc(c+r.length),u=a??65535;return xo.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:u},l),l.fill(n,o),l.fill(i,s),l.fill(r,c),new J({keys:[],programId:e.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;I(t.length===vo,`Private key must be ${vo} bytes but received ${t.length} bytes`);try{let e=po.fromSecretKey(t),i=e.publicKey.toBytes(),a=Er(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}},So.programId=new K(`Ed25519SigVerify111111111111111111111111111`),Co=(e,t)=>{let n=ce.sign(e,t);return[n.toCompactRawBytes(),n.recovery]},ce.utils.isValidPrivateKey,wo=ce.getPublicKey,To=32,Eo=20,Do=64,Oo=W.struct([W.u8(`numSignatures`),W.u16(`signatureOffset`),W.u8(`signatureInstructionIndex`),W.u16(`ethAddressOffset`),W.u8(`ethAddressInstructionIndex`),W.u16(`messageDataOffset`),W.u16(`messageDataSize`),W.u8(`messageInstructionIndex`),W.blob(20,`ethAddress`),W.blob(64,`signature`),W.u8(`recoveryId`)]),ko=class e{constructor(){}static publicKeyToEthAddress(e){I(e.length===Do,`Public key must be ${Do} bytes but received ${e.length} bytes`);try{return g.from(m(G(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,recoveryId:a,instructionIndex:o}=t;return e.createInstructionWithEthAddress({ethAddress:e.publicKeyToEthAddress(n),message:r,signature:i,recoveryId:a,instructionIndex:o})}static createInstructionWithEthAddress(t){let{ethAddress:n,message:r,signature:i,recoveryId:a,instructionIndex:o=0}=t,s;s=typeof n==`string`?n.startsWith(`0x`)?g.from(n.substr(2),`hex`):g.from(n,`hex`):n,I(s.length===Eo,`Address must be ${Eo} bytes but received ${s.length} bytes`);let c=12+s.length,l=c+i.length+1,u=g.alloc(Oo.span+r.length);return Oo.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:o,signature:G(i),ethAddress:G(s),recoveryId:a},u),u.fill(G(r),Oo.span),new J({keys:[],programId:e.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;I(t.length===To,`Private key must be ${To} bytes but received ${t.length} bytes`);try{let e=G(t),i=wo(e,!1).slice(1),a=g.from(m(G(n))),[o,s]=Co(a,e);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:o,recoveryId:s,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}},ko.programId=new K(`KeccakSecp256k11111111111111111111111111111`),jo=new K(`StakeConfig11111111111111111111111111111111`),Mo=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}},Ao=Mo,Mo.default=new Ao(0,0,K.default),No=Object.freeze({Initialize:{index:0,layout:W.struct([W.u32(`instruction`),zr(),Br()])},Authorize:{index:1,layout:W.struct([W.u32(`instruction`),q(`newAuthorized`),W.u32(`stakeAuthorizationType`)])},Delegate:{index:2,layout:W.struct([W.u32(`instruction`)])},Split:{index:3,layout:W.struct([W.u32(`instruction`),W.ns64(`lamports`)])},Withdraw:{index:4,layout:W.struct([W.u32(`instruction`),W.ns64(`lamports`)])},Deactivate:{index:5,layout:W.struct([W.u32(`instruction`)])},Merge:{index:7,layout:W.struct([W.u32(`instruction`)])},AuthorizeWithSeed:{index:8,layout:W.struct([W.u32(`instruction`),q(`newAuthorized`),W.u32(`stakeAuthorizationType`),Rr(`authoritySeed`),q(`authorityOwner`)])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),Po=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:r}=e,i=r||Mo.default,a=No.Initialize,o=z(a,{authorized:{staker:G(n.staker.toBuffer()),withdrawer:G(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:G(i.custodian.toBuffer())}}),s={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ai,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new J(s)}static createAccountWithSeed(e){let t=new Y;t.add(Q.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){let t=new Y;t.add(Q.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=No.Delegate,a=z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:oi,isSigner:!1,isWritable:!1},{pubkey:jo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:a}=e,o=No.Authorize,s=z(o,{newAuthorized:G(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:a,stakeAuthorizationType:o,custodianPubkey:s}=e,c=No.AuthorizeWithSeed,l=z(c,{newAuthorized:G(a.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:G(i.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new Y().add({keys:u,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,a=No.Split,o=z(a,{lamports:i});return new J({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){let n=new Y;return n.add(Q.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:a,seed:o,lamports:s}=e,c=new Y;return c.add(Q.allocate({accountPubkey:i,basePubkey:a,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(Q.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:s}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=No.Merge,a=z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:oi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:a}=e,o=No.Withdraw,s=z(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:oi,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,r=No.Deactivate,i=z(r);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}},Po.programId=new K(`Stake11111111111111111111111111111111111111`),Po.space=200,Fo=Object.freeze({InitializeAccount:{index:0,layout:W.struct([W.u32(`instruction`),Vr()])},Authorize:{index:1,layout:W.struct([W.u32(`instruction`),q(`newAuthorized`),W.u32(`voteAuthorizationType`)])},Withdraw:{index:3,layout:W.struct([W.u32(`instruction`),W.ns64(`lamports`)])},UpdateValidatorIdentity:{index:4,layout:W.struct([W.u32(`instruction`)])},AuthorizeWithSeed:{index:10,layout:W.struct([W.u32(`instruction`),Hr()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),Io=class e{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=Fo.InitializeAccount,a=z(i,{voteInit:{nodePubkey:G(r.nodePubkey.toBuffer()),authorizedVoter:G(r.authorizedVoter.toBuffer()),authorizedWithdrawer:G(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ai,isSigner:!1,isWritable:!1},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a};return new J(o)}static createAccount(e){let t=new Y;return t.add(Q.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,a=Fo.Authorize,o=z(a,{newAuthorized:G(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:a,votePubkey:o}=e,s=Fo.AuthorizeWithSeed,c=z(s,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:G(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:G(i.toBuffer()),voteAuthorizationType:a.index}}),l=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:ri,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Y().add({keys:l,programId:this.programId,data:c})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,a=Fo.Withdraw,o=z(a,{lamports:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,n,r){if(t.lamports>n-r)throw Error(`Withdraw will leave vote account with insufficient funds.`);return e.withdraw(t)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=Fo.UpdateValidatorIdentity,a=z(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:o,programId:this.programId,data:a})}},Io.programId=new K(`Vote111111111111111111111111111111111111111`),Io.space=3762,new K(`Va1idator1nfo111111111111111111111111111111`),D({name:E(),website:T(E()),details:T(E()),iconUrl:T(E()),keybaseUsername:T(E())}),new K(`Vote111111111111111111111111111111111111111`),W.struct([q(`nodePubkey`),q(`authorizedWithdrawer`),W.u8(`commission`),W.nu64(),W.seq(W.struct([W.nu64(`slot`),W.u32(`confirmationCount`)]),W.offset(W.u32(),-8),`votes`),W.u8(`rootSlotValid`),W.nu64(`rootSlot`),W.nu64(),W.seq(W.struct([W.nu64(`epoch`),q(`authorizedVoter`)]),W.offset(W.u32(),-8),`authorizedVoters`),W.struct([W.seq(W.struct([q(`authorizedPubkey`),W.nu64(`epochOfLastAuthorizedSwitch`),W.nu64(`targetEpoch`)]),32,`buf`),W.nu64(`idx`),W.u8(`isEmpty`)],`priorVoters`),W.nu64(),W.seq(W.struct([W.nu64(`epoch`),W.nu64(`credits`),W.nu64(`prevCredits`)]),W.offset(W.u32(),-8),`epochCredits`),W.struct([W.nu64(`slot`),W.nu64(`timestamp`)],`lastTimestamp`)]),Lo={http:{devnet:`http://api.devnet.solana.com`,testnet:`http://api.testnet.solana.com`,"mainnet-beta":`http://api.mainnet-beta.solana.com/`},https:{devnet:`https://api.devnet.solana.com`,testnet:`https://api.testnet.solana.com`,"mainnet-beta":`https://api.mainnet-beta.solana.com/`}}}));ee(),Ro();var zo=l([o({transaction:s}),o({signature:s})]),Bo=o({signature:s}),Vo=o({transactions:c(s)}),Ho=[`solana_signTransaction`,`solana_signMessage`,`solana_signAllTransactions`,`solana_signAndSendTransaction`],Uo=e=>_.from(De(e)?e.serialize():e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString(`base64`),Wo=(e,t)=>{let n=_.from(e,`base64`);return De(t)?ti.deserialize(n):Y.from(n)},Go=class extends ke{options;name=`WalletConnect`;url=`https://walletconnect.org`;icon=`data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+`;supportedTransactionVersions=new Set([`legacy`,0]);readyState=typeof window>`u`?Ce.Unsupported:Ce.Loadable;key=null;session;chainId;connectingPromise;unsubscribeEnded;attempt=0;disposed=!1;endedListeners=new Set;constructor(e){super(),this.options=e}get publicKey(){return this.key}subscribeEnded(e){return this.endedListeners.add(e),()=>{this.endedListeners.delete(e)}}get connecting(){return this.connectingPromise!==void 0}get chains(){return this.options.network===je.Mainnet?[`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`,`solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ`]:[`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`,`solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K`]}account(e){for(let t of this.chains)for(let n of e.accounts){if(!n.startsWith(`${t}:`))continue;let e=ue.decodeUnsafe(n.slice(t.length+1));if(e?.length===32)return{chainId:t,publicKey:new K(e)}}}restoredSession(){return this.options.walletConnectProtocol.sessions(`solana`).pipe(u(e=>e.find(e=>this.account(e)!==void 0)))}release(){this.unsubscribeEnded?.(),this.unsubscribeEnded=void 0,this.session=void 0,this.chainId=void 0,this.key=null}connect(){if(this.disposed||this.readyState!==Ce.Loadable)return Promise.reject(new de);if(this.connected)return Promise.resolve();if(this.connectingPromise)return this.connectingPromise;let e=++this.attempt,t=this.options.walletConnectProtocol;return this.connectingPromise=this.options.runWalletEffect(this.restoredSession().pipe(d(a,()=>t.connect({namespace:`solana`,chains:this.chains,requiredMethods:[],optionalMethods:Ho})))).then(n=>{if(this.disposed||e!==this.attempt)throw new ve;let r=this.account(n);if(!r)throw new pe(`No Solana account approved`);this.release(),this.session=n,this.chainId=r.chainId,this.key=r.publicKey,this.unsubscribeEnded=t.subscribeEnded(n.topic,()=>{this.release(),this.emit(`disconnect`);for(let e of[...this.endedListeners])e()}),this.emit(`connect`,r.publicKey)}).finally(()=>{e===this.attempt&&(this.connectingPromise=void 0)}),this.connectingPromise}async autoConnect(){if(this.disposed)throw new de;await this.options.runWalletEffect(this.restoredSession())&&await this.connect()}async disconnect(){++this.attempt,this.connectingPromise=void 0;let e=this.session?.topic;this.release();try{e&&await this.options.runWalletEffect(this.options.walletConnectProtocol.disconnect(e))}catch(e){this.emit(`error`,new he(e instanceof Error?e.message:void 0,e))}finally{this.emit(`disconnect`)}}supports(e){return this.session?.methods.includes(e)??!1}request(e,t,n){if(!this.session||!this.chainId||!this.key)throw new ve;if(!this.supports(e))throw Error(`Wallet does not support ${e}`);return this.options.runWalletEffect(this.options.walletConnectProtocol.request({topic:this.session.topic,chainId:this.chainId,method:e,params:t,response:n}))}async signTransaction(e){try{let t=this.key;if(!t)throw new ve;let n=await this.request(`solana_signTransaction`,{...De(e)?{}:e,transaction:Uo(e)},zo);return`transaction`in n?Wo(n.transaction,e):(e.addSignature(t,_.from(ue.decode(n.signature))),e)}catch(e){return this.signingError(e)}}async signAllTransactions(e){if(!this.key)return this.signingError(new ve);if(!this.supports(`solana_signAllTransactions`))return Promise.all(e.map(e=>this.signTransaction(e)));try{let t=await this.request(`solana_signAllTransactions`,{transactions:e.map(Uo)},Vo);if(t.transactions.length!==e.length)throw Error(`Wallet returned a different number of signed transactions`);return e.map((e,n)=>Wo(t.transactions[n],e))}catch(e){return this.signingError(e)}}async signMessage(e){try{if(!this.key)throw new ve;let t=await this.request(`solana_signMessage`,{pubkey:this.key.toBase58(),message:ue.encode(e)},Bo);return ue.decode(t.signature)}catch(e){let t=e instanceof ve?e:new xe(e instanceof Error?e.message:void 0,e);throw this.emit(`error`,t),t}}async signAndSendTransaction(e){try{return(await this.request(`solana_signAndSendTransaction`,{transaction:Uo(e)},Bo)).signature}catch(e){return this.signingError(e)}}signingError(e){let t=e instanceof ve?e:new be(e instanceof Error?e.message:void 0,e);throw this.emit(`error`,t),t}destroy(){this.disposed||(this.disposed=!0,++this.attempt,this.connectingPromise=void 0,this.release(),this.removeAllListeners(),this.endedListeners.clear())}},Ko=`data:image/svg+xml,%3csvg%20width='66'%20height='56'%20viewBox='0%200%2066%2056'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20%3e%3cpath%20d='M46.6165%208.90197L33.0006%200L19.3872%208.90197L33.0006%2017.8066L46.6165%208.90197Z'%20fill='white'%20/%3e%3cpath%20d='M19.3872%2046.921L33.0006%2055.8256L46.6165%2046.921L33.0006%2038.019L19.3872%2046.921Z'%20fill='white'%20/%3e%3cpath%20d='M13.6159%2025.3516L0%2034.2535L13.6159%2043.1555L27.2293%2034.2535L13.6159%2025.3516Z'%20fill='white'%20/%3e%3cpath%20d='M52.3843%2025.3516L38.771%2034.2535L52.3843%2043.1555L66.0003%2034.2535L52.3843%2025.3516Z'%20fill='white'%20/%3e%3c/svg%3e`,qo={Phantom:`https://chromewebstore.google.com/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa`,Trust:`https://chromewebstore.google.com/detail/trust-wallet/egjidjbpglichdcondbcbdnbeeppgdph`},Jo=e=>!!(`isSolanaConnector`in e&&e.isSolanaConnector);ee();var Yo=s,Xo=/^[0-9a-fA-F]+$/u,Zo=e=>e.startsWith(`0x`)?e.slice(2):e,Qo=e=>{let t=Zo(e.trim());return t.length>0&&t.length%2==0&&Xo.test(t)},$o=e=>{let t=e.trim(),n=Zo(t);return Qo(t)?{encoding:`hex`,buffer:_.from(n,`hex`)}:{encoding:`base64`,buffer:_.from(t,`base64`)}},es=e=>$o(e).buffer.toString(`hex`);export{de as A,ge as C,he as D,me as E,be as F,ye as M,Se as N,y as O,xe as P,Te as S,pe as T,Ae as _,Jo as a,Ce as b,fo as c,Qr as d,ti as f,ke as g,je as h,qo as i,_e as j,ve as k,K as l,Ro as m,es as n,Ko as o,yr as p,Yo as r,Go as s,$o as t,Y as u,De as v,fe as w,Ee as x,we as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,u as t}from"./Result-DQM8aaFz.js";import{$ as n,A as r,B as i,C as a,Dt as o,K as s,Nt as c,Pt as l,R as u,W as d,X as f,_t as p,c as m,d as h,gt as g,it as _,k as v,o as y,p as b,rt as x,s as S,u as C,yt as w,z as T}from"./assets-Dk5ppLtc.js";import{$ as E,It as D,Q as O,a as k,o as ee}from"./Effect-Cu_VlOsF.js";import{i as te}from"./DateTime-DR7XeJxF.js";import{Xn as ne,ar as A,fr as re}from"./call-ttPZjh8C.js";var j=H(),M=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,N=Math.ceil,P=Math.floor,F=`[BigNumber Error] `,I=0x5af3107a4000,L=14,R=9007199254740991,z=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],B=1e7,V=1e9;function H(e){var t,n,r=/^(-?)0([xbo])(?=[^.])/i,i=/^-?(Infinity|NaN)$/,a=/^\s*\+(?!-)|^\s+|\s+$/g,o=b.prototype={constructor:b,toString:null,valueOf:null},s=new b(1),c=20,l=4,u=-7,d=21,f=-1e7,p=1e7,m=!1,h=!0,g=1,_=0,v={prefix:``,negativeSign:`-`,positiveSign:``,groupSeparator:`,`,groupSize:3,secondaryGroupSize:0,decimalSeparator:`.`,fractionGroupSeparator:``,fractionGroupSize:0,suffix:``},y=`0123456789abcdefghijklmnopqrstuvwxyz`;function b(e,t){var n,o,s,c,l=this;if(!(l instanceof b))return new b(e,t);if(c=typeof e,t==null){if(w(e)){l.s=e.s,!e.c||e.e>p?l.c=l.e=null:e.e<f?l.c=[l.e=0]:(l.e=e.e,l.c=e.c.slice());return}if(c==`number`){if(e*0!=0){l.s=isNaN(e)?null:e<0?-1:1,l.c=l.e=null;return}if(l.s=1/e<0?(e=-e,-1):1,e===~~e){for(n=0,o=e;o>=10;o/=10,n++);n>p?l.c=l.e=null:(l.e=n,l.c=[e]);return}return x(l,String(e))}if(c==`bigint`)return l.s=e<0?(e=-e,-1):1,x(l,String(e));if(c==`string`)s=e;else{if(h)throw Error(F+`BigNumber, string, number, or BigInt expected: `+e);s=String(e)}if(M.test(s))return l.s=s.charCodeAt(0)==45?(s=s.slice(1),-1):1,x(l,s);if(s=s.replace(a,``),i.test(s)){l.s=isNaN(s)?null:s<0?-1:1,l.c=l.e=null;return}if(s=s.replace(r,function(e,n,r){return t=(r=r.toLowerCase())==`x`?16:r==`b`?2:8,n}),t)return S(l,s,t,e);if(s=s.replace(/(\d)_(?=\d)/g,`$1`),M.test(s))return l.s=s.charCodeAt(0)==45?(s=s.slice(1),-1):1,x(l,s);if(h)throw Error(F+`Not a number: `+e);l.s=l.c=l.e=null}else{if(c!=`string`){if(h)throw Error(F+`String expected: `+e);e=String(e)}K(t,2,y.length,`Base`),S(l,e.replace(a,``),t,e)}}b.clone=H,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(e!=null){if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(c=K(e[t],0,V,t)),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(l=K(e[t],0,8,t)),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],q(n)?(K(n[0],-V,0,t),K(n[1],0,V,t),u=n[0],d=n[1]):u=-(d=K(n,-V,V,t)<0?-n:n)),e.hasOwnProperty(t=`RANGE`)){if(n=e[t],n)q(n)?(K(n[0],-V,-1,t),K(n[1],1,V,t),f=n[0],p=n[1]):f=-(p=K(n,-V,V,t)<0?-n:n);else throw Error(F+t+` cannot be zero: `+n)}if(e.hasOwnProperty(t=`CRYPTO`)){if(n=e[t],n===!!n){if(n){if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))m=n;else throw m=!n,Error(F+`crypto unavailable`)}else m=n}else throw Error(F+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`STRICT`)){if(n=e[t],n===!!n)h=n;else throw Error(F+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`MODULO_MODE`)&&(g=K(e[t],0,9,t)),e.hasOwnProperty(t=`POW_PRECISION`)&&(_=K(e[t],0,V,t)),e.hasOwnProperty(t=`FORMAT`)){if(n=e[t],typeof n==`object`)for(t in n)n.hasOwnProperty(t)&&v.hasOwnProperty(t)&&(v[t]=n[t]);else throw Error(F+t+` not an object: `+n)}if(e.hasOwnProperty(t=`ALPHABET`)){if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))y=n;else throw Error(F+t+` invalid: `+n)}}else throw Error(F+`Object expected: `+e)}return{DECIMAL_PLACES:c,ROUNDING_MODE:l,EXPONENTIAL_AT:[u,d],RANGE:[f,p],CRYPTO:m,STRICT:h,MODULO_MODE:g,POW_PRECISION:_,FORMAT:v,ALPHABET:y}},b.fromFormat=function(e,t){if(typeof e!=`string`)throw Error(F+`Not a string: `+e);if(t==null)t=v;else if(typeof t!=`object`)throw Error(F+`Argument not an object: `+t);else t=D(t);var n,r,i,a,o=t.negativeSign||`-`,s=t.positiveSign||``,c=t.prefix||``,l=t.suffix||``,u=t.groupSeparator||``,d=t.decimalSeparator||`.`,f=t.fractionGroupSeparator||``;if(c&&e.indexOf(c)===0&&(e=e.slice(c.length)),l&&e.lastIndexOf(l)===e.length-l.length&&(e=e.slice(0,-l.length)),o&&e.indexOf(o)===0?(e=e.slice(o.length),r=!0):s&&e.indexOf(s)===0&&(e=e.slice(s.length)),n=e.indexOf(d),n<0){if(u)for(;e.indexOf(u)>-1;)e=e.replace(u,``)}else{if(i=e.slice(0,n),a=e.slice(n+d.length),u)for(;i.indexOf(u)>-1;)i=i.replace(u,``);if(f)for(;a.indexOf(f)>-1;)a=a.replace(f,``);e=i+`.`+a}return new b(r?`-`+e:e)},b.isBigNumber=function(e){if(!w(e))return!1;var t,n,r=e.c,i=e.e,a=e.s;if(!q(r))return r===null&&i===null&&(a===null||a===1||a===-1);if(a!==1&&a!==-1||i<-V||i>V||i!==P(i))return!1;if(r[0]===0)return i===0&&r.length===1;if(t=(i+1)%L,t<1&&(t+=L),String(r[0]).length!==t)return!1;for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=I||n!==P(n))return!1;return n!==0},b.maximum=b.max=function(){return T(arguments,-1)},b.minimum=b.min=function(){return T(arguments,1)},b.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return P(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,a,o,l=0,u=[],d=new b(s);if(e=e==null?c:K(e,0,V),a=N(e/L),m){if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(a*=2));l<a;)o=n[l]*131072+(n[l+1]>>>11),o>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(o%0x5af3107a4000),l+=2);l=a/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(a*=7);l<a;)o=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],o>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(o%0x5af3107a4000),l+=7);l=a/7}else throw m=!1,Error(F+`crypto unavailable`)}if(!m)for(;l<a;)o=t(),o<9e15&&(u[l++]=o%0x5af3107a4000);for(a=u[--l],e%=L,a&&e&&(o=z[L-e],u[l]=P(a/o)*o);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=L);for(l=1,o=u[0];o>=10;o/=10,l++);l<L&&(i-=L-l)}return d.e=i,d.c=u,d}})(),b.sum=function(){for(var e=0,t=new b(0);e<arguments.length;)t=t.plus(arguments[e++]);return t};function x(e,t){var n,r,i;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;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(--i)===48;);if(t=t.slice(r,++i)){if(i-=r,n=n-r-1,n>p)e.c=e.e=null;else if(n<f)e.c=[e.e=0];else{if(e.e=n,e.c=[],r=(n+1)%L,n<0&&(r+=L),r<i){for(r&&e.c.push(+t.slice(0,r)),i-=L;r<i;)e.c.push(+t.slice(r,r+=L));r=L-(t=t.slice(r)).length}else r-=i;for(;r--;t+=`0`);e.c.push(+t)}}else e.c=[e.e=0]}function S(e,t,r,i){var a,o,s=y.slice(0,r),c=0,l=``,u=!1,d=!1,f=!1;for(e.s=t.charCodeAt(0)===45?(t=t.slice(1),-1):1,o=t.length;c<o;c++){if(a=t.charAt(c),s.indexOf(a)>=0){l+=a,d=!0;continue}if(a==`_`){if(d&&c+1<o){d=!1;continue}}else if(a==`.`){if(c==0||!u&&d){if(c+1==o)break;c==0&&(l=`0`),l+=a,u=!0,d=!1;continue}}else if(!f&&(t==t.toUpperCase()&&s==s.toLowerCase()&&(t=t.toLowerCase())||t==t.toLowerCase()&&s==s.toUpperCase()&&(t=t.toUpperCase()))){c=-1,l=``,f=!0,u=d=!1;continue}if(h)throw Error(F+`Not a base `+r+` number: `+i);e.s=e.c=e.e=null;return}x(e,n(l,r,10,e.s))}n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,o,s){var u,d,f,p,m,h,g,v,x=r.indexOf(`.`),S=c,C=l;for(x>=0&&(p=_,_=0,r=r.replace(`.`,``),v=new b(i),h=v.pow(r.length-x),_=p,v.c=n(X(W(h.c),h.e,`0`),10,a,e),v.e=v.c.length),g=n(r,i,a,s?(u=y,e):(u=e,y)),f=p=g.length;g[--p]==0;g.pop());if(!g[0])return u.charAt(0);if(x<0?--f:(h.c=g,h.e=f,h.s=o,h=t(h,v,S,C,a),g=h.c,m=h.r,f=h.e),d=f+S+1,x=g[d],p=a/2,m=m||d<0||g[d+1]!=null,m=C<4?(x!=null||m)&&(C==0||C==(h.s<0?3:2)):x>p||x==p&&(C==4||m||C==6&&g[d-1]&1||C==(h.s<0?8:7)),d<1||!g[0])r=m?X(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(d<g.length&&(g.length=d),m)for(--a;++g[--d]>a;)g[d]=0,d||(++f,g=[1].concat(g));for(p=g.length;!g[--p];);for(x=0,r=``;x<=p;r+=u.charAt(g[x++]));r=X(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%B,u=t/B|0;for(e=e.slice();c--;)a=e[c]%B,o=e[c]/B|0,r=u*a+o*l,i=l*a+r%B*B+s,s=(i/n|0)+(r/B|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,v,y,x,S,C,w,T,E=r.s==i.s?1:-1,D=r.c,k=i.c;if(!D||!D[0]||!k||!k[0])return new b(!r.s||!i.s||(D?k&&D[0]==k[0]:!k)?NaN:D&&D[0]==0||!k?E*0:E/0);for(h=new b(E),g=h.c=[],l=r.e-i.e,E=a+l+1,s||(s=I,l=U(r.e/L)-U(i.e/L),E=E/L|0),u=0;k[u]==(D[u]||0);u++);if(k[u]>(D[u]||0)&&l--,E<0)g.push(1),d=!0;else{for(S=D.length,w=k.length,u=0,E+=2,f=P(s/(k[0]+1)),f>1&&(k=e(k,f,s),D=e(D,f,s),w=k.length,S=D.length),x=w,_=D.slice(0,w),v=_.length;v<w;_[v++]=0);T=k.slice(),T=[0].concat(T),C=k[0],k[1]>=s/2&&C++;do{if(f=0,c=t(k,_,w,v),c<0){if(y=_[0],w!=v&&(y=y*s+(_[1]||0)),f=P(y/C),f>1)for(f>=s&&(f=s-1),p=e(k,f,s),m=p.length,v=_.length;t(p,_,m,v)==1;)f--,n(p,w<m?T:k,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=k.slice(),m=p.length;if(m<v&&(p=[0].concat(p)),n(_,p,v,s),v=_.length,c==-1)for(;t(k,_,w,v)<1;)f++,n(_,w<v?T:k,v,s),v=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[v++]=D[x]||0:(_=[D[x]],v=1)}while((x++<S||_[0]!=null)&&E--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==I){for(u=1,E=g[0];E>=10;E/=10,u++);O(h,a+(h.e=u+l*L-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function C(e,t,n,r){var i,a,o,s,c;if(n=n==null?l:K(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)c=W(e.c),c=r==1||r==2&&(o<=u||o>=d)?Y(c,o):X(c,o,`0`);else if(e=O(new b(e),t,n),a=e.e,c=W(e.c),s=c.length,r==1||r==2&&(t<=a||a<=u)){for(;s<t;c+=`0`,s++);c=Y(c,a)}else if(t-=o+(r===2&&a>o),c=X(c,a,`0`),a+1>s){if(--t>0)for(c+=`.`;t--;c+=`0`);}else if(t+=a-s,t>0)for(a+1==s&&(c+=`.`);t--;c+=`0`);return e.s<0&&i?`-`+c:c}function w(e){return e instanceof b||!!e&&e._isBigNumber===!0}function T(e,t){for(var n,r,i=1,a=new b(e[0]);i<e.length;i++)r=new b(e[i]),(!r.s||(n=G(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function E(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*L-1)>p?e.c=e.e=null:n<f?e.c=[e.e=0]:(e.e=n,e.c=t),e}function D(e){var t,n={};for(t in v)v.hasOwnProperty(t)&&(n[t]=e.hasOwnProperty(t)?e[t]:v[t]);return n}function O(e,t,n,r){var i,a,o,s,c,l,u,d=e.c,m=z;if(d){out:{for(i=1,s=d[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=L,o=t,c=d[l=0],u=P(c/m[i-o-1]%10);else if(l=N((a+1)/L),l>=d.length){if(r){for(;d.length<=l;d.push(0));c=u=0,i=1,a%=L,o=a-L+1}else break out}else{for(c=s=d[l],i=1;s>=10;s/=10,i++);a%=L,o=a-L+i,u=o<0?0:P(c/m[i-o-1]%10)}if(r=r||t<0||d[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(u||r)&&(n==0||n==(e.s<0?3:2)):u>5||u==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:d[l-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,r?(t-=e.e+1,d[0]=m[(L-t%L)%L],e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=l,s=1,l--):(d.length=l+1,s=m[L-a],d[l]=o>0?P(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=d[0];o>=10;o/=10,a++);for(o=d[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,d[0]==I&&(d[0]=1));break}else{if(d[l]+=s,d[l]!=I)break;d[l--]=0,s=1}for(a=d.length;d[--a]===0;d.pop());}e.e>p?e.c=e.e=null:e.e<f&&(e.c=[e.e=0])}return e}function k(e){var t,n=e.e;return n===null?e.toString():(t=W(e.c),t=n<=u||n>=d?Y(t,n):X(t,n,`0`),e.s<0?`-`+t:t)}return o.absoluteValue=o.abs=function(){var e=new b(this);return e.s<0&&(e.s=1),e},o.comparedTo=function(e,t){return G(this,new b(e,t))},o.decimalPlaces=o.dp=function(e,t){var n,r,i,a=this;if(e!=null)return O(new b(a),K(e,-V,V)+a.e+1,t==null?l:K(t,0,8));if(!(n=a.c))return null;if(r=((i=n.length-1)-U(this.e/L))*L,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},o.dividedBy=o.div=function(e,n){return t(this,new b(e,n),c,l)},o.dividedToIntegerBy=o.idiv=function(e,n){return t(this,new b(e,n),0,1)},o.exponentiatedBy=o.pow=function(e,t){var n,r,i,a,o,c,u,d,f,p=this;if(e=new b(e),e.c&&!e.isInteger())throw Error(F+`Exponent not an integer: `+k(e));if(t!=null&&(t=new b(t)),c=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new b((+k(p))**(c?e.s*(2-J(e)):+k(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new b(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||c&&p.c[1]>=24e7:p.c[0]<8e13||c&&p.c[0]<=9999975e7)))return a=p.s<0&&J(e)?-0:0,p.e>-1&&(a=1/a),new b(u?1/a:a);else _&&(a=N(_/L+2));for(c?(n=new b(.5),u&&(e.s=1),d=J(e)):(i=Math.abs(+k(e)),d=i%2),f=new b(s);;){if(d){if(f=f.times(p),!f.c)break;a?f.c.length>a&&(f.c.length=a):r&&(f=f.mod(t))}if(i){if(i=P(i/2),i===0)break;d=i%2}else if(e=e.times(n),O(e,e.e+1,1),e.e>14)d=J(e);else{if(i=+k(e),i===0)break;d=i%2}p=p.times(p),a?p.c&&p.c.length>a&&(p.c.length=a):r&&(p=p.mod(t))}return r?f:(u&&(f=s.div(f)),t?f.mod(t):a?O(f,_,l,o):f)},o.integerValue=function(e){var t=new b(this);return O(t,t.e+1,e==null?l:K(e,0,8))},o.isEqualTo=o.eq=function(e,t){return G(this,new b(e,t))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(e,t){return G(this,new b(e,t))>0},o.isGreaterThanOrEqualTo=o.gte=function(e,t){return(t=G(this,new b(e,t)))===1||t===0},o.isInteger=function(){return!!this.c&&U(this.e/L)>this.c.length-2},o.isLessThan=o.lt=function(e,t){return G(this,new b(e,t))<0},o.isLessThanOrEqualTo=o.lte=function(e,t){return(t=G(this,new b(e,t)))===-1||t===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(e,t){var n,r,i,a,o=this,s=o.s;if(e=new b(e,t),t=e.s,!s||!t)return new b(NaN);if(s!=t)return e.s=-t,o.plus(e);var c=o.e/L,u=e.e/L,d=o.c,f=e.c;if(!c||!u){if(!d||!f)return d?(e.s=-t,e):new b(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new b(d[0]?o:l==3?-0:0)}if(c=U(c),u=U(u),d=d.slice(),s=c-u){for((a=s<0)?(s=-s,i=d):(u=c,i=f),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(r=(a=(s=d.length)<(t=f.length))?s:t,s=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=I-1;r>s;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=I}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?E(e,d,u):(e.s=l==3?-1:1,e.c=[e.e=0],e)},o.modulo=o.mod=function(e,n){var r,i,a=this;return e=new b(e,n),!a.c||!e.s||e.c&&!e.c[0]?new b(NaN):!e.c||a.c&&!a.c[0]?new b(a):(g==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,g),e=a.minus(r.times(e)),!e.c[0]&&g==1&&(e.s=a.s),e)},o.multipliedBy=o.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,v=_.c,y=(e=new b(e,t)).c;if(!v||!y||!v[0]||!y[0])return!_.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=_.s,!v||!y?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=U(_.e/L)+U(e.e/L),e.s*=_.s,c=v.length,d=y.length,c<d&&(m=v,v=y,y=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=I,g=B,i=d;--i>=0;){for(n=0,f=y[i]%g,p=y[i]/g|0,o=c,a=i+o;a>i;)l=v[--o]%g,u=v[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),E(e,m,r)},o.negated=function(){var e=new b(this);return e.s=-e.s||null,e},o.plus=function(e,t){var n,r=this,i=r.s;if(e=new b(e,t),t=e.s,!i||!t)return new b(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/L,o=e.e/L,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new b(i/0);if(!s[0]||!c[0])return c[0]?e:new b(s[0]?r:i*0)}if(a=U(a),o=U(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/I|0,s[t]=I===s[t]?0:s[t]%I;return i&&(s=[i].concat(s),++o),E(e,s,o)},o.precision=o.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return O(new b(a),K(e,1,V),t==null?l:K(t,0,8));if(!(n=a.c))return null;if(i=n.length-1,r=i*L+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},o.shiftedBy=function(e){return this.times(`1e`+K(e,-R,R))},o.squareRoot=o.sqrt=function(){var e,n,r,i,a,o=this,s=o.c,u=o.s,d=o.e,f=c+4,p=new b(`0.5`);if(u!==1||!s||!s[0])return new b(!u||u<0&&(!s||s[0])?NaN:s?o:1/0);if(u=Math.sqrt(+k(o)),u==0||u==1/0?(n=W(s),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=U((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new b(n)):r=new b(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(o,a,f,1))),W(a.c).slice(0,u)===(n=W(r.c)).slice(0,u)){if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(O(a,a.e+c+2,0),a.times(a).eq(o))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(O(r,r.e+c+2,1),e=!r.times(r).eq(o));break}}}return O(r,r.e+c+1,l,e)},typeof BigInt==`function`&&(o.toBigInt=function(e){var t=this;return t.c?BigInt(C(t,t.e+1,e)):null}),o.toExponential=function(e,t){return C(this,e==null?e:K(e,0,V)+1,t,1)},o.toFixed=function(e,t){return C(this,e==null?e:K(e,-V,V)+this.e+1,t)},o.toFormat=function(e,t,n){var r,i,a,o,s=this;if(n==null)n=v,e!=null&&(t==null?typeof e==`object`&&!q(e)&&(n=D(e),e=t=null):typeof t==`object`&&(n=D(t),t=null));else if(typeof n!=`object`)throw Error(F+`Argument not an object: `+n);else n=D(n);if(e!=null){if(q(e)&&e.length<=2){if(i=e[0],a=e[1],e=s.dp(),a!=null&&e>K(a,0,V)&&(e=a),i!=null&&K(i,0,V)!==0){if(a!=null&&i>a)throw Error(F+`Minimum must not exceed maximum`);e<i&&(e=i)}}else K(e,-V,V)}if(o=s.toFixed(e,t),r=o.charCodeAt(0)===45,r&&(o=o.slice(1)),s.c){var c,l=o.split(`.`),u=+n.groupSize,d=+n.secondaryGroupSize,f=n.groupSeparator||``,p=l[0],m=l[1],h=p.length;if(d&&(c=u,u=d,d=c,h-=c),u>0&&h>0){for(c=h%u||u,o=p.substr(0,c);c<h;c+=u)o+=f+p.substr(c,u);d>0&&(o+=f+p.slice(c))}else o=p;m&&(c=+n.fractionGroupSize,c&&(m=m.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``))),o+=(n.decimalSeparator||``)+m)}return(n.prefix||``)+(r?n.negativeSign||``:s.s>0&&n.positiveSign||``)+o+(n.suffix||``)},o.toFraction=function(e){var n,r,i,a,o,c,l,u,d,f,m,h,g,_,v=this,y=v.c;if(e!=null&&(l=new b(e),!l.isInteger()&&(l.c||l.s!==1)||l.lt(s)))throw Error(F+`Argument `+(l.isInteger()?`out of range: `:`not an integer: `)+k(l));if(!y)return[new b(v.s||0),new b(0)];for(n=new b(s),d=r=new b(s),i=u=new b(s),h=W(y),o=n.e=h.length-v.e-1,n.c[0]=z[(c=o%L)<0?L+c:c],e=!e||l.comparedTo(n)>0?o>0?n:d:l,c=p,p=1/0,l=new b(h),_=l,g=n,u.c[0]=0;f=t(l,n,0,1),a=r.plus(f.times(i)),a.comparedTo(e)!=1;)r=i,i=a,d=u.plus(f.times(a=d)),u=a,n=l.minus(f.times(a=n)),l=a;return a=t(e.minus(r),i,0,1),u=u.plus(a.times(d)),r=r.plus(a.times(i)),m=d.times(g).minus(_.times(i)).abs().times(r).comparedTo(u.times(g).minus(_.times(r)).abs().times(i))<1?[d,i]:[u,r],m[0].s=v.s,p=c,m},o.toNumber=function(){return+k(this)},o.toObject=function(){var e=this;return{c:e.c?e.c.slice():null,e:e.e,s:e.s}},o.toPrecision=function(e,t){return C(this,e==null?e:K(e,1,V),t,2)},o.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=u||a>=d?Y(W(r.c),a):X(W(r.c),a,`0`):(K(e,2,y.length,`Base`),t=n(X(W(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},o.valueOf=o.toJSON=function(){return k(this)},o._isBigNumber=!0,e!=null&&b.set(e),b}function U(e){var t=e|0;return e>0||e===t?t:t-1}function W(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=L-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function G(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function K(e,t,n,r){if(e<t||e>n||e!==P(e))throw Error(F+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e));return e}function q(e){return{}.toString.call(e)==`[object Array]`}function J(e){var t=e.c.length-1;return U(e.e/L)==t&&e.c[t]%2!=0}function Y(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function X(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}j.config({DECIMAL_PLACES:20,ROUNDING_MODE:j.ROUND_HALF_UP,FORMAT:{prefix:``,decimalSeparator:`.`,groupSeparator:`,`,groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:` `,fractionGroupSize:0,suffix:``}});var ie=e=>j.isBigNumber(e)?e:new j(e),ae=()=>new j(0),oe=e=>e.reduce((e,t)=>e.plus(t),ae()),se=(e,t)=>e.decimalPlaces(t,j.ROUND_DOWN),ce=e=>{if(!e.isFinite()||!e.isInteger())return null;let t=Number(e.toFixed(0));return Number.isSafeInteger(t)?t:null},le=e=>O(`Rejected API response entry`).pipe(k({event:`api_decode_rejection`,operation:e.operation,location:String(e.location),issue:e.issue,...e.identifier?{identifier:e.identifier}:{}})),ue=e=>O(`Ignored invalid optional API response field`).pipe(k({event:`api_decode_field_rejection`,operation:e.operation,field:e.field,issue:e.issue})),de=T([v.check(g()),b]),fe=de.pipe(f(_(j).check(p(e=>e.isFinite()?!0:`expected a finite decimal`)),o({decode:e=>new j(e),encode:e=>e.toFixed()}))),pe=p(e=>e.isGreaterThanOrEqualTo(0)?!0:`expected a finite non-negative decimal`),me=fe.check(pe),he=b.check(p(e=>Number.isSafeInteger(e)?!0:`expected a safe integer Base Unit Amount`)).pipe(f(S,o({decode:e=>BigInt(e),encode:e=>Number(e)}))),ge=T([m,he]),_e=h,ve=(e,r)=>{let i=n(_e)(e);return t(i,{onFailure:()=>ue({...r,issue:`invalid UTC date-time`}).pipe(ee(void 0)),onSuccess:e=>D(e)})},ye=e=>i.pipe(f(u(C),{decode:l(t=>t===void 0?D(void 0):ve(t,e)),encode:c(e=>e===void 0?void 0:te(e))})),be=e=>i.pipe(f(a(C),{decode:l(t=>t===null?D(null):ve(t,e).pipe(E(e=>e??null))),encode:c(e=>e===null?null:te(e))})),xe=e=>{let t=Number(e);return Number.isNaN(t)?e:t},Se={id:`ledgerLive`,name:`Ledger Live`,type:`ledgerLive`},Ce=e=>e.id===Se.id,we=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed hex string`}),Te=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed address`}),Ee=v.check(p(e=>re(e)&&e.length>2?!0:`expected a 0x-prefixed hex quantity`)).pipe(f(S,o({decode:e=>ne(e),encode:e=>A(e)}))),Z=T([ge,Ee]),De=r({data:we,to:Te,gasLimit:Z,from:Te,value:w(Z),type:b,gasPrice:w(Z),maxFeePerGas:w(Z),maxPriorityFeePerGas:w(Z),chainId:b}),Oe=De,ke=x(De),Ae=e=>s(ke)(e),Q=e=>e===void 0?void 0:A(e),je=(e,t)=>({to:e.to,from:t,data:e.data,value:e.value?A(e.value):void 0,gas:A(e.gasLimit),chainId:A(e.chainId)}),Me=e=>({address:t,tx:n})=>Ae(n).pipe(E(n=>({...je(n,t),...e(n)}))),Ne=Me(e=>e.maxFeePerGas?{type:`0x2`,maxFeePerGas:A(e.maxFeePerGas),maxPriorityFeePerGas:e.maxPriorityFeePerGas?A(e.maxPriorityFeePerGas):void 0}:{type:`0x1`,gasPrice:e.gasPrice?A(e.gasPrice):void 0}),Pe=Me(e=>e.type===2?{type:`0x2`,maxFeePerGas:Q(e.maxFeePerGas),maxPriorityFeePerGas:Q(e.maxPriorityFeePerGas)}:{type:`0x0`,gasPrice:Q(e.gasPrice)}),Fe=(t,r)=>n(t)(r).pipe(e(e=>e.message)),$=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed hex string`}),Ie=r({tx:r({address:v,assetId:w($),blockHash:$,blockNumber:$,era:$,genesisHash:$,metadataHash:w($),method:v,mode:w(b),nonce:$,specVersion:$,tip:$,transactionVersion:$,signedExtensions:y(v),version:b,metadataRpc:$}),specName:v,specVersion:b,metadataRpc:$});export{se as C,ce as S,ue as _,Ae as a,ae as b,Ce as c,fe as d,de as f,_e as g,ye as h,Ne as i,xe as l,be as m,Fe as n,Oe as o,me as p,Pe as r,Se as s,Ie as t,ge as u,le as v,j as w,oe as x,ie as y};
|
|
1
|
+
import{l as e,u as t}from"./Result-DQM8aaFz.js";import{$ as n,A as r,B as i,C as a,Ft as o,K as s,Ot as c,Pt as l,R as u,W as d,X as f,_t as p,c as m,d as h,gt as g,it as _,k as v,o as y,p as b,rt as x,s as S,u as C,yt as w,z as T}from"./assets-DXO6qW6R.js";import{$ as E,It as D,Q as O,a as k,o as ee}from"./Effect-Cu_VlOsF.js";import{i as te}from"./DateTime-ByC3zr_K.js";import{Xn as ne,ar as A,fr as re}from"./call-ttPZjh8C.js";var j=H(),M=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,N=Math.ceil,P=Math.floor,F=`[BigNumber Error] `,I=0x5af3107a4000,L=14,R=9007199254740991,z=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],B=1e7,V=1e9;function H(e){var t,n,r=/^(-?)0([xbo])(?=[^.])/i,i=/^-?(Infinity|NaN)$/,a=/^\s*\+(?!-)|^\s+|\s+$/g,o=b.prototype={constructor:b,toString:null,valueOf:null},s=new b(1),c=20,l=4,u=-7,d=21,f=-1e7,p=1e7,m=!1,h=!0,g=1,_=0,v={prefix:``,negativeSign:`-`,positiveSign:``,groupSeparator:`,`,groupSize:3,secondaryGroupSize:0,decimalSeparator:`.`,fractionGroupSeparator:``,fractionGroupSize:0,suffix:``},y=`0123456789abcdefghijklmnopqrstuvwxyz`;function b(e,t){var n,o,s,c,l=this;if(!(l instanceof b))return new b(e,t);if(c=typeof e,t==null){if(w(e)){l.s=e.s,!e.c||e.e>p?l.c=l.e=null:e.e<f?l.c=[l.e=0]:(l.e=e.e,l.c=e.c.slice());return}if(c==`number`){if(e*0!=0){l.s=isNaN(e)?null:e<0?-1:1,l.c=l.e=null;return}if(l.s=1/e<0?(e=-e,-1):1,e===~~e){for(n=0,o=e;o>=10;o/=10,n++);n>p?l.c=l.e=null:(l.e=n,l.c=[e]);return}return x(l,String(e))}if(c==`bigint`)return l.s=e<0?(e=-e,-1):1,x(l,String(e));if(c==`string`)s=e;else{if(h)throw Error(F+`BigNumber, string, number, or BigInt expected: `+e);s=String(e)}if(M.test(s))return l.s=s.charCodeAt(0)==45?(s=s.slice(1),-1):1,x(l,s);if(s=s.replace(a,``),i.test(s)){l.s=isNaN(s)?null:s<0?-1:1,l.c=l.e=null;return}if(s=s.replace(r,function(e,n,r){return t=(r=r.toLowerCase())==`x`?16:r==`b`?2:8,n}),t)return S(l,s,t,e);if(s=s.replace(/(\d)_(?=\d)/g,`$1`),M.test(s))return l.s=s.charCodeAt(0)==45?(s=s.slice(1),-1):1,x(l,s);if(h)throw Error(F+`Not a number: `+e);l.s=l.c=l.e=null}else{if(c!=`string`){if(h)throw Error(F+`String expected: `+e);e=String(e)}K(t,2,y.length,`Base`),S(l,e.replace(a,``),t,e)}}b.clone=H,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(e!=null){if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(c=K(e[t],0,V,t)),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(l=K(e[t],0,8,t)),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],q(n)?(K(n[0],-V,0,t),K(n[1],0,V,t),u=n[0],d=n[1]):u=-(d=K(n,-V,V,t)<0?-n:n)),e.hasOwnProperty(t=`RANGE`)){if(n=e[t],n)q(n)?(K(n[0],-V,-1,t),K(n[1],1,V,t),f=n[0],p=n[1]):f=-(p=K(n,-V,V,t)<0?-n:n);else throw Error(F+t+` cannot be zero: `+n)}if(e.hasOwnProperty(t=`CRYPTO`)){if(n=e[t],n===!!n){if(n){if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))m=n;else throw m=!n,Error(F+`crypto unavailable`)}else m=n}else throw Error(F+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`STRICT`)){if(n=e[t],n===!!n)h=n;else throw Error(F+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`MODULO_MODE`)&&(g=K(e[t],0,9,t)),e.hasOwnProperty(t=`POW_PRECISION`)&&(_=K(e[t],0,V,t)),e.hasOwnProperty(t=`FORMAT`)){if(n=e[t],typeof n==`object`)for(t in n)n.hasOwnProperty(t)&&v.hasOwnProperty(t)&&(v[t]=n[t]);else throw Error(F+t+` not an object: `+n)}if(e.hasOwnProperty(t=`ALPHABET`)){if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))y=n;else throw Error(F+t+` invalid: `+n)}}else throw Error(F+`Object expected: `+e)}return{DECIMAL_PLACES:c,ROUNDING_MODE:l,EXPONENTIAL_AT:[u,d],RANGE:[f,p],CRYPTO:m,STRICT:h,MODULO_MODE:g,POW_PRECISION:_,FORMAT:v,ALPHABET:y}},b.fromFormat=function(e,t){if(typeof e!=`string`)throw Error(F+`Not a string: `+e);if(t==null)t=v;else if(typeof t!=`object`)throw Error(F+`Argument not an object: `+t);else t=D(t);var n,r,i,a,o=t.negativeSign||`-`,s=t.positiveSign||``,c=t.prefix||``,l=t.suffix||``,u=t.groupSeparator||``,d=t.decimalSeparator||`.`,f=t.fractionGroupSeparator||``;if(c&&e.indexOf(c)===0&&(e=e.slice(c.length)),l&&e.lastIndexOf(l)===e.length-l.length&&(e=e.slice(0,-l.length)),o&&e.indexOf(o)===0?(e=e.slice(o.length),r=!0):s&&e.indexOf(s)===0&&(e=e.slice(s.length)),n=e.indexOf(d),n<0){if(u)for(;e.indexOf(u)>-1;)e=e.replace(u,``)}else{if(i=e.slice(0,n),a=e.slice(n+d.length),u)for(;i.indexOf(u)>-1;)i=i.replace(u,``);if(f)for(;a.indexOf(f)>-1;)a=a.replace(f,``);e=i+`.`+a}return new b(r?`-`+e:e)},b.isBigNumber=function(e){if(!w(e))return!1;var t,n,r=e.c,i=e.e,a=e.s;if(!q(r))return r===null&&i===null&&(a===null||a===1||a===-1);if(a!==1&&a!==-1||i<-V||i>V||i!==P(i))return!1;if(r[0]===0)return i===0&&r.length===1;if(t=(i+1)%L,t<1&&(t+=L),String(r[0]).length!==t)return!1;for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=I||n!==P(n))return!1;return n!==0},b.maximum=b.max=function(){return T(arguments,-1)},b.minimum=b.min=function(){return T(arguments,1)},b.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return P(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,a,o,l=0,u=[],d=new b(s);if(e=e==null?c:K(e,0,V),a=N(e/L),m){if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(a*=2));l<a;)o=n[l]*131072+(n[l+1]>>>11),o>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(o%0x5af3107a4000),l+=2);l=a/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(a*=7);l<a;)o=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],o>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(o%0x5af3107a4000),l+=7);l=a/7}else throw m=!1,Error(F+`crypto unavailable`)}if(!m)for(;l<a;)o=t(),o<9e15&&(u[l++]=o%0x5af3107a4000);for(a=u[--l],e%=L,a&&e&&(o=z[L-e],u[l]=P(a/o)*o);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=L);for(l=1,o=u[0];o>=10;o/=10,l++);l<L&&(i-=L-l)}return d.e=i,d.c=u,d}})(),b.sum=function(){for(var e=0,t=new b(0);e<arguments.length;)t=t.plus(arguments[e++]);return t};function x(e,t){var n,r,i;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;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(--i)===48;);if(t=t.slice(r,++i)){if(i-=r,n=n-r-1,n>p)e.c=e.e=null;else if(n<f)e.c=[e.e=0];else{if(e.e=n,e.c=[],r=(n+1)%L,n<0&&(r+=L),r<i){for(r&&e.c.push(+t.slice(0,r)),i-=L;r<i;)e.c.push(+t.slice(r,r+=L));r=L-(t=t.slice(r)).length}else r-=i;for(;r--;t+=`0`);e.c.push(+t)}}else e.c=[e.e=0]}function S(e,t,r,i){var a,o,s=y.slice(0,r),c=0,l=``,u=!1,d=!1,f=!1;for(e.s=t.charCodeAt(0)===45?(t=t.slice(1),-1):1,o=t.length;c<o;c++){if(a=t.charAt(c),s.indexOf(a)>=0){l+=a,d=!0;continue}if(a==`_`){if(d&&c+1<o){d=!1;continue}}else if(a==`.`){if(c==0||!u&&d){if(c+1==o)break;c==0&&(l=`0`),l+=a,u=!0,d=!1;continue}}else if(!f&&(t==t.toUpperCase()&&s==s.toLowerCase()&&(t=t.toLowerCase())||t==t.toLowerCase()&&s==s.toUpperCase()&&(t=t.toUpperCase()))){c=-1,l=``,f=!0,u=d=!1;continue}if(h)throw Error(F+`Not a base `+r+` number: `+i);e.s=e.c=e.e=null;return}x(e,n(l,r,10,e.s))}n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,o,s){var u,d,f,p,m,h,g,v,x=r.indexOf(`.`),S=c,C=l;for(x>=0&&(p=_,_=0,r=r.replace(`.`,``),v=new b(i),h=v.pow(r.length-x),_=p,v.c=n(X(W(h.c),h.e,`0`),10,a,e),v.e=v.c.length),g=n(r,i,a,s?(u=y,e):(u=e,y)),f=p=g.length;g[--p]==0;g.pop());if(!g[0])return u.charAt(0);if(x<0?--f:(h.c=g,h.e=f,h.s=o,h=t(h,v,S,C,a),g=h.c,m=h.r,f=h.e),d=f+S+1,x=g[d],p=a/2,m=m||d<0||g[d+1]!=null,m=C<4?(x!=null||m)&&(C==0||C==(h.s<0?3:2)):x>p||x==p&&(C==4||m||C==6&&g[d-1]&1||C==(h.s<0?8:7)),d<1||!g[0])r=m?X(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(d<g.length&&(g.length=d),m)for(--a;++g[--d]>a;)g[d]=0,d||(++f,g=[1].concat(g));for(p=g.length;!g[--p];);for(x=0,r=``;x<=p;r+=u.charAt(g[x++]));r=X(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%B,u=t/B|0;for(e=e.slice();c--;)a=e[c]%B,o=e[c]/B|0,r=u*a+o*l,i=l*a+r%B*B+s,s=(i/n|0)+(r/B|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,v,y,x,S,C,w,T,E=r.s==i.s?1:-1,D=r.c,k=i.c;if(!D||!D[0]||!k||!k[0])return new b(!r.s||!i.s||(D?k&&D[0]==k[0]:!k)?NaN:D&&D[0]==0||!k?E*0:E/0);for(h=new b(E),g=h.c=[],l=r.e-i.e,E=a+l+1,s||(s=I,l=U(r.e/L)-U(i.e/L),E=E/L|0),u=0;k[u]==(D[u]||0);u++);if(k[u]>(D[u]||0)&&l--,E<0)g.push(1),d=!0;else{for(S=D.length,w=k.length,u=0,E+=2,f=P(s/(k[0]+1)),f>1&&(k=e(k,f,s),D=e(D,f,s),w=k.length,S=D.length),x=w,_=D.slice(0,w),v=_.length;v<w;_[v++]=0);T=k.slice(),T=[0].concat(T),C=k[0],k[1]>=s/2&&C++;do{if(f=0,c=t(k,_,w,v),c<0){if(y=_[0],w!=v&&(y=y*s+(_[1]||0)),f=P(y/C),f>1)for(f>=s&&(f=s-1),p=e(k,f,s),m=p.length,v=_.length;t(p,_,m,v)==1;)f--,n(p,w<m?T:k,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=k.slice(),m=p.length;if(m<v&&(p=[0].concat(p)),n(_,p,v,s),v=_.length,c==-1)for(;t(k,_,w,v)<1;)f++,n(_,w<v?T:k,v,s),v=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[v++]=D[x]||0:(_=[D[x]],v=1)}while((x++<S||_[0]!=null)&&E--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==I){for(u=1,E=g[0];E>=10;E/=10,u++);O(h,a+(h.e=u+l*L-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function C(e,t,n,r){var i,a,o,s,c;if(n=n==null?l:K(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)c=W(e.c),c=r==1||r==2&&(o<=u||o>=d)?Y(c,o):X(c,o,`0`);else if(e=O(new b(e),t,n),a=e.e,c=W(e.c),s=c.length,r==1||r==2&&(t<=a||a<=u)){for(;s<t;c+=`0`,s++);c=Y(c,a)}else if(t-=o+(r===2&&a>o),c=X(c,a,`0`),a+1>s){if(--t>0)for(c+=`.`;t--;c+=`0`);}else if(t+=a-s,t>0)for(a+1==s&&(c+=`.`);t--;c+=`0`);return e.s<0&&i?`-`+c:c}function w(e){return e instanceof b||!!e&&e._isBigNumber===!0}function T(e,t){for(var n,r,i=1,a=new b(e[0]);i<e.length;i++)r=new b(e[i]),(!r.s||(n=G(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function E(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*L-1)>p?e.c=e.e=null:n<f?e.c=[e.e=0]:(e.e=n,e.c=t),e}function D(e){var t,n={};for(t in v)v.hasOwnProperty(t)&&(n[t]=e.hasOwnProperty(t)?e[t]:v[t]);return n}function O(e,t,n,r){var i,a,o,s,c,l,u,d=e.c,m=z;if(d){out:{for(i=1,s=d[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=L,o=t,c=d[l=0],u=P(c/m[i-o-1]%10);else if(l=N((a+1)/L),l>=d.length){if(r){for(;d.length<=l;d.push(0));c=u=0,i=1,a%=L,o=a-L+1}else break out}else{for(c=s=d[l],i=1;s>=10;s/=10,i++);a%=L,o=a-L+i,u=o<0?0:P(c/m[i-o-1]%10)}if(r=r||t<0||d[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(u||r)&&(n==0||n==(e.s<0?3:2)):u>5||u==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:d[l-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,r?(t-=e.e+1,d[0]=m[(L-t%L)%L],e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=l,s=1,l--):(d.length=l+1,s=m[L-a],d[l]=o>0?P(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=d[0];o>=10;o/=10,a++);for(o=d[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,d[0]==I&&(d[0]=1));break}else{if(d[l]+=s,d[l]!=I)break;d[l--]=0,s=1}for(a=d.length;d[--a]===0;d.pop());}e.e>p?e.c=e.e=null:e.e<f&&(e.c=[e.e=0])}return e}function k(e){var t,n=e.e;return n===null?e.toString():(t=W(e.c),t=n<=u||n>=d?Y(t,n):X(t,n,`0`),e.s<0?`-`+t:t)}return o.absoluteValue=o.abs=function(){var e=new b(this);return e.s<0&&(e.s=1),e},o.comparedTo=function(e,t){return G(this,new b(e,t))},o.decimalPlaces=o.dp=function(e,t){var n,r,i,a=this;if(e!=null)return O(new b(a),K(e,-V,V)+a.e+1,t==null?l:K(t,0,8));if(!(n=a.c))return null;if(r=((i=n.length-1)-U(this.e/L))*L,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},o.dividedBy=o.div=function(e,n){return t(this,new b(e,n),c,l)},o.dividedToIntegerBy=o.idiv=function(e,n){return t(this,new b(e,n),0,1)},o.exponentiatedBy=o.pow=function(e,t){var n,r,i,a,o,c,u,d,f,p=this;if(e=new b(e),e.c&&!e.isInteger())throw Error(F+`Exponent not an integer: `+k(e));if(t!=null&&(t=new b(t)),c=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new b((+k(p))**(c?e.s*(2-J(e)):+k(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new b(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||c&&p.c[1]>=24e7:p.c[0]<8e13||c&&p.c[0]<=9999975e7)))return a=p.s<0&&J(e)?-0:0,p.e>-1&&(a=1/a),new b(u?1/a:a);else _&&(a=N(_/L+2));for(c?(n=new b(.5),u&&(e.s=1),d=J(e)):(i=Math.abs(+k(e)),d=i%2),f=new b(s);;){if(d){if(f=f.times(p),!f.c)break;a?f.c.length>a&&(f.c.length=a):r&&(f=f.mod(t))}if(i){if(i=P(i/2),i===0)break;d=i%2}else if(e=e.times(n),O(e,e.e+1,1),e.e>14)d=J(e);else{if(i=+k(e),i===0)break;d=i%2}p=p.times(p),a?p.c&&p.c.length>a&&(p.c.length=a):r&&(p=p.mod(t))}return r?f:(u&&(f=s.div(f)),t?f.mod(t):a?O(f,_,l,o):f)},o.integerValue=function(e){var t=new b(this);return O(t,t.e+1,e==null?l:K(e,0,8))},o.isEqualTo=o.eq=function(e,t){return G(this,new b(e,t))===0},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(e,t){return G(this,new b(e,t))>0},o.isGreaterThanOrEqualTo=o.gte=function(e,t){return(t=G(this,new b(e,t)))===1||t===0},o.isInteger=function(){return!!this.c&&U(this.e/L)>this.c.length-2},o.isLessThan=o.lt=function(e,t){return G(this,new b(e,t))<0},o.isLessThanOrEqualTo=o.lte=function(e,t){return(t=G(this,new b(e,t)))===-1||t===0},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&this.c[0]==0},o.minus=function(e,t){var n,r,i,a,o=this,s=o.s;if(e=new b(e,t),t=e.s,!s||!t)return new b(NaN);if(s!=t)return e.s=-t,o.plus(e);var c=o.e/L,u=e.e/L,d=o.c,f=e.c;if(!c||!u){if(!d||!f)return d?(e.s=-t,e):new b(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new b(d[0]?o:l==3?-0:0)}if(c=U(c),u=U(u),d=d.slice(),s=c-u){for((a=s<0)?(s=-s,i=d):(u=c,i=f),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(r=(a=(s=d.length)<(t=f.length))?s:t,s=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=I-1;r>s;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=I}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?E(e,d,u):(e.s=l==3?-1:1,e.c=[e.e=0],e)},o.modulo=o.mod=function(e,n){var r,i,a=this;return e=new b(e,n),!a.c||!e.s||e.c&&!e.c[0]?new b(NaN):!e.c||a.c&&!a.c[0]?new b(a):(g==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,g),e=a.minus(r.times(e)),!e.c[0]&&g==1&&(e.s=a.s),e)},o.multipliedBy=o.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,v=_.c,y=(e=new b(e,t)).c;if(!v||!y||!v[0]||!y[0])return!_.s||!e.s||v&&!v[0]&&!y||y&&!y[0]&&!v?e.c=e.e=e.s=null:(e.s*=_.s,!v||!y?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=U(_.e/L)+U(e.e/L),e.s*=_.s,c=v.length,d=y.length,c<d&&(m=v,v=y,y=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=I,g=B,i=d;--i>=0;){for(n=0,f=y[i]%g,p=y[i]/g|0,o=c,a=i+o;a>i;)l=v[--o]%g,u=v[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),E(e,m,r)},o.negated=function(){var e=new b(this);return e.s=-e.s||null,e},o.plus=function(e,t){var n,r=this,i=r.s;if(e=new b(e,t),t=e.s,!i||!t)return new b(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/L,o=e.e/L,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new b(i/0);if(!s[0]||!c[0])return c[0]?e:new b(s[0]?r:i*0)}if(a=U(a),o=U(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/I|0,s[t]=I===s[t]?0:s[t]%I;return i&&(s=[i].concat(s),++o),E(e,s,o)},o.precision=o.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return O(new b(a),K(e,1,V),t==null?l:K(t,0,8));if(!(n=a.c))return null;if(i=n.length-1,r=i*L+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},o.shiftedBy=function(e){return this.times(`1e`+K(e,-R,R))},o.squareRoot=o.sqrt=function(){var e,n,r,i,a,o=this,s=o.c,u=o.s,d=o.e,f=c+4,p=new b(`0.5`);if(u!==1||!s||!s[0])return new b(!u||u<0&&(!s||s[0])?NaN:s?o:1/0);if(u=Math.sqrt(+k(o)),u==0||u==1/0?(n=W(s),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=U((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new b(n)):r=new b(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(o,a,f,1))),W(a.c).slice(0,u)===(n=W(r.c)).slice(0,u)){if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(O(a,a.e+c+2,0),a.times(a).eq(o))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(O(r,r.e+c+2,1),e=!r.times(r).eq(o));break}}}return O(r,r.e+c+1,l,e)},typeof BigInt==`function`&&(o.toBigInt=function(e){var t=this;return t.c?BigInt(C(t,t.e+1,e)):null}),o.toExponential=function(e,t){return C(this,e==null?e:K(e,0,V)+1,t,1)},o.toFixed=function(e,t){return C(this,e==null?e:K(e,-V,V)+this.e+1,t)},o.toFormat=function(e,t,n){var r,i,a,o,s=this;if(n==null)n=v,e!=null&&(t==null?typeof e==`object`&&!q(e)&&(n=D(e),e=t=null):typeof t==`object`&&(n=D(t),t=null));else if(typeof n!=`object`)throw Error(F+`Argument not an object: `+n);else n=D(n);if(e!=null){if(q(e)&&e.length<=2){if(i=e[0],a=e[1],e=s.dp(),a!=null&&e>K(a,0,V)&&(e=a),i!=null&&K(i,0,V)!==0){if(a!=null&&i>a)throw Error(F+`Minimum must not exceed maximum`);e<i&&(e=i)}}else K(e,-V,V)}if(o=s.toFixed(e,t),r=o.charCodeAt(0)===45,r&&(o=o.slice(1)),s.c){var c,l=o.split(`.`),u=+n.groupSize,d=+n.secondaryGroupSize,f=n.groupSeparator||``,p=l[0],m=l[1],h=p.length;if(d&&(c=u,u=d,d=c,h-=c),u>0&&h>0){for(c=h%u||u,o=p.substr(0,c);c<h;c+=u)o+=f+p.substr(c,u);d>0&&(o+=f+p.slice(c))}else o=p;m&&(c=+n.fractionGroupSize,c&&(m=m.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``))),o+=(n.decimalSeparator||``)+m)}return(n.prefix||``)+(r?n.negativeSign||``:s.s>0&&n.positiveSign||``)+o+(n.suffix||``)},o.toFraction=function(e){var n,r,i,a,o,c,l,u,d,f,m,h,g,_,v=this,y=v.c;if(e!=null&&(l=new b(e),!l.isInteger()&&(l.c||l.s!==1)||l.lt(s)))throw Error(F+`Argument `+(l.isInteger()?`out of range: `:`not an integer: `)+k(l));if(!y)return[new b(v.s||0),new b(0)];for(n=new b(s),d=r=new b(s),i=u=new b(s),h=W(y),o=n.e=h.length-v.e-1,n.c[0]=z[(c=o%L)<0?L+c:c],e=!e||l.comparedTo(n)>0?o>0?n:d:l,c=p,p=1/0,l=new b(h),_=l,g=n,u.c[0]=0;f=t(l,n,0,1),a=r.plus(f.times(i)),a.comparedTo(e)!=1;)r=i,i=a,d=u.plus(f.times(a=d)),u=a,n=l.minus(f.times(a=n)),l=a;return a=t(e.minus(r),i,0,1),u=u.plus(a.times(d)),r=r.plus(a.times(i)),m=d.times(g).minus(_.times(i)).abs().times(r).comparedTo(u.times(g).minus(_.times(r)).abs().times(i))<1?[d,i]:[u,r],m[0].s=v.s,p=c,m},o.toNumber=function(){return+k(this)},o.toObject=function(){var e=this;return{c:e.c?e.c.slice():null,e:e.e,s:e.s}},o.toPrecision=function(e,t){return C(this,e==null?e:K(e,1,V),t,2)},o.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=u||a>=d?Y(W(r.c),a):X(W(r.c),a,`0`):(K(e,2,y.length,`Base`),t=n(X(W(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},o.valueOf=o.toJSON=function(){return k(this)},o._isBigNumber=!0,e!=null&&b.set(e),b}function U(e){var t=e|0;return e>0||e===t?t:t-1}function W(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=L-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function G(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function K(e,t,n,r){if(e<t||e>n||e!==P(e))throw Error(F+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e));return e}function q(e){return{}.toString.call(e)==`[object Array]`}function J(e){var t=e.c.length-1;return U(e.e/L)==t&&e.c[t]%2!=0}function Y(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function X(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}j.config({DECIMAL_PLACES:20,ROUNDING_MODE:j.ROUND_HALF_UP,FORMAT:{prefix:``,decimalSeparator:`.`,groupSeparator:`,`,groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:` `,fractionGroupSize:0,suffix:``}});var ie=e=>j.isBigNumber(e)?e:new j(e),ae=()=>new j(0),oe=e=>e.reduce((e,t)=>e.plus(t),ae()),se=(e,t)=>e.decimalPlaces(t,j.ROUND_DOWN),ce=e=>{if(!e.isFinite()||!e.isInteger())return null;let t=Number(e.toFixed(0));return Number.isSafeInteger(t)?t:null},le=e=>O(`Rejected API response entry`).pipe(k({event:`api_decode_rejection`,operation:e.operation,location:String(e.location),issue:e.issue,...e.identifier?{identifier:e.identifier}:{}})),ue=e=>O(`Ignored invalid optional API response field`).pipe(k({event:`api_decode_field_rejection`,operation:e.operation,field:e.field,issue:e.issue})),de=T([v.check(g()),b]),fe=de.pipe(f(_(j).check(p(e=>e.isFinite()?!0:`expected a finite decimal`)),c({decode:e=>new j(e),encode:e=>e.toFixed()}))),pe=p(e=>e.isGreaterThanOrEqualTo(0)?!0:`expected a finite non-negative decimal`),me=fe.check(pe),he=b.check(p(e=>Number.isSafeInteger(e)?!0:`expected a safe integer Base Unit Amount`)).pipe(f(S,c({decode:e=>BigInt(e),encode:e=>Number(e)}))),ge=T([m,he]),_e=h,ve=(e,r)=>{let i=n(_e)(e);return t(i,{onFailure:()=>ue({...r,issue:`invalid UTC date-time`}).pipe(ee(void 0)),onSuccess:e=>D(e)})},ye=e=>i.pipe(f(u(C),{decode:o(t=>t===void 0?D(void 0):ve(t,e)),encode:l(e=>e===void 0?void 0:te(e))})),be=e=>i.pipe(f(a(C),{decode:o(t=>t===null?D(null):ve(t,e).pipe(E(e=>e??null))),encode:l(e=>e===null?null:te(e))})),xe=e=>{let t=Number(e);return Number.isNaN(t)?e:t},Se={id:`ledgerLive`,name:`Ledger Live`,type:`ledgerLive`},Ce=e=>e.id===Se.id,we=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed hex string`}),Te=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed address`}),Ee=v.check(p(e=>re(e)&&e.length>2?!0:`expected a 0x-prefixed hex quantity`)).pipe(f(S,c({decode:e=>ne(e),encode:e=>A(e)}))),Z=T([ge,Ee]),De=r({data:we,to:Te,gasLimit:Z,from:Te,value:w(Z),type:b,gasPrice:w(Z),maxFeePerGas:w(Z),maxPriorityFeePerGas:w(Z),chainId:b}),Oe=De,ke=x(De),Ae=e=>s(ke)(e),Q=e=>e===void 0?void 0:A(e),je=(e,t)=>({to:e.to,from:t,data:e.data,value:e.value?A(e.value):void 0,gas:A(e.gasLimit),chainId:A(e.chainId)}),Me=e=>({address:t,tx:n})=>Ae(n).pipe(E(n=>({...je(n,t),...e(n)}))),Ne=Me(e=>e.maxFeePerGas?{type:`0x2`,maxFeePerGas:A(e.maxFeePerGas),maxPriorityFeePerGas:e.maxPriorityFeePerGas?A(e.maxPriorityFeePerGas):void 0}:{type:`0x1`,gasPrice:e.gasPrice?A(e.gasPrice):void 0}),Pe=Me(e=>e.type===2?{type:`0x2`,maxFeePerGas:Q(e.maxFeePerGas),maxPriorityFeePerGas:Q(e.maxPriorityFeePerGas)}:{type:`0x0`,gasPrice:Q(e.gasPrice)}),Fe=(t,r)=>n(t)(r).pipe(e(e=>e.message)),$=d(e=>typeof e==`string`&&e.startsWith(`0x`),{expected:`a 0x-prefixed hex string`}),Ie=r({tx:r({address:v,assetId:w($),blockHash:$,blockNumber:$,era:$,genesisHash:$,metadataHash:w($),method:v,mode:w(b),nonce:$,specVersion:$,tip:$,transactionVersion:$,signedExtensions:y(v),version:b,metadataRpc:$}),specName:v,specVersion:b,metadataRpc:$});export{se as C,ce as S,ue as _,Ae as a,ae as b,Ce as c,fe as d,de as f,_e as g,ye as h,Ne as i,xe as l,be as m,Fe as n,Oe as o,me as p,Pe as r,Se as s,Ie as t,ge as u,le as v,j as w,oe as x,ie as y};
|