"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var comapare_draft_content_exports = {};
__export(comapare_draft_content_exports, {
  isContentEqual: () => isContentEqual
});
module.exports = __toCommonJS(comapare_draft_content_exports);
var import_lodash = __toESM(require("lodash"));
var import_compare = require("../comparision/compare.js");
function areRangesEqual(blockRanges1, blockRanges2, sortKey) {
  return blockRanges1.length === blockRanges2.length && import_lodash.default.isEqual(
    import_lodash.default.sortBy(blockRanges1, (r) => r[sortKey]),
    import_lodash.default.sortBy(blockRanges2, (r) => r[sortKey])
  );
}
function isTextAlignmentEqual(block1, block2) {
  const isBlock1AlignedLeft = !block1.data.textAlignment || block1.data.textAlignment === "left";
  const isBlock2AlignedLeft = !block2.data.textAlignment || block2.data.textAlignment === "left";
  return isBlock1AlignedLeft === isBlock2AlignedLeft || block1.data.textAlignment === block2.data.textAlignment;
}
function areBlockFieldsEqual(block1, block2) {
  return block1.text === block2.text && block1.depth === block2.depth && block1.type === block2.type && areRangesEqual(block1.inlineStyleRanges, block2.inlineStyleRanges, "style") && areRangesEqual(block1.entityRanges, block2.entityRanges, "key") && isTextAlignmentEqual(block1, block2) && import_lodash.default.isEmpty(
    (0, import_compare.compare)(block1.data, block2.data, { verbose: false, ignoredKeys: ["textAlignment"] })
  );
}
function areBlocksEqual(currentStateBlocks, initialStateBlocks) {
  return currentStateBlocks?.length === initialStateBlocks?.length && currentStateBlocks.every(
    (block, i) => areBlockFieldsEqual(block, initialStateBlocks[i])
  );
}
function isContentEqual(currContent, initialContent) {
  const blocksEqual = areBlocksEqual(currContent.blocks, initialContent.blocks);
  const entitiesEqual = import_lodash.default.isEmpty(
    (0, import_compare.compare)(currContent.entityMap, initialContent.entityMap, { verbose: false })
  );
  return blocksEqual && entitiesEqual;
}
//# sourceMappingURL=comapare-draft-content.js.map
