// Rôle : assemble le hero et les sous-pages Monster Hunter Wilds.
import { MhwildsListing } from "./MhwildsListing.jsx";
import { MhwildsLists } from "./MhwildsLists.jsx";
import { MhwildsOverview } from "./MhwildsOverview.jsx";

export function MhwildsPage({ category, game, mhwilds, filters, setFilters, t, links, actions }) {
  const activeCategory = category === "monsters" || category === "endemic" || category === "lists" ? category : "";
  const heroStyle = game?.images?.heroBg ? { "--game-hero-image": `url("${game.images.heroBg}")` } : undefined;

  if (!mhwilds.loaded) {
    return (
      <>
        <section className="game-hero" style={heroStyle}>
          <div>
            <p className="eyebrow">Monster Hunter Wilds</p>
            <h1>Monster Hunter: Wilds</h1>
            <p>Chargement des données de chasse, faune endémique et filtres associés.</p>
          </div>
        </section>
        <section className="empty">
          <h2>Chargement</h2>
          <p>Préparation des données locales...</p>
        </section>
      </>
    );
  }

  if (mhwilds.error) {
    return (
      <section className="empty">
        <h1>Impossible de charger MH Wilds</h1>
        <p>{mhwilds.error}</p>
      </section>
    );
  }

  if (!activeCategory) return <MhwildsOverview game={game} />;
  if (activeCategory === "lists") return <MhwildsLists game={game} mhwilds={mhwilds} linkedToolboxId={links?.[game.id] || ""} actions={actions} />;

  return (
    <MhwildsListing
      category={activeCategory}
      game={game}
      mhwilds={mhwilds}
      filters={filters}
      setFilters={setFilters}
      t={t}
    />
  );
}
