"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));
var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
var WebLinkBar = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(WebLinkBar, _React$Component);
  function WebLinkBar() {
    return _React$Component.apply(this, arguments) || this;
  }
  var _proto = WebLinkBar.prototype;
  _proto.renderActionButton = function renderActionButton(item, index) {
    var _this$props = this.props,
      nextTablePrefix = _this$props.nextTablePrefix,
      onActionClick = _this$props.onActionClick;
    var content;
    var itemProps = {
      onClick: function onClick() {
        onActionClick && onActionClick(item, index);
      }
    };
    if (item.render && (0, _isFunction["default"])(item.render)) {
      content = /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
        className: nextTablePrefix + "link-div"
      }, itemProps), item.render(item.title));
    } else {
      content = /*#__PURE__*/_react["default"].createElement("a", (0, _extends2["default"])({
        className: nextTablePrefix + "link-a"
      }, itemProps), item.title);
    }
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: nextTablePrefix + "link-item",
      key: index
    }, content, index === 0 ? null : /*#__PURE__*/_react["default"].createElement("div", {
      className: nextTablePrefix + "link-sp"
    }));
  };
  _proto.render = function render() {
    var _this = this;
    var _this$props2 = this.props,
      nextTablePrefix = _this$props2.nextTablePrefix,
      _this$props2$linkBar = _this$props2.linkBar,
      linkBar = _this$props2$linkBar === void 0 ? [] : _this$props2$linkBar;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: nextTablePrefix + "link-wrap"
    }, linkBar.slice(0).reverse().map(function (link, index) {
      return link ? _this.renderActionButton(link, index) : null;
    }));
  };
  return WebLinkBar;
}(_react["default"].Component);
exports["default"] = WebLinkBar;