# keyboards/user_kb.py

from __future__ import annotations

from typing import Iterable, Optional, Sequence

from aiogram.types import (
    InlineKeyboardButton,
    InlineKeyboardMarkup,
)
from aiogram.utils.keyboard import (
    InlineKeyboardBuilder,
)


# ============================================================
# Custom Emoji IDs
# ============================================================

EMOJI = {
    "shop": "5402516323710279908",
    "plus": "5318974936310627698",
    "money": "5990147899403539264",
    "wallet": "5803143039060808890",
    "wallets": "6008196202384859008",
    "users": "5875180111744995604",
    "support": "5319164022245832659",
    "orders": "5985774024968379294",
    "stars": "5843892082447487088",
    "premium": "5823537588186647980",
    "ton": "6008196202384859008",
    "gift": "5294466362566014067",
    "boost": "5899764453007692085",
    "trx": "6032713293049633080",
    "reaction": "5951704669339258951",
    "giveaway": "5951801486492045346",
    "back": "5447183459602669338",
    "flash": "5449683594425410231",
    "broadcast": "5897602448075263134",
    "folder": "5244837092042750681",
    "delete": "6030430277413638534",
}


# ============================================================
# Generic Helpers
# ============================================================

def _btn(
    text: str,
    callback_data: Optional[str] = None,
    *,
    url: Optional[str] = None,
    icon: Optional[str] = None,
    style: Optional[str] = None,
) -> InlineKeyboardButton:
    """
    سازگار با نسخه‌های مختلف aiogram / Telegram Bot API.

    اگر InlineKeyboardButton در نسخه نصب‌شده از فیلدهای جدید
    icon_custom_emoji_id و style پشتیبانی کند، استفاده می‌شوند.
    در نسخه‌های قدیمی‌تر خودکار حذف می‌شوند تا منو ValidationError ندهد.
    """

    kwargs: dict[str, object] = {
        "text": text,
    }

    if callback_data is not None:
        kwargs["callback_data"] = callback_data

    if url is not None:
        kwargs["url"] = url

    model_fields = getattr(
        InlineKeyboardButton,
        "model_fields",
        None,
    )

    if not model_fields:
        model_fields = getattr(
            InlineKeyboardButton,
            "__fields__",
            {},
        )

    supported_fields = set(
        getattr(model_fields, "keys", lambda: [])()
    )

    if icon and "icon_custom_emoji_id" in supported_fields:
        icon_value = EMOJI.get(
            icon
        )

        # Explicit numeric Telegram custom-emoji IDs are also accepted.
        if (
            icon_value is None
            and str(icon).isdigit()
        ):
            icon_value = str(icon)

        # Unknown symbolic keys are intentionally ignored so a typo in an
        # icon name can never break the whole keyboard / main menu.
        if icon_value:
            kwargs["icon_custom_emoji_id"] = icon_value

    if style and "style" in supported_fields:
        kwargs["style"] = style

    return InlineKeyboardButton(
        **kwargs
    )


def _markup(
    rows: Iterable[
        Sequence[
            InlineKeyboardButton
        ]
    ],
) -> InlineKeyboardMarkup:

    return InlineKeyboardMarkup(
        inline_keyboard=[
            list(row)
            for row
            in rows
        ]
    )


def get_back_keyboard(
    callback_data: str = "main_menu",
    *,
    text: str = "بازگشت",
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    text,
                    callback_data,
                    icon="back",
                    style="danger",
                )
            ]
        ]
    )


# ============================================================
# Main User Menu
# ============================================================

def get_user_main_menu(
    user_id: Optional[int] = None,
) -> InlineKeyboardMarkup:
    """
    منوی اصلی کاربر.

    user_id اختیاری است تا با هر دو نوع فراخوانی پروژه سازگار باشد:

        get_user_main_menu()
        get_user_main_menu(message.from_user.id)

    در حال حاضر خود کیبورد برای همه کاربران یکسان است و این مقدار
    فقط برای سازگاری با start.py پذیرفته می‌شود.
    """
    _ = user_id

    builder = InlineKeyboardBuilder()

    builder.row(
        _btn(
            "خرید محصول",
            "buy_product",
            icon="shop",
            style="success",
        )
    )

    builder.row(
        _btn(
            "لیست قیمت‌ها",
            "price_list",
            icon="money",
            style="primary",
        ),
        _btn(
            "حساب کاربری",
            "user_profile",
            icon="wallet",
            style="primary",
        ),
    )

    builder.row(
        _btn(
            "سفارش‌های من",
            "my_orders",
            icon="orders",
            style="primary",
        ),
        _btn(
            "تاریخچه مالی",
            "wallet_tx_history",
            icon="folder",
            style="primary",
        ),
    )

    builder.row(
        _btn(
            "زیرمجموعه‌گیری",
            "referral_menu",
            icon="users",
            style="primary",
        ),
        _btn(
            "پشتیبانی",
            "support",
            icon="support",
            style="primary",
        ),
    )

    return builder.as_markup()


# ============================================================
# Products Menu
# ============================================================

def get_products_menu_keyboard(
    *,
    show_unavailable_services: bool = True,
) -> InlineKeyboardMarkup:

    builder = InlineKeyboardBuilder()

    builder.row(
        _btn(
            "سفارش‌های اخیر من",
            "my_orders",
            icon="folder",
            style="success",
        )
    )

    builder.row(
        _btn(
            "Stars",
            "buy_stars",
            icon="stars",
            style="primary",
        ),
        _btn(
            "Premium",
            "buy_premium",
            icon="premium",
            style="primary",
        ),
    )

    if show_unavailable_services:

        builder.row(
            _btn(
                "خرید TON",
                "buy_ton",
                icon="ton",
                style="primary",
            ),
            _btn(
                "خرید TRX",
                "buy_trx",
                icon="trx",
                style="primary",
            ),
        )

        builder.row(
            _btn(
                "گیفت استارزی",
                "gift_stars",
                icon="gift",
                style="primary",
            ),
            _btn(
                "بوست تلگرام",
                "boost_telegram",
                icon="boost",
                style="primary",
            ),
        )

        builder.row(
            _btn(
                "ری‌اکشن استارزی",
                "star_reaction",
                icon="reaction",
                style="primary",
            ),
            _btn(
                "گیو‌اوی استارزی",
                "star_giveaway",
                icon="giveaway",
                style="primary",
            ),
        )

    builder.row(
        _btn(
            "بازگشت به منوی اصلی",
            "main_menu",
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


# ============================================================
# Wallet Menu
# ============================================================

def get_wallet_menu_keyboard(
    *,
    show_crypto_deposits: bool = True,
) -> InlineKeyboardMarkup:
    """
    منوی مرتب حساب کاربری / کیف پول.

    واریز ارزی عمداً فقط در این بخش نمایش داده می‌شود
    و از منوی اصلی حذف شده است.
    """

    builder = InlineKeyboardBuilder()

    # --------------------------------------------------------
    # Balance actions
    # --------------------------------------------------------

    if show_crypto_deposits:
        builder.row(
            _btn(
                "افزایش موجودی",
                "charge_fiat",
                icon="plus",
                style="success",
            ),
            _btn(
                "واریز ارزی",
                "crypto_deposit_menu",
                icon="wallets",
                style="success",
            ),
        )
    else:
        builder.row(
            _btn(
                "افزایش موجودی",
                "charge_fiat",
                icon="plus",
                style="success",
            )
        )

    # --------------------------------------------------------
    # Financial history
    # --------------------------------------------------------

    if show_crypto_deposits:
        builder.row(
            _btn(
                "واریزهای من",
                "my_crypto_deposits",
                icon="ton",
                style="primary",
            ),
            _btn(
                "تاریخچه مالی",
                "wallet_tx_history",
                icon="orders",
                style="primary",
            ),
        )
    else:
        builder.row(
            _btn(
                "تاریخچه مالی",
                "wallet_tx_history",
                icon="orders",
                style="primary",
            )
        )

    # --------------------------------------------------------
    # Orders / support
    # --------------------------------------------------------

    builder.row(
        _btn(
            "سفارش‌های من",
            "my_orders",
            icon="folder",
            style="primary",
        ),
        _btn(
            "پشتیبانی",
            "support",
            icon="support",
            style="primary",
        ),
    )

    builder.row(
        _btn(
            "بازگشت به منوی اصلی",
            "main_menu",
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


# ============================================================
# Crypto Deposit
# ============================================================

def get_crypto_deposit_currency_keyboard(
    available: Optional[
        set[str]
    ] = None,
) -> InlineKeyboardMarkup:
    """
    انتخاب ارز برای واریز دستی.

    available:
        فقط ارزهایی که مالک برایشان ولت دریافت ثبت کرده
        نمایش داده می‌شوند.

    callbackها:
        crypto_deposit_TON
        crypto_deposit_USDT
        crypto_deposit_TRX
    """

    available = set(
        available
        or {
            "TON",
            "USDT",
            "TRX",
        }
    )

    builder = InlineKeyboardBuilder()

    if "TON" in available:
        builder.row(
            _btn(
                "TON — شبکه TON",
                "crypto_deposit_TON",
                icon="ton",
                style="primary",
            )
        )

    if "USDT" in available:
        builder.row(
            _btn(
                "USDT — شبکه TRC20",
                "crypto_deposit_USDT",
                icon="wallet",
                style="primary",
            )
        )

    if "TRX" in available:
        builder.row(
            _btn(
                "TRX — شبکه TRON",
                "crypto_deposit_TRX",
                icon="trx",
                style="primary",
            )
        )

    builder.row(
        _btn(
            "درخواست‌های واریز من",
            "my_crypto_deposits",
            icon="orders",
            style="primary",
        )
    )

    builder.row(
        _btn(
            "بازگشت به حساب",
            "user_profile",
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


def get_crypto_deposit_destination_keyboard(
    currency: str,
) -> InlineKeyboardMarkup:
    """
    بعد از نمایش آدرس ولت مالک.
    """

    currency = str(
        currency
        or ""
    ).strip().upper()

    if currency not in {
        "TON",
        "USDT",
        "TRX",
    }:
        currency = "TON"

    return _markup(
        [
            [
                _btn(
                    "واریز کردم — ثبت درخواست",
                    f"crypto_deposit_paid_{currency}",
                    icon="plus",
                    style="success",
                )
            ],
            [
                _btn(
                    "تغییر ارز",
                    "crypto_deposit_menu",
                    icon="wallets",
                    style="primary",
                ),
                _btn(
                    "انصراف",
                    "user_profile",
                    icon="back",
                    style="danger",
                ),
            ],
        ]
    )


def get_crypto_deposit_cancel_keyboard(
) -> InlineKeyboardMarkup:
    """
    استفاده در مراحل FSM ثبت درخواست واریز.
    """

    return _markup(
        [
            [
                _btn(
                    "لغو و بازگشت",
                    "crypto_deposit_menu",
                    icon="back",
                    style="danger",
                )
            ]
        ]
    )


def get_crypto_receipt_keyboard(
) -> InlineKeyboardMarkup:
    """
    مرحله دریافت رسید.
    کاربر می‌تواند Photo/Document بفرستد یا مرحله را Skip کند.
    """

    return _markup(
        [
            [
                _btn(
                    "رسید ندارم / رد کردن این مرحله",
                    "crypto_dep_skip_receipt",
                    icon="folder",
                    style="primary",
                )
            ],
            [
                _btn(
                    "لغو درخواست",
                    "crypto_deposit_menu",
                    icon="delete",
                    style="danger",
                )
            ],
        ]
    )


def get_crypto_note_keyboard(
) -> InlineKeyboardMarkup:
    """
    مرحله توضیحات اختیاری.
    """

    return _markup(
        [
            [
                _btn(
                    "بدون توضیحات",
                    "crypto_dep_skip_note",
                    icon="folder",
                    style="primary",
                )
            ],
            [
                _btn(
                    "لغو درخواست",
                    "crypto_deposit_menu",
                    icon="delete",
                    style="danger",
                )
            ],
        ]
    )




# ============================================================
# External Wallet Management
# ============================================================

def get_external_wallets_keyboard(
    saved_types: Optional[
        set[str]
    ] = None,
) -> InlineKeyboardMarkup:

    saved_types = set(
        saved_types
        or set()
    )

    def label(
        title: str,
        wallet_type: str,
    ) -> str:

        if (
            wallet_type
            in saved_types
        ):
            return (
                f"ویرایش {title}"
            )

        return (
            f"ثبت {title}"
        )

    builder = InlineKeyboardBuilder()

    builder.row(
        _btn(
            label(
                "TON",
                "ton",
            ),
            "wallet_set_ton",
            icon="ton",
            style="primary",
        )
    )

    builder.row(
        _btn(
            label(
                "USDT (TRC20)",
                "usdt_trc20",
            ),
            "wallet_set_usdt_trc20",
            icon="wallet",
            style="primary",
        )
    )

    builder.row(
        _btn(
            label(
                "TRON / TRX",
                "tron",
            ),
            "wallet_set_tron",
            icon="trx",
            style="primary",
        )
    )

    if saved_types:

        builder.row(
            _btn(
                "حذف ولت ثبت‌شده",
                "wallet_delete_menu",
                icon="delete",
                style="danger",
            )
        )

    builder.row(
        _btn(
            "حساب کاربری",
            "user_profile",
            icon="wallet",
            style="primary",
        ),
        _btn(
            "منوی اصلی",
            "main_menu",
            icon="back",
            style="danger",
        ),
    )

    return builder.as_markup()


# ============================================================
# Delete Wallet Menu
# ============================================================

def get_external_wallet_delete_keyboard(
    saved_types: set[str],
) -> InlineKeyboardMarkup:

    saved_types = set(
        saved_types
        or set()
    )

    builder = InlineKeyboardBuilder()

    wallet_rows = (
        (
            "ton",
            "TON",
            "ton",
        ),
        (
            "usdt_trc20",
            "USDT (TRC20)",
            "wallet",
        ),
        (
            "tron",
            "TRON / TRX",
            "trx",
        ),
    )

    for (
        wallet_type,
        title,
        icon,
    ) in wallet_rows:

        if (
            wallet_type
            not in saved_types
        ):
            continue

        builder.row(
            _btn(
                f"حذف {title}",
                (
                    f"wallet_delete_"
                    f"{wallet_type}"
                ),
                icon=icon,
                style="danger",
            )
        )

    builder.row(
        _btn(
            "انصراف",
            "manage_external_wallets",
            icon="back",
            style="primary",
        )
    )

    return builder.as_markup()


# ============================================================
# Wallet Input Keyboard
# ============================================================

def get_external_wallet_input_keyboard(
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "انصراف و بازگشت",
                    "manage_external_wallets",
                    icon="back",
                    style="danger",
                )
            ]
        ]
    )


# ============================================================
# Stars / Premium Packages
# ============================================================

def get_services_packages_keyboard(
    service_type: str,
) -> InlineKeyboardMarkup:

    service_type = str(
        service_type
        or ""
    ).strip().lower()

    builder = InlineKeyboardBuilder()

    if (
        service_type
        == "premium"
    ):

        builder.row(
            _btn(
                "پرمیوم ۱ ماهه",
                "prem_1m",
                icon="premium",
                style="primary",
            ),
            _btn(
                "پرمیوم ۳ ماهه",
                "prem_3m",
                icon="premium",
                style="primary",
            ),
        )

        builder.row(
            _btn(
                "پرمیوم ۶ ماهه",
                "prem_6m",
                icon="premium",
                style="primary",
            ),
            _btn(
                "پرمیوم ۱ ساله",
                "prem_1y",
                icon="boost",
                style="success",
            ),
        )

    elif (
        service_type
        == "stars"
    ):

        builder.row(
            _btn(
                "۵۰ Stars",
                "stars_50",
                icon="stars",
                style="primary",
            ),
            _btn(
                "۱۰۰ Stars",
                "stars_100",
                icon="stars",
                style="primary",
            ),
        )

        builder.row(
            _btn(
                "۲۵۰ Stars",
                "stars_250",
                icon="stars",
                style="primary",
            ),
            _btn(
                "۵۰۰ Stars",
                "stars_500",
                icon="stars",
                style="primary",
            ),
        )

        builder.row(
            _btn(
                "۱۰۰۰ Stars",
                "stars_1000",
                icon="stars",
                style="success",
            ),
            _btn(
                "۵۰۰۰ Stars",
                "stars_5000",
                icon="stars",
                style="success",
            ),
        )

        builder.row(
            _btn(
                "تعداد دلخواه Stars",
                "custom_stars",
                icon="stars",
                style="success",
            )
        )

    builder.row(
        _btn(
            "بازگشت به محصولات",
            "buy_product",
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


# ============================================================
# Checkout
# ============================================================

def get_confirm_order_keyboard(
    order_id: Optional[
        str | int
    ] = None,
) -> InlineKeyboardMarkup:

    # برای سازگاری با کدهای قدیمی
    _ = order_id

    return _markup(
        [
            [
                _btn(
                    "ثبت درخواست خرید",
                    "finalize_purchase",
                    icon="plus",
                    style="success",
                )
            ],
            [
                _btn(
                    "شارژ کیف پول",
                    "charge_fiat",
                    icon="wallet",
                    style="primary",
                ),
                _btn(
                    "لغو سفارش",
                    "cancel_shop",
                    icon="delete",
                    style="danger",
                ),
            ],
        ]
    )


def get_checkout_keyboard(
) -> InlineKeyboardMarkup:

    return (
        get_confirm_order_keyboard()
    )


def get_cancel_order_keyboard(
    *,
    back_callback: str = "buy_product",
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "بازگشت",
                    back_callback,
                    icon="back",
                    style="primary",
                ),
                _btn(
                    "لغو سفارش",
                    "cancel_shop",
                    icon="delete",
                    style="danger",
                ),
            ]
        ]
    )


# ============================================================
# Price Change
# ============================================================

def get_price_change_keyboard(
    order_id: int,
) -> InlineKeyboardMarkup:

    order_id = int(
        order_id
    )

    return _markup(
        [
            [
                _btn(
                    "تأیید مبلغ جدید",
                    (
                        "accept_new_price_order_"
                        f"{order_id}"
                    ),
                    icon="plus",
                    style="success",
                )
            ],
            [
                _btn(
                    "لغو درخواست",
                    (
                        "cancel_new_price_order_"
                        f"{order_id}"
                    ),
                    icon="delete",
                    style="danger",
                )
            ],
        ]
    )


# ============================================================
# Insufficient Balance
# ============================================================

def get_insufficient_balance_keyboard(
    *,
    back_callback: str = "buy_product",
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "افزایش موجودی",
                    "charge_fiat",
                    icon="plus",
                    style="success",
                )
            ],
            [
                _btn(
                    "واریز ارزی",
                    "crypto_deposit_menu",
                    icon="wallets",
                    style="primary",
                )
            ],
            [
                _btn(
                    "بازگشت",
                    back_callback,
                    icon="back",
                    style="primary",
                ),
                _btn(
                    "لغو سفارش",
                    "cancel_shop",
                    icon="delete",
                    style="danger",
                ),
            ],
        ]
    )


# ============================================================
# Order Result
# ============================================================

def get_order_result_keyboard(
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "سفارش‌های من",
                    "my_orders",
                    icon="orders",
                    style="primary",
                ),
                _btn(
                    "خرید جدید",
                    "buy_product",
                    icon="shop",
                    style="success",
                ),
            ],
            [
                _btn(
                    "منوی اصلی",
                    "main_menu",
                    icon="back",
                    style="danger",
                )
            ],
        ]
    )


# ============================================================
# My Orders
# ============================================================

def get_my_orders_keyboard(
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "بروزرسانی",
                    "my_orders",
                    icon="orders",
                    style="primary",
                )
            ],
            [
                _btn(
                    "فروشگاه",
                    "buy_product",
                    icon="shop",
                    style="success",
                ),
                _btn(
                    "پشتیبانی",
                    "support",
                    icon="support",
                    style="primary",
                ),
            ],
            [
                _btn(
                    "منوی اصلی",
                    "main_menu",
                    icon="back",
                    style="danger",
                )
            ],
        ]
    )


# ============================================================
# Wallet History
# ============================================================

def get_wallet_history_keyboard(
) -> InlineKeyboardMarkup:

    return _markup(
        [
            [
                _btn(
                    "بروزرسانی تاریخچه",
                    "wallet_tx_history",
                    icon="orders",
                    style="primary",
                )
            ],
            [
                _btn(
                    "افزایش موجودی",
                    "charge_fiat",
                    icon="plus",
                    style="success",
                ),
                _btn(
                    "واریز ارزی",
                    "crypto_deposit_menu",
                    icon="wallets",
                    style="primary",
                ),
            ],
            [
                _btn(
                    "حساب کاربری",
                    "user_profile",
                    icon="wallet",
                    style="primary",
                ),
                _btn(
                    "منوی اصلی",
                    "main_menu",
                    icon="back",
                    style="danger",
                ),
            ],
        ]
    )


# ============================================================
# Support
# ============================================================

def get_support_keyboard(
    support_username: Optional[
        str
    ] = None,
) -> InlineKeyboardMarkup:

    rows: list[
        list[
            InlineKeyboardButton
        ]
    ] = []

    username = str(
        support_username
        or ""
    ).strip().lstrip("@")

    if username:

        rows.append(
            [
                _btn(
                    "ارتباط با پشتیبانی",
                    url=(
                        "https://t.me/"
                        f"{username}"
                    ),
                    icon="support",
                    style="success",
                )
            ]
        )

    rows.extend(
        [
            [
                _btn(
                    "سفارش‌های من",
                    "my_orders",
                    icon="orders",
                    style="primary",
                ),
                _btn(
                    "حساب کاربری",
                    "user_profile",
                    icon="wallet",
                    style="primary",
                ),
            ],
            [
                _btn(
                    "منوی اصلی",
                    "main_menu",
                    icon="back",
                    style="danger",
                )
            ],
        ]
    )

    return _markup(
        rows
    )


# ============================================================
# Pagination
# ============================================================

def get_pagination_keyboard(
    current_page: int,
    total_pages: int,
    action_prefix: str,
    *,
    back_callback: str = "main_menu",
) -> InlineKeyboardMarkup:

    current_page = max(
        1,
        int(
            current_page
        ),
    )

    total_pages = max(
        1,
        int(
            total_pages
        ),
    )

    current_page = min(
        current_page,
        total_pages,
    )

    action_prefix = str(
        action_prefix
    ).strip()

    builder = InlineKeyboardBuilder()

    nav: list[
        InlineKeyboardButton
    ] = []

    if (
        current_page
        > 1
    ):

        nav.append(
            _btn(
                "قبلی",
                (
                    f"{action_prefix}"
                    f"_page_"
                    f"{current_page - 1}"
                ),
                style="primary",
            )
        )

    nav.append(
        _btn(
            (
                f"{current_page}"
                " / "
                f"{total_pages}"
            ),
            (
                f"{action_prefix}"
                f"_page_"
                f"{current_page}"
            ),
            style="primary",
        )
    )

    if (
        current_page
        < total_pages
    ):

        nav.append(
            _btn(
                "بعدی",
                (
                    f"{action_prefix}"
                    f"_page_"
                    f"{current_page + 1}"
                ),
                style="primary",
            )
        )

    builder.row(
        *nav
    )

    builder.row(
        _btn(
            "بازگشت",
            back_callback,
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


# ============================================================
# Admin Compatibility
# ============================================================

def get_admin_main_menu(
) -> InlineKeyboardMarkup:

    builder = InlineKeyboardBuilder()

    builder.row(
        _btn(
            "بررسی احراز هویت‌های جدید",
            "admin_kyc_queue",
            icon="wallet",
            style="primary",
        )
    )

    builder.row(
        _btn(
            "آمار و گزارشات مالی",
            "admin_stats",
            icon="flash",
            style="success",
        ),
        _btn(
            "تنظیم نرخ ارز و قیمت‌ها",
            "admin_pricing",
            icon="stars",
            style="primary",
        ),
    )

    builder.row(
        _btn(
            "مدیریت کاربران",
            "admin_users_list",
            icon="users",
            style="primary",
        )
    )

    builder.row(
        _btn(
            "ارسال پیام همگانی",
            "admin_broadcast",
            icon="broadcast",
            style="primary",
        )
    )

    builder.row(
        _btn(
            "خروج از پنل مدیریت",
            "main_menu",
            icon="back",
            style="danger",
        )
    )

    return builder.as_markup()


def get_admin_kyc_review_keyboard(
    user_id: int,
) -> InlineKeyboardMarkup:

    user_id = int(
        user_id
    )

    return _markup(
        [
            [
                _btn(
                    "تأیید احراز هویت",
                    (
                        f"kyc_approve_"
                        f"{user_id}"
                    ),
                    icon="plus",
                    style="success",
                ),
                _btn(
                    "رد مدارک",
                    (
                        f"kyc_reject_"
                        f"{user_id}"
                    ),
                    icon="delete",
                    style="danger",
                ),
            ],
            [
                _btn(
                    "بازگشت به لیست انتظار",
                    "admin_kyc_queue",
                    icon="back",
                    style="primary",
                )
            ],
        ]
    )


# ============================================================
# Public Exports
# ============================================================

__all__ = [
    "get_user_main_menu",
    "get_products_menu_keyboard",
    "get_wallet_menu_keyboard",

    "get_crypto_deposit_currency_keyboard",
    "get_crypto_deposit_destination_keyboard",
    "get_crypto_deposit_cancel_keyboard",
    "get_crypto_receipt_keyboard",
    "get_crypto_note_keyboard",

    "get_external_wallets_keyboard",
    "get_external_wallet_delete_keyboard",
    "get_external_wallet_input_keyboard",

    "get_services_packages_keyboard",

    "get_confirm_order_keyboard",
    "get_checkout_keyboard",
    "get_cancel_order_keyboard",
    "get_price_change_keyboard",
    "get_insufficient_balance_keyboard",

    "get_order_result_keyboard",
    "get_my_orders_keyboard",
    "get_wallet_history_keyboard",

    "get_support_keyboard",
    "get_pagination_keyboard",
    "get_back_keyboard",

    "get_admin_main_menu",
    "get_admin_kyc_review_keyboard",
]