"""Google Calendar tool configuration."""

from __future__ import annotations

from typing import TYPE_CHECKING

from mindroom.tool_system.declarations import (
    ConfigField,
    SetupType,
    ToolCategory,
    ToolManagedInitArg,
    ToolStatus,
)
from mindroom.tool_system.registration import register_tool_with_metadata

if TYPE_CHECKING:
    from mindroom.custom_tools.google_calendar import GoogleCalendarTools


@register_tool_with_metadata(
    name="google_calendar",
    display_name="Google Calendar",
    description="View and schedule meetings with Google Calendar",
    category=ToolCategory.PRODUCTIVITY,
    status=ToolStatus.REQUIRES_CONFIG,
    setup_type=SetupType.OAUTH,
    auth_provider="google_calendar",
    icon="SiGooglecalendar",
    icon_color="text-blue-600",  # Google Calendar blue
    config_fields=[
        ConfigField(
            name="calendar_id",
            label="Calendar ID",
            type="text",
            required=False,
            default="primary",
            placeholder="primary",
            description="The Google Calendar ID to use (default: 'primary' for the user's main calendar)",
        ),
        ConfigField(
            name="allow_update",
            label="Allow Updates",
            type="boolean",
            required=False,
            default=True,
            description="Allow the agent to create, update, and delete calendar events",
        ),
    ],
    managed_init_args=(
        ToolManagedInitArg.RUNTIME_PATHS,
        ToolManagedInitArg.CREDENTIALS_MANAGER,
        ToolManagedInitArg.WORKER_TARGET,
    ),
    dependencies=["google-api-python-client", "google-auth", "google-auth-httplib2", "google-auth-oauthlib"],
    docs_url="https://docs.agno.com/tools/toolkits/others/googlecalendar",
    function_names=(
        "check_availability",
        "create_event",
        "delete_event",
        "fetch_all_events",
        "find_available_slots",
        "get_event",
        "get_event_attendees",
        "list_calendars",
        "list_events",
        "move_event",
        "quick_add_event",
        "respond_to_event",
        "search_events",
        "update_event",
    ),
)
def google_calendar_tools() -> type[GoogleCalendarTools]:
    """Return Google Calendar tools for calendar management."""
    from mindroom.custom_tools.google_calendar import GoogleCalendarTools

    return GoogleCalendarTools
