/*
 * 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 {
  JudgeAttachment,
  JudgeAttachment$inboundSchema,
  JudgeAttachment$Outbound,
  JudgeAttachment$outboundSchema,
} from "./judgeattachment.js";

export type JudgeConfiguration = {
  /**
   * List of judges for this variation. When updating, this replaces all existing judge attachments, and if empty, removes all judge attachments.
   *
   * @remarks
   */
  judges?: Array<JudgeAttachment> | undefined;
};

/** @internal */
export const JudgeConfiguration$inboundSchema: z.ZodType<
  JudgeConfiguration,
  z.ZodTypeDef,
  unknown
> = z.object({
  judges: z.array(JudgeAttachment$inboundSchema).optional(),
});
/** @internal */
export type JudgeConfiguration$Outbound = {
  judges?: Array<JudgeAttachment$Outbound> | undefined;
};

/** @internal */
export const JudgeConfiguration$outboundSchema: z.ZodType<
  JudgeConfiguration$Outbound,
  z.ZodTypeDef,
  JudgeConfiguration
> = z.object({
  judges: z.array(JudgeAttachment$outboundSchema).optional(),
});

export function judgeConfigurationToJSON(
  judgeConfiguration: JudgeConfiguration,
): string {
  return JSON.stringify(
    JudgeConfiguration$outboundSchema.parse(judgeConfiguration),
  );
}
export function judgeConfigurationFromJSON(
  jsonString: string,
): SafeParseResult<JudgeConfiguration, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => JudgeConfiguration$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'JudgeConfiguration' from JSON`,
  );
}
