'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var neetoAtoms = require('@bigbinary/neeto-atoms');
var classnames = require('classnames');
var reactI18next = require('react-i18next');
var jsxRuntime = require('react/jsx-runtime');
var circleQuestionMark = require('../circle-question-mark-kxBMPyWQ.js');
require('../createLucideIcon-DBDhE7kE.js');
require('react');

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

var _excluded = ["label"];
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,
    className = _ref.className,
    _ref$iconColor = _ref.iconColor,
    iconColor = _ref$iconColor === void 0 ? "currentColor" : _ref$iconColor,
    _ref$icon = _ref.icon,
    IconComponent = _ref$icon === void 0 ? circleQuestionMark.CircleQuestionMark : _ref$icon,
    side = _ref.side,
    sideOffset = _ref.sideOffset,
    align = _ref.align,
    alignOffset = _ref.alignOffset;
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var position = align && align !== "center" ? "".concat(side, "-").concat(align) : side;
  return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Popover, {
    alignOffset: alignOffset,
    position: position,
    sideOffset: sideOffset,
    className: "!max-w-[calc(100vw-2rem)]",
    closeDelay: 150,
    collisionPadding: 12,
    openDelay: 0,
    trigger: /*#__PURE__*/jsxRuntime.jsx("button", {
      "data-testid": "help-popover-button",
      type: "button",
      className: classnames("inline-flex cursor-pointer items-center justify-center rounded-full border-none bg-transparent p-0", className),
      children: /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
        color: iconColor,
        size: SIZE[size]
      })
    }),
    children: /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: "flex flex-col",
      onClick: function onClick(event) {
        return event.stopPropagation();
      },
      children: [title && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
        asChild: true,
        variant: "body2",
        weight: "semibold",
        children: /*#__PURE__*/jsxRuntime.jsx("h3", {
          className: "mb-2",
          "data-testid": "help-popover-title",
          children: title
        })
      }), typeof description === "string" ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
        color: "muted",
        "data-testid": "help-popover-description",
        variant: "body2",
        children: description
      }) : description, helpLinkProps && function () {
        var linkLabel = helpLinkProps.label,
          restLinkProps = _objectWithoutProperties(helpLinkProps, _excluded);
        return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
          asChild: true,
          className: "mt-3 self-start",
          variant: "link",
          children: /*#__PURE__*/jsxRuntime.jsx("a", _objectSpread(_objectSpread({
            "data-testid": "help-popover-link-button",
            rel: "noreferrer",
            target: "_blank"
          }, restLinkProps), {}, {
            children: linkLabel !== null && linkLabel !== void 0 ? linkLabel : t("neetoMolecules.common.viewHelpArticle")
          }))
        });
      }()]
    })
  });
};

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