import { lazy, Suspense, useState } from 'react'
import TeamFoundationApp from './TeamFoundationApp'

const KnowledgeWorkspace = lazy(() => import('./App'))

export default function TeamFoundationRoot() {
  const [surface, setSurface] = useState<'lighthouse' | 'knowledge'>('lighthouse')

  if (surface === 'lighthouse') {
    return <TeamFoundationApp onOpenKnowledgeSpace={() => setSurface('knowledge')} />
  }

  return (
    <Suspense fallback={<div className="team-foundation__loading">正在打开 AI 知识空间…</div>}>
      <KnowledgeWorkspace distribution="team" onReturnToLighthouse={() => setSurface('lighthouse')} />
    </Suspense>
  )
}
