/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 4d03ddfe5100
 */

import * as z from "zod/v4";
import { Unrecognized, unrecognized } from "./unrecognized.js";

export type ClosedEnum<T extends Readonly<Record<string, string | number>>> =
  T[keyof T];
export type OpenEnum<T extends Readonly<Record<string, string | number>>> =
  | T[keyof T]
  | Unrecognized<T[keyof T] extends number ? number : string>;

export function inboundSchema<T extends Record<string, string>>(
  enumObj: T,
): z.ZodType<OpenEnum<T>, unknown> {
  const options = Object.values(enumObj);
  return z.union([
    ...options.map(x => z.literal(x)),
    z.string().transform(x => unrecognized(x)),
  ] as any);
}

export function inboundSchemaInt<T extends Record<string, number | string>>(
  enumObj: T,
): z.ZodType<OpenEnum<T>, unknown> {
  // For numeric enums, Object.values returns both numbers and string keys
  const options = Object.values(enumObj).filter(v => typeof v === "number");
  return z.union([
    ...options.map(x => z.literal(x)),
    z.int().transform(x => unrecognized(x)),
  ] as any);
}

export function outboundSchema<T extends Record<string, string>>(
  _: T,
): z.ZodType<string, OpenEnum<T>> {
  return z.string() as any;
}

export function outboundSchemaInt<T extends Record<string, number | string>>(
  _: T,
): z.ZodType<number, OpenEnum<T>> {
  return z.int() as any;
}
