"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = CloneButton;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactIntl = require("react-intl");
var _cspaceInput = require("cspace-input");
var _CloneButton = _interopRequireDefault(require("../../../styles/cspace-ui/CloneButton.css"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const {
  Button
} = _cspaceInput.components;
const messages = (0, _reactIntl.defineMessages)({
  label: {
    "id": "cloneButton.label",
    "defaultMessage": "Clone"
  }
});
const propTypes = {
  isCloneable: _propTypes.default.bool,
  isModified: _propTypes.default.bool,
  isSavePending: _propTypes.default.bool,
  onClick: _propTypes.default.func
};
const defaultProps = {
  isCloneable: true
};
function CloneButton(props) {
  const {
    isCloneable,
    isModified,
    isSavePending,
    onClick
  } = props;
  if (!isCloneable) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(Button, {
    className: _CloneButton.default.common,
    disabled: isModified || isSavePending,
    icon: true,
    name: "clone",
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.label));
}
CloneButton.propTypes = propTypes;
CloneButton.defaultProps = defaultProps;