var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from 'react';
import warning from 'warning';
import { MAX_SAFE_DIGITS } from '../CurrencyInput/constants.js';
import { CurrencyHelper } from '../CurrencyInput/CurrencyHelper.js';
import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
import { forwardRefAndName } from '../../lib/forwardRefAndName.js';
var FRACTION_DIGITS_DEFAULT = 2;
export var CurrencyLabelDataTids = {
    root: 'CurrencyLabel__root',
};
/**
 * Подпись для денежных сумм и других числовых значений.
 */
var CurrencyLabel = forwardRefAndName('CurrencyLabel', function CurrencyLabel(_a, ref) {
    var id = _a.id, value = _a.value, _b = _a.fractionDigits, fractionDigits = _b === void 0 ? FRACTION_DIGITS_DEFAULT : _b, currencySymbol = _a.currencySymbol, _c = _a.hideTrailingZeros, hideTrailingZeros = _c === void 0 ? false : _c, rest = __rest(_a, ["id", "value", "fractionDigits", "currencySymbol", "hideTrailingZeros"]);
    React.useEffect(function () {
        warning(fractionDigits <= MAX_SAFE_DIGITS, "[CurrencyLabel]: Prop 'fractionDigits' exceeds ".concat(MAX_SAFE_DIGITS, ".\nSee CurrencyInput documentation"));
        var fraction = (CurrencyHelper.destructString(String(value)) || { fraction: '' }).fraction;
        warning(fraction.length <= fractionDigits, "[CurrencyLabel]: Prop 'fractionDigits' less than fractional part of the 'value' property," +
            "'value' will not be cutted");
        warning(Number.isInteger(fractionDigits), "[CurrencyLabel]: Prop 'fractionDigits' is not integer, fraction part of these property will not be used");
    }, [fractionDigits, value]);
    return (React.createElement(CommonWrapper, __assign({}, rest),
        React.createElement("span", { id: id, "data-tid": CurrencyLabelDataTids.root, ref: ref },
            CurrencyHelper.format(value, { fractionDigits: fractionDigits, hideTrailingZeros: hideTrailingZeros }),
            currencySymbol && String.fromCharCode(0xa0) /* &nbsp; */,
            currencySymbol)));
});
export { CurrencyLabel };
//# sourceMappingURL=CurrencyLabel.js.map