'use client';

import { lazy, Suspense } from 'react';
import { AppShell } from '@/components/layouts/AppShell/AppShell';
import { ProtectedRoute } from '@/components/common/ProtectedRoute';
import { LoadingFallback } from '@/components/common/LoadingFallback';
import { ErrorBoundary } from '@/components/common/ErrorBoundary';
import { ComponentErrorFallback } from '@/components/common/ErrorFallbacks';

// Lazy load the AI chat interface component
const AIChatInterface = lazy(() =>
  import('@/components/features/ai-chat/AIChatInterface').then((mod) => ({
    default: mod.AIChatInterface,
  }))
);

export default function AIAssistantPage() {
  return (
    <ProtectedRoute>
      <AppShell>
        <ErrorBoundary
          isolate
          fallback={<ComponentErrorFallback error={new Error('AI Assistant failed to load')} />}
        >
          <Suspense fallback={<LoadingFallback variant="chat" />}>
            <AIChatInterface />
          </Suspense>
        </ErrorBoundary>
      </AppShell>
    </ProtectedRoute>
  );
}
