import { CIRCOM_P as e } from "../../constants/protocol.constants.mjs";
import { ethers as t } from "ethers";
import { BN as n } from "@coral-xyz/anchor";
//#region libs/shared/common/src/functions/pre-transaction/getSolanaCalldataHash.ts
var r = (r, i, a, o, s, c, l, u) => {
	let d = new n(s.toString()), f = new n(c.toString()), p = o.reduce((e, t) => [
		...e,
		...new n(t.length).toArray("be", 8),
		...t
	], []), m = l.reduce((e, t) => {
		let r = [
			...new n(t.programIndex).toArray("be", 1),
			...new n(t.accountIndexes.length).toArray("be", 8),
			...t.accountIndexes,
			...new n(t.data.length).toArray("be", 8),
			...t.data
		];
		return [...e, ...r];
	}, []), h = u.reduce((e, t) => [
		...e,
		+!!t.isWritable,
		...t.pubkey.toBytes()
	], []), g = [
		r.tokenNumber,
		r.nullifierAmount,
		r.outputAmount,
		...i.toBytes(),
		...a.toBytes(),
		...p,
		...d.toArray("be", 8),
		...f.toArray("be", 8),
		...m,
		...h
	];
	return BigInt(t.sha256(new Uint8Array(g))) % e;
};
//#endregion
export { r as getSolanaCalldataHash };
