import { ImageFillType } from "../enum"
import { Edge } from "@antv/x6";
import { LineType, ConnectorType } from "../enum";

// 通用连接桩
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: "#fff",
    color2: "#eee",
    gradientType: "linear",
    gradientValue: 0,
    objectFit: ImageFillType.Fill,
    imageUrl: "",
  },
  stroke: {
    type: "solid",
    color: "#323232",
    width: 1,
  },
  lock: false,
};

// 默认边数据
export const BaseEdge: Edge.Properties = {
  router: {
    name: 'manhattan',
    args: {
      excludeShapes: ['page-container-node'],
      padding: 10
    }
  },
  attrs: {
    line: {
      stroke: "#323232",
      strokeDasharray: LineType.solid,
      strokeWidth: 2,
      sourceMarker: {
        name: "",
      },
      targetMarker: {
        name: "block",
      },
    },
    text: defaultData.text,
  },
  data: {
    connectorType: ConnectorType.Rounded
  },
};

