"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);
var modify_exports = {};
__export(modify_exports, {
  modify: () => modify
});
module.exports = __toCommonJS(modify_exports);
var import_function = require("fp-ts-esm/function");
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_modifier_infra = require("../modifier-infra.js");
const nodesAccessor = (node) => node.nodes ?? [];
const nodesSetter = (nodes) => ({ nodes });
const getRootNode = (content) => ({
  id: "root",
  type: import_v1.Node_Type.UNRECOGNIZED,
  nodes: content.nodes
});
const toRichContentModifier = (content) => function(modifier) {
  const self = { modifier };
  return {
    filter(predicate) {
      self.modifier = modifier.filter.bind(self.modifier)(predicate);
      self.modifier.set = this.set;
      self.modifier.filter = this.filter;
      return self.modifier;
    },
    set(setter) {
      const root = modifier.set.bind(self.modifier)(setter);
      return { ...content, nodes: root.nodes };
    }
  };
};
const modify = (content) => (0, import_function.pipe)(
  content,
  getRootNode,
  (0, import_modifier_infra.getModifier)(nodesAccessor, nodesSetter),
  toRichContentModifier(content)
);
//# sourceMappingURL=modify.js.map
