/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: a60397a86def
 */
import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { discriminatedUnion } from "../../types/discriminatedUnion.js";
import { TranscriptionStreamDone$inboundSchema, } from "./transcriptionstreamdone.js";
import { TranscriptionStreamEventTypes$inboundSchema, } from "./transcriptionstreameventtypes.js";
import { TranscriptionStreamLanguage$inboundSchema, } from "./transcriptionstreamlanguage.js";
import { TranscriptionStreamSegmentDelta$inboundSchema, } from "./transcriptionstreamsegmentdelta.js";
import { TranscriptionStreamTextDelta$inboundSchema, } from "./transcriptionstreamtextdelta.js";
/** @internal */
export const TranscriptionStreamEventsData$inboundSchema = discriminatedUnion("type", {
    ["transcription.done"]: TranscriptionStreamDone$inboundSchema,
    ["transcription.language"]: TranscriptionStreamLanguage$inboundSchema,
    ["transcription.segment"]: TranscriptionStreamSegmentDelta$inboundSchema,
    ["transcription.text.delta"]: TranscriptionStreamTextDelta$inboundSchema,
});
export function transcriptionStreamEventsDataFromJSON(jsonString) {
    return safeParse(jsonString, (x) => TranscriptionStreamEventsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TranscriptionStreamEventsData' from JSON`);
}
/** @internal */
export const TranscriptionStreamEvents$inboundSchema = z.object({
    event: TranscriptionStreamEventTypes$inboundSchema,
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({
                input: v,
                code: "custom",
                message: `malformed json: ${err}`,
            });
            return z.NEVER;
        }
    }).pipe(discriminatedUnion("type", {
        ["transcription.done"]: TranscriptionStreamDone$inboundSchema,
        ["transcription.language"]: TranscriptionStreamLanguage$inboundSchema,
        ["transcription.segment"]: TranscriptionStreamSegmentDelta$inboundSchema,
        ["transcription.text.delta"]: TranscriptionStreamTextDelta$inboundSchema,
    })),
});
export function transcriptionStreamEventsFromJSON(jsonString) {
    return safeParse(jsonString, (x) => TranscriptionStreamEvents$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TranscriptionStreamEvents' from JSON`);
}
//# sourceMappingURL=transcriptionstreamevents.js.map