import {
  ButtonData_Type,
  DividerData_Alignment,
  DividerData_LineStyle,
  DividerData_Width,
  HTMLData_Source,
  Node_Type,
  PluginContainerData_Alignment,
  PluginContainerData_Width_Type,
  PollData_Design_PollDesign_Background_Type,
  PollData_Layout_PollLayout_Direction,
  PollData_Layout_PollLayout_Type,
  PollData_Poll_Settings_Permissions_ViewRole,
  PollData_Poll_Settings_Permissions_VoteRole,
  TextStyle_TextAlignment
} from "./../../ricos-schema/legacy/wix/rich_content/v1/index.js";
import DEFAULT_BULLETED_LIST_DATA from "./../../ricos-schema/legacy/statics/bulleted_list.defaults.json.js";
import DEFAULT_ORDERED_LIST_DATA from "./../../ricos-schema/legacy/statics/ordered_list.defaults.json.js";
import { dataByNodeType } from "../converters/node-utils.js";
import { addNode as add, toListDataArray, toTextDataArray } from "./builder-utils.js";
const DEFAULT_PARAGRAPH_DATA = {
  textStyle: { textAlignment: TextStyle_TextAlignment.AUTO },
  indentation: 0
};
const DEFAULT_CONTAINER_DATA = {
  alignment: PluginContainerData_Alignment.CENTER,
  textWrap: true,
  width: { size: PluginContainerData_Width_Type.CONTENT }
};
const DEFAULT_DIVIDER_DATA = {
  lineStyle: DividerData_LineStyle.SINGLE,
  width: DividerData_Width.LARGE,
  alignment: DividerData_Alignment.CENTER,
  containerData: { ...DEFAULT_CONTAINER_DATA, textWrap: false }
};
const DEFAULT_BUTTON_DATA = {
  type: ButtonData_Type.ACTION,
  containerData: DEFAULT_CONTAINER_DATA,
  text: "Click Me"
};
const DEFAULT_CODE_DATA = {
  textStyle: {
    textAlignment: TextStyle_TextAlignment.AUTO
  }
};
const DEFAULT_HEADING_DATA = {
  level: 2,
  indentation: 0,
  textStyle: { textAlignment: TextStyle_TextAlignment.AUTO }
};
const DEFAULT_HTML_DATA = {
  containerData: DEFAULT_CONTAINER_DATA,
  html: "<div/>",
  url: void 0,
  widgetId: void 0,
  source: HTMLData_Source.HTML
};
const DEFAULT_POLL_DATA = {
  containerData: DEFAULT_CONTAINER_DATA,
  poll: {
    options: [],
    title: "",
    settings: {
      permissions: {
        view: PollData_Poll_Settings_Permissions_ViewRole.VOTERS,
        vote: PollData_Poll_Settings_Permissions_VoteRole.SITE_MEMBERS,
        allowMultipleVotes: false
      },
      showVoters: true,
      showVotesCount: true
    }
  },
  layout: {
    poll: {
      type: PollData_Layout_PollLayout_Type.LIST,
      direction: PollData_Layout_PollLayout_Direction.LTR,
      enableImage: false
    },
    options: {
      enableImage: false
    }
  },
  design: {
    poll: {
      background: {
        type: PollData_Design_PollDesign_Background_Type.IMAGE
      },
      borderRadius: 0
    },
    options: {
      borderRadius: 0
    }
  }
};
const createNode = (generateId) => (type, data, nodes) => {
  return {
    id: generateId(),
    type,
    ...dataByNodeType(type, data),
    nodes: nodes || []
  };
};
const createListNode = (generateId) => (type, items, data) => createNode(generateId)(
  type,
  data,
  items.map(
    ({ text, data: data2 }) => createNode(generateId)(Node_Type.LIST_ITEM, {}, [
      createTextNode(generateId)(Node_Type.PARAGRAPH, text, data2)
    ])
  )
);
const createTextNode = (generateId) => (type, text, data) => ({
  ...createNode(generateId)(type, data),
  nodes: text.map((textData) => ({
    nodes: [],
    id: "",
    type: Node_Type.TEXT,
    ...dataByNodeType(Node_Type.TEXT, textData)
  }))
});
const makeNode = (generateId) => ({ data, type }) => createNode(generateId)(type, data);
const addNode = (generateId) => ({ data, type, index, before, after, content }) => {
  const node = makeNode(generateId)({ type, data });
  return add({ node, index, before, after, content });
};
const makeTextNode = (generateId) => ({
  text,
  data,
  type
}) => {
  const textData = toTextDataArray(text);
  return createTextNode(generateId)(type, textData, data);
};
const addTextNode = (generateId) => ({
  text,
  data,
  type,
  index,
  before,
  after,
  content
}) => {
  const node = makeTextNode(generateId)({ text, data, type });
  return add({ node, index, before, after, content });
};
const makeListNode = (generateId) => ({
  items,
  data = DEFAULT_PARAGRAPH_DATA,
  type,
  listData = type === Node_Type.BULLETED_LIST ? DEFAULT_BULLETED_LIST_DATA : DEFAULT_ORDERED_LIST_DATA
}) => {
  const listItemData = toListDataArray(items, data);
  return createListNode(generateId)(type, listItemData, listData);
};
const addListNode = (generateId) => ({
  items,
  data,
  listData,
  type,
  index,
  before,
  after,
  content
}) => {
  const node = makeListNode(generateId)({ items, data, type, listData });
  return add({ node, index, before, after, content });
};
export {
  DEFAULT_BUTTON_DATA,
  DEFAULT_CODE_DATA,
  DEFAULT_CONTAINER_DATA,
  DEFAULT_DIVIDER_DATA,
  DEFAULT_HEADING_DATA,
  DEFAULT_HTML_DATA,
  DEFAULT_PARAGRAPH_DATA,
  DEFAULT_POLL_DATA,
  addListNode,
  addNode,
  addTextNode,
  createNode,
  createTextNode,
  makeListNode,
  makeNode,
  makeTextNode
};
//# sourceMappingURL=node-builder-methods.js.map
