require("../../../_virtual/_rolldown/runtime.js");
const require_rangeConverter = require("./rangeConverter.js");
let _pisell_utils = require("@pisell/utils");
//#region src/components/pisellPercent/utils/percentFormatter.ts
/**
* 格式化百分比数值
* 
* @param value 数值
* @param options 格式化选项
* @returns 格式化后的百分比字符串
* 
* @example
* formatPercent(85.5, { showPercentSymbol: true, precision: 1, range: [0, 100] })
* // 返回: '85.5%'
* 
* @example
* formatPercent(0.855, { showPercentSymbol: true, precision: 1, range: [0, 1] })
* // 返回: '85.5%'
*/
function formatPercent(value, options) {
	if (value === null || value === void 0) return null;
	const { showPercentSymbol, precision, range } = options;
	const percentValue = require_rangeConverter.convertToPercent(value, range);
	if (percentValue === null) return null;
	const formatted = (0, _pisell_utils.formatNumber)(percentValue, { precision });
	if (!formatted) return null;
	if (showPercentSymbol) return `${formatted}%`;
	return formatted;
}
//#endregion
exports.formatPercent = formatPercent;
