/**
 * Extended Switch & Router Seed Data — Security, Industrial, Broadcast & Misc Vendors
 *
 * Covers Flexoptix-supported vendors beyond the core networking OEMs.
 * These devices all have SFP/SFP+/QSFP ports and use optical transceivers.
 * Sources: Public datasheets, vendor product pages.
 */
import { pool, ensureVendor, findOrCreateSwitch } from "../utils/db";

interface SwitchSeed {
  vendor: string;
  vendorType: string;
  vendorWebsite: string;
  model: string;
  series: string;
  category: "DataCenter" | "Campus" | "Edge" | "Core" | "SP" | "Industrial";
  layer: "L2" | "L3" | "L2/L3";
  portsConfig: Record<string, number>;
  totalPorts: number;
  uplinkSpeedGbps?: number;
  maxSpeedGbps: number;
  switchingCapacityTbps?: number;
  forwardingRateMpps?: number;
  asicVendor?: string;
  asicModel?: string;
  rackUnits?: number;
  maxPowerW?: number;
  poeSupport?: string;
  stackingSupport?: boolean;
  vxlanSupport?: boolean;
  evpnSupport?: boolean;
  bgpSupport?: boolean;
  mplsSupport?: boolean;
  openconfigSupport?: boolean;
  sonicCompatible?: boolean;
  macsecSupport?: boolean;
  lifecycleStatus?: string;
  tags?: string[];
}

// ═══════════════════════════════════════════════════════
// FORTINET — FortiSwitch + FortiGate (with SFP ports)
// ═══════════════════════════════════════════════════════
const FORTINET: SwitchSeed[] = [
  // FortiSwitch 100 Series — Access
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 108F", series: "FortiSwitch 100", category: "Campus", layer: "L2",
    portsConfig: { "1G_RJ45": 8, "1G_SFP": 2 }, totalPorts: 10,
    maxSpeedGbps: 1,
    rackUnits: 0, maxPowerW: 15,
    tags: ["access", "managed", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 124F", series: "FortiSwitch 100", category: "Campus", layer: "L2",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 30,
    tags: ["access", "managed", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 124F-POE", series: "FortiSwitch 100", category: "Campus", layer: "L2",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 370,
    poeSupport: "PoE+",
    tags: ["access", "PoE", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 148F-POE", series: "FortiSwitch 100", category: "Campus", layer: "L2",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 740,
    poeSupport: "PoE+",
    tags: ["access", "PoE", "FortiLink"],
  },
  // FortiSwitch 400 Series — Aggregation
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 424E", series: "FortiSwitch 400", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 45,
    tags: ["aggregation", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 448E-FPOE", series: "FortiSwitch 400", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 780,
    poeSupport: "PoE+",
    tags: ["aggregation", "PoE", "FortiLink"],
  },
  // FortiSwitch 500 Series — Distribution
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 524D", series: "FortiSwitch 500", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 4, "40G_QSFP+": 2 }, totalPorts: 30,
    maxSpeedGbps: 40,
    rackUnits: 1, maxPowerW: 65,
    tags: ["distribution", "40G", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 548D-FPOE", series: "FortiSwitch 500", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4, "40G_QSFP+": 2 }, totalPorts: 54,
    maxSpeedGbps: 40,
    rackUnits: 1, maxPowerW: 780,
    poeSupport: "PoE+",
    tags: ["distribution", "40G", "PoE", "FortiLink"],
  },
  // FortiSwitch 1000/3000 Series — Core
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 1024E", series: "FortiSwitch 1000", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_SFP+": 24, "40G_QSFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 40,
    rackUnits: 1, maxPowerW: 150,
    tags: ["10G", "core", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 1048E", series: "FortiSwitch 1000", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_SFP+": 48, "40G_QSFP+": 6 }, totalPorts: 54,
    maxSpeedGbps: 40,
    rackUnits: 1, maxPowerW: 200,
    tags: ["10G", "core", "FortiLink"],
  },
  {
    vendor: "Fortinet", vendorType: "oem", vendorWebsite: "https://www.fortinet.com",
    model: "FortiSwitch 3032E", series: "FortiSwitch 3000", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "100G_QSFP28": 32 }, totalPorts: 32,
    maxSpeedGbps: 100,
    rackUnits: 1, maxPowerW: 350,
    tags: ["100G", "spine", "FortiLink"],
  },
];

// ═══════════════════════════════════════════════════════
// MIKROTIK — CRS / CCR Series (with SFP/QSFP ports)
// ═══════════════════════════════════════════════════════
const MIKROTIK: SwitchSeed[] = [
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS504-4XQ-IN", series: "CRS504", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "100G_QSFP28": 4 }, totalPorts: 4,
    maxSpeedGbps: 100, switchingCapacityTbps: 0.8,
    asicVendor: "Marvell", asicModel: "Prestera 98DX8525",
    rackUnits: 1, maxPowerW: 75,
    tags: ["100G", "aggregation", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS518-16XS-2XQ", series: "CRS518", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "25G_SFP28": 16, "100G_QSFP28": 2 }, totalPorts: 18,
    maxSpeedGbps: 100, switchingCapacityTbps: 1.2,
    asicVendor: "Marvell", asicModel: "Prestera 98DX8525",
    rackUnits: 1, maxPowerW: 85,
    tags: ["25G", "aggregation", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS354-48G-4S+2Q+", series: "CRS354", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4, "40G_QSFP+": 2 }, totalPorts: 54,
    maxSpeedGbps: 40,
    rackUnits: 1, maxPowerW: 55,
    tags: ["campus", "aggregation", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS326-24G-2S+", series: "CRS326", category: "Campus", layer: "L2",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 2 }, totalPorts: 26,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 30,
    tags: ["campus", "access", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS317-1G-16S+", series: "CRS317", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_SFP+": 16, "1G_RJ45": 1 }, totalPorts: 17,
    maxSpeedGbps: 10, switchingCapacityTbps: 0.32,
    asicVendor: "Marvell", asicModel: "Prestera 98DX8216",
    rackUnits: 1, maxPowerW: 45,
    tags: ["10G", "aggregation", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS312-4C+8XG", series: "CRS312", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_RJ45": 8, "10G_SFP+_Combo": 4 }, totalPorts: 12,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 75,
    tags: ["10G", "combo", "RouterOS"],
  },
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CRS305-1G-4S+", series: "CRS305", category: "Edge", layer: "L2",
    portsConfig: { "10G_SFP+": 4, "1G_RJ45": 1 }, totalPorts: 5,
    maxSpeedGbps: 10,
    rackUnits: 0, maxPowerW: 15,
    tags: ["10G", "desktop", "RouterOS"],
  },
  // CCR Routers with SFP
  {
    vendor: "MikroTik", vendorType: "oem", vendorWebsite: "https://mikrotik.com",
    model: "CCR2216-1G-12XS-2XQ", series: "CCR2216", category: "Core", layer: "L3",
    portsConfig: { "25G_SFP28": 12, "100G_QSFP28": 2, "1G_RJ45": 1 }, totalPorts: 15,
    maxSpeedGbps: 100,
    rackUnits: 1, maxPowerW: 130,
    bgpSupport: true, mplsSupport: true,
    tags: ["router", "100G", "BGP", "MPLS", "RouterOS"],
  },
];

// ═══════════════════════════════════════════════════════
// UBIQUITI — UniFi / EdgeSwitch with SFP
// ═══════════════════════════════════════════════════════
const UBIQUITI: SwitchSeed[] = [
  {
    vendor: "Ubiquiti", vendorType: "oem", vendorWebsite: "https://www.ui.com",
    model: "USW-Pro-Max-48-PoE", series: "UniFi Pro Max", category: "Campus", layer: "L2/L3",
    portsConfig: { "2.5G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 720,
    poeSupport: "PoE++",
    tags: ["campus", "PoE", "UniFi"],
  },
  {
    vendor: "Ubiquiti", vendorType: "oem", vendorWebsite: "https://www.ui.com",
    model: "USW-Enterprise-48-PoE", series: "UniFi Enterprise", category: "Campus", layer: "L2/L3",
    portsConfig: { "2.5G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 720,
    poeSupport: "PoE++",
    tags: ["enterprise", "PoE", "UniFi"],
  },
  {
    vendor: "Ubiquiti", vendorType: "oem", vendorWebsite: "https://www.ui.com",
    model: "USW-Aggregation", series: "UniFi Aggregation", category: "DataCenter", layer: "L2",
    portsConfig: { "10G_SFP+": 8 }, totalPorts: 8,
    maxSpeedGbps: 10,
    rackUnits: 1, maxPowerW: 40,
    tags: ["aggregation", "10G", "UniFi"],
  },
  {
    vendor: "Ubiquiti", vendorType: "oem", vendorWebsite: "https://www.ui.com",
    model: "USW-Pro-Aggregation", series: "UniFi Pro", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_SFP+": 28, "25G_SFP28": 4 }, totalPorts: 32,
    maxSpeedGbps: 25,
    rackUnits: 1, maxPowerW: 75,
    tags: ["aggregation", "25G", "UniFi"],
  },
];

// ═══════════════════════════════════════════════════════
// NETGEAR — M4300/M4350/M4500 Managed with SFP
// ═══════════════════════════════════════════════════════
const NETGEAR: SwitchSeed[] = [
  {
    vendor: "Netgear", vendorType: "oem", vendorWebsite: "https://www.netgear.com",
    model: "M4350-48G4XF", series: "M4350", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1,
    poeSupport: "PoE++", stackingSupport: true,
    tags: ["campus", "PoE", "ProAV"],
  },
  {
    vendor: "Netgear", vendorType: "oem", vendorWebsite: "https://www.netgear.com",
    model: "M4500-32C", series: "M4500", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "100G_QSFP28": 32 }, totalPorts: 32,
    maxSpeedGbps: 100, switchingCapacityTbps: 6.4,
    rackUnits: 1,
    tags: ["100G", "spine", "ProAV"],
  },
  {
    vendor: "Netgear", vendorType: "oem", vendorWebsite: "https://www.netgear.com",
    model: "M4300-96X", series: "M4300", category: "Campus", layer: "L2/L3",
    portsConfig: { "10G_RJ45": 48, "10G_SFP+": 48 }, totalPorts: 96,
    maxSpeedGbps: 10,
    rackUnits: 2,
    stackingSupport: true,
    tags: ["10G", "campus", "ProAV"],
  },
];

// ═══════════════════════════════════════════════════════
// ALLIED TELESIS — Campus/Industrial
// ═══════════════════════════════════════════════════════
const ALLIED_TELESIS: SwitchSeed[] = [
  {
    vendor: "Allied Telesis", vendorType: "oem", vendorWebsite: "https://www.alliedtelesis.com",
    model: "AT-x950-28XSQ", series: "x950", category: "Campus", layer: "L3",
    portsConfig: { "10G_SFP+": 24, "40G_QSFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 40, switchingCapacityTbps: 0.96,
    rackUnits: 1,
    stackingSupport: true, bgpSupport: true,
    tags: ["10G", "core", "stackable"],
  },
  {
    vendor: "Allied Telesis", vendorType: "oem", vendorWebsite: "https://www.alliedtelesis.com",
    model: "AT-x530-28GSX", series: "x530", category: "Campus", layer: "L3",
    portsConfig: { "1G_SFP": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 1,
    stackingSupport: true,
    tags: ["campus", "all-fiber", "stackable"],
  },
  {
    vendor: "Allied Telesis", vendorType: "oem", vendorWebsite: "https://www.alliedtelesis.com",
    model: "AT-x530L-52GPX", series: "x530L", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1,
    poeSupport: "PoE+", stackingSupport: true,
    tags: ["campus", "PoE", "stackable"],
  },
];

// ═══════════════════════════════════════════════════════
// HIRSCHMANN / BELDEN — Industrial Ethernet
// ═══════════════════════════════════════════════════════
const HIRSCHMANN: SwitchSeed[] = [
  {
    vendor: "Hirschmann", vendorType: "oem", vendorWebsite: "https://www.belden.com/brands/hirschmann",
    model: "MACH4002-48G-L3P", series: "MACH4002", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 2,
    poeSupport: "PoE+",
    tags: ["industrial", "managed", "ruggedized", "DIN-rail"],
  },
  {
    vendor: "Hirschmann", vendorType: "oem", vendorWebsite: "https://www.belden.com/brands/hirschmann",
    model: "RSP30-08033O6TT-SK", series: "RSP", category: "Industrial", layer: "L2",
    portsConfig: { "1G_RJ45": 8, "1G_SFP": 3 }, totalPorts: 11,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "managed", "DIN-rail", "compact"],
  },
  {
    vendor: "Hirschmann", vendorType: "oem", vendorWebsite: "https://www.belden.com/brands/hirschmann",
    model: "GREYHOUND-1040-BT", series: "GREYHOUND", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 8, "10G_SFP+": 4 }, totalPorts: 12,
    maxSpeedGbps: 10,
    rackUnits: 0,
    tags: ["industrial", "ruggedized", "backbone", "10G"],
  },
  {
    vendor: "Hirschmann", vendorType: "oem", vendorWebsite: "https://www.belden.com/brands/hirschmann",
    model: "DRAGON-MACH4500-48G6XG", series: "DRAGON", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 6 }, totalPorts: 54,
    maxSpeedGbps: 10,
    rackUnits: 2,
    tags: ["industrial", "modular", "backbone", "redundancy"],
  },
];

// ═══════════════════════════════════════════════════════
// MOXA — Industrial Ethernet
// ═══════════════════════════════════════════════════════
const MOXA: SwitchSeed[] = [
  {
    vendor: "Moxa", vendorType: "oem", vendorWebsite: "https://www.moxa.com",
    model: "IKS-G6824A", series: "IKS-G6824A", category: "Industrial", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 24, "1G_SFP": 4 }, totalPorts: 28,
    maxSpeedGbps: 1,
    rackUnits: 2,
    tags: ["industrial", "managed", "rack-mount", "redundancy"],
  },
  {
    vendor: "Moxa", vendorType: "oem", vendorWebsite: "https://www.moxa.com",
    model: "ICS-G7826A", series: "ICS-G7826A", category: "Industrial", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 24, "1G_SFP": 2 }, totalPorts: 26,
    maxSpeedGbps: 1,
    rackUnits: 2,
    tags: ["industrial", "modular", "rack-mount"],
  },
  {
    vendor: "Moxa", vendorType: "oem", vendorWebsite: "https://www.moxa.com",
    model: "EDS-G4014", series: "EDS-G4014", category: "Industrial", layer: "L2",
    portsConfig: { "1G_RJ45": 8, "1G_SFP": 6 }, totalPorts: 14,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "managed", "DIN-rail", "compact"],
  },
  {
    vendor: "Moxa", vendorType: "oem", vendorWebsite: "https://www.moxa.com",
    model: "EDS-518E", series: "EDS-500E", category: "Industrial", layer: "L2",
    portsConfig: { "100M_RJ45": 14, "1G_SFP": 4 }, totalPorts: 18,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "managed", "DIN-rail"],
  },
];

// ═══════════════════════════════════════════════════════
// SIEMENS — SCALANCE Industrial Switches
// ═══════════════════════════════════════════════════════
const SIEMENS: SwitchSeed[] = [
  {
    vendor: "Siemens", vendorType: "oem", vendorWebsite: "https://www.siemens.com",
    model: "SCALANCE XR528-6M", series: "SCALANCE XR500", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 2,
    tags: ["industrial", "backbone", "rack-mount", "PROFINET"],
  },
  {
    vendor: "Siemens", vendorType: "oem", vendorWebsite: "https://www.siemens.com",
    model: "SCALANCE XM416-4C", series: "SCALANCE XM400", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 12, "10G_SFP+": 4 }, totalPorts: 16,
    maxSpeedGbps: 10,
    rackUnits: 0,
    tags: ["industrial", "managed", "PROFINET", "10G"],
  },
  {
    vendor: "Siemens", vendorType: "oem", vendorWebsite: "https://www.siemens.com",
    model: "SCALANCE XC216-4C", series: "SCALANCE XC200", category: "Industrial", layer: "L2",
    portsConfig: { "100M_RJ45": 16, "1G_SFP_Combo": 4 }, totalPorts: 20,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "managed", "compact", "PROFINET"],
  },
  {
    vendor: "Siemens", vendorType: "oem", vendorWebsite: "https://www.siemens.com",
    model: "SCALANCE XR324-12M", series: "SCALANCE XR300", category: "Industrial", layer: "L2",
    portsConfig: { "1G_RJ45": 24, "1G_SFP": 4 }, totalPorts: 28,
    maxSpeedGbps: 1,
    rackUnits: 1,
    tags: ["industrial", "rack-mount", "PROFINET", "redundancy"],
  },
];

// ═══════════════════════════════════════════════════════
// PHOENIX CONTACT — Industrial Networking
// ═══════════════════════════════════════════════════════
const PHOENIX_CONTACT: SwitchSeed[] = [
  {
    vendor: "Phoenix Contact", vendorType: "oem", vendorWebsite: "https://www.phoenixcontact.com",
    model: "FL SWITCH 4808E-16FX-4GC", series: "FL SWITCH 4800", category: "Industrial", layer: "L2",
    portsConfig: { "100M_FX_SFP": 16, "1G_SFP_Combo": 4 }, totalPorts: 20,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "managed", "DIN-rail"],
  },
  {
    vendor: "Phoenix Contact", vendorType: "oem", vendorWebsite: "https://www.phoenixcontact.com",
    model: "FL SWITCH 7528-2S", series: "FL SWITCH 7500", category: "Industrial", layer: "L3",
    portsConfig: { "1G_RJ45": 24, "1G_SFP": 4 }, totalPorts: 28,
    maxSpeedGbps: 1,
    rackUnits: 1,
    tags: ["industrial", "managed", "rack-mount", "L3"],
  },
];

// ═══════════════════════════════════════════════════════
// F5 NETWORKS — BIG-IP with SFP ports
// ═══════════════════════════════════════════════════════
const F5: SwitchSeed[] = [
  {
    vendor: "F5 Networks", vendorType: "oem", vendorWebsite: "https://www.f5.com",
    model: "BIG-IP i5800", series: "BIG-IP i-Series", category: "DataCenter", layer: "L3",
    portsConfig: { "10G_SFP+": 8, "40G_QSFP+": 4, "1G_RJ45": 4 }, totalPorts: 16,
    maxSpeedGbps: 40,
    rackUnits: 1,
    tags: ["load-balancer", "ADC", "WAF"],
  },
  {
    vendor: "F5 Networks", vendorType: "oem", vendorWebsite: "https://www.f5.com",
    model: "BIG-IP i10800", series: "BIG-IP i-Series", category: "DataCenter", layer: "L3",
    portsConfig: { "10G_SFP+": 16, "40G_QSFP+": 4, "1G_RJ45": 4 }, totalPorts: 24,
    maxSpeedGbps: 40,
    rackUnits: 2,
    tags: ["load-balancer", "ADC", "WAF", "high-perf"],
  },
  {
    vendor: "F5 Networks", vendorType: "oem", vendorWebsite: "https://www.f5.com",
    model: "BIG-IP i15800", series: "BIG-IP i-Series", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 16, "100G_QSFP28": 4, "10G_RJ45": 4 }, totalPorts: 24,
    maxSpeedGbps: 100,
    rackUnits: 2,
    tags: ["load-balancer", "ADC", "WAF", "100G"],
  },
];

// ═══════════════════════════════════════════════════════
// TP-LINK — JetStream Managed with SFP
// ═══════════════════════════════════════════════════════
const TPLINK: SwitchSeed[] = [
  {
    vendor: "TP-Link", vendorType: "oem", vendorWebsite: "https://www.tp-link.com",
    model: "TL-SX3016F", series: "JetStream", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_SFP+": 16 }, totalPorts: 16,
    maxSpeedGbps: 10,
    rackUnits: 1,
    tags: ["10G", "all-fiber", "managed"],
  },
  {
    vendor: "TP-Link", vendorType: "oem", vendorWebsite: "https://www.tp-link.com",
    model: "TL-SG3452XP", series: "JetStream", category: "Campus", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1,
    poeSupport: "PoE+",
    tags: ["campus", "PoE", "managed"],
  },
];

// ═══════════════════════════════════════════════════════
// ZYXEL — Managed Switches with SFP
// ═══════════════════════════════════════════════════════
const ZYXEL: SwitchSeed[] = [
  {
    vendor: "Zyxel", vendorType: "oem", vendorWebsite: "https://www.zyxel.com",
    model: "XGS4600-52F", series: "XGS4600", category: "Campus", layer: "L3",
    portsConfig: { "1G_SFP": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10,
    rackUnits: 1,
    stackingSupport: true,
    tags: ["campus", "all-fiber", "L3", "stackable"],
  },
  {
    vendor: "Zyxel", vendorType: "oem", vendorWebsite: "https://www.zyxel.com",
    model: "XS3800-28", series: "XS3800", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "10G_RJ45": 24, "10G_SFP+": 4 }, totalPorts: 28,
    maxSpeedGbps: 10,
    rackUnits: 1,
    tags: ["10G", "aggregation", "stackable"],
  },
];

// ═══════════════════════════════════════════════════════
// PALO ALTO NETWORKS — Firewalls with SFP
// ═══════════════════════════════════════════════════════
const PALO_ALTO: SwitchSeed[] = [
  {
    vendor: "Palo Alto Networks", vendorType: "oem", vendorWebsite: "https://www.paloaltonetworks.com",
    model: "PA-5430", series: "PA-5400", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 24, "100G_QSFP28": 4 }, totalPorts: 28,
    maxSpeedGbps: 100,
    rackUnits: 2,
    tags: ["NGFW", "security", "100G"],
  },
  {
    vendor: "Palo Alto Networks", vendorType: "oem", vendorWebsite: "https://www.paloaltonetworks.com",
    model: "PA-3430", series: "PA-3400", category: "Edge", layer: "L3",
    portsConfig: { "10G_SFP+": 12, "1G_RJ45": 4 }, totalPorts: 16,
    maxSpeedGbps: 10,
    rackUnits: 1,
    tags: ["NGFW", "security", "edge"],
  },
  {
    vendor: "Palo Alto Networks", vendorType: "oem", vendorWebsite: "https://www.paloaltonetworks.com",
    model: "PA-7080", series: "PA-7000", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 48 }, totalPorts: 48,
    maxSpeedGbps: 100,
    rackUnits: 19,
    tags: ["NGFW", "chassis", "SP", "high-perf"],
  },
];

// ═══════════════════════════════════════════════════════
// CHECK POINT — Quantum Security Gateways with SFP
// ═══════════════════════════════════════════════════════
const CHECK_POINT: SwitchSeed[] = [
  {
    vendor: "Check Point", vendorType: "oem", vendorWebsite: "https://www.checkpoint.com",
    model: "Quantum 6800", series: "Quantum 6000", category: "DataCenter", layer: "L3",
    portsConfig: { "10G_SFP+": 8, "25G_SFP28": 4, "1G_RJ45": 8 }, totalPorts: 20,
    maxSpeedGbps: 25,
    rackUnits: 1,
    tags: ["NGFW", "security", "25G"],
  },
  {
    vendor: "Check Point", vendorType: "oem", vendorWebsite: "https://www.checkpoint.com",
    model: "Quantum 28000", series: "Quantum 28000", category: "DataCenter", layer: "L3",
    portsConfig: { "40G_QSFP+": 16, "10G_SFP+": 16 }, totalPorts: 32,
    maxSpeedGbps: 40,
    rackUnits: 2,
    tags: ["NGFW", "chassis", "high-perf", "SP"],
  },
];

// ═══════════════════════════════════════════════════════
// WESTERMO — Industrial Ethernet
// ═══════════════════════════════════════════════════════
const WESTERMO: SwitchSeed[] = [
  {
    vendor: "Westermo", vendorType: "oem", vendorWebsite: "https://www.westermo.com",
    model: "Redfox-5728-F16G-T12G-LV", series: "Redfox", category: "Industrial", layer: "L3",
    portsConfig: { "1G_SFP": 16, "1G_RJ45": 12 }, totalPorts: 28,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "rack-mount", "ruggedized"],
  },
  {
    vendor: "Westermo", vendorType: "oem", vendorWebsite: "https://www.westermo.com",
    model: "Lynx 5612-F4G-T8G", series: "Lynx", category: "Industrial", layer: "L2",
    portsConfig: { "1G_SFP": 4, "1G_RJ45": 8 }, totalPorts: 12,
    maxSpeedGbps: 1,
    rackUnits: 0,
    tags: ["industrial", "DIN-rail", "compact", "ruggedized"],
  },
];

// Combine all extended vendors
const ALL_EXTENDED_SWITCHES: SwitchSeed[] = [
  ...FORTINET,
  ...MIKROTIK,
  ...UBIQUITI,
  ...NETGEAR,
  ...ALLIED_TELESIS,
  ...HIRSCHMANN,
  ...MOXA,
  ...SIEMENS,
  ...PHOENIX_CONTACT,
  ...F5,
  ...TPLINK,
  ...ZYXEL,
  ...PALO_ALTO,
  ...CHECK_POINT,
  ...WESTERMO,
];

export async function seedExtendedSwitches(): Promise<void> {
  console.log("=== Extended Switch & Router Seed Data ===\n");
  console.log(`Seeding ${ALL_EXTENDED_SWITCHES.length} switches from ${new Set(ALL_EXTENDED_SWITCHES.map(s => s.vendor)).size} vendors...\n`);

  const vendorCache = new Map<string, string>();
  let created = 0;
  let updated = 0;

  for (const sw of ALL_EXTENDED_SWITCHES) {
    try {
      let vendorId = vendorCache.get(sw.vendor);
      if (!vendorId) {
        vendorId = await ensureVendor(sw.vendor, sw.vendorType, sw.vendorWebsite);
        vendorCache.set(sw.vendor, vendorId);
      }

      const existing = await pool.query(
        `SELECT id FROM switches WHERE model = $1 AND vendor_id = $2`,
        [sw.model, vendorId]
      );

      await findOrCreateSwitch({
        model: sw.model,
        vendorId,
        series: sw.series,
        category: sw.category,
        layer: sw.layer,
        portsConfig: sw.portsConfig,
        totalPorts: sw.totalPorts,
        uplinkSpeedGbps: sw.uplinkSpeedGbps,
        maxSpeedGbps: sw.maxSpeedGbps,
        switchingCapacityTbps: sw.switchingCapacityTbps,
        forwardingRateMpps: sw.forwardingRateMpps,
        asicVendor: sw.asicVendor,
        asicModel: sw.asicModel,
        rackUnits: sw.rackUnits,
        maxPowerW: sw.maxPowerW,
        poeSupport: sw.poeSupport,
        stackingSupport: sw.stackingSupport,
        vxlanSupport: sw.vxlanSupport,
        evpnSupport: sw.evpnSupport,
        bgpSupport: sw.bgpSupport,
        mplsSupport: sw.mplsSupport,
        openconfigSupport: sw.openconfigSupport,
        sonicCompatible: sw.sonicCompatible,
        macsecSupport: sw.macsecSupport,
        tags: sw.tags,
      });

      if (existing.rows.length > 0) {
        updated++;
      } else {
        created++;
      }
    } catch (err) {
      console.error(`  Error [${sw.vendor} ${sw.model}]: ${(err as Error).message.slice(0, 100)}`);
    }
  }

  console.log(`\n=== Extended Seed Complete: ${created} created, ${updated} updated ===`);
}

if (require.main === module) {
  seedExtendedSwitches()
    .then(() => pool.end())
    .catch((err) => { console.error("Fatal:", err); pool.end(); process.exit(1); });
}
