"""
SmartNotesManager
Generated by Eden via recursive self-improvement
2025-10-27 18:46:12.702823
"""

from datetime import datetime

class SmartNote:
    def __init__(self, title, content, category=None, tags=None, keywords=None):
        self.title = title
        self.content = content
        self.category = category
        self.tags = tags if tags else []
        self.keywords = keywords if keywords else []
        self.creation_date = datetime.now().isoformat()

    def __repr__(self):
        return f"Note: {self.title}, Category: {self.category}"

class SmartNotesManager:
    """
    A smart note management system that allows users to create, retrieve,
    update, and delete notes with categorization capabilities.
    
    Methods:
    - create_note(title, content, category=None, tags=None, keywords=None)
    - get_all_notes()
    - get_note(title)
    - update_note(title, **kwargs)
    - delete_note(title)
    - search_notes(category=None, keyword=None)
    """
    
    def __init__(self):
        self.notes = {}
        
    def create_note(self, title, content, category=None, tags=None, keywords=None):
        """Create a new note with optional category, tags and keywords."""
        if not title:
            raise ValueError("Note must have a title.")
            
        if title in self.notes:
            raise ValueError(f"Note with title '{title}' already exists.")
            
        note = SmartNote(title=title, content=content, 
                         category=category, tags=tags, keywords=keywords)
        self.notes[title] = note
        return f"Note '{title}' created successfully."
        
    def get_all_notes(self):
        """Return a dictionary of all notes with their details."""
        if not self.notes:
            return "No notes found."
            
        return {title: note.__dict__ for title, note in self.notes.items()}
        
    def get_note(self, title):
        """Retrieve a specific note by title."""
        if title not in self.notes:
            raise ValueError(f"Note '{title}' not found.")
            
        return self.notes[title]
        
    def update_note(self, title, content=None, category=None, tags=None, keywords=None):
        """Update an existing note with new values."""
        if title not in self.notes:
            raise ValueError(f"Note '{title}' not found.")
            
        note = self.notes[title]
        if content is not None:
            note.content = content
        if category is not None:
            note.category = category
        if tags is not None:
            note.tags = tags
        if keywords is not None:
            note.keywords = keywords
            
        return f"Note '{title}' updated successfully."
        
    def delete_note(self, title):
        """Delete a specific note by title."""
        if title not in self.notes:
            raise ValueError(f"Note '{title}' not found.")
            
        del self.notes[title]
        return f"Note '{title}' deleted successfully."
        
    def search_notes(self, category=None, keyword=None):
        """Search notes by category or keyword."""
        results = []
        for note in self.notes.values():
            match = True
            if category and note.category != category:
                match = False
            if keyword and keyword not in (note.tags + note.keywords):
                match = False
            if match:
                results.append(note)
                
        return results

# Example usage:
if __name__ == "__main__":
    notes_manager = SmartNotesManager()
    
    # Create notes
    print(notes_manager.create_note(
        title="Welcome Message",
        content="Hello, welcome to the smart note system!",
        category="system",
        tags=["welcome", "message"],
        keywords=["greeting"]
    ))
    
    print(notes_manager.create_note(
        title="Meeting Notes",
        content="Discuss project deadlines and milestones.",
        category="work"
    ))
    
    # List all notes
    print("\nAll Notes:")
    print(notes_manager.get_all_notes())
    
    # Search by category
    print("\nNotes in 'system' category:")
    system_notes = notes_manager.search_notes(category="system")
    for note in system_notes:
        print(note)
        
    # Update a note
    print("\nUpdating 'Welcome Message':")
    print(notes_manager.update_note(
        title="Welcome Message",
        content="Updated welcome message for new users.",
        tags=["user", "update"]
    ))
    
    # Retrieve a specific note
    print("\nNote details for 'Welcome Message':")
    print(notes_manager.get_note("Welcome Message"))
    
    # Delete a note
    print("\nDeleting 'Meeting Notes':")
    print(notes_manager.delete_note("Meeting Notes"))