"""
Social media share URL generators.

Builds intent URLs for Twitter/X and LinkedIn sharing.
"""

from urllib.parse import quote


def get_twitter_url(text: str, url: str) -> str:
    """Generate Twitter/X share URL."""
    encoded_text = quote(text)
    encoded_url = quote(url)
    return f"https://twitter.com/intent/tweet?text={encoded_text}&url={encoded_url}"


def get_linkedin_url(url: str) -> str:
    """Generate LinkedIn share URL."""
    encoded_url = quote(url)
    return f"https://www.linkedin.com/sharing/share-offsite/?url={encoded_url}"


def get_share_text_for_grade(
    grade: str,
    score: int,
) -> str:
    """
    Generate appropriate share text based on grade.

    Uses optimistic, celebratory tone -- not boastful.

    Args:
        grade: Letter grade.
        score: Numeric score 0-100.
        project_name: Optional project name.

    Returns:
        Share text string suitable for social posting.
    """
    if grade in ("A+", "A"):
        return (
            f"Just validated my AI-generated code with @DeepSweepAI "
            f"-- Grade {grade}! Ship-ready."
        )
    elif grade in ("A-", "B+", "B"):
        return (
            f"Validated my code with @DeepSweepAI "
            f"-- Grade {grade} ({score}/100). Ready to ship safely."
        )
    elif grade in ("B-", "C+", "C"):
        return (
            f"Using @DeepSweepAI to validate my AI-generated code. "
            f"Grade {grade} -- improving every commit."
        )
    else:
        return (
            "Started validating my AI code with @DeepSweepAI. "
            "Every project starts somewhere."
        )
