'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var classnames = require('classnames');
var Help = require('@bigbinary/neeto-icons/Help');
var Button = require('@bigbinary/neetoui/Button');
var Popover = require('@bigbinary/neetoui/Popover');
var Typography = require('@bigbinary/neetoui/Typography');
var reactI18next = require('react-i18next');
var jsxRuntime = require('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 ? "default" : _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 = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var popoverRef = React.useRef();
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread(_objectSpread({}, otherProps), {}, {
      "data-testid": "help-popover-button",
      icon: function icon() {
        return /*#__PURE__*/jsxRuntime.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__*/jsxRuntime.jsx(Popover, _objectSpread(_objectSpread({
      appendTo: function appendTo() {
        return document.body;
      },
      reference: popoverRef
    }, popoverProps), {}, {
      children: /*#__PURE__*/jsxRuntime.jsxs("div", {
        className: "flex flex-col",
        onClick: function onClick(event) {
          return event.stopPropagation();
        },
        children: [title && /*#__PURE__*/jsxRuntime.jsx(Popover.Title, {
          "data-testid": "help-popover-title",
          children: title
        }), typeof description === "string" ? /*#__PURE__*/jsxRuntime.jsx(Typography, {
          "data-testid": "help-popover-description",
          lineHeight: "normal",
          style: "body2",
          children: description
        }) : description, helpLinkProps && /*#__PURE__*/jsxRuntime.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"
        }))]
      })
    }))]
  });
};

module.exports = HelpPopover;
//# sourceMappingURL=HelpPopover.js.map
