import Container, { ContainerBlock } from "./components/Container";
import Button, { ButtonBlock } from "./components/Button";
import Column, { ColumnBlock } from "./components/Column";
import ColumnBreak, { ColumnBreakBlock } from "./components/ColumnBreak";
import Row, { RowBlock } from "./components/Row";
import MediaObject, { MediaBlock } from "./components/MediaObject";
import Text, { TextBlock } from "./components/Text";
import Image, { ImageBlock } from "./components/Image";
import Video, { VideoBlock } from "./components/Video";
import Embed from "./components/Embed";
import Header, { HeaderBlock } from "./components/Header";
import Paragraph, { ParagraphBlock } from "./components/Paragraph";
import Input, { InputBlock } from "./components/Input";
import InputGroup, { InputGroupBlock } from "./components/InputGroup";
import Textarea, { TextareaBlock } from "./components/Textarea";
import Checkbox, { CheckboxBlock } from "./components/Checkbox";
import Radio, { RadioBlock } from "./components/Radio";
import Label, { LabelBlock } from "./components/Label";
import FileInput, { FileInputBlock } from "./components/FileInput";
import Select, { SelectBlock } from "./components/Select";
import Badge, { BadgeBlock } from "./components/Badge";
import { ListBlock } from "./components/Lists";
import { GridBlock } from "./components/Grid";
import NavBarOld, { NavbarOldBlock } from "./components/NavBarOld";
import NavBar, { NavbarBlock } from "./components/NavBar";
import SubMenu, { SubmenuBlock } from "./components/SubMenu";
import Jumbotron, { JumbotronBlock } from "./components/Jumbotron";
import ListGroup, { ListGroupBlock } from "./components/ListGroup";
import SideBar, { SideBarBlock } from "./components/SideBar";
import Tabs, { TabsBlock } from "./components/tabs/Tabs";
import Tab from "./components/tabs/Tab";
import TabContent from "./components/tabs/TabContent";
import TabContainer from "./components/tabs/TabContainer";
import Accordions, { AccordionsBlock } from "./components/accordion/Accordions";
import Accordion from "./components/accordion/Accordion";
import AccordionContent from "./components/accordion/AccordionContent";
import AccordionContainer from "./components/accordion/AccordionContainer";
import Carousels, { CarouselsBlock } from "./components/carousel/Carousels";
import Footer, { FooterBlock } from "./components/Footer";
import Modal, { ModalBlock } from "./components/Modal";
import FacebookButton, {
  FacebookButtonBlock,
} from "./components/FacebookButton";
import GoogleButton, { GoogleButtonBlock } from "./components/GoogleButton";
import Sections, { SectionsBlock } from "./components/sections/Sections";
import { SectionComponentsBlock } from "./components/sections/SectionComponents";
import Cards, { CardsBlock } from "./components/cards/Cards";
import LinkBox, { LinkBoxBlock } from "./components/LinkBox";
import { HorizontalLineBlock } from "./components/HorizontalLine";
import { VerticalLineBlock } from "./components/VerticalLine";
import Box, { BoxBlock } from "./components/Box";
import Table, { TableBlock } from "./components/Table";
import { BreadcrumbBlock } from "./components/Breadcrumb";
import Audio, { AudioBlock } from "./components/Audio";
import Iframe, { IframeBlock } from "./components/Iframe";
import PageContentPlaceholder, {
  PageContentPlaceholderBlock,
} from "./components/PageContentPlaceholder";

export default (editor, opts = {}) => {
  const dc = editor.DomComponents;
  const bm = editor.BlockManager;
  const ed = editor;

  const {
    types,
    commands,
    labels,
    blocks,
    labelWebConnectBasicCategory,
    labelWebConnectAdvancedCategory,
    labelWebConnectFormCategory,
    labelWebConnectLayoutCategory,
    labelWebConnectMediaCategory,
    labelWebConnectSocialCategory,
  } = opts;

  const traits = {
    id: {
      name: "id",
      label: labels.trait_id,
    },
    for: {
      name: "for",
      label: labels.trait_for,
    },
    name: {
      name: "name",
      label: labels.trait_name,
    },
    placeholder: {
      name: "placeholder",
      label: labels.trait_placeholder,
    },
    value: {
      name: "value",
      label: labels.trait_value,
    },
    required: {
      type: "checkbox",
      name: "required",
      label: labels.trait_required,
    },
    checked: {
      label: labels.trait_checked,
      type: "checkbox",
      name: "checked",
      changeProp: 1,
    },
  };
  /**
   * Basic Component
   */
  if (blocks.text) {
    TextBlock(bm, labelWebConnectBasicCategory, labels.text, types.text);
    Text(dc, labels.text, types.text);
  }
  if (blocks.header) {
    HeaderBlock(bm, labelWebConnectBasicCategory, labels.header, types.header);
    Header(dc, labels.header, types.header);
  }
  if (blocks.paragraph) {
    ParagraphBlock(
      bm,
      labelWebConnectBasicCategory,
      labels.paragraph,
      types.paragraph
    );
    Paragraph(dc, labels.paragraph, types.paragraph);
  }
  if (blocks.badge) {
    BadgeBlock(bm, labelWebConnectBasicCategory, labels.badge, types.badge);
    Badge(dc, labels.badge, types.badge);
  }
  if (blocks.image) {
    ImageBlock(bm, labelWebConnectBasicCategory, labels.image, types.image);
    Image(dc, labels.image, types.image);
  }
  if (blocks.video) {
    Embed(dc, "Embed", types.video);
    VideoBlock(bm, labelWebConnectBasicCategory, labels.video, types.video);
    Video(dc, labels.video, types.video);
  }
  if (blocks.audio) {
    AudioBlock(bm, labelWebConnectBasicCategory, labels.audio, types.audio);
    Audio(dc, labels.audio, types.audio);
  }

  if (blocks.linkBox) {
    LinkBoxBlock(
      bm,
      labelWebConnectBasicCategory,
      labels.link_box,
      types.link_box
    );
    LinkBox(dc, labels.link_box, types.link_box);
  }
  if (blocks.breadcrumb) {
    BreadcrumbBlock(
      bm,
      labelWebConnectBasicCategory,
      labels.breadcrumb,
      types.breadcrumb
    );
  }
  /**
   * Layout Component
   */
  if (blocks.container) {
    ContainerBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.container,
      types.container
    );
    Container(dc, labels.container, types.container);
  }
  if (blocks.row) {
    RowBlock(bm, labelWebConnectLayoutCategory, labels.row, types.row);
    Row(dc, labels.row, types.row);
  }
  if (blocks.column) {
    ColumnBlock(bm, labelWebConnectLayoutCategory, labels.column, types.column);
    Column(dc, labels.column, types.column, ed);
  }
  if (blocks.sections) {
    SectionsBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.sections,
      types.sections,
      opts
    );
    SectionComponentsBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.sections,
      types.sections,
      opts
    );
    Sections(dc, labels.sections, types.sections, opts);
  }
  if (blocks.column_break) {
    ColumnBreakBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.column_break,
      types.column_break
    );
    ColumnBreak(dc, labels.column_break, types.column_break);
  }
  if (blocks.media_object) {
    MediaBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.media_object,
      types.media_object
    );
    MediaObject(dc, labels.media_object, types.media_object);
  }
  if (blocks.navbar_old) {
    NavbarOldBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.navbar_old,
      types.navbar_old,
      opts
    );
    NavBarOld(dc, labels.navbar_old, types.burgerType);
  }
  if (blocks.navbar) {
    NavbarBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.navbar,
      types.navbar,
      opts
    );
    NavBar(dc, labels.navbar, types.navbar, opts);
  }
  if (blocks.nav_item_submenu) {
    SubmenuBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.labelNavItemSubMenu,
      types.nav_item_dropdown,
      opts
    );
    SubMenu(dc, labels.labelNavItemSubMenu, types.nav_item_dropdown, opts);
  }
  if (blocks.jumbotron) {
    JumbotronBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.jumbotron,
      types.jumbotron
    );
    Jumbotron(dc, labels.jumbotron, types.jumbotron);
  }
  if (blocks.side_bar) {
    SideBarBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.side_bar,
      types.side_bar
    );
    SideBar(dc, labels.side_bar, types.side_bar);
  }
  if (blocks.footer) {
    FooterBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.footer,
      types.footer,
      opts
    );
    Footer(dc, labels.footer, types.footer);
  }
  if (blocks.list) {
    ListBlock(bm, labelWebConnectLayoutCategory, labels.list, types.list);
  }
  if (blocks.grid) {
    GridBlock(bm, labelWebConnectLayoutCategory, labels.grid, types.grid);
  }
  if (blocks.horizontalLine) {
    HorizontalLineBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.horizontal_line,
      types.horizontal_line
    );
  }
  if (blocks.verticalLine) {
    VerticalLineBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.vertical_line,
      types.vertical_line
    );
  }
  if (blocks.box) {
    BoxBlock(bm, labelWebConnectLayoutCategory, labels.box, types.box);
    Box(dc, labels.box, types.box);
  }
  if (blocks.pagePlaceholder) {
    PageContentPlaceholderBlock(
      bm,
      labelWebConnectLayoutCategory,
      labels.pagePlaceholder,
      types.pagePlaceholder
    );
    PageContentPlaceholder(dc, labels.pagePlaceholder, types.pagePlaceholder);
  }
  if (blocks.table) {
    TableBlock(bm, labelWebConnectLayoutCategory, labels.table, types.table);
    Table(dc, labels.table, types.table);
  }

  /**
   * Form Component
   */
  if (blocks.input) {
    InputBlock(bm, labelWebConnectFormCategory, labels.input, types.input);
    Input(dc, labels.input, types.input, traits, opts);

    FileInputBlock(
      bm,
      labelWebConnectFormCategory,
      labels.file_input,
      types.file_input
    );
    FileInput(dc, labels.file_input, types.file_input, traits);
  }

  if (blocks.form_group_input) {
    InputGroupBlock(
      bm,
      labelWebConnectFormCategory,
      labels.form_group_input,
      labels.input_group,
      types.form_group_input
    );
    InputGroup(dc, labels.form_group_input, types.form_group_input);
  }
  if (blocks.textarea) {
    TextareaBlock(
      bm,
      labelWebConnectFormCategory,
      labels.textarea,
      types.textarea
    );
    Textarea(dc, labels.textarea, types.textarea, traits);
  }
  if (blocks.select) {
    SelectBlock(bm, labelWebConnectFormCategory, labels.select, types.select);
    Select(editor, dc, labels.select, types.select, traits, opts);
  }
  if (blocks.checkbox) {
    CheckboxBlock(
      bm,
      labelWebConnectFormCategory,
      labels.checkbox,
      types.checkbox
    );
    Checkbox(dc, labels.checkbox, types.checkbox, traits);
  }
  if (blocks.radio) {
    RadioBlock(bm, labelWebConnectFormCategory, labels.radio, types.radio);
    Radio(dc, labels.radio, types.radio);
  }
  if (blocks.label) {
    LabelBlock(bm, labelWebConnectFormCategory, labels.label, types.label);
    Label(dc, labels.label, types.label);
  }
  if (blocks.button) {
    ButtonBlock(bm, labelWebConnectFormCategory, labels.button, types.button);
    Button(dc, labels.button, types.button);
  }
  /**
   * Components Component
   */
  if (blocks.card) {
    CardsBlock(
      bm,
      labelWebConnectAdvancedCategory,
      labels.cards,
      types.cards,
      opts
    );
    Cards(dc, labels.cards, types.cards, opts);
  }
  if (blocks.tabs) {
    TabsBlock(bm, labelWebConnectAdvancedCategory, labels.tabs, types.tabs);
    Tabs(dc, labels.tabs, types.tabs);
    Tab(dc, labels.tab, types.tab);
    TabContent(dc, labels.tab_content, types.tab_content);
    TabContainer(dc, labels.tab_container, types.tab_container);
  }
  if (blocks.list_group) {
    ListGroupBlock(
      bm,
      labelWebConnectAdvancedCategory,
      labels.list_group,
      types.list_group
    );
    ListGroup(dc, labels.list_group, types.list_group);
  }
  if (blocks.accordions) {
    AccordionsBlock(
      bm,
      labelWebConnectAdvancedCategory,
      labels.accordions,
      types.accordions
    );
    Accordions(dc, labels.accordions, types.accordions);
    Accordion(dc, labels.accordion, types.accordion);
    AccordionContent(dc, labels.accordion_content, types.accordion_content);
    AccordionContainer(
      dc,
      labels.accordion_container,
      types.accordion_container
    );
  }
  if (blocks.carousel) {
    CarouselsBlock(
      bm,
      labelWebConnectAdvancedCategory,
      labels.carousels,
      types.carousels,
      opts
    );
    Carousels(dc, labels.carousels, types.carousels, opts);
  }
  if (blocks.modal) {
    ModalBlock(
      bm,
      labelWebConnectAdvancedCategory,
      labels.modal,
      types.modal,
      opts
    );
    Modal(dc, labels.modal, types.modal, opts);
  }
  /**
   * Social Component
   */
  if (blocks.facebook_button) {
    FacebookButtonBlock(
      bm,
      labelWebConnectSocialCategory,
      labels.facebook_button,
      types.facebook_button
    );
    FacebookButton(dc, labels.facebook_button, types.facebook_button);
  }
  if (blocks.google_button) {
    GoogleButtonBlock(
      bm,
      labelWebConnectSocialCategory,
      labels.google_button,
      types.google_button
    );
    GoogleButton(dc, labels.google_button, types.google_button);
  }

  if (blocks.iframe) {
    IframeBlock(bm, labelWebConnectBasicCategory, labels.iframe, types.iframe);
    Iframe(dc, labels.iframe, types.iframe);
  }
};
