import { __ } from "@wordpress/i18n";
import { pencil } from "@wordpress/icons";
import { useMemo } from "@wordpress/element";
import { privateApis as routerPrivateApis } from "@wordpress/router";
import { PATTERN_TYPES } from "../../utils/constants";
import { unlock } from "../../lock-unlock";
const { useHistory } = unlock(routerPrivateApis);
const useEditPostAction = () => {
  const history = useHistory();
  return useMemo(
    () => ({
      id: "edit-post",
      label: __("Edit"),
      isPrimary: true,
      icon: pencil,
      isEligible(post) {
        if (post.status === "trash") {
          return false;
        }
        return post.type !== PATTERN_TYPES.theme;
      },
      callback(items) {
        const post = items[0];
        history.navigate(`/${post.type}/${post.id}?canvas=edit`);
      }
    }),
    [history]
  );
};
export {
  useEditPostAction
};
//# sourceMappingURL=index.js.map
