// Mock data for course package classes
export const coursePackageClasses = [
  // Online Long-Term Course for Super Memory (Package ID: 2)
  {
    id: 1,
    course_package_id: 2,
    title: "Level 1 (Basic)",
    title_cn: "第一级 (基础)",
    description: "Introduction to memory techniques",
    description_cn: "记忆技巧入门",
    level_name: "Basic",
    price: 390,
    discount: 0,
    duration: 120,
    sequence_order: 1,
    class_type: "online",
    agenda: "1. Introduction to memory\n2. Basic techniques\n3. Practice exercises",
    agenda_cn: "1. 记忆入门\n2. 基本技巧\n3. 练习",
    image: "/memory-training-techniques.png",
    image_cn: "/memory-training-techniques.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 2,
    course_package_id: 2,
    title: "Level 2 (Basic)",
    title_cn: "第二级 (基础)",
    description: "Building memory foundations",
    description_cn: "构建记忆基础",
    level_name: "Basic",
    price: 410,
    discount: 20,
    duration: 120,
    sequence_order: 2,
    class_type: "online",
    agenda: "1. Review of Level 1\n2. Advanced associations\n3. Memory exercises",
    agenda_cn: "1. 第一级回顾\n2. 高级联想\n3. 记忆练习",
    image: "/memory-palace.png",
    image_cn: "/memory-palace.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 3,
    course_package_id: 2,
    title: "Level 3 (Intermediate)",
    title_cn: "第三级 (中级)",
    description: "Advanced memory techniques",
    description_cn: "高级记忆技巧",
    level_name: "Intermediate",
    price: 430,
    discount: 0,
    duration: 150,
    sequence_order: 3,
    class_type: "online",
    agenda: "1. Memory palace technique\n2. Number memorization\n3. Advanced practice",
    agenda_cn: "1. 记忆宫殿技巧\n2. 数字记忆\n3. 高级练习",
    image: "/memorization-techniques.png",
    image_cn: "/memorization-techniques.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 4,
    course_package_id: 2,
    title: "Level 4 (Intermediate)",
    title_cn: "第四级 (中级)",
    description: "Memory application in daily life",
    description_cn: "日常生活中的记忆应用",
    level_name: "Intermediate",
    price: 450,
    discount: 30,
    duration: 150,
    sequence_order: 4,
    class_type: "online",
    agenda: "1. Practical applications\n2. Memory for names and faces\n3. Daily memory challenges",
    agenda_cn: "1. 实际应用\n2. 名字和面孔的记忆\n3. 日常记忆挑战",
    image: "/brain-training-visualization.png",
    image_cn: "/brain-training-visualization.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 5,
    course_package_id: 2,
    title: "Level 5 (Advanced)",
    title_cn: "第五级 (高级)",
    description: "Memory mastery techniques",
    description_cn: "记忆掌握技巧",
    level_name: "Advanced",
    price: 470,
    discount: 0,
    duration: 180,
    sequence_order: 5,
    class_type: "online",
    agenda: "1. Memory competition techniques\n2. Speed memorization\n3. Expert level exercises",
    agenda_cn: "1. 记忆比赛技巧\n2. 速度记忆\n3. 专家级练习",
    image: "/brain-training-concept.png",
    image_cn: "/brain-training-concept.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 6,
    course_package_id: 2,
    title: "Level 6 (Advanced)",
    title_cn: "第六级 (高级)",
    description: "Professional memory applications",
    description_cn: "专业记忆应用",
    level_name: "Advanced",
    price: 490,
    discount: 40,
    duration: 180,
    sequence_order: 6,
    class_type: "online",
    agenda: "1. Professional memory systems\n2. Teaching memory techniques\n3. Final assessment",
    agenda_cn: "1. 专业记忆系统\n2. 教授记忆技巧\n3. 最终评估",
    image: "/mind-mapping.png",
    image_cn: "/mind-mapping.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },

  // Offline Long-Term Course for Super Memory (Package ID: 3)
  {
    id: 7,
    course_package_id: 3,
    title: "Level 1 (Basic)",
    title_cn: "第一级 (基础)",
    description: "Introduction to memory techniques in person",
    description_cn: "面对面记忆技巧入门",
    level_name: "Basic",
    price: 440,
    discount: 20,
    duration: 180,
    sequence_order: 1,
    class_type: "physical",
    agenda: "1. Introduction to memory\n2. Basic techniques\n3. Group exercises",
    agenda_cn: "1. 记忆入门\n2. 基本技巧\n3. 小组练习",
    image: "/memory-training-techniques.png",
    image_cn: "/memory-training-techniques.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 8,
    course_package_id: 3,
    title: "Level 2 (Basic)",
    title_cn: "第二级 (基础)",
    description: "Building memory foundations in person",
    description_cn: "面对面构建记忆基础",
    level_name: "Basic",
    price: 460,
    discount: 0,
    duration: 180,
    sequence_order: 2,
    class_type: "physical",
    agenda: "1. Review of Level 1\n2. Advanced associations\n3. Interactive exercises",
    agenda_cn: "1. 第一级回顾\n2. 高级联想\n3. 互动练习",
    image: "/memory-palace.png",
    image_cn: "/memory-palace.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 9,
    course_package_id: 3,
    title: "Level 3 (Intermediate)",
    title_cn: "第三级 (中级)",
    description: "Advanced memory techniques in person",
    description_cn: "面对面高级记忆技巧",
    level_name: "Intermediate",
    price: 480,
    discount: 30,
    duration: 210,
    sequence_order: 3,
    class_type: "physical",
    agenda: "1. Memory palace workshop\n2. Number memorization practice\n3. Group challenges",
    agenda_cn: "1. 记忆宫殿工作坊\n2. 数字记忆练习\n3. 小组挑战",
    image: "/memorization-techniques.png",
    image_cn: "/memorization-techniques.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 10,
    course_package_id: 3,
    title: "Level 4 (Intermediate)",
    title_cn: "第四级 (中级)",
    description: "Memory application in daily life in person",
    description_cn: "面对面日常生活中的记忆应用",
    level_name: "Intermediate",
    price: 500,
    discount: 0,
    duration: 210,
    sequence_order: 4,
    class_type: "physical",
    agenda: "1. Practical applications\n2. Memory for names and faces workshop\n3. Interactive challenges",
    agenda_cn: "1. 实际应用\n2. 名字和面孔的记忆工作坊\n3. 互动挑战",
    image: "/brain-training-visualization.png",
    image_cn: "/brain-training-visualization.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 11,
    course_package_id: 3,
    title: "Level 5 (Advanced)",
    title_cn: "第五级 (高级)",
    description: "Memory mastery techniques in person",
    description_cn: "面对面记忆掌握技巧",
    level_name: "Advanced",
    price: 520,
    discount: 40,
    duration: 240,
    sequence_order: 5,
    class_type: "physical",
    agenda: "1. Memory competition preparation\n2. Speed memorization workshop\n3. Advanced group exercises",
    agenda_cn: "1. 记忆比赛准备\n2. 速度记忆工作坊\n3. 高级小组练习",
    image: "/brain-training-concept.png",
    image_cn: "/brain-training-concept.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 12,
    course_package_id: 3,
    title: "Level 6 (Advanced)",
    title_cn: "第六级 (高级)",
    description: "Professional memory applications in person",
    description_cn: "面对面专业记忆应用",
    level_name: "Advanced",
    price: 540,
    discount: 0,
    duration: 240,
    sequence_order: 6,
    class_type: "physical",
    agenda:
      "1. Professional memory systems workshop\n2. Teaching techniques practice\n3. Final assessment and certification",
    agenda_cn: "1. 专业记忆系统工作坊\n2. 教学技巧实践\n3. 最终评估和认证",
    image: "/mind-mapping.png",
    image_cn: "/mind-mapping.png",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
]

// Get classes by package ID
export function getClassesByPackageId(packageId: number) {
  console.log("[mock] getClassesByPackageId called with packageId:", packageId)
  const result = coursePackageClasses.filter((cls) => cls.course_package_id === packageId)
  console.log("[mock] getClassesByPackageId returning:", result)
  return Promise.resolve(result)
}

// Get class by ID
export function getClassById(id: number) {
  console.log("[mock] getClassById called with id:", id)
  const result = coursePackageClasses.find((cls) => cls.id === id)
  console.log("[mock] getClassById returning:", result)

  if (!result) {
    return Promise.reject(new Error(`Class with ID ${id} not found`))
  }

  return Promise.resolve(result)
}

// Get all classes
export function getAllClasses() {
  console.log("[mock] getAllClasses called")
  console.log("[mock] getAllClasses returning:", coursePackageClasses)
  return Promise.resolve(coursePackageClasses)
}

// Create a new class
export function createClass(classData: Omit<(typeof coursePackageClasses)[0], "id" | "created_at" | "updated_at">) {
  console.log("[mock] createClass called with data:", classData)

  const newClass = {
    ...classData,
    id: Math.max(...coursePackageClasses.map((cls) => cls.id)) + 1,
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString(),
  }

  console.log("[mock] createClass created:", newClass)
  return Promise.resolve(newClass)
}

// Update an existing class
export function updateClass(id: number, classData: Partial<(typeof coursePackageClasses)[0]>) {
  console.log("[mock] updateClass called with id:", id, "and data:", classData)

  const classIndex = coursePackageClasses.findIndex((cls) => cls.id === id)

  if (classIndex === -1) {
    console.error("[mock] updateClass error: Class not found")
    return Promise.reject(new Error(`Class with ID ${id} not found`))
  }

  const updatedClass = {
    ...coursePackageClasses[classIndex],
    ...classData,
    updated_at: new Date().toISOString(),
  }

  console.log("[mock] updateClass updated:", updatedClass)
  return Promise.resolve(updatedClass)
}

// Delete a class
export function deleteClass(id: number) {
  console.log("[mock] deleteClass called with id:", id)

  const classIndex = coursePackageClasses.findIndex((cls) => cls.id === id)

  if (classIndex === -1) {
    console.error("[mock] deleteClass error: Class not found")
    return Promise.reject(new Error(`Class with ID ${id} not found`))
  }

  console.log("[mock] deleteClass deleted class with id:", id)
  return Promise.resolve({ success: true })
}
