"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 abstract_content_builder_exports = {};
__export(abstract_content_builder_exports, {
  setupAbstractContentBuilder: () => setupAbstractContentBuilder
});
module.exports = __toCommonJS(abstract_content_builder_exports);
var import_lodash = __toESM(require("lodash"));
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_node_builder_methods = require("./node-builder-methods.js");
const setupAbstractContentBuilder = (generateId, textNodeCreator, listNodeCreator, nodeCreator, tableNodeCreator, collapsibleListNodeCreator, methodPrefix = import_lodash.default.identity) => {
  class RicosContentBuilder {
  }
  const builderApis = {};
  const addMethod = (name, method) => {
    builderApis[methodPrefix(name)] = RicosContentBuilder.prototype[methodPrefix(name)] = method;
  };
  const TextNodes = [
    {
      name: "paragraph",
      type: import_v1.Node_Type.PARAGRAPH,
      dataT: import_node_builder_methods.DEFAULT_PARAGRAPH_DATA
    },
    { name: "heading", type: import_v1.Node_Type.HEADING, dataT: import_node_builder_methods.DEFAULT_HEADING_DATA },
    { name: "code", type: import_v1.Node_Type.CODE_BLOCK, dataT: import_node_builder_methods.DEFAULT_CODE_DATA }
  ];
  const ListNodes = [
    { name: "bulletList", type: import_v1.Node_Type.BULLETED_LIST },
    { name: "orderedList", type: import_v1.Node_Type.ORDERED_LIST }
  ];
  const PluginNodes = [
    { name: "divider", type: import_v1.Node_Type.DIVIDER, dataT: import_node_builder_methods.DEFAULT_DIVIDER_DATA },
    { name: "file", type: import_v1.Node_Type.FILE, dataT: {} },
    { name: "gallery", type: import_v1.Node_Type.GALLERY, dataT: {} },
    { name: "html", type: import_v1.Node_Type.HTML, dataT: import_node_builder_methods.DEFAULT_HTML_DATA },
    { name: "image", type: import_v1.Node_Type.IMAGE, dataT: {} },
    { name: "video", type: import_v1.Node_Type.VIDEO, dataT: {} },
    { name: "appEmbed", type: import_v1.Node_Type.APP_EMBED, dataT: {} },
    { name: "embed", type: import_v1.Node_Type.EMBED, dataT: {} },
    {
      name: "linkPreview",
      type: import_v1.Node_Type.LINK_PREVIEW,
      dataT: {}
    },
    { name: "button", type: import_v1.Node_Type.BUTTON, dataT: import_node_builder_methods.DEFAULT_BUTTON_DATA },
    { name: "gif", type: import_v1.Node_Type.GIF, dataT: {} },
    { name: "poll", type: import_v1.Node_Type.POLL, dataT: import_node_builder_methods.DEFAULT_POLL_DATA }
  ];
  TextNodes.forEach(
    ({
      name,
      type,
      dataT
    }) => {
      addMethod(name, ({ data = dataT, text, ...rest }) => {
        return textNodeCreator(generateId)({
          text,
          type,
          data,
          ...rest
        });
      });
    }
  );
  ListNodes.forEach(({ name, type }) => {
    addMethod(name, ({ items, data, ...rest }) => {
      return listNodeCreator(generateId)({ items, data, type, ...rest });
    });
  });
  PluginNodes.forEach(({ name, type, dataT }) => {
    addMethod(name, ({ data = dataT, ...rest }) => {
      return nodeCreator(generateId)({
        type,
        data,
        ...rest
      });
    });
  });
  Object.entries({
    table: tableNodeCreator,
    collapsibleList: collapsibleListNodeCreator
  }).forEach(([name, method]) => addMethod(name, method(generateId)));
  return builderApis;
};
//# sourceMappingURL=abstract-content-builder.js.map
