/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 07c04da6648f
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.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,
  unknown
> = smartUnion([
  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`,
  );
}
