import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useRef } from 'react';
import classnames from 'classnames';
import Help from '@bigbinary/neeto-icons/Help';
import Button from '@bigbinary/neetoui/Button';
import Popover from '@bigbinary/neetoui/Popover';
import Typography from '@bigbinary/neetoui/Typography';
import { useTranslation } from 'react-i18next';
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';

var SIZE = {
  "default": 16,
  large: 20
};

var _excluded = ["title", "size", "description", "helpLinkProps", "popoverProps", "className", "iconColor", "icon"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var HelpPopover = function HelpPopover(_ref) {
  var title = _ref.title,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? "large" : _ref$size,
    description = _ref.description,
    helpLinkProps = _ref.helpLinkProps,
    popoverProps = _ref.popoverProps,
    className = _ref.className,
    _ref$iconColor = _ref.iconColor,
    iconColor = _ref$iconColor === void 0 ? "currentColor" : _ref$iconColor,
    _ref$icon = _ref.icon,
    IconComponent = _ref$icon === void 0 ? Help : _ref$icon,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var popoverRef = useRef();
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({}, otherProps), {}, {
      "data-testid": "help-popover-button",
      icon: function icon() {
        return /*#__PURE__*/jsx(IconComponent, {
          color: iconColor,
          size: SIZE[size]
        });
      },
      ref: popoverRef,
      style: "text",
      className: classnames("neeto-molecule-help-popover-trigger neeto-ui-rounded-full bg-transparent p-0", className)
    })), /*#__PURE__*/jsx(Popover, _objectSpread(_objectSpread({
      appendTo: function appendTo() {
        return document.body;
      },
      reference: popoverRef
    }, popoverProps), {}, {
      children: /*#__PURE__*/jsxs("div", {
        className: "flex flex-col",
        onClick: function onClick(event) {
          return event.stopPropagation();
        },
        children: [title && /*#__PURE__*/jsx(Popover.Title, {
          "data-testid": "help-popover-title",
          children: title
        }), typeof description === "string" ? /*#__PURE__*/jsx(Typography, {
          "data-testid": "help-popover-description",
          lineHeight: "normal",
          style: "body2",
          children: description
        }) : description, helpLinkProps && /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
          className: "neeto-ui-mt-3",
          "data-testid": "help-popover-link-button",
          label: t("neetoMolecules.common.viewHelpArticle"),
          size: "small"
        }, helpLinkProps), {}, {
          style: "link",
          target: "_blank"
        }))]
      })
    }))]
  });
};

export { HelpPopover as default };
//# sourceMappingURL=HelpPopover.js.map
