/**
 * 发送消息响应 DTO
 */
import {
  ChatSendResponseSchema,
  type ChatSendResponseInput,
  type ChatSendResponseData,
  type ChatBlockDetailData,
} from "@/data/schemas/chat/chat_send_response";

export class ChatSendResponse {
  declare readonly mode: string;
  declare readonly reply: string;
  declare readonly voiceUrl: string;
  declare readonly audioUrl: string;
  declare readonly intimacyChange: number;
  declare readonly newIntimacy: number;
  declare readonly relationshipStage: string;
  declare readonly currentMood: string;
  declare readonly messageId: string;
  declare readonly isGuest: boolean;
  declare readonly timestamp: number;
  declare readonly blocked: boolean | null;
  declare readonly blockReason: string | null;
  declare readonly blockDetail: ChatBlockDetailData | null;
  declare readonly paywallTriggered: boolean;
  declare readonly showUpgrade: boolean;
  declare readonly imageType: string | null;
  declare readonly imageUrl: string | null;

  private constructor(input: ChatSendResponseInput) {
    const data = ChatSendResponseSchema.parse(input);
    Object.assign(this, data);
    Object.freeze(this);
  }

  static from(input: ChatSendResponseInput): ChatSendResponse {
    return new ChatSendResponse(input);
  }

  static fromJson(json: unknown): ChatSendResponse {
    return ChatSendResponse.from(json as ChatSendResponseInput);
  }

  toJson(): ChatSendResponseData {
    return ChatSendResponseSchema.parse(this);
  }
}
