"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 common_plugins_builder_exports = {};
__export(common_plugins_builder_exports, {
  blockquote: () => blockquote,
  fontSize: () => fontSize,
  italic: () => italic,
  li: () => li,
  link: () => link,
  ol: () => ol,
  p: () => p,
  text: () => text,
  textColor: () => textColor,
  ul: () => ul
});
module.exports = __toCommonJS(common_plugins_builder_exports);
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_utils = require("./utils.js");
const p = (...args) => {
  const paragraphData = args.find(
    (a) => typeof a !== "string" && !("type" in a)
  );
  const nodes = args.map(
    (arg) => typeof arg === "string" ? text(arg).node() : "type" in arg && arg.type === "text_node" ? arg.node() : void 0
  ).filter(import_utils.isDefined);
  return {
    type: "block_node",
    // @ts-ignore
    node: (getId) => {
      return {
        id: getId(),
        type: import_v1.Node_Type.PARAGRAPH,
        ...paragraphData ? { paragraphData } : {},
        ...nodes?.length && { nodes }
      };
    }
  };
};
const ul = (...args) => {
  const bulletedListData = args.find((a) => !("type" in a));
  return {
    type: "block_node",
    node: (getId) => ({
      id: getId(),
      type: import_v1.Node_Type.BULLETED_LIST,
      nodes: args.map((arg) => {
        const nodeArg = arg;
        return nodeArg.node ? nodeArg.node(getId) : void 0;
      }).filter(import_utils.isDefined),
      ...bulletedListData !== void 0 && { bulletedListData }
    })
  };
};
const ol = (...args) => {
  const orderedListData = args.find((a) => !("type" in a));
  return {
    type: "block_node",
    node: (getId) => ({
      id: getId(),
      type: import_v1.Node_Type.ORDERED_LIST,
      nodes: args.map((arg) => {
        const nodeArg = arg;
        return nodeArg.node ? nodeArg.node(getId) : void 0;
      }).filter(import_utils.isDefined),
      ...orderedListData !== void 0 && { orderedListData }
    })
  };
};
const li = (...args) => {
  return {
    type: "block_node",
    node: (getId) => ({
      id: getId(),
      type: import_v1.Node_Type.LIST_ITEM,
      nodes: args.map((arg) => arg.node(getId))
    })
  };
};
const text = (text2, ...decorations) => {
  return {
    type: "text_node",
    node: () => ({
      type: import_v1.Node_Type.TEXT,
      id: "",
      // @ts-expect-error
      textData: { text: text2, ...decorations.length ? { decorations } : {} }
    })
  };
};
const fontSize = (fontSize2) => {
  return {
    type: import_v1.Decoration_Type.FONT_SIZE,
    fontSizeData: { unit: import_v1.FontSizeData_fontType.PX, value: fontSize2 }
  };
};
const blockquote = (...args) => {
  return {
    type: "block_node",
    node: (getId) => ({
      id: getId(),
      type: import_v1.Node_Type.BLOCKQUOTE,
      nodes: args.map((arg) => arg.node(getId)),
      blockquoteData: {
        indentation: 0
      }
    })
  };
};
const italic = (italicData = true) => ({
  type: import_v1.Decoration_Type.ITALIC,
  italicData
});
const link = (url) => ({
  type: import_v1.Decoration_Type.LINK,
  linkData: {
    link: {
      anchor: void 0,
      target: import_v1.Link_Target.BLANK,
      url
    }
  }
});
const textColor = ({
  background,
  foreground
}) => ({
  type: import_v1.Decoration_Type.COLOR,
  colorData: {
    background,
    foreground
  }
});
//# sourceMappingURL=common-plugins.builder.js.map
