---
import Base from "../layouts/Base.astro";
import Root from "../components/AppLayout.jsx";
import "@styles/DiscordLogs.css";

// Auth + role check handled by middleware
// Middleware redirects to /login if not authenticated or lacks 'discord' role
const user = Astro.locals.user as any;

// Prevent browser caching of authenticated pages
Astro.response.headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, private');
Astro.response.headers.set('Pragma', 'no-cache');
---

<Base title="Discord Archive" description="Archived Discord channel logs">
  <script is:inline>
    // Suppress "unreachable code" warnings from YouTube's embedded player
    (function() {
      const originalWarn = console.warn;
      console.warn = function(...args) {
        if (args[0] && typeof args[0] === 'string' && args[0].includes('unreachable code')) {
          return; // Suppress YouTube player warnings
        }
        originalWarn.apply(console, args);
      };
    })();
  </script>
  <section class="page-section discord-logs-section">
    <Root child="DiscordLogs" client:only="react" />
  </section>
</Base>

<style is:global>
  /* Override main container width for Discord logs */
  body:has(.discord-logs-section) main {
    max-width: 1400px !important;
  }
</style>
