import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { forwardRef, useRef } from 'react';
import classnames from 'classnames';
import Help from '@bigbinary/neeto-icons/Help';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import Button from './Button.js';
import Popover from './Popover.js';
import Tooltip from './Tooltip.js';
import Typography from './Typography.js';
import '@babel/runtime/helpers/slicedToArray';
import '@tippyjs/react';
import 'tippy.js';
import 'react-router-dom';
import '@bigbinary/neeto-hotkeys';
import './overlayManager.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'qs';
import 'ramda';
import './index-DyUNP5G9.js';
import 'i18next';
import './Spinner.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import './usePrefersReducedMotion-n4ZJtExQ.js';

var _excluded$2 = ["onClick", "className", "icon"];
function ownKeys$2(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$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var HelpIcon = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var onClick = _ref.onClick,
    className = _ref.className,
    icon = _ref.icon,
    otherProps = _objectWithoutProperties(_ref, _excluded$2);
  var HelpIcon = icon || Help;
  return /*#__PURE__*/jsx("span", {
    onClick: onClick,
    ref: ref,
    className: classnames("neeto-ui-label__help-icon-wrap", _defineProperty({}, className, className)),
    children: /*#__PURE__*/jsx(HelpIcon, _objectSpread$2({
      size: 20
    }, otherProps))
  });
});
HelpIcon.displayName = "HelpIcon";

var _excluded$1 = ["tooltipProps", "popoverProps"],
  _excluded2 = ["title", "description", "helpLinkProps"];
function ownKeys$1(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$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var HelpContent = function HelpContent(_ref) {
  var helpIconProps = _ref.helpIconProps;
  var popoverReferenceElement = useRef();
  var _ref2 = helpIconProps || {},
    tooltipProps = _ref2.tooltipProps,
    popoverProps = _ref2.popoverProps,
    otherHelpIconProps = _objectWithoutProperties(_ref2, _excluded$1);
  if (tooltipProps) {
    return /*#__PURE__*/jsx(Tooltip, _objectSpread$1(_objectSpread$1({}, tooltipProps), {}, {
      children: /*#__PURE__*/jsx(HelpIcon, _objectSpread$1({}, otherHelpIconProps))
    }));
  }
  if (popoverProps) {
    var title = popoverProps.title,
      description = popoverProps.description,
      helpLinkProps = popoverProps.helpLinkProps,
      otherPopoverProps = _objectWithoutProperties(popoverProps, _excluded2);
    return /*#__PURE__*/jsxs(Fragment, {
      children: [/*#__PURE__*/jsx(HelpIcon, _objectSpread$1(_objectSpread$1({}, otherHelpIconProps), {}, {
        ref: popoverReferenceElement
      })), /*#__PURE__*/jsx(Popover, _objectSpread$1(_objectSpread$1({
        reference: popoverReferenceElement
      }, otherPopoverProps), {}, {
        children: /*#__PURE__*/jsxs("div", {
          className: "neeto-ui-flex neeto-ui-flex-col",
          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",
            weight: "normal",
            children: description
          }) : description, helpLinkProps && /*#__PURE__*/jsx(Button, _objectSpread$1(_objectSpread$1({
            className: "neeto-ui-mt-3",
            "data-testid": "help-popover-link-button",
            size: "small"
          }, helpLinkProps), {}, {
            style: "link",
            target: "_blank"
          }))]
        })
      }))]
    });
  }
  return /*#__PURE__*/jsx(HelpIcon, _objectSpread$1({}, otherHelpIconProps));
};

var _excluded = ["children", "className", "required", "helpIconProps"];
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 Label = function Label(_ref) {
  var children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    _ref$required = _ref.required,
    required = _ref$required === void 0 ? false : _ref$required,
    _ref$helpIconProps = _ref.helpIconProps,
    helpIconProps = _ref$helpIconProps === void 0 ? null : _ref$helpIconProps,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/jsxs("label", _objectSpread(_objectSpread({
    className: classnames("neeto-ui-label neeto-ui-flex neeto-ui-items-center", className)
  }, props), {}, {
    children: [children, required && /*#__PURE__*/jsx("span", {
      "aria-hidden": true,
      children: "*"
    }), helpIconProps && /*#__PURE__*/jsx(HelpContent, {
      helpIconProps: helpIconProps
    })]
  }));
};

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