class ChatTurnResponse {
  const ChatTurnResponse({
    required this.sessionId,
    required this.replyText,
    this.transcription,
    this.replyAudioPath,
    this.error,
  });

  final String sessionId;
  final String replyText;
  final String? transcription;
  final String? replyAudioPath;
  final String? error;

  bool get isOk => error == null || error!.isEmpty;

  factory ChatTurnResponse.fromJson(Map<String, dynamic> json) {
    return ChatTurnResponse(
      sessionId: json['session_id']?.toString() ?? '',
      replyText: json['reply_text']?.toString() ?? '',
      transcription: json['transcription']?.toString(),
      replyAudioPath: json['reply_audio_path']?.toString(),
      error: json['error']?.toString(),
    );
  }
}

enum ChatBubbleRole { user, assistant, system }

class ChatBubble {
  ChatBubble({
    required this.role,
    required this.text,
    this.audioPath,
    this.isPending = false,
    DateTime? createdAt,
  }) : createdAt = createdAt ?? DateTime.now();

  final ChatBubbleRole role;
  String text;
  String? audioPath;
  bool isPending;
  final DateTime createdAt;
}
