"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-editor/src/components/rich-text/use-mark-persistent.js
var use_mark_persistent_exports = {};
__export(use_mark_persistent_exports, {
  useMarkPersistent: () => useMarkPersistent
});
module.exports = __toCommonJS(use_mark_persistent_exports);
var import_element = require("@wordpress/element");
var import_data = require("@wordpress/data");
var import_store = require("../../store");
function useMarkPersistent({ html, value }) {
  const previousTextRef = (0, import_element.useRef)();
  const hasActiveFormats = !!value.activeFormats?.length;
  const { __unstableMarkLastChangeAsPersistent } = (0, import_data.useDispatch)(import_store.store);
  (0, import_element.useLayoutEffect)(() => {
    if (!previousTextRef.current) {
      previousTextRef.current = value.text;
      return;
    }
    if (previousTextRef.current !== value.text) {
      const timeout = window.setTimeout(() => {
        __unstableMarkLastChangeAsPersistent();
      }, 1e3);
      previousTextRef.current = value.text;
      return () => {
        window.clearTimeout(timeout);
      };
    }
    __unstableMarkLastChangeAsPersistent();
  }, [html, hasActiveFormats]);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useMarkPersistent
});
//# sourceMappingURL=use-mark-persistent.js.map
