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

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,
  DocumentURLChunk$Outbound,
  DocumentURLChunk$outboundSchema,
} from "./documenturlchunk.js";
import {
  ImageURLChunk,
  ImageURLChunk$inboundSchema,
  ImageURLChunk$Outbound,
  ImageURLChunk$outboundSchema,
} from "./imageurlchunk.js";
import {
  TextChunk,
  TextChunk$inboundSchema,
  TextChunk$Outbound,
  TextChunk$outboundSchema,
} from "./textchunk.js";
import {
  ThinkChunk,
  ThinkChunk$inboundSchema,
  ThinkChunk$Outbound,
  ThinkChunk$outboundSchema,
} from "./thinkchunk.js";
import {
  ToolFileChunk,
  ToolFileChunk$inboundSchema,
  ToolFileChunk$Outbound,
  ToolFileChunk$outboundSchema,
} from "./toolfilechunk.js";

export type MessageInputContentChunks =
  | ToolFileChunk
  | TextChunk
  | ImageURLChunk
  | DocumentURLChunk
  | ThinkChunk;

/** @internal */
export const MessageInputContentChunks$inboundSchema: z.ZodType<
  MessageInputContentChunks,
  unknown
> = smartUnion([
  ToolFileChunk$inboundSchema,
  TextChunk$inboundSchema,
  ImageURLChunk$inboundSchema,
  DocumentURLChunk$inboundSchema,
  ThinkChunk$inboundSchema,
]);
/** @internal */
export type MessageInputContentChunks$Outbound =
  | ToolFileChunk$Outbound
  | TextChunk$Outbound
  | ImageURLChunk$Outbound
  | DocumentURLChunk$Outbound
  | ThinkChunk$Outbound;

/** @internal */
export const MessageInputContentChunks$outboundSchema: z.ZodType<
  MessageInputContentChunks$Outbound,
  MessageInputContentChunks
> = smartUnion([
  ToolFileChunk$outboundSchema,
  TextChunk$outboundSchema,
  ImageURLChunk$outboundSchema,
  DocumentURLChunk$outboundSchema,
  ThinkChunk$outboundSchema,
]);

export function messageInputContentChunksToJSON(
  messageInputContentChunks: MessageInputContentChunks,
): string {
  return JSON.stringify(
    MessageInputContentChunks$outboundSchema.parse(messageInputContentChunks),
  );
}
export function messageInputContentChunksFromJSON(
  jsonString: string,
): SafeParseResult<MessageInputContentChunks, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => MessageInputContentChunks$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'MessageInputContentChunks' from JSON`,
  );
}
