// Based mfs only use only one 500 line file instead of ten 50 line files.
import { useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import { get } from "@/backend/metadata/tmdb";
import { Divider } from "@/components/utils/Divider";
import { Flare } from "@/components/utils/Flare";
import { useIsMobile } from "@/hooks/useIsMobile";
import { conf } from "@/setup/config";
import {
Category,
Genre,
Media,
Movie,
TVShow,
categories,
tvCategories,
} from "@/utils/discover";
import { Icon, Icons } from "../components/Icon";
const editorPicks = [
{ id: 9342, type: "movie" }, // The Mask of Zorro
{ id: 293, type: "movie" }, // A River Runs Through It
{ id: 370172, type: "movie" }, // No Time To Die
{ id: 661374, type: "movie" }, // The Glass Onion
{ id: 207, type: "movie" }, // Dead Poets Society
{ id: 378785, type: "movie" }, // The Best of the Blues Brothers
{ id: 335984, type: "movie" }, // Blade Runner 2049
{ id: 13353, type: "movie" }, // It's the Great Pumpkin, Charlie Brown
{ id: 27205, type: "movie" }, // Inception
{ id: 106646, type: "movie" }, // The Wolf of Wall Street
{ id: 334533, type: "movie" }, // Captain Fantastic
{ id: 693134, type: "movie" }, // Dune: Part Two
{ id: 765245, type: "movie" }, // Swan Song
{ id: 264660, type: "movie" }, // Ex Machina
{ id: 92591, type: "movie" }, // Bernie
{ id: 976893, type: "movie" }, // Perfect Days
];
function ScrollToTopButton() {
const [isVisible, setIsVisible] = useState(false);
// Throttle scroll event for performance
const toggleVisibility = () => {
const scrolled = window.scrollY > 300; // Show button after 300px of scrolling
setIsVisible(scrolled);
};
useEffect(() => {
const handleScroll = () => {
// Throttle the scroll event to fire every 100ms for better performance
const timeout = setTimeout(toggleVisibility, 100);
return () => clearTimeout(timeout);
};
window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
return (
{/* Glow Effect (Behind the Button) */}
{/* Button */}
);
}
export function DiscoverContent() {
const [genres, setGenres] = useState([]);
const [randomMovie, setRandomMovie] = useState(null);
const [genreMovies, setGenreMovies] = useState<{
[genreId: number]: Movie[];
}>({});
const [providerMovies, setProviderMovies] = useState<{
[providerId: string]: Movie[];
}>({});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [selectedProvider, setSelectedProvider] = useState({
name: "",
id: "",
});
const [providerTVShows, setProviderTVShows] = useState<{
[providerId: string]: Movie[];
}>({});
const [selectedTVProvider, setSelectedTVProvider] = useState({
name: "",
id: "",
});
const movieProviders = [
{ name: "Netflix", id: "8" },
{ name: "Apple TV+", id: "2" },
{ name: "Amazon Prime Video", id: "10" },
{ name: "Hulu", id: "15" },
{ name: "Max", id: "1899" },
{ name: "Paramount Plus", id: "531" },
{ name: "Disney Plus", id: "337" },
{ name: "Shudder", id: "99" },
];
const tvProviders = [
{ name: "Netflix", id: "8" },
{ name: "Apple TV+", id: "350" },
{ name: "Paramount Plus", id: "531" },
{ name: "Hulu", id: "15" },
{ name: "Max", id: "1899" },
{ name: "Disney Plus", id: "337" },
{ name: "fubuTV", id: "257" },
];
const [countdown, setCountdown] = useState(null);
const navigate = useNavigate();
const [categoryShows, setCategoryShows] = useState<{
[categoryName: string]: Movie[];
}>({});
const [categoryMovies, setCategoryMovies] = useState<{
[categoryName: string]: Movie[];
}>({});
const [tvGenres, setTVGenres] = useState([]);
const [tvShowGenres, setTVShowGenres] = useState<{
[genreId: number]: TVShow[];
}>({});
const carouselRef = useRef(null);
const carouselRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
const gradientRef = useRef(null);
const [countdownTimeout, setCountdownTimeout] =
useState(null);
const { isMobile } = useIsMobile();
const [editorPicksData, setEditorPicksData] = useState([]);
// State to track selected category (movies or TV shows)
const [selectedCategory, setSelectedCategory] = useState("movies");
const [isDropdownOpen, setDropdownOpen] = useState(false);
// Handle category change for both event (from