/* ─────────────────────────────────────────────────────────────────────────────
   DTTube — central content-type registry
   Every page that filters/renders by content_type imports from here.
───────────────────────────────────────────────────────────────────────────── */

export const CT = {
  VIDEO: 1,
  MUSIC: 2,
  REEL: 3,
  PODCAST: 4,
  PLAYLIST: 5,
  RADIO: 6,
} as const;

export type ContentTypeId = typeof CT[keyof typeof CT];

export type LayoutType =
  | "video-grid"    // landscape thumbnail grid — videos, live
  | "music-list"    // numbered track rows      — music
  | "reel-grid"     // portrait card grid       — reels
  | "podcast-list"; // wide row with cover art  — podcasts, radio

export interface ContentTypeConfig {
  id: ContentTypeId;
  label: string;
  emoji: string;
  layout: LayoutType;
}

export const CONTENT_TYPE_MAP: Record<number, ContentTypeConfig> = {
  [CT.VIDEO]: { id: CT.VIDEO, label: "Videos", emoji: "🎬", layout: "video-grid" },
  [CT.MUSIC]: { id: CT.MUSIC, label: "Music", emoji: "🎵", layout: "music-list" },
  [CT.REEL]: { id: CT.REEL, label: "Reels", emoji: "📱", layout: "reel-grid" },
  [CT.PODCAST]: { id: CT.PODCAST, label: "Podcasts", emoji: "🎙️", layout: "podcast-list" },
  [CT.PLAYLIST]: { id: CT.PLAYLIST, label: "Live", emoji: "🔴", layout: "video-grid" },
  [CT.RADIO]: { id: CT.RADIO, label: "Radio", emoji: "📻", layout: "podcast-list" },
};

/* Ordered tab lists per page ────────────────────────────────────────────── */

export const HISTORY_TABS: ContentTypeId[] = [CT.VIDEO, CT.MUSIC, CT.REEL, CT.PODCAST, CT.RADIO];
export const LIKED_TABS: ContentTypeId[] = [CT.VIDEO, CT.MUSIC, CT.REEL, CT.PODCAST, CT.RADIO];
export const WATCH_LATER_TABS: ContentTypeId[] = [CT.VIDEO, CT.MUSIC, CT.REEL, CT.PODCAST, CT.RADIO];

export function getLayout(contentTypeId: number): LayoutType {
  return CONTENT_TYPE_MAP[contentTypeId]?.layout ?? "video-grid";
}
