@revibase/wallet-adapter 0.0.23 → 0.0.24

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