"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useEditPostAction = void 0;
var _i18n = require("@wordpress/i18n");
var _icons = require("@wordpress/icons");
var _element = require("@wordpress/element");
var _router = require("@wordpress/router");
var _constants = require("../../utils/constants");
var _lockUnlock = require("../../lock-unlock");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  useHistory
} = (0, _lockUnlock.unlock)(_router.privateApis);
const useEditPostAction = () => {
  const history = useHistory();
  return (0, _element.useMemo)(() => ({
    id: 'edit-post',
    label: (0, _i18n.__)('Edit'),
    isPrimary: true,
    icon: _icons.edit,
    isEligible(post) {
      if (post.status === 'trash') {
        return false;
      }
      // It's eligible for all post types except theme patterns.
      return post.type !== _constants.PATTERN_TYPES.theme;
    },
    callback(items) {
      const post = items[0];
      history.navigate(`/${post.type}/${post.id}?canvas=edit`);
    }
  }), [history]);
};
exports.useEditPostAction = useEditPostAction;
//# sourceMappingURL=index.js.map