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

export const locationTools: ToolDef[] = [
  {
    name: 'locations_search',
    description:
      'Search locations in the map database. Filter by address, postal code, ' +
      'city, province, or cut assignment. Returns paginated results with coordinates.',
    inputSchema: {
      page: z.coerce.number().int().positive().default(1).describe('Page number'),
      limit: z.coerce.number().int().positive().max(100).default(50).describe('Items per page'),
      search: z.string().optional().describe('Search by address, city, or postal code'),
      cutId: z.coerce.number().int().positive().optional().describe('Filter by cut assignment'),
      province: z.string().optional().describe('Filter by province code'),
      hasCoordinates: z.coerce.boolean().optional().describe('Filter to geocoded locations only'),
    },
    method: 'GET',
    path: '/api/map/locations',
    tier: 1,
  },
  {
    name: 'locations_stats',
    description:
      'Get statistics about the locations database: total count, geocoded percentage, ' +
      'breakdown by province, cut assignment coverage.',
    inputSchema: {},
    method: 'GET',
    path: '/api/map/locations/stats',
    tier: 1,
  },
  {
    name: 'cuts_list',
    description:
      'List map cuts (polygons/areas). Cuts define canvassing territories. ' +
      'Each cut has a name, color, and polygon coordinates. Returns location counts per cut.',
    inputSchema: {
      page: z.coerce.number().int().positive().default(1).describe('Page number'),
      limit: z.coerce.number().int().positive().max(100).default(50).describe('Items per page'),
    },
    method: 'GET',
    path: '/api/map/cuts',
    tier: 1,
  },
  {
    name: 'map_settings',
    description:
      'Get map display settings: center coordinates, default zoom level, ' +
      'and other map configuration.',
    inputSchema: {},
    method: 'GET',
    path: '/api/map/settings',
    tier: 1,
  },
];
