import { MongoClient } from "mongodb";

const uri = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017/cratis";

// Sample electronic products with full specifications and multiple images
const electronicProducts = [
  {
    title: "Gaming Laptop - ASUS ROG Strix G15",
    sku: "ELEC-ASUS-ROG-G15-001",
    itc1: "LAPTOP",
    itn: "ASUS-ROG-G15",
    bcode1: "ASUSROGG15001",
    shortDescription: "High-performance gaming laptop with AMD Ryzen 9 processor and NVIDIA RTX 4070",
    description: "Experience next-level gaming with the ASUS ROG Strix G15. Powered by AMD Ryzen 9 7940HS processor and NVIDIA GeForce RTX 4070 graphics card.",
    fullDescription: `The ASUS ROG Strix G15 is a powerhouse gaming laptop designed for serious gamers. It features a 15.6-inch Full HD 165Hz display that delivers smooth, tear-free gaming experiences. The laptop is powered by the latest AMD Ryzen 9 7940HS processor with 8 cores and 16 threads, ensuring exceptional performance in both gaming and productivity tasks.

The NVIDIA GeForce RTX 4070 graphics card with 8GB GDDR6 VRAM provides stunning visuals and supports real-time ray tracing and AI-powered DLSS technology. With 16GB DDR5 RAM and a 1TB NVMe SSD, you'll enjoy fast load times and seamless multitasking.

The laptop features a premium design with RGB backlit keyboard, advanced cooling system, and comprehensive connectivity options including USB-C, USB-A, HDMI, and Ethernet ports.`,
    productDetails: JSON.stringify({
      brand: "ASUS",
      model: "ROG Strix G15",
      processor: "AMD Ryzen 9 7940HS",
      processorCores: 8,
      processorThreads: 16,
      graphicsCard: "NVIDIA GeForce RTX 4070",
      graphicsMemory: "8GB GDDR6",
      ram: "16GB DDR5",
      storage: "1TB NVMe SSD",
      display: "15.6-inch Full HD",
      refreshRate: "165Hz",
      operatingSystem: "Windows 11 Home",
      battery: "90Wh",
      weight: "2.3kg",
      dimensions: "35.4 x 25.9 x 2.26 cm",
      ports: "USB-C, USB-A 3.2, HDMI 2.1, Ethernet, Audio Jack",
      wireless: "Wi-Fi 6E, Bluetooth 5.3",
      color: "Black",
      warranty: "2 Years"
    }),
    price: 1299.99,
    cost: 950.00,
    newCost: 920.00,
    lastSell: 1299.99,
    qty: 15,
    stock: 15,
    scat: "Laptops",
    cat: "Computers",
    itc: "Electronics",
    category: "Gaming Laptops",
    supplier: "ASUS Distribution",
    mfg: "ASUS",
    vat: 15,
    unit: "PCS",
    rack: "A-101",
    images: [
      "https://images.unsplash.com/photo-1603302576837-37561b2e2302?w=800",
      "https://images.unsplash.com/photo-1496181133206-80ce9b88a853?w=800",
      "https://images.unsplash.com/photo-1525547719571-a2d4ac8945e2?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1603302576837-37561b2e2302?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Wireless Gaming Mouse - Logitech G Pro X Superlight",
    sku: "ELEC-LOGI-GPRO-X-002",
    itc1: "MOUSE",
    itn: "LOGITECH-GPRO-X",
    bcode1: "LOGIGPROX002",
    shortDescription: "Ultra-lightweight wireless gaming mouse with HERO 25K sensor",
    description: "Professional-grade wireless gaming mouse weighing less than 63g. Features Logitech's most advanced HERO 25K sensor for precision gaming.",
    fullDescription: `The Logitech G Pro X Superlight is the ultimate wireless gaming mouse for competitive gamers. Weighing in at less than 63 grams, it's one of the lightest gaming mice available, reducing fatigue during long gaming sessions.

Equipped with the HERO 25K sensor, this mouse delivers exceptional tracking accuracy with up to 25,600 DPI sensitivity. The sensor provides zero smoothing, filtering, or acceleration for true 1:1 tracking.

The mouse features LIGHTSYNC RGB lighting, five programmable buttons, and a battery life of up to 70 hours. The Powerplay compatibility allows for wireless charging, so you'll never run out of battery during crucial moments.

Built with professional esports players, the G Pro X Superlight offers the perfect balance of performance, comfort, and durability.`,
    productDetails: JSON.stringify({
      brand: "Logitech",
      model: "G Pro X Superlight",
      sensor: "HERO 25K",
      dpi: "100-25,600",
      connectivity: "Wireless (LIGHTSPEED)",
      batteryLife: "70 hours",
      weight: "63g",
      buttons: 5,
      rgb: "LIGHTSYNC RGB",
      compatibility: "Windows, macOS, Linux",
      warranty: "2 Years",
      color: "Black/White",
      dimensions: "12.5 x 6.3 x 3.9 cm"
    }),
    price: 149.99,
    cost: 85.00,
    newCost: 80.00,
    lastSell: 149.99,
    qty: 50,
    stock: 50,
    scat: "Gaming Accessories",
    cat: "Computer Accessories",
    itc: "Electronics",
    category: "Mice",
    supplier: "Logitech Official",
    mfg: "Logitech",
    vat: 15,
    unit: "PCS",
    rack: "B-205",
    images: [
      "https://images.unsplash.com/photo-1527814050087-3793815479db?w=800",
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1527814050087-3793815479db?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Mechanical Keyboard - Corsair K70 RGB TKL",
    sku: "ELEC-CORS-K70-TKL-003",
    itc1: "KEYBOARD",
    itn: "CORS-K70-TKL",
    bcode1: "CORSK70TKL003",
    shortDescription: "Tenkeyless mechanical gaming keyboard with Cherry MX switches and RGB backlighting",
    description: "Compact tenkeyless design with Cherry MX switches. Features per-key RGB backlighting and aluminum frame construction.",
    fullDescription: `The Corsair K70 RGB TKL is a premium tenkeyless mechanical keyboard designed for gamers who want a compact layout without sacrificing performance. The keyboard features Cherry MX Speed Silver switches that provide fast, responsive actuation with a linear feel.

Each key features individually addressable RGB backlighting, allowing you to create stunning lighting effects and personalize your setup. The keyboard is built with an aircraft-grade aluminum frame for durability and stability.

The K70 RGB TKL includes dedicated media controls, a detachable USB-C cable, and on-the-fly macro recording. With its compact design, you'll have more room for mouse movement, perfect for competitive gaming.

Compatible with Corsair's iCUE software, you can customize lighting effects, create macros, and adjust performance settings. The keyboard also features a removable wrist rest for added comfort during long gaming sessions.`,
    productDetails: JSON.stringify({
      brand: "Corsair",
      model: "K70 RGB TKL",
      switchType: "Cherry MX Speed Silver",
      layout: "Tenkeyless (87 keys)",
      connectivity: "USB-C",
      rgb: "Per-key RGB",
      frame: "Aluminum",
      mediaControls: "Yes",
      macroSupport: "Yes",
      software: "Corsair iCUE",
      cable: "Detachable USB-C",
      warranty: "2 Years",
      color: "Black",
      dimensions: "36.2 x 15.3 x 3.5 cm",
      weight: "0.8kg"
    }),
    price: 179.99,
    cost: 110.00,
    newCost: 105.00,
    lastSell: 179.99,
    qty: 30,
    stock: 30,
    scat: "Gaming Accessories",
    cat: "Computer Accessories",
    itc: "Electronics",
    category: "Keyboards",
    supplier: "Corsair Distribution",
    mfg: "Corsair",
    vat: 15,
    unit: "PCS",
    rack: "B-206",
    images: [
      "https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=800",
      "https://images.unsplash.com/photo-1541140532154-b024d705b90a?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Gaming Monitor - Samsung Odyssey G9 49-inch",
    sku: "ELEC-SAMS-ODYSSEY-G9-004",
    itc1: "MONITOR",
    itn: "SAMS-ODYSSEY-G9",
    bcode1: "SAMSODYSSEYG9004",
    shortDescription: "Ultra-wide curved gaming monitor with 240Hz refresh rate and QLED display",
    description: "Massive 49-inch ultra-wide curved monitor with 240Hz refresh rate, 1ms response time, and QLED technology for stunning visuals.",
    fullDescription: `The Samsung Odyssey G9 is a revolutionary ultra-wide gaming monitor that redefines immersive gaming experiences. With its massive 49-inch curved screen and 32:9 aspect ratio, you'll feel fully immersed in your games.

The monitor features a stunning QLED display with 5120x1440 resolution, delivering crisp, vibrant visuals. With a 240Hz refresh rate and 1ms response time, you'll enjoy buttery-smooth gameplay with no motion blur.

The 1000R curvature matches the curvature of the human eye, reducing eye strain and providing a more natural viewing experience. The monitor supports HDR1000 for enhanced contrast and brightness in supported games and content.

Features include Picture-by-Picture mode, allowing you to display two different sources simultaneously. The monitor also includes USB hub, DisplayPort, and HDMI ports for comprehensive connectivity.

With its futuristic design, including RGB lighting on the back, the Odyssey G9 is not just a monitor—it's a statement piece for any gaming setup.`,
    productDetails: JSON.stringify({
      brand: "Samsung",
      model: "Odyssey G9",
      screenSize: "49 inches",
      resolution: "5120 x 1440 (DQHD)",
      aspectRatio: "32:9",
      panelType: "QLED",
      curvature: "1000R",
      refreshRate: "240Hz",
      responseTime: "1ms (GtG)",
      brightness: "1000 cd/m² (HDR1000)",
      contrast: "2500:1",
      colorGamut: "125% sRGB",
      ports: "DisplayPort 1.4, HDMI 2.1, USB Hub",
      hdr: "HDR1000",
      adaptiveSync: "G-Sync, FreeSync Premium Pro",
      warranty: "3 Years",
      dimensions: "114.7 x 52.6 x 40.6 cm",
      weight: "15.7kg"
    }),
    price: 1299.99,
    cost: 980.00,
    newCost: 950.00,
    lastSell: 1299.99,
    qty: 8,
    stock: 8,
    scat: "Monitors",
    cat: "Displays",
    itc: "Electronics",
    category: "Gaming Monitors",
    supplier: "Samsung Official",
    mfg: "Samsung",
    vat: 15,
    unit: "PCS",
    rack: "C-301",
    images: [
      "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf?w=800",
      "https://images.unsplash.com/photo-1593640408182-31c70c8268f5?w=800",
      "https://images.unsplash.com/photo-1586219101073-9bb8f7c3195a?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Wireless Headset - SteelSeries Arctis 7P+",
    sku: "ELEC-STEEL-ARCTIS-7P-005",
    itc1: "HEADSET",
    itn: "STEEL-ARCTIS-7P",
    bcode1: "STEELARCTIS7P005",
    shortDescription: "Wireless gaming headset with 30-hour battery and 3D audio support",
    description: "Premium wireless gaming headset with Discord-certified microphone, 30-hour battery life, and compatibility with PlayStation, PC, and Switch.",
    fullDescription: `The SteelSeries Arctis 7P+ is a premium wireless gaming headset designed for console and PC gamers. It features the same award-winning audio drivers as the Arctis 7, delivering exceptional sound quality with clear highs and powerful bass.

The headset boasts an impressive 30-hour battery life, so you can game all day without worrying about charging. The USB-C charging port allows for fast charging, getting you back in the game quickly.

The Discord-certified ClearCast bidirectional microphone provides crystal-clear voice communication. The retractable design keeps the microphone out of the way when not in use.

The Arctis 7P+ is compatible with PlayStation 5, PlayStation 4, PC, Nintendo Switch, and mobile devices. The wireless dongle features a USB-A adapter, making it easy to connect to various devices.

With its comfortable ski goggle suspension headband and AirWeave ear cushions, the headset remains comfortable even during extended gaming sessions. The headset also features on-earcup controls for volume and mic mute.`,
    productDetails: JSON.stringify({
      brand: "SteelSeries",
      model: "Arctis 7P+",
      connectivity: "Wireless (2.4GHz)",
      batteryLife: "30 hours",
      charging: "USB-C",
      drivers: "40mm Neodymium",
      frequencyResponse: "20-20000 Hz",
      microphone: "Discord-certified ClearCast",
      microphoneType: "Bidirectional, Retractable",
      compatibility: "PlayStation 5/4, PC, Nintendo Switch, Mobile",
      weight: "350g",
      cable: "USB-C to USB-A adapter included",
      warranty: "1 Year",
      color: "White",
      dimensions: "19.5 x 19.5 x 9.5 cm"
    }),
    price: 169.99,
    cost: 100.00,
    newCost: 95.00,
    lastSell: 169.99,
    qty: 25,
    stock: 25,
    scat: "Audio",
    cat: "Gaming Accessories",
    itc: "Electronics",
    category: "Headsets",
    supplier: "SteelSeries Official",
    mfg: "SteelSeries",
    vat: 15,
    unit: "PCS",
    rack: "B-207",
    images: [
      "https://images.unsplash.com/photo-1484704849700-f032a568e944?w=800",
      "https://images.unsplash.com/photo-1599669454699-248893623440?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1484704849700-f032a568e944?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "SSD Storage - Samsung 990 PRO 2TB NVMe",
    sku: "ELEC-SAMS-990-PRO-2TB-006",
    itc1: "SSD",
    itn: "SAMS-990-PRO-2TB",
    bcode1: "SAMS990PRO2TB006",
    shortDescription: "High-performance NVMe SSD with 2TB capacity and 7450 MB/s read speeds",
    description: "Latest generation PCIe 4.0 NVMe SSD with exceptional read/write speeds. Perfect for gaming, content creation, and professional workloads.",
    fullDescription: `The Samsung 990 PRO is the latest generation of high-performance NVMe SSDs, delivering exceptional speeds and reliability. With read speeds of up to 7,450 MB/s and write speeds of up to 6,900 MB/s, this SSD significantly reduces load times and improves system responsiveness.

Built with Samsung's advanced V-NAND technology and optimized controller, the 990 PRO offers superior performance for gaming, content creation, and professional applications. The SSD features a nickel-coated controller and heat spreader label for effective thermal management.

The 990 PRO is PCIe 4.0 compatible and backward compatible with PCIe 3.0 systems. It supports the latest Windows 11 features and is optimized for DirectStorage technology, enabling faster game load times.

With a 2TB capacity, you'll have plenty of space for your operating system, games, applications, and files. The SSD comes with Samsung's Magician software for drive management, performance monitoring, and firmware updates.

The 990 PRO is backed by a 5-year limited warranty and offers excellent endurance ratings, making it a reliable choice for intensive workloads.`,
    productDetails: JSON.stringify({
      brand: "Samsung",
      model: "990 PRO",
      capacity: "2TB",
      interface: "PCIe 4.0 x4 NVMe",
      formFactor: "M.2 2280",
      readSpeed: "7,450 MB/s",
      writeSpeed: "6,900 MB/s",
      randomRead: "1,400,000 IOPS",
      randomWrite: "1,550,000 IOPS",
      nandType: "V-NAND 3-bit MLC",
      controller: "Samsung Pascal",
      endurance: "1,200 TBW",
      warranty: "5 Years",
      dimensions: "80 x 22 x 2.38 mm",
      weight: "8g",
      operatingTemperature: "0-70°C"
    }),
    price: 249.99,
    cost: 180.00,
    newCost: 175.00,
    lastSell: 249.99,
    qty: 40,
    stock: 40,
    scat: "Storage",
    cat: "Computer Components",
    itc: "Electronics",
    category: "SSDs",
    supplier: "Samsung Official",
    mfg: "Samsung",
    vat: 15,
    unit: "PCS",
    rack: "D-401",
    images: [
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
      "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Graphics Card - NVIDIA GeForce RTX 4080",
    sku: "ELEC-NVIDIA-RTX-4080-007",
    itc1: "GPU",
    itn: "NVIDIA-RTX-4080",
    bcode1: "NVIDIARTX4080007",
    shortDescription: "High-end graphics card with 16GB GDDR6X memory and ray tracing support",
    description: "Powerful graphics card featuring NVIDIA's latest Ada Lovelace architecture. Perfect for 4K gaming, ray tracing, and AI-powered features.",
    fullDescription: `The NVIDIA GeForce RTX 4080 is a high-end graphics card built on the revolutionary Ada Lovelace architecture. With 16GB of ultra-fast GDDR6X memory and 9,728 CUDA cores, this GPU delivers exceptional performance for 4K gaming, ray tracing, and content creation.

The RTX 4080 features fourth-generation RT cores for real-time ray tracing and third-generation Tensor cores for AI-powered DLSS 3 technology. DLSS 3 uses AI to generate additional frames, dramatically improving performance in supported games.

The card supports up to 4K resolution at high frame rates and is capable of handling the most demanding games and applications. It features DisplayPort 1.4a and HDMI 2.1 outputs for connectivity to multiple displays.

With advanced cooling solutions and efficient power management, the RTX 4080 delivers high performance while maintaining reasonable power consumption. The card requires a 750W power supply and features a 16-pin PCIe 5.0 power connector.

The RTX 4080 is perfect for gamers who want the ultimate gaming experience, content creators working with 4K video, and professionals using GPU-accelerated applications.`,
    productDetails: JSON.stringify({
      brand: "NVIDIA",
      model: "GeForce RTX 4080",
      architecture: "Ada Lovelace",
      cudaCores: 9728,
      memory: "16GB GDDR6X",
      memoryBus: "256-bit",
      memorySpeed: "22.4 Gbps",
      baseClock: "2210 MHz",
      boostClock: "2505 MHz",
      rtCores: "3rd Gen",
      tensorCores: "4th Gen",
      powerConsumption: "320W",
      powerConnector: "16-pin PCIe 5.0",
      recommendedPSU: "750W",
      outputs: "DisplayPort 1.4a x3, HDMI 2.1 x1",
      rayTracing: "Yes",
      dlss: "DLSS 3",
      warranty: "3 Years",
      dimensions: "30.5 x 13.7 x 6.1 cm",
      weight: "2.2kg"
    }),
    price: 1199.99,
    cost: 950.00,
    newCost: 920.00,
    lastSell: 1199.99,
    qty: 12,
    stock: 12,
    scat: "Graphics Cards",
    cat: "Computer Components",
    itc: "Electronics",
    category: "GPUs",
    supplier: "NVIDIA Partner",
    mfg: "NVIDIA",
    vat: 15,
    unit: "PCS",
    rack: "E-501",
    images: [
      "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
      "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "Webcam - Logitech Brio 4K",
    sku: "ELEC-LOGI-BRIO-4K-008",
    itc1: "WEBCAM",
    itn: "LOGITECH-BRIO-4K",
    bcode1: "LOGIBRIO4K008",
    shortDescription: "4K Ultra HD webcam with HDR and Windows Hello facial recognition",
    description: "Premium webcam with 4K Ultra HD video, HDR, and advanced features like auto light correction and background replacement.",
    fullDescription: `The Logitech Brio is a premium 4K Ultra HD webcam designed for professionals, streamers, and content creators. It delivers stunning video quality with 4K resolution at 30fps or 1080p at 60fps, ensuring you look your best in every video call or stream.

The webcam features HDR technology, which automatically adjusts brightness and contrast to provide optimal image quality in any lighting condition. The autofocus ensures you stay sharp even when moving, and the digital zoom allows you to frame yourself perfectly.

One of the standout features is Windows Hello facial recognition support, allowing you to securely log into your Windows device with just a look. The webcam also features a privacy shutter, so you can physically block the camera when not in use.

The Brio includes Logitech's RightLight 3 technology, which automatically adjusts exposure and color balance to provide natural-looking video even in challenging lighting conditions. The webcam also supports background replacement and blur effects through compatible software.

With its premium build quality, versatile mounting options, and comprehensive software support, the Logitech Brio is the perfect choice for anyone who wants the best video quality.`,
    productDetails: JSON.stringify({
      brand: "Logitech",
      model: "Brio 4K",
      resolution: "4K Ultra HD (3840x2160)",
      maxFrameRate: "30fps @ 4K, 60fps @ 1080p",
      fieldOfView: "65°, 78°, 90°",
      autofocus: "Yes",
      hdr: "Yes",
      windowsHello: "Yes",
      microphone: "Dual stereo microphones",
      privacyShutter: "Yes",
      mounting: "Tripod thread, Monitor clip",
      connectivity: "USB 3.0 Type-C",
      compatibility: "Windows, macOS, Chrome OS",
      warranty: "2 Years",
      dimensions: "10.4 x 2.8 x 2.8 cm",
      weight: "0.58kg"
    }),
    price: 199.99,
    cost: 120.00,
    newCost: 115.00,
    lastSell: 199.99,
    qty: 35,
    stock: 35,
    scat: "Webcams",
    cat: "Computer Accessories",
    itc: "Electronics",
    category: "Cameras",
    supplier: "Logitech Official",
    mfg: "Logitech",
    vat: 15,
    unit: "PCS",
    rack: "B-208",
    images: [
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
      "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "USB-C Hub - Anker 7-in-1 Multiport Adapter",
    sku: "ELEC-ANKER-7IN1-009",
    itc1: "HUB",
    itn: "ANKER-7IN1",
    bcode1: "ANKER7IN1009",
    shortDescription: "7-in-1 USB-C hub with HDMI, USB ports, SD card reader, and power delivery",
    description: "Versatile USB-C hub that expands your laptop's connectivity with multiple ports including HDMI, USB 3.0, SD card reader, and 100W power delivery.",
    fullDescription: `The Anker 7-in-1 USB-C Hub is a versatile connectivity solution that expands your laptop's capabilities. Whether you're working from home, giving presentations, or transferring files, this hub provides all the ports you need in a compact design.

The hub features an HDMI port that supports 4K @ 30Hz output, allowing you to connect to external monitors and displays. With two USB 3.0 ports, you can connect peripherals like mice, keyboards, and external storage devices at high speeds.

The SD and microSD card readers make it easy to transfer photos and videos from your camera or phone. The USB-C Power Delivery port supports up to 100W charging, so you can charge your laptop while using the hub.

The hub is plug-and-play, requiring no drivers or software installation. It's compatible with most USB-C devices including MacBook, iPad Pro, Surface Pro, and Chromebook. The compact design makes it perfect for travel, and the aluminum construction ensures durability.

With its comprehensive port selection and reliable performance, the Anker 7-in-1 USB-C Hub is an essential accessory for any modern laptop user.`,
    productDetails: JSON.stringify({
      brand: "Anker",
      model: "7-in-1 USB-C Hub",
      ports: "HDMI, 2x USB 3.0, USB-C PD, SD Card Reader, MicroSD Card Reader",
      hdmiOutput: "4K @ 30Hz",
      usbSpeed: "USB 3.0 (5 Gbps)",
      powerDelivery: "100W",
      cardReader: "SD, MicroSD",
      compatibility: "USB-C devices",
      material: "Aluminum",
      dimensions: "11.5 x 4.3 x 1.5 cm",
      weight: "0.1kg",
      warranty: "18 Months",
      color: "Space Gray"
    }),
    price: 49.99,
    cost: 28.00,
    newCost: 26.00,
    lastSell: 49.99,
    qty: 60,
    stock: 60,
    scat: "Computer Accessories",
    cat: "Adapters",
    itc: "Electronics",
    category: "USB Hubs",
    supplier: "Anker Official",
    mfg: "Anker",
    vat: 15,
    unit: "PCS",
    rack: "B-209",
    images: [
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
      "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
  {
    title: "External Hard Drive - Western Digital 4TB Elements",
    sku: "ELEC-WD-4TB-ELEM-010",
    itc1: "HDD",
    itn: "WD-4TB-ELEM",
    bcode1: "WD4TBELEM010",
    shortDescription: "Portable external hard drive with 4TB capacity and USB 3.0 connectivity",
    description: "Reliable portable storage solution with 4TB capacity. Perfect for backups, file storage, and media libraries. USB 3.0 for fast data transfer.",
    fullDescription: `The Western Digital Elements portable external hard drive offers reliable, high-capacity storage in a compact design. With 4TB of storage space, you can store thousands of photos, videos, documents, and files.

The drive features USB 3.0 connectivity for fast data transfer speeds, making it quick and easy to backup your important files. It's also backward compatible with USB 2.0 ports, ensuring compatibility with older devices.

The compact and lightweight design makes it perfect for travel and on-the-go storage. The drive is formatted for Windows out of the box, but can be easily reformatted for macOS or other operating systems.

Western Digital's reputation for reliability means you can trust your data with this drive. It's perfect for backing up important files, expanding your storage capacity, or creating a portable media library.

The drive requires no external power supply, drawing all the power it needs from the USB connection. It's ready to use right out of the box, with no software installation required.`,
    productDetails: JSON.stringify({
      brand: "Western Digital",
      model: "Elements 4TB",
      capacity: "4TB",
      interface: "USB 3.0",
      transferSpeed: "Up to 5 Gbps",
      compatibility: "Windows, macOS, Linux",
      powerSupply: "USB powered",
      dimensions: "11.1 x 8.2 x 2.0 cm",
      weight: "0.23kg",
      warranty: "2 Years",
      color: "Black",
      formFactor: "2.5-inch"
    }),
    price: 89.99,
    cost: 55.00,
    newCost: 52.00,
    lastSell: 89.99,
    qty: 45,
    stock: 45,
    scat: "Storage",
    cat: "External Drives",
    itc: "Electronics",
    category: "Hard Drives",
    supplier: "Western Digital Official",
    mfg: "Western Digital",
    vat: 15,
    unit: "PCS",
    rack: "D-402",
    images: [
      "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
      "https://images.unsplash.com/photo-1587825140708-dfaf72ae4b04?w=800",
    ],
    photoUrl: "https://images.unsplash.com/photo-1591488320449-11f2d4fcd8fd?w=800",
    active: true,
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString(),
  },
];

async function seedProducts() {
  const client = new MongoClient(uri);

  try {
    await client.connect();
    console.log("Connected to MongoDB");

    const db = client.db();
    const collection = db.collection("ecommers");

    // Check if products already exist
    const existingCount = await collection.countDocuments({});
    if (existingCount > 0) {
      console.log(`Found ${existingCount} existing products. Adding new products...`);
    }

    // Insert products
    const result = await collection.insertMany(electronicProducts);
    console.log(`Successfully inserted ${result.insertedCount} products`);

    // Display inserted products
    console.log("\nInserted products:");
    electronicProducts.forEach((product, index) => {
      console.log(`${index + 1}. ${product.title} - ${product.sku}`);
    });

    console.log("\n✅ Seeding completed successfully!");
  } catch (error) {
    console.error("Error seeding products:", error);
  } finally {
    await client.close();
    console.log("MongoDB connection closed");
  }
}

// Run the seed function
seedProducts();

