require(`../../_virtual/_rolldown/runtime.cjs`),require(`../../constants/protocol.constants.cjs`);let e=require(`@solana/web3.js`),t=require(`@solana/spl-token`);var n=async(n,r,i,a,o)=>{let{erc20TokenAddress:s,is2022Program:c,decimals:l}=a,u=[];if(s===`11111111111111111111111111111111`)return u.push(e.SystemProgram.transfer({fromPubkey:r,toPubkey:i,lamports:Number(o)})),{instructions:u,programId:e.SystemProgram.programId};let d=c?t.TOKEN_2022_PROGRAM_ID:t.TOKEN_PROGRAM_ID,f=new e.PublicKey(s),p=await(0,t.getAssociatedTokenAddress)(f,r,!0,d),m=await(0,t.getAssociatedTokenAddress)(f,i,!0,d);return await n.getAccountInfo(m)||u.push((0,t.createAssociatedTokenAccountInstruction)(r,m,i,f,d)),c?u.push((0,t.createTransferCheckedInstruction)(p,f,m,r,o,l,[],d)):u.push((0,t.createTransferInstruction)(p,m,r,o,[],d)),{instructions:u,programId:d}};exports.buildSolanaTransferInstructions=n;