import { useMemo } from 'react'
import { useSearchParams } from 'react-router-dom'
import VisitorChat from '@/widgets/VisitorChat'

/** 供 widget.js iframe 嵌入的无边框页面 */
const WidgetEmbed = () => {
  const [params] = useSearchParams()
  const channelKey = useMemo(() => params.get('channel_key') || 'WK_8a3f2e', [params])
  const embedded = params.get('embedded') === '1'

  return (
    <div className="h-screen w-screen overflow-hidden bg-transparent">
      <VisitorChat
        defaultOpen
        channelKey={channelKey}
        embedded={embedded}
        layout={embedded ? 'fill' : 'floating'}
      />
    </div>
  )
}

export default WidgetEmbed
