import type { CloseReason } from "../types.mjs"; /** See `PencereViewerOptions.routing`. */ export interface RoutingOptions { /** Build the fragment for a given slide index. Default: `#p{n+1}`. */ pattern?: (index: number) => string; /** * Parse the current `location.hash` into a slide index, or return * `null` when the URL does not identify a slide. Default matches * the default pattern. */ parse?: (hash: string) => number | null; } export interface ResolvedRouting { pattern: (index: number) => string; parse: (hash: string) => number | null; } /** * Normalize the `routing` option into a concrete pattern/parse pair, * or `null` when routing is disabled. */ export declare function resolveRouting(option: boolean | RoutingOptions | undefined): ResolvedRouting | null; export interface RoutingControllerOptions { /** Resolved routing config, or `null` to disable. */ routing: ResolvedRouting | null; /** Called when popstate dismisses the viewer. */ onPopClose: (reason: CloseReason) => void; /** Query whether the viewer is currently open. */ isOpen: () => boolean; /** Query the currently displayed slide index. */ getIndex: () => number; /** Query the total number of items. */ getItemCount: () => number; /** Abort signal used to tear down the popstate listener. */ signal: AbortSignal; } /** * Hash-based deep linking (#75). On `open()` the controller pushes * `#p{n+1}` into the URL; on every slide change it replaces the * current entry; on `popstate` it closes the viewer so the browser * Back button dismisses the lightbox naturally. */ export declare class RoutingController { private readonly routing; private readonly onPopClose; private readonly isOpen; private readonly getIndex; private readonly getItemCount; private routedOpen; private suppressPop; constructor(options: RoutingControllerOptions); get enabled(): boolean; /** * Look at the current `location.hash`, and if it identifies a * valid slide, return the matching index. Otherwise `null`. */ parseCurrentLocation(): number | null; /** Push the current slide's fragment. Called from `open()`. */ pushFragment(): void; /** Replace the current slide's fragment. Called on `change`. */ replaceFragment(): void; /** * Unwind any pushed history entry when the viewer closes from * inside pencere. popstate-driven closes must NOT step history * again. */ handleClose(): void; private syncFragment; }