import { ContractType as e } from "../../types/ethereum-network.types.mjs";
import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
import { maxBigInt as n } from "../utils/amounts.utils.mjs";
import { createTransferToEmporiumOp as r } from "../private-wallet/emporium.helpers.mjs";
import { mergeWithFeeStructure as i } from "./merge-with-fee-structure.mjs";
import { getPublicAddressBalance as a } from "../web3/getPublicAddressBalance.mjs";
//#region libs/shared/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.ts
var o = async (o, s, c, l, u, d, f, p) => {
	let m = 0n, h = p < 0n ? p : 0n, g = await a(o, s, f.feeToken, c) + h;
	m = g < 0 ? f.flatFee : n(f.flatFee - g, 0n), m !== 0n && (i(s, u, d, {
		...f,
		flatFee: m
	}), l.push(r(f.feeToken === t ? void 0 : o.getContractWithFetcher(s, e.ERC20Contract, f.feeToken), c, m, !1)));
};
//#endregion
export { o as mergeWithFeeStructureEmporium };
