// Local dev-reference copy — real scaffolds get this file's content from
// `generateHomePage()` in bin/cli.ts, not from this file on disk.
import React from 'react';
import { XerticaAssistant } from 'xertica-ui/assistant';
import { useLayout } from 'xertica-ui/hooks';
import { useNavigate } from 'react-router-dom';
import { AppLayout } from '../app/components/AppLayout';
import { HomeContent } from '../features/home';
import {
  useAssistantConfig,
  useFdmAssistant,
  getMockRichSuggestions,
  getMockFeedbackOptions,
} from '../features/assistant';

/**
 * Home page — thin layout shell.
 *
 * Assistant config (suggestions, feedback options) is fetched via React Query.
 * The lateral assistant talks to FDM's real Agent Engine via `useFdmAssistant`
 * (see server/fdm-proxy.mjs) — to connect to a different backend, replace
 * that hook.
 */
export function HomePage() {
  const { assistenteExpanded, toggleAssistente } = useLayout();
  const navigate = useNavigate();

  const { data: assistantConfig } = useAssistantConfig();
  const { assistantProps } = useFdmAssistant();

  return (
    <AppLayout
      assistant={
        <XerticaAssistant
          {...assistantProps}
          isExpanded={assistenteExpanded}
          onToggle={toggleAssistente}
          defaultTab="chat"
          suggestions={assistantConfig?.suggestions}
          richSuggestions={assistantConfig?.richSuggestions ?? getMockRichSuggestions()}
          feedbackOptions={assistantConfig?.feedbackOptions ?? getMockFeedbackOptions()}
          showHistory={false}
          showFavorites={false}
          onNavigateSettings={() => navigate('/settings')}
          onNavigateFullPage={() => navigate('/assistente')}
          onEvaluation={(messageId, type, reason) => {
            // Wire your feedback persistence logic here
            console.log(`Avaliação: ${type} na mensagem ${messageId}. Motivo: ${reason}`);
          }}
        />
      }
    >
      <HomeContent />
    </AppLayout>
  );
}
