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

import * as z from "zod/v3";
import { remap as remap$ } from "../../../lib/primitives.js";
import {
  collectExtraKeys as collectExtraKeys$,
  safeParse,
} from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { RFCDate } from "../../types/rfcdate.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { Filter, Filter$inboundSchema } from "./filter.js";
import { Image, Image$inboundSchema } from "./image.js";
import { Sort, Sort$inboundSchema } from "./sort.js";
import { Tag, Tag$inboundSchema } from "./tag.js";

export type MediaContainerWithDecisionGuid = {
  /**
   * The unique identifier for the Guid. Can be prefixed with imdb://, tmdb://, tvdb://
   *
   * @remarks
   */
  id: string;
};

export enum StreamDecision {
  Copy = "copy",
  Transcode = "transcode",
  Burn = "burn",
  Unavailable = "unavailable",
  Ignore = "ignore",
  None = "none",
}

export enum MediaContainerWithDecisionLocation {
  Direct = "direct",
  SidecarSubs = "sidecar-subs",
  SegmentsVideo = "segments-video",
  SegmentsAudio = "segments-audio",
  SegmentsAv = "segments-av",
  SegmentsSubs = "segments-subs",
  Embedded = "embedded",
  Sidecar = "sidecar",
}

/**
 * `Stream` represents a particular stream from a media item, such as the video stream, audio stream, or subtitle stream. The stream may either be part of the file represented by the parent `Part` or, especially for subtitles, an external file. The stream contains more detailed information about the specific stream. For example, a video may include the `aspectRatio` at the `Media` level, but detailed information about the video stream like the color space will be included on the `Stream` for the video stream.  Note that photos do not have streams (mostly as an optimization).
 *
 * @remarks
 */
export type MediaContainerWithDecisionStream = {
  /**
   * Indicates if this stream is default.
   */
  default?: boolean | undefined;
  /**
   * Audio channel layout.
   */
  audioChannelLayout?: string | undefined;
  /**
   * Number of audio channels (for audio streams).
   */
  channels?: number | undefined;
  /**
   * Bit depth of the video stream.
   */
  bitDepth?: number | undefined;
  /**
   * Dolby Vision BL compatibility ID.
   */
  doviblCompatID?: number | undefined;
  /**
   * Indicates if Dolby Vision BL is present.
   */
  doviblPresent?: boolean | undefined;
  /**
   * Indicates if Dolby Vision EL is present.
   */
  dovielPresent?: boolean | undefined;
  /**
   * Dolby Vision level.
   */
  doviLevel?: number | undefined;
  /**
   * Indicates if Dolby Vision is present.
   */
  doviPresent?: boolean | undefined;
  /**
   * Dolby Vision profile.
   */
  doviProfile?: number | undefined;
  /**
   * Indicates if Dolby Vision RPU is present.
   */
  dovirpuPresent?: boolean | undefined;
  /**
   * Dolby Vision version.
   */
  doviVersion?: string | undefined;
  /**
   * Bitrate of the stream.
   */
  bitrate?: number | undefined;
  /**
   * Indicates if the stream can auto-sync.
   */
  canAutoSync?: boolean | undefined;
  /**
   * Chroma sample location.
   */
  chromaLocation?: string | undefined;
  /**
   * Chroma subsampling format.
   */
  chromaSubsampling?: string | undefined;
  /**
   * Coded video height.
   */
  codedHeight?: number | undefined;
  /**
   * Coded video width.
   */
  codedWidth?: number | undefined;
  closedCaptions?: boolean | undefined;
  /**
   * Codec used by the stream.
   */
  codec: string;
  /**
   * Color primaries used.
   */
  colorPrimaries?: string | undefined;
  /**
   * Color range (e.g., tv).
   */
  colorRange?: string | undefined;
  /**
   * Color space.
   */
  colorSpace?: string | undefined;
  /**
   * Color transfer characteristics.
   */
  colorTrc?: string | undefined;
  /**
   * Display title for the stream.
   */
  displayTitle: string;
  /**
   * Extended display title for the stream.
   */
  extendedDisplayTitle?: string | undefined;
  /**
   * Frame rate of the stream.
   */
  frameRate?: number | undefined;
  hasScalingMatrix?: boolean | undefined;
  /**
   * Height of the video stream.
   */
  height?: number | undefined;
  /**
   * Unique stream identifier.
   */
  id: number;
  /**
   * Index of the stream.
   */
  index?: number | undefined;
  /**
   * Key to access this stream part.
   */
  key: string;
  /**
   * Language of the stream.
   */
  language?: string | undefined;
  /**
   * ISO language code.
   */
  languageCode?: string | undefined;
  /**
   * Language tag (e.g., en).
   */
  languageTag?: string | undefined;
  /**
   * Format of the stream (e.g., srt).
   */
  format?: string | undefined;
  /**
   * Indicates whether header compression is enabled.
   */
  headerCompression?: boolean | undefined;
  /**
   * Video level.
   */
  level?: number | undefined;
  /**
   * Indicates if this is the original stream.
   */
  original?: boolean | undefined;
  /**
   * Video profile.
   */
  profile?: string | undefined;
  /**
   * Number of reference frames.
   */
  refFrames?: number | undefined;
  /**
   * Sampling rate for the audio stream.
   */
  samplingRate?: number | undefined;
  scanType?: string | undefined;
  embeddedInVideo?: string | undefined;
  /**
   * Indicates if this stream is selected (applicable for audio streams).
   */
  selected?: boolean | undefined;
  forced?: boolean | undefined;
  /**
   * Indicates if the stream is for the hearing impaired.
   */
  hearingImpaired?: boolean | undefined;
  /**
   * Indicates if the stream is a dub.
   */
  dub?: boolean | undefined;
  /**
   * Optional title for the stream (e.g., language variant).
   */
  title?: string | undefined;
  streamIdentifier?: number | undefined;
  /**
   * Stream type:
   *
   * @remarks
   *   - VIDEO = 1
   *   - AUDIO = 2
   *   - SUBTITLE = 3
   */
  streamType?: 1 | undefined;
  /**
   * Width of the video stream.
   */
  width?: number | undefined;
  decision?: StreamDecision | undefined;
  location?: MediaContainerWithDecisionLocation | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

export enum Decision {
  Directplay = "directplay",
  Transcode = "transcode",
  None = "none",
}

/**
 * `Part` represents a particular file or "part" of a media item. The part is the playable unit of the media hierarchy. Suppose that a movie library contains a movie that is broken up into files, reminiscent of a movie split across two BDs. The metadata item represents information about the movie, the media item represents this instance of the movie at this resolution and quality, and the part items represent the two playable files.  If another media were added which contained the joining of these two parts transcoded down to a lower resolution, then this metadata would contain 2 medias, one with 2 parts and one with 1 part.
 *
 * @remarks
 */
export type MediaContainerWithDecisionPart = {
  /**
   * Indicates if the part is accessible.
   */
  accessible?: boolean | undefined;
  audioProfile?: string | undefined;
  /**
   * The container of the media file, such as `mp4` or `mkv`
   */
  container?: string | undefined;
  /**
   * The duration of the media item, in milliseconds
   */
  duration?: number | undefined;
  /**
   * Indicates if the part exists.
   */
  exists?: boolean | undefined;
  /**
   * The local file path at which the part is stored on the server
   */
  file?: string | undefined;
  has64bitOffsets?: boolean | undefined;
  id: number;
  indexes?: string | undefined;
  /**
   * The key from which the media can be streamed
   */
  key: string;
  optimizedForStreaming?: boolean | undefined;
  /**
   * The size of the media, in bytes
   */
  size?: number | undefined;
  stream?: Array<MediaContainerWithDecisionStream> | undefined;
  videoProfile?: string | undefined;
  decision?: Decision | undefined;
  selected?: boolean | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

/**
 * `Media` represents an one or more media files (parts) and is a child of a metadata item. There aren't necessarily any guaranteed attributes on media elements since the attributes will vary based on the type. The possible attributes are not documented here, but they typically have self-evident names. High-level media information that can be used for badging and flagging, such as `videoResolution` and codecs, is included on the media element.
 *
 * @remarks
 */
export type MediaContainerWithDecisionMedia = {
  aspectRatio?: number | undefined;
  audioChannels?: number | undefined;
  audioCodec?: string | undefined;
  audioProfile?: string | undefined;
  bitrate?: number | undefined;
  container?: string | undefined;
  duration?: number | undefined;
  has64bitOffsets?: boolean | undefined;
  hasVoiceActivity?: boolean | undefined;
  height?: number | undefined;
  id: number;
  optimizedForStreaming?: boolean | undefined;
  part?: Array<MediaContainerWithDecisionPart> | undefined;
  videoCodec?: string | undefined;
  videoFrameRate?: string | undefined;
  videoProfile?: string | undefined;
  videoResolution?: string | undefined;
  width?: number | undefined;
  abr?: boolean | undefined;
  resourceSession?: string | undefined;
  selected?: boolean | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

/**
 * Items in a library are referred to as "metadata items." These metadata items are distinct from "media items" which represent actual instances of media that can be consumed. Consider a TV library that has a single video file in it for a particular episode of a show. The library has a single media item, but it has three metadata items: one for the show, one for the season, and one for the episode. Consider a movie library that has two video files in it: the same movie, but two different resolutions. The library has a single metadata item for the movie, but that metadata item has two media items, one for each resolution. Additionally a "media item" will have one or more "media parts" where the the parts are intended to be watched together, such as a CD1 and CD2 parts of the same movie.
 *
 * @remarks
 *
 * Note that when a metadata item has multiple media items, those media items should be isomorphic. That is, a 4K version and 1080p version of a movie are different versions of the same movie. They have the same duration, same summary, same rating, etc. and they can generally be considered interchangeable. A theatrical release vs. director's cut vs. unrated version on the other hand would be separate metadata items.
 *
 * Metadata items can often live in a hierarchy with relationships between them.  For example, the metadata item for an episodes is associated with a season metadata item which is associated with a show metadata item.  A similar hierarchy exists with track, album, and artist and photos and photo album.  The relationships may be expressed via relative terms and absolute terms.  For example, "leaves" refer to metadata items which has associated media (there is no media for a season nor show).  A show will have "children" in the form of seasons and a season will have "children" in the form of episodes and episodes have "parent" in the form of a season which has a "parent" in the form of a show.  Similarly, a show has "grandchildren" in the form of episodse and an episode has a "grandparent" in the form of a show.
 */
export type MediaContainerWithDecisionMetadatum = {
  /**
   * The title of the item (e.g. “300” or “The Simpsons”)
   */
  title: string;
  /**
   * The type of the video item, such as `movie`, `episode`, or `clip`.
   */
  type: string;
  /**
   * When present, contains the disc number for a track on multi-disc albums.
   */
  absoluteIndex?: number | undefined;
  /**
   * In units of seconds since the epoch, returns the time at which the item was added to the library.
   */
  addedAt: number;
  /**
   * When present, the URL for the background artwork for the item.
   */
  art?: string | undefined;
  /**
   * Some rating systems separate reviewer ratings from audience ratings
   */
  audienceRating?: number | undefined;
  /**
   * A URI representing the image to be shown with the audience rating (e.g. rottentomatoes://image.rating.spilled).
   */
  audienceRatingImage?: string | undefined;
  autotag?: Array<Tag> | undefined;
  /**
   * When present, the URL for a banner graphic for the item.
   */
  banner?: string | undefined;
  /**
   * When present, indicates the source for the chapters in the media file. Can be media (the chapters were embedded in the media itself), agent (a metadata agent computed them), or mixed (a combination of the two).
   */
  chapterSource?: string | undefined;
  /**
   * The number of child items associated with this media item.
   */
  childCount?: number | undefined;
  /**
   * When present, the URL for a composite image for descendent items (e.g. photo albums or playlists).
   */
  composite?: string | undefined;
  /**
   * If known, the content rating (e.g. MPAA) for an item.
   */
  contentRating?: string | undefined;
  country?: Array<Tag> | undefined;
  director?: Array<Tag> | undefined;
  /**
   * When present, the duration for the item, in units of milliseconds.
   */
  duration?: number | undefined;
  /**
   * Typically only seen in metadata at a library's top level
   */
  filter?: Array<Filter> | undefined;
  genre?: Array<Tag> | undefined;
  /**
   * The `art` of the grandparent
   */
  grandparentArt?: string | undefined;
  /**
   * The GUID of the grandparent media item.
   */
  grandparentGuid?: string | undefined;
  /**
   * The `hero` of the grandparent
   */
  grandparentHero?: string | undefined;
  /**
   * The `key` of the grandparent
   */
  grandparentKey?: string | undefined;
  /**
   * The `ratingKey` of the grandparent
   */
  grandparentRatingKey?: string | undefined;
  /**
   * The `theme` of the grandparent
   */
  grandparentTheme?: string | undefined;
  /**
   * The `thumb` of the grandparent
   */
  grandparentThumb?: string | undefined;
  /**
   * The `title` of the grandparent
   */
  grandparentTitle?: string | undefined;
  /**
   * The globally unique identifier for the media item.
   */
  guid?: string | undefined;
  guids?: Array<MediaContainerWithDecisionGuid> | undefined;
  /**
   * When present, the URL for a hero image for the item.
   */
  hero?: string | undefined;
  image?: Array<Image> | undefined;
  /**
   * When present, this represents the episode number for episodes, season number for seasons, or track number for audio tracks.
   */
  index?: number | undefined;
  /**
   * The key at which the item's details can be fetched.  In many cases a metadata item may be passed without all the details (such as in a hub) and this key corresponds to the endpoint to fetch additional details.
   */
  key: string;
  lastViewedAt?: number | undefined;
  /**
   * For shows and seasons, contains the number of total episodes.
   */
  leafCount?: number | undefined;
  media?: Array<MediaContainerWithDecisionMedia> | undefined;
  /**
   * When present, in the format YYYY-MM-DD [HH:MM:SS] (the hours/minutes/seconds part is not always present). The air date, or a higher resolution release date for an item, depending on type. For example, episodes usually have air date like 1979-08-10 (we don't use epoch seconds because media existed prior to 1970). In some cases, recorded over-the-air content has higher resolution air date which includes a time component. Albums and movies may have day-resolution release dates as well.
   */
  originallyAvailableAt?: RFCDate | undefined;
  /**
   * When present, used to indicate an item's original title, e.g. a movie's foreign title.
   */
  originalTitle?: string | undefined;
  /**
   * The GUID of the parent media item.
   */
  parentGuid?: string | undefined;
  /**
   * The `hero` of the parent
   */
  parentHero?: string | undefined;
  /**
   * The `index` of the parent
   */
  parentIndex?: number | undefined;
  /**
   * The `key` of the parent
   */
  parentKey?: string | undefined;
  /**
   * The `ratingKey` of the parent
   */
  parentRatingKey?: string | undefined;
  /**
   * The `thumb` of the parent
   */
  parentThumb?: string | undefined;
  /**
   * The `title` of the parent
   */
  parentTitle?: string | undefined;
  /**
   * Indicates that the item has a primary extra; for a movie, this is a trailer, and for a music track it is a music video. The URL points to the metadata details endpoint for the item.
   */
  primaryExtraKey?: string | undefined;
  /**
   * Prompt to give the user for this directory (such as `Search Movies`)
   */
  prompt?: string | undefined;
  /**
   * When present, the rating for the item. The exact meaning and representation depends on where the rating was sourced from.
   */
  rating?: number | undefined;
  ratingArray?: Array<Tag> | undefined;
  /**
   * Number of ratings under this metadata
   */
  ratingCount?: number | undefined;
  /**
   * When present, indicates an image to be shown with the rating. This is passed back as a small set of defined URI values, e.g. rottentomatoes://image.rating.rotten.
   */
  ratingImage?: string | undefined;
  /**
   * This is the opaque string to be passed into timeline, scrobble, and rating endpoints to identify them.  While it often appears to be numeric, this is not guaranteed.
   */
  ratingKey?: string | undefined;
  role?: Array<Tag> | undefined;
  /**
   * Indicates this is a search directory
   */
  search?: boolean | undefined;
  /**
   * Used by old clients to provide nested menus allowing for primative (but structured) navigation.
   */
  secondary?: boolean | undefined;
  /**
   * When found on a show item, indicates that the children (seasons) should be skipped in favor of the grandchildren (episodes). Useful for mini-series, etc.
   */
  skipChildren?: boolean | undefined;
  /**
   * When present on an episode or track item, indicates parent should be skipped in favor of grandparent (show).
   */
  skipParent?: boolean | undefined;
  /**
   * Typically only seen in metadata at a library's top level
   */
  sort?: Array<Sort> | undefined;
  /**
   * When present, the studio or label which produced an item (e.g. movie studio for movies, record label for albums).
   */
  studio?: string | undefined;
  /**
   * The subtype of the video item, such as `photo` when the video item is in a photo library
   */
  subtype?: string | undefined;
  /**
   * When present, the extended textual information about the item (e.g. movie plot, artist biography, album review).
   */
  summary?: string | undefined;
  /**
   * When present, a pithy one-liner about the item (usually only seen for movies).
   */
  tagline?: string | undefined;
  /**
   * When present, the URL for theme music for the item (usually only for TV shows).
   */
  theme?: string | undefined;
  /**
   * When present, the URL for the poster or thumbnail for the item. When available for types like movie, it will be the poster graphic, but fall-back to the extracted media thumbnail.
   */
  thumb?: string | undefined;
  /**
   * Whene present, this is the string used for sorting the item. It's usually the title with any leading articles removed (e.g. “Simpsons”).
   */
  titleSort?: string | undefined;
  /**
   * In units of seconds since the epoch, returns the time at which the item was last changed (e.g. had its metadata updated).
   */
  updatedAt?: number | undefined;
  /**
   * When the user has rated an item, this contains the user rating
   */
  userRating?: number | undefined;
  /**
   * When a users has completed watched or listened to an item, this attribute contains the number of consumptions.
   */
  viewCount?: number | undefined;
  /**
   * For shows and seasons, contains the number of viewed episodes.
   */
  viewedLeafCount?: number | undefined;
  /**
   * When a user is in the process of viewing or listening to this item, this attribute contains the current offset, in units of milliseconds.
   */
  viewOffset?: number | undefined;
  writer?: Array<Tag> | undefined;
  /**
   * When present, the year associated with the item's release (e.g. release year for a movie).
   */
  year?: number | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

/**
 * `MediaContainer` is the root element of most Plex API responses. It serves as a generic container for various types of content (Metadata, Hubs, Directories, etc.) and includes pagination information (offset, size, totalSize) when applicable.
 *
 * @remarks
 * Common attributes: - identifier: Unique identifier for this container - size: Number of items in this response page - totalSize: Total number of items available (for pagination) - offset: Starting index of this page (for pagination)
 * The container often "hoists" common attributes from its children. For example, if all tracks in a container share the same album title, the `parentTitle` attribute may appear on the MediaContainer rather than being repeated on each track.
 */
export type MediaContainerWithDecisionMediaContainer = {
  identifier?: string | undefined;
  /**
   * The offset of where this container page starts among the total objects available. Also provided in the `X-Plex-Container-Start` header.
   *
   * @remarks
   */
  offset?: number | undefined;
  size?: number | undefined;
  /**
   * The total size of objects available. Also provided in the `X-Plex-Container-Total-Size` header.
   *
   * @remarks
   */
  totalSize?: number | undefined;
  /**
   * The maximum available bitrate when the decision was rendered.
   */
  availableBandwidth?: number | undefined;
  directPlayDecisionCode?: number | undefined;
  directPlayDecisionText?: string | undefined;
  /**
   * The overall decision. 1xxx are playback can succeed, 2xxx are a general error (such as insufficient bandwidth), 3xxx are errors in direct play, and 4xxx are errors in transcodes. Same codes are used in all.
   */
  generalDecisionCode?: number | undefined;
  generalDecisionText?: string | undefined;
  /**
   * The code indicating the status of evaluation of playback when client indicates `hasMDE=1`
   */
  mdeDecisionCode?: number | undefined;
  /**
   * Descriptive text for the above code
   */
  mdeDecisionText?: string | undefined;
  metadata?: Array<MediaContainerWithDecisionMetadatum> | undefined;
  transcodeDecisionCode?: number | undefined;
  transcodeDecisionText?: string | undefined;
};

/**
 * `MediaContainer` is commonly found as the root of a response and is a pretty generic container. Common attributes include `identifier` and things related to paging (`offset`, `size`, `totalSize`).
 *
 * @remarks
 *
 * It is also common for a `MediaContainer` to contain attributes "hoisted" from its children. If every element in the container would have had the same attribute, then that attribute can be present on the container instead of being repeated on every element. For example, an album's list of tracks might include `parentTitle` on the container since all of the tracks have the same album title. A container may have a `source` attribute when all of the items came from the same source. Generally speaking, when looking for an attribute on an item, if the attribute wasn't found then the container should be checked for that attribute as well.
 */
export type MediaContainerWithDecision = {
  mediaContainer?: MediaContainerWithDecisionMediaContainer | undefined;
};

/** @internal */
export const MediaContainerWithDecisionGuid$inboundSchema: z.ZodType<
  MediaContainerWithDecisionGuid,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
});

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

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

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

/** @internal */
export const MediaContainerWithDecisionStream$inboundSchema: z.ZodType<
  MediaContainerWithDecisionStream,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    default: z.boolean().optional(),
    audioChannelLayout: z.string().optional(),
    channels: z.number().int().optional(),
    bitDepth: z.number().int().optional(),
    DOVIBLCompatID: z.number().int().optional(),
    DOVIBLPresent: z.boolean().optional(),
    DOVIELPresent: z.boolean().optional(),
    DOVILevel: z.number().int().optional(),
    DOVIPresent: z.boolean().optional(),
    DOVIProfile: z.number().int().optional(),
    DOVIRPUPresent: z.boolean().optional(),
    DOVIVersion: z.string().optional(),
    bitrate: z.number().int().optional(),
    canAutoSync: z.boolean().optional(),
    chromaLocation: z.string().optional(),
    chromaSubsampling: z.string().optional(),
    codedHeight: z.number().int().optional(),
    codedWidth: z.number().int().optional(),
    closedCaptions: z.boolean().optional(),
    codec: z.string(),
    colorPrimaries: z.string().optional(),
    colorRange: z.string().optional(),
    colorSpace: z.string().optional(),
    colorTrc: z.string().optional(),
    displayTitle: z.string(),
    extendedDisplayTitle: z.string().optional(),
    frameRate: z.number().optional(),
    hasScalingMatrix: z.boolean().optional(),
    height: z.number().int().optional(),
    id: z.number().int(),
    index: z.number().int().optional(),
    key: z.string(),
    language: z.string().optional(),
    languageCode: z.string().optional(),
    languageTag: z.string().optional(),
    format: z.string().optional(),
    headerCompression: z.boolean().optional(),
    level: z.number().int().optional(),
    original: z.boolean().optional(),
    profile: z.string().optional(),
    refFrames: z.number().int().optional(),
    samplingRate: z.number().int().optional(),
    scanType: z.string().optional(),
    embeddedInVideo: z.string().optional(),
    selected: z.boolean().optional(),
    forced: z.boolean().optional(),
    hearingImpaired: z.boolean().optional(),
    dub: z.boolean().optional(),
    title: z.string().optional(),
    streamIdentifier: z.number().int().optional(),
    streamType: z.literal(1).default(1).optional(),
    width: z.number().int().optional(),
    decision: StreamDecision$inboundSchema.optional(),
    location: MediaContainerWithDecisionLocation$inboundSchema.optional(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
).transform((v) => {
  return remap$(v, {
    "DOVIBLCompatID": "doviblCompatID",
    "DOVIBLPresent": "doviblPresent",
    "DOVIELPresent": "dovielPresent",
    "DOVILevel": "doviLevel",
    "DOVIPresent": "doviPresent",
    "DOVIProfile": "doviProfile",
    "DOVIRPUPresent": "dovirpuPresent",
    "DOVIVersion": "doviVersion",
  });
});

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

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

/** @internal */
export const MediaContainerWithDecisionPart$inboundSchema: z.ZodType<
  MediaContainerWithDecisionPart,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    accessible: z.boolean().optional(),
    audioProfile: z.string().optional(),
    container: z.string().optional(),
    duration: z.number().int().optional(),
    exists: z.boolean().optional(),
    file: z.string().optional(),
    has64bitOffsets: z.boolean().optional(),
    id: z.number().int(),
    indexes: z.string().optional(),
    key: z.string(),
    optimizedForStreaming: z.boolean().optional(),
    size: z.number().int().optional(),
    Stream: z.array(
      z.lazy(() => MediaContainerWithDecisionStream$inboundSchema),
    ).optional(),
    videoProfile: z.string().optional(),
    decision: Decision$inboundSchema.optional(),
    selected: z.boolean().optional(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
).transform((v) => {
  return remap$(v, {
    "Stream": "stream",
  });
});

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

/** @internal */
export const MediaContainerWithDecisionMedia$inboundSchema: z.ZodType<
  MediaContainerWithDecisionMedia,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    aspectRatio: z.number().optional(),
    audioChannels: z.number().int().optional(),
    audioCodec: z.string().optional(),
    audioProfile: z.string().optional(),
    bitrate: z.number().int().optional(),
    container: z.string().optional(),
    duration: z.number().int().optional(),
    has64bitOffsets: z.boolean().optional(),
    hasVoiceActivity: z.boolean().optional(),
    height: z.number().int().optional(),
    id: z.number().int(),
    optimizedForStreaming: z.boolean().optional(),
    Part: z.array(z.lazy(() => MediaContainerWithDecisionPart$inboundSchema))
      .optional(),
    videoCodec: z.string().optional(),
    videoFrameRate: z.string().optional(),
    videoProfile: z.string().optional(),
    videoResolution: z.string().optional(),
    width: z.number().int().optional(),
    abr: z.boolean().optional(),
    resourceSession: z.string().optional(),
    selected: z.boolean().optional(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
).transform((v) => {
  return remap$(v, {
    "Part": "part",
  });
});

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

/** @internal */
export const MediaContainerWithDecisionMetadatum$inboundSchema: z.ZodType<
  MediaContainerWithDecisionMetadatum,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    title: z.string(),
    type: z.string(),
    absoluteIndex: z.number().int().optional(),
    addedAt: z.number().int(),
    art: z.string().optional(),
    audienceRating: z.number().optional(),
    audienceRatingImage: z.string().optional(),
    Autotag: z.array(Tag$inboundSchema).optional(),
    banner: z.string().optional(),
    chapterSource: z.string().optional(),
    childCount: z.number().int().optional(),
    composite: z.string().optional(),
    contentRating: z.string().optional(),
    Country: z.array(Tag$inboundSchema).optional(),
    Director: z.array(Tag$inboundSchema).optional(),
    duration: z.number().int().optional(),
    Filter: z.array(Filter$inboundSchema).optional(),
    Genre: z.array(Tag$inboundSchema).optional(),
    grandparentArt: z.string().optional(),
    grandparentGuid: z.string().optional(),
    grandparentHero: z.string().optional(),
    grandparentKey: z.string().optional(),
    grandparentRatingKey: z.string().optional(),
    grandparentTheme: z.string().optional(),
    grandparentThumb: z.string().optional(),
    grandparentTitle: z.string().optional(),
    guid: z.string().optional(),
    Guid: z.array(z.lazy(() => MediaContainerWithDecisionGuid$inboundSchema))
      .optional(),
    hero: z.string().optional(),
    Image: z.array(Image$inboundSchema).optional(),
    index: z.number().int().optional(),
    key: z.string(),
    lastViewedAt: z.number().int().optional(),
    leafCount: z.number().int().optional(),
    Media: z.array(z.lazy(() => MediaContainerWithDecisionMedia$inboundSchema))
      .optional(),
    originallyAvailableAt: z.string().transform(v => new RFCDate(v)).optional(),
    originalTitle: z.string().optional(),
    parentGuid: z.string().optional(),
    parentHero: z.string().optional(),
    parentIndex: z.number().int().optional(),
    parentKey: z.string().optional(),
    parentRatingKey: z.string().optional(),
    parentThumb: z.string().optional(),
    parentTitle: z.string().optional(),
    primaryExtraKey: z.string().optional(),
    prompt: z.string().optional(),
    rating: z.number().optional(),
    Rating: z.array(Tag$inboundSchema).optional(),
    ratingCount: z.number().int().optional(),
    ratingImage: z.string().optional(),
    ratingKey: z.string().optional(),
    Role: z.array(Tag$inboundSchema).optional(),
    search: z.boolean().optional(),
    secondary: z.boolean().optional(),
    skipChildren: z.boolean().optional(),
    skipParent: z.boolean().optional(),
    Sort: z.array(Sort$inboundSchema).optional(),
    studio: z.string().optional(),
    subtype: z.string().optional(),
    summary: z.string().optional(),
    tagline: z.string().optional(),
    theme: z.string().optional(),
    thumb: z.string().optional(),
    titleSort: z.string().optional(),
    updatedAt: z.number().int().optional(),
    userRating: z.number().optional(),
    viewCount: z.number().int().optional(),
    viewedLeafCount: z.number().int().optional(),
    viewOffset: z.number().int().optional(),
    Writer: z.array(Tag$inboundSchema).optional(),
    year: z.number().int().optional(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
).transform((v) => {
  return remap$(v, {
    "Autotag": "autotag",
    "Country": "country",
    "Director": "director",
    "Filter": "filter",
    "Genre": "genre",
    "Guid": "guids",
    "Image": "image",
    "Media": "media",
    "Rating": "ratingArray",
    "Role": "role",
    "Sort": "sort",
    "Writer": "writer",
  });
});

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

/** @internal */
export const MediaContainerWithDecisionMediaContainer$inboundSchema: z.ZodType<
  MediaContainerWithDecisionMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  availableBandwidth: z.number().int().optional(),
  directPlayDecisionCode: z.number().int().optional(),
  directPlayDecisionText: z.string().optional(),
  generalDecisionCode: z.number().int().optional(),
  generalDecisionText: z.string().optional(),
  mdeDecisionCode: z.number().int().optional(),
  mdeDecisionText: z.string().optional(),
  Metadata: z.array(
    z.lazy(() => MediaContainerWithDecisionMetadatum$inboundSchema),
  ).optional(),
  transcodeDecisionCode: z.number().int().optional(),
  transcodeDecisionText: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "Metadata": "metadata",
  });
});

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

/** @internal */
export const MediaContainerWithDecision$inboundSchema: z.ZodType<
  MediaContainerWithDecision,
  z.ZodTypeDef,
  unknown
> = z.object({
  MediaContainer: z.lazy(() =>
    MediaContainerWithDecisionMediaContainer$inboundSchema
  ).optional(),
}).transform((v) => {
  return remap$(v, {
    "MediaContainer": "mediaContainer",
  });
});

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