import { safeJsonStringify as e } from "./serialize.utils.mjs";
//#region libs/shared/common/src/functions/utils/amounts.utils.ts
var t = (e) => e.reduce((e, t) => e + t, 0), n = (e) => e / 100, r = (e, t) => t * e / 10000n;
function i(e) {
	return typeof e == "object" && "toBigInt" in e ? e.toBigInt() : BigInt(e);
}
var a = (t) => {
	if (Array.isArray(t) && t.length === 32) {
		let e = 0n;
		for (let n = 0; n < 32; n += 1) e = e << 8n | BigInt(t[n]);
		return e;
	}
	if (typeof t == "string" || typeof t == "number") return BigInt(t);
	if (typeof t == "bigint") return t;
	throw Error(`Cannot convert value to BigInt: ${typeof t}, value: ${e(t)}`);
}, o = (e) => {
	try {
		return BigInt(e);
	} catch {
		return;
	}
}, s = (e) => {
	let t = Number(e);
	return Number.isNaN(t) ? void 0 : t;
}, c = (e, t) => e ? parseInt(e, 10) : t;
function l(...e) {
	return e.reduce((e, t) => t > e ? t : e);
}
function u(e, t) {
	return e === 0 ? 0 : e < 9.9999e-7 ? " < 0.000001" : +Number(e).toFixed(t ?? 6);
}
var d = (e, t) => {
	let n = e.toFixed(20), r = n.indexOf(".");
	if (r === -1) return n;
	let i = r + t + 1;
	return n.substring(0, i);
}, f = (e) => {
	if (/^0+$/.test(e)) return "0";
	if (/^0\.\d+$/.test(e)) return e;
	let t = e.replace(/^0+/, "");
	return t.startsWith(".") ? `0${t}` : t;
}, p = (e) => {
	let t = e.split("."), n = t[0], r = t.length > 1 ? `.${t[1]}` : "";
	return `${f(n).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${r}`;
}, m = (e, t = 18) => {
	let n = e.match(/^(\d+)(\.(\d+))?$/);
	if (n) {
		let e = n[1], r = n[3]?.slice(0, t) || "";
		return r ? `${e}.${r}` : e;
	}
	return e;
}, h = (e, t, n) => {
	if (!/^[0-9]*[.]?[0-9]*$/.test(e)) return null;
	let r = m(f(e), t);
	if (n && r !== e) {
		let t = n.selectionStart ?? 0, r = e.match(/^0+(?=\d)/)?.[0]?.length ?? 0, i = Math.max(t - r, 1);
		requestAnimationFrame(() => {
			n.setSelectionRange(i, i);
		});
	}
	return r;
}, g = (e) => e < 0n ? -e : e, _ = (e, t, n) => {
	let r = e < t ? e : t;
	return n ? r < n ? r : n : r;
}, v = (e, t) => e > t ? e : t, y = (e) => e.reduce((e, { amount: t }) => e + t, 0n);
//#endregion
export { g as absBigInt, a as advancedToBigInt, n as beepsToPercentage, l as bigintMax, r as calculateAmountUsingBeeps, t as calculateSum, y as countTotalAmountInUtxos, u as fixDecimalsAmount, h as formatAmountInput, d as getValueFirstNDigit, v as maxBigInt, _ as minBigInt, i as toBigInt, o as toBigIntOrUndefined, p as toCommaSeparatedNumberString, c as toInt, s as toNumberOrUndefined, f as trimLeadingZeros, m as truncateToDecimalPlaces };
