"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var dataviews_actions_exports = {};
__export(dataviews_actions_exports, {
  useEditPostAction: () => useEditPostAction
});
module.exports = __toCommonJS(dataviews_actions_exports);
var import_i18n = require("@wordpress/i18n");
var import_icons = require("@wordpress/icons");
var import_element = require("@wordpress/element");
var import_router = require("@wordpress/router");
var import_constants = require("../../utils/constants");
var import_lock_unlock = require("../../lock-unlock");
const { useHistory } = (0, import_lock_unlock.unlock)(import_router.privateApis);
const useEditPostAction = () => {
  const history = useHistory();
  return (0, import_element.useMemo)(
    () => ({
      id: "edit-post",
      label: (0, import_i18n.__)("Edit"),
      isPrimary: true,
      icon: import_icons.pencil,
      isEligible(post) {
        if (post.status === "trash") {
          return false;
        }
        return post.type !== import_constants.PATTERN_TYPES.theme;
      },
      callback(items) {
        const post = items[0];
        history.navigate(`/${post.type}/${post.id}?canvas=edit`);
      }
    }),
    [history]
  );
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useEditPostAction
});
//# sourceMappingURL=index.js.map
