import { SftpFileEntry } from "../../../domain/models";
import { formatDate } from "./utils";

// Mock local file data for development (when backend is not available)
export function buildMockLocalFiles(path: string): SftpFileEntry[] {
  // Normalize path for matching (handle both Windows and Unix paths)
  const normPath = path.replace(/\\/g, "/").replace(/\/$/, "") || "/";

  const mockData: Record<string, SftpFileEntry[]> = {
    // Unix-style paths
    "/": [
      {
        name: "Users",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "Applications",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "System",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 259200000,
        lastModifiedFormatted: formatDate(Date.now() - 259200000),
      },
    ],
    "/Users": [
      {
        name: "damao",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "Shared",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
    ],
    "/Users/damao": [
      {
        name: "Desktop",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 1800000,
        lastModifiedFormatted: formatDate(Date.now() - 1800000),
      },
      {
        name: "Documents",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "Downloads",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "Pictures",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "Projects",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 900000,
        lastModifiedFormatted: formatDate(Date.now() - 900000),
      },
    ],
    // Windows-style paths (normalized to forward slashes for matching)
    "C:": [
      {
        name: "Users",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "Program Files",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "Windows",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 259200000,
        lastModifiedFormatted: formatDate(Date.now() - 259200000),
      },
    ],
    "C:/Users": [
      {
        name: "damao",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "Public",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "Default",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
    ],
    "C:/Users/damao": [
      {
        name: "Desktop",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 1800000,
        lastModifiedFormatted: formatDate(Date.now() - 1800000),
      },
      {
        name: "Documents",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "Downloads",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "Pictures",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "Projects",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 900000,
        lastModifiedFormatted: formatDate(Date.now() - 900000),
      },
    ],
    "C:/Users/damao/Desktop": [
      {
        name: "Netcatty",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 300000,
        lastModifiedFormatted: formatDate(Date.now() - 300000),
      },
      {
        name: "notes.txt",
        type: "file",
        size: 2048,
        sizeFormatted: "2 KB",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "screenshot.png",
        type: "file",
        size: 1048576,
        sizeFormatted: "1 MB",
        lastModified: Date.now() - 43200000,
        lastModifiedFormatted: formatDate(Date.now() - 43200000),
      },
    ],
    "C:/Users/damao/Desktop/Netcatty": [
      {
        name: "src",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 600000,
        lastModifiedFormatted: formatDate(Date.now() - 600000),
      },
      {
        name: "package.json",
        type: "file",
        size: 1536,
        sizeFormatted: "1.5 KB",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "README.md",
        type: "file",
        size: 4096,
        sizeFormatted: "4 KB",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "tsconfig.json",
        type: "file",
        size: 512,
        sizeFormatted: "512 Bytes",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
    ],
    "C:/Users/damao/Documents": [
      {
        name: "Work",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "Personal",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "report.pdf",
        type: "file",
        size: 2097152,
        sizeFormatted: "2 MB",
        lastModified: Date.now() - 259200000,
        lastModifiedFormatted: formatDate(Date.now() - 259200000),
      },
    ],
    "C:/Users/damao/Downloads": [
      {
        name: "installer.exe",
        type: "file",
        size: 52428800,
        sizeFormatted: "50 MB",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "archive.zip",
        type: "file",
        size: 10485760,
        sizeFormatted: "10 MB",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "document.pdf",
        type: "file",
        size: 524288,
        sizeFormatted: "512 KB",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
    ],
    "C:/Users/damao/Projects": [
      {
        name: "webapp",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 1800000,
        lastModifiedFormatted: formatDate(Date.now() - 1800000),
      },
      {
        name: "scripts",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 43200000,
        lastModifiedFormatted: formatDate(Date.now() - 43200000),
      },
    ],
    "/Users/damao/Desktop": [
      {
        name: "Netcatty",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 300000,
        lastModifiedFormatted: formatDate(Date.now() - 300000),
      },
      {
        name: "notes.txt",
        type: "file",
        size: 2048,
        sizeFormatted: "2 KB",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "screenshot.png",
        type: "file",
        size: 1048576,
        sizeFormatted: "1 MB",
        lastModified: Date.now() - 43200000,
        lastModifiedFormatted: formatDate(Date.now() - 43200000),
      },
    ],
    "/Users/damao/Desktop/Netcatty": [
      {
        name: "src",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 600000,
        lastModifiedFormatted: formatDate(Date.now() - 600000),
      },
      {
        name: "package.json",
        type: "file",
        size: 1536,
        sizeFormatted: "1.5 KB",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "README.md",
        type: "file",
        size: 4096,
        sizeFormatted: "4 KB",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "tsconfig.json",
        type: "file",
        size: 512,
        sizeFormatted: "512 Bytes",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
    ],
    "/Users/damao/Documents": [
      {
        name: "Work",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
      {
        name: "Personal",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 172800000,
        lastModifiedFormatted: formatDate(Date.now() - 172800000),
      },
      {
        name: "report.pdf",
        type: "file",
        size: 2097152,
        sizeFormatted: "2 MB",
        lastModified: Date.now() - 259200000,
        lastModifiedFormatted: formatDate(Date.now() - 259200000),
      },
    ],
    "/Users/damao/Downloads": [
      {
        name: "installer.exe",
        type: "file",
        size: 52428800,
        sizeFormatted: "50 MB",
        lastModified: Date.now() - 3600000,
        lastModifiedFormatted: formatDate(Date.now() - 3600000),
      },
      {
        name: "archive.zip",
        type: "file",
        size: 10485760,
        sizeFormatted: "10 MB",
        lastModified: Date.now() - 7200000,
        lastModifiedFormatted: formatDate(Date.now() - 7200000),
      },
      {
        name: "document.pdf",
        type: "file",
        size: 524288,
        sizeFormatted: "512 KB",
        lastModified: Date.now() - 86400000,
        lastModifiedFormatted: formatDate(Date.now() - 86400000),
      },
    ],
    "/Users/damao/Projects": [
      {
        name: "webapp",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 1800000,
        lastModifiedFormatted: formatDate(Date.now() - 1800000),
      },
      {
        name: "scripts",
        type: "directory",
        size: 0,
        sizeFormatted: "--",
        lastModified: Date.now() - 43200000,
        lastModifiedFormatted: formatDate(Date.now() - 43200000),
      },
    ],
  };
  return mockData[normPath] || [];
}
