import lodash from "lodash";
import { uuid } from "./../../wix-rich-content-common/index.js";
import { initializeMetadata } from "../converters/node-utils.js";
import { createEmptyContent } from "./create-empty-content.js";
const applyNewId = ({ metadata, ...rest }) => ({
  ...rest,
  metadata: initializeMetadata({ ...metadata || {}, id: uuid() })
});
const duplicate = (content) => applyNewId(lodash.cloneDeep(content));
const ensureContentId = (content) => {
  if (!content) {
    return createEmptyContent();
  }
  if (content.metadata?.id) {
    return content;
  }
  return applyNewId(content);
};
const extractIdFromContent = (content) => content.metadata?.id;
export {
  duplicate,
  ensureContentId,
  extractIdFromContent
};
//# sourceMappingURL=metadata-utils.js.map
