"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const React = require('react');
const context = require('@btst/stack/context');
const components = require('@btst/stack/client/components');
const defaultError = require('../shared/default-error.cjs');
const index = require('../loading/index.cjs');
const _404Page = require('./404-page.cjs');

const ChatPage = React.lazy(
  () => import('./chat-page.internal.cjs').then((m) => ({ default: m.ChatPage }))
);
function ChatPageComponent({ conversationId }) {
  const { onRouteError } = context.usePluginOverrides("ai-chat", {});
  return /* @__PURE__ */ jsxRuntime.jsx(
    components.ComposedRoute,
    {
      path: conversationId ? `/chat/${conversationId}` : "/chat",
      PageComponent: ChatPage,
      ErrorComponent: defaultError.DefaultError,
      LoadingComponent: index.ChatLoading,
      NotFoundComponent: _404Page.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
          });
        }
      }
    }
  );
}

exports.ChatPageComponent = ChatPageComponent;
