import { z } from "zod";
const ttsSessionCreateEventSchema = z.object({
  type: z.literal("session.create"),
  sample_rate: z.string(),
  encoding: z.string(),
  model: z.string().optional(),
  voice: z.string().optional(),
  language: z.string().optional(),
  extra: z.record(z.string(), z.unknown()),
  transcript: z.string().optional()
});
const ttsGenerationConfigSchema = z.object({
  voice: z.string().optional(),
  language: z.string().optional(),
  model: z.string().optional()
});
const ttsInputTranscriptEventSchema = z.object({
  type: z.literal("input_transcript"),
  transcript: z.string(),
  generation_config: ttsGenerationConfigSchema.optional(),
  extra: z.record(z.string(), z.unknown()).optional()
});
const ttsSessionFlushEventSchema = z.object({
  type: z.literal("session.flush")
});
const ttsSessionCloseEventSchema = z.object({
  type: z.literal("session.close")
});
const ttsSessionCreatedEventSchema = z.object({
  type: z.literal("session.created"),
  session_id: z.string()
});
const ttsOutputAudioEventSchema = z.object({
  type: z.literal("output_audio"),
  audio: z.string(),
  session_id: z.string()
});
const ttsDoneEventSchema = z.object({
  type: z.literal("done"),
  session_id: z.string()
});
const ttsSessionClosedEventSchema = z.object({
  type: z.literal("session.closed"),
  session_id: z.string()
});
const ttsErrorEventSchema = z.object({
  type: z.literal("error"),
  message: z.string().optional(),
  session_id: z.string().optional()
});
const ttsWordTimestampSchema = z.object({
  word: z.string(),
  start: z.number(),
  end: z.number()
});
const ttsCharTimestampSchema = z.object({
  char: z.string(),
  start: z.number(),
  end: z.number()
});
const ttsOutputAlignmentEventSchema = z.object({
  type: z.literal("output_alignment"),
  session_id: z.string().optional(),
  words: z.array(ttsWordTimestampSchema).optional(),
  chars: z.array(ttsCharTimestampSchema).optional()
});
const ttsClientEventSchema = z.discriminatedUnion("type", [
  ttsSessionCreateEventSchema,
  ttsInputTranscriptEventSchema,
  ttsSessionFlushEventSchema,
  ttsSessionCloseEventSchema
]);
const ttsKnownServerEventSchema = z.discriminatedUnion("type", [
  ttsSessionCreatedEventSchema,
  ttsOutputAudioEventSchema,
  ttsOutputAlignmentEventSchema,
  ttsDoneEventSchema,
  ttsSessionClosedEventSchema,
  ttsErrorEventSchema
]);
const knownTtsServerEventTypes = /* @__PURE__ */ new Set([
  "session.created",
  "output_audio",
  "output_alignment",
  "done",
  "session.closed",
  "error"
]);
const ttsUnknownServerEventSchema = z.object({
  type: z.string().refine((type) => !knownTtsServerEventTypes.has(type))
}).passthrough();
const ttsServerEventSchema = z.union([
  ttsKnownServerEventSchema,
  ttsUnknownServerEventSchema
]);
const sttWordSchema = z.object({
  word: z.string().optional().default(""),
  start: z.number().optional().default(0),
  end: z.number().optional().default(0),
  confidence: z.number().optional().default(0),
  speaker_id: z.string().nullable().optional(),
  extra: z.unknown().nullable().optional()
});
const sttWordsSchema = z.preprocess((words) => words ?? [], z.array(sttWordSchema));
const sttInterimTranscriptEventSchema = z.object({
  type: z.literal("interim_transcript"),
  session_id: z.string().optional(),
  transcript: z.string().optional().default(""),
  language: z.string().optional().default(""),
  start: z.number().optional().default(0),
  duration: z.number().optional().default(0),
  confidence: z.number().optional().default(1),
  words: sttWordsSchema,
  speaker_id: z.string().nullable().optional(),
  extra: z.unknown().nullable().optional()
});
const sttFinalTranscriptEventSchema = z.object({
  type: z.literal("final_transcript"),
  session_id: z.string().optional(),
  transcript: z.string().optional().default(""),
  language: z.string().optional().default(""),
  start: z.number().optional().default(0),
  duration: z.number().optional().default(0),
  confidence: z.number().optional().default(1),
  words: sttWordsSchema,
  speaker_id: z.string().nullable().optional(),
  extra: z.unknown().nullable().optional()
});
const sttPreflightTranscriptEventSchema = sttInterimTranscriptEventSchema.extend({
  type: z.literal("preflight_transcript")
});
const sttSessionCreatedEventSchema = z.object({
  type: z.literal("session.created"),
  session_id: z.string().optional()
});
const sttSessionFinalizedEventSchema = z.object({
  type: z.literal("session.finalized")
});
const sttSessionClosedEventSchema = z.object({
  type: z.literal("session.closed")
});
const sttErrorEventSchema = z.object({
  type: z.literal("error"),
  message: z.string().optional(),
  code: z.number().optional()
});
const sttKnownServerEventSchema = z.discriminatedUnion("type", [
  sttSessionCreatedEventSchema,
  sttSessionFinalizedEventSchema,
  sttSessionClosedEventSchema,
  sttInterimTranscriptEventSchema,
  sttFinalTranscriptEventSchema,
  sttPreflightTranscriptEventSchema,
  sttErrorEventSchema
]);
const knownSttServerEventTypes = /* @__PURE__ */ new Set([
  "session.created",
  "session.finalized",
  "session.closed",
  "interim_transcript",
  "final_transcript",
  "preflight_transcript",
  "error"
]);
const sttUnknownServerEventSchema = z.object({
  type: z.string().refine((type) => !knownSttServerEventTypes.has(type))
}).passthrough();
const sttServerEventSchema = z.union([
  sttKnownServerEventSchema,
  sttUnknownServerEventSchema
]);
export {
  sttErrorEventSchema,
  sttFinalTranscriptEventSchema,
  sttInterimTranscriptEventSchema,
  sttKnownServerEventSchema,
  sttPreflightTranscriptEventSchema,
  sttServerEventSchema,
  sttSessionClosedEventSchema,
  sttSessionCreatedEventSchema,
  sttSessionFinalizedEventSchema,
  sttUnknownServerEventSchema,
  sttWordSchema,
  ttsCharTimestampSchema,
  ttsClientEventSchema,
  ttsDoneEventSchema,
  ttsErrorEventSchema,
  ttsGenerationConfigSchema,
  ttsInputTranscriptEventSchema,
  ttsKnownServerEventSchema,
  ttsOutputAlignmentEventSchema,
  ttsOutputAudioEventSchema,
  ttsServerEventSchema,
  ttsSessionCloseEventSchema,
  ttsSessionClosedEventSchema,
  ttsSessionCreateEventSchema,
  ttsSessionCreatedEventSchema,
  ttsSessionFlushEventSchema,
  ttsUnknownServerEventSchema,
  ttsWordTimestampSchema
};
//# sourceMappingURL=api_protos.js.map