/**
 * 个性特征 DTO
 */
import {
  PersonalityTraitsSchema,
  type PersonalityTraitsInput,
  type PersonalityTraitsData,
} from "@/data/schemas/user/personality_traits";

export class PersonalityTraits {
  declare readonly cheerful: number;
  declare readonly caring: number;
  declare readonly playful: number;
  declare readonly serious: number;
  declare readonly romantic: number;

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

  static from(input: PersonalityTraitsInput): PersonalityTraits {
    return new PersonalityTraits(input);
  }

  static fromJson(json: unknown): PersonalityTraits {
    return PersonalityTraits.from(json as PersonalityTraitsInput);
  }

  toJson(): PersonalityTraitsData {
    return PersonalityTraitsSchema.parse(this);
  }
}
