/**
 * STT（语音转文字）响应 DTO
 */
import {
  SttDataSchema,
  type SttDataInput,
  type SttDataData,
} from "@/data/schemas/chat/stt_data";

export class SttData {
  declare readonly text: string;

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

  static from(input: SttDataInput): SttData {
    return new SttData(input);
  }

  static fromJson(json: unknown): SttData {
    return SttData.from(json as SttDataInput);
  }

  toJson(): SttDataData {
    return SttDataSchema.parse(this);
  }
}
