Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_chunk = require("../chunk-BN4qSVkS.cjs");
const require_components_typography_renderTypography = require("./typography/renderTypography.cjs");
const require_components_Icon_Icon = require("./Icon/Icon.cjs");
let _emotion_styled = require("@emotion/styled");
_emotion_styled = require_chunk.__toESM(_emotion_styled);
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
let _lightsparkdev_core = require("@lightsparkdev/core");
//#region src/components/CurrencyAmount.tsx
function CurrencyAmount({ amount, displayUnit: displayUnitProp, shortNumber = false, showUnits = false, includeEstimatedIndicator = false, fullPrecision = false, id, ml = 0, typography, unitsPerBtc, showCurrencyIcon = true }) {
	let value;
	let defaultFormattedNumber;
	let displayUnitStr;
	let currencyAmountForFormatting;
	if ((0, _lightsparkdev_core.isUmaCurrencyAmount)(amount)) {
		value = amount.value;
		defaultFormattedNumber = (0, _lightsparkdev_core.formatCurrencyStr)(amount);
		displayUnitStr = amount.currency.code === "SAT" ? _lightsparkdev_core.CurrencyUnit.SATOSHI : amount.currency.code;
		currencyAmountForFormatting = amount;
	} else {
		let amountMap;
		let displayUnit;
		if ((0, _lightsparkdev_core.isCurrencyMap)(amount)) {
			displayUnit = displayUnitProp || _lightsparkdev_core.CurrencyUnit.SATOSHI;
			amountMap = amount;
		} else {
			const resolvedCurrencyAmount = (0, _lightsparkdev_core.getCurrencyAmount)(amount);
			displayUnit = displayUnitProp || resolvedCurrencyAmount.unit;
			amountMap = (0, _lightsparkdev_core.mapCurrencyAmount)(amount, unitsPerBtc);
		}
		value = amountMap[displayUnit];
		defaultFormattedNumber = amountMap.formatted[displayUnit];
		displayUnitStr = displayUnit;
		currencyAmountForFormatting = {
			value: Number(value),
			unit: displayUnit
		};
	}
	const appendUnits = showUnits === false ? void 0 : showUnits === true ? {
		plural: false,
		lowercase: false,
		showForCurrentLocaleUnit: false
	} : showUnits;
	let formattedNumber = defaultFormattedNumber;
	if (shortNumber) formattedNumber = (0, _lightsparkdev_core.formatCurrencyStr)(currencyAmountForFormatting, {
		precision: 1,
		compact: true,
		appendUnits
	});
	else if (fullPrecision) formattedNumber = (0, _lightsparkdev_core.formatCurrencyStr)(currencyAmountForFormatting, {
		precision: "full",
		appendUnits
	});
	else if (appendUnits) formattedNumber = (0, _lightsparkdev_core.formatCurrencyStr)(currencyAmountForFormatting, { appendUnits });
	let content = formattedNumber;
	if (typography && typography.type) content = require_components_typography_renderTypography.renderTypography(typography.type, {
		size: typography.size,
		color: typography.color,
		children: formattedNumber
	});
	return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(StyledCurrencyAmount, {
		ml,
		id,
		children: [
			includeEstimatedIndicator && "Est. ",
			showCurrencyIcon ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(CurrencyIcon, { unit: displayUnitStr }) : null,
			content
		]
	});
}
const CurrencyIcon = ({ unit }) => {
	switch (unit) {
		case _lightsparkdev_core.CurrencyUnit.BITCOIN: return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_Icon_Icon.Icon, {
			name: "BitcoinB",
			width: 8,
			verticalAlign: -2,
			mr: 2
		});
		case _lightsparkdev_core.CurrencyUnit.SATOSHI: return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_Icon_Icon.Icon, {
			name: "Satoshi",
			width: 8,
			verticalAlign: -2,
			mr: 2
		});
		default: return null;
	}
};
const StyledCurrencyAmount = _emotion_styled.default.span`
  color: inherit !important;
  white-space: nowrap;
  font-feature-settings:
    "tnum" on,
    "lnum" on;
  margin-left: ${({ ml }) => ml}px;
`;
//#endregion
exports.CurrencyAmount = CurrencyAmount;
exports.CurrencyIcon = CurrencyIcon;
