import { Node } from "@antv/x6";
import { BorderSize, StructureType, TopicBorderType, TopicType } from "./enum";
export interface CompoundedComponent {
  name: string;
  icon: string;
  node: Node.Metadata;
}

export interface LaneItem {
  width: number;
  name: string;
}

export interface StageItem {
  height: number;
  name: string;
}

export interface cellStyle {
  opacity: number;
  text: {
    fontFamily: string;
    color: string;
    fontSize: number;
    lineHeight: number;
    textAlign: "left" | "center" | "right";
    textVAlign: "top" | "middle" | "bottom";
    bold: boolean;
    italic: boolean;
    textDecoration: "underline" | "line-through" | "none";
  };
  fill: {
    fillType: "color" | "gradient" | "image";
    color1: string;
    color2: string;
    gradientType: "linear" | "radial";
    gradientValue: number;
    objectFit: ImageFillType;
    imageUrl: string;
  };
  stroke: {
    type: "solid" | "dashed" | "dotted" | "dashdot";
    color: string;
    width: number;
  };
}

export interface HierarchyResult {
  id: string;
  x: number;
  y: number;
  data: TopicItem;
  width: number;
  height: number;
  children: HierarchyResult[];
  totalHeight: number;
  totalWidth: number;
  direction?: string;
}

export type TopicItem = {
  /**
   * 主键
   */
  id: string;
  /**
   * 主题内容
   */
  label: string;
  /**
   * 宽
   */
  width: number;
  /**
   * 高
   */
  height: number;
  /**
   * 主题类型 main:中心主题 branch:分支主题 sub:子主题
   */
  type: TopicType;
  /**
   * 是否固定宽度
   */
  fixedWidth: boolean;
  /**
   * 扩展模块
   */
  extraModules?: {
    type: "image" | "code";
    data:
      | {
          code: string;
          language: string;
        }
      | {
          imageUrl: string;
          width: number;
          height: number;
        };
  };
  /**
   * 图标
   */
  icons?: string[];
  /**
   * 标签
   */
  tags?: { name: string; color: string }[];
  /**
   * 备注
   */
  remark?: string;
  /**
   * 链接
   */
  href?: {
    title: string;
    value: string;
  };
  /**
   * 父级节点
   */
  parentId?: string;
  /**
   * 位置x
   */
  x?: number;
  /**
   * 位置y
   */
  y?: number;
  /**
   * 子节点
   */
  children?: TopicItem[];
  /**
   * 连线
   */
  edge?: {
    color: string;
    width: number;
  };
  /**
   * 折叠子节点
   */
  collapsed?: boolean;
  /**
   * 边框圆角
   */
  borderSize: BorderSize;
  /**
   * 关联线
   */
  links?: any[];
  /**
   * 主题链接
   */
  linkTopicId?: string;
  /**
   * 外框
   */
  border?: {
    line: {
      width: number;
      style: "solid" | "dashed";
      color: string;
    };
    fill: string;
    type: TopicBorderType;
    label: string;
  };
  /**
   * 概要
   */
  isSummary?: boolean;
  summarySource?: string;
  summary?: {
    topic: TopicItem;
    range: [];
    border: {
      line: {
        width: number;
        color: string;
      };
      type: TopicBorderType;
    };
  };
} & cellStyle;
export interface MindMapProjectInfo {
  name: string;
  desc: string;
  version: string;
  author: string;
  theme: string;
  structure: StructureType;
  pageSetting: {
    backgroundType: "color" | "image";
    backgroundColor: string;
    backgroundImage: string;
    branchY: number;
    branchX: number;
    subTopicY: number;
    subTopicX: number;
    alignSameTopic: boolean;
    showWatermark: boolean;
    watermarkText: string;
  };
  topics: any[];
}
