export interface NetworkTypeOption {
  value: string
  label: string
  tone: "sky" | "emerald" | "amber" | "rose" | "violet" | "slate"
  description?: string
}

export const NETWORK_TYPES: NetworkTypeOption[] = [
  { value: "cn2_gia", label: "CN2 GIA", tone: "sky", description: "电信 CN2 GIA 精品回国" },
  { value: "cn2_gt", label: "CN2 GT", tone: "sky", description: "CN2 普通线路" },
  { value: "cmin2", label: "CMIN2", tone: "emerald", description: "移动 CMIN2 回国" },
  { value: "cmi", label: "CMI", tone: "emerald", description: "移动国际 CMI" },
  { value: "cu_vip", label: "联通 CUVIP", tone: "amber", description: "联通 9929 / 4837 优化" },
  { value: "bgp_multi", label: "三网 BGP", tone: "violet", description: "三网 BGP 直连" },
  { value: "hk_direct", label: "香港直连", tone: "rose", description: "香港本地 / 直连大陆" },
  { value: "intl_direct", label: "国际直连", tone: "slate", description: "海外原生直连" },
  { value: "domestic", label: "国内大陆", tone: "amber", description: "国内大陆机房" },
  { value: "anti_ddos", label: "高防", tone: "rose", description: "DDoS 高防线路" },
  { value: "standard", label: "普通线路", tone: "slate" },
]

const BY_VALUE: Record<string, NetworkTypeOption> = Object.fromEntries(
  NETWORK_TYPES.map((n) => [n.value, n]),
)

export function getNetworkType(value: string | null | undefined): NetworkTypeOption | undefined {
  if (!value) return undefined
  return BY_VALUE[value]
}

export const NETWORK_TYPE_BADGE_CLS: Record<NetworkTypeOption["tone"], string> = {
  sky: "bg-sky-50 text-sky-600 ring-sky-100",
  emerald: "bg-emerald-50 text-emerald-600 ring-emerald-100",
  amber: "bg-amber-50 text-amber-600 ring-amber-100",
  rose: "bg-rose-50 text-rose-600 ring-rose-100",
  violet: "bg-violet-50 text-violet-600 ring-violet-100",
  slate: "bg-slate-100 text-slate-600 ring-slate-200",
}

export const NETWORK_TYPE_DOT_CLS: Record<NetworkTypeOption["tone"], string> = {
  sky: "bg-sky-400",
  emerald: "bg-emerald-400",
  amber: "bg-amber-400",
  rose: "bg-rose-400",
  violet: "bg-violet-400",
  slate: "bg-slate-400",
}
