/*
 * 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 { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ChannelMapping,
  ChannelMapping$inboundSchema,
} from "./channelmapping.js";

export type MediaContainerWithDeviceDevice = {
  channelMapping?: Array<ChannelMapping> | undefined;
  key?: string | undefined;
  lastSeenAt?: number | undefined;
  make?: string | undefined;
  model?: string | undefined;
  modelNumber?: string | undefined;
  protocol?: string | undefined;
  sources?: string | undefined;
  state?: string | undefined;
  status?: string | undefined;
  tuners?: string | undefined;
  uri?: string | undefined;
  uuid?: string | 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 MediaContainerWithDeviceMediaContainer = {
  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;
  device?: Array<MediaContainerWithDeviceDevice> | undefined;
};

export type MediaContainerWithDevice = {
  mediaContainer?: MediaContainerWithDeviceMediaContainer | undefined;
};

/** @internal */
export const MediaContainerWithDeviceDevice$inboundSchema: z.ZodType<
  MediaContainerWithDeviceDevice,
  z.ZodTypeDef,
  unknown
> = z.object({
  ChannelMapping: z.array(ChannelMapping$inboundSchema).optional(),
  key: z.string().optional(),
  lastSeenAt: z.number().int().optional(),
  make: z.string().optional(),
  model: z.string().optional(),
  modelNumber: z.string().optional(),
  protocol: z.string().optional(),
  sources: z.string().optional(),
  state: z.string().optional(),
  status: z.string().optional(),
  tuners: z.string().optional(),
  uri: z.string().optional(),
  uuid: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "ChannelMapping": "channelMapping",
  });
});

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

/** @internal */
export const MediaContainerWithDeviceMediaContainer$inboundSchema: z.ZodType<
  MediaContainerWithDeviceMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  Device: z.array(z.lazy(() => MediaContainerWithDeviceDevice$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "Device": "device",
  });
});

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

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

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