import type { NoteDetail, NoteSummary, WorkspaceSummary } from "@/lib/types";

export const mockWorkspaces: WorkspaceSummary[] = [
  {
    id: "workspace-product",
    name: "Product Strategy",
    description: "PRDs, roadmap cuts, launch tradeoffs, and operating decisions.",
    noteCount: 18,
    visibility: "shared",
    updatedAt: "2026-03-10T14:35:00.000Z",
    tags: ["strategy", "launch", "roadmap"],
  },
  {
    id: "workspace-research",
    name: "Research Ops",
    description: "Source notes, citations, summaries, and extracted action items.",
    noteCount: 42,
    visibility: "private",
    updatedAt: "2026-03-10T13:10:00.000Z",
    tags: ["research", "sources", "agent-ready"],
  },
  {
    id: "workspace-platform",
    name: "Platform Coordination",
    description: "Shared-platform integration notes and handoffs for other agents.",
    noteCount: 11,
    visibility: "shared",
    updatedAt: "2026-03-10T11:05:00.000Z",
    tags: ["platform", "handoff", "integration"],
  },
];

export const mockNotes: NoteSummary[] = [
  {
    id: "note-prd-cutline",
    workspaceId: "workspace-product",
    title: "MVP cut line for agentic notes launch",
    excerpt: "Define which note, task, search, and approval flows must exist before wider rollout.",
    status: "active",
    tags: ["mvp", "launch", "scope"],
    updatedAt: "2026-03-10T14:30:00.000Z",
    updatedBy: "Product Lead",
  },
  {
    id: "note-web-shell",
    workspaceId: "workspace-product",
    title: "Web shell execution plan",
    excerpt: "Scaffold authenticated layout, notes routes, search, settings, and operator affordances.",
    status: "draft",
    tags: ["web", "execution", "ui"],
    updatedAt: "2026-03-10T14:10:00.000Z",
    updatedBy: "Web Agent",
  },
  {
    id: "note-platform-deps",
    workspaceId: "workspace-platform",
    title: "Platform integration dependencies for v1",
    excerpt: "Identify auth, telemetry, diagnostics, blob, and extraction dependencies that must be wired from day one.",
    status: "active",
    tags: ["platform", "telemetry", "auth"],
    updatedAt: "2026-03-10T13:00:00.000Z",
    updatedBy: "Platform Agent",
  },
  {
    id: "note-research-sources",
    workspaceId: "workspace-research",
    title: "Source summary ingestion workflow",
    excerpt: "Map external research capture into note creation, citation linking, and downstream task extraction.",
    status: "active",
    tags: ["research", "sources", "workflow"],
    updatedAt: "2026-03-10T12:15:00.000Z",
    updatedBy: "Research Agent",
  },
];

export const mockNoteDetails: Record<string, NoteDetail> = {
  "note-prd-cutline": {
    ...mockNotes[0],
    body: "# MVP Cut Line\n\nThe initial release must feel trustworthy for both humans and agents.\n\n## Must ship\n- Web authoring shell\n- Notes and workspace routes\n- Search and retrieval entry points\n- Agent review and approval placeholders\n\n## Defer if needed\n- Rich artifact upload orchestration\n- Advanced semantic ranking\n- Deep operator analytics",
    metadata: {
      owner: "Product Lead",
      source: "manual",
      reviewState: "approved",
      taskCount: 3,
      artifactCount: 2,
    },
    linkedNotes: [
      { id: "note-web-shell", title: "Web shell execution plan", relationship: "implements" },
      { id: "note-platform-deps", title: "Platform integration dependencies for v1", relationship: "depends_on" },
    ],
    tasks: [
      { id: "task-w0", title: "Stand up web shell", status: "in_progress", source: "manual" },
      { id: "task-w1", title: "Define backend integration boundary", status: "todo", source: "manual" },
      { id: "task-w2", title: "Review approval UX cut line", status: "todo", source: "agent" },
    ],
    artifacts: [
      { id: "artifact-prd", name: "PRD v2.0", type: "document", status: "ready" },
      { id: "artifact-roadmap", name: "Roadmap execution sheet", type: "document", status: "ready" },
    ],
  },
  "note-web-shell": {
    ...mockNotes[1],
    body: "# Web Shell Execution Plan\n\nUse existing ByteLyst web patterns.\n\n- App Router shell\n- Shared clients and tokens\n- Workspace-first navigation\n- Mock data until backend contracts stabilize",
    metadata: {
      owner: "Web Agent",
      source: "agent",
      reviewState: "proposed",
      taskCount: 2,
      artifactCount: 1,
    },
    linkedNotes: [
      { id: "note-prd-cutline", title: "MVP cut line for agentic notes launch", relationship: "supports" },
    ],
    tasks: [
      { id: "task-shell-1", title: "Create route skeleton", status: "done", source: "agent" },
      { id: "task-shell-2", title: "Wire providers", status: "in_progress", source: "agent" },
    ],
    artifacts: [
      { id: "artifact-shell", name: "UI scaffold", type: "ui", status: "processing" },
    ],
  },
};

export function getWorkspaceById(id: string) {
  return mockWorkspaces.find((workspace) => workspace.id === id) ?? null;
}

export function getNoteById(id: string) {
  return mockNoteDetails[id] ?? null;
}

export function getNotesForWorkspace(workspaceId: string) {
  return mockNotes.filter((note) => note.workspaceId === workspaceId);
}
