import { z } from 'zod';
import type { ToolDef } from '../tool-registry.js';

export const shiftTools: ToolDef[] = [
  {
    name: 'shifts_list',
    description:
      'List volunteer shifts. Returns upcoming and past shifts with signup counts, ' +
      'cut assignments, and capacity info. Use to check volunteer scheduling.',
    inputSchema: {
      page: z.coerce.number().int().positive().default(1).describe('Page number'),
      limit: z.coerce.number().int().positive().max(100).default(20).describe('Items per page'),
      upcoming: z.coerce.boolean().optional().describe('Filter to upcoming shifts only'),
    },
    method: 'GET',
    path: '/api/map/shifts',
    tier: 1,
  },
  {
    name: 'shifts_get',
    description: 'Get full details of a single shift by ID, including signups.',
    inputSchema: {
      id: z.string().describe('Shift ID'),
    },
    method: 'GET',
    path: '/api/map/shifts/:id',
    tier: 1,
  },
  {
    name: 'shifts_create',
    description:
      'Create a new volunteer shift. Specify date/time, location description, ' +
      'and optionally assign to a cut (map polygon) for canvassing.',
    inputSchema: {
      title: z.string().min(1).max(200).describe('Shift title'),
      description: z.string().max(2000).optional().describe('Shift description'),
      startTime: z.string().describe('Start time (ISO 8601 datetime)'),
      endTime: z.string().describe('End time (ISO 8601 datetime)'),
      location: z.string().max(500).optional().describe('Meeting location description'),
      maxVolunteers: z.number().int().positive().optional().describe('Maximum volunteer capacity'),
      cutId: z.number().int().positive().optional().describe('Assign to a map cut for canvassing'),
    },
    method: 'POST',
    path: '/api/map/shifts',
    tier: 1,
  },
  {
    name: 'shifts_update',
    description: 'Update an existing shift. Only provided fields are changed.',
    inputSchema: {
      id: z.string().describe('Shift ID'),
      title: z.string().min(1).max(200).optional().describe('Shift title'),
      description: z.string().max(2000).optional().describe('Shift description'),
      startTime: z.string().optional().describe('Start time (ISO 8601)'),
      endTime: z.string().optional().describe('End time (ISO 8601)'),
      location: z.string().max(500).optional().describe('Meeting location'),
      maxVolunteers: z.number().int().positive().optional().describe('Max volunteer capacity'),
      cutId: z.number().int().positive().nullable().optional().describe('Assigned map cut'),
    },
    method: 'PUT',
    path: '/api/map/shifts/:id',
    tier: 1,
  },
  {
    name: 'canvass_dashboard',
    description:
      'Get canvassing dashboard stats: total sessions, visits recorded, ' +
      'outcome breakdowns (home, not-home, refused, etc.), volunteer activity.',
    inputSchema: {},
    method: 'GET',
    path: '/api/map/canvass/admin/dashboard',
    tier: 1,
  },
];
