@revibase/lite 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -44,9 +44,10 @@ declare class RevibaseProvider {
44
44
  private popUp;
45
45
  constructor(opts: Options);
46
46
  openBlankPopUp(): void;
47
- sendPayloadToProvider({ payload, signature, }: {
47
+ sendPayloadToProvider({ payload, signature, timeoutMs, }: {
48
48
  payload: StartMessageRequest | StartTransactionRequest;
49
49
  signature: string;
50
+ timeoutMs?: number;
50
51
  }): Promise<any>;
51
52
  private openWebPopup;
52
53
  private pollForResult;
package/dist/index.d.ts CHANGED
@@ -44,9 +44,10 @@ declare class RevibaseProvider {
44
44
  private popUp;
45
45
  constructor(opts: Options);
46
46
  openBlankPopUp(): void;
47
- sendPayloadToProvider({ payload, signature, }: {
47
+ sendPayloadToProvider({ payload, signature, timeoutMs, }: {
48
48
  payload: StartMessageRequest | StartTransactionRequest;
49
49
  signature: string;
50
+ timeoutMs?: number;
50
51
  }): Promise<any>;
51
52
  private openWebPopup;
52
53
  private pollForResult;
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import {prepareTransactionMessage,getSettingsFromIndex,bufferToBase64URLString,createClientAuthorizationStartRequestChallenge,createMessageChallenge,convertPubkeyCompressedToCose,getWalletAddressFromIndex,fetchSettingsAccountData,UserRole,createClientAuthorizationCompleteRequestChallenge,base64URLStringToBuffer,getSignedSecp256r1Key,retrieveTransactionManager,getSignedTransactionManager,tokenTransferIntent,nativeTransferIntent,signAndSendTransaction,prepareTransactionSync,getJitoTipsConfig,prepareTransactionBundle,signAndSendBundledTransactions,fetchUserAccountData,Secp256r1Key}from'@revibase/core';export{initialize}from'@revibase/core';import {verifyAuthenticationResponse}from'@simplewebauthn/server';async function vc(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let t=window.origin,n={phase:"start",data:{type:"message"},redirectOrigin:t},{signature:r,message:o,id:s}=await e.onClientAuthorizationCallback(n),i=await e.sendPayloadToProvider({payload:{...n,data:{...n.data,payload:o}},signature:r});return await e.onClientAuthorizationCallback({...i,data:{...i.data,payload:{...i.data.payload,id:s,message:o}}})}var zn=1,kn=2,xn=3,Wn=4,Gn=5,Vn=6,Hn=7,Kn=8,Yn=9,$n=10,Xn=-32700,jn=-32603,Zn=-32602,qn=-32601,Jn=-32600,Qn=-32019,er=-32018,tr=-32017,nr=-32016,rr=-32015,or=-32014,ir=-32013,ar=-32012,sr=-32011,cr=-32010,dr=-32009,ur=-32008,Ir=-32007,_r=-32006,Ar=-32005,lr=-32004,Er=-32003,Rr=-32002,Tr=-32001,Ie=28e5,_e=2800001,gr=2800002,Xe=2800003,je=2800004,Ze=2800005,qe=2800006,Je=2800007,Qe=2800008,et=2800009,tt=2800010,nt=2800011,Dr=323e4,Sr=32300001,Nr=3230002,fr=3230003,Cr=3230004,Or=361e4,mr=3610001,pr=3610002,hr=3610003,Mr=3610004,yr=3610005,Lr=3610006,Ur=3610007,br=3611e3,Pr=3704e3,Fr=3704001,Br=3704002,vr=3704003,wr=3704004,zr=4128e3,kr=4128001,xr=4128002,Wr=4615e3,Gr=4615001,Vr=4615002,Hr=4615003,Kr=4615004,Yr=4615005,$r=4615006,Xr=4615007,jr=4615008,Zr=4615009,qr=4615010,Jr=4615011,Qr=4615012,eo=4615013,to=4615014,no=4615015,ro=4615016,oo=4615017,io=4615018,ao=4615019,so=4615020,co=4615021,uo=4615022,Io=4615023,_o=4615024,Ao=4615025,lo=4615026,Eo=4615027,Ro=4615028,To=4615029,go=4615030,Do=4615031,So=4615032,No=4615033,fo=4615034,Co=4615035,Oo=4615036,mo=4615037,po=4615038,ho=4615039,Mo=4615040,yo=4615041,Lo=4615042,Uo=4615043,bo=4615044,Po=4615045,Fo=4615046,Bo=4615047,vo=4615048,wo=4615049,zo=4615050,ko=4615051,xo=4615052,Wo=4615053,Go=4615054,Vo=5508e3,Ho=5508001,Ko=5508002,Yo=5508003,$o=5508004,Xo=5508005,jo=5508006,Zo=5508007,qo=5508008,Jo=5508009,Qo=5508010,ei=5508011,Ae=5663e3,ee=5663001,le=5663002,Ee=5663003,Re=5663004,rt=5663005,ot=5663006,it=5663007,at=5663008,st=5663009,ti=5663010,ni=5663011,ct=5663012,ri=5663013,oi=5663014,dt=5663015,Te=5663016,ut=5663017,It=5663018,_t=5663019,At=5663020,ge=5663021,lt=5663022,ii=705e4,ai=7050001,si=7050002,ci=7050003,di=7050004,ui=7050005,Ii=7050006,_i=7050007,Ai=7050008,li=7050009,Ei=7050010,Ri=7050011,Ti=7050012,gi=7050013,Di=7050014,Si=7050015,Ni=7050016,fi=7050017,Ci=7050018,Oi=7050019,mi=7050020,pi=7050021,hi=7050022,Mi=7050023,yi=7050024,Li=7050025,Ui=7050026,bi=7050027,Pi=7050028,Fi=7050029,Bi=7050030,vi=7050031,wi=7050032,zi=7050033,ki=7050034,xi=7050035,Wi=7050036,Gi=7618e3,Vi=7618001,Hi=7618002,Ki=7618003,De=8078e3,Se=8078001,Et=8078002,Rt=8078003,Tt=8078004,gt=8078005,Dt=8078006,Ne=8078007,St=8078008,Nt=8078009,ft=8078010,fe=8078011,Z=8078012,Ct=8078013,Ot=8078014,mt=8078015,pt=8078016,Ce=8078017,ht=8078018,Yi=8078019,Mt=8078020,yt=8078021,Lt=8078022,Ut=8078023,$i=81e5,Xi=8100001,ji=8100002,Zi=8100003,qi=819e4,Ji=8190001,Qi=8190002,ea=8190003,ta=8190004,na=99e5,ra=9900001,oa=9900002,ia=9900003,aa=9900004,sa=9900005,ca=9900006;function bt(e){return Array.isArray(e)?"%5B"+e.map(bt).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function da([e,t]){return `${e}=${bt(t)}`}function ua(e){let t=Object.entries(e).map(da).join("&");return Buffer.from(t,"utf8").toString("base64")}var Ia={[Dr]:"Account not found at address: $address",[Cr]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[fr]:"Expected decoded account at address: $address",[Nr]:"Failed to decode account data at address: $address",[Sr]:"Accounts not found at addresses: $addresses",[et]:"Unable to find a viable program address bump seed.",[gr]:"$putativeAddress is not a base58-encoded address.",[Ie]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Xe]:"The `CryptoKey` must be an `Ed25519` public key.",[nt]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Qe]:"Invalid seeds; point must fall off the Ed25519 curve.",[je]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[qe]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Je]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Ze]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[tt]:"Program address cannot end with PDA marker.",[_e]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Wn]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[zn]:"The network has progressed past the last block for which this transaction could have been committed.",[De]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Lt]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Mt]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[gt]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Dt]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Tt]:"Encoder and decoder must either both be fixed-size or variable-size.",[St]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Et]:"Expected a fixed-size codec, got a variable-size one.",[Ct]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Rt]:"Expected a variable-size codec, got a fixed-size one.",[Yi]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Se]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[ht]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Nt]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[ft]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[mt]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Ne]:"Expected [$codecDescription] to have $expected items, got $actual.",[Z]:"Invalid value $value for base $base with alphabet $alphabet.",[pt]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[fe]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Ot]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[yt]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Ce]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Ut]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[br]:"No random values implementation could be found.",[Zr]:"instruction requires an uninitialized account",[Io]:"instruction tries to borrow reference for an account which is already borrowed",[_o]:"instruction left account with an outstanding borrowed reference",[co]:"program other than the account's owner changed the size of the account data",[Yr]:"account data too small for instruction",[uo]:"instruction expected an executable account",[Fo]:"An account does not have enough lamports to be rent-exempt",[vo]:"Program arithmetic overflowed",[Po]:"Failed to serialize or deserialize account data: $encodedData",[Go]:"Builtin programs must consume compute units",[So]:"Cross-program invocation call depth too deep",[po]:"Computational budget exceeded",[lo]:"custom program error: #$code",[oo]:"instruction contains duplicate accounts",[Ao]:"instruction modifications of multiply-passed account differ",[go]:"executable accounts must be rent exempt",[Ro]:"instruction changed executable accounts data",[To]:"instruction changed the balance of an executable account",[io]:"instruction changed executable bit of an account",[to]:"instruction modified data of an account it does not own",[eo]:"instruction spent from the balance of an account it does not own",[Gr]:"generic instruction error",[zo]:"Provided owner is not allowed",[Uo]:"Account is immutable",[bo]:"Incorrect authority provided",[Xr]:"incorrect program id for instruction",[$r]:"insufficient funds for instruction",[Kr]:"invalid account data for instruction",[Bo]:"Invalid account owner",[Vr]:"invalid program argument",[Eo]:"program returned invalid error code",[Hr]:"invalid instruction data",[mo]:"Failed to reallocate account data",[Oo]:"Provided seeds do not result in a valid address",[ko]:"Accounts data allocations exceeded the maximum allowed per transaction",[xo]:"Max accounts exceeded",[Wo]:"Max instruction trace length exceeded",[Co]:"Length of the seed is too long for address generation",[No]:"An account required by the instruction is missing",[jr]:"missing required signature for instruction",[Qr]:"instruction illegally modified the program id of an account",[so]:"insufficient account keys for instruction",[ho]:"Cross-program invocation with unauthorized signer or writable account",[Mo]:"Failed to create program execution environment",[Lo]:"Program failed to compile",[yo]:"Program failed to complete",[ro]:"instruction modified data of a read-only account",[no]:"instruction changed the balance of a read-only account",[fo]:"Cross-program invocation reentrancy not allowed for this instruction",[ao]:"instruction modified rent epoch of an account",[Jr]:"sum of account balances before and after instruction do not match",[qr]:"instruction requires an initialized account",[Wr]:"",[Do]:"Unsupported program id",[wo]:"Unsupported sysvar",[sa]:"Invalid instruction plan kind: $kind.",[Hi]:"The provided instruction plan is empty.",[Ki]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Gi]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[ca]:"Invalid transaction plan kind: $kind.",[Vi]:"No more instructions to pack; the message packer has completed the instruction plan.",[zr]:"The instruction does not have any accounts.",[kr]:"The instruction does not have any data.",[xr]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Gn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[kn]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[oa]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[aa]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[ra]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[na]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ia]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[jn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Zn]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Jn]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[qn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Xn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ar]:"$__serverMessage",[Tr]:"$__serverMessage",[lr]:"$__serverMessage",[or]:"$__serverMessage",[tr]:"Epoch rewards period still active at slot $slot",[cr]:"$__serverMessage",[dr]:"$__serverMessage",[Qn]:"Failed to query long-term storage; please try again",[nr]:"Minimum context slot has not been reached",[Ar]:"Node is unhealthy; behind by $numSlotsBehind slots",[ur]:"No snapshot",[Rr]:"Transaction simulation failed",[er]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[Ir]:"$__serverMessage",[sr]:"Transaction history is not available from this node",[_r]:"$__serverMessage",[ir]:"Transaction signature length mismatch",[Er]:"Transaction signature verification failure",[rr]:"$__serverMessage",[Pr]:"Key pair bytes must be of length 64, got $byteLength.",[Fr]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Br]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[wr]:"The provided private key does not match the provided public key.",[vr]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Vn]:"Lamports value must be in the range [0, 2e64-1]",[Hn]:"`$value` cannot be parsed as a `BigInt`",[$n]:"$message",[Kn]:"`$value` cannot be parsed as a `Number`",[xn]:"No nonce account could be found at address `$nonceAccountAddress`",[qi]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Qi]:"WebSocket was closed before payload could be added to the send buffer",[ea]:"WebSocket connection closed",[ta]:"WebSocket failed to connect",[Ji]:"Failed to obtain a subscription id from the server",[Zi]:"Could not find an API plan for RPC method: `$method`",[$i]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[ji]:"HTTP error ($statusCode): $message",[Xi]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Vo]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Ho]:"The provided value does not implement the `KeyPairSigner` interface",[Yo]:"The provided value does not implement the `MessageModifyingSigner` interface",[$o]:"The provided value does not implement the `MessagePartialSigner` interface",[Ko]:"The provided value does not implement any of the `MessageSigner` interfaces",[jo]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Zo]:"The provided value does not implement the `TransactionPartialSigner` interface",[qo]:"The provided value does not implement the `TransactionSendingSigner` interface",[Xo]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Jo]:"More than one `TransactionSendingSigner` was identified.",[Qo]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[ei]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Ur]:"Cannot export a non-extractable key.",[mr]:"No digest implementation could be found.",[Or]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[pr]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ import {prepareTransactionMessage,getSettingsFromIndex,bufferToBase64URLString,createClientAuthorizationStartRequestChallenge,createMessageChallenge,convertPubkeyCompressedToCose,getWalletAddressFromIndex,fetchSettingsAccountData,UserRole,createClientAuthorizationCompleteRequestChallenge,base64URLStringToBuffer,getSignedSecp256r1Key,retrieveTransactionManager,getSignedTransactionManager,tokenTransferIntent,nativeTransferIntent,signAndSendTransaction,prepareTransactionSync,getJitoTipsConfig,prepareTransactionBundle,signAndSendBundledTransactions,fetchUserAccountData,Secp256r1Key}from'@revibase/core';export{initialize}from'@revibase/core';import {verifyAuthenticationResponse}from'@simplewebauthn/server';async function xc(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let t=window.origin,n={phase:"start",data:{type:"message"},redirectOrigin:t},{signature:r,message:o,id:s}=await e.onClientAuthorizationCallback(n),i=await e.sendPayloadToProvider({payload:{...n,data:{...n.data,payload:o}},signature:r});return await e.onClientAuthorizationCallback({...i,data:{...i.data,payload:{...i.data.payload,id:s,message:o}}})}var xn=1,Wn=2,Gn=3,Vn=4,Hn=5,Kn=6,Yn=7,$n=8,Xn=9,jn=10,Zn=-32700,qn=-32603,Jn=-32602,Qn=-32601,er=-32600,tr=-32019,nr=-32018,rr=-32017,or=-32016,ir=-32015,ar=-32014,sr=-32013,cr=-32012,dr=-32011,ur=-32010,Ir=-32009,_r=-32008,Ar=-32007,lr=-32006,Er=-32005,Rr=-32004,Tr=-32003,gr=-32002,Dr=-32001,Ae=28e5,le=2800001,Sr=2800002,qe=2800003,Je=2800004,Qe=2800005,et=2800006,tt=2800007,nt=2800008,rt=2800009,ot=2800010,it=2800011,Nr=323e4,fr=32300001,Cr=3230002,Or=3230003,mr=3230004,pr=361e4,hr=3610001,Mr=3610002,yr=3610003,Lr=3610004,Ur=3610005,br=3610006,Pr=3610007,Fr=3611e3,Br=3704e3,vr=3704001,wr=3704002,zr=3704003,kr=3704004,xr=4128e3,Wr=4128001,Gr=4128002,Vr=4615e3,Hr=4615001,Kr=4615002,Yr=4615003,$r=4615004,Xr=4615005,jr=4615006,Zr=4615007,qr=4615008,Jr=4615009,Qr=4615010,eo=4615011,to=4615012,no=4615013,ro=4615014,oo=4615015,io=4615016,ao=4615017,so=4615018,co=4615019,uo=4615020,Io=4615021,_o=4615022,Ao=4615023,lo=4615024,Eo=4615025,Ro=4615026,To=4615027,go=4615028,Do=4615029,So=4615030,No=4615031,fo=4615032,Co=4615033,Oo=4615034,mo=4615035,po=4615036,ho=4615037,Mo=4615038,yo=4615039,Lo=4615040,Uo=4615041,bo=4615042,Po=4615043,Fo=4615044,Bo=4615045,vo=4615046,wo=4615047,zo=4615048,ko=4615049,xo=4615050,Wo=4615051,Go=4615052,Vo=4615053,Ho=4615054,Ko=5508e3,Yo=5508001,$o=5508002,Xo=5508003,jo=5508004,Zo=5508005,qo=5508006,Jo=5508007,Qo=5508008,ei=5508009,ti=5508010,ni=5508011,Ee=5663e3,J=5663001,Re=5663002,Te=5663003,ge=5663004,at=5663005,st=5663006,ct=5663007,dt=5663008,ut=5663009,ri=5663010,oi=5663011,It=5663012,ii=5663013,ai=5663014,_t=5663015,De=5663016,At=5663017,lt=5663018,Et=5663019,Rt=5663020,Se=5663021,Tt=5663022,si=705e4,ci=7050001,di=7050002,ui=7050003,Ii=7050004,_i=7050005,Ai=7050006,li=7050007,Ei=7050008,Ri=7050009,Ti=7050010,gi=7050011,Di=7050012,Si=7050013,Ni=7050014,fi=7050015,Ci=7050016,Oi=7050017,mi=7050018,pi=7050019,hi=7050020,Mi=7050021,yi=7050022,Li=7050023,Ui=7050024,bi=7050025,Pi=7050026,Fi=7050027,Bi=7050028,vi=7050029,wi=7050030,zi=7050031,ki=7050032,xi=7050033,Wi=7050034,Gi=7050035,Vi=7050036,Hi=7618e3,Ki=7618001,Yi=7618002,$i=7618003,Ne=8078e3,fe=8078001,gt=8078002,Dt=8078003,St=8078004,Nt=8078005,ft=8078006,Ce=8078007,Ct=8078008,Ot=8078009,mt=8078010,Oe=8078011,X=8078012,pt=8078013,ht=8078014,Mt=8078015,yt=8078016,me=8078017,Lt=8078018,Xi=8078019,Ut=8078020,bt=8078021,Pt=8078022,Ft=8078023,ji=81e5,Zi=8100001,qi=8100002,Ji=8100003,Qi=819e4,ea=8190001,ta=8190002,na=8190003,ra=8190004,oa=99e5,ia=9900001,aa=9900002,sa=9900003,ca=9900004,da=9900005,ua=9900006;function Bt(e){return Array.isArray(e)?"%5B"+e.map(Bt).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Ia([e,t]){return `${e}=${Bt(t)}`}function _a(e){let t=Object.entries(e).map(Ia).join("&");return Buffer.from(t,"utf8").toString("base64")}var Aa={[Nr]:"Account not found at address: $address",[mr]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Or]:"Expected decoded account at address: $address",[Cr]:"Failed to decode account data at address: $address",[fr]:"Accounts not found at addresses: $addresses",[rt]:"Unable to find a viable program address bump seed.",[Sr]:"$putativeAddress is not a base58-encoded address.",[Ae]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[qe]:"The `CryptoKey` must be an `Ed25519` public key.",[it]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[nt]:"Invalid seeds; point must fall off the Ed25519 curve.",[Je]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[et]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[tt]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Qe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[ot]:"Program address cannot end with PDA marker.",[le]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Vn]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[xn]:"The network has progressed past the last block for which this transaction could have been committed.",[Ne]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Pt]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Ut]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Nt]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ft]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[St]:"Encoder and decoder must either both be fixed-size or variable-size.",[Ct]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[gt]:"Expected a fixed-size codec, got a variable-size one.",[pt]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Dt]:"Expected a variable-size codec, got a fixed-size one.",[Xi]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[fe]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Lt]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Ot]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[mt]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Mt]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Ce]:"Expected [$codecDescription] to have $expected items, got $actual.",[X]:"Invalid value $value for base $base with alphabet $alphabet.",[yt]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Oe]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[ht]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[bt]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[me]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Ft]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[Fr]:"No random values implementation could be found.",[Jr]:"instruction requires an uninitialized account",[Ao]:"instruction tries to borrow reference for an account which is already borrowed",[lo]:"instruction left account with an outstanding borrowed reference",[Io]:"program other than the account's owner changed the size of the account data",[Xr]:"account data too small for instruction",[_o]:"instruction expected an executable account",[vo]:"An account does not have enough lamports to be rent-exempt",[zo]:"Program arithmetic overflowed",[Bo]:"Failed to serialize or deserialize account data: $encodedData",[Ho]:"Builtin programs must consume compute units",[fo]:"Cross-program invocation call depth too deep",[Mo]:"Computational budget exceeded",[Ro]:"custom program error: #$code",[ao]:"instruction contains duplicate accounts",[Eo]:"instruction modifications of multiply-passed account differ",[So]:"executable accounts must be rent exempt",[go]:"instruction changed executable accounts data",[Do]:"instruction changed the balance of an executable account",[so]:"instruction changed executable bit of an account",[ro]:"instruction modified data of an account it does not own",[no]:"instruction spent from the balance of an account it does not own",[Hr]:"generic instruction error",[xo]:"Provided owner is not allowed",[Po]:"Account is immutable",[Fo]:"Incorrect authority provided",[Zr]:"incorrect program id for instruction",[jr]:"insufficient funds for instruction",[$r]:"invalid account data for instruction",[wo]:"Invalid account owner",[Kr]:"invalid program argument",[To]:"program returned invalid error code",[Yr]:"invalid instruction data",[ho]:"Failed to reallocate account data",[po]:"Provided seeds do not result in a valid address",[Wo]:"Accounts data allocations exceeded the maximum allowed per transaction",[Go]:"Max accounts exceeded",[Vo]:"Max instruction trace length exceeded",[mo]:"Length of the seed is too long for address generation",[Co]:"An account required by the instruction is missing",[qr]:"missing required signature for instruction",[to]:"instruction illegally modified the program id of an account",[uo]:"insufficient account keys for instruction",[yo]:"Cross-program invocation with unauthorized signer or writable account",[Lo]:"Failed to create program execution environment",[bo]:"Program failed to compile",[Uo]:"Program failed to complete",[io]:"instruction modified data of a read-only account",[oo]:"instruction changed the balance of a read-only account",[Oo]:"Cross-program invocation reentrancy not allowed for this instruction",[co]:"instruction modified rent epoch of an account",[eo]:"sum of account balances before and after instruction do not match",[Qr]:"instruction requires an initialized account",[Vr]:"",[No]:"Unsupported program id",[ko]:"Unsupported sysvar",[da]:"Invalid instruction plan kind: $kind.",[Yi]:"The provided instruction plan is empty.",[$i]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Hi]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[ua]:"Invalid transaction plan kind: $kind.",[Ki]:"No more instructions to pack; the message packer has completed the instruction plan.",[xr]:"The instruction does not have any accounts.",[Wr]:"The instruction does not have any data.",[Gr]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Hn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Wn]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[aa]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ca]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[ia]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[oa]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[sa]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[qn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Jn]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[er]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Qn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Zn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[cr]:"$__serverMessage",[Dr]:"$__serverMessage",[Rr]:"$__serverMessage",[ar]:"$__serverMessage",[rr]:"Epoch rewards period still active at slot $slot",[ur]:"$__serverMessage",[Ir]:"$__serverMessage",[tr]:"Failed to query long-term storage; please try again",[or]:"Minimum context slot has not been reached",[Er]:"Node is unhealthy; behind by $numSlotsBehind slots",[_r]:"No snapshot",[gr]:"Transaction simulation failed",[nr]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[Ar]:"$__serverMessage",[dr]:"Transaction history is not available from this node",[lr]:"$__serverMessage",[sr]:"Transaction signature length mismatch",[Tr]:"Transaction signature verification failure",[ir]:"$__serverMessage",[Br]:"Key pair bytes must be of length 64, got $byteLength.",[vr]:"Expected private key bytes with length 32. Actual length: $actualLength.",[wr]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[kr]:"The provided private key does not match the provided public key.",[zr]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Kn]:"Lamports value must be in the range [0, 2e64-1]",[Yn]:"`$value` cannot be parsed as a `BigInt`",[jn]:"$message",[$n]:"`$value` cannot be parsed as a `Number`",[Gn]:"No nonce account could be found at address `$nonceAccountAddress`",[Qi]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ta]:"WebSocket was closed before payload could be added to the send buffer",[na]:"WebSocket connection closed",[ra]:"WebSocket failed to connect",[ea]:"Failed to obtain a subscription id from the server",[Ji]:"Could not find an API plan for RPC method: `$method`",[ji]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[qi]:"HTTP error ($statusCode): $message",[Zi]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ko]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Yo]:"The provided value does not implement the `KeyPairSigner` interface",[Xo]:"The provided value does not implement the `MessageModifyingSigner` interface",[jo]:"The provided value does not implement the `MessagePartialSigner` interface",[$o]:"The provided value does not implement any of the `MessageSigner` interfaces",[qo]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Jo]:"The provided value does not implement the `TransactionPartialSigner` interface",[Qo]:"The provided value does not implement the `TransactionSendingSigner` interface",[Zo]:"The provided value does not implement any of the `TransactionSigner` interfaces",[ei]:"More than one `TransactionSendingSigner` was identified.",[ti]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[ni]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Pr]:"Cannot export a non-extractable key.",[hr]:"No digest implementation could be found.",[pr]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Mr]:`This runtime does not support the generation of Ed25519 key pairs.
2
2
 
3
3
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
4
4
 
5
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[hr]:"No signature verification implementation could be found.",[Mr]:"No key generation implementation could be found.",[yr]:"No signing implementation could be found.",[Lr]:"No key export implementation could be found.",[Yn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ni]:"Transaction processing left an account with an outstanding borrowed reference",[ai]:"Account in use",[si]:"Account loaded twice",[ci]:"Attempt to debit an account but found no record of a prior credit.",[Mi]:"Transaction loads an address table account that doesn't exist",[_i]:"This transaction has already been processed",[Ai]:"Blockhash not found",[li]:"Loader call chain is too deep",[Si]:"Transactions are currently disabled due to cluster maintenance",[Bi]:"Transaction contains a duplicate instruction ($index) that is not allowed",[ui]:"Insufficient funds for fee",[vi]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ii]:"This account may not be used to pay transaction fees",[Ri]:"Transaction contains an invalid account reference",[Li]:"Transaction loads an address table account with invalid data",[Ui]:"Transaction address table lookup uses an invalid index",[yi]:"Transaction loads an address table account with an invalid owner",[zi]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[gi]:"This program may not be used for executing instructions",[bi]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Oi]:"Transaction loads a writable account that cannot be written",[wi]:"Transaction exceeded max loaded accounts data size cap",[Ei]:"Transaction requires a fee but has no signature present",[di]:"Attempt to load a program that does not exist",[xi]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[ki]:"ResanitizationNeeded",[Di]:"Transaction failed to sanitize accounts offsets correctly",[Ti]:"Transaction did not pass signature verification",[hi]:"Transaction locked too many accounts",[Wi]:"Sum of account balances before and after transaction do not match",[ii]:"The transaction failed with the error `$errorName`",[Ci]:"Transaction version is unsupported",[pi]:"Transaction would exceed account data limit within the block",[Fi]:"Transaction would exceed total account data limit",[mi]:"Transaction would exceed max account limit within the block",[fi]:"Transaction would exceed max Block Cost Limit",[Pi]:"Transaction would exceed max Vote Cost Limit",[dt]:"Attempted to sign a transaction with an address that is not a signer for it",[ti]:"Transaction is missing an address at index: $index.",[Te]:"Transaction has no expected signers therefore it cannot be encoded",[At]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[le]:"Transaction does not have a blockhash lifetime",[Ee]:"Transaction is not a durable nonce transaction",[rt]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[ot]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[at]:"No fee payer set in CompiledTransaction",[it]:"Could not find program address at index $index",[It]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[_t]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[ni]:"Transaction is missing a fee payer.",[ct]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[oi]:"Transaction first instruction is not advance nonce account instruction.",[ri]:"Transaction with no instructions cannot be durable nonce transaction.",[Ae]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[ee]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ut]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[st]:"Transaction is missing signatures for addresses: $addresses.",[Re]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[ge]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[lt]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},M="i",h="t";function _a(e,t={}){let n=Ia[e];if(n.length===0)return "";let r;function o(i){if(r[h]===2){let a=n.slice(r[M]+1,i);s.push(a in t?`${t[a]}`:`$${a}`);}else r[h]===1&&s.push(n.slice(r[M],i));}let s=[];return n.split("").forEach((i,a)=>{if(a===0){r={[M]:0,[h]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[h]){case 0:c={[M]:a,[h]:1};break;case 1:i==="\\"?c={[M]:a,[h]:0}:i==="$"&&(c={[M]:a,[h]:2});break;case 2:i==="\\"?c={[M]:a,[h]:0}:i==="$"?c={[M]:a,[h]:2}:i.match(/\w/)||(c={[M]:a,[h]:1});break}c&&(r!==c&&o(a),r=c);}),o(),s.join("")}function Aa(e,t={}){if(process.env.NODE_ENV!=="production")return _a(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${ua(t)}'`),`${n}\``}}var _=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([s,i])=>{s==="cause"?r={cause:i.value}:(n===void 0&&(n={}),Object.defineProperty(n,s,i));});let o=Aa(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function la(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Ea=(e,t)=>la(e.length<=t?e:e.slice(0,t),t);function U(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function R(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(U(t,e));return e.write(t,n,0),n}})}function b(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function C(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Ra(e){return !C(e)}function Pt(e,t,n=0){if(t.length-n<=0)throw new _(De,{codecDescription:e})}function te(e,t,n,r=0){let o=n.length-r;if(o<t)throw new _(Se,{bytesLength:o,codecDescription:e,expected:t})}function Ft(e,t){let n=(i,a,c)=>{let d=e.encode(i);return c=t.write(d.length,a,c),a.set(d,c),c+d.length};if(C(t)&&C(e))return R({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=C(t)?t.fixedSize:t.maxSize??null,o=C(e)?e.fixedSize:e.maxSize??null,s=r!==null&&o!==null?r+o:null;return R({...e,...s!==null?{maxSize:s}:{},getSizeFromValue:i=>{let a=U(i,e);return U(a,t)+a},write:n})}function x(e,t){return R({fixedSize:t,write:(n,r,o)=>{let s=e.encode(n),i=s.length>t?s.slice(0,t):s;return r.set(i,o),o+t}})}function q(e,t){return b({fixedSize:t,read:(n,r)=>{te("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),C(e)&&(n=Ea(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function O(e,t){return R({...Ra(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function Ta(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new _(Z,{alphabet:e,base:e.length,value:n})}var ga=e=>R({getSizeFromValue:t=>{let[n,r]=Bt(t,e[0]);if(!r)return t.length;let o=vt(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Ta(e,t),t==="")return r;let[o,s]=Bt(t,e[0]);if(!s)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=vt(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...a];return n.set(c,r),r+c.length}}),Da=e=>b({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let s=e[0].repeat(o);if(o===r.length)return [s,t.length];let i=r.slice(o).reduce((c,d)=>c*256n+BigInt(d),0n),a=Sa(i,e);return [s+a,t.length]}});function Bt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function vt(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Sa(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var wt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ne=()=>ga(wt),f=()=>Da(wt);var re=()=>b({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var Oe,me;function pe(){return Oe||(Oe=ne()),Oe}function fa(){return me||(me=f()),me}function zt(e){if(e.length<32||e.length>44)return false;let t=pe();try{return t.encode(e).byteLength===32}catch{return false}}function he(e){if(e.length<32||e.length>44)throw new _(_e,{actualLength:e.length});let r=pe().encode(e).byteLength;if(r!==32)throw new _(Ie,{actualLength:r})}function D(e){return he(e),e}function W(){return O(x(pe(),32),e=>D(e))}function P(){return q(fa(),32)}function oe(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}function kt(e,t,n,r){if(r<t||r>n)throw new _(fe,{codecDescription:e,max:n,min:t,value:r})}function xt(e){return e?.endian!==1}function Me(e){return R({fixedSize:e.size,write(t,n,r){e.range&&kt(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,xt(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function Ca(e){return b({fixedSize:e.size,read(t,n=0){Pt(e.name,t,n),te(e.name,e.size,t,n);let r=new DataView(Oa(t,n,e.size));return [e.get(r,xt(e.config)),n+e.size]}})}function Oa(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var y=()=>R({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{kt("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let s=Number(e)>>o*7;if(s===0)break;let i=127&s;r[o]=i,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var ie=(e={})=>Me({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4});var ae=(e={})=>Me({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),ye=(e={})=>Ca({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var L=()=>Me({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1});function ha(e,t,n){if(t!==n)throw new _(Ne,{actual:n,codecDescription:e,expected:t})}function Ma(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function Wt(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function Kt(e){return C(e)?e.fixedSize:null}function Ue(e){return C(e)?e.fixedSize:e.maxSize??null}function F(e,t={}){let n=t.size??ie(),r=Gt(n,Kt(e)),o=Gt(n,Ue(e))??void 0;return R({...r!==null?{fixedSize:r}:{getSizeFromValue:s=>(typeof n=="object"?U(s.length,n):0)+[...s].reduce((a,c)=>a+U(c,e),0),maxSize:o},write:(s,i,a)=>(typeof n=="number"&&ha("array",n,s.length),typeof n=="object"&&(a=n.write(s.length,i,a)),s.forEach(c=>{a=e.write(c,i,a);}),a)})}function Gt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function J(){return R({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}function Yt(e){return R({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function $t(e,t){let n=ya(e),r=(s,i,a)=>{let c=t(s);return Vt(e,c),e[c].write(s,i,a)};if(n!==null)return R({fixedSize:n,write:r});let o=La(e);return R({...o!==null?{maxSize:o}:{},getSizeFromValue:s=>{let i=t(s);return Vt(e,i),U(s,e[i])},write:r})}function Vt(e,t){if(typeof e[t]>"u")throw new _(Ce,{maxRange:e.length-1,minRange:0,variant:t})}function ya(e){if(e.length===0)return 0;if(!C(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>C(r)&&r.fixedSize===t)?t:null}function La(e){return Ma(e.map(t=>Ue(t)))}function m(e){let t=e.map(([,o])=>o),n=Wt(t.map(Kt)),r=Wt(t.map(Ue))??void 0;return R({...n===null?{getSizeFromValue:o=>e.map(([s,i])=>U(o[s],i)).reduce((s,i)=>s+i,0),maxSize:r}:{fixedSize:n},write:(o,s,i)=>(e.forEach(([a,c])=>{i=c.write(o[a],s,i);}),i)})}function be(e,...t){return t.reduce((n,r)=>r(n),e)}var B=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(B||{});var Ua=1;function v(e){return e>=2}function V(e){return (e&Ua)!==0}function Pe(e,t){return e|t}function Xt(e){return zt(e)}function jt(){return P()}function nn(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&Xt(e.lifetimeConstraint.blockhash)}function rn(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 Ba(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new _(Z,{alphabet:e,base:e.length,value:n})}var va=e=>R({getSizeFromValue:t=>{let[n,r]=Zt(t,e[0]);if(!r)return t.length;let o=qt(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Ba(e,t),t==="")return r;let[o,s]=Zt(t,e[0]);if(!s)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=qt(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...a];return n.set(c,r),r+c.length}});function Zt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function qt(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var wa="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",za=()=>va(wa);var Fe;function ka(){if(!Fe){let e=F(L(),{size:y()});Fe=m([["lookupTableAddress",W()],["writableIndexes",e],["readonlyIndexes",e]]);}return Fe}var Be;function ve(){return Be||(Be=L()),Be}function xa(){return m([["numSignerAccounts",ve()],["numReadonlySignerAccounts",ve()],["numReadonlyNonSignerAccounts",ve()]])}var we;function Wa(){return we||(we=O(m([["programAddressIndex",L()],["accountIndices",F(L(),{size:y()})],["data",Ft(J(),y())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),we}var Ga=0,Va=128;function Ha(){return R({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new _(Re,{actualVersion:e});if(e>Ga)throw new _(ge,{unsupportedVersion:e});return t.set([e|Va],n),n+1}})}function Jt(){return m(on())}function Qt(){return O(m([...on(),["addressTableLookups",Ka()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function on(){let e=$t([Yt(new Uint8Array(32)),x(za(),32)],t=>t===void 0?0:1);return [["version",Ha()],["header",xa()],["staticAccounts",F(W(),{size:y()})],["lifetimeToken",e],["instructions",F(Wa(),{size:y()})]]}function Ka(){return F(ka(),{size:y()})}function an(){return R({getSizeFromValue:e=>e.version==="legacy"?Jt().getSizeFromValue(e):Qt().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Jt().write(e,t,n):Qt().write(e,t,n)})}function en(e,t,n){e[t]=n(e[t]??{role:B.READONLY});}var T=Symbol("AddressMapTypeProperty");function Ya(e,t){let n={[e]:{[T]:0,role:B.WRITABLE_SIGNER}},r=new Set;for(let o of t){en(n,o.programAddress,i=>{if(r.add(o.programAddress),T in i){if(V(i.role))switch(i[T]){case 0:throw new _(Ae,{programAddress:o.programAddress});default:throw new _(ee,{programAddress:o.programAddress})}if(i[T]===2)return i}return {[T]:2,role:B.READONLY}});let s;if(o.accounts)for(let i of o.accounts)en(n,i.address,a=>{let{address:c,...d}=i;if(T in a)switch(a[T]){case 0:return a;case 1:{let u=Pe(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(s||=oe())(d.lookupTableAddress,a.lookupTableAddress)<0)return {[T]:1,...d,role:u}}else if(v(d.role))return {[T]:2,role:u};return a.role!==u?{...a,role:u}:a}case 2:{let u=Pe(a.role,d.role);if(r.has(i.address)){if(V(d.role))throw new _(ee,{programAddress:i.address});return a.role!==u?{...a,role:u}:a}else return "lookupTableAddress"in d&&!v(a.role)?{...d,[T]:1,role:u}:a.role!==u?{...a,role:u}:a}}return "lookupTableAddress"in d?{...d,[T]:1}:{...d,[T]:2}});}return n}function $a(e){let t;return Object.entries(e).sort(([r,o],[s,i])=>{if(o[T]!==i[T]){if(o[T]===0)return -1;if(i[T]===0)return 1;if(o[T]===2)return -1;if(i[T]===2)return 1}let a=v(o.role);if(a!==v(i.role))return a?-1:1;let c=V(o.role);return c!==V(i.role)?c?-1:1:(t||=oe(),o[T]===1&&i[T]===1&&o.lookupTableAddress!==i.lookupTableAddress?t(o.lookupTableAddress,i.lookupTableAddress):t(r,s))}).map(([r,o])=>({address:r,...o}))}function Xa(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===B.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(oe()).map(n=>({lookupTableAddress:n,...t[n]}))}function ja(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let s=V(o.role);v(o.role)?(r++,s||n++):s||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Za(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function qa(e,t){let n=Za(t);return e.map(({accounts:r,data:o,programAddress:s})=>({programAddressIndex:n[s],...r?{accountIndices:r.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function Ja(e){return "nonce"in e?e.nonce:e.blockhash}function Qa(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function sn(e){let t=Ya(e.feePayer.address,e.instructions),n=$a(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:Xa(n)}:null,...r?{lifetimeToken:Ja(r)}:null,header:ja(n),instructions:qa(e.instructions,n),staticAccounts:Qa(n),version:e.version}}function es(e,t,n){for(let[r,o]of Object.entries(n))for(let s=0;s<o.length;s++)if(e===o[s])return {address:e,addressIndex:s,lookupTableAddress:r,role:t}}function cn(e,t){let n=new Set(e.instructions.map(i=>i.programAddress)),r=new Set(Object.values(t).flatMap(i=>i).filter(i=>!n.has(i))),o=[],s=false;for(let i of e.instructions){if(!i.accounts){o.push(i);continue}let a=[],c=false;for(let d of i.accounts){if("lookupTableAddress"in d||!r.has(d.address)||v(d.role)){a.push(d);continue}let u=es(d.address,d.role,t);a.push(Object.freeze(u)),c=true,s=true;}o.push(Object.freeze(c?{...i,accounts:a}:i));}return Object.freeze(s?{...e,instructions:o}:e)}function dn(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var ts="SysvarRecentB1ockHashes11111111111111111111",ns="11111111111111111111111111111111";function rs(e){return e.programAddress===ns&&e.data!=null&&os(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===B.WRITABLE&&e.accounts[1].address===ts&&e.accounts[1].role===B.READONLY&&e.accounts[2].address!=null&&v(e.accounts[2].role)}function os(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function ze(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&rs(e.instructions[0])}function un(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function In(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function is(e){let t=Object.values(e);if(t.length===0)throw new _(Te);return t.map(n=>n||new Uint8Array(64).fill(0))}function as(){return O(F(x(J(),64),{size:y()}),is)}function ke(){return m([["signatures",as()],["messageBytes",J()]])}function xe(e){let t=sn(e),n=an().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let i of r)o[i]=null;let s;return nn(e)?s={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:ze(e)&&(s={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...s?{lifetimeConstraint:s}:void 0,messageBytes:n,signatures:Object.freeze(o)})}function We(e){let t=ke().encode(e);return re().decode(t)}function _n(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}function An(e){return Object.freeze({address:e,signMessages:n=>Promise.resolve(n.map(()=>Object.freeze({}))),signTransactions:n=>Promise.resolve(n.map(()=>Object.freeze({})))})}var se="ComputeBudget111111111111111111111111111111";var Ge=2;function Ve(){return O(m([["discriminator",L()],["units",ie()]]),e=>({...e,discriminator:Ge}))}function ce(e,t){let n=se,r={...e};return Object.freeze({data:Ve().encode(r),programAddress:n})}var He=3;function Ke(){return O(m([["discriminator",L()],["microLamports",ae()]]),e=>({...e,discriminator:He}))}function de(e,t){let n=se,r={...e};return Object.freeze({data:Ke().encode(r),programAddress:n})}var H="11111111111111111111111111111111";var ln=0,En=1,Rn=2,Tn=3,gn=4,Dn=5,Sn=6,Nn=7,fn=8;process.env.NODE_ENV!=="production"&&({[ln]:"an account with the same address already exists",[Dn]:"provided address does not match addressed derived from seed",[Tn]:"cannot allocate account data of this length",[Rn]:"cannot assign account to this program id",[gn]:"length of requested seed is too long",[Nn]:"stored nonce is still in recent_blockhashes",[Sn]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[fn]:"specified nonce does not match stored nonce",[En]:"account does not have enough SOL to perform the operation"});var Ye="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";var ue="https://auth.revibase.com",K="https://api.revibase.com",Cn="revibase.com",On="Gq6VZLi2aNSxB4Ag7L1NKDfuCgNZgUuxy1B8yW28PdEp";function mn(e){let t=`${e.domain} wants you to sign in with your account.`,n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length&&(t+=`
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[yr]:"No signature verification implementation could be found.",[Lr]:"No key generation implementation could be found.",[Ur]:"No signing implementation could be found.",[br]:"No key export implementation could be found.",[Xn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ci]:"Transaction processing left an account with an outstanding borrowed reference",[ci]:"Account in use",[di]:"Account loaded twice",[ui]:"Attempt to debit an account but found no record of a prior credit.",[Li]:"Transaction loads an address table account that doesn't exist",[li]:"This transaction has already been processed",[Ei]:"Blockhash not found",[Ri]:"Loader call chain is too deep",[fi]:"Transactions are currently disabled due to cluster maintenance",[wi]:"Transaction contains a duplicate instruction ($index) that is not allowed",[_i]:"Insufficient funds for fee",[zi]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ai]:"This account may not be used to pay transaction fees",[gi]:"Transaction contains an invalid account reference",[bi]:"Transaction loads an address table account with invalid data",[Pi]:"Transaction address table lookup uses an invalid index",[Ui]:"Transaction loads an address table account with an invalid owner",[xi]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Si]:"This program may not be used for executing instructions",[Fi]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[pi]:"Transaction loads a writable account that cannot be written",[ki]:"Transaction exceeded max loaded accounts data size cap",[Ti]:"Transaction requires a fee but has no signature present",[Ii]:"Attempt to load a program that does not exist",[Gi]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Wi]:"ResanitizationNeeded",[Ni]:"Transaction failed to sanitize accounts offsets correctly",[Di]:"Transaction did not pass signature verification",[yi]:"Transaction locked too many accounts",[Vi]:"Sum of account balances before and after transaction do not match",[si]:"The transaction failed with the error `$errorName`",[mi]:"Transaction version is unsupported",[Mi]:"Transaction would exceed account data limit within the block",[vi]:"Transaction would exceed total account data limit",[hi]:"Transaction would exceed max account limit within the block",[Oi]:"Transaction would exceed max Block Cost Limit",[Bi]:"Transaction would exceed max Vote Cost Limit",[_t]:"Attempted to sign a transaction with an address that is not a signer for it",[ri]:"Transaction is missing an address at index: $index.",[De]:"Transaction has no expected signers therefore it cannot be encoded",[Rt]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Re]:"Transaction does not have a blockhash lifetime",[Te]:"Transaction is not a durable nonce transaction",[at]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[st]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[dt]:"No fee payer set in CompiledTransaction",[ct]:"Could not find program address at index $index",[lt]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[Et]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[oi]:"Transaction is missing a fee payer.",[It]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ai]:"Transaction first instruction is not advance nonce account instruction.",[ii]:"Transaction with no instructions cannot be durable nonce transaction.",[Ee]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[J]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[At]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[ut]:"Transaction is missing signatures for addresses: $addresses.",[ge]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[Se]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Tt]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},y="i",h="t";function la(e,t={}){let n=Aa[e];if(n.length===0)return "";let r;function o(i){if(r[h]===2){let a=n.slice(r[y]+1,i);s.push(a in t?`${t[a]}`:`$${a}`);}else r[h]===1&&s.push(n.slice(r[y],i));}let s=[];return n.split("").forEach((i,a)=>{if(a===0){r={[y]:0,[h]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[h]){case 0:c={[y]:a,[h]:1};break;case 1:i==="\\"?c={[y]:a,[h]:0}:i==="$"&&(c={[y]:a,[h]:2});break;case 2:i==="\\"?c={[y]:a,[h]:0}:i==="$"?c={[y]:a,[h]:2}:i.match(/\w/)||(c={[y]:a,[h]:1});break}c&&(r!==c&&o(a),r=c);}),o(),s.join("")}function Ea(e,t={}){if(process.env.NODE_ENV!=="production")return la(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${_a(t)}'`),`${n}\``}}var I=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([s,i])=>{s==="cause"?r={cause:i.value}:(n===void 0&&(n={}),Object.defineProperty(n,s,i));});let o=Ea(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Ra(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Ta=(e,t)=>Ra(e.length<=t?e:e.slice(0,t),t);function b(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function A(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(b(t,e));return e.write(t,n,0),n}})}function P(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function O(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function ga(e){return !O(e)}function vt(e,t,n=0){if(t.length-n<=0)throw new I(Ne,{codecDescription:e})}function Q(e,t,n,r=0){let o=n.length-r;if(o<t)throw new I(fe,{bytesLength:o,codecDescription:e,expected:t})}function wt(e,t){let n=(i,a,c)=>{let d=e.encode(i);return c=t.write(d.length,a,c),a.set(d,c),c+d.length};if(O(t)&&O(e))return A({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=O(t)?t.fixedSize:t.maxSize??null,o=O(e)?e.fixedSize:e.maxSize??null,s=r!==null&&o!==null?r+o:null;return A({...e,...s!==null?{maxSize:s}:{},getSizeFromValue:i=>{let a=b(i,e);return b(a,t)+a},write:n})}function x(e,t){return A({fixedSize:t,write:(n,r,o)=>{let s=e.encode(n),i=s.length>t?s.slice(0,t):s;return r.set(i,o),o+t}})}function j(e,t){return P({fixedSize:t,read:(n,r)=>{Q("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),O(e)&&(n=Ta(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function m(e,t){return A({...ga(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function Da(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new I(X,{alphabet:e,base:e.length,value:n})}var Sa=e=>A({getSizeFromValue:t=>{let[n,r]=zt(t,e[0]);if(!r)return t.length;let o=kt(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Da(e,t),t==="")return r;let[o,s]=zt(t,e[0]);if(!s)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=kt(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...a];return n.set(c,r),r+c.length}}),Na=e=>P({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let s=e[0].repeat(o);if(o===r.length)return [s,t.length];let i=r.slice(o).reduce((c,d)=>c*256n+BigInt(d),0n),a=fa(i,e);return [s+a,t.length]}});function zt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function kt(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function fa(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var xt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ee=()=>Sa(xt),C=()=>Na(xt);var te=()=>P({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var pe,he;function Me(){return pe||(pe=ee()),pe}function Oa(){return he||(he=C()),he}function Wt(e){if(e.length<32||e.length>44)return false;let t=Me();try{return t.encode(e).byteLength===32}catch{return false}}function ye(e){if(e.length<32||e.length>44)throw new I(le,{actualLength:e.length});let r=Me().encode(e).byteLength;if(r!==32)throw new I(Ae,{actualLength:r})}function S(e){return ye(e),e}function W(){return m(x(Me(),32),e=>S(e))}function F(){return j(Oa(),32)}function ne(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}function Gt(e,t,n,r){if(r<t||r>n)throw new I(Oe,{codecDescription:e,max:n,min:t,value:r})}function Vt(e){return e?.endian!==1}function Le(e){return A({fixedSize:e.size,write(t,n,r){e.range&&Gt(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,Vt(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function ma(e){return P({fixedSize:e.size,read(t,n=0){vt(e.name,t,n),Q(e.name,e.size,t,n);let r=new DataView(pa(t,n,e.size));return [e.get(r,Vt(e.config)),n+e.size]}})}function pa(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var L=()=>A({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{Gt("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let s=Number(e)>>o*7;if(s===0)break;let i=127&s;r[o]=i,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var re=(e={})=>Le({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4});var oe=(e={})=>Le({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),Ue=(e={})=>ma({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var U=()=>Le({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1});function ya(e,t,n){if(t!==n)throw new I(Ce,{actual:n,codecDescription:e,expected:t})}function La(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function Ht(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function Xt(e){return O(e)?e.fixedSize:null}function Pe(e){return O(e)?e.fixedSize:e.maxSize??null}function B(e,t={}){let n=t.size??re(),r=Kt(n,Xt(e)),o=Kt(n,Pe(e))??void 0;return A({...r!==null?{fixedSize:r}:{getSizeFromValue:s=>(typeof n=="object"?b(s.length,n):0)+[...s].reduce((a,c)=>a+b(c,e),0),maxSize:o},write:(s,i,a)=>(typeof n=="number"&&ya("array",n,s.length),typeof n=="object"&&(a=n.write(s.length,i,a)),s.forEach(c=>{a=e.write(c,i,a);}),a)})}function Kt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function Z(){return A({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}function jt(e){return A({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function Zt(e,t){let n=Ua(e),r=(s,i,a)=>{let c=t(s);return Yt(e,c),e[c].write(s,i,a)};if(n!==null)return A({fixedSize:n,write:r});let o=ba(e);return A({...o!==null?{maxSize:o}:{},getSizeFromValue:s=>{let i=t(s);return Yt(e,i),b(s,e[i])},write:r})}function Yt(e,t){if(typeof e[t]>"u")throw new I(me,{maxRange:e.length-1,minRange:0,variant:t})}function Ua(e){if(e.length===0)return 0;if(!O(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>O(r)&&r.fixedSize===t)?t:null}function ba(e){return La(e.map(t=>Pe(t)))}function p(e){let t=e.map(([,o])=>o),n=Ht(t.map(Xt)),r=Ht(t.map(Pe))??void 0;return A({...n===null?{getSizeFromValue:o=>e.map(([s,i])=>b(o[s],i)).reduce((s,i)=>s+i,0),maxSize:r}:{fixedSize:n},write:(o,s,i)=>(e.forEach(([a,c])=>{i=c.write(o[a],s,i);}),i)})}function Fe(e,...t){return t.reduce((n,r)=>r(n),e)}var v=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(v||{});var Pa=1;function w(e){return e>=2}function H(e){return (e&Pa)!==0}function Be(e,t){return e|t}function qt(e){return Wt(e)}function Jt(){return F()}function an(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&qt(e.lifetimeConstraint.blockhash)}function sn(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 wa(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new I(X,{alphabet:e,base:e.length,value:n})}var za=e=>A({getSizeFromValue:t=>{let[n,r]=Qt(t,e[0]);if(!r)return t.length;let o=en(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(wa(e,t),t==="")return r;let[o,s]=Qt(t,e[0]);if(!s)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=en(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...a];return n.set(c,r),r+c.length}});function Qt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function en(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var ka="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xa=()=>za(ka);var ve;function Wa(){if(!ve){let e=B(U(),{size:L()});ve=p([["lookupTableAddress",W()],["writableIndexes",e],["readonlyIndexes",e]]);}return ve}var we;function ze(){return we||(we=U()),we}function Ga(){return p([["numSignerAccounts",ze()],["numReadonlySignerAccounts",ze()],["numReadonlyNonSignerAccounts",ze()]])}var ke;function Va(){return ke||(ke=m(p([["programAddressIndex",U()],["accountIndices",B(U(),{size:L()})],["data",wt(Z(),L())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),ke}var Ha=0,Ka=128;function Ya(){return A({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new I(ge,{actualVersion:e});if(e>Ha)throw new I(Se,{unsupportedVersion:e});return t.set([e|Ka],n),n+1}})}function tn(){return p(cn())}function nn(){return m(p([...cn(),["addressTableLookups",$a()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function cn(){let e=Zt([jt(new Uint8Array(32)),x(xa(),32)],t=>t===void 0?0:1);return [["version",Ya()],["header",Ga()],["staticAccounts",B(W(),{size:L()})],["lifetimeToken",e],["instructions",B(Va(),{size:L()})]]}function $a(){return B(Wa(),{size:L()})}function dn(){return A({getSizeFromValue:e=>e.version==="legacy"?tn().getSizeFromValue(e):nn().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?tn().write(e,t,n):nn().write(e,t,n)})}function rn(e,t,n){e[t]=n(e[t]??{role:v.READONLY});}var l=Symbol("AddressMapTypeProperty");function Xa(e,t){let n={[e]:{[l]:0,role:v.WRITABLE_SIGNER}},r=new Set;for(let o of t){rn(n,o.programAddress,i=>{if(r.add(o.programAddress),l in i){if(H(i.role))switch(i[l]){case 0:throw new I(Ee,{programAddress:o.programAddress});default:throw new I(J,{programAddress:o.programAddress})}if(i[l]===2)return i}return {[l]:2,role:v.READONLY}});let s;if(o.accounts)for(let i of o.accounts)rn(n,i.address,a=>{let{address:c,...d}=i;if(l in a)switch(a[l]){case 0:return a;case 1:{let u=Be(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(s||=ne())(d.lookupTableAddress,a.lookupTableAddress)<0)return {[l]:1,...d,role:u}}else if(w(d.role))return {[l]:2,role:u};return a.role!==u?{...a,role:u}:a}case 2:{let u=Be(a.role,d.role);if(r.has(i.address)){if(H(d.role))throw new I(J,{programAddress:i.address});return a.role!==u?{...a,role:u}:a}else return "lookupTableAddress"in d&&!w(a.role)?{...d,[l]:1,role:u}:a.role!==u?{...a,role:u}:a}}return "lookupTableAddress"in d?{...d,[l]:1}:{...d,[l]:2}});}return n}function ja(e){let t;return Object.entries(e).sort(([r,o],[s,i])=>{if(o[l]!==i[l]){if(o[l]===0)return -1;if(i[l]===0)return 1;if(o[l]===2)return -1;if(i[l]===2)return 1}let a=w(o.role);if(a!==w(i.role))return a?-1:1;let c=H(o.role);return c!==H(i.role)?c?-1:1:(t||=ne(),o[l]===1&&i[l]===1&&o.lookupTableAddress!==i.lookupTableAddress?t(o.lookupTableAddress,i.lookupTableAddress):t(r,s))}).map(([r,o])=>({address:r,...o}))}function Za(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===v.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(ne()).map(n=>({lookupTableAddress:n,...t[n]}))}function qa(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let s=H(o.role);w(o.role)?(r++,s||n++):s||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Ja(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function Qa(e,t){let n=Ja(t);return e.map(({accounts:r,data:o,programAddress:s})=>({programAddressIndex:n[s],...r?{accountIndices:r.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function es(e){return "nonce"in e?e.nonce:e.blockhash}function ts(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function un(e){let t=Xa(e.feePayer.address,e.instructions),n=ja(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:Za(n)}:null,...r?{lifetimeToken:es(r)}:null,header:qa(n),instructions:Qa(e.instructions,n),staticAccounts:ts(n),version:e.version}}function ns(e,t,n){for(let[r,o]of Object.entries(n))for(let s=0;s<o.length;s++)if(e===o[s])return {address:e,addressIndex:s,lookupTableAddress:r,role:t}}function In(e,t){let n=new Set(e.instructions.map(i=>i.programAddress)),r=new Set(Object.values(t).flatMap(i=>i).filter(i=>!n.has(i))),o=[],s=false;for(let i of e.instructions){if(!i.accounts){o.push(i);continue}let a=[],c=false;for(let d of i.accounts){if("lookupTableAddress"in d||!r.has(d.address)||w(d.role)){a.push(d);continue}let u=ns(d.address,d.role,t);a.push(Object.freeze(u)),c=true,s=true;}o.push(Object.freeze(c?{...i,accounts:a}:i));}return Object.freeze(s?{...e,instructions:o}:e)}function _n(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var rs="SysvarRecentB1ockHashes11111111111111111111",os="11111111111111111111111111111111";function is(e){return e.programAddress===os&&e.data!=null&&as(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===v.WRITABLE&&e.accounts[1].address===rs&&e.accounts[1].role===v.READONLY&&e.accounts[2].address!=null&&w(e.accounts[2].role)}function as(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function xe(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&is(e.instructions[0])}function An(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function ln(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function ss(e){let t=Object.values(e);if(t.length===0)throw new I(De);return t.map(n=>n||new Uint8Array(64).fill(0))}function cs(){return m(B(x(Z(),64),{size:L()}),ss)}function We(){return p([["signatures",cs()],["messageBytes",Z()]])}function Ge(e){let t=un(e),n=dn().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let i of r)o[i]=null;let s;return an(e)?s={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:xe(e)&&(s={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...s?{lifetimeConstraint:s}:void 0,messageBytes:n,signatures:Object.freeze(o)})}function Ve(e){let t=We().encode(e);return te().decode(t)}function En(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}function Rn(e){return Object.freeze({address:e,signMessages:n=>Promise.resolve(n.map(()=>Object.freeze({}))),signTransactions:n=>Promise.resolve(n.map(()=>Object.freeze({})))})}var ie="ComputeBudget111111111111111111111111111111";var He=2;function Ke(){return m(p([["discriminator",U()],["units",re()]]),e=>({...e,discriminator:He}))}function ae(e,t){let n=ie,r={...e};return Object.freeze({data:Ke().encode(r),programAddress:n})}var Ye=3;function $e(){return m(p([["discriminator",U()],["microLamports",oe()]]),e=>({...e,discriminator:Ye}))}function se(e,t){let n=ie,r={...e};return Object.freeze({data:$e().encode(r),programAddress:n})}var K="11111111111111111111111111111111";var Tn=0,gn=1,Dn=2,Sn=3,Nn=4,fn=5,Cn=6,On=7,mn=8;process.env.NODE_ENV!=="production"&&({[Tn]:"an account with the same address already exists",[fn]:"provided address does not match addressed derived from seed",[Sn]:"cannot allocate account data of this length",[Dn]:"cannot assign account to this program id",[Nn]:"length of requested seed is too long",[On]:"stored nonce is still in recent_blockhashes",[Cn]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[mn]:"specified nonce does not match stored nonce",[gn]:"account does not have enough SOL to perform the operation"});var Xe="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";var ce="https://auth.revibase.com",Y="https://api.revibase.com",pn="revibase.com",hn="Gq6VZLi2aNSxB4Ag7L1NKDfuCgNZgUuxy1B8yW28PdEp";function Mn(e){let t=`${e.domain} wants you to sign in with your account.`,n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length&&(t+=`
6
6
 
7
7
  ${n.join(`
8
- `)}`),t}async function w(e,t){let n;if(e.data.payload.additionalInfo.settingsIndexWithAddress)n=e.data.payload.additionalInfo.settingsIndexWithAddress;else {let r=await fetchUserAccountData(new Secp256r1Key(e.data.payload.signer),e.data.payload.userAddressTreeIndex,t);if(r.delegatedTo.__option==="None")throw Error("User has no delegated wallet");n=r.delegatedTo.value;}return n}function pn(e,t){let n=be(dn({version:0}),o=>un(e,o),o=>_n(An(P().decode(crypto.getRandomValues(new Uint8Array(32)))),o),o=>rn({blockhash:jt().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)},o),o=>t?cn(o,t):o,o=>In([ce({units:8e5}),de({microLamports:1e3})],o),o=>xe(o)),r=We(n).length;return console.log("Estimated Tx Size: ",r),r>1644*.7}async function hn(e=getJitoTipsConfig()){let{getJitoTipsUrl:t,priority:n}=e,o=await(await fetch(t)).json();return Math.round(o[0][n]*10**9)}function z(){return {[D(On)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT","nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148","amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2","aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","6MZszp7ihPjUeoi8RJs9NNC4jBxi7beiqvXHJhxd7fe","smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho","nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X","smt3AFtReRGVcrP11D6bSLEaKdUmrGfaTNowMVccJeu","nfq3de4qt9d3wHxXWy1wcge3EXhid25mCr12bNWFdtV","smt4vjXvdjDFzvRMUxwTWnSy4c7cKkMaHuPrGsdDH7V","nfq4Ncp1vk3mFnCQ9cvwidp9k2L6fxEyCo2nerYD25A","smt5uPaQT9n6b1qAkgyonmzRxtuazA53Rddwntqistc","nfq5b5xEguPtdD6uPetZduyrB5EUqad7gcUE46rALau","smt6ukQDSPPYHSshQovmiRUjG9jGFq2hW9vgrDFk5Yz","nfq6uzaNZ5n3EWF4t64M93AWzLGt5dXTikEA9fFRktv","smt7onMFkvi3RbyhQCMajudYQkB1afAFt9CDXBQTLz6","nfq7yytdKkkLabu1KpvLsa5VPkvCT4jPWus5Yi74HTH","smt8TYxNy8SuhAdKJ8CeLtDkr2w6dgDmdz5ruiDw9Y9","nfq8vExDykci3VUSpj9R1totVst87hJfFWevNK4hiFb","smt9ReAYRF5eFjTd5gBJMn5aKwNRcmp3ub2CQr2vW7j","nfq9KFpNQL45ppP6ZG7zBpUeN18LZrNGkKyvV1kjTX2","smtAvYA5UbTRyKAkAj5kHs1CmrA42t6WkVLi4c6mA1f","nfqAroCRkcZBgsAJDNkptKpsSWyM6cgB9XpWNNiCEC4","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg"].map(D)}}async function TM(e,t){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let{instructions:n,signer:r,addressesByLookupTableAddress:o}=t,s=prepareTransactionMessage({payer:D(r.walletAddress),instructions:n,addressesByLookupTableAddress:o}),i=pn(n,o),a=await getSettingsFromIndex(r.settingsIndexWithAddress.index),c=window.origin,d={transactionActionType:i?r.hasTxManager?"execute":"create_with_preauthorized_execution":"sync",transactionAddress:a,transactionMessageBytes:bufferToBase64URLString(new Uint8Array(s))},u={phase:"start",data:{type:"transaction",payload:d},redirectOrigin:c,signer:r.publicKey},{signature:I}=await e.onClientAuthorizationCallback(u),l=await e.sendPayloadToProvider({payload:u,signature:I});return await e.onClientAuthorizationCallback({...l,data:{...l.data,payload:{...l.data.payload,transactionPayload:d}}})}async function fM(e,t){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let{mint:n,tokenProgram:r=Ye,amount:o,destination:s,signer:i}=t,a=window.origin,c={transactionActionType:"transfer_intent",transactionAddress:n?r:H,transactionMessageBytes:bufferToBase64URLString(new Uint8Array([...ae().encode(o),...W().encode(D(s)),...W().encode(D(n??H))]))},d={phase:"start",data:{type:"transaction",payload:c},redirectOrigin:a,signer:i},{signature:u}=await e.onClientAuthorizationCallback(d),I=await e.sendPayloadToProvider({payload:d,signature:u});return await e.onClientAuthorizationCallback({...I,data:{...I.data,payload:{...I.data.payload,transactionPayload:c}}})}function $e(e="about:blank"){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,s,i,a;if(r)o=t,s=n,i=0,a=0;else {let d=window.screenLeft??window.screenX??0,u=window.screenTop??window.screenY??0,I=window.innerWidth??document.documentElement.clientWidth??window.screen.width,l=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,s=600,a=Math.round(d+(I-o)/2),i=Math.round(u+(l-s)/2);}let c=["popup=yes",`width=${o}`,`height=${s}`,`top=${i}`,`left=${a}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}var Ln=class{pending=new Map;onClientAuthorizationCallback;providerOrigin;popUp;constructor(t){this.onClientAuthorizationCallback=t.onClientAuthorizationCallback,this.providerOrigin=t.providerOrigin??ue,this.popUp=null;}openBlankPopUp(){this.popUp=$e();}async sendPayloadToProvider({payload:t,signature:n}){if(typeof window>"u")throw new Error("Provider can only be used in a browser environment");if(this.pending.size>0)throw new Error("An authorization flow is already in progress");let r=bufferToBase64URLString(crypto.getRandomValues(new Uint8Array(16))),o=new URL(this.providerOrigin);return o.searchParams.set("rid",r),o.searchParams.set("payload",bufferToBase64URLString(new TextEncoder().encode(JSON.stringify(t)))),o.searchParams.set("sig",n),new Promise((s,i)=>{let a=setTimeout(()=>{let c=this.pending.get(r);c&&(c.cancel?c.cancel(new Error("Authentication timed out")):(this.pending.delete(r),i(new Error("Authentication timed out"))));},6e5);this.pending.set(r,{rid:r,resolve:s,reject:i,timeoutId:a}),this.openWebPopup({startUrl:o.toString(),origin:o.origin,rid:r});})}openWebPopup(t){let{startUrl:n,origin:r,rid:o}=t,s=this.pending.get(o);if(!s)return;let i=this.popUp??null,a=null,c=false,d=false,u=false,I=new AbortController,l=Date.now()+6e5,g=null,S=()=>{window.removeEventListener("message",$),I.abort(),g&&(clearTimeout(g),g=null);try{a?.close();}catch{}try{i&&!i.closed&&i.close(),this.popUp=null;}catch{}clearInterval(p);},E=A=>{c||(c=true,clearTimeout(s.timeoutId),this.pending.delete(o),S(),s.reject(A));},N=A=>{c||(c=true,clearTimeout(s.timeoutId),this.pending.delete(o),S(),s.resolve(A));};if(s.cancel=E,!i)i=$e(n);else try{i.location.href!==n&&i.location.replace(n);}catch{i.location.replace(n);}if(!i){E(new Error("Popup blocked. Please enable popups."));return}g=setTimeout(async()=>{if(c||d)return;let A=await this.pollForResult({rid:o,deadlineMs:l,signal:I.signal});c||(A.status==="complete"?N(A.payload):A.status==="error"&&E(new Error(A.error)));},1200);let p=setInterval(()=>{if(i?.closed&&!u){if(u=true,d){E(new Error("User closed the authentication window"));return}(async()=>{let A=await this.pollForResult({rid:o,deadlineMs:l,signal:I.signal});c||(A.status==="complete"?N(A.payload):A.status==="error"?E(new Error(A.error)):E(new Error("User closed the authentication window")));})().catch(()=>E(new Error("User closed the authentication window")));}},2e3),$=A=>{if(A.origin!==r||A.source!==i)return;let X=A.data;X?.type==="popup-connect"&&X.rid===o&&A.ports?.[0]&&(d=true,g&&(clearTimeout(g),g=null),a=A.ports[0],a.start(),a.onmessage=j=>{switch(j.data.type){case "popup-complete":N(j.data.payload);break;case "popup-error":E(new Error(j.data.error));break;case "popup-closed":(async()=>{let Q=await this.pollForResult({rid:o,deadlineMs:l,signal:I.signal});c||(Q.status==="complete"?N(Q.payload):Q.status==="error"?E(new Error(Q.error)):E(new Error("User closed the authentication window")));})().catch(()=>E(new Error("User closed the authentication window")));break}},window.removeEventListener("message",$));};window.addEventListener("message",$);}async pollForResult({rid:t,deadlineMs:n,signal:r}){let o=300,s=async()=>{let i=new URL(this.providerOrigin);i.pathname="/api/getResult",i.searchParams.set("rid",t);let a=await fetch(i.toString(),{method:"GET",headers:{accept:"application/json"},signal:r,cache:"no-store",credentials:"omit"});if(!a.ok)return {status:"pending"};let c=null;try{c=await a.json();}catch{return {status:"pending"}}return c?.status==="complete"?{status:"complete",payload:c.payload}:c?.status==="error"?{status:"error",error:String(c.error??"Unknown error")}:{status:"pending"}};for(;Date.now()<n;){if(r?.aborted)return {status:"error",error:"Polling aborted"};try{let c=await s();if(c.status==="complete")return {status:"complete",payload:c.payload};if(c.status==="error")return {status:"error",error:c.error}}catch{}let i=n-Date.now(),a=Math.min(o,Math.max(0,i));await new Promise(c=>setTimeout(c,a)),o=Math.min(2e3,Math.round(o*1.4));}return {status:"timeout"}}};async function Y(e){let t=await fetch(`${e}/getRandomPayer`),{randomPayer:n}=await t.json();return {address:D(n),async signTransactions(r){let o={publicKey:n,transactions:r.map(a=>re().decode(ke().encode(a)))},i=await(await fetch(`${e}/sign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json();if("error"in i)throw new Error(i.error);return i.signatures.map(a=>({[D(n)]:ne().encode(a)}))}}}async function bn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o}=e.data.payload.transactionPayload;if(r!=="execute"&&r!=="create_with_preauthorized_execution")throw new Error("Transaction Action not allowed.");let s=createClientAuthorizationCompleteRequestChallenge(e),i=f().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(s)))),a={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:i}},c=new Map,d=await w(e,c),[u,I,l,g]=await Promise.all([n??await Y(K),fetchSettingsAccountData(d.index,d.settingsAddressTreeIndex,c),getSignedSecp256r1Key(a),hn()]),{transactionManagerAddress:S,userAddressTreeIndex:E}=retrieveTransactionManager(e.data.payload.signer,I),N=await getSignedTransactionManager({authResponses:[a],transactionManagerAddress:S,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),userAddressTreeIndex:E,cachedAccounts:c}),k=await prepareTransactionBundle({compressed:I.isCompressed,index:d.index,settingsAddressTreeIndex:d.settingsAddressTreeIndex,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),creator:N??l,executor:N?l:void 0,jitoBundlesTipAmount:g,payer:u,cachedAccounts:c});return signAndSendBundledTransactions(k.map(p=>({...p,addressesByLookupTableAddress:p.addressesByLookupTableAddress?{...p.addressesByLookupTableAddress,...z()}:z()})))}async function Pn(e,t=ue,n=Cn){let{payload:r}=e.data,o=r.message,s=createMessageChallenge(o,r.clientSignature.clientOrigin,r.deviceSignature.publicKey,r.nonce),{verified:i}=await verifyAuthenticationResponse({response:r.authResponse,expectedChallenge:bufferToBase64URLString(s),expectedRPID:n,expectedOrigin:t,requireUserVerification:false,credential:{counter:0,id:r.authResponse.id,publicKey:convertPubkeyCompressedToCose(r.signer)}});if(!i)throw new Error("Unable to verify message");let a=await w(e),c=await getWalletAddressFromIndex(a.index),u=(await fetchSettingsAccountData(a.index,a.settingsAddressTreeIndex)).members.some(l=>l.role===UserRole.TransactionManager);return {publicKey:r.signer,walletAddress:c,settingsIndexWithAddress:a,hasTxManager:u,...r.additionalInfo}}async function Bn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o}=e.data.payload.transactionPayload;if(r!=="sync")throw new Error("Transaction Action not allowed.");let s=createClientAuthorizationCompleteRequestChallenge(e),i=f().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(s)))),a={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:i}},c=new Map,d=await w(e,c),[u,I,l]=await Promise.all([n??await Y(K),fetchSettingsAccountData(d.index,d.settingsAddressTreeIndex,c),getSignedSecp256r1Key(a)]),{transactionManagerAddress:g,userAddressTreeIndex:S}=retrieveTransactionManager(e.data.payload.signer,I),E=await getSignedTransactionManager({authResponses:[a],transactionManagerAddress:g,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),userAddressTreeIndex:S,cachedAccounts:c}),N=E?[l,E]:[l],{instructions:k,addressesByLookupTableAddress:p}=await prepareTransactionSync({compressed:I.isCompressed,signers:N,payer:u,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),index:d.index,settingsAddressTreeIndex:d.settingsAddressTreeIndex,cachedAccounts:c});return signAndSendTransaction({instructions:k,payer:u,addressesByLookupTableAddress:p?{...p,...z()}:z()})}async function vn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o,transactionAddress:s}=e.data.payload.transactionPayload;if(r!=="transfer_intent")throw new Error("Transaction Action not allowed.");let i=createClientAuthorizationCompleteRequestChallenge(e),a=f().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(i)))),c={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:a}},d=new Uint8Array(base64URLStringToBuffer(o)),u=ye().decode(d.slice(0,8)),I=P().decode(d.slice(8,40)),l=P().decode(d.slice(40,72)),g=new Map,S=await w(e,g),[E,N,k]=await Promise.all([n??await Y(K),fetchSettingsAccountData(S.index,S.settingsAddressTreeIndex,g),getSignedSecp256r1Key(c)]),{transactionManagerAddress:p,userAddressTreeIndex:$}=retrieveTransactionManager(e.data.payload.signer,N),A=await getSignedTransactionManager({authResponses:[c],transactionManagerAddress:p,userAddressTreeIndex:$,cachedAccounts:g}),X=A?[k,A]:[k],j=l!==H?await tokenTransferIntent({payer:E,index:S.index,settingsAddressTreeIndex:S.settingsAddressTreeIndex,amount:u,signers:X,destination:I,mint:l,tokenProgram:D(s),compressed:N.isCompressed,cachedAccounts:g}):await nativeTransferIntent({payer:E,index:S.index,settingsAddressTreeIndex:S.settingsAddressTreeIndex,amount:u,signers:X,destination:I,compressed:N.isCompressed,cachedAccounts:g});return signAndSendTransaction({instructions:j,payer:E,addressesByLookupTableAddress:z()})}async function ly(e,t,n,r,o){if(e.phase==="start"){let{data:i}=e;if(i.type==="message"){let a=i.payload??mn({domain:"your_website_name",nonce:crypto.randomUUID()}),c=createClientAuthorizationStartRequestChallenge({...e,data:{...i,payload:a}});return {signature:f().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(c)))),message:a}}else {let a=createClientAuthorizationStartRequestChallenge(e);return {signature:f().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(a))))}}}if(e.data.type==="message")return {user:await Pn({data:e.data},r,o)};let{transactionActionType:s}=e.data.payload.transactionPayload;if(s==="transfer_intent")return {txSig:await vn({phase:"complete",data:e.data},t,n)};if(s==="sync")return {txSig:await Bn({phase:"complete",data:e.data},t,n)};if(s==="execute"||s==="create_with_preauthorized_execution")return {txSig:await bn({phase:"complete",data:e.data},t,n)};throw new Error("Transaction action type not allowed.")}export{Ln as RevibaseProvider,TM as executeTransaction,Y as getRandomPayer,ly as processClientAuthCallback,vc as signIn,fM as transferTokens};//# sourceMappingURL=index.js.map
8
+ `)}`),t}async function z(e,t){let n;if(e.data.payload.additionalInfo.settingsIndexWithAddress)n=e.data.payload.additionalInfo.settingsIndexWithAddress;else {let r=await fetchUserAccountData(new Secp256r1Key(e.data.payload.signer),e.data.payload.userAddressTreeIndex,t);if(r.delegatedTo.__option==="None")throw Error("User has no delegated wallet");n=r.delegatedTo.value;}return n}function yn(e,t){let n=Fe(_n({version:0}),o=>An(e,o),o=>En(Rn(F().decode(crypto.getRandomValues(new Uint8Array(32)))),o),o=>sn({blockhash:Jt().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)},o),o=>t?In(o,t):o,o=>ln([ae({units:8e5}),se({microLamports:1e3})],o),o=>Ge(o)),r=Ve(n).length;return console.log("Estimated Tx Size: ",r),r>1644*.7}async function Ln(e=getJitoTipsConfig()){let{getJitoTipsUrl:t,priority:n}=e,o=await(await fetch(t)).json();return Math.round(o[0][n]*10**9)}function k(){return {[S(hn)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT","nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148","amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2","aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","6MZszp7ihPjUeoi8RJs9NNC4jBxi7beiqvXHJhxd7fe","smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho","nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X","smt3AFtReRGVcrP11D6bSLEaKdUmrGfaTNowMVccJeu","nfq3de4qt9d3wHxXWy1wcge3EXhid25mCr12bNWFdtV","smt4vjXvdjDFzvRMUxwTWnSy4c7cKkMaHuPrGsdDH7V","nfq4Ncp1vk3mFnCQ9cvwidp9k2L6fxEyCo2nerYD25A","smt5uPaQT9n6b1qAkgyonmzRxtuazA53Rddwntqistc","nfq5b5xEguPtdD6uPetZduyrB5EUqad7gcUE46rALau","smt6ukQDSPPYHSshQovmiRUjG9jGFq2hW9vgrDFk5Yz","nfq6uzaNZ5n3EWF4t64M93AWzLGt5dXTikEA9fFRktv","smt7onMFkvi3RbyhQCMajudYQkB1afAFt9CDXBQTLz6","nfq7yytdKkkLabu1KpvLsa5VPkvCT4jPWus5Yi74HTH","smt8TYxNy8SuhAdKJ8CeLtDkr2w6dgDmdz5ruiDw9Y9","nfq8vExDykci3VUSpj9R1totVst87hJfFWevNK4hiFb","smt9ReAYRF5eFjTd5gBJMn5aKwNRcmp3ub2CQr2vW7j","nfq9KFpNQL45ppP6ZG7zBpUeN18LZrNGkKyvV1kjTX2","smtAvYA5UbTRyKAkAj5kHs1CmrA42t6WkVLi4c6mA1f","nfqAroCRkcZBgsAJDNkptKpsSWyM6cgB9XpWNNiCEC4","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg"].map(S)}}async function NM(e,t){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let{instructions:n,signer:r,addressesByLookupTableAddress:o}=t,s=prepareTransactionMessage({payer:S(r.walletAddress),instructions:n,addressesByLookupTableAddress:o}),i=yn(n,o),a=await getSettingsFromIndex(r.settingsIndexWithAddress.index),c=window.origin,d={transactionActionType:i?r.hasTxManager?"execute":"create_with_preauthorized_execution":"sync",transactionAddress:a,transactionMessageBytes:bufferToBase64URLString(new Uint8Array(s))},u={phase:"start",data:{type:"transaction",payload:d},redirectOrigin:c,signer:r.publicKey},{signature:_}=await e.onClientAuthorizationCallback(u),E=await e.sendPayloadToProvider({payload:u,signature:_});return await e.onClientAuthorizationCallback({...E,data:{...E.data,payload:{...E.data.payload,transactionPayload:d}}})}async function pM(e,t){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");e.openBlankPopUp();let{mint:n,tokenProgram:r=Xe,amount:o,destination:s,signer:i}=t,a=window.origin,c={transactionActionType:"transfer_intent",transactionAddress:n?r:K,transactionMessageBytes:bufferToBase64URLString(new Uint8Array([...oe().encode(o),...W().encode(S(s)),...W().encode(S(n??K))]))},d={phase:"start",data:{type:"transaction",payload:c},redirectOrigin:a,signer:i},{signature:u}=await e.onClientAuthorizationCallback(d),_=await e.sendPayloadToProvider({payload:d,signature:u});return await e.onClientAuthorizationCallback({..._,data:{..._.data,payload:{..._.data.payload,transactionPayload:c}}})}function je(e="about:blank"){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,s,i,a;if(r)o=t,s=n,i=0,a=0;else {let d=window.screenLeft??window.screenX??0,u=window.screenTop??window.screenY??0,_=window.innerWidth??document.documentElement.clientWidth??window.screen.width,E=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,s=600,a=Math.round(d+(_-o)/2),i=Math.round(u+(E-s)/2);}let c=["popup=yes",`width=${o}`,`height=${s}`,`top=${i}`,`left=${a}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}var bn=class{pending=new Map;onClientAuthorizationCallback;providerOrigin;popUp;constructor(t){this.onClientAuthorizationCallback=t.onClientAuthorizationCallback,this.providerOrigin=t.providerOrigin??ce,this.popUp=null;}openBlankPopUp(){this.popUp=je("about:blank");}async sendPayloadToProvider({payload:t,signature:n,timeoutMs:r=3e5}){if(typeof window>"u")throw new Error("Provider can only be used in a browser environment");if(this.pending.size>0)throw new Error("An authorization flow is already in progress");let o=bufferToBase64URLString(crypto.getRandomValues(new Uint8Array(16))),s=new URL(this.providerOrigin);return s.searchParams.set("rid",o),s.searchParams.set("payload",bufferToBase64URLString(new TextEncoder().encode(JSON.stringify(t)))),s.searchParams.set("sig",n),new Promise((i,a)=>{let c=setTimeout(()=>{let d=this.pending.get(o);d&&(d.cancel?d.cancel(new Error("Authentication timed out")):(this.pending.delete(o),a(new Error("Authentication timed out"))));},r);this.pending.set(o,{rid:o,resolve:i,reject:a,timeoutId:c}),this.openWebPopup({startUrl:s.toString(),origin:s.origin,rid:o,timeoutMs:r});})}openWebPopup(t){let{startUrl:n,origin:r,rid:o,timeoutMs:s}=t,i=this.pending.get(o);if(!i)return;let a=this.popUp??null,c=null,d=false,u=false,_=false,E=new AbortController,g=null,N=Date.now()+s,T=null,f=()=>{try{g?.abort();}catch{}g=null;},M=()=>{window.removeEventListener("message",Ie),f();try{E.abort();}catch{}T&&(clearTimeout(T),T=null);try{c?.close();}catch{}try{a&&!a.closed&&a.close(),this.popUp=null;}catch{}clearInterval(ue);},R=D=>{d||(d=true,clearTimeout(i.timeoutId),this.pending.delete(o),M(),i.reject(D));},q=D=>{d||(d=true,clearTimeout(i.timeoutId),this.pending.delete(o),M(),i.resolve(D));};if(i.cancel=R,!a)a=je(n);else try{a.location.href!==n&&a.location.replace(n);}catch{a.location.replace(n);}if(!a){R(new Error("Popup blocked. Please enable popups."));return}let G=async()=>{if(d)return;f(),g=new AbortController;let D=await this.pollForResult({rid:o,deadlineMs:N,signal:g.signal});d||(D.status==="complete"?q(D.payload):D.status==="error"&&R(new Error(D.error)));};T=setTimeout(()=>{d||u||G().catch(()=>{});},1200);let ue=setInterval(()=>{if(a?.closed&&!_){if(_=true,u){R(new Error("User closed the authentication window"));return}G().then(()=>{d||R(new Error("User closed the authentication window"));}).catch(()=>R(new Error("User closed the authentication window")));}},2e3),Ie=D=>{if(D.origin!==r||D.source!==a)return;let Ze=D.data;Ze?.type==="popup-connect"&&Ze.rid===o&&D.ports?.[0]&&(u=true,T&&(clearTimeout(T),T=null),f(),c=D.ports[0],c.start(),c.postMessage({type:"popup-init"}),c.onmessage=_e=>{switch(_e.data.type){case "popup-complete":q(_e.data.payload);break;case "popup-error":R(new Error(_e.data.error));break;case "popup-closed":G().then(()=>{d||R(new Error("User closed the authentication window"));}).catch(()=>R(new Error("User closed the authentication window")));break}},window.removeEventListener("message",Ie));};window.addEventListener("message",Ie);}async pollForResult({rid:t,deadlineMs:n,signal:r}){let o=1e3,s=async()=>{let i=new URL(this.providerOrigin);i.pathname="/api/getResult",i.searchParams.set("rid",t);let a=await fetch(i.toString(),{method:"GET",headers:{accept:"application/json"},signal:r,cache:"no-store",credentials:"omit"});if(!a.ok)return {status:"pending"};let c=null;try{c=await a.json();}catch{return {status:"pending"}}return c?.status==="complete"?{status:"complete",payload:c.payload}:c?.status==="error"?{status:"error",error:String(c.error??"Unknown error")}:{status:"pending"}};for(;Date.now()<n;){if(r?.aborted)return {status:"error",error:"Polling aborted"};try{let c=await s();if(c.status==="complete"||c.status==="error")return c}catch{}let i=n-Date.now(),a=Math.min(o,Math.max(0,i));await new Promise(c=>setTimeout(c,dc(a))),o=Math.min(4e3,Math.round(o*1.7));}return {status:"timeout"}}};function dc(e,t=.3){let n=e*t,r=e+(Math.random()*2-1)*n;return Math.max(0,Math.round(r))}async function $(e){let t=await fetch(`${e}/getRandomPayer`),{randomPayer:n}=await t.json();return {address:S(n),async signTransactions(r){let o={publicKey:n,transactions:r.map(a=>te().decode(We().encode(a)))},i=await(await fetch(`${e}/sign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json();if("error"in i)throw new Error(i.error);return i.signatures.map(a=>({[S(n)]:ee().encode(a)}))}}}async function Fn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o}=e.data.payload.transactionPayload;if(r!=="execute"&&r!=="create_with_preauthorized_execution")throw new Error("Transaction Action not allowed.");let s=createClientAuthorizationCompleteRequestChallenge(e),i=C().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(s)))),a={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:i}},c=new Map,d=await z(e,c),[u,_,E,g]=await Promise.all([n??await $(Y),fetchSettingsAccountData(d.index,d.settingsAddressTreeIndex,c),getSignedSecp256r1Key(a),Ln()]),{transactionManagerAddress:N,userAddressTreeIndex:T}=retrieveTransactionManager(e.data.payload.signer,_),f=await getSignedTransactionManager({authResponses:[a],transactionManagerAddress:N,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),userAddressTreeIndex:T,cachedAccounts:c}),M=await prepareTransactionBundle({compressed:_.isCompressed,index:d.index,settingsAddressTreeIndex:d.settingsAddressTreeIndex,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),creator:f??E,executor:f?E:void 0,jitoBundlesTipAmount:g,payer:u,cachedAccounts:c});return signAndSendBundledTransactions(M.map(R=>({...R,addressesByLookupTableAddress:R.addressesByLookupTableAddress?{...R.addressesByLookupTableAddress,...k()}:k()})))}async function Bn(e,t=ce,n=pn){let{payload:r}=e.data,o=r.message,s=createMessageChallenge(o,r.clientSignature.clientOrigin,r.deviceSignature.publicKey,r.nonce),{verified:i}=await verifyAuthenticationResponse({response:r.authResponse,expectedChallenge:bufferToBase64URLString(s),expectedRPID:n,expectedOrigin:t,requireUserVerification:false,credential:{counter:0,id:r.authResponse.id,publicKey:convertPubkeyCompressedToCose(r.signer)}});if(!i)throw new Error("Unable to verify message");let a=await z(e),c=await getWalletAddressFromIndex(a.index),u=(await fetchSettingsAccountData(a.index,a.settingsAddressTreeIndex)).members.some(E=>E.role===UserRole.TransactionManager);return {publicKey:r.signer,walletAddress:c,settingsIndexWithAddress:a,hasTxManager:u,...r.additionalInfo}}async function wn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o}=e.data.payload.transactionPayload;if(r!=="sync")throw new Error("Transaction Action not allowed.");let s=createClientAuthorizationCompleteRequestChallenge(e),i=C().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(s)))),a={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:i}},c=new Map,d=await z(e,c),[u,_,E]=await Promise.all([n??await $(Y),fetchSettingsAccountData(d.index,d.settingsAddressTreeIndex,c),getSignedSecp256r1Key(a)]),{transactionManagerAddress:g,userAddressTreeIndex:N}=retrieveTransactionManager(e.data.payload.signer,_),T=await getSignedTransactionManager({authResponses:[a],transactionManagerAddress:g,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),userAddressTreeIndex:N,cachedAccounts:c}),f=T?[E,T]:[E],{instructions:M,addressesByLookupTableAddress:R}=await prepareTransactionSync({compressed:_.isCompressed,signers:f,payer:u,transactionMessageBytes:new Uint8Array(base64URLStringToBuffer(o)),index:d.index,settingsAddressTreeIndex:d.settingsAddressTreeIndex,cachedAccounts:c});return signAndSendTransaction({instructions:M,payer:u,addressesByLookupTableAddress:R?{...R,...k()}:k()})}async function zn(e,t,n){let{transactionActionType:r,transactionMessageBytes:o,transactionAddress:s}=e.data.payload.transactionPayload;if(r!=="transfer_intent")throw new Error("Transaction Action not allowed.");let i=createClientAuthorizationCompleteRequestChallenge(e),a=C().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(i)))),c={...e.data.payload,clientSignature:{...e.data.payload.clientSignature,signature:a}},d=new Uint8Array(base64URLStringToBuffer(o)),u=Ue().decode(d.slice(0,8)),_=F().decode(d.slice(8,40)),E=F().decode(d.slice(40,72)),g=new Map,N=await z(e,g),[T,f,M]=await Promise.all([n??await $(Y),fetchSettingsAccountData(N.index,N.settingsAddressTreeIndex,g),getSignedSecp256r1Key(c)]),{transactionManagerAddress:R,userAddressTreeIndex:q}=retrieveTransactionManager(e.data.payload.signer,f),G=await getSignedTransactionManager({authResponses:[c],transactionManagerAddress:R,userAddressTreeIndex:q,cachedAccounts:g}),de=G?[M,G]:[M],ue=E!==K?await tokenTransferIntent({payer:T,index:N.index,settingsAddressTreeIndex:N.settingsAddressTreeIndex,amount:u,signers:de,destination:_,mint:E,tokenProgram:S(s),compressed:f.isCompressed,cachedAccounts:g}):await nativeTransferIntent({payer:T,index:N.index,settingsAddressTreeIndex:N.settingsAddressTreeIndex,amount:u,signers:de,destination:_,compressed:f.isCompressed,cachedAccounts:g});return signAndSendTransaction({instructions:ue,payer:T,addressesByLookupTableAddress:k()})}async function gy(e,t,n,r,o){if(e.phase==="start"){let{data:i}=e;if(i.type==="message"){let a=i.payload??Mn({domain:"your_website_name",nonce:crypto.randomUUID()}),c=createClientAuthorizationStartRequestChallenge({...e,data:{...i,payload:a}});return {signature:C().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(c)))),message:a}}else {let a=createClientAuthorizationStartRequestChallenge(e);return {signature:C().decode(new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},t,new Uint8Array(a))))}}}if(e.data.type==="message")return {user:await Bn({data:e.data},r,o)};let{transactionActionType:s}=e.data.payload.transactionPayload;if(s==="transfer_intent")return {txSig:await zn({phase:"complete",data:e.data},t,n)};if(s==="sync")return {txSig:await wn({phase:"complete",data:e.data},t,n)};if(s==="execute"||s==="create_with_preauthorized_execution")return {txSig:await Fn({phase:"complete",data:e.data},t,n)};throw new Error("Transaction action type not allowed.")}export{bn as RevibaseProvider,NM as executeTransaction,$ as getRandomPayer,gy as processClientAuthCallback,xc as signIn,pM as transferTokens};//# sourceMappingURL=index.js.map
9
9
  //# sourceMappingURL=index.js.map