import { Toaster } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import NotFound from "@/pages/NotFound";
import { Route, Switch } from "wouter";
import ErrorBoundary from "./components/ErrorBoundary";
import { ThemeProvider } from "./contexts/ThemeContext";
import Login from "./pages/Login";
import Dashboard from "./pages/Dashboard";
import AuditLog from "./pages/AuditLog";
import RegulatoryMonitor from "./pages/RegulatoryMonitor";
import AdminLayout from "./components/AdminLayout";

/**
 * NAC 运维管理后台（ops/nac-admin）
 * 
 * 职责范围（仅限运维）：
 *   - Dashboard：节点状态监控、服务健康检查
 *   - AuditLog：系统操作审计日志
 *   - RegulatoryMonitor：合规监控
 * 
 * 已迁移到独立服务的功能：
 *   - KnowledgeBase → services/nac-knowledge-portal
 *   - Crawlers → services/nac-data-crawler
 *   - ApprovalCases/TagEngine → services/nac-rwa-portal
 *   - ProtocolRegistry → services/nac-protocol-registry
 */
function Router() {
  return (
    <Switch>
      <Route path="/login" component={Login} />
      <Route path="/" component={() => <AdminLayout><Dashboard /></AdminLayout>} />
      <Route path="/audit" component={() => <AdminLayout><AuditLog /></AdminLayout>} />
      <Route path="/regulatory" component={() => <AdminLayout><RegulatoryMonitor /></AdminLayout>} />
      <Route path="/404" component={NotFound} />
      <Route component={NotFound} />
    </Switch>
  );
}

function App() {
  return (
    <ErrorBoundary>
      <ThemeProvider defaultTheme="dark">
        <TooltipProvider>
          <Toaster />
          <Router />
        </TooltipProvider>
      </ThemeProvider>
    </ErrorBoundary>
  );
}

export default App;
