/*
 * 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";

/**
 * Describes both the purpose and intended presentation of the image.
 */
export enum ImageType {
  Background = "background",
  Banner = "banner",
  ClearLogo = "clearLogo",
  CoverPoster = "coverPoster",
  Snapshot = "snapshot",
}

/**
 * Images such as movie posters and background artwork are represented by Image elements.
 *
 * @remarks
 */
export type Image = {
  /**
   * Describes both the purpose and intended presentation of the image.
   */
  type?: ImageType | undefined;
  /**
   * Title to use for accessibility.
   */
  alt?: string | undefined;
  /**
   * The relative path or absolute url for the image.
   */
  url?: string | undefined;
};

/** @internal */
export const ImageType$inboundSchema: z.ZodNativeEnum<typeof ImageType> = z
  .nativeEnum(ImageType);

/** @internal */
export const Image$inboundSchema: z.ZodType<Image, z.ZodTypeDef, unknown> = z
  .object({
    type: ImageType$inboundSchema.optional(),
    alt: z.string().optional(),
    url: z.string().optional(),
  });

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