import { z } from "zod";

export const createLessonPlanSchema = z.object({
  title: z.string().min(1, "请输入课案标题").max(255),
  textbookId: z.string().optional(),
  chapterId: z.string().optional(),
  subjectId: z.string().optional(),
  gradeId: z.string().optional(),
  templateId: z.string().min(1, "请选择模板"),
});

export const updateLessonPlanContentSchema = z.object({
  planId: z.string().min(1),
  title: z.string().min(1).max(255).optional(),
  content: z.unknown(), // Block 文档结构由 types 守卫，运行时只校验存在
});

export const saveVersionSchema = z.object({
  planId: z.string().min(1),
  label: z.string().max(100).optional(),
});

export const revertVersionSchema = z.object({
  planId: z.string().min(1),
  versionNo: z.number().int().positive(),
});

export const saveAsTemplateSchema = z.object({
  sourcePlanId: z.string().min(1),
  name: z.string().min(1).max(100),
});

export type CreateLessonPlanInput = z.infer<typeof createLessonPlanSchema>;
export type UpdateLessonPlanContentInput = z.infer<typeof updateLessonPlanContentSchema>;
