"""
SmartTaskManager
Generated by Eden via recursive self-improvement
2025-10-28 10:55:05.541231
"""

class TaskManager:
    """A class to manage tasks with prioritization and deadline tracking."""
    
    def __init__(self):
        self.tasks = []
        self.task_id = 1
    
    def add_task(self, title, priority, deadline):
        """
        Add a new task to the list.
        Args:
            title (str): The title of the task
            priority (int): Priority level (1-3, with 3 being highest)
            deadline (str): Deadline date in 'YYYY-MM-DD' format
        """
        new_task = {
            "id": self.task_id,
            "title": title,
            "priority": priority,
            "deadline": deadline,
            "completed": False
        }
        self.tasks.append(new_task)
        self.task_id += 1
    
    def list_tasks(self):
        """List all tasks in a formatted manner, sorted by priority."""
        if not self.tasks:
            print("No tasks found.")
            return
        
        # Sort tasks by priority (lower number is higher priority)
        sorted_tasks = sorted(self.tasks, key=lambda x: x['priority'])
        for task in sorted_tasks:
            status = "✓" if task["completed"] else "✗"
            print(f"[{task['id']}]", 
                  f"{status} {task['title']}",
                  f"(Priority: {task['priority']}, Deadline: {task['deadline']})")
    
    def get_high_priority_tasks(self):
        """Return tasks with highest priority (priority level 3)."""
        return [task for task in self.tasks if task["priority"] == 3]
    
    def update_task_status(self, task_id):
        """
        Mark a task as completed.
        Args:
            task_id (int): The ID of the task to mark
        """
        for task in self.tasks:
            if task['id'] == task_id:
                task['completed'] = True
                print(f"Task {task_id} marked as completed.")
                return
        print(f"Task with ID {task_id} not found.")

def main():
    """The main function that provides CLI for TaskManager."""
    tm = TaskManager()
    
    while True:
        print("\n=== Smart Task Manager ===")
        print("1. Add New Task")
        print("2. List All Tasks")
        print("3. List High Priority Tasks (Priority 3)")
        print("4. Mark Task as Completed")
        print("5. Exit")
        
        try:
            choice = int(input("\nEnter your choice: "))
            
            if choice == 1:
                title = input("Enter task title: ")
                priority = int(input("Enter priority (1-3): "))
                deadline = input("Enter deadline (YYYY-MM-DD): ")
                tm.add_task(title, priority, deadline)
                
            elif choice == 2:
                tm.list_tasks()
                
            elif choice == 3:
                high_prio_tasks = tm.get_high_priority_tasks()
                if not high_prio_tasks:
                    print("No high-priority tasks found.")
                else:
                    print("\n=== High Priority Tasks ===")
                    for task in high_prio_tasks:
                        status = "✓" if task["completed"] else "✗"
                        print(f"[{task['id']}]", 
                              f"{status} {task['title']}",
                              f"(Deadline: {task['deadline']})")
                
            elif choice == 4:
                task_id = int(input("Enter task ID to mark as completed: "))
                tm.update_task_status(task_id)
                
            elif choice == 5:
                print("Exiting Task Manager...")
                break
                
            else:
                print("Invalid choice. Please try again.")
            
        except ValueError:
            print("Please enter a valid input.")
        
if __name__ == "__main__":
    main()
# Create a new TaskManager instance and add some tasks
tm = TaskManager()
tm.add_task("Complete project proposal", 3, "2023-10-30")
tm.add_task("Buy groceries", 2, "2023-11-01")
tm.add_task("Review documentation", 1, "2023-11-05")

# List all tasks
tm.list_tasks()

# Output:
# === Smart Task Manager ===
# 1. Add New Task
# 2. List All Tasks
# 3. List High Priority Tasks (Priority 3)
# 4. Mark Task as Completed
# 5. Exit
# Enter your choice: 2

# [1] ✗ Complete project proposal (Priority: 3, Deadline: 2023-10-30)
# [2] ✗ Buy groceries (Priority: 2, Deadline: 2023-11-01)
# [3] ✗ Review documentation (Priority: 1, Deadline: 2023-11-05)

# Mark a task as completed
tm.update_task_status(1)

# Output:
# Task 1 marked as completed.

# List high priority tasks
tm.get_high_priority_tasks()

# Output:
# [
#     {'id': 1, 'title': 'Complete project proposal', 'priority': 3, 
#      'deadline': '2023-10-30', 'completed': True}
# ]