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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  DocumentURLChunk,
  DocumentURLChunk$inboundSchema,
} from "./documenturlchunk.js";
import { ImageURLChunk, ImageURLChunk$inboundSchema } from "./imageurlchunk.js";
import { TextChunk, TextChunk$inboundSchema } from "./textchunk.js";
import { ThinkChunk, ThinkChunk$inboundSchema } from "./thinkchunk.js";
import { ToolFileChunk, ToolFileChunk$inboundSchema } from "./toolfilechunk.js";
import {
  ToolReferenceChunk,
  ToolReferenceChunk$inboundSchema,
} from "./toolreferencechunk.js";

export type OutputContentChunks =
  | ToolFileChunk
  | ToolReferenceChunk
  | TextChunk
  | ImageURLChunk
  | DocumentURLChunk
  | ThinkChunk;

/** @internal */
export const OutputContentChunks$inboundSchema: z.ZodType<
  OutputContentChunks,
  z.ZodTypeDef,
  unknown
> = z.union([
  ToolFileChunk$inboundSchema,
  ToolReferenceChunk$inboundSchema,
  TextChunk$inboundSchema,
  ImageURLChunk$inboundSchema,
  DocumentURLChunk$inboundSchema,
  ThinkChunk$inboundSchema,
]);

export function outputContentChunksFromJSON(
  jsonString: string,
): SafeParseResult<OutputContentChunks, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => OutputContentChunks$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'OutputContentChunks' from JSON`,
  );
}
