"use strict";

exports.__esModule = true;
exports.Tab = void 0;
var _react = _interopRequireWildcard(require("react"));
var _styled = require("./styled");
var _excluded = ["index", "isMenuItem", "onChange"];
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
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); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
var Tab = exports.Tab = function Tab(_ref) {
  var index = _ref.index,
    isMenuItem = _ref.isMenuItem,
    onChange = _ref.onChange,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var onClick = (0, _react.useCallback)(function (e) {
    return onChange && onChange(index || 0, e);
  }, [index, onChange]);
  var TabComponent = isMenuItem ? _styled.StyledTabMenu : _styled.StyledTab;
  return /*#__PURE__*/_react["default"].createElement(TabComponent, _extends({
    justifyContent: "center",
    alignItems: "center",
    onClick: rest.disabled ? undefined : onClick
  }, rest), typeof rest.label === "function" ? rest.label(_extends({
    index: index,
    isMenuItem: isMenuItem
  }, rest)) : rest.label);
};