/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type AudioChunk = {
  type?: "input_audio" | undefined;
  inputAudio: string;
};

/** @internal */
export const AudioChunk$inboundSchema: z.ZodType<
  AudioChunk,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: z.literal("input_audio").default("input_audio"),
  input_audio: z.string(),
}).transform((v) => {
  return remap$(v, {
    "input_audio": "inputAudio",
  });
});
/** @internal */
export type AudioChunk$Outbound = {
  type: "input_audio";
  input_audio: string;
};

/** @internal */
export const AudioChunk$outboundSchema: z.ZodType<
  AudioChunk$Outbound,
  z.ZodTypeDef,
  AudioChunk
> = z.object({
  type: z.literal("input_audio").default("input_audio" as const),
  inputAudio: z.string(),
}).transform((v) => {
  return remap$(v, {
    inputAudio: "input_audio",
  });
});

export function audioChunkToJSON(audioChunk: AudioChunk): string {
  return JSON.stringify(AudioChunk$outboundSchema.parse(audioChunk));
}
export function audioChunkFromJSON(
  jsonString: string,
): SafeParseResult<AudioChunk, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AudioChunk$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AudioChunk' from JSON`,
  );
}
