PageSourceSearch

https://defi-loan-aggregator.vercel.app/_next/static/chunks/471d6826adfba2f6.js

js defi-loan-aggregator.vercel.app collected 2026-10-03 05:52:47 UTC 157,041 bytes, 23 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,364211,727695,553106,651846,350838,63398,718903,639111,600599,e=>{"use strict";let t={path:"/api/v1/apps/:app_id/smart_wallets",method:"GET"};class r{getConfig(){return this._privyInternal.config}async getSmartWalletConfig(){return this._smartWalletConfig||(this._smartWalletConfig=await this._privyInternal.fetch(t,{params:{app_id:this.appId}})),this._smartWalletConfig}get appId(){return this._privyInternal.appId}constructor(e){this._privyInternal=e}}e.s(["default",()=>r],364211);let n={path:"/api/v1/apps/:app_id/cross-app/connections",method:"GET"},i=new TextEncoder,a=new TextDecoder,s=e=>{let t=e;t instanceof Uint8Array&&(t=a.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{var r=t;let e=atob(r),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}catch(e){throw TypeError("The input to be decoded is not correctly encoded.")}};e.s(["decode",0,s,"encode",0,e=>(e=>{let t=e;"string"==typeof t&&(t=i.encode(t));let r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))})(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")],727695);class o extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){var t;super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,null==(t=Error.captureStackTrace)||t.call(Error,this,this.constructor)}}class c extends o{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}}class l{static parse(e){try{return new l(e)}catch(e){return null}}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=function(e){let t,r;if("string"!=typeof e)throw new c("JWTs must use Compact JWS serialization, JWT must be a string");let{1:n,length:i}=e.split(".");if(5===i)throw new c("Only JWTs using Compact JWS serialization can be decoded");if(3!==i)throw new c("Invalid JWT");if(!n)throw new c("JWTs must contain a payload");try{t=s(n)}catch(e){throw new c("Failed to base64url decode the payload")}try{r=JSON.parse(a.decode(t))}catch(e){throw new c("Failed to parse the decoded payload as JSON")}if(!function(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(r))throw new c("Invalid JWT Claims Set");return r}(e)}}e.s(["Token",()=>l],553106);class d{async updateOnCrossAppAuthentication(e,t){let r=t.access_token,n=d.providerAccessTokenStorageKey(e);await this._storage.put(n,r)}async getProviderAccessToken(e){let t=d.providerAccessTokenStorageKey(e),r=await this._storage.get(t);if("string"!=typeof r)return null;try{if(new l(r).isExpired())throw Error("JWT is expired");return r}catch{return await this._storage.del(t),null}}async getCrossAppConnections(){return await this._privyInternal.fetch(n,{params:{app_id:this._privyInternal.appId}})}constructor(e,t){this._privyInternal=e,this._storage=t}}d.providerAccessTokenStorageKey=e=>`privy:cross-app:${e}`,e.s(["default",()=>d],651846);var _=e.i(944406);class f{async revoke(){await this._privyInternal.fetch(_.WalletsRevoke,{})}constructor(e){this._privyInternal=e}}e.s(["default",()=>f],350838);class u extends Error{constructor({error:e,code:t}){super(e),this.error=e,this.code=t}}
1class h extends Error{constructor({error:e,code:t}){super(e),this.code=t,this.error=e}}class p extends Error{constructor({error:e,code:t,response:r}){super(e),this.code=t,this.error=e,this.response=r}}e.s(["MoonpayApiError",()=>p,"PrivyApiError",()=>u,"PrivyClientError",()=>h],63398);let y=e=>!!e.id&&"privy-v2"===e.recovery_method;e.s(["isUnifiedWallet",()=>y],718903);class E{async sign({message:e}){return await this.request({method:"sign",params:{message:new TextDecoder("utf8").decode(e)}})}async signTransaction({psbt:e}){return await this.request({method:"signTransaction",params:{psbt:e}})}async request(e){if(y(this._account))throw new h({code:"unsupported_wallet_type",error:"Bitcoin wallet providers are only supported for on-device execution and this app uses TEE execution. Use the useSignRawHash hook from @privy-io/expo/extended-chains to sign over a hash with this wallet. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide"});if(!await this._privyInternal.getAccessTokenInternal())throw new h({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});return this.handleIFrameRpc(e)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing access token. User must be authenticated.");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),(await this._proxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:this._account.chain_type})).response.data}catch(r){console.error(r);let t=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new h({code:"embedded_wallet_request_error",error:t})}}toJSON(){return`PrivyEmbeddedBitcoinProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:r,entropyId:n,entropyIdVerifier:i}){this._proxy=e,this._privyInternal=t,this._account=r,this._entropyId=n,this._entropyIdVerifier=i}}e.s(["EmbeddedBitcoinWalletProvider",()=>E],639111);var A=e.i(403555);async function g({context:e,chainType:t}){return{wallet:await (0,A.create)(e,{request:{chain_type:t,owner_id:void 0}})}}e.s(["walletCreate",()=>g],600599)},497530,e=>{"use strict";var t=e.i(309682),r=e.i(110163),n=e.i(180635);let i=(e,i,s,o)=>{let c=Number(e),l=i.find(e=>e.id===c);if(!l)throw new n.PrivyConnectorError(`Unsupported chainId ${e}`,4901);return(0,t.createPublicClient)({transport:(0,r.http)(a(l,s,o.appId)),chain:l})},a=(e,t,r)=>{let i,a=e.id,s=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])i=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[s])i=t.rpcUrls[s];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",r),i=t.toString()}else i=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!i)throw new n.PrivyConnectorError(`No RPC url found for ${a}`);return i};function s({currentRecoveryMethod:e,upgradeToRecoveryMethod:t}){switch(e){case"privy":case"user-passcode":case"recovery-encryption-key":return!0;case"icloud":case"google-drive":if(e===t)throw Error("Cannot upgrade to the existing cloud platform");return!0;default:throw Error("Unknown recovery method")}}e.s(["getJsonRpcEndpointFromChain",()=>a,"getPublicClient",()=>i,"throwIfInvalidRecoveryUpgradePath",()=>s])},733821,(e,t,r)=>{"use strict";t.exports=function e(t){if("number"==typeof t&&isNaN(t))throw Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw Error("Infinity is not allowed");if(null===t||"object"!=typeof t)return JSON.stringify(t);if(t.toJSON instanceof Function)return e(t.toJSON());if(Array.isArray(t)){let r=t.reduce((t,r,n)=>`${t}${0===n?"":","}${e(void 0===r||"symbol"==typeof r?null:r)}`,"");return`[${r}]`}let r=Object.keys(t).sort().reduce((r,n)=>{if(void 0===t[n]||"symbol"==typeof t[n])return r;let i=0===r.length?"":",";return`${r}${i}${e(n)}:${e(t[n])}`},"");return`{${r}}`}},732260,(e,t,r)=>{e.e,t.exports=function(){"use strict";function e(e){return Number.isInteger(e)&&e>=0}function t(e){this.name="ArgumentError",this.message=e}return function(r,n){if(n=n||{},"function"!=typeof r)throw new t("fetch must be a function");if("object"!=typeof n)throw new t("defaults must be an object");
1if(void 0!==n.retries&&!e(n.retries))throw new t("retries must be a positive integer");if(void 0!==n.retryDelay&&!e(n.retryDelay)&&"function"!=typeof n.retryDelay)throw new t("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==n.retryOn&&!Array.isArray(n.retryOn)&&"function"!=typeof n.retryOn)throw new t("retryOn property expects an array or function");return n=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},n),function(i,a){var s=n.retries,o=n.retryDelay,c=n.retryOn;if(a&&void 0!==a.retries)if(e(a.retries))s=a.retries;else throw new t("retries must be a positive integer");if(a&&void 0!==a.retryDelay)if(e(a.retryDelay)||"function"==typeof a.retryDelay)o=a.retryDelay;else throw new t("retryDelay must be a positive integer or a function returning a positive integer");if(a&&a.retryOn)if(Array.isArray(a.retryOn)||"function"==typeof a.retryOn)c=a.retryOn;else throw new t("retryOn property expects an array or function");return new Promise(function(e,t){var n=function(n){r("u">typeof Request&&i instanceof Request?i.clone():i,a).then(function(r){if(Array.isArray(c)&&-1===c.indexOf(r.status))e(r);else if("function"==typeof c)try{return Promise.resolve(c(n,null,r)).then(function(t){t?l(n,null,r):e(r)}).catch(t)}catch(e){t(e)}else n<s?l(n,null,r):e(r)}).catch(function(e){if("function"==typeof c)try{Promise.resolve(c(n,e,null)).then(function(r){r?l(n,e,null):t(e)}).catch(function(e){t(e)})}catch(e){t(e)}else n<s?l(n,e,null):t(e)})};function l(e,t,r){setTimeout(function(){n(++e)},"function"==typeof o?o(e,t,r):o)}n(0)})}}}()},902910,740382,31557,771567,382743,117595,e=>{"use strict";let t;var r=e.i(364211),n=e.i(651846),i=e.i(350838),a=e.i(877225),s=e.i(906764),o=e.i(63398),c=e.i(639111),l=e.i(180635),d=e.i(600599),_=e.i(497530),f=e.i(718903);async function u(e,t,r,n,i=!1,a,s){let o=i,c=async a=>{if(o){a===+!i?n():r.current?.reject(new l.PrivyIframeError("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise((e,n)=>{t.current={resolve:e,reject:n},setTimeout(()=>{let e=new l.PrivyIframeError("mfa_timeout","Timed out waiting for MFA code");r.current?.reject(e),n(e)},s)});return await e(o)}return await e()},d=null;for(let e=0;e<a;e++)try{d=await c(e),r.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw r.current?.resolve(void 0),e;o=!0}if(null===d){let e=new l.PrivyIframeError("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw r.current?.reject(e),e}return d}let h=(q=0,()=>"id-"+q++),p=(e,t)=>"bigint"==typeof t?t.toString():t,y=async(e,{ms:t,msg:r})=>{let n,i=new Promise((e,i)=>{n=setTimeout(()=>{i(Error(r))},t??15e3)});try{return await Promise.race([e,i])}finally{void 0!==n&&clearTimeout(n)}},E=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let r=this.callbacks[t];if(!r)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:user-signer:sign":case"privy:wallets:add":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:wallet:connect":case"privy:wallet:recover":case"privy:wallet:rpc":case"privy:solana-wallet:create":case"privy:solana-wallet:create-additional":case"privy:solana-wallet:connect":case"privy:solana-wallet:recover":case"privy:solana-wallet:rpc":case"privy:delegated-actions:consent":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":return r;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}};class A{invokeWithMfa(e,t){return y(u(r=>y(this.waitForReady().then(()=>e(r)),{msg:t.timeoutMsg,ms:t.timeoutMs}),this.mfa.rootPromise,this.mfa.submitPromise,()=>this.mfa.emit("mfaRequired"),t.mfaAlwaysRequired??!1,4,3e5),{msg:"Operation reached timeout: MFA verification",ms:126e4})}reload(){return this.ready=!1,this._embeddedWalletMessagePoster.reload()}ping(e=15e3){return y(this.invoke("privy:iframe:ready",{}),{msg:"Ping reached timeout",ms:e})}create(e){return y(this.waitForReady().then(()=>this.invoke("privy:wallet:create",e)),{msg:"Operation reached timeout: create"})}rpc(e){return this.invokeWithMfa(t=>this.invoke("privy:wallet:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: rpc"})}createSolana(e){return this.invokeWithMfa(t=>this.invoke("privy:solana-wallet:create",{...t,...e}),{timeoutMsg:"Operation reached timeout: create",timeoutMs:6e4})}createAdditionalSolana(e){return y(this.waitForReady().then(()=>this.invoke("privy:solana-wallet:create-additional",e)),{msg:"Operation reached timeout: create"})}solanaRpc(e){return this.invokeWithMfa(t=>this.invoke("privy:solana-wallet:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: solana-rpc"})}delegateWallets(e){return this.invokeWithMfa(t=>this.invoke("privy:delegated-actions:consent",{...t,...e}),{timeoutMsg:"Operation reached timeout: delegated-actions:consent"})}verifyMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:verify",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:verify",mfaAlwaysRequired:!0})}initEnrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:init-enrollment",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:init-enrollment"})}submitEnrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:submit-enrollment",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:submit-enrollment"})}unenrollMfa(e){return this.invokeWithMfa(t=>this.invoke("privy:mfa:unenroll",{...t,...e}),{timeoutMsg:"Operation reached timeout: mfa:unenroll",mfaAlwaysRequired:!0})}clearMfa(e){return y(this.waitForReady().then(()=>this.invoke("privy:mfa:clear",e)),{msg:"Operation reached timeout: mfa:clear"})}createWallet(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:create",{...t,...e}),{timeoutMsg:"Operation reached timeout: create",timeoutMs:6e4})}signWithUserSigner(e){return this.invokeWithMfa(t=>this.invoke("privy:user-signer:sign",{...t,...e}),{timeoutMsg:"Operation reached timeout: user-signer:sign"})}addWallet(e){return y(this.waitForReady().then(()=>this.invoke("privy:wallets:add",e)),{msg:"Operation reached timeout: wallets:add"})}setRecovery(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:set-recovery",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:set-recovery",t
1imeoutMs:6e4})}connect(e){return y(this.waitForReady().then(()=>this.invoke("privy:wallets:connect",e)),{msg:"Operation reached timeout: wallets:connect"})}recover(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:recover",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:recover",timeoutMs:6e4})}rpcWallet(e){return this.invokeWithMfa(t=>this.invoke("privy:wallets:rpc",{...t,...e}),{timeoutMsg:"Operation reached timeout: wallets:rpc"})}handleEmbeddedWalletMessages(e){if(!e.event.startsWith("privy:"))return void console.warn(`Unsupported event type: ${e.event}`);let{reject:t,resolve:r}=E.dequeue(e.event,e.id);return void 0!==e.error?t(new l.PrivyIframeError(e.error.type,e.error.message)):r(e.data)}waitForReady(){return this.ready?Promise.resolve():new Promise(async(e,t)=>{for(;!this.ready;)this.invoke("privy:iframe:ready",{}).then(()=>{this.ready=!0,e()}).catch(t),await new Promise(e=>{setTimeout(()=>{e()},150)})})}invoke(e,t){let r=`${e}${JSON.stringify(t,p)}`;if("privy:wallet:create"===e||"privy:solana-wallet:create"===e){let e=this.cache.get(r);if(e)return e}let n=new Promise((r,n)=>{let i=h();E.enqueue(i,{resolve:r,reject:n}),this._embeddedWalletMessagePoster.postMessage(JSON.stringify({id:i,event:e,data:t}),"*")}).finally(()=>{this.cache.delete(r)});return this.cache.set(r,n),n}constructor(e,t){this.ready=!1,this.cache=new Map,this._embeddedWalletMessagePoster=e,this.mfa=t}}var g=e.i(595932),S=e.i(675107),R=e.i(880841);let I={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844",4:"eip7702"},m={legacy:0,eip2930:1,eip1559:2,eip4844:3,eip7702:4},O=e=>void 0!==e?BigInt(e):void 0;function v(e){let t,{type:r=2,...n}="string"==typeof e?JSON.parse(e):e;n.accessList&&Array.isArray(n.accessList)?t=n.accessList.map(e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e):n.accessList&&(t=Object.entries(n.accessList).map(e=>({address:e[0],storageKeys:e[1]})));let i=Number(n.chainId??1),a=(0,R.isHex)(n.data)?n.data:n.data?(0,S.toHex)(Uint8Array.from(n.data)):void 0,s=n.nonce?Number(n.nonce):void 0,o={chainId:i,data:a,nonce:s,value:O(n.value),gas:O(n.gas??n.gasLimit)},c=Number(r);if(0===c)return{...n,type:I[c],...o,gasPrice:O(n.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===c)return{...n,type:I[c],...o,gasPrice:O(n.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===c)return{...n,type:I[c],...o,nonce:s,accessList:t,maxFeePerGas:O(n.maxFeePerGas),maxPriorityFeePerGas:O(n.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw Error(`Unsupported transaction type: ${r}`)}e.s(["STRING_TO_NUMBER_TXN_TYPE",()=>m,"toViemTransactionSerializable",()=>v],740382);var T=e.i(467034);let w=e=>T.Buffer.from(e,"utf8"),N=e=>`0x${e.toString("hex")}`;var b=e.i(944406),C=e.i(733821);async function D(e,t){let r=(0,C.default)(t);if(void 0===r)throw new o.PrivyClientError({error:"Failed to prepare the payload for signing",code:"invalid_input"});let n=T.Buffer.from(r).toString("base64"),{signature:i}=await e({message:n});return{signature:i}}async function L(e,t,{wallet_id:r,...n}){let i={version:1,url:e.getCompiledPath(b.WalletRpc,{params:{wallet_id:r}}),method:b.WalletRpc.method,headers:{"privy-app-id":e.app.appId},body:{...n}},{signature:a}=await D(t,i);return await e.fetchPrivyRoute(b.WalletRpc,{body:n,params:{wallet_id:r},headers:{"privy-authorization-signature":a}})}function k(e){if("number"==typeof e||"bigint"==typeof e)return`0x${BigInt(e).toString(16)}`;if("string"==typeof e)return/^0x[0-9a-fA-F]*$/.test(e)?e:N(w(e))}async function P({context:e,account:t,rpcRequest:r}){switch(r.chainType){case"ethereum":return async function({context:e,account:t,rpcRequest:r}){var n;switch(r.method){case"personal_sign":{let[n]=r.params,i=await L(e,e.signRequest,{chain_type:"ethereum",method:"personal_sign",wallet_id:t.id,params:n.startsWith("0x")?{message:n.slice(2),encoding:"hex"}:{message:n,encoding:"utf-8"}});if("personal_sign"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}case"eth_signTransaction":{let[n]=r.params,i=await L(e,e.signRequest,{chain_type:"ethereum",method:"eth_signTransaction",wallet_id:t.id,params:{transaction:{from:n.from,to:n.to??void 0,nonce:k(n.nonce),chain_id:k(n.chainId),data:function(e){if(void 0!==e)return"string"==typeof e?/^0x[0-9a-fA-F]*$/.test(e)?e:N(w(e)):N(T.Buffer.from(Uint8Array.from(e)))}(n.data),value:k(n.value),type:n.type,gas_limit:k(n.gasLimit),gas_price:k(n.gasPrice),max_fee_per_gas:k(n.maxFeePerGas),max_priority_fee_per_gas:k(n.maxPriorityFeePerGas)}}});if("eth_signTransaction"!==i.method)throw Error("Unable to sign transaction");return{data:i.data.signed_transaction}}case"eth_signTypedData_v4":{let[,i]=r.params,a=await L(e,e.signRequest,{chain_type:"ethereum",method:r.method,wallet_id:t.id,params:{typed_data:("string"==typeof(n=i)&&(n=JSON.parse(n)),{types:n.types,primary_type:String(n.primaryType),domain:n.domain,message:n.message})}});if("eth_signTypedData_v4"!==a.method)throw Error("Unable to sign typed data");return{data:a.data.signature}}case"eth_sign":{let[,n]=r.params,i=await L(e,e.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:/^0x[0-9a-fA-F]*$/.test(n)?n:N(w(n))}});if("secp256k1_sign"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}case"secp256k1_sign":{let[n]=r.params,i=await L(e,e.signRequest,{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:/^0x[0-9a-fA-F]*$/.test(n)?n:N(w(n))}});if("secp256k1_sign"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}case"csw_signUserOperation":case"eth_sendTransaction":case"eth_populateTransactionRequest":throw Error(`This wallet does not support the method: ${r.method}`)}}({context:e,account:t,rpcRequest:r.request});case"solana":return async function({context:e,account:t,rpcRequest:r}){if("signMessage"===r.method){let{message:n}=r.params,i=await L(e,e.signRequest,{chain_type:"solana",method:"signMessage",wallet_id:t.id,params:{message:n,encoding:"base64"}});if("signMessage"!==i.method)throw Error("Unable to sign message");return{data:i.data.signature}}}({context:e,account:t,rpcRequest:r.request})}}e.s(["generateAuthorizationSignature",()=>D],31557),e.s(["rpc",()=>L],771567);let U=new Set(["eth_sign","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"]);class x extends g.default{async request(e){if(U.has(e.method))return this.handleIFrameRpc(e);switch(e.method){case"eth_accounts":case"eth_requestAccounts":return this._account.address?[this._account.address]:[];case"eth_chainId":return`0x${this._chainId.toString(16)}`;case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_signTransaction":{let t=e.params?.[0];return this.handleSignTransaction(t)}case"eth_sendTransaction":{let t=e.params?.[0];return this.handleSendTransaction(t)}case"eth_populateTransactionRequest":{let t=e.params?.[0];return this.handlePopulateTransaction(t)}default:return this.handleJsonRpc(e)}}ensureChainId(e){let t={chainId:this._chainId,...e};return this.internalSwitchEthereumChain(t.chainId),t}internalSwitchEthereumChain(e){e&&Number(e)!==this._chainId&&(this._chainId=Number(e),this._client=(0,_.getPublicClient)(this._chainId,this._chains,{rpcUrls:[]},{appId:this._privyInternal.appId}
1),this.emit("chainChanged",e))}async handlePopulateTransaction(e){let t=this.ensureChainId(e),r=v(t),{type:n,...i}=await this._client.prepareTransactionRequest({account:t.from??this._account.address,...r});return{...i,type:m[n]}}async handleSignTransaction(e){let t={...e};for(let e of Object.keys(t)){let r=t[e];r&&"bigint"==typeof r&&(t[e]=(0,S.toHex)(r))}return await this.handleIFrameRpc({method:"eth_signTransaction",params:[t]})}async handleSendTransaction(e){let t=await this.handlePopulateTransaction(e),r=await this.handleSignTransaction(t);return await this.handleJsonRpc({method:"eth_sendRawTransaction",params:[r]})}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");let t=e.params?.[0],r=this.ensureChainId(t),n=v(r);return await this._client.estimateGas({account:r.from??this._account.address,...n})}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new l.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new l.EmbeddedProviderError(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.internalSwitchEthereumChain(t)}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address});let r=this._account;if((0,f.isUnifiedWallet)(r)){let{data:n}=await P({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._walletProxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"ethereum",request:e}});return n}try{await this._walletProxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t})}catch(r){let e=(0,l.errorIndicatesRecoveryIsNeeded)(r);if(e&&"privy"===this._account.recovery_method)await this._walletProxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:t});else{if(!e||!this._onNeedsRecovery)throw r;{let e;await new Promise(async(t,r)=>{e=setTimeout(()=>r(new o.PrivyClientError({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"})),12e4),await this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)})}).finally(()=>clearTimeout(e))}}}return(await this._walletProxy.rpcWallet({accessToken:t,request:e,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,hdWalletIndex:this._account.wallet_index,chainType:"ethereum"})).response.data}catch(r){console.error(r);let t=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new o.PrivyClientError({code:"embedded_wallet_request_error",error:t})}}async handleJsonRpc(e){return this._client.request(e)}toJSON(){return`PrivyEIP1193Provider { address: '${this._account.address}', chainId: ${this._chainId}, request: [Function] }`}constructor({walletProxy:e,privyInternal:t,account:r,entropyId:n,entropyIdVerifier:i,chains:a,onNeedsRecovery:s,chainId:o=a[0].id,appApi:c}){super(),this._walletProxy=e,this._privyInternal=t,this._account=r,this._entropyId=n,this._entropyIdVerifier=i,this._chainId=o,this._chains=a,this._onNeedsRecovery=s,this._client=(0,_.getPublicClient)(o,a,{rpcUrls:[]},{appId:c.appId}),this._appApi=c}}function M(e){return"version"in e}function F(e,t){let r=(M(e)?e.message:e.compileMessage()).staticAccountKeys.find(e=>e.toBase58()===t);if(!r)throw Error(`Transaction does not contain public key ${t}`);return r}class z{async request(e){if(!await this._privyInternal.getAccessTokenInternal())throw new o.PrivyClientError({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});switch(e.method){case"signAndSendTransaction":return await this.handleSignAndSendTransaction(e);case"signTransaction":return await this.handleSignTransaction(e);default:return await this.handleIFrameRpc(e)}}get _publicKey(){return this._account.address}
1async connectAndRecover(e){if("privy-v2"!==this._account.recovery_method)try{await this._proxy.connect({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:e})}catch(r){let t=(0,l.errorIndicatesRecoveryIsNeeded)(r);if(t&&"privy"===this._account.recovery_method)await this._proxy.recover({entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier,accessToken:e});else{if(!t||!this._onNeedsRecovery)throw r;{let e;await new Promise(async(t,r)=>{e=setTimeout(()=>r(new o.PrivyClientError({code:"embedded_wallet_recovery_error",error:"User-owned recovery timed out"})),12e4),await this._onNeedsRecovery?.({recoveryMethod:this._account.recovery_method,onRecovered:()=>t(!0)})}).finally(()=>clearTimeout(e))}}}}async signMessageRpc(e,t){let r=this._account;if(!(0,f.isUnifiedWallet)(r))return(await this._proxy.rpcWallet({accessToken:t,request:e,chainType:"solana",hdWalletIndex:this._account.wallet_index,entropyId:this._entropyId,entropyIdVerifier:this._entropyIdVerifier})).response.data;{let{data:n}=await P({context:{app:this._app,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e),signRequest:({message:e})=>this._proxy.signWithUserSigner({accessToken:t,message:e})},account:r,rpcRequest:{chainType:"solana",request:e}});return{signature:n}}}async handleIFrameRpc(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t),await this.signMessageRpc(e,t)}catch(r){console.error(r);let t=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new o.PrivyClientError({code:"embedded_wallet_request_error",error:t})}}async handleSignAndSendTransaction(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t);let{transaction:r,connection:n,options:i}=e.params,a=F(r,this._account.address),s=M(r)?T.Buffer.from(r.message.serialize()):r.serializeMessage(),{signature:o}=await this.signMessageRpc({method:"signMessage",params:{message:s.toString("base64")}},t);return r.addSignature(a,T.Buffer.from(o,"base64")),{signature:await n.sendRawTransaction(r.serialize(),i)}}catch(r){console.error(r);let t=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.address,error:t}),new o.PrivyClientError({code:"embedded_wallet_request_error",error:t})}}async handleSignTransaction(e){try{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw Error("Missing privy token. User must be logged in");this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_started",{method:e.method,address:this._account.address}),await this.connectAndRecover(t);let{transaction:r}=e.params,n=F(r,this._account.address),i=M(r)?T.Buffer.from(r.message.serialize()):r.serializeMessage(),{signature:a}=await this.signMessageRpc({method:"signMessage",params:{message:i.toString("base64")}},t);return r.addSignature(n,T.Buffer.from(a,"base64")),{signedTransaction:r}}catch(r){console.error(r);let t=r instanceof Error?r.message:"Unable to make wallet request";throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_rpc_failed",{method:e.method,address:this._account.wallet_index,error:t}),new o.PrivyClientError({code:"embedded_wallet_request_error",error:t})}}toJSON(){return`PrivyEmbeddedSolanaProvider { address: '${this._account.address}', request: [Function] }`}constructor({proxy:e,privyInternal:t,account:r,entropyId:n,entropyIdVerifier:i,onNeedsRecovery:a,app:s}){this._proxy=e,this._privyInternal=t,this._account=r,this._entropyId=n,this._entropyIdVerifier=i,this._onNeedsRecovery=a,this._app=s}}
1class B{setMessagePoster(e){this._proxy=new A(e,this._mfaPromises),this._mfa.setProxy(this._proxy)}async signWithUserSigner(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new o.PrivyClientError({error:"User must be logged in to sign a message with the user signer",code:"user_signer_sign_error"});let{signature:r}=await this._proxy.signWithUserSigner({accessToken:t,message:e.message});return{signature:r}}async add(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await (0,d.walletCreate)({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:e.chainType});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new o.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.addWallet({accessToken:t,...e})}let{user:t}=await this._privyInternal.refreshSession();return{user:t}}async getBitcoinProvider({wallet:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:n,recoveryAccessToken:i,recoverySecretOverride:a}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return(0,f.isUnifiedWallet)(e)||await this._load({entropyId:t,entropyIdVerifier:r,wallet:e,recoveryPassword:n,recoveryAccessToken:i,recoverySecretOverride:a}),new c.EmbeddedBitcoinWalletProvider({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:r})}async create({password:e,recoveryMethod:t,recoveryToken:r,recoveryKey:n,recoverySecretOverride:i,iCloudRecordNameOverride:a,solanaAccount:s,skipCallbacks:c}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode){if(t&&!t.startsWith("privy"))throw new o.PrivyClientError({error:"User-controlled server wallets do not support custom recovery methods",code:"embedded_wallet_creation_error"});await (0,d.walletCreate)({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"ethereum"})}else{let o;if(o=t||(e?"user-passcode":"privy"),e&&"string"!=typeof e)throw Error("Invalid recovery password, must be a string");if("privy"===o&&this._privyInternal.config?.embedded_wallet_config.require_user_password_on_create)throw Error("Password not provided yet is required by App configuration");let c=await this._privyInternal.getAccessTokenInternal();if(!c)throw Error("User must be logged in to create an embedded wallet");let{address:l}=await this._proxy.create({accessToken:c,recoveryMethod:o,recoveryKey:n,recoveryPassword:e,recoveryAccessToken:r,recoverySecretOverride:i,iCloudRecordNameOverride:a,solanaAddress:s?.address});if(!l)throw Error("Failed to create wallet")}return await this._privyInternal.refreshSession(c)}async createSolana(e){if(!this._proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});if("user-controlled-server-wallets-only"===this._privyInternal.config?.embedded_wallet_config.mode)await (0,d.walletCreate)({context:{app:this._appApi,fetchPrivyRoute:(...e)=>this._privyInternal.fetch(...e),getCompiledPath:(...e)=>this._privyInternal.getPath(...e)},chainType:"solana"});else{let t=await this._privyInternal.getAccessTokenInternal();if(!t)throw new o.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});e?.ethereumAccount&&await this.getProvider(e.ethereumAccount);let{publicKey:r}=await this._proxy.createSolana({accessToken:t,ethereumAddress:e?.ethereumAccount?.address});if(!r)throw new o.PrivyClientError({error:"Failed to create wallet",code:"embedded_wallet_creation_error"})}return await this._privyInternal.refreshSession()}async delegateWallets({delegatedWallets:e,rootWallet:t}){if(!this._proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_creation_error"});let r=await this._privyInternal.getAccessTokenInternal();if(!r)throw new o.PrivyClientError({error:"User must be logged in to create an embedded wallet",code:"embedded_wallet_creation_error"});await this._proxy.delegateWallets({accessToken:r,delegatedWallets:e,rootWallet:t})}async getProvider(e,t,r,n,i){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return(0,f.isUnifiedWallet)(e)||await this._load({wallet:e,entro
1pyId:e.address,entropyIdVerifier:"ethereum-address-verifier",recoveryPassword:t,recoveryKey:i,recoveryAccessToken:r,recoverySecretOverride:n}),new x({account:e,entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}async getEthereumProvider({wallet:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:n,recoveryAccessToken:i,recoverySecretOverride:a,recoveryKey:s,onNeedsRecovery:o}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if(!await this._privyInternal.getAccessTokenInternal())throw Error("User must be logged in to create an embedded wallet");return(0,f.isUnifiedWallet)(e)||(!o||n||i||a||s)&&await this._load({entropyId:t,entropyIdVerifier:r,wallet:e,recoveryPassword:n,recoveryAccessToken:i,recoverySecretOverride:a,recoveryKey:s}),new x({account:e,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,onNeedsRecovery:o,appApi:this._appApi})}async getSolanaProvider(e,t,r,n,i,a,s){if(!this._proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return(0,f.isUnifiedWallet)(e)||(!s||n||i||a)&&await this._load({wallet:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:n,recoveryAccessToken:i,recoverySecretOverride:a}),new z({account:e,privyInternal:this._privyInternal,proxy:this._proxy,entropyId:t,entropyIdVerifier:r,onNeedsRecovery:s,app:this._appApi})}async setRecovery(e){let{wallet:t,...r}=e;if(!this._proxy)throw Error("Embedded wallet proxy not initialized");if((0,f.isUnifiedWallet)(t))throw new o.PrivyClientError({error:"This wallet does not support setting recovery methods",code:"unsupported_recovery_method"});(0,_.throwIfInvalidRecoveryUpgradePath)({currentRecoveryMethod:t.recovery_method,upgradeToRecoveryMethod:"icloud-native"===r.recoveryMethod?"icloud":r.recoveryMethod}),await this._load("solana"===t.chain_type?{wallet:t,entropyId:t.address,entropyIdVerifier:"solana-address-ver
1ifier"}:{wallet:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier"});let n=await this._privyInternal.getAccessTokenInternal();if(!n)throw Error("User must be logged in to interact with embedded wallets");let i=t.recovery_method;this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_started",{address:t.address,target_recovery_method:r.recoveryMethod,existing_recovery_method:i});try{let e;if("user-passcode"===r.recoveryMethod)e={recoveryMethod:"user-passcode",recoveryPassword:r.password};else if("google-drive"===r.recoveryMethod)e={recoveryMethod:"google-drive",recoveryAccessToken:r.recoveryAccessToken};else if("icloud"===r.recoveryMethod)e={recoveryMethod:"icloud",recoveryAccessToken:r.recoveryAccessToken};else if("icloud-native"===r.recoveryMethod)e={recoveryMethod:"icloud-native",iCloudRecordNameOverride:r.iCloudRecordNameOverride,recoverySecretOverride:r.recoverySecretOverride};else if("recovery-encryption-key"===r.recoveryMethod)e={recoveryMethod:"recovery-encryption-key",recoveryKey:r.recoveryKey};else{if("privy"!==r.recoveryMethod)throw Error(`Unknown recovery method: ${r.recoveryMethod}`);e={recoveryMethod:"privy"}}await this._proxy.setRecovery({accessToken:n,entropyId:t.address,entropyIdVerifier:"solana"===t.chain_type?"solana-address-ver
1ifier":"ethereum-address-verifier",...e}),this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_completed",{address:t.address,target_recovery_method:r.recoveryMethod,existing_recovery_method:i});let{user:a}=await this._privyInternal.refreshSession();return{user:a,provider:"ethereum"!==t.chain_type?null:new x({account:t,entropyId:t.address,entropyIdVerifier:"ethereum-address-verifier",privyInternal:this._privyInternal,chains:this._chains,walletProxy:this._proxy,appApi:this._appApi})}}catch(e){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_set_recovery_failed",{address:t.address,recovery_method:t.recovery_method,error:e instanceof Error?e.message:"Unable to recover wallet"}),e}}getURL(){let e=new URL(`${this._privyInternal.baseUrl}/apps/${this._privyInternal.appId}/embedded-wallets`);return this._privyInternal.caid&&e.searchParams.append("caid",this._privyInternal.caid),this._privyInternal.appClientId&&e.searchParams.append("client_id",this._privyInternal.appClientId),e.href}get chains(){return this._chains}onMessage(e){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return this._proxy.handleEmbeddedWalletMessages(e)}reload(){this._proxy?this._proxy.reload():console.warn("Attempted to reload proxy before initialized")}async ping(e){try{if(!this._proxy)throw Error("Embedded wallet proxy not initialized");return await this._proxy.ping(e),!0}catch(e){return console.error(e),!1}}async _load({entropyId:e,entropyIdVerifier:t,wallet:r,recoveryPassword:n,recoveryKey:i,recoveryAccessToken:a,recoverySecretOverride:s}){if(!this._proxy)throw Error("Embedded wallet proxy not initialized");let o=await this._privyInternal.getAccessTokenInternal();if(!o)throw Error("User must be logged in to interact with embedded wallets");try{return await this._proxy.connect({accessToken:o,entropyId:e,entropyIdVerifier:t}),e}catch(c){if((0,l.errorIndicatesRecoveryIsNeeded)(c))try{if("privy"===r.recovery_method){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:r.address,recovery_method:r.recovery_method});let n=await this._proxy.recover({accessToken:o,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:r.address,recovery_method:r.recovery_method}),n.entropyId}if("user-passcode"===r.recovery_method&&n){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:r.address,recovery_method:r.recovery_method});let i=await this._proxy.recover({accessToken:o,recoveryPassword:n,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:r.address,recovery_method:r.recovery_method}),i.entropyId}if(["google-drive","icloud"].includes(r.recovery_method)&&a){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:r.address,recovery_method:r.recovery_method});let n=await this._proxy.recover({accessToken:o,recoveryAccessToken:a,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:r.address,recovery_method:r.recovery_method}),n.entropyId}if("icloud"===r.recovery_method&&s){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:r.address,recovery_method:"icloud-native"});let n=await this._proxy.recover({accessToken:o,recoverySecretOverride:s,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:r.address,recovery_method:"icloud-native"}),n.entropyId}if("recovery-encryption-key"===r.recovery_method&&i){this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_started",{address:r.address,recovery_method:r.recovery_method});let n=await this._proxy.recover({accessToken:o,recoveryKey:i,entropyId:e,entropyIdVerifier:t});return this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_completed",{address:r.address,recovery_method:r.recovery_method}),n.entropyId}}catch(t){throw this._privyInternal.createAnalyticsEvent("embedded_wallet_sdk_recovery_failed",{address:r.address,recovery_method:r.re
1covery_method,error:t instanceof Error?t.message:`Unable to recover wallet: ${e}`}),t}throw c}}constructor(e,t,r,n,i,o){if(this._chains=Array.from(a.DEFAULT_SUPPORTED_CHAINS),this._privyInternal=e,t&&(this._proxy=new A(t,i),n.setProxy(this._proxy)),r){let e=(0,s.dedupeSupportedChains)(r);this._chains=e}this._mfa=n,this._mfaPromises=i,this._appApi=o}}var G=g;class V extends G.default{constructor(){super(),this.rootPromise={current:null},this.submitPromise={current:null}}}var W=e.i(732260);let H="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),j=new Uint8Array(16),Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));let K=function(e,r,n){if(H&&!r&&!e)return H();let i=(e=e||{}).random||(e.rng||function(){if(!t&&!(t="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(j)})();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,r){n=n||0;for(let e=0;e<16;++e)r[n+e]=i[e];return r}return function(e,t=0){return Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+"-"+Y[e[t+4]]+Y[e[t+5]]+"-"+Y[e[t+6]]+Y[e[t+7]]+"-"+Y[e[t+8]]+Y[e[t+9]]+"-"+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]}(i)};var q,$,X=(($={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",$.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",$.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",$.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",$.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",$.MISSING_MFA_ENROLLMENT="missing_mfa_enrollment",$.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",$.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",$.INVALID_DATA="invalid_data",$.INVALID_CREDENTIALS="invalid_credentials",$.INVALID_CAPTCHA="invalid_captcha",$.LINKED_TO_ANOTHER_USER="linked_to_another_user",$.ALLOWLIST_REJECTED="allowlist_rejected",$.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",$.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",$.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",$.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",$.TOO_MANY_REQUESTS="too_many_requests",$.RESOURCE_CONFLICT="resource_conflict",$.INVALID_ORIGIN="invalid_origin",$.MISSING_ORIGIN="missing_origin",$.INVALID_NATIVE_APP_ID="invalid_native_app_id",$.TOKEN_ALREADY_USED="token_already_used",$.ALREADY_LOGGED_OUT="already_logged_out",$.NOT_SUPPORTED="not_supported",$.USER_UNSUBSCRIBED="user_unsubscribed",$.MAX_APPS_REACHED="max_apps_reached",$.USER_LIMIT_REACHED="max_accounts_reached",$.DEVICE_REVOKED="device_revoked",$.WALLET_PASSWORD_EXISTS="wallet_password_exists",$.OAUTH_STATE_MISMATCH="oauth_state_mismatch",$.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",$.MAX_TEST_ACCOUNTS_REACHED="max_test_accounts_reached",$.DISALLOWED_LOGIN_METHOD="disallowed_login_method",$.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",$.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",$.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",$.CANNOT_SET_PASSWORD="cannot_set_password",$.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",$.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",$.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",$.USER_DOES_NOT_EXIST="user_does_not_exist",$.ALREADY_EXISTS="resource_already_exists",$.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",$.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",$.FEATURE_NOT_ENABLED="feature_not_enabled",$.INSUFFICIENT_FUNDS="insufficient_funds",$.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",$.TRANSACTION_EXECUTION_FAILURE="transaction_execution_failure",$.INVALID_POLICY_FORMAT="invalid_policy_format",$.INVALID_AGGREGATION_FORMAT="invalid_aggregation_format",$.POLICY_VIOLATION="policy_violation",$.AUTHORIZATION_KEY_HAS_ASSOCIATED_WALLETS="authorization_key_has_associated_wallets",$.INVALID_REQUEST="invalid_request",$.SIGNUP_DISABLED="signup_disabled",$);e.s(["PrivyErrorCode",()=>X],382743);let J={path:"/api/v1/apps/:app_id",method:"GET"},Z={path:"/api/v1/analytics_events",method:"POST"},Q={path:"/api/v1/sessions",method:"POST"},ee={path:"/api/v1/sessions/logout",method:"POST"};var et=g,er=e.i(727695),er=er;function en(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var ei=function e(t,r){function n(e,n,i){if("u">typeof document){"number"==typeof(i=en({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decode
1URIComponent).replace(/[()]/g,escape);var a="";for(var s in i)i[s]&&(a+="; "+s,!0!==i[s]&&(a+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(n,e)+a}}return Object.create({set:n,get:function(e){if("u">typeof document&&(!arguments.length||e)){for(var r=document.cookie?document.cookie.split("; "):[],n={},i=0;i<r.length;i++){var a=r[i].split("="),s=a.slice(1).join("=");try{var o=decodeURIComponent(a[0]);if(n[o]=t.read(s,o),e===o)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){n(e,"",en({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,en({},this.attributes,t))},withConverter:function(t){return e(en({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});e.s(["default",()=>ei],117595);var ea=e.i(553106);let es=Promise.allSettled.bind(Promise)??(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),eo="privy:token",ec="privy-token",el="privy:pat",ed="privy:refresh_token",e_="privy-refresh-token",ef="privy:id-token",eu="privy-id-token",eh="privy-session";class ep extends et.default{set isUsingServerCookies(e){this._isUsingServerCookies=e}async getCustomerAccessToken(){let e=await this._storage.get(eo);try{return"string"==typeof e?new ea.Token(e).value:null}catch(e){return console.error(e),await this.destroyLocalState({reason:"getToken_error"}),null}}async getPrivyAccessToken(){let e=await this._storage.get(el);try{return"string"==typeof e?new ea.Token(e).value:null}catch(e){return console.error(e),await this.destroyLocalState({reason:"getToken_error"}),null}}async getRefreshToken(){let e=await this._storage.get(ed);return"string"==typeof e?e:null}async getIdentityToken(){let e=await this._storage.get(ef);return"string"==typeof e?e:null}get mightHaveServerCookies(){try{let e=ei.get(eh);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e,t){return this.mightHaveServerCookies||"string"==typeof e&&"string"==typeof t}tokenIsActive(e){if(!e)return!1;let t=ea.Token.parse(e);return null!==t&&!t.isExpired(30)}async destroyLocalState(e){await es([this._storage.del(eo),this._storage.del(ed),this._storage.del(ef),this._storage.del(this.GUEST_CREDENTIAL_STORAGE_KEY)]),ei.remove(ec),ei.remove(e_),ei.remove(eu),ei.remove(eh),e?.reason&&this.emit("storage_cleared",{reason:e.reason})}async storeCustomerAccessToken(e){if("string"==typeof e){let t=await this._storage.get(eo);if(await this._storage.put(eo,e),!this._isUsingServerCookies){let t=ea.Token.parse(e)?.expiration;ei.set(ec,e,{sameSite:"Strict",secure:!0,expires:t?new Date(1e3*t):void 0})}t!==e&&this.emit("token_stored",{cookiesEnabled:this._isUsingServerCookies})}else{let e=await this._storage.get(eo);await this._storage.del(eo),ei.remove(ec),null!==e&&this.emit("token_cleared",{reason:"set_with_non_string_value"})}}async storePrivyAccessToken(e){"string"==typeof e?await this._storage.put(el,e):await this._storage.del(el)}async storeRefreshToken(e){"string"==typeof e?(await this._storage.put(ed,e),this._isUsingServerCookies||(ei.set(eh,"t",{sameSite:"Strict",secure:!0,expires:30}),ei.set(e_,e,{sameSite:"Strict",secure:!0,expires:30})),this.emit("refresh_token_stored",{cookiesEnabled:this._isUsingServerCookies})):(await this._storage.del(ed),ei.remove(e_),ei.remove(eh),this.emit("refresh_token_cleared",{reason:"set_with_non_string_value"}))}async updateWithTokensResponse(e){let t=(await es([this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),this.storeRefreshToken(e.refresh_token),this.storeIdentityToken(e.identity_token),this.processOAuthTokens(e.oauth_tokens)])).filter(e=>"rejected"===e.status);t.length>0&&this.emit("error_storing_tokens",t.map(e=>String(e.reason)).join(", "))}async processOAuthTokens(e){e&&this.emit("oauth_tokens_granted",e)}async storeIdentityToken(e){if("string"==typeof e){let t=await this._storage.get(ef);if(await this._storage.put(ef,e),!this._isUsingServerCookies){let t=ea.Token.parse(e)?.expiration;
1ei.set(eu,e,{sameSite:"Strict",secure:!0,expires:t?new Date(1e3*t):void 0})}t!==e&&this.emit("identity_token_stored",{cookiesEnabled:this._isUsingServerCookies})}else{let e=await this._storage.get(ef);await this._storage.del(ef),ei.remove(eu),null!==e&&this.emit("identity_token_cleared",{reason:"set_with_non_string_value"})}}async getOrCreateGuestCredential(){let e=this._storage.get(this.GUEST_CREDENTIAL_STORAGE_KEY);if(e&&"string"==typeof e)return e;let t=er.encode(crypto.getRandomValues(new Uint8Array(32)));return await this._storage.put(this.GUEST_CREDENTIAL_STORAGE_KEY,t),t}constructor(e){super(),this._isUsingServerCookies=!1,this._storage=e.storage,this.GUEST_CREDENTIAL_STORAGE_KEY=`privy:guest:${e.appId}`}}ep.events=["storage_cleared","token_cleared","refresh_token_cleared","identity_token_cleared","token_stored","refresh_token_stored","identity_token_stored","oauth_tokens_granted","error_storing_tokens"];let ey=()=>{},eE={NONE:-1/0,ERROR:1,WARN:2,INFO:3,DEBUG:1/0},eA="privy:caid";class eg{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!this._config}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:r}){let n;return`${this.baseUrl}${n=e.path,t?Object.entries(t).reduce((e,[t,r])=>e.replace(`:${t}`,`${r}`),n):n}${function(e){let t=new URLSearchParams;for(let r in e)null!=e[r]&&t.append(r,String(e[r]));return Array.from(t).length?"?"+t.toString():""}(r)}`}async fetch(e,{body:t,params:r,query:n,headers:i,onRequest:a=this._beforeRequest.bind(this)}){let s=new Request(this.getPath(e,{params:r,query:n}),{method:e.method,body:JSON.stringify(t),headers:i}),c=await a(s),l=await this._fetch(s,c),d=await l.json();if(l.status>299)throw new o.PrivyApiError(d);return d}async _beforeRequestWithoutInitialize(e){let t,r=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),n=new Headers(e.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-client",this._sdkVersion),r&&n.set("Authorization",`Bearer ${r}`),n.set("Content-Type","application/json"),n.set("Accept","application/json");let i=await this._getOrGenerateClientAnalyticsId();return i&&n.set("privy-ca-id",i),this.nativeAppIdentifier&&n.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:(t=new AbortController,setTimeout(()=>t.abort(),2e4),t.signal),headers:n,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(J,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(eA);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=K()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(eA,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(eA)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(Z,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new o.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,r=t??"key",n=this._cache.get(r);if(n)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await n;let i=this._refreshSession(t,e);this._cache.set(r,i);try{return await i}finally{this._cache.delete(r)}}async _refreshSession(e,t){let r=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(r,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new o.PrivyApiError({code:X.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.logger.debug(`[privy:refresh] fetching: ${Q.path}`);let r=await this.fetch(Q,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),n=r.session_update_action;return this.logger.debug(`[privy:refresh] response: ${n}`),"set"===n&&(await this.session.updateWithTokensResponse(r),this.logger.debug("[privy:refresh] tokens stored")),"clear"===n&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===n&&(r.token&&(await this.session.storeCustomerAccessToken(r.token),this.logger.debug("[privy:refresh] token stored (CAT)")),r.privy_access_token&&(await this.session.storePrivyAccessToken(r.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),r.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(r.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(r.user),r}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof o.PrivyApiError&&e.code===X.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}
1async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),r=await this.session.getCustomerAccessToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),r===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??r}return e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${K()}`,t="blobby";await this._storage.put(e,t);let r=await this._storage.get(e);return await this._storage.del(e),r===t}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.58.7",this._cache=new Map,this.logger=(({level:e}={level:"ERROR"})=>({get level(){return e},error:eE[e]>=eE.ERROR?console.error:ey,warn:eE[e]>=eE.WARN?console.warn:ey,info:eE[e]>=eE.INFO?console.info:ey,debug:eE[e]>=eE.DEBUG?console.debug:ey}))({level:e.logLevel??"ERROR"}),this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new ep({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=(0,W.default)(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})})}}let eS={path:"/api/v1/users/me/accept_terms",method:"POST"};class eR{async get(){let{user:e}=await this._privyInternal.refreshSession();return{user:e}}async acceptTerms(){return{user:await this._privyInternal.fetch(eS,{})}}constructor(e){this._privyInternal=e}}let eI={path:"/api/v1/custom_jwt_account/authenticate",method:"POST"},em=e=>"wallet"===e.type&&"privy"===e.wallet_client_type&&"embedded"===e.connector_type,eO=e=>e?e.linked_accounts.filter(em).filter(e=>"ethereum"===e.chain_type).sort((e,t)=>e.wallet_index-t.wallet_index):[],ev=e=>eO(e).find(e=>0===e.wallet_index)??null,eT=e=>e?e.linked_accounts.filter(em).filter(e=>"solana"===e.chain_type).sort((e,t)=>e.wallet_index-t.wallet_index):[],ew=async(e,t,r)=>{let n,i,a,s,o=(n=t.user,!("off"===(i=r?.ethereum?.createOnLogin??"off")||eO(n).length>0||n.linked_accounts.filter(e=>"wallet"===e.type&&"ethereum"===e.chain_type).length>0&&"all-users"!==i)),c=(a=t.user,!("off"===(s=r?.solana?.createOnLogin??"off")||eT(a).length>0||a.linked_accounts.filter(e=>"wallet"===e.type&&"solana"===e.chain_type).length>0&&"all-users"!==s));if(o&&c){let r=await e.create({recoveryMethod:"privy",skipCallbacks:!0});return{...await e.createSolana({ethereumAccount:ev(r.user)??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}}return o?{...await e.create({recoveryMethod:"privy",solanaAccount:eT(t.user).find(e=>0===e.wallet_index)??null??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}:c?{...await e.createSolana({ethereumAccount:ev(t.user)??void 0}),is_new_user:t.is_new_user,oauth_tokens:t.oauth_tokens}:t};class eN{async syncWithToken(e,t,r){let n=await this._privyInternal.fetch(eI,{body:{token:e,mode:r}});await this._privyInternal.session.updateWithTokensResponse(n);let i=await ew(this._embedded,n,t?.embedded);return this._privyInternal.callbacks?.setUser?.(i.user),i}constructor(e,t){this._privyInternal=e,this._embedded=t}}let eb={path:"/api/v1/passwordless/authenticate",method:"POST"},eC={path:"/api/v1/passwordless/init",method:"POST"},eD={path:"/api/v1/passwordless/link",method:"POST"},eL={path:"/api/v1/passwordless/unlink",method:"POST"},ek={path:"/api/v1/passwordless/update",method:"POST"};class eP{async sendCode(e,t){return this._privyInternal.fetch(eC,{body:{email:e,token:t}})}async loginWithCode(e,t,r,n){let i=await this._privyInternal.fetch(eb,{body:{email:e,code:t,mode:r}});await this._privyInternal.session.updateWithTokensResponse(i);let a=await ew(this._embedded,i,n?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async linkWithCode(e,t){await this._privyInternal.fetch(eD,{body:{email:e,code:t}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async updateEmail({oldEmailAddress:e,newEmailAddress:t,code:r}){await this._privyInternal.fetch(ek,{body:{oldAddress:e,newAddress:t,code:r}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}async unlink(e){await this._privyInternal.fetch(eL,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let eU={path:"/api/v1/farcaster/init",method:"POST"},ex={path:"/api/v1/farcaster/authenticate",method:"POST"},eM={path:"/api/v1/farcaster/link",method:"POST"},eF={path:"/api/v1/farcaster/unlink",method:"POST"},ez={path:"/api/v1/farcaster/status",method:"GET"},eB={path:"/api/v2/farcaster/init",method:"POST"},eG={path:"/api/v2/farcaster/authenticate",method:"POST"};class eV{async initializeAuth({relyingParty:e,redirectUrl:t,token:r}){return await this._privyInternal.fetch(eU,{body:{relying_party:e,redirect_url:t,token:r}})}async getFarcasterStatus({channel_token:e}){return await this._privyInternal.fetch(ez,{headers:{"farcaster-channel-token":e}})}async authenticate({channel_token:e,message:t,signature:r,fid:n,mode:i},a){let s=await this._privyInternal.fetch(ex,{body:{channel_token:e,message:t,signature:r,fid:n,mode:i}});await this._privyInternal.session.updateWithTokensResponse(s);let o=await ew(this._embedded,s,a?.embedded);return this._privyInternal.callbacks?.setUser?.(o.user),o}async link({channel_token:e,message:t,signature:r,fid:n}){await this._privyInternal.fetch(eM,{body:{channel_token:e,message:t,signature:r,fid:n}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async unlink({fid:e}
1){await this._privyInternal.fetch(eF,{body:{fid:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}class eW{async initializeAuth(){return await this._privyInternal.fetch(eB,{body:{}})}async authenticate({message:e,signature:t,fid:r},n){let i=await this._privyInternal.fetch(eG,{body:{message:e,signature:t,fid:r}});await this._privyInternal.session.updateWithTokensResponse(i);let a=await ew(this._embedded,i,n?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}constructor(e,t){this._privyInternal=e,this._embedded=t}}let eH={path:"/api/v1/guest/authenticate",method:"POST"};class ej{async create(e){let t=await this._privyInternal.session.getOrCreateGuestCredential(),r=await this._privyInternal.fetch(eH,{body:{guest_credential:t}});await this._privyInternal.session.updateWithTokensResponse(r);let n=await ew(this._embedded,r,e?.embedded);return this._privyInternal.callbacks?.setUser?.(n.user),n}constructor(e,t){this._privyInternal=e,this._embedded=t}}let eY={path:"/api/v1/oauth/authenticate",method:"POST"},eK={path:"/api/v1/oauth/init",method:"POST"},eq={path:"/api/v1/oauth/link",method:"POST"},e$={path:"/api/v1/oauth/unlink",method:"POST"};var er=er;let eX="privy:state_code",eJ="privy:code_verifier";async function eZ(e,t){let r=(new TextEncoder).encode(e);return new Uint8Array(await t("SHA-256",r))}function eQ(){return er.encode(crypto.getRandomValues(new Uint8Array(36)))}async function e0({codeVerifier:e,method:t="S256",digest:r=crypto.subtle.digest.bind(crypto.subtle)}){if("S256"!=t)return e;{let t=await eZ(e,r);return er.encode(t)}}class e1{async generateURL(e,t){let r=eQ(),n=eQ(),i=await e0({codeVerifier:r,digest:this._crypto?.digest});return await Promise.all([this._storage.put(eJ,r),this._storage.put(eX,n)]),this._privyInternal.fetch(eK,{body:{redirect_to:t,provider:e,code_challenge:i,state_code:n}})}async loginWithCode(e,t,r,n,i,a){let[s,c]=await Promise.all([this._storage.get(eJ),this._storage.get(eX)]);if(c!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"oauth",provider:r,storedStateCode:c??"",returnedStateCode:t??""}),new o.PrivyClientError({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let l=await this._privyInternal.fetch(eY,{body:{authorization_code:e,code_type:n,state_code:c,code_verifier:s,mode:i}});await this._privyInternal.session.updateWithTokensResponse(l);let d=await ew(this._embedded,l,a?.embedded);return await Promise.all([this._storage.del(eJ),this._storage.del(eX)]),this._privyInternal.callbacks?.setUser?.(d.user),d}async linkWithCode(e,t,r,n){let[i,a]=await Promise.all([this._storage.get(eJ),this._storage.get(eX)]);if(a!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"oauth",provider:r,storedStateCode:a??"",returnedStateCode:t??""}),new o.PrivyClientError({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let s=await this._privyInternal.fetch(eq,{body:{authorization_code:e,code_type:n,state_code:a,code_verifier:i}});await this._privyInternal.session.processOAuthTokens(s.oauth_tokens);let c=await this._privyInternal.refreshSession();return await Promise.all([this._storage.del(eJ),this._storage.del(eX)]),{user:c.user,identity_token:c.identity_token}}async unlink(e,t){await this._privyInternal.fetch(e$,{body:{provider:e,subject:t}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}constructor(e,t,r,n){this._privyInternal=e,this._embedded=t,this._storage=r,this._crypto=n}}let e6={path:"/api/v1/passkeys/link",method:"POST"},e2={path:"/api/v1/passkeys/authenticate",method:"POST"},e8={path:"/api/v1/passkeys/register",method:"POST"},e3={path:"/api/v1/passkeys/authenticate/init",method:"POST"},e5={path:"/api/v1/passkeys/register/init",method:"POST"},e4={path:"/api/v1/passkeys/link/init",method:"POST"};class e7{async generateRegistrationOptions(e){return await this._privyInternal.fetch(e4,{body:{relying_party:e}})}async generateAuthenticationOptions(e){return await this._privyInternal.fetch(e3,{body:{relying_party:e}})}async generateSignupOptions(e){return await this._privyInternal.fetch(e5,{body:{relying_party:e}})}async loginWithPasskey(e,t,r,n){let i=await this._privyInternal.fetch(e2,{body:{relying_party:r,challenge:t,authenticator_response:this._transformAuthenticationResponseToSnakeCase(e)}});await this._privyInternal.session.updateWithTokensResponse(i);let a=await ew(this._embedded,i,n?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async signupWithPasskey(e,t,r){let n=await this._privyInternal.fetch(e8,{body:{relying_party:t,authenticator_response:this._transformRegistrationResponseToSnakeCase(e)}});await this._privyInternal.session.updateWithTokensResponse(n);let i=await ew(this._embedded,n,r?.embedded);return this._privyInternal.callbacks?.setUser?.(i.user),i}async linkWithPasskey(e,t){await this._privyInternal.fetch(e6,{body:{relying_party:t,authenticator_response:this._transformRegistrationResponseToSnakeCase(e)}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}_transformRegistrationResponseToSnakeCase(e){return{type:e.type,id:e.id,raw_i
1d:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData||void 0,transports:e.response.transports||void 0,public_key:e.response.publicKey||void 0,public_key_algorithm:e.response.publicKeyAlgorithm||void 0},authenticator_attachment:e.authenticatorAttachment||void 0,client_extension_results:{app_id:e.clientExtensionResults.appid||void 0,cred_props:e.clientExtensionResults.credProps||void 0,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret||void 0}}}_transformAuthenticationResponseToSnakeCase(e){return{type:e.type,id:e.id,raw_id:e.rawId,response:{signature:e.response.signature,client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,user_handle:e.response.userHandle||void 0},authenticator_attachment:e.authenticatorAttachment||void 0,client_extension_results:{app_id:e.clientExtensionResults.appid||void 0,cred_props:e.clientExtensionResults.credProps||void 0,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret||void 0}}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let e9={path:"/api/v1/passwordless_sms/authenticate",method:"POST"},te={path:"/api/v1/passwordless_sms/init",method:"POST"},tt={path:"/api/v1/passwordless_sms/link",method:"POST"},tr={path:"/api/v1/passwordless_sms/unlink",method:"POST"},tn={path:"/api/v1/passwordless_sms/update",method:"POST"};class ti{async sendCode(e,t){return this._privyInternal.fetch(te,{body:{phoneNumber:e,token:t}})}async loginWithCode(e,t,r,n){let i=await this._privyInternal.fetch(e9,{body:{phoneNumber:e,code:t,mode:r}});await this._privyInternal.session.updateWithTokensResponse(i);let a=await ew(this._embedded,i,n?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async linkWithCode(e,t){await this._privyInternal.fetch(tt,{body:{phoneNumber:e,code:t}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async updatePhone({oldPhoneNumber:e,newPhoneNumber:t,code:r}){await this._privyInternal.fetch(tn,{body:{old_phone_number:e,new_phone_number:t,code:r}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}async unlink(e){await this._privyInternal.fetch(tr,{body:{phoneNumber:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}let ta={path:"/api/v1/siwe/init",method:"POST"},ts={path:"/api/v1/siwe/authenticate",method:"POST"},to={path:"/api/v1/siwe/link",method:"POST"},tc={path:"/api/v1/siwe/link_smart_wallet",method:"POST"},tl={path:"/api/v1/siwe/unlink",method:"POST"};class td{async unlinkWallet(e){await this._privyInternal.fetch(tl,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}async linkWithSiwe(e,t,r){let n=t||this._wallet,i=r||this._preparedMessage;if(!n)throw Error("A wallet must be provided in the init step or as an argument to linkWithSiwe");if(!i)throw Error("A message must be generated and signed before being used to link a wallet to privy");await this._privyInternal.fetch(to,{body:{message:i,signature:e,chainId:n.chainId,walletClientType:n.walletClientType??null,connectorType:n.connectorType??null}});let a=await this._privyInternal.refreshSession();return{user:a.user,identity_token:a.identity_token}}async loginWithSiwe(e,t,r,n,i){let a=t||this._wallet,s=r||this._preparedMessage;if(!a)throw Error("A wallet must be provided in the init step or as an argument to loginWithSiwe");if(!s)throw Error("A message must be generated and signed before being used to login to privy with a wallet");let o=await this._privyInternal.fetch(ts,{body:{signature:e,message:s,chainId:a.chainId,walletClientType:a.walletClientType??null,connectorType:a.connectorType??null,mode:n}});await this._privyInternal.session.updateWithTokensResponse(o);let c=await ew(this._embedded,o,i?.embedded);return this._privyInternal.callbacks?.setUser?.(c.user),c}async init(e,t,r){var n;this._wallet=e;let{nonce:i}=await this._privyInternal.fetch(ta,{body:{address:e.address}}),a=`${(n={chainId:e.chainId.toString().replace("eip155:",""),address:e.address,issuedAt:(new Date).toISOString(),statement:"By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",domain:t,nonce:i,uri:r}).domain} wants you to sign in with your Ethereum account:
2${n.address}
3
4${n.statement}
5
6URI: ${n.uri}
7Version: 1
8Chain ID: ${n.chainId}
9Nonce: ${n.nonce}
10Issued At: ${n.issuedAt}
11Resources:
12- https://privy.io`;return this._preparedMessage=a,{nonce:i,message:a}}constructor(e,t){this._wallet=void 0,this._privyInternal=e,this._embedded=t}}let t_={path:"/api/v1/siws/init",method:"POST"},tf={path:"/api/v1/siws/authenticate",method:"POST"},tu={path:"/api/v1/siws/link",method:"POST"},th={path:"/api/v1/siws/unlink",method:"POST"};class tp{async unlink({address:e}){await this._privyInternal.fetch(th,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}async link({message:e,signature:t,walletClientType:r,connectorType:n}){await this._privyInternal.fetch(tu,{body:{message:e,signature:t,walletClientType:r??null,connectorType:n??null}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async login({mode:e,message:t,signature:r,walletClientType:n,connectorType:i,opts:a}){let s=await this._privyInternal.fetch(tf,{body:{signature:r,message:t,walletClientType:n??null,connectorType:i??null,mode:e}});await this._privyInternal.session.updateWithTokensResponse(s);let o=await ew(this._embedded,s,a?.embedded);return this._privyInternal.callbacks?.setUser?.(o.user),o}async fetchNonce({address:e}){let{nonce:t}=await this._privyInternal.fetch(t_,{body:{address:e}});return{nonce:t}}constructor(e,t){this._privyInternal=e,this._embedded=t}}class ty{async link(e,t,r,n){await this._privyInternal.fetch(tc,{body:{message:e,signature:t,smart_wallet_type:r,smart_wallet_version:n}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async init(e){var t;let{nonce:r}=await this._privyInternal.fetch(ta,{body:{address:e.address}});return{nonce:r,message:`${(t={chainId:e.chainId.toString().replace("eip155:",""),address:e.address,issuedAt:(new Date).toISOString(),statement:"By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",domain:"privy.io",uri:"https://auth.privy.io",nonce:r}).domain} wants you to sign in with your Ethereum account:
13${t.address}
14
15${t.statement}
16
17URI: ${t.uri}
18Version: 1
19Chain ID: ${t.chainId}
20Nonce: ${t.nonce}
21Issued At: ${t.issuedAt}
22Resources:
23- https://privy.io`}}constructor(e){this._privyInternal=e}}class tE{async logout(e){try{let e=await this._privyInternal.session.getRefreshToken()??void 0;await this._privyInternal.fetch(ee,{body:{refresh_token:e}})}catch(e){console.warn("Error destroying session")}await Promise.all([this._privyInternal.session.destroyLocalState({reason:"logout"}),this._privyInternal.destroyClientAnalyticsId(),e?.userId&&this._mfa.clearMfa({userId:e.userId})]),this._privyInternal.callbacks?.setUser?.(null)}constructor(e,t,r,n,i){this._privyInternal=e,this._mfa=i,this.customProvider=new eN(this._privyInternal,t),this.phone=new ti(this._privyInternal,t),this.email=new eP(this._privyInternal,t),this.oauth=new e
231(this._privyInternal,t,r,n),this.guest=new ej(this._privyInternal,t),this.siwe=new td(this._privyInternal,t),this.siws=new tp(this._privyInternal,t),this.smartWallet=new ty(this._privyInternal),this.passkey=new e7(this._privyInternal,t),this.farcaster=new eV(this._privyInternal,t),this.farcasterV2=new eW(this._privyInternal,t)}}let tA={path:"/api/v1/funding/coinbase_on_ramp/init",method:"POST"},tg={path:"/api/v1/funding/coinbase_on_ramp/status",method:"GET"};class tS{async initOnRampSession(e){return await this._privyInternal.fetch(tA,{body:e})}async getStatus(e){return await this._privyInternal.fetch(tg,{query:{partnerUserId:e}})}constructor(e){this._privyInternal=e}}let tR={path:"/api/v1/plugins/moonpay_on_ramp/sign",method:"POST"};var tI=e.i(920209);class tm{async sign(e){return await this._privyInternal.fetch(tR,{body:e})}async getTransactionStatus({transactionId:e,useSandbox:t}){let{url:r,key:n}=tI.MoonpayEnvironments[t?"sandbox":"prod"],i=await (0,W.default)(fetch,{retries:3,retryDelay:500})(`${r}/transactions/ext/${e}?apiKey=${n}`);if(!i.ok)throw new o.MoonpayApiError({error:`Failed to fetch transaction status for Transaction ${e}`,code:"failed_to_fetch_moonpay_transaction_status",response:i});let a=await i.json();return Array.isArray(a)?a.at(0):void 0}constructor(e){this._privyInternal=e}}class tO{constructor(e){this.moonpay=new tm(e),this.coinbase=new tS(e)}}let tv={path:"/api/v1/mfa/passkeys/init",method:"POST"};class tT{async generateAuthenticationOptions(e){return await this._privyInternal.fetch(tv,{body:e})}constructor(e){this._privyInternal=e}}let tw={path:"/api/v1/mfa/passwordless_sms/init",method:"POST"};class tN{async sendCode(e){return await this._privyInternal.fetch(tw,{body:e})}constructor(e){this._privyInternal=e}}class tb{setProxy(e){this.proxy=e}async getAccessTokenInternal(){let e=await this.privyInternal.getAccessTokenInternal();if(!e)throw new o.PrivyClientError({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});return e}async verifyMfa(){if(!this.proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.verifyMfa({accessToken:await this.getAccessTokenInternal()})}async initEnrollMfa(e){if(!this.proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.initEnrollMfa({...e,accessToken:await this.getAccessTokenInternal()})}async submitEnrollMfa(e){if(!this.proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let t=await this.proxy.submitEnrollMfa({...e,accessToken:await this.getAccessTokenInternal()});return await this.privyInternal.refreshSession(),t}async unenrollMfa(e){if(!this.proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let t=await this.proxy.unenrollMfa({method:e,accessToken:await this.getAccessTokenInternal()});return await this.privyInternal.refreshSession(),t}async clearMfa(e){if(!this.proxy)throw new o.PrivyClientError({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.clearMfa(e)}constructor(e,t){this.proxy=t,this.privyInternal=e,this.sms=new tN(e),this.passkey=new tT(e)}}let tC={path:"/api/v1/embedded_wallets/:address/recovery/key_material",method:"POST"},tD={path:"/api/v1/recovery/oauth/init",method:"POST"},tL={path:"/api/v1/recovery/oauth/authenticate",method:"POST"},tk={path:"/api/v1/recovery/oauth/init_icloud",method:"POST"},tP={path:"/api/v1/recovery/configuration_icloud",method:"POST"},tU=class{async init(e){return this._privyInternal.fetch(tk,{body:{client_type:e}})}async getICloudConfiguration(e){return this._privyInternal.fetch(tP,{body:{client_type:e}})}constructor(e){this._privyInternal=e}};class tx{async generateURL(e){let t=eQ(),r=eQ(),n=await e0({codeVerifier:t,digest:this._crypto?.digest});return await Promise.all([this._storage.put(eJ,t),this._storage.put(eX,r)]),this._privyInternal.fetch(tD,{body:{redirect_to:e,code_challenge:n,state_code:r}})}async authorize(e,t){let[r,n]=await Promise.all([this._storage.get(eJ),this._storage.get(eX)]);if(n!==t)throw this._privyInternal.createAnalyticsEvent("possible_phishing_attempt",{flow:"recovery_oauth",storedStateCode:n??"",returnedStateCode:t??""}),new o.PrivyClientError({code:"pkce_state_code_mismatch",error:"Unexpected auth flow. This may be a phishing attempt."});let i=await this._privyInternal.fetch(tL,{body:{authorization_code:e,state_code:n,code_verifier:r}});return await Promise.all([this._storage.del(eJ),this._storage.del(eX)]),i}constructor(e,t,r){this._privyInternal=e,this._storage=t,this._crypto=r}}class tM{async getRecoveryKeyMaterial(e,t){return this._privyInternal.fetch(tC,{body:{chain_type:t},params:{address:e}})}constructor(e,t,r){this._privyInternal=e,this.auth=new tx(this._privyInternal,t,r),this.icloudAuth=new tU(this._privyInternal)}}class tF{async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}getCompiledPath(e,t){return this._privyInternal.getPath(e,t)}
23async fetchPrivyRoute(e,t){return this._privyInternal.fetch(e,t)}get logger(){return this._privyInternal.logger}constructor({clientId:e,...t}){this._privyInternal=new eg({...t,appClientId:e}),this.mfa=new tb(this._privyInternal),this.mfaPromises=new V,this.app=new r.default(this._privyInternal),this.embeddedWallet=new B(this._privyInternal,t.embeddedWalletMessagePoster,t.supportedChains,this.mfa,this.mfaPromises,this.app),this.user=new eR(this._privyInternal),this.auth=new tE(this._privyInternal,this.embeddedWallet,t.storage,t.crypto,this.mfa),this.recovery=new tM(this._privyInternal,t.storage,t.crypto),this.funding=new tO(this._privyInternal),this.delegated=new i.default(this._privyInternal),this.crossApp=new n.default(this._privyInternal,t.storage)}}e.s(["default",()=>tF],902910)},642108,e=>{"use strict";function t([e,t]){return`${e}=${function e(t){return Array.isArray(t)?"%5B"+t.map(e).join("%2C%20")+"%5D":"bigint"==typeof t?`${t}n`:encodeURIComponent(String(null!=t&&null===Object.getPrototypeOf(t)?{...t}:t))}(t)}`}function r(e,t){return e instanceof Error&&"SolanaError"===e.name&&(void 0===t||e.context.__code===t)}var n=class extends Error{cause=this.cause;context;constructor(...[e,r]){let n,i;r&&Object.entries(Object.getOwnPropertyDescriptors(r)).forEach(([t,r])=>{"cause"===t?i={cause:r.value}:(void 0===n&&(n={__code:e}),Object.defineProperty(n,t,r))}),super(function(e,r={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(r).length&&(n+=` '${btoa(Object.entries(r).map(t).join("&"))}'`),`${n}\``}}(e,n),i),this.context=Object.freeze(void 0===n?{__code:e}:n),this.name="SolanaError"}};function i(...e){"captureStackTrace"in Error&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(...e)}function a({errorCodeBaseOffset:e,getErrorContext:t,orderedErrorNames:r,rpcEnumError:a},s){let o,c;"string"==typeof a?o=a:(o=Object.keys(a)[0],c=a[o]);let l=e+r.indexOf(o),d=t(l,o,c),_=new n(l,d);return i(_,s),_}var s=["GenericError","InvalidArgument","InvalidInstructionData","InvalidAccountData","AccountDataTooSmall","InsufficientFunds","IncorrectProgramId","MissingRequiredSignature","AccountAlreadyInitialized","UninitializedAccount","UnbalancedInstruction","ModifiedProgramId","ExternalAccountLamportSpend","ExternalAccountDataModified","ReadonlyLamportChange","ReadonlyDataModified","DuplicateAccountIndex","ExecutableModified","RentEpochModified","NotEnoughAccountKeys","AccountDataSizeChanged","AccountNotExecutable","AccountBorrowFailed","AccountBorrowOutstanding","DuplicateAccountOutOfSync","Custom","InvalidError","ExecutableDataModified","ExecutableLamportChange","ExecutableAccountNotRentExempt","UnsupportedProgramId","CallDepth","MissingAccount","ReentrancyNotAllowed","MaxSeedLengthExceeded","InvalidSeeds","InvalidRealloc","ComputationalBudgetExceeded","PrivilegeEscalation","ProgramEnvironmentSetupFailure","ProgramFailedToComplete","ProgramFailedToCompile","Immutable","IncorrectAuthority","BorshIoError","AccountNotRentExempt","InvalidAccountOwner","ArithmeticOverflow","UnsupportedSysvar","IllegalOwner","MaxAccountsDataAllocationsExceeded","MaxAccountsExceeded","MaxInstructionTraceLengthExceeded","BuiltinProgramsMustConsumeComputeUnits"],o=["AccountInUse","AccountLoadedTwice","AccountNotFound","ProgramAccountNotFound","InsufficientFundsForFee","InvalidAccountForFee","AlreadyProcessed","BlockhashNotFound","CallChainTooDeep","MissingSignatureForFee","InvalidAccountIndex","SignatureFailure","InvalidProgramForExecution","SanitizeFailure","ClusterMaintenance","AccountBorrowOutstanding","WouldExceedMaxBlockCostLimit","UnsupportedVersion","InvalidWritableAccount","WouldExceedMaxAccountCostLimit","WouldExceedAccountDataBlockLimit","TooManyAccountLocks","AddressLookupTableNotFound","InvalidAddressLookupTableOwner","InvalidAddressLookupTableData","InvalidAddressLookupTableIndex","InvalidRentPayingAccount","WouldExceedMaxVoteCostLimit","WouldExceedAccountDataTotalLimit","DuplicateInstruction","InsufficientFundsForRent","MaxLoadedAccountsDataSizeExceeded","InvalidLoadedAccountsDataSizeLimit","ResanitizationNeeded","ProgramExecutionTemporarilyRestricted","UnbalancedTransaction"];function c(e){return"object"==typeof e&&"InstructionError"in e?function e(t,r){let n=Number(t);return a({errorCodeBaseOffset:4615001,getErrorContext:(e,t,r)=>4615e3===e?{errorName:t,index:n,...void 0!==r?{instructionErrorContext:r}:null}:4615026===e?{code:Number(r),index:n}:{index:n},orderedErrorNames:s,rpcEnumError:r},e)}
23(...e.InstructionError):a({errorCodeBaseOffset:7050001,getErrorContext:(e,t,r)=>705e4===e?{errorName:t,...void 0!==r?{transactionErrorContext:r}:null}:7050030===e?{index:Number(r)}:7050031===e||7050035===e?{accountIndex:Number(r.account_index)}:void 0,orderedErrorNames:o,rpcEnumError:e},c)}function l(e){var t;let r;if("object"==typeof(t=e)&&null!==t&&"code"in t&&"message"in t&&("number"==typeof t.code||"bigint"==typeof t.code)&&"string"==typeof t.message){let{code:t,data:i,message:a}=e,s=Number(t);if(-32002===s){let{err:e,...t}=i,a=e?{cause:c(e)}:null;r=new n(-32002,{...t,...a})}else{let e;switch(s){case -32603:case -32602:case -32600:case -32601:case -32700:case -32012:case -32001:case -32004:case -32014:case -32010:case -32009:case -32007:case -32006:case -32015:e={__serverMessage:a};break;default:"object"!=typeof i||Array.isArray(i)||(e=i)}r=new n(s,e)}}else{let t="object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:"Malformed JSON-RPC error with no message attribute";r=new n(10,{error:e,message:t})}return i(r,l),r}e.s(["SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND",()=>323e4,"SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED",()=>3230004,"SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT",()=>3230003,"SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT",()=>3230002,"SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND",()=>0x1ecdbe1,"SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED",()=>2800009,"SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH",()=>28e5,"SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY",()=>2800003,"SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS",()=>2800011,"SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE",()=>2800008,"SOLANA_ERROR__ADDRESSES__MALFORMED_PDA",()=>2800004,"SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED",()=>2800006,"SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED",()=>2800007,"SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE",()=>2800005,"SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER",()=>2800010,"SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE",()=>2800001,"SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE",()=>4,"SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED",()=>1,"SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY",()=>8078e3,"SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS",()=>8078022,"SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL",()=>8078020,"SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH",()=>8078005,"SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH",()=>8078006,"SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH",()=>8078004,"SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE",()=>8078008,"SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY",()=>8078023,"SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH",()=>8078002,"SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH",()=>8078013,"SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH",()=>8078003,"SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH",()=>8078001,"SOLANA_ERROR__CODECS__INVALID_CONSTANT",()=>8078018,"SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT",()=>8078009,"SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT",()=>8078010,"SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT",()=>8078015,"SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS",()=>8078007,"SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE",()=>8078012,"SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE",()=>8078016,"SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE",()=>8078011,"SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE",()=>8078014,"SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES",()=>8078021,"SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE",()=>8078017,"SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED",()=>3611e3,"SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM",()=>4615026,"SOLANA_ERROR__INSTRUCTION_PLANS__EMPTY_INSTRUCTION_PLAN",()=>7618002,"SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN",()=>7618003,"SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN",()=>7618e3,"SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE",()=>7618001,"SOLANA_ERROR__INSTRUCTION_PLANS__NON_DIVISIBLE_TRANSACTION_PLANS_NOT_SUPPORTED",()=>7618004,"SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS",()=>4128e3,"SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA",()=>4128001,"SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH",()=>4128002,"SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH",()=>
235,"SOLANA_ERROR__INVALID_NONCE",()=>2,"SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED",()=>9900004,"SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_INSTRUCTION_PLAN_KIND",()=>9900005,"SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_TRANSACTION_PLAN_KIND",()=>9900006,"SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE",()=>9900001,"SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING",()=>99e5,"SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE",()=>9900003,"SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH",()=>3704e3,"SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH",()=>3704001,"SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH",()=>3704002,"SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY",()=>3704004,"SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE",()=>3704003,"SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE",()=>6,"SOLANA_ERROR__MALFORMED_BIGINT_STRING",()=>7,"SOLANA_ERROR__MALFORMED_NUMBER_STRING",()=>8,"SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND",()=>3,"SOLANA_ERROR__OFFCHAIN_MESSAGE__ADDRESSES_CANNOT_SIGN_OFFCHAIN_MESSAGE",()=>5607013,"SOLANA_ERROR__OFFCHAIN_MESSAGE__APPLICATION_DOMAIN_STRING_LENGTH_OUT_OF_RANGE",()=>5607002,"SOLANA_ERROR__OFFCHAIN_MESSAGE__ENVELOPE_SIGNERS_MISMATCH",()=>5607012,"SOLANA_ERROR__OFFCHAIN_MESSAGE__INVALID_APPLICATION_DOMAIN_BYTE_LENGTH",()=>5607003,"SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED",()=>5607e3,"SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH",()=>5607007,"SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_LENGTH_MISMATCH",()=>5607008,"SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY",()=>5607009,"SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO",()=>5607010,"SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO",()=>5607005,"SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH",()=>5607004,"SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE",()=>5607001,"SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED",()=>5607015,"SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE",()=>5607016,"SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING",()=>5607011,"SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE",()=>5607017,"SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION",()=>5607014,"SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED",()=>5607006,"SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN",()=>819e4,"SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED",()=>8190002,"SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED",()=>8190003,"SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT",()=>8190004,"SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID",()=>8190001,"SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD",()=>8100003,"SOLANA_ERROR__RPC__INTEGER_OVERFLOW",()=>81e5,"SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR",()=>8100002,"SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN",()=>8100001,"SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS",()=>5508e3,"SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER",()=>5508001,"SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER",()=>5508003,"SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER",()=>5508004,"SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER",()=>5508002,"SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER",()=>5508006,"SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER",()=>5508007,"SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER",()=>5508008,"SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER",()=>5508005,"SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS",()=>5508009,"SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING",()=>5508010,"SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY",()=>3610007,"SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED",()=>3610001,"SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT",()=>361e4,"SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENT
23ED",()=>3610002,"SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED",()=>3610003,"SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED",()=>3610004,"SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED",()=>3610005,"SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED",()=>3610006,"SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE",()=>9,"SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION",()=>5663015,"SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES",()=>5663016,"SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT",()=>5663020,"SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME",()=>5663002,"SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME",()=>5663003,"SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING",()=>5663005,"SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE",()=>5663006,"SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING",()=>5663008,"SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND",()=>5663007,"SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT",()=>5663018,"SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT",()=>5663019,"SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING",()=>5663012,"SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES",()=>5663e3,"SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE",()=>5663001,"SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH",()=>5663017,"SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE",()=>5663022,"SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING",()=>5663009,"SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED",()=>5663021,"SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE",()=>5663004,"SolanaError",()=>n,"getSolanaErrorFromJsonRpcError",()=>l,"getSolanaErrorFromTransactionError",()=>c,"isSolanaError",()=>r,"safeCaptureStackTrace",()=>i])},441960,e=>{"use strict";e.i(642108);var t,r=((t=r||{})[t.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",t[t.READONLY_SIGNER=2]="READONLY_SIGNER",t[t.WRITABLE=1]="WRITABLE",t[t.READONLY=0]="READONLY",t);function n(e){return e>=2}function i(e){return(1&e)!=0}function a(e,t){return e|t}function s(e){return 2|e}e.s(["AccountRole",()=>r,"isSignerRole",()=>n,"isWritableRole",()=>i,"mergeRoles",()=>a,"upgradeRoleToSigner",()=>s])},912440,587896,994999,503403,e=>{"use strict";var t,r,n,i=e.i(642108);function a(e,t,r){return s(0===r&&e.length===t.length?e:e.slice(r,r+t.length),t)}function s(e,t){return e.length===t.length&&e.every((e,r)=>e===t[r])}function o(e,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function c(e){return Object.freeze({...e,encode:t=>{let r=new Uint8Array(o(t,e));return e.write(t,r,0),r}})}function l(e){return Object.freeze({...e,decode:(t,r=0)=>e.read(t,r)[0]})}function d(e){return"fixedSize"in e&&"number"==typeof e.fixedSize}function _(e){if(!d(e))throw new i.SolanaError(i.SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH)}function f(e,t){if(d(e)!==d(t))throw new i.SolanaError(i.SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH);if(d(e)&&d(t)&&e.fixedSize!==t.fixedSize)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!d(e)&&!d(t)&&e.maxSize!==t.maxSize)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function u(e,t,r=0){if(t.length-r<=0)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY,{codecDescription:e})}function h(e,t,r,n=0){let a=r.length-n;if(a<t)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH,{bytesLength:a,codecDescription:e,expected:t})}function p(e,t,r){if(t<0||t>r)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE,{bytesLength:r,codecDescription:e,offset:t})}function y(e,t){let r=(r,n,i)=>{let a=e.encode(r);return i=t.write(a.length,n,i),n.set(a,i),i+a.length};if(d(t)&&d(e))return c({...e,fixedSize:t.fixedSize+e.fixedSize,write:r});let n=d(t)?t.fixedSize:t.maxSize??null,i=d(e)?e.fixedSize:e.maxSize??null,a=null!==n&&null!==i?n+i:null;return c({...e,...null!==a?{maxSize:a}:{}
23,getSizeFromValue:r=>{let n=o(r,e);return o(n,t)+n},write:r})}function E(e,t){let r=(r,n)=>{let[i,a]=t.read(r,n),s=Number(i);return((n=a)>0||r.length>s)&&(r=r.slice(n,n+s)),h("addDecoderSizePrefix",s,r),[e.decode(r),n+s]};if(d(t)&&d(e))return l({...e,fixedSize:t.fixedSize+e.fixedSize,read:r});let n=d(t)?t.fixedSize:t.maxSize??null,i=d(e)?e.fixedSize:e.maxSize??null,a=null!==n&&null!==i?n+i:null;return l({...e,...null!==a?{maxSize:a}:{},read:r})}function A(e,t,r){let n,i=e.byteOffset+(t??0),a=r??e.byteLength;return"u"<typeof SharedArrayBuffer?n=e.buffer:e.buffer instanceof SharedArrayBuffer?new Uint8Array(n=new ArrayBuffer(e.length)).set(new Uint8Array(e)):n=e.buffer,(0===i||i===-e.byteLength)&&a===e.byteLength?n:n.slice(i,i+a)}function g(e,t){return c({fixedSize:t,write:(r,n,i)=>{let a=e.encode(r),s=a.length>t?a.slice(0,t):a;return n.set(s,i),i+t}})}function S(e,t){return l({fixedSize:t,read:(r,n)=>{let i,a;h("fixCodecSize",t,r,n),(n>0||r.length>t)&&(r=r.slice(n,n+t)),d(e)&&(i=r,a=e.fixedSize,r=function(e,t){if(e.length>=t)return e;let r=new Uint8Array(t).fill(0);return r.set(e),r}(i.length<=a?i:i.slice(0,a),a));let[s]=e.read(r,0);return[s,n+t]}})}function R(e,t){return l({...e,read:(r,n)=>{let i=e=>I(e,r.length),a=t.preOffset?t.preOffset({bytes:r,preOffset:n,wrapBytes:i}):n;p("offsetDecoder",a,r.length);let[s,o]=e.read(r,a),c=t.postOffset?t.postOffset({bytes:r,newPreOffset:a,postOffset:o,preOffset:n,wrapBytes:i}):o;return p("offsetDecoder",c,r.length),[s,c]}})}function I(e,t){return 0===t?0:(e%t+t)%t}function m(e,t){var r,n;return r=function(e,t){if(d(e)){let r=t(e.fixedSize);if(r<0)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH,{bytesLength:r,codecDescription:"resizeEncoder"});return c({...e,fixedSize:r})}return c({...e,getSizeFromValue:r=>{let n=t(e.getSizeFromValue(r));if(n<0)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH,{bytesLength:n,codecDescription:"resizeEncoder"});return n}})}(e,e=>e+t),n={preOffset:({preOffset:e})=>e+t},c({...r,write:(e,t,i)=>{let a=e=>I(e,t.length),s=n.preOffset?n.preOffset({bytes:t,preOffset:i,wrapBytes:a}):i;p("offsetEncoder",s,t.length);let o=r.write(e,t,s),c=n.postOffset?n.postOffset({bytes:t,newPreOffset:s,postOffset:o,preOffset:i,wrapBytes:a}):o;return p("offsetEncoder",c,t.length),c}})}function O(e,t){return R(function(e,t){if(d(e)){let r=t(e.fixedSize);if(r<0)throw new i.SolanaError(i.SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH,{bytesLength:r,codecDescription:"resizeDecoder"});return l({...e,fixedSize:r})}return e}(e,e=>e+t),{postOffset:({postOffset:e})=>e+t})}function v(e,t){return c({...!d(e)?{...e,getSizeFromValue:r=>e.getSizeFromValue(t(r))}:e,write:(r,n,i)=>e.write(t(r),n,i)})}function T(e,t){return l({...e,read:(r,n)=>{let[i,a]=e.read(r,n);return[t(i,r,n),a]}})}function w(e,t){let[r,n]=e.split(RegExp(`((?!${t}).*)`));return[r,n]}function N(e,t){let r=BigInt(t.length),n=0n;for(let i of e)n*=r,n+=BigInt(t.indexOf(i));return n}e.s(["addDecoderSizePrefix",()=>E,"addEncoderSizePrefix",()=>y,"assertByteArrayHasEnoughBytesForCodec",()=>h,"assertByteArrayIsNotEmptyForCodec",()=>u,"assertIsFixedSize",()=>_,"bytesEqual",()=>s,"combineCodec",()=>f,"containsBytes",()=>a,"createDecoder",()=>l,"createEncoder",()=>c,"fixDecoderSize",()=>S,"fixEncoderSize",()=>g,"getEncodedSize",()=>o,"isFixedSize",()=>d,"offsetDecoder",()=>R,"padLeftEncoder",()=>m,"padRightDecoder",()=>O,"toArrayBuffer",()=>A,"transformDecoder",()=>T,"transformEncoder",()=>v],587896);var b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",C=()=>c({getSizeFromValue:e=>{let[t,r]=w(e,b[0]);if(!r)return e.length;let n=N(r,b);return t.length+Math.ceil(n.toString(16).length/2)},write(e,t,r){if(!function(e,t,r=t){if(!t.match(RegExp(`^[${e}]*$`)))throw new i.SolanaError(i.SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE,{alphabet:e,base:e.length,value:r})}(b,e),""===e)return r;let[n,a]=w(e,b[0]);if(!a)return t.set(new Uint8Array(n.length).fill(0),r),r+n.length;let s=N(a,b),o=[];for(;s>0n;)o.unshift(Number(s%256n)),s/=256n;let c=[...Array(n.length).fill(0),...o];return t.set(c,r),r+c.length}}),D=()=>l({read(e,t){let r=0===t?e:e.slice(t);if(0===r.length)return["",0];let n=r.findIndex(e=>0!==e);n=-1===n?r.length:n;let i=b[0].repeat(n);return n===r.length?[i,e.length]:[i+function(e,t){let r=BigInt(t.length),n=[];for(;e>0n;)n.unshift(t[Number(e%r)]),e/=r;return n.join("")}(r.slice(n).reduce((e,t)=>
23256n*e+BigInt(t),0n),b),e.length]}}),L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=()=>c({getSizeFromValue:e=>{try{return atob(e).length}catch{throw new i.SolanaError(i.SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE,{alphabet:L,base:64,value:e})}},write(e,t,r){try{let n=atob(e).split("").map(e=>e.charCodeAt(0));return t.set(n,r),n.length+r}catch{throw new i.SolanaError(i.SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE,{alphabet:L,base:64,value:e})}}}),P=()=>l({read:(e,t=0)=>[btoa(String.fromCharCode(...e.slice(t))),e.length]}),U=globalThis.TextDecoder,x=globalThis.TextEncoder,M=()=>{let e;return c({getSizeFromValue:t=>(e||=new x).encode(t).length,write:(t,r,n)=>{let i=(e||=new x).encode(t);return r.set(i,n),n+i.length}})},F=()=>{let e;return l({read:(t,r)=>[(e||=new U).decode(t.slice(r)).replace(/\u0000/g,""),t.length]})};function z(){if(void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.getRandomValues)throw new i.SolanaError(i.SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED)}function B(){if(!globalThis.isSecureContext)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT)}async function G(e){return(void 0===t&&(t=new Promise(r=>{e.generateKey("Ed25519",!1,["sign","verify"]).then(()=>{r(t=!0)}).catch(()=>{r(t=!1)})})),"boolean"==typeof t)?t:await t}function V(){if(B(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.digest)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED)}async function W(){if(B(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.generateKey)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED);if(!await G(globalThis.crypto.subtle))throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED)}function H(){if(B(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.exportKey)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED)}function j(){if(B(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.sign)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED)}function Y(){if(B(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.verify)throw new i.SolanaError(i.SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED)}function K(){return r||(r=C()),r}function q(e){if(e.length<32||e.length>44)return!1;let t=K();try{return 32===t.encode(e).byteLength}catch{return!1}}function $(e){if(e.length<32||e.length>44)throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE,{actualLength:e.length});let t=K().encode(e).byteLength;if(32!==t)throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH,{actualLength:t})}function X(e){return $(e),e}function J(){return v(g(K(),32),e=>X(e))}function Z(){return S((n||(n=D()),n),32)}function Q(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function ee(e){let t=e%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn;return t>=0n?t:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn+t}function et(e,t){let r=e;for(;t-- >0n;)r*=r,r%=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn;return r}e.s(["getBase58Decoder",()=>D,"getBase58Encoder",()=>C,"getBase64Decoder",()=>P,"getBase64Encoder",()=>k,"getUtf8Decoder",()=>F,"getUtf8Encoder",()=>M],994999),e.s(["assertDigestCapabilityIsAvailable",()=>V,"assertKeyExporterIsAvailable",()=>H,"assertKeyGenerationIsAvailable",()=>W,"assertPRNGIsAvailable",()=>z,"assertSigningCapabilityIsAvailable",()=>j,"assertVerificationCapabilityIsAvailable",()=>Y],503403);var er=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function en({programAddress:e,seeds:t}){let r;if(V(),t.length>16)throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED,{actual:t.length,maxSeeds:16});
23let n=t.reduce((e,t,n)=>{let a="string"==typeof t?(r||=new TextEncoder).encode(t):t;if(a.byteLength>32)throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED,{actual:a.byteLength,index:n,maxSeedLength:32});return e.push(...a),e},[]),a=f(J(),Z()),s=a.encode(e),o=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...s,...er])),c=new Uint8Array(o);if(function(e){var t,r,n;let i,a,s,o,c,l,d,_,f,u,h,p,y,E,A,g,S,R,I,m,O,v,T;return 32===e.byteLength&&(i=e.reduce((e,t,r)=>{let n;return`${1===(n=(31===r?-129&t:t).toString(16)).length?`0${n}`:n}${e}`},""),t=BigInt(`0x${i}`),r=e[31],a=ee(t*t),s=ee(a-1n),o=ee(0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n*a+1n),c=ee(o*o*o),d=et(l=(n=s*ee(c*c*o))*n%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn*n%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,2n)*l%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,_=et(d,1n)*n%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,f=et(_,5n)*_%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,u=et(f,10n)*f%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,h=et(u,20n)*u%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,p=et(h,40n)*h%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,y=et(p,80n)*p%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,E=et(y,80n)*p%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,A=et(E,10n)*f%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,g=ee(s*c*(et(A,2n)*n%0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn)),S=ee(o*g*g),R=g,I=ee(0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n*g),m=S===s,O=S===ee(-s),v=S===ee(-(0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n*s)),null!==(m&&(g=R),(O||v)&&(g=I),(1n&ee(g))===1n&&(g=ee(-g)),T=m||O?g:null)&&(0n!==T||(128&r)==0))}(c))throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE);return a.decode(c)}async function ei({programAddress:e,seeds:t}){let r=255;for(;r>0;)try{return[await en({programAddress:e,seeds:[...t,new Uint8Array([r])]}),r]}catch(e){if((0,i.isSolanaError)(e,i.SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE))r--;else throw e}throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED)}async function ea(e){if(H(),"public"!==e.type||"Ed25519"!==e.algorithm.name)throw new i.SolanaError(i.SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY);let t=await crypto.subtle.exportKey("raw",e);return Z().decode(new Uint8Array(t))}async function es(e){let t=J().encode(e);return await crypto.subtle.importKey("raw",t,{name:"Ed25519"},!0,["verify"])}e.s(["address",()=>X,"assertIsAddress",()=>$,"getAddressComparator",()=>Q,"getAddressDecoder",()=>Z,"getAddressEncoder",()=>J,"getAddressFromPublicKey",()=>ea,"getProgramDerivedAddress",()=>ei,"getPublicKeyFromAddress",()=>es,"isAddress",()=>q],912440)},810657,e=>{"use strict";var t=e.i(503403),r=e.i(642108),n=e.i(587896);e.i(994999);var i=Object.freeze({name:"Ed25519"});async function a(e,t=!1){let n=e.byteLength;if(32!==n)throw new r.SolanaError(r.SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH,{actualLength:n});let s=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e]);return await crypto.subtle.importKey("pkcs8",s,i,t,["sign"])}async function s(e,n=!1){if((0,t.assertKeyExporterIsAvailable)(),!1===e.extractable)throw new r.SolanaError(r.SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY,{key:e});let i=await crypto.subtle.exportKey("jwk",e);return await crypto.subtle.importKey("jwk",{crv:"Ed25519",ext:n,key_ops:["verify"],kty:"OKP",x:i.x},"Ed25519",n,["verify"])}async function o(e,r){return(0,t.assertSigningCapabilityIsAvailable)(),new Uint8Array(await crypto.subtle.sign(i,e,(0,n.toArrayBuffer)(r)))}async function c(e,r,a){return(0,t.assertVerificationCapabilityIsAvailable)(),await crypto.subtle.verify(i,e,(0,n.toArrayBuffer)(r),(0,n.toArrayBuffer)(a))}async function l(){return await (0,t.assertKeyGenerationIsAvailable)(),await crypto.subtle.generateKey(i,!1,["sign","verify"])}async function d(e,n=!1){if((0,t.assertPRNGIsAvailable)(),64!==e.byteLength)throw new r.SolanaError(r.SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH,{byteLength:e.byteLength});let[s,l]=await Promise.all([crypto.subtle.importKey("raw",e.slice(32),i,!0,["verify"]),a(e.slice(0,32),n)]),_=new Uint8Array(32);crypto.getRandomValues(_);let f=await o(l,_);if(!await c(s,f,_))throw new r.SolanaError(r.SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY);return{privateKey:l,publicKey:s}}async function _(e,t=!1){let r=a(e,t),[n,i]=await Promise.all([(t?r:a(e,!0)).then(async e=>await s(e,!0)),r]);return{privateKey:i,publicKey:n}}e.s(["createKeyPairFromBytes",()=>d,"createKeyPairFromPrivateKeyBytes",()=>_,"generateKeyPair",()=>l,"signBytes",()=>o,"verifySignature",()=>c])},631157,38340,850631,e=>{"use strict";var t,r,n,i=e.i(587896),a=e.i(642108);function s(e,t,r,n){if(n<t||n>r)throw new a.SolanaError(a.SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE,{codecDescription:e,max:r,min:t,value:n})}var o=((t=o||{})[t.Little=0]="Little",t[t.Big=1]="Big",t);function c(e){return e?.endian!==1}function l(e){return(0,i.createEncoder)({fixedSize:e.size,write(t,r,n){e.range&&s(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,c(e.config)),r.set(new Uint8Array(i),n),n+e.size}})}function d(e){return(0,i.createDecoder)({fixedSize:e.size,read(t,r=0){(0,i.assertByteArrayIsNotEmptyForCo
23dec)(e.name,t,r),(0,i.assertByteArrayHasEnoughBytesForCodec)(e.name,e.size,t,r);let n=new DataView((0,i.toArrayBuffer)(t,r,e.size));return[e.get(n,c(e.config)),r+e.size]}})}var _=(e={})=>l({config:e,name:"f64",set:(e,t,r)=>e.setFloat64(0,Number(t),r),size:8}),f=(e={})=>d({config:e,get:(e,t)=>e.getFloat64(0,t),name:"f64",size:8}),u=(e={})=>l({config:e,name:"i16",range:[-Number("0x7fff")-1,Number("0x7fff")],set:(e,t,r)=>e.setInt16(0,Number(t),r),size:2}),h=(e={})=>d({config:e,get:(e,t)=>e.getInt16(0,t),name:"i16",size:2}),p=(e={})=>l({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(e,t,r)=>e.setBigInt64(0,BigInt(t),r),size:8}),y=(e={})=>d({config:e,get:(e,t)=>e.getBigInt64(0,t),name:"i64",size:8}),E=()=>l({name:"i8",range:[-Number("0x7f")-1,Number("0x7f")],set:(e,t)=>e.setInt8(0,Number(t)),size:1}),A=()=>d({get:e=>e.getInt8(0),name:"i8",size:1}),g=()=>(0,i.createEncoder)({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,r)=>{s("shortU16",0,65535,e);let n=[0];for(let t=0;;t+=1){let r=Number(e)>>7*t;if(0===r)break;let i=127&r;n[t]=i,t>0&&(n[t-1]|=128)}return t.set(n,r),r+n.length}}),S=()=>(0,i.createDecoder)({maxSize:3,read:(e,t)=>{let r=0,n=0;for(;++n;){let i=n-1,a=e[t+i];if(r|=(127&a)<<7*i,(128&a)==0)break}return[r,t+n]}}),R=(e={})=>l({config:e,name:"u128",range:[0n,BigInt("0xffffffffffffffffffffffffffffffff")],set:(e,t,r)=>{let n=8*!!r,i=8*!r;e.setBigUint64(n,BigInt(t)>>64n,r),e.setBigUint64(i,0xffffffffffffffffn&BigInt(t),r)},size:16}),I=(e={})=>d({config:e,get:(e,t)=>{let r=8*!!t,n=8*!t;return(e.getBigUint64(r,t)<<64n)+e.getBigUint64(n,t)},name:"u128",size:16}),m=(e={})=>l({config:e,name:"u16",range:[0,Number("0xffff")],set:(e,t,r)=>e.setUint16(0,Number(t),r),size:2}),O=(e={})=>d({config:e,get:(e,t)=>e.getUint16(0,t),name:"u16",size:2}),v=(e={})=>l({config:e,name:"u32",range:[0,Number("0xffffffff")],set:(e,t,r)=>e.setUint32(0,Number(t),r),size:4}),T=(e={})=>d({config:e,get:(e,t)=>e.getUint32(0,t),name:"u32",size:4}),w=(e={})=>l({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8}),N=(e={})=>d({config:e,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),b=(e={})=>(0,i.combineCodec)(w(e),N(e)),C=()=>l({name:"u8",range:[0,Number("0xff")],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),D=()=>d({get:e=>e.getUint8(0),name:"u8",size:1});function L(e,t,r){if(t!==r)throw new a.SolanaError(a.SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS,{actual:r,codecDescription:e,expected:t})}function k(e){return e.reduce((e,t)=>null===e||null===t?null:e+t,0)}function P(e){return(0,i.isFixedSize)(e)?e.fixedSize:null}function U(e){return(0,i.isFixedSize)(e)?e.fixedSize:e.maxSize??null}function x(e,t={}){let r=t.size??v(),n=z(r,P(e)),a=z(r,U(e))??void 0;return(0,i.createEncoder)({...null!==n?{fixedSize:n}:{getSizeFromValue:t=>("object"==typeof r?(0,i.getEncodedSize)(t.length,r):0)+[...t].reduce((t,r)=>t+(0,i.getEncodedSize)(r,e),0),maxSize:a},write:(t,n,i)=>("number"==typeof r&&L("array",r,t.length),"object"==typeof r&&(i=r.write(t.length,n,i)),t.forEach(t=>{i=e.write(t,n,i)}),i)})}function M(e,t={}){let r=t.size??T(),n=z(r,P(e)),a=z(r,U(e))??void 0;return(0,i.createDecoder)({...null!==n?{fixedSize:n}:{maxSize:a},read:(t,n)=>{let i=[];if("object"==typeof r&&0===t.slice(n).length)return[i,n];if("remainder"===r){for(;n<t.length;){let[r,a]=e.read(t,n);n=a,i.push(r)}return[i,n]}let[a,s]="number"==typeof r?[r,n]:r.read(t,n);n=s;for(let r=0;r<a;r+=1){let[r,a]=e.read(t,n);n=a,i.push(r)}return[i,n]}})}function F(e,t={}){return(0,i.combineCodec)(x(e,t),M(e,t))}function z(e,t){return"number"!=typeof e?null:0===e?0:null===t?null:t*e}function B(e={}){return(0,i.transformEncoder)(e.size??C(),e=>+!!e)}function G(e={}){return(0,i.transformDecoder)(e.size??D(),e=>1===Number(e))}function V(){return(0,i.createEncoder)({getSizeFromValue:e=>e.length,write:(e,t,r)=>(t.set(e,r),r+e.length)})}function W(){return(0,i.createDecoder)({read:(e,t)=>{let r=e.slice(t);return[r,t+r.length]}})}function H(e){return(0,i.createEncoder)({fixedSize:e.length,write:(t,r,n)=>(r.set(e,n),n+e.length)})}function j(e){return(0,i.createDecoder)({fixedSize:e.length,read:(t,r)=>{let n=(0,i.createDecoder)({read:(e,t)=>[e.slice(t).reduce((e,t)=>
23e+t.toString(16).padStart(2,"0"),""),e.length]});if(!(0,i.containsBytes)(t,e,r))throw new a.SolanaError(a.SOLANA_ERROR__CODECS__INVALID_CONSTANT,{constant:e,data:t,hexConstant:n.decode(e),hexData:n.decode(t),offset:r});return[void 0,r+e.length]}})}function Y(e){let t=k(e.map(P)),r=k(e.map(U))??void 0;return(0,i.createEncoder)({...null===t?{getSizeFromValue:t=>e.map((e,r)=>(0,i.getEncodedSize)(t[r],e)).reduce((e,t)=>e+t,0),maxSize:r}:{fixedSize:t},write:(t,r,n)=>(L("tuple",e.length,t.length),e.forEach((e,i)=>{n=e.write(t[i],r,n)}),n)})}function K(e){let t=k(e.map(P)),r=k(e.map(U))??void 0;return(0,i.createDecoder)({...null===t?{maxSize:r}:{fixedSize:t},read:(t,r)=>{let n=[];return e.forEach(e=>{let[i,a]=e.read(t,r);n.push(i),r=a}),[n,r]}})}function q(e,t){let r=J(e),n=(r,n,i)=>{let a=t(r);return X(e,a),e[a].write(r,n,i)};if(null!==r)return(0,i.createEncoder)({fixedSize:r,write:n});let a=Z(e);return(0,i.createEncoder)({...null!==a?{maxSize:a}:{},getSizeFromValue:r=>{let n=t(r);return X(e,n),(0,i.getEncodedSize)(r,e[n])},write:n})}function $(e,t){let r=J(e),n=(r,n)=>{let i=t(r,n);return X(e,i),e[i].read(r,n)};if(null!==r)return(0,i.createDecoder)({fixedSize:r,read:n});let a=Z(e);return(0,i.createDecoder)({...null!==a?{maxSize:a}:{},read:n})}function X(e,t){if(void 0===e[t])throw new a.SolanaError(a.SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE,{maxRange:e.length-1,minRange:0,variant:t})}function J(e){if(0===e.length)return 0;if(!(0,i.isFixedSize)(e[0]))return null;let t=e[0].fixedSize;return e.every(e=>(0,i.isFixedSize)(e)&&e.fixedSize===t)?t:null}function Z(e){return e.map(e=>U(e)).reduce((e,t)=>null===e||null===t?null:Math.max(e,t),0)}function Q(e,t={}){let r=t.discriminator??"__kind",n=t.size??C();return q(e.map(([,e],t)=>(0,i.transformEncoder)(Y([n,e]),e=>[t,e])),t=>(function(e,t){let r=e.findIndex(([e])=>t===e);if(r<0)throw new a.SolanaError(a.SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT,{value:t,variants:e.map(([e])=>e)});return r})(e,t[r]))}function ee(e,t={}){let r=t.discriminator??"__kind",n=t.size??D();return $(e.map(([e,t])=>(0,i.transformDecoder)(K([n,t]),([,t])=>({[r]:e,...t}))),(e,t)=>Number(n.read(e,t)[0]))}function et(e){let t=[...new Set(Object.values(e).filter(e=>"number"==typeof e))].sort(),r=Object.fromEntries(Object.entries(e).slice(t.length)),n=Object.keys(r),i=Object.values(r),a=[...new Set([...n,...i.filter(e=>"string"==typeof e)])];return{enumKeys:n,enumRecord:r,enumValues:i,numericalValues:t,stringValues:a}}function er(e,t){let r=e.length;for(;r--;)if(t(e[r],r,e))return r;return -1}function en(e){if(0===e.length)return"";let t=[e[0],e[0]],r=[];for(let n=1;n<e.length;n++){let i=e[n];t[1]+1===i?t[1]=i:(r.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),t=[i,i])}return r.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),r.join(", ")}function ei(e,t={}){let r=t.size??C(),n=t.useValuesAsDiscriminators??!1,{enumKeys:s,enumValues:o,numericalValues:c,stringValues:l}=et(e);if(n&&o.some(e=>"string"==typeof e))throw new a.SolanaError(a.SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS,{stringValues:o.filter(e=>"string"==typeof e)});return(0,i.transformEncoder)(r,e=>
23{let t=function({enumKeys:e,enumValues:t,variant:r}){let n=er(t,e=>e===r);return n>=0?n:e.findIndex(e=>e===r)}({enumKeys:s,enumValues:o,variant:e});if(t<0)throw new a.SolanaError(a.SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT,{formattedNumericalValues:en(c),numericalValues:c,stringValues:l,variant:e});return n?o[t]:t})}function ea(e,t={}){let r=t.size??D(),n=t.useValuesAsDiscriminators??!1,{enumKeys:s,enumValues:o,numericalValues:c}=et(e);if(n&&o.some(e=>"string"==typeof e))throw new a.SolanaError(a.SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS,{stringValues:o.filter(e=>"string"==typeof e)});return(0,i.transformDecoder)(r,e=>{let t=Number(e),r=function({discriminator:e,enumKeys:t,enumValues:r,useValuesAsDiscriminators:n}){return n?er(r,t=>t===e):e>=0&&e<t.length?e:-1}({discriminator:t,enumKeys:s,enumValues:o,useValuesAsDiscriminators:n});if(r<0){let e=n?c:[...Array(s.length).keys()];throw new a.SolanaError(a.SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE,{discriminator:t,formattedValidDiscriminators:en(e),validDiscriminators:e})}return o[r]})}function es(e,t){return(0,i.transformEncoder)(Y([...t,e]),e=>[...t.map(()=>void 0),e])}function eo(e,t){return(0,i.transformDecoder)(K([...t,e]),e=>e[e.length-1])}function ec(e,t,r={}){return(0,i.transformEncoder)(x(Y([e,t]),r),e=>[...e.entries()])}function el(e,t,r={}){return(0,i.transformDecoder)(M(K([e,t]),r),e=>new Map(e))}function ed(){return(0,i.createEncoder)({fixedSize:0,write:(e,t,r)=>r})}function e_(){return(0,i.createDecoder)({fixedSize:0,read:(e,t)=>[void 0,t]})}function ef(e){let t=e.map(([,e])=>e),r=k(t.map(P)),n=k(t.map(U))??void 0;return(0,i.createEncoder)({...null===r?{getSizeFromValue:t=>e.map(([e,r])=>(0,i.getEncodedSize)(t[e],r)).reduce((e,t)=>e+t,0),maxSize:n}:{fixedSize:r},write:(t,r,n)=>(e.forEach(([e,i])=>{n=i.write(t[e],r,n)}),n)})}function eu(e){let t=e.map(([,e])=>e),r=k(t.map(P)),n=k(t.map(U))??void 0;return(0,i.createDecoder)({...null===r?{maxSize:n}:{fixedSize:r},read:(t,r)=>{let n={};return e.forEach(([e,i])=>{let[a,s]=i.read(t,r);r=s,n[e]=a}),[n,r]}})}e.s(["getF64Decoder",()=>f,"getF64Encoder",()=>_,"getI16Decoder",()=>h,"getI16Encoder",()=>u,"getI64Decoder",()=>y,"getI64Encoder",()=>p,"getI8Decoder",()=>A,"getI8Encoder",()=>E,"getShortU16Decoder",()=>S,"getShortU16Encoder",()=>g,"getU128Decoder",()=>I,"getU128Encoder",()=>R,"getU16Decoder",()=>O,"getU16Encoder",()=>m,"getU32Decoder",()=>T,"getU32Encoder",()=>v,"getU64Codec",()=>b,"getU64Decoder",()=>N,"getU64Encoder",()=>w,"getU8Decoder",()=>D,"getU8Encoder",()=>C],38340),e.s(["getArrayCodec",()=>F,"getArrayDecoder",()=>M,"getArrayEncoder",()=>x,"getBooleanDecoder",()=>G,"getBooleanEncoder",()=>B,"getBytesDecoder",()=>W,"getBytesEncoder",()=>V,"getConstantDecoder",()=>j,"getConstantEncoder",()=>H,"getDiscriminatedUnionDecoder",()=>ee,"getDiscriminatedUnionEncoder",()=>Q,"getEnumDecoder",()=>ea,"getEnumEncoder",()=>ei,"getHiddenPrefixDecoder",()=>eo,"getHiddenPrefixEncoder",()=>es,"getMapDecoder",()=>el,"getMapEncoder",()=>ec,"getStructDecoder",()=>eu,"getStructEncoder",()=>ef,"getTupleDecoder",()=>K,"getTupleEncoder",()=>Y,"getUnionDecoder",()=>$,"getUnionEncoder",()=>q,"getUnitDecoder",()=>e_,"getUnitEncoder",()=>ed],631157);var eh=e.i(912440);function ep(e){return(0,eh.isAddress)(e)}function ey(){let e=(0,eh.getAddressEncoder)();return(0,i.createEncoder)({fixedSize:32,write:(t,r,n)=>{try{(0,eh.assertIsAddress)(t)}catch(e){if((0,a.isSolanaError)(e,a.SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE))throw new a.SolanaError(a.SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE,e.context);if((0,a.isSolanaError)(e,a.SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH))throw new a.SolanaError(a.SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH,e.context);throw e}return e.write(t,r,n)}})}function eE(){return(0,eh.getAddressDecoder)()}function eA(e){return e}function eg(e){return e}function eS(e){switch(e){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new a.SolanaError(a.SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE,{unexpectedValue:e})}}function eR(e,t){return e===t?0:eS(e)<eS(t)?-1:1}function eI(){return r||(r=w()),r}function em(){var e;return e=(n||(n=N()),n),(0,i.transformDecoder)(e,e=>(function(e){if(e<0||e>0xffffffffffffffffn)throw new a.SolanaError(a.SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE);return e})("bigint"==typeof e?e:BigInt(e)))}e.s(["commitmentComparator",()=>eR,"devnet",()=>eg,"getBlockhashDecoder",()=>eE,"getBlockhashEncoder",()=>ey,"getDefaultLamportsDecoder",()=>em,"getDefaultLamportsEncoder",()=>eI,"isBlockhash",()=>ep,"mainnet",()=>eA],850631)},421720,631985,e=>{"use strict";var t,r,n,i,a,s,o=e.i(642108),c=e.i(850631),l=e.i(912440),d=e.i(587896),_=e.i(631157),f=e.i(38340),u=e.i(441960);function h(e,...t){return t.reduce((e,t)=>
23t(e),e)}function p(e){return"lifetimeConstraint"in e&&"string"==typeof e.lifetimeConstraint.blockhash&&"bigint"==typeof e.lifetimeConstraint.lastValidBlockHeight&&(0,c.isBlockhash)(e.lifetimeConstraint.blockhash)}function y(e,t){return"lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}function E(e,t){let[r,n]=e.split(RegExp(`((?!${t}).*)`));return[r,n]}function A(e,t){let r=BigInt(t.length),n=0n;for(let i of e)n*=r,n+=BigInt(t.indexOf(i));return n}e.s(["pipe",()=>h],631985);var g="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function S(){return n||(n=(0,f.getU8Encoder)()),n}function R(){return i||(i=(0,f.getU8Decoder)()),i}function I(){return(0,d.createDecoder)({maxSize:1,read:(e,t)=>{let r=e[t];if((128&r)==0)return["legacy",t];{let e=128^r;if(e>0)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED,{unsupportedVersion:e});return[e,t+1]}}})}function m(){return(0,_.getStructEncoder)(v())}function O(){return(0,d.transformEncoder)((0,_.getStructEncoder)([...v(),["addressTableLookups",(0,_.getArrayEncoder)(function(){if(!t){let e=(0,_.getArrayEncoder)((0,f.getU8Encoder)(),{size:(0,f.getShortU16Encoder)()});t=(0,_.getStructEncoder)([["lookupTableAddress",(0,l.getAddressEncoder)()],["writableIndexes",e],["readonlyIndexes",e]])}return t}(),{size:(0,f.getShortU16Encoder)()})]]),e=>"legacy"===e.version?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function v(){let e=(0,_.getUnionEncoder)([(0,_.getConstantEncoder)(new Uint8Array(32)),(0,d.fixEncoderSize)((0,d.createEncoder)({getSizeFromValue:e=>{let[t,r]=E(e,g[0]);if(!r)return e.length;let n=A(r,g);return t.length+Math.ceil(n.toString(16).length/2)},write(e,t,r){if(!function(e,t,r=t){if(!t.match(RegExp(`^[${e}]*$`)))throw new o.SolanaError(o.SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE,{alphabet:e,base:e.length,value:r})}(g,e),""===e)return r;let[n,i]=E(e,g[0]);if(!i)return t.set(new Uint8Array(n.length).fill(0),r),r+n.length;let a=A(i,g),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(n.length).fill(0),...s];return t.set(c,r),r+c.length}}),32)],e=>+(void 0!==e));return[["version",(0,d.createEncoder)({getSizeFromValue:e=>+("legacy"!==e),maxSize:1,write:(e,t,r)=>{if("legacy"===e)return r;if(e<0||e>127)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE,{actualVersion:e});if(e>0)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED,{unsupportedVersion:e});return t.set([128|e],r),r+1}})],["header",(0,_.getStructEncoder)([["numSignerAccounts",S()],["numReadonlySignerAccounts",S()],["numReadonlyNonSignerAccounts",S()]])],["staticAccounts",(0,_.getArrayEncoder)((0,l.getAddressEncoder)(),{size:(0,f.getShortU16Encoder)()})],["lifetimeToken",e],["instructions",(0,_.getArrayEncoder)((a||(a=(0,d.transformEncoder)((0,_.getStructEncoder)([["programAddressIndex",(0,f.getU8Encoder)()],["accountIndices",(0,_.getArrayEncoder)((0,f.getU8Encoder)(),{size:(0,f.getShortU16Encoder)()})],["data",(0,d.addEncoderSizePrefix)((0,_.getBytesEncoder)(),(0,f.getShortU16Encoder)())]]),e=>void 0!==e.accountIndices&&void 0!==e.data?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),a),{size:(0,f.getShortU16Encoder)()})]]}function T(){return(0,d.createEncoder)({getSizeFromValue:e=>"legacy"===e.version?m().getSizeFromValue(e):O().getSizeFromValue(e),write:(e,t,r)=>"legacy"===e.version?m().write(e,t,r):O().write(e,t,r)})}function w(){return(0,d.transformDecoder)((0,_.getStructDecoder)([["version",I()],["header",(0,_.getStructDecoder)([["numSignerAccounts",R()],["numReadonlySignerAccounts",R()],["numReadonlyNonSignerAccounts",R()]])],["staticAccounts",(0,_.getArrayDecoder)((0,l.getAddressDecoder)(),{size:(0,f.getShortU16Decoder)()})],["lifetimeToken",(0,d.fixDecoderSize)((0,d.createDecoder)({read(e,t){let r=0===t?e:e.slice(t);if(0===r.length)return["",0];let n=r.findIndex(e=>0!==e);n=-1===n?r.length:n;let i=g[0].repeat(n);return n===r.length?[i,e.length]:[i+function(e,t){let r=BigInt(t.length),n=[];for(;e>0n;)n.unshift(t[Number(e%r)]),e/=r;return n.join("")}(r.slice(n).reduce((e,t)=>
23256n*e+BigInt(t),0n),g),e.length]}}),32)],["instructions",(0,_.getArrayDecoder)((s||(s=(0,d.transformDecoder)((0,_.getStructDecoder)([["programAddressIndex",(0,f.getU8Decoder)()],["accountIndices",(0,_.getArrayDecoder)((0,f.getU8Decoder)(),{size:(0,f.getShortU16Decoder)()})],["data",(0,d.addDecoderSizePrefix)((0,_.getBytesDecoder)(),(0,f.getShortU16Decoder)())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:r,...n}=e;return{...n,...t.length?{accountIndices:t}:null,...r.byteLength?{data:r}:null}})),s),{size:(0,f.getShortU16Decoder)()})],["addressTableLookups",(0,_.getArrayDecoder)(function(){if(!r){let e=(0,_.getArrayDecoder)((0,f.getU8Decoder)(),{size:(0,f.getShortU16Decoder)()});r=(0,_.getStructDecoder)([["lookupTableAddress",(0,l.getAddressDecoder)()],["writableIndexes",e],["readonlyIndexes",e]])}return r}(),{size:(0,f.getShortU16Decoder)()})]]),({addressTableLookups:e,...t})=>"legacy"!==t.version&&e?.length?{...t,addressTableLookups:e}:t)}function N(e,t,r){e[t]=r(e[t]??{role:u.AccountRole.READONLY})}var b=Symbol("AddressMapTypeProperty");function C(e){var t;let r,n,i,a=Object.entries(function(e,t){let r={[e]:{[b]:0,role:u.AccountRole.WRITABLE_SIGNER}},n=new Set;for(let e of t){let t;if(N(r,e.programAddress,t=>{if(n.add(e.programAddress),b in t){if((0,u.isWritableRole)(t.role))if(0===t[b])throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES,{programAddress:e.programAddress});else throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,{programAddress:e.programAddress});if(2===t[b])return t}return{[b]:2,role:u.AccountRole.READONLY}}),e.accounts)for(let i of e.accounts)N(r,i.address,e=>{let{address:r,...a}=i;if(b in e)switch(e[b]){case 0:return e;case 1:{let r=(0,u.mergeRoles)(e.role,a.role);if("lookupTableAddress"in a){if(e.lookupTableAddress!==a.lookupTableAddress&&0>(t||=(0,l.getAddressComparator)())(a.lookupTableAddress,e.lookupTableAddress))return{[b]:1,...a,role:r}}else if((0,u.isSignerRole)(a.role))return{[b]:2,role:r};if(e.role!==r)return{...e,role:r};return e}case 2:{let t=(0,u.mergeRoles)(e.role,a.role);if(n.has(i.address)){if((0,u.isWritableRole)(a.role))throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,{programAddress:i.address});if(e.role!==t)return{...e,role:t};return e}if("lookupTableAddress"in a&&!(0,u.isSignerRole)(e.role))return{...a,[b]:1,role:t};if(e.role!==t)return{...e,role:t};else return e}}return"lookupTableAddress"in a?{...a,[b]:1}:{...a,[b]:2}})}return r}(e.feePayer.address,e.instructions)).sort(([e,t],[n,i])=>{if(t[b]!==i[b]){if(0===t[b])return -1;else if(0===i[b])return 1;else if(2===t[b])return -1;else if(2===i[b])return 1}let a=(0,u.isSignerRole)(t.role);if(a!==(0,u.isSignerRole)(i.role))return a?-1:1;let s=(0,u.isWritableRole)(t.role);return s!==(0,u.isWritableRole)(i.role)?s?-1:1:(r||=(0,l.getAddressComparator)(),1===t[b]&&1===i[b]&&t.lookupTableAddress!==i.lookupTableAddress)?r(t.lookupTableAddress,i.lookupTableAddress):r(e,n)}).map(([e,t])=>({address:e,...t})),s=e.lifetimeConstraint;return{..."legacy"!==e.version?{addressTableLookups:function(e){let t={};for(let r of e){if(!("lookupTableAddress"in r))continue;let e=t[r.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};r.role===u.AccountRole.WRITABLE?e.writableIndexes.push(r.addressIndex):e.readonlyIndexes.push(r.addressIndex)}return Object.keys(t).sort((0,l.getAddressComparator)()).map(e=>({lookupTableAddress:e,...t[e]}))}(a)}:null,...s?{lifetimeToken:"nonce"in s?s.nonce:s.blockhash}:null,header:function(e){let t=0,r=0,n=0;for(let i of e){if("lookupTableAddress"in i)break;let e=(0,u.isWritableRole)(i.role);(0,u.isSignerRole)(i.role)?(n++,!e&&r++):!e&&t++}return{numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:r,numSignerAccounts:n}}(a),instructions:(t=e.instructions,n=function(e){let t={};for(let[r,n]of e.entries())t[n.address]=r;return t}(a),t.map(({accounts:e,data:t,programAddress:r})=>({programAddressIndex:n[r],...e?{accountIndices:e.map(({address:e})=>n[e])}:null,...t?{data:t}:null}))),staticAccounts:(-1===(i=a.findIndex(e=>"lookupTableAddress"in e))?a:a.slice(0,i)).map(({address:e})=>e),version:e.version}}function D(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var L="SysvarRecentB1ockHashes11111111111111111111",k="11111111111111111111111111111111";function P(e,t){return{accounts:[{address:e,role:u.AccountRole.WRITABLE},{address:L,role:u.AccountRole.READONLY},{address:t,role:u.AccountRole.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:k}}function U(e){var t;return e.programAddress===k&&null!=e.data&&4===(t=e.data).byteLength&&4===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&e.accounts?.length===3&&null!=e.accounts[0].address&&e.accounts[0].role===u.AccountRole.WRITABLE&&e.accounts[1].address===L&&e.accounts[1].role===u.AccountRole.READONLY&&null!=e.accounts[2].address&&(0,u.isSignerRole)(e.accounts[2].role)}function x(e){return"lifetimeConstraint"in e&&"string"==typeof e.lifetimeConstraint.nonce&&null!=e.instructions[0]&&U(e.instructions[0])}function M(e,t){var r;if("feePayer"in t&&e===t.feePayer?.address&&(r=t.feePayer)&&"address"in r&&"string"==typeof r.address&&1===Object.keys(r).length)return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function F(e,t){return z([e],t)}function z(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function B(e,t){var r,n;return r=[e],Object.freeze({...n=t,instructions:Object.freeze([...r,...n.instructions])})}function G(e,t){let r=e.staticAccounts[0];if(!r)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING);let n=[...function(e){let{header:t}=e,r=t.numSignerAccounts-t.numReadonlySignerAccounts,n=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,i=[],a=0;for(let t=0;t<r;t++)i.push({address:e.staticAccounts[a],role:u.AccountRole.WRITABLE_SIGNER}),a++;for(let r=0;r<t.numReadonlySignerAccounts;r++)i.push({address:e.staticAccounts[a],role:u.AccountRole.READONLY_SIGNER}),a++;for(let t=0;t<n;t++)i.push({address:e.staticAccounts[a],role:u.AccountRole.WRITABLE}),a++;for(let r=0;r<t.numReadonlyNonSignerAccounts;r++)i.push({address:e.staticAccounts[a],role:u.AccountRole.READONLY}),a++;return i}(e),..."addressTableLookups"in e&&void 0!==e.addressTableLookups&&e.addressTableLookups.length>0?function(e,t){let r=e.map(e=>e.lookupTableAddress).filter(e=>void 0===t[e]);if(r.length>0)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING,{lookupTableAddresses:r});let n=[],i=[];for(let r of e){let e=t[r.lookupTableAddress],a=r.readonlyIndexes,s=r.writableIndexes,c=Math.max(...a,...s);if(c>=e.length)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE,{highestKnownIndex:e.length-1,highestRequestedIndex:c,lookupTableAddress:r.lookupTableAddress});let l=a.map(t=>({address:e[t],addressIndex:t,lookupTableAddress:r.lookupTableAddress,role:u.AccountRole.READONLY}));n.push(...l);let d=s.map(t=>({address:e[t],addressIndex:t,lookupTableAddress:r.lookupTableAddress,role:u.AccountRole.WRITABLE}));i.push(...d)}return[...i,...n]}(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[]],i=e.instructions.map(e=>(function(e,t){let r=t[e.programAddressIndex]?.address;if(!r)throw new o.SolanaError(o.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND,{index:e.programAddressIndex});let n=e.accountIndices?.map(e=>t[e]),{data:i}=e;return Object.freeze({programAddress:r,...n&&n.length?{accounts:Object.freeze(n)}:{},...i&&i.length?{data:i}:{}})})(e,n)),a=i[0],s=function(e,t,r){if(!t||!U(t))return{blockhash:e,lastValidBlockHeight:r??2n**64n-1n};{let r=t.accounts[0].address;(0,l.assertIsAddress)(r);let n=t.accounts[2].address;return(0,l.assertIsAddress)(n),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n}}}(e.lifetimeToken,a,t?.lastValidBlockHeight);return h(D({version:e.version}),e=>M(r,e),e=>i.reduce((e,t)=>
23F(t,e),e),e=>"blockhash"in s?y(s,e):function({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:r},n){let i,a=n.instructions[0];if(a&&U(a))if(a.accounts[0].address===t&&a.accounts[2].address===r)if(x(n)&&n.lifetimeConstraint.nonce===e)return n;else i=[a,...n.instructions.slice(1)];else i=[Object.freeze(P(t,r)),...n.instructions.slice(1)];else i=[Object.freeze(P(t,r)),...n.instructions];return Object.freeze({...n,instructions:Object.freeze(i),lifetimeConstraint:Object.freeze({nonce:e})})}(s,e))}e.s(["appendTransactionMessageInstruction",()=>F,"appendTransactionMessageInstructions",()=>z,"compileTransactionMessage",()=>C,"createTransactionMessage",()=>D,"decompileTransactionMessage",()=>G,"getCompiledTransactionMessageDecoder",()=>w,"getCompiledTransactionMessageEncoder",()=>T,"getTransactionVersionDecoder",()=>I,"isTransactionMessageWithBlockhashLifetime",()=>p,"isTransactionMessageWithDurableNonceLifetime",()=>x,"prependTransactionMessageInstruction",()=>B,"setTransactionMessageFeePayer",()=>M,"setTransactionMessageLifetimeUsingBlockhash",()=>y],421720)},648328,e=>{"use strict";var t,r=e.i(912440),n=e.i(587896),i=e.i(631157),a=e.i(38340),s=e.i(642108),o=e.i(421720);e.i(850631);var c=e.i(994999),l=e.i(810657);function d(e){let t=Object.values(e);if(0===t.length)throw new s.SolanaError(s.SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES);return t.map(e=>e||new Uint8Array(64).fill(0))}function _(){return(0,i.getStructEncoder)([["signatures",(0,n.transformEncoder)((0,i.getArrayEncoder)((0,n.fixEncoderSize)((0,i.getBytesEncoder)(),64),{size:(0,a.getShortU16Encoder)()}),d)],["messageBytes",(0,i.getBytesEncoder)()]])}function f(){return(0,n.transformDecoder)((0,i.getStructDecoder)([["signatures",(0,i.getArrayDecoder)((0,n.fixDecoderSize)((0,i.getBytesDecoder)(),64),{size:(0,a.getShortU16Decoder)()})],["messageBytes",(0,i.getBytesDecoder)()]]),u)}function u(e){let{messageBytes:t,signatures:c}=e,[l,d,_]=(0,i.getTupleDecoder)([(0,o.getTransactionVersionDecoder)(),(0,n.padRightDecoder)((0,a.getU8Decoder)(),2),(0,i.getArrayDecoder)((0,r.getAddressDecoder)(),{size:(0,a.getShortU16Decoder)()})]).decode(t),f=_.slice(0,d);if(f.length!==c.length)throw new s.SolanaError(s.SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH,{numRequiredSignatures:d,signaturesLength:c.length,signerAddresses:f});let u={};return f.forEach((e,t)=>{let r=c[t];r.every(e=>0===e)?u[e]=null:u[e]=r}),{messageBytes:t,signatures:Object.freeze(u)}}function h(e){let t,r=(0,o.compileTransactionMessage)(e),n=(0,o.getCompiledTransactionMessageEncoder)().encode(r),i=r.staticAccounts.slice(0,r.header.numSignerAccounts),a={};for(let e of i)a[e]=null;return(0,o.isTransactionMessageWithBlockhashLifetime)(e)?t={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:(0,o.isTransactionMessageWithDurableNonceLifetime)(e)&&(t={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...t?{lifetimeConstraint:t}:void 0,messageBytes:n,signatures:Object.freeze(a)})}function p(e){t||(t=(0,c.getBase58Decoder)());let r=Object.values(e.signatures)[0];if(!r)throw new s.SolanaError(s.SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING);return t.decode(r)}async function y(e,t){let i,a;if(await Promise.all(e.map(async e=>{let s=await (0,r.getAddressFromPublicKey)(e.publicKey),o=t.signatures[s];if(void 0===o)return void(a||=new Set).add(s);if(a)return;let c=await (0,l.signBytes)(e.privateKey,t.messageBytes);null!==o&&(0,n.bytesEqual)(c,o)||((i||={})[s]=c)})),a&&a.size>0){let e=Object.keys(t.signatures);throw new s.SolanaError(s.SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION,{expectedAddresses:e,unexpectedAddresses:[...a]})}return i?Object.freeze({...t,signatures:Object.freeze({...t.signatures,...i})}):t}function E(e){let t=[];if(Object.entries(e.signatures).forEach(([e,r])=>{r||t.push(e)}),t.length>0)throw new s.SolanaError(s.SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING,{addresses:t})}function A(e){let t=_().encode(e);return(0,c.getBase64Decoder)().decode(t)}function g(e){var t;return t=h(e),_().getSizeFromValue(t)}e.s(["TRANSACTION_SIZE_LIMIT",()=>1232,"assertIsFullySignedTransaction",()=>E,"compileTransaction",()=>h,"getBase64EncodedWireTransaction",()=>A,"getSignatureFromTransaction",()=>p,"getTransactionDecoder",()=>f,"getTransactionEncoder",()=>_,"getTransactionMessageSize",()=>g,"partiallySignTransaction",()=>y])},654312,e=>{"use strict";var t,r=e.i(642108);e.i(441960);var n=e.i(912440),i=e.i(810657),a=e.i(648328);
23e.i(587896),e.i(631157),e.i(38340),e.i(994999),new Uint8Array([255,115,111,108,97,110,97,32,111,102,102,99,104,97,105,110]);var s=((t=s||{})[t.RESTRICTED_ASCII_1232_BYTES_MAX=0]="RESTRICTED_ASCII_1232_BYTES_MAX",t[t.UTF8_1232_BYTES_MAX=1]="UTF8_1232_BYTES_MAX",t[t.UTF8_65535_BYTES_MAX=2]="UTF8_65535_BYTES_MAX",t);function o(e){let t={};return e.forEach(e=>{if(t[e.address]){if(t[e.address]!==e)throw new r.SolanaError(r.SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS,{address:e.address})}else t[e.address]=e}),Object.values(t)}function c(e){return"modifyAndSignTransactions"in e&&"function"==typeof e.modifyAndSignTransactions}function l(e){return"signTransactions"in e&&"function"==typeof e.signTransactions}function d(e){return"signAndSendTransactions"in e&&"function"==typeof e.signAndSendTransactions}function _(e){return l(e)||c(e)||d(e)}function f(e){return o((e.accounts??[]).flatMap(e=>"signer"in e?e.signer:[]))}function u(e,t){Object.freeze(e);let r={...t,feePayer:e};return Object.freeze(r),r}async function h(e){let t=await (0,n.getAddressFromPublicKey)(e.publicKey);return Object.freeze({address:t,keyPair:e,signMessages:r=>Promise.all(r.map(async r=>Object.freeze({[t]:await (0,i.signBytes)(e.privateKey,r.content)}))),signTransactions:r=>Promise.all(r.map(async r=>Object.freeze({[t]:(await (0,a.partiallySignTransaction)([e],r)).signatures[t]})))})}async function p(e,t){return await h(await (0,i.createKeyPairFromBytes)(e,t))}async function y(e,t){return await h(await (0,i.createKeyPairFromPrivateKeyBytes)(e,t))}async function E(e,t){let{partialSigners:r,modifyingSigners:n}=function(e,t={}){let r=t.identifySendingSigner??!0?function(e){let t=e.filter(d);if(0===t.length)return null;let r=t.filter(e=>!c(e)&&!l(e));return r.length>0?r[0]:t[0]}(e):null,n=e.filter(e=>e!==r&&(c(e)||l(e))),i=function(e){let t=e.filter(c);if(0===t.length)return[];let r=t.filter(e=>!l(e));return r.length>0?r:[t[0]]}(n),a=n.filter(l).filter(e=>!i.includes(e));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}(o(o([...e.feePayer&&_(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(f)]).filter(_)),{identifySendingSigner:!1});return await A(e,n,r,t)}async function A(e,t=[],r=[],n){let i=(0,a.compileTransaction)(e),s=await t.reduce(async(e,t)=>{n?.abortSignal?.throwIfAborted();let[r]=await t.modifyAndSignTransactions([await e],n);return Object.freeze(r)},Promise.resolve(i));n?.abortSignal?.throwIfAborted();let o=await Promise.all(r.map(async e=>{let[t]=await e.signTransactions([s],n);return t}));return Object.freeze({...s,signatures:Object.freeze(o.reduce((e,t)=>({...e,...t}),s.signatures??{}))})}e.s(["createKeyPairSignerFromBytes",()=>p,"createKeyPairSignerFromPrivateKeyBytes",()=>y,"isTransactionModifyingSigner",()=>c,"isTransactionPartialSigner",()=>l,"isTransactionSigner",()=>_,"partiallySignTransactionMessageWithSigners",()=>E,"setTransactionMessageFeePayerSigner",()=>u],654312)},391791,e=>{"use strict";function t(e){return null!==e&&("object"==typeof e||"function"==typeof e)}var r=new WeakMap;async function n(e){let n,i=new Promise((i,a)=>{for(let s of(n={reject:a,resolve:i},e)){if(!t(s)){Promise.resolve(s).then(i,a);continue}let e=r.get(s);void 0===e?((e=function(e){let t=new Set,r={deferreds:t,settled:!1};return Promise.resolve(e).then(e=>{for(let{resolve:r}of t)r(e);t.clear(),r.settled=!0},e=>{for(let{reject:r}of t)r(e);t.clear(),r.settled=!0}),r}(s)).deferreds.add(n),r.set(s,e)):e.settled?Promise.resolve(s).then(i,a):e.deferreds.add(n)}});return await i.finally(()=>{for(let i of e)t(i)&&r.get(i).deferreds.delete(n)})}function i(e,t){return t?n([new Promise((e,r)=>{t.aborted?r(t.reason):t.addEventListener("abort",function(){r(this.reason)})}),e]):e}e.s(["getAbortablePromise",()=>i,"safeRace",()=>n])},27408,e=>{"use strict";var t=e.i(587896),r=e.i(631157),n=e.i(38340),i=e=>({__option:"Some",value:e}),a=()=>({__option:"None"}),s=e=>!!(e&&"object"==typeof e&&"__option"in e&&("Some"===e.__option&&"value"in e||"None"===e.__option)),o=e=>"None"===e.__option;function c(e,t){return"Some"===e.__option?e.value:t?t():null}var l=e=>null!==e?i(e):a();function d(e,i={}){let a=null===i.prefix?(0,t.transformEncoder)((0,r.getUnitEncoder)(),e=>void 0):(0,r.getBooleanEncoder)({size:i.prefix??(0,n.getU8Encoder)()}),o="zeroes"===i.noneValue?((0,t.assertIsFixedSize)(e),(0,t.fixEncoderSize)((0,r.getUnitEncoder)(),e.fixedSize)):i.noneValue?(0,r.getConstantEncoder)(i.noneValue):(0,r.getUnitEncoder)();return(0,r.getUnionEncoder)([(0,t.transformEncoder)((0,r.getTupleEncoder)([a,o]),e=>[!1,void 0]),(0,t.transformEncoder)((0,r.getTupleEncoder)([a,e]),e=>[!0,s(e)&&"Some"===e.__option?e.value:e])],e=>Number("Some"===(s(e)?e:l(e)).__option))}function _(e,s={}){let o=null===s.prefix?(0,t.transformDecoder)((0,r.getUnitDecoder)(),()=>!1):(0,r.getBooleanDecoder)({size:s.prefix??(0,n.getU8Decoder)()}),c="zeroes"===s.noneValue?((0,t.assertIsFixedSize)(e),(0,t.fixDecoderSize)((0,r.getUnitDecoder)(),e.fixedSize)):s.noneValue?(0,r.getConstantDecoder)(s.noneValue):(0,r.getUnitDecoder)();return(0,r.getUnionDecoder)([(0,t.transformDecoder)((0,r.getTupleDecoder)([o,c]),()=>a()),(0,t.transformDecoder)((0,r.getTupleDecoder)([o,e]),([,e])=>i(e))],(e,r)=>{if(null===s.prefix&&!s.noneValue)return Number(r<e.length);if(null===s.prefix&&null!=s.noneValue){let n="zeroes"===s.noneValue?new Uint8Array(c.fixedSize).fill(0):s.noneValue;return+!(0,t.containsBytes)(e,n,r)}return Number(o.read(e,r)[0])})}e.s(["getOptionDecoder",()=>_,"getOptionEncoder",()=>d,"isNone",()=>o,"isOption",()=>s,"none",()=>a,"unwrapOption",()=>c,"wrapNullable",()=>l])},696319,634583,e=>{"use strict";var t=e.i(642108),r=e.i(994999);function n(e,r){try{if("exists"in e&&!e.exists)return e;return Object.freeze({...e,data:r.decode(e.data)})}catch{throw new t.SolanaError(t.SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT,{address:e.address})}}function i(e){let r=e.filter(e=>(!("exists"in e)||"exists"in e&&e.exists)&&e.data instanceof Uint8Array);if(r.length>0){let e=r.map(e=>e.address);throw new t.SolanaError(t.SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED,{addresses:e})}}function a(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=(0,r.getBase64Encoder)().encode(t.data[0]);return Object.freeze({...o(t),address:e,data:n,exists:!0})}function s(e,t){if(!t)return Object.freeze({address:e,exists:!1});let r=t.data.parsed.info||{};return(t.data.program||t.data.parsed.type)&&(r.parsedAccountMeta={program:t.data.program,type:t.data.parsed.type}),Object.freeze({...o(t),address:e,data:r,exists:!0})}function o(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function c(e,t,r={}){let{abortSignal:n,...i}=r,s=await e.getAccountInfo(t,{...i,encoding:"base64"}).send({abortSignal:n});return a(t,s.value)}async function l(e,t,r={}){let{abortSignal:n,...i}=r,{value:o}=await e.getAccountInfo(t,{...i,encoding:"jsonParsed"}).send({abortSignal:n});return o&&"object"==typeof o&&"parsed"in o.data?s(t,o):a(t,o)}async function d(e,t,r={}){let{abortSignal:n,...i}=r;return(await e.getMultipleAccounts(t,{...i,encoding:"base64"}).send({abortSignal:n})).value.map((e,r)=>a(t[r],e))}async function _(e,t,r={}){let{abortSignal:n,...i}=r;return(await e.getMultipleAccounts(t,{...i,encoding:"jsonParsed"}).send({abortSignal:n})).value.map((e,r)=>e&&"object"==typeof e&&"parsed"in e.data?s(t[r],e):a(t[r],e))}function f(e){if(!e.exists)throw new t.SolanaError(t.SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND,{address:e.address})}function u(e){let r=e.filter(e=>!e.exists);if(r.length>0){let e=r.map(e=>e.address);throw new t.SolanaError(t.SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND,{addresses:e})}}function h(e,r,n,i){if(!(0,t.isSolanaError)(e,t.SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM))return!1;
23let a=r.instructions[e.context.index]?.programAddress;return!!a&&a===n&&(void 0===i||e.context.code===i)}e.s(["BASE_ACCOUNT_SIZE",()=>128,"assertAccountExists",()=>f,"assertAccountsDecoded",()=>i,"assertAccountsExist",()=>u,"decodeAccount",()=>n,"fetchEncodedAccount",()=>c,"fetchEncodedAccounts",()=>d,"fetchJsonParsedAccount",()=>l,"fetchJsonParsedAccounts",()=>_],696319),e.s(["isProgramError",()=>h],634583)},104076,e=>{"use strict";e.i(247167);var t,r,n,i,a,s=e.i(631157);e.i(27408);var o=e.i(912440),c=e.i(38340),l=e.i(587896);e.i(696319),e.i(634583);var d=e.i(441960);e.i(994999),e.i(642108),e.i(421720),e.i(648328),e.i(391791);var _=e.i(654312),f=((t=f||{})[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen",t),u=((r=u||{})[r.MintTokens=0]="MintTokens",r[r.FreezeAccount=1]="FreezeAccount",r[r.AccountOwner=2]="AccountOwner",r[r.CloseAccount=3]="CloseAccount",r),h=((n=h||{})[n.CreateAssociatedToken=0]="CreateAssociatedToken",n[n.CreateAssociatedTokenIdempotent=1]="CreateAssociatedTokenIdempotent",n[n.RecoverNestedAssociatedToken=2]="RecoverNestedAssociatedToken",n),p="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",y=((i=y||{})[i.Mint=0]="Mint",i[i.Token=1]="Token",i[i.Multisig=2]="Multisig",i),E=((a=E||{})[a.InitializeMint=0]="InitializeMint",a[a.InitializeAccount=1]="InitializeAccount",a[a.InitializeMultisig=2]="InitializeMultisig",a[a.Transfer=3]="Transfer",a[a.Approve=4]="Approve",a[a.Revoke=5]="Revoke",a[a.SetAuthority=6]="SetAuthority",a[a.MintTo=7]="MintTo",a[a.Burn=8]="Burn",a[a.CloseAccount=9]="CloseAccount",a[a.FreezeAccount=10]="FreezeAccount",a[a.ThawAccount=11]="ThawAccount",a[a.TransferChecked=12]="TransferChecked",a[a.ApproveChecked=13]="ApproveChecked",a[a.MintToChecked=14]="MintToChecked",a[a.BurnChecked=15]="BurnChecked",a[a.InitializeAccount2=16]="InitializeAccount2",a[a.SyncNative=17]="SyncNative",a[a.InitializeAccount3=18]="InitializeAccount3",a[a.InitializeMultisig2=19]="InitializeMultisig2",a[a.InitializeMint2=20]="InitializeMint2",a[a.GetAccountDataSize=21]="GetAccountDataSize",a[a.InitializeImmutableOwner=22]="InitializeImmutableOwner",a[a.AmountToUiAmount=23]="AmountToUiAmount",a[a.UiAmountToAmount=24]="UiAmountToAmount",a);function A(e,t){return t=>{if(!t.value)return Object.freeze({address:e,role:d.AccountRole.READONLY});let r=t.isWritable?d.AccountRole.WRITABLE:d.AccountRole.READONLY;return Object.freeze({address:function(e){if(!e)throw Error("Expected a Address.");return"object"==typeof e&&"address"in e?e.address:Array.isArray(e)?e[0]:e}(t.value),role:g(t.value)?(0,d.upgradeRoleToSigner)(r):r,...g(t.value)?{signer:t.value}:{}})}}function g(e){return!!e&&"object"==typeof e&&"address"in e&&(0,_.isTransactionSigner)(e)}async function S(e,t={}){let{programAddress:r="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}=t;return await (0,o.getProgramDerivedAddress)({programAddress:r,seeds:[(0,o.getAddressEncoder)().encode(e.owner),(0,o.getAddressEncoder)().encode(e.tokenProgram),(0,o.getAddressEncoder)().encode(e.mint)]})}function R(e,t){let r=t?.programAddress??"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",n={payer:{value:e.payer??null,isWritable:!0},ata:{value:e.ata??null,isWritable:!0},owner:{value:e.owner??null,isWritable:!1},mint:{value:e.mint??null,isWritable:!1},systemProgram:{value:e.systemProgram??null,isWritable:!1},tokenProgram:{value:e.tokenProgram??null,isWritable:!1}};n.tokenProgram.value||(n.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),n.systemProgram.value||(n.systemProgram.value="11111111111111111111111111111111");let i=A(r);return Object.freeze({accounts:[i(n.payer),i(n.ata),i(n.owner),i(n.mint),i(n.systemProgram),i(n.tokenProgram)],data:(0,l.transformEncoder)((0,s.getStructEncoder)([["discriminator",(0,c.getU8Encoder)()]]),e=>({...e,discriminator:1})).encode({}),programAddress:r})}function I(e,t){let r=t?.programAddress??p,n={source:{value:e.source??null,isWritable:!0},destination:{value:e.destination??null,isWritable:!0},authority:{value:e.authority??null,isWritable:!1}},i={...e},a=(i.multiSigners??[]).map(e=>({address:e.address,role:d.AccountRole.READONLY_SIGNER,signer:e})),o=A(r);return Object.freeze({accounts:[o(n.source),o(n.destination),o(n.authority),...a],data:(0,l.transformEncoder)((0,s.getStructEncoder)([["discriminator",(0,c.getU8Encoder)()],["amount",(0,c.getU64Encoder)()]]),e=>({...e,discriminator:3})).encode(i),programAddress:r})}e.s(["TOKEN_PROGRAM_ADDRESS",()=>p,"findAssociatedTokenPda",()=>S,"getCreateAssociatedTokenIdempotentInstruction",()=>
23R,"getTransferInstruction",()=>I],104076)},110043,e=>{"use strict";var t=e.i(271645),r=e.i(515502);let n=()=>{let{walletProxy:e,client:n}=(0,r.u)();return(0,t.useMemo)(()=>({signWithUserSigner:async({message:t,targetAppId:r})=>{if(!e)throw Error("Wallet proxy not initialized");let i=await n.getAccessToken();if(!i)throw Error("User must be authenticated");let{signature:a}=await e.signWithUserSigner({accessToken:i,message:t,targetAppId:r});return{signature:a}}}),[e,n])};e.s(["u",()=>n])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.