import SmartWordCloud from '../../SmartWordCloud.jsx';

/**
 * Dashboard · 词云图预览（扁平 props，由 PREVIEW_REGISTRY.mapProps 注入）
 */
export default function WordCloudPreview({
  data = [],
  datasets,
  chromeTitle,
  layout = 'square',
  categoryCount,
  categoryLabels,
  categoryColorTokens,
  showLegend = true,
  legendPosition = 'bottom',
  orientation = 'horizontal',
  height = 280,
  activeDatasetId,
  defaultDatasetId,
  onDatasetChange,
  style,
}) {
  return (
    <div
      className="smart-wordcloud-preview-scope"
      style={{
        display: 'block',
        width: '100%',
        maxWidth: 680,
        boxSizing: 'border-box',
        ...(style || {}),
      }}
    >
      <div style={{ width: '100%' }}>
        <SmartWordCloud
          data={datasets?.length ? [] : data}
          datasets={datasets}
          chromeTitle={chromeTitle}
          layout={layout}
          categoryCount={categoryCount}
          categoryLabels={categoryLabels}
          categoryColorTokens={categoryColorTokens}
          showLegend={showLegend}
          legendPosition={legendPosition}
          orientation={orientation}
          height={height}
          activeDatasetId={activeDatasetId}
          defaultDatasetId={defaultDatasetId}
          onDatasetChange={onDatasetChange}
          wordPadding={layout === 'circle' ? 2 : 2}
          maxWords={60}
        />
      </div>
    </div>
  );
}
