/** * Page navigation controller for the PDF viewer. * * Manages the page number input, previous/next buttons, and tracks * the currently visible page using an `IntersectionObserver`. * When the user scrolls, the observer detects which page is centered * in the viewport and updates the navigation state accordingly. */ export default class PageNav { /** Input field displaying and accepting the current page number. */ private readonly pageInput; /** Span element showing the total number of pages. */ private readonly totalPage; /** Button to navigate to the previous page. */ private readonly prevPageButton; /** Button to navigate to the next page. */ private readonly nextPageButton; /** The scrollable page view container. */ private readonly pageView; /** All rendered page DOM nodes in document order. */ private readonly pageNodes; /** Form element wrapping the page number input. */ private readonly pageForm; /** Minimum valid page number (always 1). */ private readonly minPage; /** Maximum valid page number (equals total pages). */ private readonly maxPage; /** Last known valid page number, used as a fallback for invalid input. */ private lastPage; /** Callback invoked when the currently visible page changes. */ private changeListener; /** * Initializes page navigation by querying dependent DOM nodes, * setting up the `IntersectionObserver`, and binding event listeners. * * @param context - The root element containing all navigation-related elements. * @param pageNumber - The total number of pages in the document. */ constructor(context: HTMLElement, pageNumber: number); /** * Scrolls to the specified page and updates the navigation state. * * @param pageNum - The 1-based page number to navigate to. */ activatePage(pageNum: number): void; /** * Updates the page input value and button disabled states to reflect the given page number. * * @param pageNum - The 1-based page number to display. */ private updatePage; /** * Parses the page number from the input field, clamps it to the valid range, * and navigates to the resulting page. If the input is not a valid number, * it is reverted to the last known valid page. */ private enterPage; /** * Registers a callback that is invoked whenever the visible page changes. * * @param listener - Callback receiving the 1-based page number of the currently visible page. * @returns This instance for chaining. */ onChange(listener: (pageNum: number) => void): PageNav; /** * Returns the page number currently displayed in the navigation input. * * @returns The current 1-based page number. */ getCurrentPageNumber(): number; }