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

import * as z from "zod/v3";
import {
  SystemMessageContentChunks,
  SystemMessageContentChunks$Outbound,
  SystemMessageContentChunks$outboundSchema,
} from "./systemmessagecontentchunks.js";

export type SystemMessageContent = string | Array<SystemMessageContentChunks>;

export type SystemMessage = {
  role?: "system" | undefined;
  content: string | Array<SystemMessageContentChunks>;
};

/** @internal */
export type SystemMessageContent$Outbound =
  | string
  | Array<SystemMessageContentChunks$Outbound>;

/** @internal */
export const SystemMessageContent$outboundSchema: z.ZodType<
  SystemMessageContent$Outbound,
  z.ZodTypeDef,
  SystemMessageContent
> = z.union([z.string(), z.array(SystemMessageContentChunks$outboundSchema)]);

export function systemMessageContentToJSON(
  systemMessageContent: SystemMessageContent,
): string {
  return JSON.stringify(
    SystemMessageContent$outboundSchema.parse(systemMessageContent),
  );
}

/** @internal */
export type SystemMessage$Outbound = {
  role: "system";
  content: string | Array<SystemMessageContentChunks$Outbound>;
};

/** @internal */
export const SystemMessage$outboundSchema: z.ZodType<
  SystemMessage$Outbound,
  z.ZodTypeDef,
  SystemMessage
> = z.object({
  role: z.literal("system").default("system" as const),
  content: z.union([
    z.string(),
    z.array(SystemMessageContentChunks$outboundSchema),
  ]),
});

export function systemMessageToJSON(systemMessage: SystemMessage): string {
  return JSON.stringify(SystemMessage$outboundSchema.parse(systemMessage));
}
