const T = window.ArbiterTokens;

const TASKS = [
  { id: 'T-001', title: 'Draft opposition to Motion for Summary Judgment', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', assignee: 'M. Kirkland', priority: 'high', status: 'In Progress', dueDate: '2026-04-21', category: 'Drafting', estimatedHours: 12, loggedHours: 8.5, description: 'Complete final draft incorporating expert testimony references and damage calculations.', blockedBy: null, linkedDeadlines: ['DL-004'], linkedDocs: [1], linkedEvidence: ['EV-0004','EV-0007'], subtasks: [{t:'Review expert report citations', done:true},{t:'Draft argument section III',done:true},{t:'Incorporate damage model',done:false},{t:'Final proofread & cite-check',done:false}], activity: [{user:'M. Kirkland',action:'Updated draft with Section II revisions',time:'1h ago'},{user:'L. Torres',action:'Added exhibit references',time:'3h ago'}] },
  { id: 'T-002', title: 'Prepare deposition outline — J. Harmon', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', assignee: 'L. Torres', priority: 'high', status: 'In Progress', dueDate: '2026-04-25', category: 'Deposition', estimatedHours: 8, loggedHours: 3, description: 'Develop deposition outline covering pricing communications and route allocations.', blockedBy: null, linkedDeadlines: ['DL-010'], linkedDocs: [5], linkedEvidence: [], subtasks: [{t:'Compile exhibit list',done:true},{t:'Draft topic areas',done:false},{t:'Review prior testimony',done:false}], activity: [{user:'L. Torres',action:'Started topic area draft',time:'2h ago'}] },
  { id: 'T-003', title: 'File expert witness designation', matter: 'Thornton Estate', matterId: 'M-2024-0284', assignee: 'R. Vasquez', priority: 'high', status: 'To Do', dueDate: '2026-04-23', category: 'Filing', estimatedHours: 3, loggedHours: 0, description: 'Prepare and file expert designation for Dr. Patel.', blockedBy: 'T-013', linkedDeadlines: ['DL-012'], linkedDocs: [7], linkedEvidence: [], subtasks: [{t:'Finalize CV',done:true},{t:'Draft designation letter',done:false}], activity: [{user:'R. Vasquez',action:'Confirmed Dr. Patel availability',time:'5h ago'}] },
  { id: 'T-004', title: 'Review patent prior art search results', matter: 'Blackwell IP', matterId: 'M-2024-0271', assignee: 'J. Park', priority: 'medium', status: 'In Progress', dueDate: '2026-04-28', category: 'Research', estimatedHours: 6, loggedHours: 2, description: 'Analyze 47 prior art references identified in database search.', blockedBy: null, linkedDeadlines: ['DL-014'], linkedDocs: [8], linkedEvidence: [], subtasks: [{t:'Categorize references',done:true},{t:'Draft invalidity chart',done:false},{t:'Flag strongest references',done:false}], activity: [{user:'J. Park',action:'Completed initial categorization',time:'4h ago'}] },
  { id: 'T-005', title: 'Prepare mediation brief', matter: 'Chen v. Atlas', matterId: 'M-2024-0265', assignee: 'A. Petrov', priority: 'medium', status: 'To Do', dueDate: '2026-05-03', category: 'Drafting', estimatedHours: 10, loggedHours: 0, description: 'Draft confidential mediation statement for upcoming session.', blockedBy: null, linkedDeadlines: ['DL-015'], linkedDocs: [9], linkedEvidence: [], subtasks: [{t:'Compile settlement history',done:false},{t:'Draft liability section',done:false},{t:'Calculate damages range',done:false}], activity: [] },
  { id: 'T-006', title: 'FCPA compliance document review — Batch 3', matter: 'Sterling Pharma', matterId: 'M-2024-0259', assignee: 'S. Chen', priority: 'high', status: 'In Progress', dueDate: '2026-04-22', category: 'Review', estimatedHours: 15, loggedHours: 11, description: 'Review and tag 2,400 documents in third production batch.', blockedBy: null, linkedDeadlines: ['DL-017'], linkedDocs: [10,11], linkedEvidence: [], subtasks: [{t:'First-pass review (2400 docs)',done:true},{t:'Privilege review',done:true},{t:'QC sampling',done:false}], activity: [{user:'S. Chen',action:'Completed privilege review pass',time:'45m ago'},{user:'S. Chen',action:'Flagged 12 docs for partner review',time:'2h ago'}] },
  { id: 'T-007', title: 'Draft appellate brief — Section II', matter: 'Harbor District', matterId: 'M-2024-0243', assignee: 'R. Vasquez', priority: 'medium', status: 'To Do', dueDate: '2026-05-15', category: 'Drafting', estimatedHours: 20, loggedHours: 0, description: 'Draft constitutional takings argument for appellate brief.', blockedBy: null, linkedDeadlines: [], linkedDocs: [12], linkedEvidence: [], subtasks: [], activity: [] },
  { id: 'T-008', title: 'Merger due diligence — IP portfolio review', matter: 'NovaTech Merger', matterId: 'M-2024-0230', assignee: 'A. Petrov', priority: 'low', status: 'In Progress', dueDate: '2026-05-20', category: 'Review', estimatedHours: 8, loggedHours: 5, description: 'Complete IP portfolio analysis for merger review.', blockedBy: null, linkedDeadlines: [], linkedDocs: [13], linkedEvidence: [], subtasks: [{t:'Patent portfolio summary',done:true},{t:'Trademark review',done:true},{t:'License agreement review',done:false}], activity: [{user:'A. Petrov',action:'Finished trademark analysis',time:'6h ago'}] },
  { id: 'T-009', title: 'Prepare class certification reply brief', matter: 'Greenfield Environmental', matterId: 'M-2024-0218', assignee: 'M. Kirkland', priority: 'high', status: 'To Do', dueDate: '2026-04-30', category: 'Drafting', estimatedHours: 14, loggedHours: 0, description: 'Reply to defendant opposition to class certification motion.', blockedBy: 'T-001', linkedDeadlines: ['DL-011'], linkedDocs: [14], linkedEvidence: [], subtasks: [{t:'Analyze opposition arguments',done:false},{t:'Draft typicality section',done:false},{t:'Update class definition',done:false}], activity: [{user:'M. Kirkland',action:'Received opposition brief',time:'1d ago'}] },
  { id: 'T-010', title: 'Finalize settlement agreement', matter: 'Marshall Employment', matterId: 'M-2024-0201', assignee: 'R. Vasquez', priority: 'low', status: 'In Review', dueDate: '2026-05-08', category: 'Drafting', estimatedHours: 4, loggedHours: 3.5, description: 'Incorporate final revisions to settlement terms.', blockedBy: null, linkedDeadlines: ['DL-016'], linkedDocs: [], linkedEvidence: [], subtasks: [{t:'Revise non-compete clause',done:true},{t:'Add payment schedule',done:true},{t:'Client approval',done:false}], activity: [{user:'R. Vasquez',action:'Sent to client for review',time:'1d ago'}] },
  { id: 'T-011', title: 'Respond to motion to compel', matter: 'Blackwell IP', matterId: 'M-2024-0271', assignee: 'J. Park', priority: 'high', status: 'To Do', dueDate: '2026-04-28', category: 'Filing', estimatedHours: 6, loggedHours: 0, description: 'Draft response to defendant motion to compel source code production.', blockedBy: 'T-004', linkedDeadlines: ['DL-014'], linkedDocs: [], linkedEvidence: [], subtasks: [], activity: [] },
  { id: 'T-012', title: 'Client meeting prep — quarterly update', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', assignee: 'S. Chen', priority: 'medium', status: 'Done', dueDate: '2026-04-18', category: 'Admin', estimatedHours: 2, loggedHours: 2, description: 'Prepare slides and talking points for quarterly client update.', blockedBy: null, linkedDeadlines: [], linkedDocs: [], linkedEvidence: [], subtasks: [{t:'Draft slide deck',done:true},{t:'Budget summary',done:true}], activity: [{user:'S. Chen',action:'Completed and presented',time:'2d ago'}] },
  { id: 'T-013', title: 'Coordinate expert deposition logistics', matter: 'Thornton Estate', matterId: 'M-2024-0284', assignee: 'R. Vasquez', priority: 'medium', status: 'Done', dueDate: '2026-04-19', category: 'Admin', estimatedHours: 1, loggedHours: 1, description: 'Schedule and confirm expert deposition venue and videographer.', blockedBy: null, linkedDeadlines: ['DL-012'], linkedDocs: [], linkedEvidence: [], subtasks: [{t:'Book conference room',done:true},{t:'Confirm videographer',done:true}], activity: [{user:'R. Vasquez',action:'All logistics confirmed',time:'1d ago'}] },
  { id: 'T-014', title: 'Review opposing expert report', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', assignee: 'L. Torres', priority: 'high', status: 'In Review', dueDate: '2026-04-24', category: 'Review', estimatedHours: 5, loggedHours: 4, description: 'Analyze opposing expert economic damages methodology for Daubert challenge.', blockedBy: null, linkedDeadlines: ['DL-005'], linkedDocs: [3], linkedEvidence: ['EV-0006','EV-0007'], subtasks: [{t:'Summarize methodology',done:true},{t:'Identify weaknesses',done:true},{t:'Draft Daubert memo',done:false}], activity: [{user:'L. Torres',action:'Submitted for partner review',time:'5h ago'},{user:'M. Kirkland',action:'Left comments on methodology section',time:'3h ago'}] },
];

const TASK_CATEGORIES = ['All', 'Drafting', 'Filing', 'Review', 'Research', 'Deposition', 'Admin'];
const TASK_STATUSES = ['To Do', 'In Progress', 'In Review', 'Done'];
const TASK_ASSIGNEES = ['All', 'M. Kirkland', 'S. Chen', 'R. Vasquez', 'L. Torres', 'A. Petrov', 'J. Park'];

const CATEGORY_COLORS = {
  'Drafting': { bg: '#EFF4FF', color: '#2563EB' },
  'Filing': { bg: '#F5F0FF', color: '#6B21A8' },
  'Review': { bg: T.color.status.warningBg, color: T.color.status.warning },
  'Research': { bg: T.color.status.activeBg, color: T.color.status.active },
  'Deposition': { bg: T.color.status.criticalBg, color: T.color.status.critical },
  'Admin': { bg: T.color.status.pendingBg, color: T.color.status.pending },
};

const ASSIGNEE_INITIALS = {
  'M. Kirkland': 'MK', 'S. Chen': 'SC', 'R. Vasquez': 'RV',
  'L. Torres': 'LT', 'A. Petrov': 'AP', 'J. Park': 'JP',
};
const ASSIGNEE_COLORS = {
  'M. Kirkland': '#2563EB', 'S. Chen': '#6B21A8', 'R. Vasquez': '#B8860B',
  'L. Torres': '#C23030', 'A. Petrov': '#1B7A4A', 'J. Park': '#4A5A80',
};

// Cross-reference lookup: deadline ID → task IDs
const DEADLINE_TO_TASKS = {};
TASKS.forEach(t => {
  (t.linkedDeadlines || []).forEach(dlId => {
    if (!DEADLINE_TO_TASKS[dlId]) DEADLINE_TO_TASKS[dlId] = [];
    DEADLINE_TO_TASKS[dlId].push(t.id);
  });
});

window.TASKS = TASKS;
window.TASK_CATEGORIES = TASK_CATEGORIES;
window.TASK_STATUSES = TASK_STATUSES;
window.TASK_ASSIGNEES = TASK_ASSIGNEES;
window.CATEGORY_COLORS = CATEGORY_COLORS;
window.ASSIGNEE_INITIALS = ASSIGNEE_INITIALS;
window.ASSIGNEE_COLORS = ASSIGNEE_COLORS;
window.DEADLINE_TO_TASKS = DEADLINE_TO_TASKS;
