import _omit from "lodash/fp/omit";
import _noop from "lodash/fp/noop";
import _has from "lodash/fp/has";
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import ModuleBubble from '../module-bubble';
import style from './style.css';
const Tab = ({
  index,
  selected,
  onClick = _noop,
  level
}) => {
  const handleClick = useMemo(() => () => onClick(index), [onClick, index]);
  const isSelected = selected === index;
  const bubble = _has('status', level) ? /*#__PURE__*/React.createElement("div", {
    className: style.module
  }, /*#__PURE__*/React.createElement(ModuleBubble, _extends({}, level, {
    onClick: handleClick
  }))) : null;
  return /*#__PURE__*/React.createElement("li", {
    "data-name": "scopeTab",
    "data-index": index,
    key: index,
    onClick: handleClick,
    className: classnames(style.defaultTab, isSelected ? style.currentTab : null)
  }, bubble, /*#__PURE__*/React.createElement("div", {
    className: style.name
  }, level.name));
};
Tab.propTypes = process.env.NODE_ENV !== "production" ? {
  selected: PropTypes.number,
  index: PropTypes.number,
  onClick: PropTypes.func,
  level: PropTypes.shape(_omit('onClick', ModuleBubble.propTypes))
} : {};
const ScopeTabs = (props, context) => {
  const {
    onClick,
    selected = 0,
    levels = []
  } = props;
  const scopeContent = /*#__PURE__*/React.createElement("ul", {
    "data-name": "scopeTabs",
    className: style.tabs
  }, levels.map((level, index) => /*#__PURE__*/React.createElement(Tab, {
    key: index,
    index: index,
    level: level,
    onClick: onClick,
    selected: selected
  })));
  return levels.length > 1 ? /*#__PURE__*/React.createElement("nav", null, scopeContent) : /*#__PURE__*/React.createElement("div", null, scopeContent);
};
ScopeTabs.propTypes = process.env.NODE_ENV !== "production" ? {
  selected: PropTypes.number,
  onClick: PropTypes.func,
  levels: PropTypes.arrayOf(PropTypes.object)
} : {};
export default ScopeTabs;
//# sourceMappingURL=index.js.map