"""JavaScript generator for page jump and first/last navigation helpers."""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/js/navigation.ipynb.

# %% auto #0
__all__ = ['generate_page_nav_js']

# %% ../../nbs/js/navigation.ipynb #jn000003
from ..core.button_ids import CardStackButtonIds

# %% ../../nbs/js/navigation.ipynb #jn000005
def generate_page_nav_js(
    button_ids: CardStackButtonIds,  # Button IDs for navigation triggers
) -> str:  # JavaScript code fragment for page navigation
    """Generate JS for page-based and first/last navigation functions."""
    return f"""
        // === Page Navigation ===
        ns.jumpPageUp = function() {{
            const btn = document.getElementById('{button_ids.nav_page_up}');
            if (btn) btn.click();
        }};

        ns.jumpPageDown = function() {{
            const btn = document.getElementById('{button_ids.nav_page_down}');
            if (btn) btn.click();
        }};

        ns.jumpToFirstItem = function() {{
            const btn = document.getElementById('{button_ids.nav_first}');
            if (btn) btn.click();
        }};

        ns.jumpToLastItem = function() {{
            const btn = document.getElementById('{button_ids.nav_last}');
            if (btn) btn.click();
        }};
    """
