/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_index = require("../../node_modules/classnames/index.js");
const require_settings = require("../../settings.js");
const require_devtools = require("../../global/js/utils/devtools.js");
const require_TooltipTrigger = require("../TooltipTrigger/TooltipTrigger.js");
const require_getSupportedLocale = require("../../global/js/utils/getSupportedLocale.js");
const require_constants = require("./constants.js");
const require_BigNumberSkeleton = require("./BigNumberSkeleton.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");
let _carbon_react_icons = require("@carbon/react/icons");
//#region src/components/BigNumber/BigNumber.tsx
/**
* Copyright IBM Corp. 2024, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--big-number`;
const componentName = "BigNumber";
/**
* BigNumber is used to display large values in a small area. The display of
* values can be the value itself, or grouped in a `numerator/denominator` fashion.
* Control over the total fraction decimals displayed as well as how the
* values/totals are displayed are done via a locale prop. Other optional props
* allow control over size, truncation, if the value is a percentage, the addition
* of a button as well as tool tip functionality.
* The default locale is English (`en-US`) if one is not provided or if the provided one is not supported.
*/
const BigNumber = (0, react.forwardRef)(({ className, forceShowTotal = false, fractionDigits = 1, iconButton, loading = false, label, locale = require_constants.DefaultLocale, percentage = false, size = "default", tooltipDescription, total, trending = false, truncate = true, value, ...rest }, ref) => {
	const bigNumberClasses = (0, import_classnames.default)(className, {
		[`${blockClass}--lg`]: size === "lg",
		[`${blockClass}--xl`]: size === "xl"
	});
	const supportedLocale = require_getSupportedLocale.getSupportedLocale(locale, require_constants.DefaultLocale);
	const truncatedValue = require_constants.formatValue(supportedLocale, value, fractionDigits, truncate) ?? "–";
	const truncatedTotal = require_constants.formatValue(supportedLocale, total, fractionDigits, truncate) ?? "Unknown";
	const shouldDisplayDenominator = forceShowTotal || !percentage && total && value && total > value && truncatedValue !== truncatedTotal;
	if (loading) return /* @__PURE__ */ react.default.createElement(require_BigNumberSkeleton.BigNumberSkeleton, {
		...rest,
		ref,
		className,
		size,
		...require_devtools.getDevtoolsProps(componentName)
	});
	return /* @__PURE__ */ react.default.createElement("div", {
		...rest,
		className: (0, import_classnames.default)(blockClass, bigNumberClasses, className),
		ref,
		...require_devtools.getDevtoolsProps(componentName)
	}, /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__row` }, /* @__PURE__ */ react.default.createElement("h4", { className: `${blockClass}__label` }, label), tooltipDescription && /* @__PURE__ */ react.default.createElement(_carbon_react.Tooltip, {
		description: tooltipDescription,
		align: "right",
		className: `${blockClass}__info`
	}, /* @__PURE__ */ react.default.createElement(require_TooltipTrigger.TooltipTrigger, { className: `${blockClass}__tooltip-trigger` }, /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Information, { size: 16 })))), /* @__PURE__ */ react.default.createElement("span", {
		className: `${blockClass}__row`,
		role: "math"
	}, trending && /* @__PURE__ */ react.default.createElement(_carbon_react_icons.ArrowUp, {
		className: `${blockClass}__trend`,
		size: require_constants.getIconSize(size)
	}), /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__value` }, percentage ? /* @__PURE__ */ react.default.createElement("div", { className: `${blockClass}__percentage` }, truncatedValue, /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__percentage-mark` }, "%")) : truncatedValue), shouldDisplayDenominator && /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__total` }, /* @__PURE__ */ react.default.createElement("span", null, `/${truncatedTotal}`)), /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}__icon-button` }, iconButton)));
});
BigNumber.displayName = componentName;
BigNumber.propTypes = {
	/**
	* Provide an optional class to be applied to the containing node.
	*/
	className: prop_types.default.string,
	/**
	* The default behavior will hide `total` if `undefined` or is the same as `value`.
	*
	* Set to `true` to ignore the default behavior and show the `total`.
	*/
	forceShowTotal: prop_types.default.bool,
	/**
	* Specifies the number of fraction digits when truncating `value` and `total`.
	*/
	fractionDigits: prop_types.default.number,
	/**
	* Displays an icon button next to `value`.
	*/
	iconButton: prop_types.default.node,
	/**
	* Text label above the `value`.
	*/
	label: prop_types.default.string.isRequired,
	/**
	* When `true`, will show the loading state.
	*/
	loading: prop_types.default.bool,
	/**
	* Determines how `value` and `total` will be formatted.
	*/
	locale: prop_types.default.string,
	/**
	* Appends a percent sign (_%_) after `value` and hides `total`.
	*/
	percentage: prop_types.default.bool,
	/**
	*
	*/
	size: prop_types.default.oneOf([
		"default",
		"lg",
		"xl"
	]),
	/**
	* When applied, an information icon will be rendered next to the
	* `label` and the description will be applied to its tooltip.
	*/
	tooltipDescription: prop_types.default.string,
	/**
	* The number that will appear after the slash (i.e. the "denominator" of a fraction).
	*
	* This number will not be rendered if it's the same as `value` or
	* `percentage` is true. See also the **forceShowTotal** prop.
	*/
	total: prop_types.default.number,
	/**
	* When `true`, will render a "trending up" icon.
	*/
	trending: prop_types.default.bool,
	/**
	* Abbreviates the number when `true`. E.g. from _1,000_ to _1K_.
	*/
	truncate: prop_types.default.bool,
	/**
	* The primary value to display (or the "numerator" of a fraction).
	*/
	value: prop_types.default.number
};
//#endregion
exports.BigNumber = BigNumber;
