const e=require(`../../constants/chains.constants.cjs`),t=require(`../../data-structures/crypto-keys/keys.cjs`),n=require(`../utils/solanaMint.utils.cjs`),r=require(`../snarkjs/common.snarkjs.cjs`),i=require(`../../webworker/worker.registry.cjs`),a=require(`../../webworker/performTaskWithWorker.cjs`),o=require(`../snarkjs/generateZkProof.cjs`),s=require(`../../webworker/zkProofWorker/zkProofWorker.types.cjs`);var c=async(c,l,u,d)=>{let f=e.isSolanaLike(c),p=d.map(e=>e.map(e=>e.amount.toString())),m=d.map(e=>e.map(e=>e.timeStamp)),h=d.map(e=>e.map(e=>r.getUtxoCircuitInRandomization(e))),g=d.map(e=>e.map(e=>e.getConstructableParams())),_=d.map(e=>e.map(e=>e.amount===0n?`0`:BigInt(e.getCommitment()).toString())),v=await a.performTaskWithWorker({type:i.WorkerVariant.ZKProof,payload:{type:s.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:g}}}),y=l.getShieldedPrivateKey(),b=l.getSpendingKeyPair().pubSpendingBJJPoint,x=f?u.map(e=>{let{compressedAddress:t}=n.formatMintAddress(e);return BigInt(t).toString()}):u.map(e=>BigInt(e).toString());d.forEach((e,n)=>{e.forEach((e,r)=>{let i=e.getStealthAddress(),a=e.spendingPublicKey??b,o=e.isNewStyle&&e.H0?t.UserKeys.getStealthAddressNewStyle(e.H0,y,a):t.UserKeys.getStealthAddress(BigInt(e.randomization),y);if(BigInt(i).toString()!==BigInt(o).toString())throw Error(`Commitment validation stealth mismatch at tokenIdx=${n}, utxoIdx=${r}`)})});let S={nullifyingPrivateKey:y,spendingPublicKey:b,erc20TokenAddresses:x,inAmounts:p,inRandomizations:h,inH0Ax:d.map(e=>e.map(e=>r.getUtxoCircuitH0Coords(e)[0].toString())),inH0Ay:d.map(e=>e.map(e=>r.getUtxoCircuitH0Coords(e)[1].toString())),isNewStyle:d.map(e=>e.map(e=>!!e.isNewStyle)),inTimeStamps:m,inCommitments:_,inNullifiers:v};if(!u.length||!d[0]?.length)return;let{zkCallData:C}=await o.generateZkProof(c,`commitmentCalculator${u.length}x${d[0].length}`,S,!1);if(!Array.isArray(C?.[0])||!Array.isArray(C?.[1])||!Array.isArray(C?.[2]))throw Error(`Invalid zkCallData shape for commitment validation`);return{tokenAddresses:x,inAmounts:p,inTimeStamps:m,inRandomizations:h,inCommitments:_,inNullifiers:v,proof:{a:C[0],b:C[1],c:C[2]}}};exports.buildCommitmentValidationData=c;