/**
 * Twilio Voice Types - Stub
 * TODO: Define proper types when voice calling feature is built
 */

export interface VoiceCallRecord {
  id: string;
  userId: string;
  from: string;
  to: string;
  status: string;
  duration: number;
  direction: 'inbound' | 'outbound';
  recordingUrl?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface TwilioPhoneNumber {
  sid: string;
  phoneNumber: string;
  friendlyName: string;
  capabilities: Record<string, boolean>;
}

export interface VoiceCallFilters {
  userId?: string;
  status?: string;
  direction?: string;
  from?: Date;
  to?: Date;
  limit?: number;
  offset?: number;
}

export type CallDirection = 'inbound' | 'outbound';
export type CallStatus =
  | 'queued' | 'ringing' | 'in-progress' | 'completed' | 'busy' | 'failed' | 'no-answer' | 'canceled'
  | 'QUEUED' | 'RINGING' | 'IN_PROGRESS' | 'COMPLETED' | 'BUSY' | 'FAILED' | 'NO_ANSWER' | 'CANCELLED';

export function formatPhoneNumber(phone: string): string {
  // Simple E.164 formatting stub
  const digits = phone.replace(/\D/g, '');
  return digits.startsWith('+') ? digits : `+${digits}`;
}

export function mapTwilioStatusToCallStatus(twilioStatus: string): CallStatus {
  const statusMap: Record<string, CallStatus> = {
    'queued': 'queued',
    'ringing': 'ringing',
    'in-progress': 'in-progress',
    'completed': 'completed',
    'busy': 'busy',
    'failed': 'failed',
    'no-answer': 'no-answer',
    'canceled': 'canceled',
  };
  return statusMap[twilioStatus] || 'failed';
}
