"use client";
import { jsx } from 'react/jsx-runtime';
import { lazy } from 'react';
import { usePluginOverrides } from '@btst/stack/context';
import { ComposedRoute } from '@btst/stack/client/components';
import { DefaultError } from '../shared/default-error.mjs';
import { ChatLoading } from '../loading/index.mjs';
import { NotFoundPage } from './404-page.mjs';

const ChatPage = lazy(
  () => import('./chat-page.internal.mjs').then((m) => ({ default: m.ChatPage }))
);
function ChatPageComponent({ conversationId }) {
  const { onRouteError } = usePluginOverrides("ai-chat", {});
  return /* @__PURE__ */ jsx(
    ComposedRoute,
    {
      path: conversationId ? `/chat/${conversationId}` : "/chat",
      PageComponent: ChatPage,
      ErrorComponent: DefaultError,
      LoadingComponent: ChatLoading,
      NotFoundComponent: NotFoundPage,
      props: { conversationId },
      onError: (error) => {
        if (onRouteError) {
          onRouteError(conversationId ? "chatConversation" : "chat", error, {
            path: conversationId ? `/chat/${conversationId}` : "/chat",
            isSSR: typeof window === "undefined",
            params: conversationId ? { id: conversationId } : void 0
          });
        }
      }
    }
  );
}

export { ChatPageComponent };
