import {
  mediaKind,
  mediaSource,
  mediaUsageType,
  portfolioAssetKind,
  portfolioProjectViewMode,
  portfolioSectionType,
} from "./schema";

/**
 * Prisma-compatible enum objects + types, derived from the Drizzle pgEnums, so
 * existing consumers can keep writing `MediaKind.IMAGE` (value) and `: MediaKind`
 * (type) — only the import path changes from `@prisma/client` to `@/lib/db/enums`.
 */
function asEnum<T extends string>(values: readonly T[]): { [K in T]: K } {
  return Object.fromEntries(values.map((v) => [v, v])) as { [K in T]: K };
}

export const MediaKind = asEnum(mediaKind.enumValues);
export type MediaKind = (typeof mediaKind.enumValues)[number];

export const MediaSource = asEnum(mediaSource.enumValues);
export type MediaSource = (typeof mediaSource.enumValues)[number];

export const MediaUsageType = asEnum(mediaUsageType.enumValues);
export type MediaUsageType = (typeof mediaUsageType.enumValues)[number];

export const PortfolioAssetKind = asEnum(portfolioAssetKind.enumValues);
export type PortfolioAssetKind = (typeof portfolioAssetKind.enumValues)[number];

export const PortfolioProjectViewMode = asEnum(portfolioProjectViewMode.enumValues);
export type PortfolioProjectViewMode = (typeof portfolioProjectViewMode.enumValues)[number];

export const PortfolioSectionType = asEnum(portfolioSectionType.enumValues);
export type PortfolioSectionType = (typeof portfolioSectionType.enumValues)[number];
