// element
import { getModel as createLines } from "../card/elements/lines/model";
import { getModel as createLine } from "../card/elements/line/model";
import { getModel as createText } from "../card/elements/text/model";
import { getModel as createImage } from "../card/elements/image/model";
import { getModel as createGrids } from "../card/elements/grids/model";
import { getModel as createPane } from "../card/elements/pane/model";
import { getModel as createGutter } from "../card/elements/gutter/model";
import { getModel as createFillField } from "./elements/fill-field/model";
import { getModel as createFillTable } from "../card/elements/fill-table/model";
import { getModel as createFillPane } from "../card/elements/fill-pane/model";
import { getModel as createPaneBox } from "./elements/pane-box/model";
import { getModel as createFieldText } from "./elements/field-text/model";
import { getModel as createPaperStruct } from "./elements/paper-struct/model";

// available infos
const EDITABLE_ELEMENT = [
  "LINE_HORIZONTAL",
  "LINE_VERTICAL",
  "LINES",
  "TEXT",
  "FIELD_TEXT",
  "IMAGE",
  "GRIDS",
  "PANE",
  "GUTTER",
  "FILL_FIELD",
  "FILL_TABLE",
  "FILL_PANE",
];
const EDITABLE_TOPIC = ["PANE_BOX", "PAPER_STRUCT"];

const ELEMENT_INFOS = {
  LINES: {
    name: "多横线",
    getModel: createLines,
  },
  LINE_HORIZONTAL: {
    name: "横线",
    getModel: () => createLine("HORIZONTAL"),
  },
  LINE_VERTICAL: {
    name: "竖线",
    getModel: () => createLine("VERTICAL"),
  },
  TEXT: {
    name: "文本",
    getModel: createText,
  },
  IMAGE: {
    name: "图片",
    getModel: createImage,
  },
  GRIDS: {
    name: "网格",
    getModel: createGrids,
  },
  PANE: {
    name: "方框",
    getModel: createPane,
  },
  GUTTER: {
    name: "装订线",
    getModel: createGutter,
  },
  FILL_FIELD: {
    name: "填词块",
    getModel: createFillField,
  },
  FILL_TABLE: {
    name: "表格",
    getModel: createFillTable,
  },
  FILL_PANE: {
    name: "方格组",
    getModel: createFillPane,
  },
  PANE_BOX: {
    name: "编辑框",
    getModel: createPaneBox,
  },
  FIELD_TEXT: {
    name: "字段文本",
    getModel: createFieldText,
  },
  PAPER_STRUCT: {
    name: "试卷结构",
    getModel: createPaperStruct,
  },
};

const ELEMENT_LIST = EDITABLE_ELEMENT.map((type) => {
  return {
    ...ELEMENT_INFOS[type],
    type,
  };
});
const TOPIC_LIST = EDITABLE_TOPIC.map((type) => {
  return {
    ...ELEMENT_INFOS[type],
    type,
  };
});

// 获取元件默认数据结构
const getElementModel = (type, optionData = {}) => {
  return ELEMENT_INFOS[type].getModel(optionData);
};

const getElementName = (type) => {
  return ELEMENT_INFOS[type].name;
};

const PAGE_CONFIG = {
  pageSize: "A3",
  columnNumber: 2,
  columnGap: 40,
  showPageNo: true,
  showSide: true,
  showCover: false,
};

export {
  getElementModel,
  getElementName,
  PAGE_CONFIG,
  ELEMENT_LIST,
  TOPIC_LIST,
};
