import { z } from 'zod';
import { LOCATION_TYPES } from '../constants';

export const searchLocationsQuerySchema = z.object({
  q: z.string().max(100).optional(),
  type: z.enum(LOCATION_TYPES).optional(),
  localityId: z.coerce.number().int().positive().optional(),
  limit: z.coerce.number().int().min(1).max(50).default(20),
});

export const createLocationFromPlaceSchema = z.object({
  placeId: z.string().min(5).max(255),
  sessionToken: z.string().min(8).max(100),
  // Optional overrides if user wants to rename or set type explicitly
  displayName: z.string().min(2).max(200).optional(),
  locationType: z.enum(LOCATION_TYPES),
  localityId: z.number().int().positive().optional().nullable(),
});
export type CreateLocationFromPlaceInput = z.infer<typeof createLocationFromPlaceSchema>;

export const placesAutocompleteQuerySchema = z.object({
  q: z.string().min(2).max(100),
  sessionToken: z.string().min(8).max(100),
});
