import { Node } from "@antv/x6";
import { cloneDeep } from "lodash-es";

import { basic } from "@/components/basic";
import { flowchart } from "@/components/flowchart";
import { er } from "@/components/er";
import { lane } from "@/components/lane";
import { umlBase } from "@/components/uml/common";
import { umlUseCase } from "@/components/uml/usecase";
import { umlSequence } from "@/components/uml/sequence";
import { umlClass } from "@/components/uml/class";

const compMap: Record<string, Node.Metadata> = {};
/**
 * 导出flowchart自定义组件列表
 * @returns 组件列表
 */
export const getCompMap = () => {
  const compList = [
    ...basic,
    ...flowchart,
    ...er,
    ...lane,
    ...umlBase,
    ...umlUseCase,
    ...umlSequence,
    ...umlClass,
  ];

  compList.forEach((item) => {
    compMap[item.node.shape as string] = cloneDeep(item.node);
  });

  return compMap;
};