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