"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _core = require("@blueprintjs/core");
var _ToolbarItem = _interopRequireDefault(require("./ToolbarItem"));
var _withEditorProps = require("../withEditorProps");
var _recompose = require("recompose");
var _redux = require("redux");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _default = (0, _redux.compose)((0, _withEditorProps.connectToEditor)(function (_ref) {
  var readOnly = _ref.readOnly,
    _ref$sequenceData = _ref.sequenceData,
    sequenceData = _ref$sequenceData === void 0 ? {} : _ref$sequenceData,
    _ref$lastSavedId = _ref.lastSavedId,
    lastSavedId = _ref$lastSavedId === void 0 ? "134%!@#%!@#%!@%" : _ref$lastSavedId;
  return {
    readOnly: readOnly,
    sequenceData: sequenceData,
    hasBeenSaved: sequenceData.stateTrackingId === "initialLoadId" || sequenceData.stateTrackingId === lastSavedId
  };
}), (0, _recompose.withHandlers)({
  handleSave: _withEditorProps.handleSave
}))(function (_ref2) {
  var toolbarItemProps = _ref2.toolbarItemProps,
    alwaysAllowSave = _ref2.alwaysAllowSave,
    handleSave = _ref2.handleSave,
    readOnly = _ref2.readOnly,
    hasBeenSaved = _ref2.hasBeenSaved,
    onSave = _ref2.onSave;
  return /*#__PURE__*/_react["default"].createElement(_ToolbarItem["default"], _extends({
    Icon: /*#__PURE__*/_react["default"].createElement(_core.Icon, {
      "data-test": "saveTool",
      icon: "floppy-disk"
    }),
    onIconClick: handleSave,
    disabled: alwaysAllowSave ? false : !onSave || hasBeenSaved || readOnly,
    tooltip: /*#__PURE__*/_react["default"].createElement("span", null, "Save ", /*#__PURE__*/_react["default"].createElement("span", {
      style: {
        fontSize: 10
      }
    }, "(Cmd/Ctrl+S)"))
  }, toolbarItemProps));
});
exports["default"] = _default;
module.exports = exports.default;