@revibase/lite 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,15 +1,15 @@
1
- 'use strict';var core=require('@revibase/core'),jose=require('jose'),server=require('@simplewebauthn/server'),jsonCanonicalize=require('json-canonicalize');var vo=1,Po=2,Bo=3,Fo=4,zo=5,ko=6,xo=7,Wo=8,Go=9,Vo=10,Ho=-32700,Ko=-32603,$o=-32602,jo=-32601,Yo=-32600,qo=-32019,Xo=-32018,Zo=-32017,Jo=-32016,Qo=-32015,ei=-32014,ti=-32013,ni=-32012,ri=-32011,oi=-32010,ii=-32009,ai=-32008,si=-32007,ci=-32006,di=-32005,ui=-32004,li=-32003,Ii=-32002,_i=-32001,nt=28e5,rt=2800001,Ai=2800002,Qt=2800003,en=2800004,tn=2800005,nn=2800006,rn=2800007,on=2800008,an=2800009,sn=2800010,cn=2800011,dn=323e4,ot=32300001,it=3230002,un=3230003,at=3230004,Ei=361e4,ln=3610001,In=3610002,_n=3610003,An=3610004,En=3610005,st=3610006,gi=3610007,gn=3611e3,Ri=3704e3,Ti=3704001,fi=3704002,Di=3704003,Si=3704004,pi=4128e3,mi=4128001,Ni=4128002,Ci=4615e3,Rn=4615001,Oi=4615002,hi=4615003,yi=4615004,Mi=4615005,Li=4615006,bi=4615007,Ui=4615008,wi=4615009,vi=4615010,Pi=4615011,Bi=4615012,Fi=4615013,zi=4615014,ki=4615015,xi=4615016,Wi=4615017,Gi=4615018,Vi=4615019,Hi=4615020,Ki=4615021,$i=4615022,ji=4615023,Yi=4615024,qi=4615025,Xi=4615026,Zi=4615027,Ji=4615028,Qi=4615029,ea=4615030,ta=4615031,na=4615032,ra=4615033,oa=4615034,ia=4615035,aa=4615036,sa=4615037,ca=4615038,da=4615039,ua=4615040,la=4615041,Ia=4615042,_a=4615043,Aa=4615044,Ea=4615045,ga=4615046,Ra=4615047,Ta=4615048,fa=4615049,Da=4615050,Sa=4615051,pa=4615052,ma=4615053,Na=4615054,ct=5508e3,Tn=5508001,fn=5508002,Dn=5508003,Sn=5508004,pn=5508005,mn=5508006,Nn=5508007,Cn=5508008,On=5508009,hn=5508010,Ca=5508011,dt=5663e3,Me=5663001,ut=5663002,lt=5663003,It=5663004,yn=5663005,Mn=5663006,Ln=5663007,bn=5663008,_t=5663009,Oa=5663010,ha=5663011,At=5663012,ya=5663013,Ma=5663014,Un=5663015,Et=5663016,wn=5663017,vn=5663018,Pn=5663019,Bn=5663020,gt=5663021,Fn=5663022,zn=705e4,La=7050001,ba=7050002,Ua=7050003,wa=7050004,va=7050005,Pa=7050006,Ba=7050007,Fa=7050008,za=7050009,ka=7050010,xa=7050011,Wa=7050012,Ga=7050013,Va=7050014,Ha=7050015,Ka=7050016,$a=7050017,ja=7050018,Ya=7050019,qa=7050020,Xa=7050021,Za=7050022,Ja=7050023,Qa=7050024,es=7050025,ts=7050026,ns=7050027,rs=7050028,os=7050029,is=7050030,as=7050031,ss=7050032,cs=7050033,ds=7050034,us=7050035,ls=7050036,Is=7618e3,_s=7618001,As=7618002,Es=7618003,Rt=8078e3,Tt=8078001,ft=8078002,kn=8078003,xn=8078004,Wn=8078005,Gn=8078006,Dt=8078007,Vn=8078008,Hn=8078009,Kn=8078010,St=8078011,Ae=8078012,$n=8078013,jn=8078014,Yn=8078015,qn=8078016,pt=8078017,mt=8078018,gs=8078019,Xn=8078020,Zn=8078021,Jn=8078022,Qn=8078023,Rs=81e5,Ts=8100001,fs=8100002,Ds=8100003,Ss=819e4,ps=8190001,ms=8190002,Ns=8190003,Cs=8190004,Os=99e5,hs=9900001,ys=9900002,Ms=9900003,Ls=9900004,bs=9900005,Us=9900006;function er(e){return Array.isArray(e)?"%5B"+e.map(er).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function ws([e,t]){return `${e}=${er(t)}`}function vs(e){let t=Object.entries(e).map(ws).join("&");return Buffer.from(t,"utf8").toString("base64")}var Ps={[dn]:"Account not found at address: $address",[at]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[un]:"Expected decoded account at address: $address",[it]:"Failed to decode account data at address: $address",[ot]:"Accounts not found at addresses: $addresses",[an]:"Unable to find a viable program address bump seed.",[Ai]:"$putativeAddress is not a base58-encoded address.",[nt]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Qt]:"The `CryptoKey` must be an `Ed25519` public key.",[cn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[on]:"Invalid seeds; point must fall off the Ed25519 curve.",[en]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[nn]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[rn]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[tn]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[sn]:"Program address cannot end with PDA marker.",[rt]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Fo]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[vo]:"The network has progressed past the last block for which this transaction could have been committed.",[Rt]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Jn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Xn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Wn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Gn]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[xn]:"Encoder and decoder must either both be fixed-size or variable-size.",[Vn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[ft]:"Expected a fixed-size codec, got a variable-size one.",[$n]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[kn]:"Expected a variable-size codec, got a fixed-size one.",[gs]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Tt]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[mt]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Hn]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Kn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Yn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Dt]:"Expected [$codecDescription] to have $expected items, got $actual.",[Ae]:"Invalid value $value for base $base with alphabet $alphabet.",[qn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[St]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[jn]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Zn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[pt]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Qn]:"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?",[gn]:"No random values implementation could be found.",[wi]:"instruction requires an uninitialized account",[ji]:"instruction tries to borrow reference for an account which is already borrowed",[Yi]:"instruction left account with an outstanding borrowed reference",[Ki]:"program other than the account's owner changed the size of the account data",[Mi]:"account data too small for instruction",[$i]:"instruction expected an executable account",[ga]:"An account does not have enough lamports to be rent-exempt",[Ta]:"Program arithmetic overflowed",[Ea]:"Failed to serialize or deserialize account data: $encodedData",[Na]:"Builtin programs must consume compute units",[na]:"Cross-program invocation call depth too deep",[ca]:"Computational budget exceeded",[Xi]:"custom program error: #$code",[Wi]:"instruction contains duplicate accounts",[qi]:"instruction modifications of multiply-passed account differ",[ea]:"executable accounts must be rent exempt",[Ji]:"instruction changed executable accounts data",[Qi]:"instruction changed the balance of an executable account",[Gi]:"instruction changed executable bit of an account",[zi]:"instruction modified data of an account it does not own",[Fi]:"instruction spent from the balance of an account it does not own",[Rn]:"generic instruction error",[Da]:"Provided owner is not allowed",[_a]:"Account is immutable",[Aa]:"Incorrect authority provided",[bi]:"incorrect program id for instruction",[Li]:"insufficient funds for instruction",[yi]:"invalid account data for instruction",[Ra]:"Invalid account owner",[Oi]:"invalid program argument",[Zi]:"program returned invalid error code",[hi]:"invalid instruction data",[sa]:"Failed to reallocate account data",[aa]:"Provided seeds do not result in a valid address",[Sa]:"Accounts data allocations exceeded the maximum allowed per transaction",[pa]:"Max accounts exceeded",[ma]:"Max instruction trace length exceeded",[ia]:"Length of the seed is too long for address generation",[ra]:"An account required by the instruction is missing",[Ui]:"missing required signature for instruction",[Bi]:"instruction illegally modified the program id of an account",[Hi]:"insufficient account keys for instruction",[da]:"Cross-program invocation with unauthorized signer or writable account",[ua]:"Failed to create program execution environment",[Ia]:"Program failed to compile",[la]:"Program failed to complete",[xi]:"instruction modified data of a read-only account",[ki]:"instruction changed the balance of a read-only account",[oa]:"Cross-program invocation reentrancy not allowed for this instruction",[Vi]:"instruction modified rent epoch of an account",[Pi]:"sum of account balances before and after instruction do not match",[vi]:"instruction requires an initialized account",[Ci]:"",[ta]:"Unsupported program id",[fa]:"Unsupported sysvar",[bs]:"Invalid instruction plan kind: $kind.",[As]:"The provided instruction plan is empty.",[Es]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Is]:"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).",[Us]:"Invalid transaction plan kind: $kind.",[_s]:"No more instructions to pack; the message packer has completed the instruction plan.",[pi]:"The instruction does not have any accounts.",[mi]:"The instruction does not have any data.",[Ni]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[zo]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Po]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[ys]:"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",[Ls]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[hs]:"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",[Os]:"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",[Ms]:"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",[Ko]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[$o]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Yo]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[jo]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Ho]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ni]:"$__serverMessage",[_i]:"$__serverMessage",[ui]:"$__serverMessage",[ei]:"$__serverMessage",[Zo]:"Epoch rewards period still active at slot $slot",[oi]:"$__serverMessage",[ii]:"$__serverMessage",[qo]:"Failed to query long-term storage; please try again",[Jo]:"Minimum context slot has not been reached",[di]:"Node is unhealthy; behind by $numSlotsBehind slots",[ai]:"No snapshot",[Ii]:"Transaction simulation failed",[Xo]:"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",[si]:"$__serverMessage",[ri]:"Transaction history is not available from this node",[ci]:"$__serverMessage",[ti]:"Transaction signature length mismatch",[li]:"Transaction signature verification failure",[Qo]:"$__serverMessage",[Ri]:"Key pair bytes must be of length 64, got $byteLength.",[Ti]:"Expected private key bytes with length 32. Actual length: $actualLength.",[fi]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Si]:"The provided private key does not match the provided public key.",[Di]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[ko]:"Lamports value must be in the range [0, 2e64-1]",[xo]:"`$value` cannot be parsed as a `BigInt`",[Vo]:"$message",[Wo]:"`$value` cannot be parsed as a `Number`",[Bo]:"No nonce account could be found at address `$nonceAccountAddress`",[Ss]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ms]:"WebSocket was closed before payload could be added to the send buffer",[Ns]:"WebSocket connection closed",[Cs]:"WebSocket failed to connect",[ps]:"Failed to obtain a subscription id from the server",[Ds]:"Could not find an API plan for RPC method: `$method`",[Rs]:"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`.",[fs]:"HTTP error ($statusCode): $message",[Ts]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[ct]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Tn]:"The provided value does not implement the `KeyPairSigner` interface",[Dn]:"The provided value does not implement the `MessageModifyingSigner` interface",[Sn]:"The provided value does not implement the `MessagePartialSigner` interface",[fn]:"The provided value does not implement any of the `MessageSigner` interfaces",[mn]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Nn]:"The provided value does not implement the `TransactionPartialSigner` interface",[Cn]:"The provided value does not implement the `TransactionSendingSigner` interface",[pn]:"The provided value does not implement any of the `TransactionSigner` interfaces",[On]:"More than one `TransactionSendingSigner` was identified.",[hn]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Ca]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[gi]:"Cannot export a non-extractable key.",[ln]:"No digest implementation could be found.",[Ei]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[In]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ 'use strict';var core=require('@revibase/core'),jose=require('jose'),server=require('@simplewebauthn/server');var wo=1,vo=2,Po=3,Bo=4,Fo=5,zo=6,ko=7,xo=8,Wo=9,Go=10,Vo=-32700,Ho=-32603,Ko=-32602,$o=-32601,jo=-32600,Yo=-32019,qo=-32018,Xo=-32017,Zo=-32016,Jo=-32015,Qo=-32014,ei=-32013,ti=-32012,ni=-32011,ri=-32010,oi=-32009,ii=-32008,ai=-32007,si=-32006,ci=-32005,ui=-32004,di=-32003,li=-32002,Ii=-32001,tt=28e5,nt=2800001,_i=2800002,Qt=2800003,en=2800004,tn=2800005,nn=2800006,rn=2800007,on=2800008,an=2800009,sn=2800010,cn=2800011,un=323e4,rt=32300001,ot=3230002,dn=3230003,it=3230004,Ai=361e4,ln=3610001,In=3610002,_n=3610003,An=3610004,En=3610005,at=3610006,Ei=3610007,gn=3611e3,gi=3704e3,Ri=3704001,Ti=3704002,fi=3704003,Di=3704004,Si=4128e3,pi=4128001,mi=4128002,Ni=4615e3,Rn=4615001,Ci=4615002,Oi=4615003,hi=4615004,yi=4615005,Mi=4615006,Li=4615007,bi=4615008,Ui=4615009,wi=4615010,vi=4615011,Pi=4615012,Bi=4615013,Fi=4615014,zi=4615015,ki=4615016,xi=4615017,Wi=4615018,Gi=4615019,Vi=4615020,Hi=4615021,Ki=4615022,$i=4615023,ji=4615024,Yi=4615025,qi=4615026,Xi=4615027,Zi=4615028,Ji=4615029,Qi=4615030,ea=4615031,ta=4615032,na=4615033,ra=4615034,oa=4615035,ia=4615036,aa=4615037,sa=4615038,ca=4615039,ua=4615040,da=4615041,la=4615042,Ia=4615043,_a=4615044,Aa=4615045,Ea=4615046,ga=4615047,Ra=4615048,Ta=4615049,fa=4615050,Da=4615051,Sa=4615052,pa=4615053,ma=4615054,st=5508e3,Tn=5508001,fn=5508002,Dn=5508003,Sn=5508004,pn=5508005,mn=5508006,Nn=5508007,Cn=5508008,On=5508009,hn=5508010,Na=5508011,ct=5663e3,Me=5663001,ut=5663002,dt=5663003,lt=5663004,yn=5663005,Mn=5663006,Ln=5663007,bn=5663008,It=5663009,Ca=5663010,Oa=5663011,_t=5663012,ha=5663013,ya=5663014,Un=5663015,At=5663016,wn=5663017,vn=5663018,Pn=5663019,Bn=5663020,Et=5663021,Fn=5663022,zn=705e4,Ma=7050001,La=7050002,ba=7050003,Ua=7050004,wa=7050005,va=7050006,Pa=7050007,Ba=7050008,Fa=7050009,za=7050010,ka=7050011,xa=7050012,Wa=7050013,Ga=7050014,Va=7050015,Ha=7050016,Ka=7050017,$a=7050018,ja=7050019,Ya=7050020,qa=7050021,Xa=7050022,Za=7050023,Ja=7050024,Qa=7050025,es=7050026,ts=7050027,ns=7050028,rs=7050029,os=7050030,is=7050031,as=7050032,ss=7050033,cs=7050034,us=7050035,ds=7050036,ls=7618e3,Is=7618001,_s=7618002,As=7618003,gt=8078e3,Rt=8078001,Tt=8078002,kn=8078003,xn=8078004,Wn=8078005,Gn=8078006,ft=8078007,Vn=8078008,Hn=8078009,Kn=8078010,Dt=8078011,_e=8078012,$n=8078013,jn=8078014,Yn=8078015,qn=8078016,St=8078017,pt=8078018,Es=8078019,Xn=8078020,Zn=8078021,Jn=8078022,Qn=8078023,gs=81e5,Rs=8100001,Ts=8100002,fs=8100003,Ds=819e4,Ss=8190001,ps=8190002,ms=8190003,Ns=8190004,Cs=99e5,Os=9900001,hs=9900002,ys=9900003,Ms=9900004,Ls=9900005,bs=9900006;function er(e){return Array.isArray(e)?"%5B"+e.map(er).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Us([e,t]){return `${e}=${er(t)}`}function ws(e){let t=Object.entries(e).map(Us).join("&");return Buffer.from(t,"utf8").toString("base64")}var vs={[un]:"Account not found at address: $address",[it]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[dn]:"Expected decoded account at address: $address",[ot]:"Failed to decode account data at address: $address",[rt]:"Accounts not found at addresses: $addresses",[an]:"Unable to find a viable program address bump seed.",[_i]:"$putativeAddress is not a base58-encoded address.",[tt]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Qt]:"The `CryptoKey` must be an `Ed25519` public key.",[cn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[on]:"Invalid seeds; point must fall off the Ed25519 curve.",[en]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[nn]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[rn]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[tn]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[sn]:"Program address cannot end with PDA marker.",[nt]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Bo]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[wo]:"The network has progressed past the last block for which this transaction could have been committed.",[gt]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Jn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Xn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Wn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Gn]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[xn]:"Encoder and decoder must either both be fixed-size or variable-size.",[Vn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Tt]:"Expected a fixed-size codec, got a variable-size one.",[$n]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[kn]:"Expected a variable-size codec, got a fixed-size one.",[Es]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Rt]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[pt]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Hn]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Kn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Yn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ft]:"Expected [$codecDescription] to have $expected items, got $actual.",[_e]:"Invalid value $value for base $base with alphabet $alphabet.",[qn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Dt]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[jn]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Zn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[St]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Qn]:"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?",[gn]:"No random values implementation could be found.",[Ui]:"instruction requires an uninitialized account",[$i]:"instruction tries to borrow reference for an account which is already borrowed",[ji]:"instruction left account with an outstanding borrowed reference",[Hi]:"program other than the account's owner changed the size of the account data",[yi]:"account data too small for instruction",[Ki]:"instruction expected an executable account",[Ea]:"An account does not have enough lamports to be rent-exempt",[Ra]:"Program arithmetic overflowed",[Aa]:"Failed to serialize or deserialize account data: $encodedData",[ma]:"Builtin programs must consume compute units",[ta]:"Cross-program invocation call depth too deep",[sa]:"Computational budget exceeded",[qi]:"custom program error: #$code",[xi]:"instruction contains duplicate accounts",[Yi]:"instruction modifications of multiply-passed account differ",[Qi]:"executable accounts must be rent exempt",[Zi]:"instruction changed executable accounts data",[Ji]:"instruction changed the balance of an executable account",[Wi]:"instruction changed executable bit of an account",[Fi]:"instruction modified data of an account it does not own",[Bi]:"instruction spent from the balance of an account it does not own",[Rn]:"generic instruction error",[fa]:"Provided owner is not allowed",[Ia]:"Account is immutable",[_a]:"Incorrect authority provided",[Li]:"incorrect program id for instruction",[Mi]:"insufficient funds for instruction",[hi]:"invalid account data for instruction",[ga]:"Invalid account owner",[Ci]:"invalid program argument",[Xi]:"program returned invalid error code",[Oi]:"invalid instruction data",[aa]:"Failed to reallocate account data",[ia]:"Provided seeds do not result in a valid address",[Da]:"Accounts data allocations exceeded the maximum allowed per transaction",[Sa]:"Max accounts exceeded",[pa]:"Max instruction trace length exceeded",[oa]:"Length of the seed is too long for address generation",[na]:"An account required by the instruction is missing",[bi]:"missing required signature for instruction",[Pi]:"instruction illegally modified the program id of an account",[Vi]:"insufficient account keys for instruction",[ca]:"Cross-program invocation with unauthorized signer or writable account",[ua]:"Failed to create program execution environment",[la]:"Program failed to compile",[da]:"Program failed to complete",[ki]:"instruction modified data of a read-only account",[zi]:"instruction changed the balance of a read-only account",[ra]:"Cross-program invocation reentrancy not allowed for this instruction",[Gi]:"instruction modified rent epoch of an account",[vi]:"sum of account balances before and after instruction do not match",[wi]:"instruction requires an initialized account",[Ni]:"",[ea]:"Unsupported program id",[Ta]:"Unsupported sysvar",[Ls]:"Invalid instruction plan kind: $kind.",[_s]:"The provided instruction plan is empty.",[As]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[ls]:"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).",[bs]:"Invalid transaction plan kind: $kind.",[Is]:"No more instructions to pack; the message packer has completed the instruction plan.",[Si]:"The instruction does not have any accounts.",[pi]:"The instruction does not have any data.",[mi]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Fo]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[vo]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[hs]:"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",[Ms]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Os]:"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",[Cs]:"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",[ys]:"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",[Ho]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Ko]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[jo]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[$o]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Vo]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ti]:"$__serverMessage",[Ii]:"$__serverMessage",[ui]:"$__serverMessage",[Qo]:"$__serverMessage",[Xo]:"Epoch rewards period still active at slot $slot",[ri]:"$__serverMessage",[oi]:"$__serverMessage",[Yo]:"Failed to query long-term storage; please try again",[Zo]:"Minimum context slot has not been reached",[ci]:"Node is unhealthy; behind by $numSlotsBehind slots",[ii]:"No snapshot",[li]:"Transaction simulation failed",[qo]:"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",[ai]:"$__serverMessage",[ni]:"Transaction history is not available from this node",[si]:"$__serverMessage",[ei]:"Transaction signature length mismatch",[di]:"Transaction signature verification failure",[Jo]:"$__serverMessage",[gi]:"Key pair bytes must be of length 64, got $byteLength.",[Ri]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Ti]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Di]:"The provided private key does not match the provided public key.",[fi]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[zo]:"Lamports value must be in the range [0, 2e64-1]",[ko]:"`$value` cannot be parsed as a `BigInt`",[Go]:"$message",[xo]:"`$value` cannot be parsed as a `Number`",[Po]:"No nonce account could be found at address `$nonceAccountAddress`",[Ds]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ps]:"WebSocket was closed before payload could be added to the send buffer",[ms]:"WebSocket connection closed",[Ns]:"WebSocket failed to connect",[Ss]:"Failed to obtain a subscription id from the server",[fs]:"Could not find an API plan for RPC method: `$method`",[gs]:"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`.",[Ts]:"HTTP error ($statusCode): $message",[Rs]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[st]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Tn]:"The provided value does not implement the `KeyPairSigner` interface",[Dn]:"The provided value does not implement the `MessageModifyingSigner` interface",[Sn]:"The provided value does not implement the `MessagePartialSigner` interface",[fn]:"The provided value does not implement any of the `MessageSigner` interfaces",[mn]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Nn]:"The provided value does not implement the `TransactionPartialSigner` interface",[Cn]:"The provided value does not implement the `TransactionSendingSigner` interface",[pn]:"The provided value does not implement any of the `TransactionSigner` interfaces",[On]:"More than one `TransactionSendingSigner` was identified.",[hn]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Na]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Ei]:"Cannot export a non-extractable key.",[ln]:"No digest implementation could be found.",[Ai]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[In]:`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.`,[_n]:"No signature verification implementation could be found.",[An]:"No key generation implementation could be found.",[En]:"No signing implementation could be found.",[st]:"No key export implementation could be found.",[Go]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ka]:"Transaction processing left an account with an outstanding borrowed reference",[La]:"Account in use",[ba]:"Account loaded twice",[Ua]:"Attempt to debit an account but found no record of a prior credit.",[Ja]:"Transaction loads an address table account that doesn't exist",[Ba]:"This transaction has already been processed",[Fa]:"Blockhash not found",[za]:"Loader call chain is too deep",[Ha]:"Transactions are currently disabled due to cluster maintenance",[is]:"Transaction contains a duplicate instruction ($index) that is not allowed",[va]:"Insufficient funds for fee",[as]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Pa]:"This account may not be used to pay transaction fees",[xa]:"Transaction contains an invalid account reference",[es]:"Transaction loads an address table account with invalid data",[ts]:"Transaction address table lookup uses an invalid index",[Qa]:"Transaction loads an address table account with an invalid owner",[cs]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Ga]:"This program may not be used for executing instructions",[ns]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ya]:"Transaction loads a writable account that cannot be written",[ss]:"Transaction exceeded max loaded accounts data size cap",[ka]:"Transaction requires a fee but has no signature present",[wa]:"Attempt to load a program that does not exist",[us]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[ds]:"ResanitizationNeeded",[Va]:"Transaction failed to sanitize accounts offsets correctly",[Wa]:"Transaction did not pass signature verification",[Za]:"Transaction locked too many accounts",[ls]:"Sum of account balances before and after transaction do not match",[zn]:"The transaction failed with the error `$errorName`",[ja]:"Transaction version is unsupported",[Xa]:"Transaction would exceed account data limit within the block",[os]:"Transaction would exceed total account data limit",[qa]:"Transaction would exceed max account limit within the block",[$a]:"Transaction would exceed max Block Cost Limit",[rs]:"Transaction would exceed max Vote Cost Limit",[Un]:"Attempted to sign a transaction with an address that is not a signer for it",[Oa]:"Transaction is missing an address at index: $index.",[Et]:"Transaction has no expected signers therefore it cannot be encoded",[Bn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[ut]:"Transaction does not have a blockhash lifetime",[lt]:"Transaction is not a durable nonce transaction",[yn]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Mn]:"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",[bn]:"No fee payer set in CompiledTransaction",[Ln]:"Could not find program address at index $index",[vn]:"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",[Pn]:"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",[ha]:"Transaction is missing a fee payer.",[At]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Ma]:"Transaction first instruction is not advance nonce account instruction.",[ya]:"Transaction with no instructions cannot be durable nonce transaction.",[dt]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Me]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[wn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[_t]:"Transaction is missing signatures for addresses: $addresses.",[It]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[gt]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Fn]:"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."},x="i",z="t";function Bs(e,t={}){let n=Ps[e];if(n.length===0)return "";let r;function o(a){if(r[z]===2){let s=n.slice(r[x]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[z]===1&&i.push(n.slice(r[x],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[x]:0,[z]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[z]){case 0:c={[x]:s,[z]:1};break;case 1:a==="\\"?c={[x]:s,[z]:0}:a==="$"&&(c={[x]:s,[z]:2});break;case 2:a==="\\"?c={[x]:s,[z]:0}:a==="$"?c={[x]:s,[z]:2}:a.match(/\w/)||(c={[x]:s,[z]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function Fs(e,t={}){if(process.env.NODE_ENV!=="production")return Bs(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${vs(t)}'`),`${n}\``}}var E=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,a])=>{i==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,i,a));});let o=Fs(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function zs(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var ks=(e,t)=>zs(e.length<=t?e:e.slice(0,t),t);function re(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,i)=>o===r[i])}function j(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function D(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(j(t,e));return e.write(t,n,0),n}})}function N(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function L(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Nt(e){if(!L(e))throw new E(ft)}function xs(e){return !L(e)}function tr(e,t,n=0){if(t.length-n<=0)throw new E(Rt,{codecDescription:e})}function Le(e,t,n,r=0){let o=n.length-r;if(o<t)throw new E(Tt,{bytesLength:o,codecDescription:e,expected:t})}function nr(e,t){let n=(a,s,c)=>{let d=e.encode(a);return c=t.write(d.length,s,c),s.set(d,c),c+d.length};if(L(t)&&L(e))return D({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=L(t)?t.fixedSize:t.maxSize??null,o=L(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return D({...e,...i!==null?{maxSize:i}:{},getSizeFromValue:a=>{let s=j(a,e);return j(s,t)+s},write:n})}function Y(e,t){return D({fixedSize:t,write:(n,r,o)=>{let i=e.encode(n),a=i.length>t?i.slice(0,t):i;return r.set(a,o),o+t}})}function Q(e,t){return N({fixedSize:t,read:(n,r)=>{Le("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),L(e)&&(n=ks(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function h(e,t){return D({...xs(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function q(e,t){return N({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function ar(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var Ws=e=>D({getSizeFromValue:t=>{let[n,r]=rr(t,e[0]);if(!r)return t.length;let o=or(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(ar(e,t),t==="")return r;let[o,i]=rr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=or(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),Gs=e=>N({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 i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,d)=>c*256n+BigInt(d),0n),s=Vs(a,e);return [i+s,t.length]}});function rr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function or(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Vs(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var sr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ee=()=>Ws(sr),Ee=()=>Gs(sr);var Hs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=()=>D({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){ar(Hs,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),U=()=>N({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var ir=globalThis.TextEncoder,be=()=>{let e;return D({getSizeFromValue:t=>(e||=new ir).encode(t).length,write:(t,n,r)=>{let o=(e||=new ir).encode(t);return n.set(o,r),r+o.length}})};function cr(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new E(it,{address:e.address})}}function Ks(e){return !("exists"in e)||"exists"in e&&e.exists}function dr(e){let t=e.filter(n=>Ks(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new E(at,{addresses:n})}}function ur(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=b().encode(t.data[0]);return Object.freeze({...lr(t),address:e,data:n,exists:true})}function $s(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...lr(t),address:e,data:n,exists:true})}function lr(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function Ir(e,t,n={}){let{abortSignal:r,...o}=n,i=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return ur(t,i.value)}async function _r(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?$s(t[s],a):ur(t[s],a))}function Ct(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new E(ot,{addresses:n})}}function Ar(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new E(st)}var Ot,ht;function yt(){return Ot||(Ot=ee()),Ot}function js(){return ht||(ht=Ee()),ht}function gr(e){if(e.length<32||e.length>44)return false;let t=yt();try{return t.encode(e).byteLength===32}catch{return false}}function Ue(e){if(e.length<32||e.length>44)throw new E(rt,{actualLength:e.length});let r=yt().encode(e).byteLength;if(r!==32)throw new E(nt,{actualLength:r})}function S(e){return Ue(e),e}function W(){return h(Y(yt(),32),e=>S(e))}function G(){return Q(js(),32)}function we(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}async function Rr(e){let t=W().encode(e);return await crypto.subtle.importKey("raw",t,{name:"Ed25519"},true,["verify"])}function Tr(e,t,n,r){if(r<t||r>n)throw new E(St,{codecDescription:e,max:n,min:t,value:r})}function fr(e){return e?.endian!==1}function Mt(e){return D({fixedSize:e.size,write(t,n,r){e.range&&Tr(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,fr(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function ve(e){return N({fixedSize:e.size,read(t,n=0){tr(e.name,t,n),Le(e.name,e.size,t,n);let r=new DataView(Ys(t,n,e.size));return [e.get(r,fr(e.config)),n+e.size]}})}function Ys(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var V=()=>D({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{Tr("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let i=Number(e)>>o*7;if(i===0)break;let a=127&i;r[o]=a,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var Dr=(e={})=>ve({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var ge=(e={})=>Mt({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Re=(e={})=>ve({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Te=(e={})=>Mt({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),oe=(e={})=>ve({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var P=()=>Mt({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),H=()=>ve({get:e=>e.getUint8(0),name:"u8",size:1});function qs(e,t,n){if(t!==n)throw new E(Dt,{actual:n,codecDescription:e,expected:t})}function Xs(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ie(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function fe(e){return L(e)?e.fixedSize:null}function ae(e){return L(e)?e.fixedSize:e.maxSize??null}function K(e,t={}){let n=t.size??ge(),r=Pe(n,fe(e)),o=Pe(n,ae(e))??void 0;return D({...r!==null?{fixedSize:r}:{getSizeFromValue:i=>(typeof n=="object"?j(i.length,n):0)+[...i].reduce((s,c)=>s+j(c,e),0),maxSize:o},write:(i,a,s)=>(typeof n=="number"&&qs("array",n,i.length),typeof n=="object"&&(s=n.write(i.length,a,s)),i.forEach(c=>{s=e.write(c,a,s);}),s)})}function Be(e,t={}){let n=t.size??Re(),r=fe(e),o=Pe(n,r),i=Pe(n,ae(e))??void 0;return N({...o!==null?{fixedSize:o}:{maxSize:i},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[l,I]=e.read(a,s);s=I,c.push(l);}return [c,s]}let[d,u]=typeof n=="number"?[n,s]:n.read(a,s);s=u;for(let l=0;l<d;l+=1){let[I,_]=e.read(a,s);s=_,c.push(I);}return [c,s]}})}function Pe(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function Sr(e={}){return q(e.size??H(),t=>Number(t)===1)}function De(){return D({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var Zs=()=>N({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function bt(e){return D({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function pr(e){return N({fixedSize:e.length,read:(t,n)=>{let r=Zs();if(!re(t,e,n))throw new E(mt,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function Fe(e){let t=ie(e.map(fe)),n=ie(e.map(ae))??void 0;return N({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let i=[];return e.forEach(a=>{let[s,c]=a.read(r,o);i.push(s),o=c;}),[i,o]}})}function Ut(e,t){let n=Nr(e),r=(i,a,s)=>{let c=t(i);return Lt(e,c),e[c].write(i,a,s)};if(n!==null)return D({fixedSize:n,write:r});let o=Cr(e);return D({...o!==null?{maxSize:o}:{},getSizeFromValue:i=>{let a=t(i);return Lt(e,a),j(i,e[a])},write:r})}function mr(e,t){let n=Nr(e),r=(i,a)=>{let s=t(i,a);return Lt(e,s),e[s].read(i,a)};if(n!==null)return N({fixedSize:n,read:r});let o=Cr(e);return N({...o!==null?{maxSize:o}:{},read:r})}function Lt(e,t){if(typeof e[t]>"u")throw new E(pt,{maxRange:e.length-1,minRange:0,variant:t})}function Nr(e){if(e.length===0)return 0;if(!L(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>L(r)&&r.fixedSize===t)?t:null}function Cr(e){return Xs(e.map(t=>ae(t)))}function ze(){return N({fixedSize:0,read:(e,t)=>[void 0,t]})}function w(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return D({...n===null?{getSizeFromValue:o=>e.map(([i,a])=>j(o[i],a)).reduce((i,a)=>i+a,0),maxSize:r}:{fixedSize:n},write:(o,i,a)=>(e.forEach(([s,c])=>{a=c.write(o[s],i,a);}),a)})}function Se(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return N({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[d,u]=c.read(o,i);i=u,a[s]=d;}),[a,i]}})}var Js=e=>({__option:"Some",value:e}),Qs=()=>({__option:"None"});function Or(e,t={}){let n=t.prefix===null?q(ze(),()=>false):Sr({size:t.prefix??H()}),r=t.noneValue==="zeroes"?(Nt(e),Q(ze(),e.fixedSize)):t.noneValue?pr(t.noneValue):ze();return mr([q(Fe([n,r]),()=>Qs()),q(Fe([n,e]),([,o])=>Js(o))],(o,i)=>{if(t.prefix===null&&!t.noneValue)return +(i<o.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return re(o,a,i)?0:1}return Number(n.read(o,i)[0])})}function pe(e,...t){return t.reduce((n,r)=>r(n),e)}var y=(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))(y||{});var ec=1;function Z(e){return e>=2}function se(e){return (e&ec)!==0}function wt(e,t){return e|t}function hr(e){return gr(e)}function yr(){return G()}function vr(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&hr(e.lifetimeConstraint.blockhash)}function ke(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 rc(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var oc=e=>D({getSizeFromValue:t=>{let[n,r]=Mr(t,e[0]);if(!r)return t.length;let o=Lr(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(rc(e,t),t==="")return r;let[o,i]=Mr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=Lr(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}});function Mr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Lr(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var ic="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ac=()=>oc(ic);var vt;function sc(){if(!vt){let e=K(P(),{size:V()});vt=w([["lookupTableAddress",W()],["writableIndexes",e],["readonlyIndexes",e]]);}return vt}var Pt;function Bt(){return Pt||(Pt=P()),Pt}function cc(){return w([["numSignerAccounts",Bt()],["numReadonlySignerAccounts",Bt()],["numReadonlyNonSignerAccounts",Bt()]])}var Ft;function dc(){return Ft||(Ft=h(w([["programAddressIndex",P()],["accountIndices",K(P(),{size:V()})],["data",nr(De(),V())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Ft}var uc=0,lc=128;function Ic(){return D({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new E(It,{actualVersion:e});if(e>uc)throw new E(gt,{unsupportedVersion:e});return t.set([e|lc],n),n+1}})}function br(){return w(Pr())}function Ur(){return h(w([...Pr(),["addressTableLookups",_c()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function Pr(){let e=Ut([bt(new Uint8Array(32)),Y(ac(),32)],t=>t===void 0?0:1);return [["version",Ic()],["header",cc()],["staticAccounts",K(W(),{size:V()})],["lifetimeToken",e],["instructions",K(dc(),{size:V()})]]}function _c(){return K(sc(),{size:V()})}function Br(){return D({getSizeFromValue:e=>e.version==="legacy"?br().getSizeFromValue(e):Ur().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?br().write(e,t,n):Ur().write(e,t,n)})}function wr(e,t,n){e[t]=n(e[t]??{role:y.READONLY});}var p=Symbol("AddressMapTypeProperty");function Ac(e,t){let n={[e]:{[p]:0,role:y.WRITABLE_SIGNER}},r=new Set;for(let o of t){wr(n,o.programAddress,a=>{if(r.add(o.programAddress),p in a){if(se(a.role))switch(a[p]){case 0:throw new E(dt,{programAddress:o.programAddress});default:throw new E(Me,{programAddress:o.programAddress})}if(a[p]===2)return a}return {[p]:2,role:y.READONLY}});let i;if(o.accounts)for(let a of o.accounts)wr(n,a.address,s=>{let{address:c,...d}=a;if(p in s)switch(s[p]){case 0:return s;case 1:{let u=wt(s.role,d.role);if("lookupTableAddress"in d){if(s.lookupTableAddress!==d.lookupTableAddress&&(i||=we())(d.lookupTableAddress,s.lookupTableAddress)<0)return {[p]:1,...d,role:u}}else if(Z(d.role))return {[p]:2,role:u};return s.role!==u?{...s,role:u}:s}case 2:{let u=wt(s.role,d.role);if(r.has(a.address)){if(se(d.role))throw new E(Me,{programAddress:a.address});return s.role!==u?{...s,role:u}:s}else return "lookupTableAddress"in d&&!Z(s.role)?{...d,[p]:1,role:u}:s.role!==u?{...s,role:u}:s}}return "lookupTableAddress"in d?{...d,[p]:1}:{...d,[p]:2}});}return n}function Ec(e){let t;return Object.entries(e).sort(([r,o],[i,a])=>{if(o[p]!==a[p]){if(o[p]===0)return -1;if(a[p]===0)return 1;if(o[p]===2)return -1;if(a[p]===2)return 1}let s=Z(o.role);if(s!==Z(a.role))return s?-1:1;let c=se(o.role);return c!==se(a.role)?c?-1:1:(t||=we(),o[p]===1&&a[p]===1&&o.lookupTableAddress!==a.lookupTableAddress?t(o.lookupTableAddress,a.lookupTableAddress):t(r,i))}).map(([r,o])=>({address:r,...o}))}function gc(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===y.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(we()).map(n=>({lookupTableAddress:n,...t[n]}))}function Rc(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let i=se(o.role);Z(o.role)?(r++,i||n++):i||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Tc(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function fc(e,t){let n=Tc(t);return e.map(({accounts:r,data:o,programAddress:i})=>({programAddressIndex:n[i],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...o?{data:o}:null}))}function Dc(e){return "nonce"in e?e.nonce:e.blockhash}function Sc(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Fr(e){let t=Ac(e.feePayer.address,e.instructions),n=Ec(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:gc(n)}:null,...r?{lifetimeToken:Dc(r)}:null,header:Rc(n),instructions:fc(e.instructions,n),staticAccounts:Sc(n),version:e.version}}function pc(e,t,n){for(let[r,o]of Object.entries(n))for(let i=0;i<o.length;i++)if(e===o[i])return {address:e,addressIndex:i,lookupTableAddress:r,role:t}}function zt(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),o=[],i=false;for(let a of e.instructions){if(!a.accounts){o.push(a);continue}let s=[],c=false;for(let d of a.accounts){if("lookupTableAddress"in d||!r.has(d.address)||Z(d.role)){s.push(d);continue}let u=pc(d.address,d.role,t);s.push(Object.freeze(u)),c=true,i=true;}o.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(i?{...e,instructions:o}:e)}function xe(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var mc="SysvarRecentB1ockHashes11111111111111111111",Nc="11111111111111111111111111111111";function Cc(e){return e.programAddress===Nc&&e.data!=null&&Oc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===y.WRITABLE&&e.accounts[1].address===mc&&e.accounts[1].role===y.READONLY&&e.accounts[2].address!=null&&Z(e.accounts[2].role)}function Oc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function kt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Cc(e.instructions[0])}function We(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Ge(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}var hc=Object.freeze({name:"Ed25519"});async function zr(e,t,n){return Ar(),await crypto.subtle.verify(hc,e,t,n)}function yc(e){let t=Object.values(e);if(t.length===0)throw new E(Et);return t.map(n=>n||new Uint8Array(64).fill(0))}function Mc(){return h(K(Y(De(),64),{size:V()}),yc)}function Wt(){return w([["signatures",Mc()],["messageBytes",De()]])}function te(e){let t=Fr(e),n=Br().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let a of r)o[a]=null;let i;return vr(e)?i={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:kt(e)&&(i={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...i?{lifetimeConstraint:i}:void 0,messageBytes:n,signatures:Object.freeze(o)})}var xt;function Ve(e){xt||(xt=Ee());let t=Object.values(e.signatures)[0];if(!t)throw new E(At);return xt.decode(t)}function Gt(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new E(_t,{addresses:t})}function ne(e){let t=Wt().encode(e);return U().decode(t)}function Vt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new E(ct,{address:n.address})}),Object.values(t)}function He(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function me(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function kr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function Ke(e){return me(e)||He(e)||kr(e)}function Uc(e){return Vt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function wc(e){return Vt([...e.feePayer&&Ke(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(Uc)])}function $e(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function xr(e,t){let{partialSigners:n,modifyingSigners:r}=vc(Vt(wc(e).filter(Ke)),{identifySendingSigner:false});return await Fc(e,r,n,t)}async function je(e,t){let n=await xr(e,t);return Gt(n),n}function vc(e,t={}){let r=t.identifySendingSigner??true?Pc(e):null,o=e.filter(s=>s!==r&&(He(s)||me(s))),i=Bc(o),a=o.filter(me).filter(s=>!i.includes(s));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}function Pc(e){let t=e.filter(kr);if(t.length===0)return null;let n=t.filter(r=>!He(r)&&!me(r));return n.length>0?n[0]:t[0]}function Bc(e){let t=e.filter(He);if(t.length===0)return [];let n=t.filter(r=>!me(r));return n.length>0?n:[t[0]]}async function Fc(e,t=[],n=[],r){let o=te(e),i=await t.reduce(async(s,c)=>{let[d]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(d)},Promise.resolve(o));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([i],r);return c}));return Object.freeze({...i,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),i.signatures??{}))})}async function Wr(e,t,n){if(e.length===0)return {};let r=await _r(t,e,n);return dr(r),Ct(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var Ye="ComputeBudget111111111111111111111111111111";var Ht=2;function Kt(){return h(w([["discriminator",P()],["units",ge()]]),e=>({...e,discriminator:Ht}))}function ce(e,t){let n=Ye,r={...e};return Object.freeze({data:Kt().encode(r),programAddress:n})}var $t=3;function jt(){return h(w([["discriminator",P()],["microLamports",Te()]]),e=>({...e,discriminator:$t}))}function Ne(e,t){let n=Ye,r={...e};return Object.freeze({data:jt().encode(r),programAddress:n})}async function Yt(e,t,n){let r=await Rr(e);return typeof n=="string"&&(n=new TextEncoder().encode(n)),typeof t=="string"&&(t=ee().encode(t)),zr(r,t,n)}var Gr="https://auth.revibase.com",Vr="revibase.com",Ce="https://api.revibase.com",qe="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",Hr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",Kr="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var B=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},Xe=class e extends B{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},k=class e extends B{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},Oe=class e extends B{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},Ze=class e extends B{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Je=class e extends B{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},$r=class e extends B{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},F=class e extends B{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},he=class e extends B{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},Qe=class e extends B{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var jr=180*1e3,qt=2e3,Yr=2e4,qr=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new he(n.error??"Send jito bundle failed");return n},Xr=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new he(t.error??"Estimate jito tips failed");return t},Zr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new F(n.error??"Authorization failed");return n};function Jr(e){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,i,a,s;if(r)o=t,i=n,a=0,s=0;else {let d=window.screenLeft??window.screenX??0,u=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,i=600,s=Math.round(d+(l-o)/2),a=Math.round(u+(I-i)/2);}let c=["popup=yes",`width=${o}`,`height=${i}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}function Qr(e,t,n){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let r=window.matchMedia("(max-width: 768px)").matches,o=window.scrollY,i={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width},a=()=>{document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${o}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%";},s=()=>{document.body.style.overflow=i.overflow,document.body.style.position=i.position,document.body.style.top=i.top,document.body.style.left=i.left,document.body.style.right=i.right,document.body.style.width=i.width,window.scrollTo(0,o);};a();let c=document.createElement("div");c.setAttribute("data-provider-frame-root","true"),Object.assign(c.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",contain:"layout style paint"}),document.body.appendChild(c);let d=c.attachShadow({mode:"closed"}),u=document.createElement("div");Object.assign(u.style,{all:"initial",position:"fixed",inset:"0",display:"flex",alignItems:r?"flex-end":"center",justifyContent:"center",background:"rgba(0,0,0,0.45)",zIndex:"2147483647",pointerEvents:"auto",overscrollBehavior:"contain",touchAction:"none",WebkitTapHighlightColor:"transparent",paddingBottom:"env(safe-area-inset-bottom)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}),d.appendChild(u);let l=document.createElement("div");Object.assign(l.style,{all:"initial",position:"relative",display:"flex",width:r?"100%":"500px",height:r?"90dvh":"600px",maxWidth:"100vw",maxHeight:"100dvh",borderRadius:r?"16px 16px 0 0":"16px",overflow:"hidden",boxShadow:"0 24px 80px rgba(0,0,0,0.35)",background:"#fff",pointerEvents:"auto"}),u.appendChild(l);let I=document.createElement("iframe");I.src=e,I.title="Authorization",I.setAttribute("tabindex","0"),I.allow=[`publickey-credentials-get ${new URL(e).origin}`].join("; "),I.sandbox=["allow-scripts","allow-same-origin"].join(" "),Object.assign(I.style,{width:"100%",height:"100%",border:"0",background:"#fff",display:"block"}),l.appendChild(I);let _=document.createElement("button");_.type="button",_.setAttribute("aria-label","Close"),_.innerHTML="&times;",Object.assign(_.style,{all:"initial",position:"absolute",top:r?"12px":"14px",right:r?"12px":"14px",width:"44px",height:"44px",display:"grid",placeItems:"center",borderRadius:"9999px",background:"rgba(255,255,255,0.96)",color:"#111",fontSize:"28px",lineHeight:"1",cursor:"pointer",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:"2",userSelect:"none",WebkitUserSelect:"none"}),l.appendChild(_),requestAnimationFrame(()=>{try{I.focus();}catch{}});let g=T=>{T.key==="Escape"&&m();};document.addEventListener("keydown",g);let f=false,A=()=>{if(!f){f=true;try{t?.removeEventListener("abort",C);}catch{}try{document.removeEventListener("keydown",g);}catch{}try{I.src="about:blank",I.removeAttribute("src");}catch{}try{c.remove();}catch{}s();}},m=()=>{n?.(),A();};_.addEventListener("click",T=>{T.preventDefault(),T.stopPropagation(),m();}),u.addEventListener("click",T=>{T.target===u&&m();});let C=()=>{m();};return t&&(t.aborted?C():t.addEventListener("abort",C,{once:true})),{iframe:I,close:A}}var eo=class{onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;rpId;uiMode;render;popUp=null;frame=null;rendered=null;constructor(t){let{rpId:n,rpcEndpoint:r,providerOrigin:o,ui:i,onClientAuthorizationCallback:a,onSendJitoBundleCallback:s,onEstimateJitoTipsCallback:c}=t;core.initialize({rpcEndpoint:r}),this.onClientAuthorizationCallback=a??Zr,this.onSendJitoBundleCallback=s??qr,this.onEstimateJitoTipsCallback=c??Xr,this.providerOrigin=o??Gr,this.rpId=n??Vr,this.uiMode=i?.mode??"iframe",this.render=i?.render;}async sendRequestToPopupProvider({onConnectedCallback:t,onSuccessCallback:n,signal:r}){if(typeof window>"u")throw new Qe;if(this.popUp||this.frame||this.rendered)throw new Ze;let o=U().decode(crypto.getRandomValues(new Uint8Array(16))),i=window.location.origin,a=`${this.providerOrigin}?clientOrigin=${encodeURIComponent(i)}&rid=${encodeURIComponent(o)}`,s;if(this.render)this.rendered=this.render(a);else if(this.uiMode==="iframe"){let c=new AbortController,d=()=>c.abort(),u=r;u&&(u.aborted?c.abort():(u.addEventListener("abort",d,{once:true}),s=()=>u.removeEventListener("abort",d))),this.frame=Qr(a,c.signal,()=>c.abort()),r=c.signal;}else if(this.popUp=Jr(a),!this.popUp)throw new Xe;return new Promise((c,d)=>{setTimeout(()=>{this.attachTransport({rid:o,clientOrigin:i,onConnectedCallback:t,onSuccessCallback:n,signal:r,resolve:c,reject:d});},0);}).finally(()=>{try{s?.();}catch{}})}attachTransport(t){let{rid:n,clientOrigin:r,onConnectedCallback:o,onSuccessCallback:i,signal:a,reject:s,resolve:c}=t,d=()=>{A(new Je);};a?.addEventListener("abort",d,{once:true});let u=null,l=false,I=null,_=null,g=null,f=()=>{window.removeEventListener("message",C),a?.removeEventListener("abort",d),I&&(clearInterval(I),I=null),_&&(clearTimeout(_),_=null),g&&(clearTimeout(g),g=null);try{u?.close();}catch{}u=null;try{this.popUp&&!this.popUp.closed&&this.popUp.close();}catch{}try{this.frame?.close();}catch{}try{this.rendered?.close();}catch{}this.popUp=null,this.frame=null,this.rendered=null;},A=T=>{l||(l=true,f(),s(T));},m=T=>{l||(l=true,f(),i(T).then(O=>{c(O);}).catch(O=>{s(O);}));};_=setTimeout(()=>{A(new Oe("Popup connection timed out after 20s"));},Yr);let C=T=>{if(l||u||T.origin!==this.providerOrigin)return;let O=T.data;if(!O||O.type!=="popup-connect"||O.rid!==n)return;_&&(clearTimeout(_),_=null);let M=new MessageChannel;u=M.port1,u.start();let J=Date.now();I=setInterval(()=>{if(l){I&&(clearInterval(I),I=null);return}if(this.rendered?.isClosed){if(this.rendered.isClosed()){A(new k("Provider UI was closed"));return}}else if(!this.rendered){if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected){A(new k("Provider iframe was closed"));return}}else if(this.popUp?.closed){A(new k("Popup was closed"));return}}if(!u){A(new k("Message channel lost"));return}if(Date.now()-J>qt*2){A(new k("Lost connection to popup (heartbeat timeout)"));return}try{u.postMessage({type:"ping"});}catch{A(new k("Failed to send heartbeat"));}},qt),u.onmessage=v=>{if(l)return;let $=v.data;switch($.type){case "pong":J=Date.now();break;case "popup-complete":$.payload?m($.payload):A(new F("Invalid completion payload"));break;case "popup-rejected":A(new F("User rejected the operation"));break;case "popup-error":A(new F($.error||"Unknown popup error"));break;case "popup-closed":A(new k("User closed popup"));break;default:console.warn("Unknown message type from popup:",$);}},u.onmessageerror=()=>{A(new F("Message deserialization error"));};try{this.rendered?this.rendered.targetWindow.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.uiMode==="iframe"?this.frame?.iframe.contentWindow?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.popUp?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]);}catch(v){A(new F(`Failed to initialize popup: ${v}`));return}o(n,r).then(v=>{if(l||!u)return;if(this.rendered?.isClosed){if(this.rendered.isClosed())return}else if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected)return}else if(this.popUp?.closed)return;try{u.postMessage({type:"popup-start",payload:v});}catch(wo){A(new F(`Failed to send request to popup: ${wo}`));return}g&&(clearTimeout(g),g=null);let $=Math.max(0,v.request.validTill-Date.now());g=setTimeout(()=>{A(new Oe("Request expired"));},$);}).catch(v=>{A(v);});};window.addEventListener("message",C);}};function to(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[_n]:"No signature verification implementation could be found.",[An]:"No key generation implementation could be found.",[En]:"No signing implementation could be found.",[at]:"No key export implementation could be found.",[Wo]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ha]:"Transaction processing left an account with an outstanding borrowed reference",[Ma]:"Account in use",[La]:"Account loaded twice",[ba]:"Attempt to debit an account but found no record of a prior credit.",[Za]:"Transaction loads an address table account that doesn't exist",[Pa]:"This transaction has already been processed",[Ba]:"Blockhash not found",[Fa]:"Loader call chain is too deep",[Va]:"Transactions are currently disabled due to cluster maintenance",[os]:"Transaction contains a duplicate instruction ($index) that is not allowed",[wa]:"Insufficient funds for fee",[is]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[va]:"This account may not be used to pay transaction fees",[ka]:"Transaction contains an invalid account reference",[Qa]:"Transaction loads an address table account with invalid data",[es]:"Transaction address table lookup uses an invalid index",[Ja]:"Transaction loads an address table account with an invalid owner",[ss]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Wa]:"This program may not be used for executing instructions",[ts]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[ja]:"Transaction loads a writable account that cannot be written",[as]:"Transaction exceeded max loaded accounts data size cap",[za]:"Transaction requires a fee but has no signature present",[Ua]:"Attempt to load a program that does not exist",[us]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[cs]:"ResanitizationNeeded",[Ga]:"Transaction failed to sanitize accounts offsets correctly",[xa]:"Transaction did not pass signature verification",[Xa]:"Transaction locked too many accounts",[ds]:"Sum of account balances before and after transaction do not match",[zn]:"The transaction failed with the error `$errorName`",[$a]:"Transaction version is unsupported",[qa]:"Transaction would exceed account data limit within the block",[rs]:"Transaction would exceed total account data limit",[Ya]:"Transaction would exceed max account limit within the block",[Ka]:"Transaction would exceed max Block Cost Limit",[ns]:"Transaction would exceed max Vote Cost Limit",[Un]:"Attempted to sign a transaction with an address that is not a signer for it",[Ca]:"Transaction is missing an address at index: $index.",[At]:"Transaction has no expected signers therefore it cannot be encoded",[Bn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[ut]:"Transaction does not have a blockhash lifetime",[dt]:"Transaction is not a durable nonce transaction",[yn]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Mn]:"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",[bn]:"No fee payer set in CompiledTransaction",[Ln]:"Could not find program address at index $index",[vn]:"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",[Pn]:"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",[Oa]:"Transaction is missing a fee payer.",[_t]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ya]:"Transaction first instruction is not advance nonce account instruction.",[ha]:"Transaction with no instructions cannot be durable nonce transaction.",[ct]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Me]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[wn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[It]:"Transaction is missing signatures for addresses: $addresses.",[lt]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[Et]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Fn]:"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."},k="i",B="t";function Ps(e,t={}){let n=vs[e];if(n.length===0)return "";let r;function o(a){if(r[B]===2){let s=n.slice(r[k]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[B]===1&&i.push(n.slice(r[k],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[k]:0,[B]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[B]){case 0:c={[k]:s,[B]:1};break;case 1:a==="\\"?c={[k]:s,[B]:0}:a==="$"&&(c={[k]:s,[B]:2});break;case 2:a==="\\"?c={[k]:s,[B]:0}:a==="$"?c={[k]:s,[B]:2}:a.match(/\w/)||(c={[k]:s,[B]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function Bs(e,t={}){if(process.env.NODE_ENV!=="production")return Ps(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${ws(t)}'`),`${n}\``}}var A=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,a])=>{i==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,i,a));});let o=Bs(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Fs(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var zs=(e,t)=>Fs(e.length<=t?e:e.slice(0,t),t);function ne(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,i)=>o===r[i])}function j(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function D(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(j(t,e));return e.write(t,n,0),n}})}function N(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function M(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function mt(e){if(!M(e))throw new A(Tt)}function ks(e){return !M(e)}function tr(e,t,n=0){if(t.length-n<=0)throw new A(gt,{codecDescription:e})}function Le(e,t,n,r=0){let o=n.length-r;if(o<t)throw new A(Rt,{bytesLength:o,codecDescription:e,expected:t})}function nr(e,t){let n=(a,s,c)=>{let u=e.encode(a);return c=t.write(u.length,s,c),s.set(u,c),c+u.length};if(M(t)&&M(e))return D({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=M(t)?t.fixedSize:t.maxSize??null,o=M(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return D({...e,...i!==null?{maxSize:i}:{},getSizeFromValue:a=>{let s=j(a,e);return j(s,t)+s},write:n})}function Y(e,t){return D({fixedSize:t,write:(n,r,o)=>{let i=e.encode(n),a=i.length>t?i.slice(0,t):i;return r.set(a,o),o+t}})}function J(e,t){return N({fixedSize:t,read:(n,r)=>{Le("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),M(e)&&(n=zs(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function C(e,t){return D({...ks(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function q(e,t){return N({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function ir(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new A(_e,{alphabet:e,base:e.length,value:n})}var xs=e=>D({getSizeFromValue:t=>{let[n,r]=rr(t,e[0]);if(!r)return t.length;let o=or(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(ir(e,t),t==="")return r;let[o,i]=rr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=or(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),Ws=e=>N({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 i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Gs(a,e);return [i+s,t.length]}});function rr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function or(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Gs(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var ar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Q=()=>xs(ar),Ae=()=>Ws(ar);var Vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=()=>D({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){ir(Vs,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),b=()=>N({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});function sr(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new A(ot,{address:e.address})}}function Hs(e){return !("exists"in e)||"exists"in e&&e.exists}function cr(e){let t=e.filter(n=>Hs(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new A(it,{addresses:n})}}function ur(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=L().encode(t.data[0]);return Object.freeze({...dr(t),address:e,data:n,exists:true})}function Ks(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...dr(t),address:e,data:n,exists:true})}function dr(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function lr(e,t,n={}){let{abortSignal:r,...o}=n,i=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return ur(t,i.value)}async function Ir(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?Ks(t[s],a):ur(t[s],a))}function Nt(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new A(rt,{addresses:n})}}function _r(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new A(at)}var Ct,Ot;function ht(){return Ct||(Ct=Q()),Ct}function $s(){return Ot||(Ot=Ae()),Ot}function Er(e){if(e.length<32||e.length>44)return false;let t=ht();try{return t.encode(e).byteLength===32}catch{return false}}function be(e){if(e.length<32||e.length>44)throw new A(nt,{actualLength:e.length});let r=ht().encode(e).byteLength;if(r!==32)throw new A(tt,{actualLength:r})}function S(e){return be(e),e}function x(){return C(Y(ht(),32),e=>S(e))}function W(){return J($s(),32)}function Ue(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}async function gr(e){let t=x().encode(e);return await crypto.subtle.importKey("raw",t,{name:"Ed25519"},true,["verify"])}function Rr(e,t,n,r){if(r<t||r>n)throw new A(Dt,{codecDescription:e,max:n,min:t,value:r})}function Tr(e){return e?.endian!==1}function yt(e){return D({fixedSize:e.size,write(t,n,r){e.range&&Rr(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,Tr(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function we(e){return N({fixedSize:e.size,read(t,n=0){tr(e.name,t,n),Le(e.name,e.size,t,n);let r=new DataView(js(t,n,e.size));return [e.get(r,Tr(e.config)),n+e.size]}})}function js(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var G=()=>D({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{Rr("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let i=Number(e)>>o*7;if(i===0)break;let a=127&i;r[o]=a,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var fr=(e={})=>we({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var Ee=(e={})=>yt({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),ge=(e={})=>we({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Re=(e={})=>yt({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),re=(e={})=>we({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var w=()=>yt({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),V=()=>we({get:e=>e.getUint8(0),name:"u8",size:1});function Ys(e,t,n){if(t!==n)throw new A(ft,{actual:n,codecDescription:e,expected:t})}function qs(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function oe(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function Te(e){return M(e)?e.fixedSize:null}function ie(e){return M(e)?e.fixedSize:e.maxSize??null}function H(e,t={}){let n=t.size??Ee(),r=ve(n,Te(e)),o=ve(n,ie(e))??void 0;return D({...r!==null?{fixedSize:r}:{getSizeFromValue:i=>(typeof n=="object"?j(i.length,n):0)+[...i].reduce((s,c)=>s+j(c,e),0),maxSize:o},write:(i,a,s)=>(typeof n=="number"&&Ys("array",n,i.length),typeof n=="object"&&(s=n.write(i.length,a,s)),i.forEach(c=>{s=e.write(c,a,s);}),s)})}function Pe(e,t={}){let n=t.size??ge(),r=Te(e),o=ve(n,r),i=ve(n,ie(e))??void 0;return N({...o!==null?{fixedSize:o}:{maxSize:i},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[l,I]=e.read(a,s);s=I,c.push(l);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(a,s);s=d;for(let l=0;l<u;l+=1){let[I,_]=e.read(a,s);s=_,c.push(I);}return [c,s]}})}function ve(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function Dr(e={}){return q(e.size??V(),t=>Number(t)===1)}function fe(){return D({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var Xs=()=>N({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function Lt(e){return D({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function Sr(e){return N({fixedSize:e.length,read:(t,n)=>{let r=Xs();if(!ne(t,e,n))throw new A(pt,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function Be(e){let t=oe(e.map(Te)),n=oe(e.map(ie))??void 0;return N({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let i=[];return e.forEach(a=>{let[s,c]=a.read(r,o);i.push(s),o=c;}),[i,o]}})}function bt(e,t){let n=mr(e),r=(i,a,s)=>{let c=t(i);return Mt(e,c),e[c].write(i,a,s)};if(n!==null)return D({fixedSize:n,write:r});let o=Nr(e);return D({...o!==null?{maxSize:o}:{},getSizeFromValue:i=>{let a=t(i);return Mt(e,a),j(i,e[a])},write:r})}function pr(e,t){let n=mr(e),r=(i,a)=>{let s=t(i,a);return Mt(e,s),e[s].read(i,a)};if(n!==null)return N({fixedSize:n,read:r});let o=Nr(e);return N({...o!==null?{maxSize:o}:{},read:r})}function Mt(e,t){if(typeof e[t]>"u")throw new A(St,{maxRange:e.length-1,minRange:0,variant:t})}function mr(e){if(e.length===0)return 0;if(!M(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>M(r)&&r.fixedSize===t)?t:null}function Nr(e){return qs(e.map(t=>ie(t)))}function Fe(){return N({fixedSize:0,read:(e,t)=>[void 0,t]})}function U(e){let t=e.map(([,o])=>o),n=oe(t.map(Te)),r=oe(t.map(ie))??void 0;return D({...n===null?{getSizeFromValue:o=>e.map(([i,a])=>j(o[i],a)).reduce((i,a)=>i+a,0),maxSize:r}:{fixedSize:n},write:(o,i,a)=>(e.forEach(([s,c])=>{a=c.write(o[s],i,a);}),a)})}function De(e){let t=e.map(([,o])=>o),n=oe(t.map(Te)),r=oe(t.map(ie))??void 0;return N({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,i);i=d,a[s]=u;}),[a,i]}})}var Zs=e=>({__option:"Some",value:e}),Js=()=>({__option:"None"});function Cr(e,t={}){let n=t.prefix===null?q(Fe(),()=>false):Dr({size:t.prefix??V()}),r=t.noneValue==="zeroes"?(mt(e),J(Fe(),e.fixedSize)):t.noneValue?Sr(t.noneValue):Fe();return pr([q(Be([n,r]),()=>Js()),q(Be([n,e]),([,o])=>Zs(o))],(o,i)=>{if(t.prefix===null&&!t.noneValue)return +(i<o.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ne(o,a,i)?0:1}return Number(n.read(o,i)[0])})}function Se(e,...t){return t.reduce((n,r)=>r(n),e)}var O=(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))(O||{});var Qs=1;function Z(e){return e>=2}function ae(e){return (e&Qs)!==0}function Ut(e,t){return e|t}function Or(e){return Er(e)}function hr(){return W()}function wr(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&Or(e.lifetimeConstraint.blockhash)}function ze(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 nc(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new A(_e,{alphabet:e,base:e.length,value:n})}var rc=e=>D({getSizeFromValue:t=>{let[n,r]=yr(t,e[0]);if(!r)return t.length;let o=Mr(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(nc(e,t),t==="")return r;let[o,i]=yr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=Mr(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}});function yr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Mr(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var oc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ic=()=>rc(oc);var wt;function ac(){if(!wt){let e=H(w(),{size:G()});wt=U([["lookupTableAddress",x()],["writableIndexes",e],["readonlyIndexes",e]]);}return wt}var vt;function Pt(){return vt||(vt=w()),vt}function sc(){return U([["numSignerAccounts",Pt()],["numReadonlySignerAccounts",Pt()],["numReadonlyNonSignerAccounts",Pt()]])}var Bt;function cc(){return Bt||(Bt=C(U([["programAddressIndex",w()],["accountIndices",H(w(),{size:G()})],["data",nr(fe(),G())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Bt}var uc=0,dc=128;function lc(){return D({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new A(lt,{actualVersion:e});if(e>uc)throw new A(Et,{unsupportedVersion:e});return t.set([e|dc],n),n+1}})}function Lr(){return U(vr())}function br(){return C(U([...vr(),["addressTableLookups",Ic()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function vr(){let e=bt([Lt(new Uint8Array(32)),Y(ic(),32)],t=>t===void 0?0:1);return [["version",lc()],["header",sc()],["staticAccounts",H(x(),{size:G()})],["lifetimeToken",e],["instructions",H(cc(),{size:G()})]]}function Ic(){return H(ac(),{size:G()})}function Pr(){return D({getSizeFromValue:e=>e.version==="legacy"?Lr().getSizeFromValue(e):br().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Lr().write(e,t,n):br().write(e,t,n)})}function Ur(e,t,n){e[t]=n(e[t]??{role:O.READONLY});}var p=Symbol("AddressMapTypeProperty");function _c(e,t){let n={[e]:{[p]:0,role:O.WRITABLE_SIGNER}},r=new Set;for(let o of t){Ur(n,o.programAddress,a=>{if(r.add(o.programAddress),p in a){if(ae(a.role))switch(a[p]){case 0:throw new A(ct,{programAddress:o.programAddress});default:throw new A(Me,{programAddress:o.programAddress})}if(a[p]===2)return a}return {[p]:2,role:O.READONLY}});let i;if(o.accounts)for(let a of o.accounts)Ur(n,a.address,s=>{let{address:c,...u}=a;if(p in s)switch(s[p]){case 0:return s;case 1:{let d=Ut(s.role,u.role);if("lookupTableAddress"in u){if(s.lookupTableAddress!==u.lookupTableAddress&&(i||=Ue())(u.lookupTableAddress,s.lookupTableAddress)<0)return {[p]:1,...u,role:d}}else if(Z(u.role))return {[p]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=Ut(s.role,u.role);if(r.has(a.address)){if(ae(u.role))throw new A(Me,{programAddress:a.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in u&&!Z(s.role)?{...u,[p]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in u?{...u,[p]:1}:{...u,[p]:2}});}return n}function Ac(e){let t;return Object.entries(e).sort(([r,o],[i,a])=>{if(o[p]!==a[p]){if(o[p]===0)return -1;if(a[p]===0)return 1;if(o[p]===2)return -1;if(a[p]===2)return 1}let s=Z(o.role);if(s!==Z(a.role))return s?-1:1;let c=ae(o.role);return c!==ae(a.role)?c?-1:1:(t||=Ue(),o[p]===1&&a[p]===1&&o.lookupTableAddress!==a.lookupTableAddress?t(o.lookupTableAddress,a.lookupTableAddress):t(r,i))}).map(([r,o])=>({address:r,...o}))}function Ec(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===O.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(Ue()).map(n=>({lookupTableAddress:n,...t[n]}))}function gc(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let i=ae(o.role);Z(o.role)?(r++,i||n++):i||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Rc(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function Tc(e,t){let n=Rc(t);return e.map(({accounts:r,data:o,programAddress:i})=>({programAddressIndex:n[i],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...o?{data:o}:null}))}function fc(e){return "nonce"in e?e.nonce:e.blockhash}function Dc(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Br(e){let t=_c(e.feePayer.address,e.instructions),n=Ac(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:Ec(n)}:null,...r?{lifetimeToken:fc(r)}:null,header:gc(n),instructions:Tc(e.instructions,n),staticAccounts:Dc(n),version:e.version}}function Sc(e,t,n){for(let[r,o]of Object.entries(n))for(let i=0;i<o.length;i++)if(e===o[i])return {address:e,addressIndex:i,lookupTableAddress:r,role:t}}function Ft(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),o=[],i=false;for(let a of e.instructions){if(!a.accounts){o.push(a);continue}let s=[],c=false;for(let u of a.accounts){if("lookupTableAddress"in u||!r.has(u.address)||Z(u.role)){s.push(u);continue}let d=Sc(u.address,u.role,t);s.push(Object.freeze(d)),c=true,i=true;}o.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(i?{...e,instructions:o}:e)}function ke(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var pc="SysvarRecentB1ockHashes11111111111111111111",mc="11111111111111111111111111111111";function Nc(e){return e.programAddress===mc&&e.data!=null&&Cc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===O.WRITABLE&&e.accounts[1].address===pc&&e.accounts[1].role===O.READONLY&&e.accounts[2].address!=null&&Z(e.accounts[2].role)}function Cc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function zt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Nc(e.instructions[0])}function xe(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function We(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}var Oc=Object.freeze({name:"Ed25519"});async function Fr(e,t,n){return _r(),await crypto.subtle.verify(Oc,e,t,n)}function hc(e){let t=Object.values(e);if(t.length===0)throw new A(At);return t.map(n=>n||new Uint8Array(64).fill(0))}function yc(){return C(H(Y(fe(),64),{size:G()}),hc)}function xt(){return U([["signatures",yc()],["messageBytes",fe()]])}function ee(e){let t=Br(e),n=Pr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let a of r)o[a]=null;let i;return wr(e)?i={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:zt(e)&&(i={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...i?{lifetimeConstraint:i}:void 0,messageBytes:n,signatures:Object.freeze(o)})}var kt;function Ge(e){kt||(kt=Ae());let t=Object.values(e.signatures)[0];if(!t)throw new A(_t);return kt.decode(t)}function Wt(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new A(It,{addresses:t})}function te(e){let t=xt().encode(e);return b().decode(t)}function Gt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new A(st,{address:n.address})}),Object.values(t)}function Ve(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function pe(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function zr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function He(e){return pe(e)||Ve(e)||zr(e)}function bc(e){return Gt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function Uc(e){return Gt([...e.feePayer&&He(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(bc)])}function Ke(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function kr(e,t){let{partialSigners:n,modifyingSigners:r}=wc(Gt(Uc(e).filter(He)),{identifySendingSigner:false});return await Bc(e,r,n,t)}async function $e(e,t){let n=await kr(e,t);return Wt(n),n}function wc(e,t={}){let r=t.identifySendingSigner??true?vc(e):null,o=e.filter(s=>s!==r&&(Ve(s)||pe(s))),i=Pc(o),a=o.filter(pe).filter(s=>!i.includes(s));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}function vc(e){let t=e.filter(zr);if(t.length===0)return null;let n=t.filter(r=>!Ve(r)&&!pe(r));return n.length>0?n[0]:t[0]}function Pc(e){let t=e.filter(Ve);if(t.length===0)return [];let n=t.filter(r=>!pe(r));return n.length>0?n:[t[0]]}async function Bc(e,t=[],n=[],r){let o=ee(e),i=await t.reduce(async(s,c)=>{let[u]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(u)},Promise.resolve(o));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([i],r);return c}));return Object.freeze({...i,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),i.signatures??{}))})}async function xr(e,t,n){if(e.length===0)return {};let r=await Ir(t,e,n);return cr(r),Nt(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var je="ComputeBudget111111111111111111111111111111";var Vt=2;function Ht(){return C(U([["discriminator",w()],["units",Ee()]]),e=>({...e,discriminator:Vt}))}function se(e,t){let n=je,r={...e};return Object.freeze({data:Ht().encode(r),programAddress:n})}var Kt=3;function $t(){return C(U([["discriminator",w()],["microLamports",Re()]]),e=>({...e,discriminator:Kt}))}function me(e,t){let n=je,r={...e};return Object.freeze({data:$t().encode(r),programAddress:n})}async function jt(e,t,n){let r=await gr(e);return typeof n=="string"&&(n=new TextEncoder().encode(n)),typeof t=="string"&&(t=Q().encode(t)),Fr(r,t,n)}var Wr="https://auth.revibase.com",Gr="revibase.com",Ne="https://api.revibase.com",Ye="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",Vr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",Hr="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var v=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},qe=class e extends v{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},F=class e extends v{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},Ce=class e extends v{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},Xe=class e extends v{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Ze=class e extends v{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},Kr=class e extends v{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},P=class e extends v{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},Oe=class e extends v{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},Je=class e extends v{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var $r=180*1e3,Yt=2e3,jr=2e4,Yr=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new Oe(n.error??"Send jito bundle failed");return n},qr=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new Oe(t.error??"Estimate jito tips failed");return t},Xr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new P(n.error??"Authorization failed");return n};function Zr(e){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,i,a,s;if(r)o=t,i=n,a=0,s=0;else {let u=window.screenLeft??window.screenX??0,d=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,i=600,s=Math.round(u+(l-o)/2),a=Math.round(d+(I-i)/2);}let c=["popup=yes",`width=${o}`,`height=${i}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}function Jr(e,t,n){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let r=window.matchMedia("(max-width: 768px)").matches,o=window.scrollY,i={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width},a=()=>{document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${o}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%";},s=()=>{document.body.style.overflow=i.overflow,document.body.style.position=i.position,document.body.style.top=i.top,document.body.style.left=i.left,document.body.style.right=i.right,document.body.style.width=i.width,window.scrollTo(0,o);};a();let c=document.createElement("div");c.setAttribute("data-provider-frame-root","true"),Object.assign(c.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",contain:"layout style paint"}),document.body.appendChild(c);let u=c.attachShadow({mode:"closed"}),d=document.createElement("div");Object.assign(d.style,{all:"initial",position:"fixed",inset:"0",display:"flex",alignItems:r?"flex-end":"center",justifyContent:"center",background:"rgba(0,0,0,0.45)",zIndex:"2147483647",pointerEvents:"auto",overscrollBehavior:"contain",touchAction:"none",WebkitTapHighlightColor:"transparent",paddingBottom:"env(safe-area-inset-bottom)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}),u.appendChild(d);let l=document.createElement("div");Object.assign(l.style,{all:"initial",position:"relative",display:"flex",width:r?"100%":"500px",height:r?"90dvh":"600px",maxWidth:"100vw",maxHeight:"100dvh",borderRadius:r?"16px 16px 0 0":"16px",overflow:"hidden",boxShadow:"0 24px 80px rgba(0,0,0,0.35)",background:"#fff",pointerEvents:"auto"}),d.appendChild(l);let I=document.createElement("iframe");I.src=e,I.title="Authorization",I.setAttribute("tabindex","0"),I.allow=[`publickey-credentials-get ${new URL(e).origin}`].join("; "),I.sandbox=["allow-scripts","allow-same-origin"].join(" "),Object.assign(I.style,{width:"100%",height:"100%",border:"0",background:"#fff",display:"block"}),l.appendChild(I);let _=document.createElement("button");_.type="button",_.setAttribute("aria-label","Close"),_.innerHTML="&times;",Object.assign(_.style,{all:"initial",position:"absolute",top:r?"12px":"14px",right:r?"12px":"14px",width:"44px",height:"44px",display:"grid",placeItems:"center",borderRadius:"9999px",background:"rgba(255,255,255,0.96)",color:"#111",fontSize:"28px",lineHeight:"1",cursor:"pointer",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:"2",userSelect:"none",WebkitUserSelect:"none"}),l.appendChild(_),requestAnimationFrame(()=>{try{I.focus();}catch{}});let g=T=>{T.key==="Escape"&&m();};document.addEventListener("keydown",g);let f=false,R=()=>{if(!f){f=true;try{t?.removeEventListener("abort",h);}catch{}try{document.removeEventListener("keydown",g);}catch{}try{I.src="about:blank",I.removeAttribute("src");}catch{}try{c.remove();}catch{}s();}},m=()=>{n?.(),R();};_.addEventListener("click",T=>{T.preventDefault(),T.stopPropagation(),m();}),d.addEventListener("click",T=>{T.target===d&&m();});let h=()=>{m();};return t&&(t.aborted?h():t.addEventListener("abort",h,{once:true})),{iframe:I,close:R}}var Qr=class{onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;rpId;uiMode;render;popUp=null;frame=null;rendered=null;constructor(t){let{rpId:n,rpcEndpoint:r,providerOrigin:o,ui:i,onClientAuthorizationCallback:a,onSendJitoBundleCallback:s,onEstimateJitoTipsCallback:c}=t;core.initialize({rpcEndpoint:r}),this.onClientAuthorizationCallback=a??Xr,this.onSendJitoBundleCallback=s??Yr,this.onEstimateJitoTipsCallback=c??qr,this.providerOrigin=o??Wr,this.rpId=n??Gr,this.uiMode=i?.mode??"iframe",this.render=i?.render;}async sendRequestToPopupProvider({onConnectedCallback:t,onSuccessCallback:n,signal:r}){if(typeof window>"u")throw new Je;if(this.popUp||this.frame||this.rendered)throw new Xe;let o=b().decode(crypto.getRandomValues(new Uint8Array(16))),i=window.location.origin,a=`${this.providerOrigin}?clientOrigin=${encodeURIComponent(i)}&rid=${encodeURIComponent(o)}`,s;if(this.render)this.rendered=this.render(a);else if(this.uiMode==="iframe"){let c=new AbortController,u=()=>c.abort(),d=r;d&&(d.aborted?c.abort():(d.addEventListener("abort",u,{once:true}),s=()=>d.removeEventListener("abort",u))),this.frame=Jr(a,c.signal,()=>c.abort()),r=c.signal;}else if(this.popUp=Zr(a),!this.popUp)throw new qe;return new Promise((c,u)=>{setTimeout(()=>{this.attachTransport({rid:o,clientOrigin:i,onConnectedCallback:t,onSuccessCallback:n,signal:r,resolve:c,reject:u});},0);}).finally(()=>{try{s?.();}catch{}})}attachTransport(t){let{rid:n,clientOrigin:r,onConnectedCallback:o,onSuccessCallback:i,signal:a,reject:s,resolve:c}=t,u=()=>{R(new Ze);};a?.addEventListener("abort",u,{once:true});let d=null,l=false,I=null,_=null,g=null,f=()=>{window.removeEventListener("message",h),a?.removeEventListener("abort",u),I&&(clearInterval(I),I=null),_&&(clearTimeout(_),_=null),g&&(clearTimeout(g),g=null);try{d?.close();}catch{}d=null;try{this.popUp&&!this.popUp.closed&&this.popUp.close();}catch{}try{this.frame?.close();}catch{}try{this.rendered?.close();}catch{}this.popUp=null,this.frame=null,this.rendered=null;},R=T=>{l||(l=true,f(),s(T));},m=T=>{l||(l=true,f(),i(T).then(y=>{c(y);}).catch(y=>{s(y);}));};_=setTimeout(()=>{R(new Ce("Popup connection timed out after 20s"));},jr);let h=T=>{if(l||d||T.origin!==this.providerOrigin)return;let y=T.data;if(!y||y.type!=="popup-connect"||y.rid!==n)return;_&&(clearTimeout(_),_=null);let K=new MessageChannel;d=K.port1,d.start();let ye=Date.now();I=setInterval(()=>{if(l){I&&(clearInterval(I),I=null);return}if(this.rendered?.isClosed){if(this.rendered.isClosed()){R(new F("Provider UI was closed"));return}}else if(!this.rendered){if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected){R(new F("Provider iframe was closed"));return}}else if(this.popUp?.closed){R(new F("Popup was closed"));return}}if(!d){R(new F("Message channel lost"));return}if(Date.now()-ye>Yt*2){R(new F("Lost connection to popup (heartbeat timeout)"));return}try{d.postMessage({type:"ping"});}catch{R(new F("Failed to send heartbeat"));}},Yt),d.onmessage=z=>{if(l)return;let $=z.data;switch($.type){case "pong":ye=Date.now();break;case "popup-complete":$.payload?m($.payload):R(new P("Invalid completion payload"));break;case "popup-rejected":R(new P("User rejected the operation"));break;case "popup-error":R(new P($.error||"Unknown popup error"));break;case "popup-closed":R(new F("User closed popup"));break;default:console.warn("Unknown message type from popup:",$);}},d.onmessageerror=()=>{R(new P("Message deserialization error"));};try{this.rendered?this.rendered.targetWindow.postMessage({type:"popup-init",rid:n},this.providerOrigin,[K.port2]):this.uiMode==="iframe"?this.frame?.iframe.contentWindow?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[K.port2]):this.popUp?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[K.port2]);}catch(z){R(new P(`Failed to initialize popup: ${z}`));return}o(n,r).then(z=>{if(l||!d)return;if(this.rendered?.isClosed){if(this.rendered.isClosed())return}else if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected)return}else if(this.popUp?.closed)return;try{d.postMessage({type:"popup-start",payload:z});}catch(Uo){R(new P(`Failed to send request to popup: ${Uo}`));return}g&&(clearTimeout(g),g=null);let $=Math.max(0,z.request.validTill-Date.now());g=setTimeout(()=>{R(new Ce("Request expired"));},$);}).catch(z=>{R(z);});};window.addEventListener("message",h);}};function eo(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
6
6
 
7
7
  ${n.join(`
8
- `)}`:t}function Cd(e){let t=e?.message||"";return t==="Failed to fetch"||t.includes("Load failed")||t.includes("NetworkError")||t.includes("ERR_NETWORK")}async function R(e,t=3,n=500,r=5e3){let o=null;for(let i=0;i<t;i++)try{return await e()}catch(a){if(o=a instanceof Error?a:new Error(String(a)),!Cd(o))throw o;if(i===t-1)break;let s=Math.min(n*Math.pow(2,i),r);await new Promise(c=>setTimeout(c,s));}throw o}async function no({data:e,url:t,options:n}){let i=Od(t),{pendingApprovalsCallback:a,signal:s}=n??{};for(let c=0;c<10;c++){if(s?.aborted)throw Error("Aborted");let d,u;try{u=await hd(i,s),u.send(JSON.stringify({type:"message",data:e})),await yd(u,(l,I)=>{if(l==="error"){let _=I&&typeof I=="object"&&typeof I.error=="string"?I.error:"Unknown error",g=new Error(_);throw g.noRetry=!0,g}return l==="signatures"?(d=I.signatures,!0):(l==="pending_transaction_approval"?a?.onPendingApprovalsCallback?.(I.validTill):l==="transaction_approved"&&a?.onPendingApprovalsSuccess?.(),!1)},s);}catch(l){if(l&&typeof l=="object"&&l.noRetry)throw new Error(`${l.message}`);if(l&&typeof l=="object"&&l.name==="AbortError")throw l}finally{try{u?.close();}catch{}}if(d?.length)return d[0];c<9&&await new Promise(l=>setTimeout(l,400));}throw new Error("Transaction manager: missing signatures")}function Od(e){let t=new URL(e);return t.protocol==="https:"?t.protocol="wss:":t.protocol==="http:"&&(t.protocol="ws:"),t.toString()}function hd(e,t){return new Promise((n,r)=>{let o=new WebSocket(e),i=()=>{try{o.close();}catch{}};t?.addEventListener("abort",i,{once:true}),o.onopen=()=>{t?.removeEventListener("abort",i),n(o);},o.onerror=()=>{t?.removeEventListener("abort",i),r(new Error("WebSocket connection failed"));};})}async function yd(e,t,n){return new Promise((r,o)=>{let i=false,a=()=>{n?.removeEventListener("abort",c),e.removeEventListener("message",d),e.removeEventListener("error",u),e.removeEventListener("close",l);},s=I=>{i||(i=true,a(),I());},c=()=>{try{e.close();}catch{}};n?.addEventListener("abort",c);let d=I=>{if(typeof I.data!="string")return;let _;try{_=JSON.parse(I.data);}catch{return}let g=typeof _.event=="string"?_.event:"message",f=_.data;try{t(g,f)&&s(()=>r());}catch(A){s(()=>o(A));}},u=()=>{s(()=>o(new Error("Transaction manager request failed")));},l=()=>{s(()=>r());};e.addEventListener("message",d),e.addEventListener("error",u),e.addEventListener("close",l);})}async function ro(e,t,n){let{startRequest:r}=t.data.payload;if(!r.data.requireTwoFactorAuthentication)return null;let i=(await R(async()=>core.fetchSettingsAccountData(await core.getSettingsFromIndex(e.settingsIndexWithAddress.index)))).members.find(d=>d.role===core.UserRole.TransactionManager);if(!i)throw new Error("No transaction manager found.");let a=core.convertMemberKeyToString(i.pubkey),s=await R(()=>core.fetchUserAccountData(S(a),i.userAddressTreeIndex));if(s.transactionManagerUrl.__option==="None")throw new Error("No transaction manager url found.");let c=await no({data:{publicKey:a,payload:t},url:s.transactionManagerUrl.value,options:n});return {publicKey:a,signature:c}}async function j_(e,t){let n=async(o,i)=>{let a={phase:"start",rid:o,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"message",payload:to({domain:i,nonce:U().decode(crypto.getRandomValues(new Uint8Array(16)))}),requireTwoFactorAuthentication:t?.requireTwoFactorAuthentication??false},clientOrigin:i},{signature:s,validTill:c}=await R(()=>e.onClientAuthorizationCallback(a));return {request:{...a,rid:o,validTill:c},signature:s}},r=async o=>{let i=core.UserInfoSchema.parse(o.data.payload.additionalInfo),a=await ro(i,o,t);return await e.onClientAuthorizationCallback(a?{...o,data:{...o.data,payload:{...o.data.payload,transactionManager:a}}}:o),{user:i}};return e.sendRequestToPopupProvider({onConnectedCallback:n,onSuccessCallback:r,signal:t?.signal})}var de="11111111111111111111111111111111";var oo=0,io=1,ao=2,so=3,co=4,uo=5,lo=6,Io=7,_o=8;process.env.NODE_ENV!=="production"&&({[oo]:"an account with the same address already exists",[uo]:"provided address does not match addressed derived from seed",[so]:"cannot allocate account data of this length",[ao]:"cannot assign account to this program id",[co]:"length of requested seed is too long",[Io]:"stored nonce is still in recent_blockhashes",[lo]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[_o]:"specified nonce does not match stored nonce",[io]:"account does not have enough SOL to perform the operation"});var Xt="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";function Ao(){return Se([["discriminator",Re()],["deactivationSlot",oe()],["lastExtendedSlot",oe()],["lastExtendedSlotStartIndex",H()],["authority",Or(G(),{noneValue:"zeroes"})],["padding",Dr()],["addresses",Be(G(),{size:"remainder"})]])}function Eo(e){return cr(e,Ao())}async function Zt(e,t,n){let r=await Ir(e,t,n);return Eo(r)}async function et({instructions:e,payer:t,addressesByLookupTableAddress:n}){let r=await R(()=>core.getSolanaRpc().getLatestBlockhash().send()),o=await pe(xe({version:0}),i=>We(e,i),i=>$e(t,i),i=>ke(r.value,i),i=>n?zt(i,n):i,async i=>{let[a,s]=await Promise.all([zd(i),kd(core.getSolanaRpc(),i.instructions.flatMap(d=>d.accounts??[]))]),c=Math.ceil((Number(a)??0)*1.1);return Ge([...c>2e5?[ce({units:c})]:[],...s>0?[Ne({microLamports:s})]:[]],i)},async i=>await R(async()=>je(await i)));return await R(()=>core.getSolanaRpc().sendTransaction(ne(o),{skipPreflight:!0,encoding:"base64"}).send()),Ve(o)}async function Ro(e,t){let n=await go(t,true),r=await Fd(n.map(ne),core.getSolanaRpcEndpoint()),o=await go(t.map((i,a)=>({...i,unitsConsumed:r[a]})));return await R(()=>e.onSendJitoBundleCallback(o.map(ne))),Ve(o[o.length-1])}async function Fd(e,t){let r=await(await R(()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"2",method:"simulateBundle",params:[{encodedTransactions:e},{skipSigVerify:!0,replaceRecentBlockhash:!0,preExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]})),postExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]}))}]})}))).json();if(!r.result||r.error)throw new Error(`Unable to simulate bundle: ${JSON.stringify(r.error??r.result)}`);if(typeof r.result.value.summary!="string"&&r.result.value.summary.failed){let{TransactionFailure:o}=r.result.value.summary.failed.error,[,i]=o;throw new Error(`Simulation failed: ${i}`)}return r.result.value.transactionResults.map(o=>o.unitsConsumed)}async function go(e,t=false){let n=t?{blockhash:yr().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)}:(await R(()=>core.getSolanaRpc().getLatestBlockhash().send())).value;return await Promise.all(e.map(async r=>await pe(xe({version:0}),i=>We(r.instructions,i),i=>$e(r.payer,i),i=>ke(n,i),i=>r.addressesByLookupTableAddress?zt(i,r.addressesByLookupTableAddress):i,i=>{let a=Math.ceil((r.unitsConsumed??0)*1.1);return a>2e5?Ge([ce({units:a})],i):i},async i=>t?te(i):await R(()=>je(i)))))}async function zd(e){let t=Ge([ce({units:8e5}),Ne({microLamports:1e4})],e),n=te(t),r=await R(()=>core.getSolanaRpc().simulateTransaction(ne(n),{encoding:"base64"}).send());if(r.value.err){if(r.value.logs){let i=["Transaction simulation failed:","",...r.value.logs].join(`
8
+ `)}`:t}function Nu(e){let t=e?.message||"";return t==="Failed to fetch"||t.includes("Load failed")||t.includes("NetworkError")||t.includes("ERR_NETWORK")}async function E(e,t=3,n=500,r=5e3){let o=null;for(let i=0;i<t;i++)try{return await e()}catch(a){if(o=a instanceof Error?a:new Error(String(a)),!Nu(o))throw o;if(i===t-1)break;let s=Math.min(n*Math.pow(2,i),r);await new Promise(c=>setTimeout(c,s));}throw o}async function to({data:e,url:t,options:n}){let i=Cu(t),{pendingApprovalsCallback:a,signal:s}=n??{};for(let c=0;c<10;c++){if(s?.aborted)throw Error("Aborted");let u,d;try{d=await Ou(i,s),d.send(JSON.stringify({type:"message",data:e})),await hu(d,(l,I)=>{if(l==="error"){let _=I&&typeof I=="object"&&typeof I.error=="string"?I.error:"Unknown error",g=new Error(_);throw g.noRetry=!0,g}return l==="signatures"?(u=I.signatures,!0):(l==="pending_transaction_approval"?a?.onPendingApprovalsCallback?.(I.validTill):l==="transaction_approved"&&a?.onPendingApprovalsSuccess?.(),!1)},s);}catch(l){if(l&&typeof l=="object"&&l.noRetry)throw new Error(`${l.message}`);if(l&&typeof l=="object"&&l.name==="AbortError")throw l}finally{try{d?.close();}catch{}}if(u?.length)return u[0];c<9&&await new Promise(l=>setTimeout(l,400));}throw new Error("Transaction manager: missing signatures")}function Cu(e){let t=new URL(e);return t.protocol==="https:"?t.protocol="wss:":t.protocol==="http:"&&(t.protocol="ws:"),t.toString()}function Ou(e,t){return new Promise((n,r)=>{let o=new WebSocket(e),i=()=>{try{o.close();}catch{}};t?.addEventListener("abort",i,{once:true}),o.onopen=()=>{t?.removeEventListener("abort",i),n(o);},o.onerror=()=>{t?.removeEventListener("abort",i),r(new Error("WebSocket connection failed"));};})}async function hu(e,t,n){return new Promise((r,o)=>{let i=false,a=()=>{n?.removeEventListener("abort",c),e.removeEventListener("message",u),e.removeEventListener("error",d),e.removeEventListener("close",l);},s=I=>{i||(i=true,a(),I());},c=()=>{try{e.close();}catch{}};n?.addEventListener("abort",c);let u=I=>{if(typeof I.data!="string")return;let _;try{_=JSON.parse(I.data);}catch{return}let g=typeof _.event=="string"?_.event:"message",f=_.data;try{t(g,f)&&s(()=>r());}catch(R){s(()=>o(R));}},d=()=>{s(()=>o(new Error("Transaction manager request failed")));},l=()=>{s(()=>r());};e.addEventListener("message",u),e.addEventListener("error",d),e.addEventListener("close",l);})}async function ro(e,t,n){let{startRequest:r}=t.data.payload;if(!r.data.requireTwoFactorAuthentication)return null;let i=(await E(async()=>core.fetchSettings(core.getSolanaRpc(),await core.getSettingsFromIndex(e.settingsIndexWithAddress.index)))).data.members.find(u=>u.role===core.UserRole.TransactionManager);if(!i)throw new Error("No transaction manager found.");let a=core.convertMemberKeyToString(i.pubkey),s=(await E(async()=>core.fetchUser(core.getSolanaRpc(),await core.getUserAddress(S(a))))).data;if(s.transactionManagerUrl.__option==="None")throw new Error("No transaction manager url found.");let c=await to({data:{publicKey:a,payload:t},url:s.transactionManagerUrl.value,options:n});return {publicKey:a,signature:c}}async function J_(e,t){let n=async(o,i)=>{let a={phase:"start",rid:o,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"message",payload:eo({domain:i,nonce:b().decode(crypto.getRandomValues(new Uint8Array(16)))}),requireTwoFactorAuthentication:t?.requireTwoFactorAuthentication??false},clientOrigin:i},{signature:s,validTill:c}=await E(()=>e.onClientAuthorizationCallback(a));return {request:{...a,rid:o,validTill:c},signature:s}},r=async o=>{let i=core.UserInfoSchema.parse(o.data.payload.additionalInfo),a=await ro(i,o,t);return await e.onClientAuthorizationCallback(a?{...o,data:{...o.data,payload:{...o.data.payload,transactionManager:a}}}:o),{user:i}};return e.sendRequestToPopupProvider({onConnectedCallback:n,onSuccessCallback:r,signal:t?.signal})}var ce="11111111111111111111111111111111";var oo=0,io=1,ao=2,so=3,co=4,uo=5,lo=6,Io=7,_o=8;process.env.NODE_ENV!=="production"&&({[oo]:"an account with the same address already exists",[uo]:"provided address does not match addressed derived from seed",[so]:"cannot allocate account data of this length",[ao]:"cannot assign account to this program id",[co]:"length of requested seed is too long",[Io]:"stored nonce is still in recent_blockhashes",[lo]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[_o]:"specified nonce does not match stored nonce",[io]:"account does not have enough SOL to perform the operation"});var qt="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";function Ao(){return De([["discriminator",ge()],["deactivationSlot",re()],["lastExtendedSlot",re()],["lastExtendedSlotStartIndex",V()],["authority",Cr(W(),{noneValue:"zeroes"})],["padding",fr()],["addresses",Pe(W(),{size:"remainder"})]])}function Eo(e){return sr(e,Ao())}async function Xt(e,t,n){let r=await lr(e,t,n);return Eo(r)}async function Qe({instructions:e,payer:t,addressesByLookupTableAddress:n}){let r=await E(()=>core.getSolanaRpc().getLatestBlockhash().send()),o=await Se(ke({version:0}),i=>xe(e,i),i=>Ke(t,i),i=>ze(r.value,i),i=>n?Ft(i,n):i,async i=>{let[a,s]=await Promise.all([zu(i),ku(core.getSolanaRpc(),i.instructions.flatMap(u=>u.accounts??[]))]),c=Math.ceil((Number(a)??0)*1.1);return We([...c>2e5?[se({units:c})]:[],...s>0?[me({microLamports:s})]:[]],i)},async i=>await E(async()=>$e(await i)));return await E(()=>core.getSolanaRpc().sendTransaction(te(o),{skipPreflight:!0,encoding:"base64"}).send()),Ge(o)}async function Ro(e,t){let n=await go(t,true),r=await Fu(n.map(te),core.getSolanaRpcEndpoint()),o=await go(t.map((i,a)=>({...i,unitsConsumed:r[a]})));return await E(()=>e.onSendJitoBundleCallback(o.map(te))),Ge(o[o.length-1])}async function Fu(e,t){let r=await(await E(()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"2",method:"simulateBundle",params:[{encodedTransactions:e},{skipSigVerify:!0,replaceRecentBlockhash:!0,preExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]})),postExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]}))}]})}))).json();if(!r.result||r.error)throw new Error(`Unable to simulate bundle: ${JSON.stringify(r.error??r.result)}`);if(typeof r.result.value.summary!="string"&&r.result.value.summary.failed){let{TransactionFailure:o}=r.result.value.summary.failed.error,[,i]=o;throw new Error(`Simulation failed: ${i}`)}return r.result.value.transactionResults.map(o=>o.unitsConsumed)}async function go(e,t=false){let n=t?{blockhash:hr().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)}:(await E(()=>core.getSolanaRpc().getLatestBlockhash().send())).value;return await Promise.all(e.map(async r=>await Se(ke({version:0}),i=>xe(r.instructions,i),i=>Ke(r.payer,i),i=>ze(n,i),i=>r.addressesByLookupTableAddress?Ft(i,r.addressesByLookupTableAddress):i,i=>{let a=Math.ceil((r.unitsConsumed??0)*1.1);return a>2e5?We([se({units:a})],i):i},async i=>t?ee(i):await E(()=>$e(i)))))}async function zu(e){let t=We([se({units:8e5}),me({microLamports:1e4})],e),n=ee(t),r=await E(()=>core.getSolanaRpc().simulateTransaction(te(n),{encoding:"base64"}).send());if(r.value.err){if(r.value.logs){let i=["Transaction simulation failed:","",...r.value.logs].join(`
9
9
  `);throw new Error(i)}let o=["Transaction simulation failed:","",r.value.err.toString()].join(`
10
- `);throw new Error(o)}return r.value.unitsConsumed}async function kd(e,t){let r=(await R(()=>e.getRecentPrioritizationFees(t.filter(i=>i.role===y.WRITABLE||i.role===y.WRITABLE_SIGNER).map(i=>i.address)).send())).map(i=>Number(i.prioritizationFee));r.sort((i,a)=>i-a);let o=Math.floor(r.length/2);return r.length%2===0?Math.round((r[o-1]+r[o])/2):r[o]}var fo=new Map;async function ue(){let e=fo.get(Ce);if(e)return e;let t=await R(()=>fetch(`${Ce}/getRandomPayer`));if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=Gd(S(n),`${Ce}/sign`);return fo.set(Ce,r),r}function Gd(e,t){return {address:e,async signTransactions(r){let o={publicKey:e,transactions:r.map(s=>U().decode(Wt().encode(s)))},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to sign transactions: ${i.statusText}`);let a=await i.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:ee().encode(s)}))}}}async function le(e){let{transactionManagerAddress:t,transactionMessageBytes:n,userAddressTreeIndex:r,authResponses:o,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:s,abortSignal:c,cachedAccounts:d}=e,u=s;if(c&&!u){let _=new AbortController;c.aborted?_.abort():c.addEventListener("abort",()=>_.abort(),{once:true}),u=_;}let l;if(t){let _=(await R(()=>core.fetchUserAccountData(t,r,d))).transactionManagerUrl;l=_.__option==="Some"?_.value:null;}return t&&l?core.createTransactionManagerSigner({address:t,url:l,authResponses:o,transactionMessageBytes:n,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:u}):null}async function Ie(e){if(!e)return await R(()=>Wr([S(qe)],core.getSolanaRpc()));if(qe in e)return e;let t=await R(()=>Zt(core.getSolanaRpc(),S(qe)));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function Do(e,t){let{authResponse:n,settings:r,additionalSigners:o,options:i,payer:a,settingsAddressTreeIndex:s}=t,{startRequest:c,signer:d}=n;if(c.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:l}=c.data.payload;if(u!=="execute"&&u!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let I=new Map,[_,g,f]=await Promise.all([a??ue(),R(()=>core.fetchSettingsAccountData(r,s,I)),core.getSignedSecp256r1Key(n)]),A=core.retrieveTransactionManager(d,g),[m,C]=await Promise.all([le({authResponses:[n],transactionManagerAddress:A?.transactionManagerAddress,userAddressTreeIndex:A?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal,cachedAccounts:I}),R(()=>e.onEstimateJitoTipsCallback())]),T=await core.prepareTransactionBundle({compressed:g.isCompressed,settings:r,settingsAddressTreeIndex:s,transactionMessageBytes:b().encode(l),creator:m??f,executor:m?f:void 0,jitoBundlesTipAmount:C,additionalSigners:o,payer:_,cachedAccounts:I}),O=await Promise.all(T.map(async M=>({...M,addressesByLookupTableAddress:await Ie(M.addressesByLookupTableAddress)})));return Ro(e,O)}async function So(e){let{authResponse:t,settings:n,payer:r,additionalSigners:o,settingsAddressTreeIndex:i,options:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionMessageBytes:u}=s.data.payload;if(d!=="sync")throw new Error("Transaction action type must be 'sync'");let l=new Map,[I,_,g]=await Promise.all([r??ue(),R(()=>core.fetchSettingsAccountData(n,i,l)),core.getSignedSecp256r1Key(t)]),f=core.retrieveTransactionManager(c,_),A=await le({authResponses:[t],transactionManagerAddress:f?.transactionManagerAddress,userAddressTreeIndex:f?.userAddressTreeIndex,transactionMessageBytes:b().encode(u),onPendingApprovalsCallback:a?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:a?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:a?.signal,cachedAccounts:l}),m=A?[g,A]:[g],{instructions:C,addressesByLookupTableAddress:T}=await core.prepareTransactionSync({compressed:_.isCompressed,signers:m,payer:I,transactionMessageBytes:b().encode(u),settings:n,settingsAddressTreeIndex:i,cachedAccounts:l,additionalSigners:o});return et({instructions:C,payer:I,addressesByLookupTableAddress:await Ie(T)})}async function po(e){let{authResponse:t,settings:n,settingsAddressTreeIndex:r,options:o,payer:i,addressesByLookupTableAddress:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionAddress:u,transactionMessageBytes:l}=s.data.payload;if(d!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let I=b().encode(l),_=oe().decode(I.slice(0,8)),g=G().decode(I.slice(8,40)),f=G().decode(I.slice(40,72)),A=new Map,[m,C,T]=await Promise.all([i??ue(),R(()=>core.fetchSettingsAccountData(n,r,A)),core.getSignedSecp256r1Key(t)]),O=core.retrieveTransactionManager(c,C),M=await le({authResponses:[t],transactionManagerAddress:O?.transactionManagerAddress,userAddressTreeIndex:O?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:o?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:o?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:o?.signal,cachedAccounts:A}),J=M?[T,M]:[T],v=f!==de?await core.tokenTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,mint:f,tokenProgram:S(u),compressed:C.isCompressed,cachedAccounts:A}):await core.nativeTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,compressed:C.isCompressed,cachedAccounts:A});return et({instructions:v,payer:m,addressesByLookupTableAddress:await Ie(a)})}async function mo(e,t=30,n=2e3){for(let r=0;r<t;r++){let i=(await R(()=>core.getSolanaRpc().getSignatureStatuses([e]).send())).value[0];if(i?.confirmationStatus==="confirmed"||i?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function tt(e,t){let{user:n,request:r,additionalSigners:o,options:i,payer:a,addressesByLookupTableAddress:s}=t,{confirmTransaction:c=true}=i??{},d=r.data.type==="transaction"&&r.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?r.data.payload.startRequest.data.payload.transactionAddress:n.settingsIndexWithAddress?.index?await core.getSettingsFromIndex(n.settingsIndexWithAddress.index):null;if(!d)throw Error("User is not delegated to any wallet");let u;switch(r.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":u=await po({authResponse:r.data.payload,settings:S(d),options:i,payer:a,addressesByLookupTableAddress:s});break;case "execute":case "create_with_preauthorized_execution":u=await Do(e,{authResponse:r.data.payload,settings:S(d),additionalSigners:o,options:i,payer:a});break;case "sync":u=await So({authResponse:r.data.payload,settings:S(d),additionalSigners:o,options:i,payer:a});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return c&&await mo(u),u}async function Sv(e,t,n){let{instructions:r,signer:o,addressesByLookupTableAddress:i,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t,d=async(l,I)=>{let _=core.prepareTransactionMessage({payer:S(o.walletAddress),instructions:r,addressesByLookupTableAddress:i}),g=a??o.settingsIndexWithAddress,f=await core.getSettingsFromIndex(g.index),m=(await R(()=>core.fetchSettingsAccountData(f,g.settingsAddressTreeIndex))).members.some(J=>J.role===core.UserRole.TransactionManager),C={transactionMessageBytes:U().decode(_),transactionAddress:f,transactionActionType:m?"execute":"create_with_preauthorized_execution"},T={phase:"start",rid:l,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:C},clientOrigin:I,signer:o.publicKey},{signature:O,validTill:M}=await R(()=>e.onClientAuthorizationCallback(T));return {request:{...T,rid:l,validTill:M},signature:O}},u=async l=>{let{signature:I}=await e.onClientAuthorizationCallback(l),_=core.UserInfoSchema.parse(l.data.payload.additionalInfo),g=await tt(e,{user:_,request:{...l,data:{...l.data,payload:{...l.data.payload,client:{...l.data.payload.client,jws:I}}}},options:n,additionalSigners:s,addressesByLookupTableAddress:i,payer:c});return {user:_,txSig:g}};return e.sendRequestToPopupProvider({onConnectedCallback:d,onSuccessCallback:u,signal:n?.signal})}async function yv(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:o=Xt,amount:i,destination:a,signer:s,payer:c,addressesByLookupTableAddress:d}=t,u=async(I,_)=>{let g={transactionActionType:"transfer_intent",transactionAddress:r?o:de,transactionMessageBytes:U().decode(new Uint8Array([...Te().encode(i),...W().encode(S(a)),...W().encode(S(r??de))]))},f={phase:"start",rid:I,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:g},clientOrigin:_,signer:s?.publicKey},{signature:A,validTill:m}=await R(()=>e.onClientAuthorizationCallback(f));return {request:{...f,rid:I,validTill:m},signature:A}},l=async I=>{let{signature:_}=await e.onClientAuthorizationCallback(I),g=core.UserInfoSchema.parse(I.data.payload.additionalInfo);return {txSig:await tt(e,{user:g,request:{...I,data:{...I.data,payload:{...I.data.payload,client:{...I.data.payload.client,jws:_}}}},options:n,addressesByLookupTableAddress:d,payer:c}),user:g}};return e.sendRequestToPopupProvider({onConnectedCallback:u,onSuccessCallback:l,signal:n?.signal})}async function No(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=Date.now()+jr,o=core.convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge({...e,validTill:r})).setProtectedHeader({alg:o.alg}).sign(o),validTill:r}}function _e(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function yo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>o.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,new Uint8Array([...core.getSecp256r1MessageHash(e.data.payload.authResponse),...be().encode(jsonCanonicalize.canonicalize(o.device.deviceProfile))])))throw new Error("Invalid device signature")}let i=core.createMessageChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid),{verified:a}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(i),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!a)throw new Error("Invalid user siganture");if(r){if(!o.startRequest.data.requireTwoFactorAuthentication)throw new Error("Two factor authentication is required.");if(!o.transactionManager)throw new Error("Missing signature from transaction manager.");let c=(await core.fetchUserAccountByFilters(await core.getDomainConfigAddress({rpId:o.startRequest.rpId}),{credentialId:o.authResponse.id}))?.wallets.find(l=>l.isDelegate);if(!c)throw new Error("User does not have a delegated wallet");let u=(await core.fetchSettingsAccountData(await core.getSettingsFromIndex(c.index))).members.find(l=>l.role===core.UserRole.TransactionManager);if(!u)throw new Error("No transaction manager found.");if(o.transactionManager.publicKey!==core.convertMemberKeyToString(u.pubkey))throw new Error("Transaction manager mismatch.");if(!await Yt(S(o.transactionManager.publicKey),o.transactionManager.signature,i))throw new Error("Invalid transaction manager signature.")}return {ok:true}}async function bo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(o.startRequest.validTill,o.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,new Uint8Array([...core.getSecp256r1MessageHash(e.data.payload.authResponse),...be().encode(jsonCanonicalize.canonicalize(o.device.deviceProfile))])))throw new Error("Invalid device signature")}{let{challenge:s}=await core.createTransactionChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid,o.slotHash,o.slotNumber,o.estimatedSlotHashExpiry),{verified:c}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(s),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!c)throw new Error("Invalid user siganture")}let i=core.convertBase64StringToJWK(r);if(!i.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:i.alg}).sign(i)}}var Uo=false;function Bu(e){Uo||e&&(core.initialize({rpcEndpoint:e}),Uo=true);}async function iP({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,requireTwoFactorAuthentication:o}){if(Bu(o?.rpcEndpoint),e.phase==="start"){if(e.data.type==="message"&&!!o!==e.data.requireTwoFactorAuthentication)throw new Error("Require 2fa check mismatch");return await No(e,n,r)}else if(e.phase==="complete"){if(e.data.type==="message")return await yo(e,t,n,!!o);if(e.data.type==="transaction")return await bo(e,t,n,r);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function cP(e="landed_tips_75th_percentile",t=Kr){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function lP(e,t,n=Hr){let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:i}),!(a.status!==429||c===5));c++){let d=Math.min(1e4,250*2**c);await Fu(d);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var Fu=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
10
+ `);throw new Error(o)}return r.value.unitsConsumed}async function ku(e,t){let r=(await E(()=>e.getRecentPrioritizationFees(t.filter(i=>i.role===O.WRITABLE||i.role===O.WRITABLE_SIGNER).map(i=>i.address)).send())).map(i=>Number(i.prioritizationFee));r.sort((i,a)=>i-a);let o=Math.floor(r.length/2);return r.length%2===0?Math.round((r[o-1]+r[o])/2):r[o]}var To=new Map;async function ue(){let e=To.get(Ne);if(e)return e;let t=await E(()=>fetch(`${Ne}/getRandomPayer`));if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=Vu(S(n),`${Ne}/sign`);return To.set(Ne,r),r}function Vu(e,t){return {address:e,async signTransactions(r){let o={publicKey:e,transactions:r.map(s=>b().decode(xt().encode(s)))},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to sign transactions: ${i.statusText}`);let a=await i.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:Q().encode(s)}))}}}async function de(e){let{transactionManagerAddress:t,transactionMessageBytes:n,authResponses:r,onPendingApprovalsCallback:o,onPendingApprovalsSuccess:i,abortController:a,abortSignal:s}=e,c=a;if(s&&!c){let l=new AbortController;s.aborted?l.abort():s.addEventListener("abort",()=>l.abort(),{once:true}),c=l;}let u;if(t){let l=(await E(async()=>core.fetchUser(core.getSolanaRpc(),await core.getUserAddress(t)))).data.transactionManagerUrl;u=l.__option==="Some"?l.value:null;}return t&&u?core.createTransactionManagerSigner({address:t,url:u,authResponses:r,transactionMessageBytes:n,onPendingApprovalsCallback:o,onPendingApprovalsSuccess:i,abortController:c}):null}async function le(e){if(!e)return await E(()=>xr([S(Ye)],core.getSolanaRpc()));if(Ye in e)return e;let t=await E(()=>Xt(core.getSolanaRpc(),S(Ye)));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function fo(e,t){let{authResponse:n,settings:r,additionalSigners:o,options:i,payer:a}=t,{startRequest:s,signer:c}=n;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:d}=s.data.payload;if(u!=="execute"&&u!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let[l,I,_]=await Promise.all([a??ue(),(await E(()=>core.fetchSettings(core.getSolanaRpc(),r))).data,core.getSignedSecp256r1Key(n)]),g=core.retrieveTransactionManager(c,I),[f,R]=await Promise.all([de({authResponses:[n],transactionManagerAddress:g?.transactionManagerAddress,transactionMessageBytes:L().encode(d),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal}),E(()=>e.onEstimateJitoTipsCallback())]),m=await core.prepareTransactionBundle({settings:r,transactionMessageBytes:L().encode(d),creator:f??_,executor:f?_:void 0,jitoBundlesTipAmount:R,additionalSigners:o,payer:l}),h=await Promise.all(m.map(async T=>({...T,addressesByLookupTableAddress:await le(T.addressesByLookupTableAddress)})));return Ro(e,h)}async function Do(e){let{authResponse:t,settings:n,payer:r,additionalSigners:o,options:i}=e,{startRequest:a,signer:s}=t;if(a.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:c,transactionMessageBytes:u}=a.data.payload;if(c!=="sync")throw new Error("Transaction action type must be 'sync'");let[d,l,I]=await Promise.all([r??ue(),(await E(()=>core.fetchSettings(core.getSolanaRpc(),n))).data,core.getSignedSecp256r1Key(t)]),_=core.retrieveTransactionManager(s,l),g=await de({authResponses:[t],transactionManagerAddress:_?.transactionManagerAddress,transactionMessageBytes:L().encode(u),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal}),f=g?[I,g]:[I],{instructions:R,addressesByLookupTableAddress:m}=await core.prepareTransactionSync({signers:f,payer:d,transactionMessageBytes:L().encode(u),settings:n,additionalSigners:o});return Qe({instructions:R,payer:d,addressesByLookupTableAddress:await le(m)})}async function So(e){let{authResponse:t,settings:n,options:r,payer:o,addressesByLookupTableAddress:i}=e,{startRequest:a,signer:s}=t;if(a.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:c,transactionAddress:u,transactionMessageBytes:d}=a.data.payload;if(c!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let l=L().encode(d),I=re().decode(l.slice(0,8)),_=W().decode(l.slice(8,40)),g=W().decode(l.slice(40,72)),[f,R,m]=await Promise.all([o??ue(),(await E(()=>core.fetchSettings(core.getSolanaRpc(),n))).data,core.getSignedSecp256r1Key(t)]),h=core.retrieveTransactionManager(s,R),T=await de({authResponses:[t],transactionManagerAddress:h?.transactionManagerAddress,transactionMessageBytes:L().encode(d),onPendingApprovalsCallback:r?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:r?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:r?.signal}),y=T?[m,T]:[m],K=g!==ce?await core.tokenTransferIntent({payer:f,settings:n,amount:I,signers:y,destination:_,mint:g,tokenProgram:S(u)}):await core.nativeTransferIntent({settings:n,amount:I,signers:y,destination:_});return Qe({instructions:K,payer:f,addressesByLookupTableAddress:await le(i)})}async function po(e,t=30,n=2e3){for(let r=0;r<t;r++){let i=(await E(()=>core.getSolanaRpc().getSignatureStatuses([e]).send())).value[0];if(i?.confirmationStatus==="confirmed"||i?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function et(e,t){let{user:n,request:r,additionalSigners:o,options:i,payer:a,addressesByLookupTableAddress:s}=t,{confirmTransaction:c=true}=i??{},u=r.data.type==="transaction"&&r.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?r.data.payload.startRequest.data.payload.transactionAddress:n.settingsIndexWithAddress?.index?await core.getSettingsFromIndex(n.settingsIndexWithAddress.index):null;if(!u)throw Error("User is not delegated to any wallet");let d;switch(r.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":d=await So({authResponse:r.data.payload,settings:S(u),options:i,payer:a,addressesByLookupTableAddress:s});break;case "execute":case "create_with_preauthorized_execution":d=await fo(e,{authResponse:r.data.payload,settings:S(u),additionalSigners:o,options:i,payer:a});break;case "sync":d=await Do({authResponse:r.data.payload,settings:S(u),additionalSigners:o,options:i,payer:a});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return c&&await po(d),d}async function Ov(e,t,n){let{instructions:r,signer:o,addressesByLookupTableAddress:i,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t,u=async(l,I)=>{let _=core.prepareTransactionMessage({payer:S(o.walletAddress),instructions:r,addressesByLookupTableAddress:i}),g=a??o.settingsIndexWithAddress,f=await core.getSettingsFromIndex(g.index),m=(await E(()=>core.fetchSettings(core.getSolanaRpc(),f))).data.members.some(ye=>ye.role===core.UserRole.TransactionManager),h={transactionMessageBytes:b().decode(_),transactionAddress:f,transactionActionType:m?"execute":"create_with_preauthorized_execution"},T={phase:"start",rid:l,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:h},clientOrigin:I,signer:o.publicKey},{signature:y,validTill:K}=await E(()=>e.onClientAuthorizationCallback(T));return {request:{...T,rid:l,validTill:K},signature:y}},d=async l=>{let{signature:I}=await e.onClientAuthorizationCallback(l),_=core.UserInfoSchema.parse(l.data.payload.additionalInfo),g=await et(e,{user:_,request:{...l,data:{...l.data,payload:{...l.data.payload,client:{...l.data.payload.client,jws:I}}}},options:n,additionalSigners:s,addressesByLookupTableAddress:i,payer:c});return {user:_,txSig:g}};return e.sendRequestToPopupProvider({onConnectedCallback:u,onSuccessCallback:d,signal:n?.signal})}async function wv(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:o=qt,amount:i,destination:a,signer:s,payer:c,addressesByLookupTableAddress:u}=t,d=async(I,_)=>{let g={transactionActionType:"transfer_intent",transactionAddress:r?o:ce,transactionMessageBytes:b().decode(new Uint8Array([...Re().encode(i),...x().encode(S(a)),...x().encode(S(r??ce))]))},f={phase:"start",rid:I,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:g},clientOrigin:_,signer:s?.publicKey},{signature:R,validTill:m}=await E(()=>e.onClientAuthorizationCallback(f));return {request:{...f,rid:I,validTill:m},signature:R}},l=async I=>{let{signature:_}=await e.onClientAuthorizationCallback(I),g=core.UserInfoSchema.parse(I.data.payload.additionalInfo);return {txSig:await et(e,{user:g,request:{...I,data:{...I.data,payload:{...I.data.payload,client:{...I.data.payload.client,jws:_}}}},options:n,addressesByLookupTableAddress:u,payer:c}),user:g}};return e.sendRequestToPopupProvider({onConnectedCallback:d,onSuccessCallback:l,signal:n?.signal})}async function mo(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=Date.now()+$r,o=core.convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge({...e,validTill:r})).setProtectedHeader({alg:o.alg}).sign(o),validTill:r}}function Ie(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function ho(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>o.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!Ie(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!Ie(c.payload,core.getDeviceMessageHash(o.authResponse,o.device.deviceProfile)))throw new Error("Invalid device signature")}let i=core.createMessageChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid),{verified:a}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(i),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!a)throw new Error("Invalid user siganture");if(r){if(!o.startRequest.data.requireTwoFactorAuthentication)throw new Error("Two factor authentication is required.");if(!o.transactionManager)throw new Error("Missing signature from transaction manager.");let c=(await core.fetchUserAccountByFilters(await core.getDomainConfigAddress({rpId:o.startRequest.rpId}),{credentialId:o.authResponse.id}))?.wallets.find(l=>l.isDelegate);if(!c)throw new Error("User does not have a delegated wallet");let d=(await core.fetchSettings(core.getSolanaRpc(),await core.getSettingsFromIndex(c.index))).data.members.find(l=>l.role===core.UserRole.TransactionManager);if(!d)throw new Error("No transaction manager found.");if(o.transactionManager.publicKey!==core.convertMemberKeyToString(d.pubkey))throw new Error("Transaction manager mismatch.");if(!await jt(S(o.transactionManager.publicKey),o.transactionManager.signature,i))throw new Error("Invalid transaction manager signature.")}return {ok:true}}async function Lo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(o.startRequest.validTill,o.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!Ie(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!Ie(c.payload,core.getDeviceMessageHash(o.authResponse,o.device.deviceProfile)))throw new Error("Invalid device signature")}{let{challenge:s}=await core.createTransactionChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid,o.slotHash,o.slotNumber,o.estimatedSlotHashExpiry),{verified:c}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(s),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!c)throw new Error("Invalid user siganture")}let i=core.convertBase64StringToJWK(r);if(!i.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:i.alg}).sign(i)}}var bo=false;function xd(e){bo||e&&(core.initialize({rpcEndpoint:e}),bo=true);}async function sP({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,requireTwoFactorAuthentication:o}){if(xd(o?.rpcEndpoint),e.phase==="start"){if(e.data.type==="message"&&!!o!==e.data.requireTwoFactorAuthentication)throw new Error("Require 2fa check mismatch");return await mo(e,n,r)}else if(e.phase==="complete"){if(e.data.type==="message")return await ho(e,t,n,!!o);if(e.data.type==="transaction")return await Lo(e,t,n,r);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function dP(e="landed_tips_75th_percentile",t=Hr){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function _P(e,t,n=Vr){let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:i}),!(a.status!==429||c===5));c++){let u=Math.min(1e4,250*2**c);await Wd(u);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var Wd=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
11
11
 
12
12
  @noble/curves/utils.js:
13
13
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
14
- */exports.RevibaseAbortedError=Je;exports.RevibaseApiError=he;exports.RevibaseAuthError=F;exports.RevibaseEnvironmentError=Qe;exports.RevibaseError=B;exports.RevibaseFlowInProgressError=Ze;exports.RevibasePopupBlockedError=Xe;exports.RevibasePopupClosedError=k;exports.RevibasePopupNotOpenError=$r;exports.RevibaseProvider=eo;exports.RevibaseTimeoutError=Oe;exports.executeTransaction=Sv;exports.processClientAuthCallback=iP;exports.processEstimateJitoTipsCallback=cP;exports.processSendJitoBundleCallback=lP;exports.signIn=j_;exports.transferTokens=yv;//# sourceMappingURL=index.cjs.map
14
+ */exports.RevibaseAbortedError=Ze;exports.RevibaseApiError=Oe;exports.RevibaseAuthError=P;exports.RevibaseEnvironmentError=Je;exports.RevibaseError=v;exports.RevibaseFlowInProgressError=Xe;exports.RevibasePopupBlockedError=qe;exports.RevibasePopupClosedError=F;exports.RevibasePopupNotOpenError=Kr;exports.RevibaseProvider=Qr;exports.RevibaseTimeoutError=Ce;exports.executeTransaction=Ov;exports.processClientAuthCallback=sP;exports.processEstimateJitoTipsCallback=dP;exports.processSendJitoBundleCallback=_P;exports.signIn=J_;exports.transferTokens=wv;//# sourceMappingURL=index.cjs.map
15
15
  //# sourceMappingURL=index.cjs.map