// packages/block-editor/src/components/block-lock/menu-item.js
import { __ } from "@wordpress/i18n";
import { useReducer } from "@wordpress/element";
import { MenuItem } from "@wordpress/components";
import { lockOutline, unlock } from "@wordpress/icons";
import useBlockLock from "./use-block-lock";
import BlockLockModal from "./modal";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function BlockLockMenuItem({ clientId }) {
  const { canLock, isLocked } = useBlockLock(clientId);
  const [isModalOpen, toggleModal] = useReducer(
    (isActive) => !isActive,
    false
  );
  if (!canLock) {
    return null;
  }
  const label = isLocked ? __("Unlock") : __("Lock");
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      MenuItem,
      {
        icon: isLocked ? unlock : lockOutline,
        onClick: toggleModal,
        "aria-expanded": isModalOpen,
        "aria-haspopup": "dialog",
        children: label
      }
    ),
    isModalOpen && /* @__PURE__ */ jsx(BlockLockModal, { clientId, onClose: toggleModal })
  ] });
}
export {
  BlockLockMenuItem as default
};
//# sourceMappingURL=menu-item.js.map
