import { z } from "zod";

export const signalCreateSchema = z.object({
  providerId: z.string().optional().nullable(),
  eventId: z.string().min(1),
  sportType: z.string().min(1),
  leagueName: z.string().min(1),
  homeTeam: z.string().min(1),
  awayTeam: z.string().min(1),
  eventStartTime: z.string().datetime(),
  marketType: z.string().min(1),
  selection: z.string().min(1),
  forecast: z.string().optional().nullable(),
  lineValue: z.number().optional().nullable(),
  odds: z.number().positive(),
  signalTime: z.string().datetime(),
  sourceType: z.enum(["manual", "provider"]).default("manual"),
  comment: z.string().optional().nullable(),
  rawPayload: z.record(z.any()).optional().nullable(),
  published: z.boolean().default(true)
});

export const signalUpdateSchema = signalCreateSchema.partial().extend({
  status: z.enum(["pending", "win", "lose", "void", "manual_review", "unpublished"]).optional()
});

export const signalStatusSchema = z.object({
  status: z.enum(["pending", "win", "lose", "void", "manual_review", "unpublished"]),
  explanation: z.string().min(1)
});

export const signalListSchema = z.object({
  status: z.string().optional(),
  sportType: z.string().optional(),
  sourceType: z.string().optional(),
  q: z.string().optional(),
  published: z.string().optional(),
  botKey: z.string().optional(),
  activeTab: z.coerce.number().int().min(1).max(2).optional(),
  page: z.coerce.number().int().min(1).default(1),
  perPage: z.coerce.number().int().min(1).max(200).default(20)
});
