import { BorderSize, ImageFillType, StructureType, TopicType } from "@/enum"
import { MindMapProjectInfo } from "@/types";
import { buildTopic } from "@/pages/mindmap/mindMap";

// 通用连接桩
export const ports = {
  groups: {
    top: {
      position: 'top',
      attrs: {
        circle: {
          r: 4,
          magnet: true,
          stroke: '#5F95FF',
          strokeWidth: 1,
          fill: '#fff',
          style: {
            visibility: 'hidden',
          },
        },
      },
    },
    right: {
      position: 'right',
      attrs: {
        circle: {
          r: 4,
          magnet: true,
          stroke: '#5F95FF',
          strokeWidth: 1,
          fill: '#fff',
          style: {
            visibility: 'hidden',
          },
        },
      },
    },
    bottom: {
      position: 'bottom',
      attrs: {
        circle: {
          r: 4,
          magnet: true,
          stroke: '#5F95FF',
          strokeWidth: 1,
          fill: '#fff',
          style: {
            visibility: 'hidden',
          },
        },
      },
    },
    left: {
      position: 'left',
      attrs: {
        circle: {
          r: 4,
          magnet: true,
          stroke: '#5F95FF',
          strokeWidth: 1,
          fill: '#fff',
          style: {
            visibility: 'hidden',
          },
        },
      },
    },
  },
  items: [
    {
      group: 'top',
      args: {
        dy: 2,
      },
    },
    {
      group: 'right',
      args: {
        dx: -2,
      },
    },
    {
      group: 'bottom',
      args: {
        dy: -2,
      },
    },
    {
      group: 'left',
      args: {
        dx: 2,
      },
    },
  ],
}

// 通用数据
export const defaultData = {
  opacity: 100,
  text: {
    fontFamily: "微软雅黑",
    color: "#000000",
    fontSize: 14,
    lineHeight: 1.25,
    textAlign: "center",
    textVAlign: "middle",
    bold: false,
    italic: false,
    underline: false,
    strikethrough: false,
  },
  fill: {
    fillType: "color",
    color1: "#FFFFFF",
    color2: "#eeeeee",
    gradientType: "linear",
    gradientValue: 0,
    objectFit: ImageFillType.Fill,
    imageUrl: "",
  },
  stroke: {
    type: "solid",
    color: "#323232",
    width: 1,
  },
  lock: false,
};

// 脑图默认主题数据
export const topicData = {
  ...defaultData,
  type: TopicType.main,
  borderSize: BorderSize.medium,
  fixedWidth: false,
  collapsed: false,
  linkTopicId: undefined,
  edge: {
    color: "#323232",
    width: 3,
  },
  children: [],
  extraModules: undefined,
  links: []
}

// 初始化项目
export const defaultProject: MindMapProjectInfo = {
  name: "新建脑图",
  desc: "",
  version: "",
  author: "",
  structure: StructureType.right,
  pageSetting: {
    fillType: "color",
    fill: "#ffffff",
    fillImageUrl: "",
    branchY: 30,
    branchX: 44,
    subTopicY: 16,
    subTopicX: 20,
    alignSameTopic: false,
    showWatermark: false,
    watermark: "",
  },
  // 主题
  theme: "default",
  topics: [
    buildTopic(TopicType.main, {
      label: "中心主题",
      fill: {
        ...topicData.fill,
        color1: "#30304D",
      },
      text: {
        ...topicData.text,
        fontSize: 30,
        color: "#fff",
      },
    })
  ],
};
