/**
 * 发送消息响应
 * 
 */
import { z } from "zod";
import {
  booleanOrFalse,
  booleanOrTrue,
  numberOrLazy,
  numberOrZero,
  stringOrEmpty,
  stringOrNull,
} from "../nullable-defaults";
import { ChatImageSchema, ChatLockDetailSchema } from "./chat_payloads";

export const ChatSendResponseSchema = z.object({
  reply: stringOrEmpty,
  audioUrl: stringOrEmpty,
  messageId: stringOrEmpty,
  isGuest: booleanOrFalse,
  // 函数式 default —— 每次 parse 时重新调 Date.now()（后端不返回 timestamp 时用当下时间）
  timestamp: numberOrLazy(() => Date.now()),
  image: ChatImageSchema,
  lockDetail: ChatLockDetailSchema,
  canSendMessage: booleanOrTrue,
  cannotSendReason: stringOrNull,
  creditBalance: numberOrZero,
  creditsCharged: numberOrZero,
  requiredCredits: numberOrZero,
  shortfallCredits: numberOrZero,
});

export type ChatSendResponseInput = z.input<typeof ChatSendResponseSchema>;
export type ChatSendResponseData = z.output<typeof ChatSendResponseSchema>;
