require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`./caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`./bytes32.utils.cjs`),i=require(`../../data-structures/utxo/Utxo.cjs`),a=require(`./bit.operations.cjs`),o=require(`../../data-structures/crypto-keys/encryptDecryptUtxo.cjs`);let s=require(`ethers`),c=require(`@solana/web3.js`),l=require(`@coral-xyz/anchor`);var u=e=>e instanceof Uint8Array?e:Array.isArray(e)?Uint8Array.from(e):new Uint8Array(e),d=(e,o,u,d)=>[...new l.EventParser(o.programId,new l.BorshCoder(o.idl)).parseLogs(e.meta?.logMessages??[])].filter(({name:e})=>t.caseInsensitiveEqual(e,`newCommitment`)).filter(({data:e})=>e.encryptedOutput.length===0).map(e=>{let{onChainData:t}=e.data,[o,l,d,f,p,m,,h]=t.map(r.convertBytes32ToBigInt),[,g,_]=t,v=new c.PublicKey([...g.slice(16),..._.slice(16)]),y=n.poseidonHash(l,d),b=a.extractHighestBit(f)===1n,x=new i.Utxo({amount:o,timeStamp:h.toString(),nullifyingKey:u.getShieldedPrivateKey(),mintAddress:v.toBase58(),erc20TokenAddress:y,stealthAddress:s.ethers.toBeHex(p),isNewStyle:b,...b?{H0:[a.takeOffHighestBit(f),m]}:{randomization:f}});return x.getStealthAddress(),x}).filter(e=>t.caseInsensitiveEqual(e.erc20TokenAddress,d)),f=(e,n,r,i)=>[...new l.EventParser(n.programId,new l.BorshCoder(n.idl)).parseLogs(e.meta?.logMessages??[])].filter(({name:e})=>t.caseInsensitiveEqual(e,`newCommitment`)).filter(({data:e})=>e.encryptedOutput?.length>0).map(e=>{let{encryptedOutput:t}=e.data,n=u(t);try{let e=o.decryptUtxo(n,r);return e.getStealthAddress(),e}catch{return null}}).filter(e=>e!==null).filter(e=>t.caseInsensitiveEqual(e.erc20TokenAddress,i)),p=(n,i)=>{let{contractData:a}=e.networkRegistry[n],{hinkalIdl:o,hinkalAddress:s}=a;if(!o||!s)throw Error(`Missing Solana Hinkal data for chainId ${n}`);return[...new l.EventParser(new c.PublicKey(s),new l.BorshCoder(o)).parseLogs(i.meta?.logMessages??[])].filter(({name:e})=>t.caseInsensitiveEqual(e,`newCommitment`)).map(({data:e})=>{try{return r.convertBytes32ToBigInt(e.commitment).toString()}catch{return null}}).filter(e=>e!==null)};exports.getOnChainUtxosFromReceiptSolana=d,exports.getOutputCommitmentsFromSolanaReceipt=p,exports.getUtxosFromReceiptSolana=f;