import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import React__default from 'react';
import classnames from 'classnames';
import { Link } from 'react-router-dom';
import Spinner from './Spinner.js';
import Tooltip from './Tooltip.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import '@babel/runtime/helpers/slicedToArray';
import '@tippyjs/react';
import 'tippy.js';
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 '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'i18next';
import './usePrefersReducedMotion-n4ZJtExQ.js';

var _excluded = ["icon", "iconPosition", "iconSize", "label", "loading", "onClick", "to", "type", "style", "fullWidth", "className", "disabled", "size", "href", "tooltipProps", "children"];
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 BUTTON_STYLES = {
  primary: "primary",
  secondary: "secondary",
  tertiary: "tertiary",
  danger: "danger",
  danger_text: "danger-text",
  text: "text",
  link: "link"
};
var SIZES = {
  medium: "medium",
  large: "large"
};
var ICON_POSITIONS = {
  left: "left",
  right: "right"
};
var BUTTON_TYPES = {
  button: "button"};
var Button = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
  var _ref$icon = _ref.icon,
    icon = _ref$icon === void 0 ? null : _ref$icon,
    _ref$iconPosition = _ref.iconPosition,
    iconPosition = _ref$iconPosition === void 0 ? ICON_POSITIONS.right : _ref$iconPosition,
    _ref$iconSize = _ref.iconSize,
    iconSize = _ref$iconSize === void 0 ? 16 : _ref$iconSize,
    _ref$label = _ref.label,
    label = _ref$label === void 0 ? "" : _ref$label,
    _ref$loading = _ref.loading,
    loading = _ref$loading === void 0 ? false : _ref$loading,
    _ref$onClick = _ref.onClick,
    onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    _ref$to = _ref.to,
    to = _ref$to === void 0 ? "" : _ref$to,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? BUTTON_TYPES.button : _ref$type,
    _ref$style = _ref.style,
    style = _ref$style === void 0 ? BUTTON_STYLES.primary : _ref$style,
    _ref$fullWidth = _ref.fullWidth,
    fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? SIZES.medium : _ref$size,
    _ref$href = _ref.href,
    href = _ref$href === void 0 ? "" : _ref$href,
    _ref$tooltipProps = _ref.tooltipProps,
    tooltipProps = _ref$tooltipProps === void 0 ? null : _ref$tooltipProps,
    children = _ref.children,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  var Parent = "button";
  var elementSpecificProps = {
    type: type
  };
  var renderLabel = label || children;
  if (!disabled) {
    if (to) {
      Parent = Link;
      elementSpecificProps = {
        to: to
      };
    } else if (href) {
      Parent = "a";
      elementSpecificProps = {
        href: href
      };
    }
  }
  var handleClick = function handleClick(e) {
    if (loading || disabled) return;
    onClick(e);
  };
  var Icon = typeof icon === "string" ? function () {
    return /*#__PURE__*/jsx("i", {
      className: classnames("neeto-ui-btn__icon", [icon]),
      "data-testid": "class-icon"
    });
  } : icon || React__default.Fragment;
  return /*#__PURE__*/jsx(Tooltip, _objectSpread(_objectSpread({
    disabled: !tooltipProps
  }, tooltipProps), {}, {
    children: /*#__PURE__*/jsxs(Parent, _objectSpread(_objectSpread({
      className: classnames("neeto-ui-btn", [className], {
        "neeto-ui-btn--style-primary": style === BUTTON_STYLES.primary,
        "neeto-ui-btn--style-secondary": style === BUTTON_STYLES.secondary,
        "neeto-ui-btn--style-tertiary": style === BUTTON_STYLES.tertiary,
        "neeto-ui-btn--style-danger": style === BUTTON_STYLES.danger,
        "neeto-ui-btn--style-danger-text": style === BUTTON_STYLES.danger_text,
        "neeto-ui-btn--style-text": style === BUTTON_STYLES.text,
        "neeto-ui-btn--style-link": style === BUTTON_STYLES.link,
        "neeto-ui-btn--size-medium": size === SIZES.medium,
        "neeto-ui-btn--size-large": size === SIZES.large,
        "neeto-ui-btn--width-full": fullWidth,
        "neeto-ui-btn--icon-left": iconPosition === ICON_POSITIONS.left,
        "neeto-ui-btn--icon-only": !renderLabel,
        "neeto-ui-btn--loading": loading,
        disabled: disabled
      }),
      onClick: handleClick
    }, _objectSpread(_objectSpread({
      disabled: disabled,
      ref: ref
    }, elementSpecificProps), otherProps)), {}, {
      children: [renderLabel && /*#__PURE__*/jsx("span", {
        className: "neeto-ui-btn__label",
        children: renderLabel
      }), icon && /*#__PURE__*/jsx(Icon, {
        "aria-hidden": "true",
        className: "neeto-ui-btn__icon",
        size: iconSize
      }), loading && /*#__PURE__*/jsx("span", {
        className: "neeto-ui-btn__spinner",
        children: /*#__PURE__*/jsx(Spinner, {
          "aria-hidden": "true",
          size: "small"
        })
      })]
    }))
  }));
});
Button.displayName = "Button";

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