import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["active", "children", "className", "size", "onClick"];
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import theme from './theme.css';
import Box from '../box';
import MarketingLockBadge from '../marketingLockBadge';
import { Heading4, Heading5 } from '../typography';
/** @type {React.ComponentType<any>} */

var MarketingTab = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var active = _ref.active,
      children = _ref.children,
      className = _ref.className,
      size = _ref.size,
      onClick = _ref.onClick,
      others = _objectWithoutProperties(_ref, _excluded);

  var tabRef = useRef();
  useImperativeHandle(ref, function () {
    return tabRef.current;
  });

  var handleClick = function handleClick(event) {
    if (onClick) {
      onClick(event);
    }

    if (event.pageX !== 0 && event.pageY !== 0) {
      blur();
    }
  };

  var blur = function blur() {
    var currentTabRef = tabRef.current;

    if (currentTabRef.blur) {
      currentTabRef.blur();
    }
  };

  var classNames = cx(theme['wrapper'], _defineProperty({}, theme['is-active'], active), className);
  var TextElement = size === 'small' ? Heading5 : Heading4;
  return /*#__PURE__*/React.createElement(Box, _extends({
    "data-teamleader-ui": "marketing-tab",
    className: classNames,
    marginHorizontal: size === 'small' ? 1 : 2,
    paddingHorizontal: size === 'small' ? 2 : 3,
    ref: tabRef,
    onClick: handleClick
  }, others), /*#__PURE__*/React.createElement(TextElement, {
    element: "span"
  }, children), /*#__PURE__*/React.createElement(MarketingLockBadge, {
    marginLeft: 3,
    size: size
  }));
});
MarketingTab.defaultProps = {
  element: 'a',
  active: false,
  size: 'medium'
};
MarketingTab.displayName = 'MarketingTab';
export default MarketingTab;