import '../models/writing_task.dart';

class WritingStaticData {
  static List<WritingTask> getAllTasks() {
    final regularTasks = [
      // 议论文类型
      WritingTask(
        id: 'essay_1',
        title: '环境保护的重要性',
        description: '写一篇关于环境保护重要性的议论文，阐述个人观点并提供支持论据。',
        type: WritingType.essay,
        difficulty: WritingDifficulty.intermediate,
        timeLimit: 45,
        wordLimit: 300,
        keywords: ['环境保护', '可持续发展', '气候变化', '绿色生活'],
        requirements: [
          '明确表达个人观点',
          '提供至少3个支持论据',
          '使用恰当的连接词',
          '结构清晰，逻辑性强'
        ],
        prompt: '随着工业化的发展，环境问题日益严重。请就"环境保护的重要性"这一话题写一篇议论文，表达你的观点并提供有力的论据支持。',
        createdAt: DateTime.now().subtract(const Duration(days: 7)),
      ),
      
      WritingTask(
        id: 'essay_2',
        title: '科技对教育的影响',
        description: '分析科技发展对现代教育的积极和消极影响。',
        type: WritingType.essay,
        difficulty: WritingDifficulty.upperIntermediate,
        timeLimit: 50,
        wordLimit: 400,
        keywords: ['科技', '教育', '在线学习', '数字化'],
        requirements: [
          '分析积极和消极两方面影响',
          '举出具体例子说明',
          '使用高级词汇和句型',
          '观点平衡，论证充分'
        ],
        prompt: '科技的快速发展正在改变教育的方式。请分析科技对现代教育的影响，包括积极和消极两个方面。',
        createdAt: DateTime.now().subtract(const Duration(days: 5)),
      ),

      // 书信类型
      WritingTask(
        id: 'letter_1',
        title: '给朋友的邀请信',
        description: '写一封邀请朋友参加生日聚会的信件。',
        type: WritingType.letter,
        difficulty: WritingDifficulty.elementary,
        timeLimit: 30,
        wordLimit: 150,
        keywords: ['邀请', '生日聚会', '朋友', '时间地点'],
        requirements: [
          '使用正确的书信格式',
          '语气友好亲切',
          '包含时间、地点等具体信息',
          '表达期待之情'
        ],
        prompt: '你即将举办生日聚会，想邀请你的好朋友Tom参加。请写一封邀请信，包含聚会的时间、地点和活动安排。',
        createdAt: DateTime.now().subtract(const Duration(days: 3)),
      ),

      WritingTask(
        id: 'letter_2',
        title: '求职申请信',
        description: '写一封应聘市场营销职位的求职信。',
        type: WritingType.letter,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 40,
        wordLimit: 250,
        keywords: ['求职', '市场营销', '技能', '经验'],
        requirements: [
          '使用正式的商务信件格式',
          '突出个人优势和相关经验',
          '表达对职位的兴趣',
          '语言专业得体'
        ],
        prompt: '你看到一家公司招聘市场营销专员的广告，请写一封求职申请信，介绍你的背景和为什么适合这个职位。',
        createdAt: DateTime.now().subtract(const Duration(days: 2)),
      ),

      // 邮件类型
      WritingTask(
        id: 'email_1',
        title: '商务邮件：会议安排',
        description: '写一封关于安排部门会议的商务邮件。',
        type: WritingType.email,
        difficulty: WritingDifficulty.intermediate,
        timeLimit: 25,
        wordLimit: 120,
        keywords: ['会议', '安排', '议程', '时间'],
        requirements: [
          '使用恰当的邮件格式',
          '主题明确',
          '内容简洁明了',
          '包含必要的会议信息'
        ],
        prompt: '作为项目经理，你需要安排下周的部门会议。请写一封邮件通知团队成员，包含会议时间、地点和主要议程。',
        createdAt: DateTime.now().subtract(const Duration(days: 1)),
      ),

      // 报告类型
      WritingTask(
        id: 'report_1',
        title: '市场调研报告',
        description: '撰写一份关于新产品市场前景的调研报告。',
        type: WritingType.report,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 60,
        wordLimit: 500,
        keywords: ['市场调研', '数据分析', '趋势', '建议'],
        requirements: [
          '使用正式的报告格式',
          '包含数据和图表说明',
          '分析客观准确',
          '提出可行性建议'
        ],
        prompt: '你的公司计划推出一款新的智能手表产品。请根据市场调研数据，撰写一份市场前景分析报告。',
        createdAt: DateTime.now(),
      ),

      // 故事类型
      WritingTask(
        id: 'story_1',
        title: '童年回忆',
        description: '写一个关于童年难忘经历的故事。',
        type: WritingType.story,
        difficulty: WritingDifficulty.intermediate,
        timeLimit: 35,
        wordLimit: 200,
        keywords: ['童年', '回忆', '成长', '经历'],
        requirements: [
          '情节生动有趣',
          '使用描述性语言',
          '表达真实情感',
          '结构完整'
        ],
        prompt: '回想你的童年时光，选择一个特别难忘的经历，写成一个小故事。可以是快乐的、有趣的，或者让你学到重要道理的经历。',
        createdAt: DateTime.now().subtract(const Duration(hours: 12)),
      ),

      // 评论类型
      WritingTask(
        id: 'review_1',
        title: '电影评论',
        description: '写一篇关于最近观看电影的评论。',
        type: WritingType.review,
        difficulty: WritingDifficulty.upperIntermediate,
        timeLimit: 40,
        wordLimit: 300,
        keywords: ['电影', '评论', '剧情', '演技'],
        requirements: [
          '客观评价电影各个方面',
          '支持观点的具体例子',
          '使用评论性词汇',
          '给出推荐建议'
        ],
        prompt: '选择一部你最近观看的电影，写一篇评论。包括对剧情、演技、视觉效果等方面的评价，并说明是否推荐他人观看。',
        createdAt: DateTime.now().subtract(const Duration(hours: 6)),
      ),

      // 描述文类型
      WritingTask(
        id: 'description_1',
        title: '我的理想房屋',
        description: '描述你心目中理想房屋的样子。',
        type: WritingType.description,
        difficulty: WritingDifficulty.elementary,
        timeLimit: 30,
        wordLimit: 180,
        keywords: ['房屋', '设计', '装修', '功能'],
        requirements: [
          '使用丰富的形容词',
          '空间描述清晰',
          '细节生动具体',
          '逻辑顺序合理'
        ],
        prompt: '想象你有机会设计自己的理想房屋。请详细描述这个房屋的外观、内部布局、装修风格和特殊功能。',
        createdAt: DateTime.now().subtract(const Duration(hours: 3)),
      ),
    ];
    
    final examTasks = getExamTasks();
    
    return [...regularTasks, ...examTasks];
  }

  static List<WritingTask> getTasksByType(WritingType type) {
    return getAllTasks().where((task) => task.type == type).toList();
  }

  static List<WritingTask> getTasksByDifficulty(WritingDifficulty difficulty) {
    return getAllTasks().where((task) => task.difficulty == difficulty).toList();
  }

  static WritingTask? getTaskById(String id) {
    try {
      return getAllTasks().firstWhere((task) => task.id == id);
    } catch (e) {
      return null;
    }
  }

  static List<WritingTask> getRecentTasks({int limit = 5}) {
    final tasks = getAllTasks();
    tasks.sort((a, b) => b.createdAt.compareTo(a.createdAt));
    return tasks.take(limit).toList();
  }

  static List<WritingTask> getPopularTasks({int limit = 5}) {
    // 模拟热门任务（实际应用中可能基于完成次数、评分等）
    final popularIds = ['essay_1', 'letter_1', 'email_1', 'story_1', 'description_1'];
    return getAllTasks()
        .where((task) => popularIds.contains(task.id))
        .take(limit)
        .toList();
  }

  static List<WritingTask> getExamTasks() {
    return [
      // 四六级写作
      WritingTask(
        id: 'cet_1',
        title: '校园生活的变化',
        description: '描述大学校园生活的变化及其影响',
        type: WritingType.essay,
        difficulty: WritingDifficulty.intermediate,
        timeLimit: 30,
        wordLimit: 120,
        keywords: ['校园生活', '变化', '影响', '大学'],
        requirements: [
          '字数不少于120词',
          '结构清晰，逻辑合理',
          '语言准确，表达流畅',
          '内容充实，观点明确'
        ],
        prompt: 'For this part, you are allowed 30 minutes to write an essay on the changes in campus life. You should write at least 120 words but no more than 180 words.',
        examType: ExamType.cet,
        createdAt: DateTime.now().subtract(const Duration(days: 1)),
      ),
      WritingTask(
        id: 'cet_2',
        title: '网络学习的利弊',
        description: '分析网络学习的优势和劣势',
        type: WritingType.essay,
        difficulty: WritingDifficulty.intermediate,
        timeLimit: 30,
        wordLimit: 120,
        keywords: ['网络学习', '在线教育', '优势', '劣势'],
        requirements: [
          '字数不少于120词',
          '分析利弊两个方面',
          '举例说明观点',
          '语言规范，表达清楚'
        ],
        prompt: 'For this part, you are allowed 30 minutes to write an essay on the advantages and disadvantages of online learning. You should write at least 120 words but no more than 180 words.',
        examType: ExamType.cet,
        createdAt: DateTime.now().subtract(const Duration(days: 2)),
      ),

      // 考研写作
      WritingTask(
        id: 'kaoyan_1',
        title: '文化交流的重要性',
        description: '论述文化交流在全球化时代的重要性',
        type: WritingType.essay,
        difficulty: WritingDifficulty.upperIntermediate,
        timeLimit: 30,
        wordLimit: 160,
        keywords: ['文化交流', '全球化', '理解', '合作'],
        requirements: [
          '字数160-200词',
          '论点明确，论证充分',
          '使用高级词汇和句型',
          '结构完整，逻辑清晰'
        ],
        prompt: 'Write an essay of 160-200 words based on the following drawing. In your essay, you should 1) describe the drawing briefly, 2) explain its intended meaning, and 3) give your comments.',
        examType: ExamType.kaoyan,
        createdAt: DateTime.now().subtract(const Duration(days: 3)),
      ),
      WritingTask(
        id: 'kaoyan_2',
        title: '环境保护与经济发展',
        description: '讨论环境保护与经济发展的关系',
        type: WritingType.essay,
        difficulty: WritingDifficulty.upperIntermediate,
        timeLimit: 30,
        wordLimit: 160,
        keywords: ['环境保护', '经济发展', '平衡', '可持续'],
        requirements: [
          '字数160-200词',
          '分析两者关系',
          '提出解决方案',
          '语言准确，表达地道'
        ],
        prompt: 'Write an essay of 160-200 words based on the following drawing. In your essay, you should 1) describe the drawing briefly, 2) explain its intended meaning, and 3) give your comments.',
        examType: ExamType.kaoyan,
        createdAt: DateTime.now().subtract(const Duration(days: 4)),
      ),

      // 托福写作
      WritingTask(
        id: 'toefl_1',
        title: '独立写作：在线教育vs传统教育',
        description: '比较在线教育和传统教育的优劣',
        type: WritingType.essay,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 30,
        wordLimit: 300,
        keywords: ['在线教育', '传统教育', '比较', '效果'],
        requirements: [
          '字数不少于300词',
          '明确表达个人观点',
          '提供具体例子支持',
          '使用多样化的句型和词汇'
        ],
        prompt: 'Do you agree or disagree with the following statement? Online education is more effective than traditional classroom education. Use specific reasons and examples to support your answer.',
        examType: ExamType.toefl,
        createdAt: DateTime.now().subtract(const Duration(days: 5)),
      ),
      WritingTask(
        id: 'toefl_2',
        title: '独立写作：科技对人际关系的影响',
        description: '分析现代科技对人际关系的影响',
        type: WritingType.essay,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 30,
        wordLimit: 300,
        keywords: ['科技', '人际关系', '社交媒体', '沟通'],
        requirements: [
          '字数不少于300词',
          '分析正面和负面影响',
          '使用具体例子',
          '结论明确'
        ],
        prompt: 'Do you agree or disagree with the following statement? Technology has made people less social and more isolated. Use specific reasons and examples to support your answer.',
        examType: ExamType.toefl,
        createdAt: DateTime.now().subtract(const Duration(days: 6)),
      ),

      // 雅思写作
      WritingTask(
        id: 'ielts_1',
        title: 'Task 2: 城市化的影响',
        description: '讨论城市化对社会和环境的影响',
        type: WritingType.essay,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 40,
        wordLimit: 250,
        keywords: ['城市化', '社会影响', '环境影响', '发展'],
        requirements: [
          '字数不少于250词',
          '讨论问题的两个方面',
          '给出自己的观点',
          '使用正式的学术语言'
        ],
        prompt: 'In many countries, people are moving from rural areas to cities. What are the advantages and disadvantages of this trend? Give reasons for your answer and include any relevant examples from your own knowledge or experience.',
        examType: ExamType.ielts,
        createdAt: DateTime.now().subtract(const Duration(days: 7)),
      ),
      WritingTask(
        id: 'ielts_2',
        title: 'Task 2: 教育的目的',
        description: '讨论教育的主要目的是什么',
        type: WritingType.essay,
        difficulty: WritingDifficulty.advanced,
        timeLimit: 40,
        wordLimit: 250,
        keywords: ['教育', '目的', '技能', '知识'],
        requirements: [
          '字数不少于250词',
          '清楚表达观点',
          '提供相关例子',
          '逻辑清晰，结构完整'
        ],
        prompt: 'Some people think that the main purpose of education is to prepare students for the working world. Others believe that education should focus on developing knowledge and critical thinking skills. Discuss both views and give your own opinion.',
        examType: ExamType.ielts,
        createdAt: DateTime.now().subtract(const Duration(days: 8)),
      ),
    ];
  }

  static List<WritingTask> getTasksByExamType(ExamType examType) {
    return getExamTasks().where((task) => task.examType == examType).toList();
  }
}