"use client";

import { AiLessonContentGenerator } from "@/modules/ai/components/ai-lesson-content-generator";
import { useAiClientOptional } from "@/modules/ai/context/ai-client-provider";
import type { AiContentGeneratorSlotProps } from "@/modules/lesson-preparation/components/node-edit-panel";

/**
 * P0-11 修复：AI 内容生成器 slot 实现。
 * 此组件在 app 层组合 @/modules/ai 的具体实现，
 * 通过 props 注入到 lesson-preparation 模块的 NodeEditPanel，
 * 避免备课模块直接依赖 @/modules/ai。
 */
export function AiContentGeneratorSlot({
  topic,
  textbookId,
  chapterId,
}: AiContentGeneratorSlotProps) {
  const aiClient = useAiClientOptional();
  if (!aiClient) return null;
  return (
    <AiLessonContentGenerator
      topic={topic}
      textbookId={textbookId}
      chapterId={chapterId}
    />
  );
}
