import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { cx } from '../../utils/index.js';
import { formatCurrency } from './utils/formatCurrency.js';
import { StyledPeriodicity, base } from './Price.styles.js';
import { base as base$1 } from './variations/_view/base.js';
import { classes } from './Price.tokens.js';

var _excluded = ["children", "locale", "currency", "minimumFractionDigits", "stroked", "periodicity", "view", "className", "stroke"];

/**
 * Компонент для отображения цены / стоимости / суммы.
 */
var priceRoot = function priceRoot(Root) {
  return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
    var children = _ref.children,
      _ref$locale = _ref.locale,
      locale = _ref$locale === void 0 ? 'ru' : _ref$locale,
      _ref$currency = _ref.currency,
      currency = _ref$currency === void 0 ? 'rub' : _ref$currency,
      _ref$minimumFractionD = _ref.minimumFractionDigits,
      minimumFractionDigits = _ref$minimumFractionD === void 0 ? 0 : _ref$minimumFractionD,
      _ref$stroked = _ref.stroked,
      stroked = _ref$stroked === void 0 ? false : _ref$stroked,
      periodicity = _ref.periodicity,
      view = _ref.view,
      className = _ref.className,
      _ref$stroke = _ref.stroke,
      stroke = _ref$stroke === void 0 ? false : _ref$stroke,
      rest = _objectWithoutProperties(_ref, _excluded);
    var strokedClass = stroked || stroke ? classes.stroked : undefined;
    var hasCurrency = currency && currency.length === 3;
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      view: view,
      ref: outerRootRef,
      className: cx(strokedClass, className)
    }, rest), hasCurrency && formatCurrency({
      value: children,
      locale: locale,
      currency: currency,
      minimumFractionDigits: minimumFractionDigits
    }), periodicity && /*#__PURE__*/React__default.createElement(StyledPeriodicity, null, periodicity));
  });
};
var priceConfig = {
  name: 'Price',
  tag: 'span',
  layout: priceRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    }
  },
  defaults: {
    view: 'default'
  }
};

export { priceConfig, priceRoot };
