"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 _react = require("react");
var _constants = require("../../constants");
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

const OFFSET = 23;
const calculate = (rect, placement) => {
  const placementTop = rect.height / 2;
  let placementLeft = 0;
  switch (placement) {
    case 'left':
      placementLeft = Math.min(OFFSET, rect.height / 2);
      break;
    case 'right':
      placementLeft = rect.width - Math.min(OFFSET, rect.height / 2);
      break;
    case 'center':
      placementLeft = rect.width / 2;
      break;
  }
  const top = rect.top + placementTop - OFFSET + window.pageYOffset;
  const left = rect.left + placementLeft - OFFSET + window.pageXOffset;
  return {
    top,
    left
  };
};
const SpotPulsar = /*#__PURE__*/(0, _react.forwardRef)(function SpotPulsar(_ref, ref) {
  let {
    baseClassName = `${_constants.CLS_PREFIX}spot-pulsar`,
    className,
    rect,
    placement = 'center',
    ...props
  } = _ref;
  const position = calculate(rect, placement);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: (0, _classnames.default)(baseClassName, className),
    style: {
      transform: `translate(${position.left}px, ${position.top}px)`
    },
    ...props,
    ref: ref,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__ring`
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__ring`
    })]
  });
});
SpotPulsar.displayName = 'SpotPulsar';
var _default = exports.default = SpotPulsar;