/**
 * Twilio Voice Validators - Stub
 * TODO: Implement proper validation when voice calling feature is built
 */

import { z } from 'zod';

export const callIdParamSchema = z.object({
  id: z.string().min(1),
});

export const listCallsQuerySchema = z.object({
  status: z.string().optional(),
  direction: z.enum(['inbound', 'outbound']).optional(),
  startDate: z.string().optional(),
  endDate: z.string().optional(),
  page: z.coerce.number().int().positive().optional(),
  pageSize: z.coerce.number().int().positive().max(100).optional(),
  limit: z.coerce.number().int().positive().max(100).default(20),
  offset: z.coerce.number().int().min(0).default(0),
});

export const callHistoryQuerySchema = listCallsQuerySchema;

export const purchaseNumberSchema = z.object({
  phoneNumber: z.string().min(1),
  friendlyName: z.string().optional(),
});

export const configureNumberSchema = z.object({
  voiceUrl: z.string().url().optional(),
  statusCallbackUrl: z.string().url().optional(),
});

export const initiateCallSchema = z.object({
  to: z.string().min(1),
  from: z.string().optional(),
  toNumber: z.string().optional(),
  phoneNumberId: z.string().optional(),
  agentId: z.string().optional(),
});

export const initiateOutboundCallSchema = initiateCallSchema;

export const updatePhoneNumberSchema = z.object({
  friendlyName: z.string().optional(),
  voiceUrl: z.string().url().optional(),
  statusCallbackUrl: z.string().url().optional(),
});

export const importPhoneNumberSchema = z.object({
  phoneNumber: z.string().min(1),
  sid: z.string().optional(),
  friendlyName: z.string().optional(),
  twilioAccountSid: z.string().optional(),
  twilioAuthToken: z.string().optional(),
  elevenLabsAgentId: z.string().optional(),
});

export const twilioStatusCallbackSchema = z.object({
  CallSid: z.string(),
  CallStatus: z.string(),
  CallDuration: z.string().optional(),
  Direction: z.string().optional(),
});

export const twilioInboundCallSchema = z.object({
  CallSid: z.string(),
  From: z.string(),
  To: z.string(),
  Direction: z.string().optional(),
});

export const twilioIncomingCallWebhookSchema = twilioInboundCallSchema;

export const twilioCallStatusWebhookSchema = twilioStatusCallbackSchema;

export const twilioCallStatusSchema = z.enum([
  'queued', 'ringing', 'in-progress', 'completed',
  'busy', 'failed', 'no-answer', 'canceled',
]);
