import { trainTypeID } from "./CommonTypes";

export type colorString =
  | "aqua"
  | "#00a0bdff"
  | "#007488ff"
  | "red"
  | "#297bff"
  | "#ff7300ff"
  | "#5f5f5fff"
  | "#e000b0ff"
  | "white"
  | "black"
  | "pink";

type trainTypeString =
  | "快速"
  | "特急"
  | "寝台特急"
  | "臨時"
  | "普通列車"
  | "普通列車(ワンマン)"
  | "臨時快速"
  | "臨時特急"
  | "団体臨時"
  | "貨物"
  | "回送"
  | "単機回送"
  | "試運転"
  | "その他";
type trainTypeDataString = "rapid" | "express" | "normal" | "notService";
type getTrainType = (e: {
  type: trainTypeID;
  id?: string;
  whiteMode?: boolean;
}) => {
  color: colorString;
  name: trainTypeString;
  shortName: string;
  fontAvailable: boolean;
  isOneMan: boolean;
  data: trainTypeDataString;
};
export const getTrainType: getTrainType = ({ type, id, whiteMode }) => {
  switch (type) {
    case "Normal":
      return {
        color: whiteMode ? "black" : "white",
        name: "普通列車",
        shortName: "普通",
        fontAvailable: true,
        isOneMan: false,
        data: "normal",
      };
    case "OneMan":
      return {
        color: whiteMode ? "black" : "white",
        name: "普通列車(ワンマン)",
        shortName: "普通",
        fontAvailable: true,
        isOneMan: true,
        data: "normal",
      };
    case "Rapid":
      return {
        color: whiteMode ? "#00a0bdff" : "aqua",
        name: "快速",
        shortName: "快速",
        fontAvailable: true,
        isOneMan: false,
        data: "rapid",
      };
    case "OneManRapid":
      return {
        color: whiteMode ? "#00a0bdff" : "aqua",
        name: "快速",
        shortName: "快速",
        fontAvailable: true,
        isOneMan: true,
        data: "rapid",
      };
    case "LTDEXP":
      return {
        color: "red",
        name: "特急",
        shortName: "特急",
        fontAvailable: true,
        isOneMan: false,
        data: "express",
      };
    case "NightLTDEXP":
      return {
        color: whiteMode ? "#e000b0ff" : "pink",
        name: "寝台特急",
        shortName: "特急",
        fontAvailable: true,
        isOneMan: false,
        data: "express",
      };
    case "SPCL":
    case "SPCL_Normal":
      return {
        color: "#297bff",
        name: "臨時",
        shortName: "臨時",
        fontAvailable: true,
        isOneMan: false,
        data: "normal",
      };
    case "SPCL_Rapid":
      return {
        color: "#297bff",
        name: "臨時快速",
        shortName: "臨時快速",
        fontAvailable: true,
        isOneMan: false,
        data: "normal",
      };
    case "SPCL_EXP":
      return {
        color: "#297bff",
        name: "臨時特急",
        shortName: "臨時特急",
        fontAvailable: true,
        isOneMan: false,
        data: "normal",
      };
    case "Party":
      return {
        color: "#ff7300ff",
        name: "団体臨時",
        shortName: "団体臨時",
        fontAvailable: true,
        isOneMan: false,
        data: "normal",
      };
    case "Freight":
      return {
        color: "#007488ff",
        name: "貨物",
        shortName: "貨物",
        fontAvailable: false,
        isOneMan: false,
        data: "notService",
      };
    case "Forwarding":
      return {
        color: "#5f5f5fff",
        name: "回送",
        shortName: "回送",
        fontAvailable: false,
        isOneMan: false,
        data: "notService",
      };
    case "FreightForwarding":
      return {
        color: "#5f5f5fff",
        name: "単機回送",
        shortName: "単機回送",
        fontAvailable: false,
        isOneMan: false,
        data: "notService",
      };
    case "Other":
    default:
      if (id) {
        switch (true) {
          case !!id.includes("T"):
            return {
              color: "#5f5f5fff",
              name: "単機回送",
              shortName: "単機回送",
              fontAvailable: false,
              isOneMan: false,
              data: "notService",
            };
          case !!id.includes("R"):
          case !!id.includes("E"):
          case !!id.includes("L"):
          case !!id.includes("A"):
          case !!id.includes("B"):
            return {
              color: "#5f5f5fff",
              name: "回送",
              shortName: "回送",
              fontAvailable: false,
              isOneMan: false,
              data: "notService",
            };
          case !!id.includes("H"):
            return {
              color: "#5f5f5fff",
              name: "試運転",
              shortName: "試運転",
              fontAvailable: false,
              isOneMan: false,
              data: "notService",
            };
        }
      }
      return {
        color: whiteMode ? "black" : "white",
        name: "その他",
        shortName: "その他",
        fontAvailable: false,
        isOneMan: false,
        data: "normal",
      };
  }
};
