from simorgh.apps.modules.registry import (
    CapabilitySpec,
    FeatureFlagSpec,
    FeatureSpec,
    ModuleManifest,
    register_module,
)

register_module(
    ModuleManifest(
        name="tasks",
        version=1,
        domain="platform",
        label_key="tasks.module_label",
        description="Tasks — task management with subtasks, comments, attachments, and watchers",
        capabilities=(
            CapabilitySpec(slug="management", label_key="tasks.capabilities.management",
                          description="Task management", icon="check-square"),
            CapabilitySpec(slug="views", label_key="tasks.capabilities.views",
                          description="Task views", icon="layout"),
        ),
        features=(
            FeatureSpec(code="management.task_management", label_key="tasks.features.task_management", scope="tenant", default_enabled=True, description="Create and manage tasks with status workflow"),
            FeatureSpec(code="management.subtasks", label_key="tasks.features.subtasks", scope="tenant", default_enabled=True, description="Break tasks down into subtasks"),
            FeatureSpec(code="management.task_comments", label_key="tasks.features.task_comments", scope="tenant", default_enabled=True, description="Comment threads on tasks"),
            FeatureSpec(code="management.task_attachments", label_key="tasks.features.task_attachments", scope="tenant", default_enabled=True, description="Attach files to tasks"),
            FeatureSpec(code="management.task_watchers", label_key="tasks.features.task_watchers", scope="tenant", default_enabled=True, description="Watch tasks for status change notifications"),
            FeatureSpec(code="management.task_templates", label_key="tasks.features.task_templates", scope="tenant", description="Reusable task templates with checklists"),
            FeatureSpec(code="views.kanban_view", label_key="tasks.features.kanban_view", scope="tenant", description="Kanban board view for task workflow management"),
        ),
        feature_flags=(
            FeatureFlagSpec(name="allow_external_comments", label_key="tasks.ff.allow_external_comments", default=False, scope="tenant"),
        ),
        permissions=(
            "tasks.task.view",
            "tasks.task.create",
            "tasks.task.update",
            "tasks.task.delete",
            "tasks.task.manage_others",
            "tasks.comment.create",
            "tasks.comment.delete_own",
            "tasks.tag.manage",
        ),
        events=(
            "tasks.task.created",
            "tasks.task.status_changed",
            "tasks.task.completed",
            "tasks.task.overdue",
            "tasks.task.assigned",
            "tasks.comment.added",
        ),
    )
)
