/**
 * 用户模型
 * 
 */
import { z } from "zod";
import { PersonalityTraitsSchema, PERSONALITY_TRAITS_DEFAULTS } from "./personality_traits";
import {
  numberOrZero,
  stringOrEmpty,
} from "../nullable-defaults";

export const UserSchema = z.object({
  id: stringOrEmpty, // 兜底：理论 id 不会 null，但保持防御
  username: stringOrEmpty,
  email: stringOrEmpty,
  platform: stringOrEmpty,
  country: stringOrEmpty,
  countryCode: stringOrEmpty,
  intimacy: numberOrZero,
  dolBalance: numberOrZero,
  personalityTraits: PersonalityTraitsSchema.default(PERSONALITY_TRAITS_DEFAULTS),
  preferredLanguage: stringOrEmpty,
  createdAt: stringOrEmpty,
  // 后端新游客返回 null（"还没发过消息"），前端统一收敛为空字符串。
  lastMessageAt: stringOrEmpty,
});

export type UserInput = z.input<typeof UserSchema>;
export type UserData = z.output<typeof UserSchema>;
