"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

const width = value => {
  let result = Math.ceil(value * 20 / 5) * 5;
  if (result % 20 === 5) {
    result += 2;
  } else if (result % 20 === 15) {
    result -= 2;
  }
  return result;
};
/**
 * `Rating` component is used for showing and collecting feedback of users' opinion in 0-5 grade scale.
 * @since 0.0.42
 */
const Rating = _ref => {
  let {
    baseClassName = `${_constants.CLS_PREFIX}rating`,
    className,
    value = 0,
    small = false,
    ...props
  } = _ref;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _classnames.default)(baseClassName, className, {
      [`${baseClassName}--static`]: true,
      [`${baseClassName}--small`]: small
    }),
    ...props,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__rates`,
      style: {
        width: `${width(value)}%`
      }
    })
  });
};
var _default = exports.default = Rating;