'use client'

import { NovaChat } from '@/components/nova-sdk/nova-chat'
import { NovaState, useBuildConversationConnect } from '@/components/nova-sdk/hooks/useBuildConversationConnect'
import { Loader2 } from 'lucide-react'

export default function NovaChatPage() {
  const { chatEnabled, agentId, conversationId, platformConfig } = useBuildConversationConnect()

  if (chatEnabled === NovaState.Failed) {
    return (
      <div className="w-full h-screen flex items-center justify-center">
        <p className="text-muted-foreground">Chat 不可用，请检查项目 .env 配置</p>
      </div>
    )
  }

  if (!agentId || !conversationId || !platformConfig) {
    return (
      <div className="w-full h-screen flex items-center justify-center gap-2">
        <Loader2 className="w-4 h-4 text-primary animate-spin" />
        <p className="text-primary">正在连接中...</p>
      </div>
    )
  }

  return (
    <div className="h-screen">
      <NovaChat mode="share" conversationId={conversationId} platformConfig={platformConfig} />
    </div>
  )
}
