"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);

// packages/block-library/src/query/edit/enhanced-pagination-modal.js
var enhanced_pagination_modal_exports = {};
__export(enhanced_pagination_modal_exports, {
  default: () => EnhancedPaginationModal
});
module.exports = __toCommonJS(enhanced_pagination_modal_exports);
var import_components = require("@wordpress/components");
var import_i18n = require("@wordpress/i18n");
var import_element = require("@wordpress/element");
var import_data = require("@wordpress/data");
var import_block_editor = require("@wordpress/block-editor");
var import_utils = require("../utils.cjs");
var import_jsx_runtime = require("react/jsx-runtime");
var modalDescriptionId = "wp-block-query-enhanced-pagination-modal__description";
function EnhancedPaginationModal({
  clientId,
  attributes: { enhancedPagination },
  setAttributes
}) {
  const [isOpen, setOpen] = (0, import_element.useState)(false);
  const hasUnsupportedBlocks = (0, import_utils.useUnsupportedBlocks)(clientId);
  const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
  (0, import_element.useEffect)(() => {
    if (enhancedPagination && hasUnsupportedBlocks) {
      __unstableMarkNextChangeAsNotPersistent();
      setAttributes({ enhancedPagination: false });
      setOpen(true);
    }
  }, [
    enhancedPagination,
    hasUnsupportedBlocks,
    setAttributes,
    __unstableMarkNextChangeAsNotPersistent
  ]);
  const closeModal = () => {
    setOpen(false);
  };
  const notice = (0, import_i18n.__)(
    "Currently, avoiding full page reloads is not possible when non-interactive or non-client Navigation compatible blocks from plugins are present inside the Query block."
  ) + " " + (0, import_i18n.__)(
    'If you still want to prevent full page reloads, remove that block, then disable "Reload full page" again in the Query Block settings.'
  );
  return isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    import_components.Modal,
    {
      title: (0, import_i18n.__)("Query block: Reload full page enabled"),
      className: "wp-block-query__enhanced-pagination-modal",
      aria: {
        describedby: modalDescriptionId
      },
      role: "alertdialog",
      focusOnMount: "firstElement",
      isDismissible: false,
      onRequestClose: closeModal,
      children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { alignment: "right", spacing: 5, children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { id: modalDescriptionId, children: notice }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_components.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            onClick: closeModal,
            children: (0, import_i18n.__)("OK")
          }
        )
      ] })
    }
  );
}
//# sourceMappingURL=enhanced-pagination-modal.cjs.map
