/** * THE single navigation-EXECUTION primitive for the whole lib. * * Link BUILDING is unified by `composeContentUrl`; the new-tab DECISION is * unified by `computeIsNewTab`/`decideNewTab`. This is the third leg: ONE place * that EXECUTES a navigation — encoding new-tab-vs-same-tab + internal-vs-external * + embed-vs-host + the runtime-then-router-then-window fallback chain. Every * surface routes through it: * - chat cards / chips / markdown links → `executeNavigation` (click form), * via the thin `handleChatNavClick` wrapper. * - buttons / page rows / form redirects → `executeNavigationImperative` directly. * * Decision tree (the SAME one `handleChatNavClick` used — copied verbatim so * behavior is byte-identical; the hub's chat-click behavior MUST NOT change): * 1. empty href → no-op (click form preventDefaults + reports handled) * 2. (click form) modifier / non-primary button → NOT handled — let the * browser do its native thing (`` opens a new tab, etc.) * 3. `computeIsNewTab` true → `runtime.navigation.openExternal(href)` else * `window.open(href, '_blank', noopener,noreferrer)` * 4. else (same-tab) → `runtime.navigation.navigate({href,path,targetPlatform})`; * if the host didn't handle it → `fallbackNavigate(stripped)` else * `window.location.assign(stripped)` * * `runtime` is nullable: surfaces with no `ChatRuntimeContext` mounted (e.g. the * announcement bar) pass `null` and get the plain same-tab fallback — there's no * new-tab/embed decision to make without a runtime. */ import type { ChatRuntime } from '../../../contexts/chat-runtime-context'; /** Minimal mouse-event surface — structural so chip buttons / tiles can call it * without casting `React.MouseEvent`. */ export interface NavClickEvent { preventDefault(): void; button?: number; metaKey?: boolean; ctrlKey?: boolean; shiftKey?: boolean; altKey?: boolean; } export interface ExecuteNavigationClickArgs { event: NavClickEvent; runtime: ChatRuntime | null | undefined; href: string; path?: string | null; targetPlatform?: string | null; /** Host router fallback for same-origin soft-nav when the runtime doesn't wire * `navigation.navigate` — pass `useRouter().push`. Without it, falls back to a * full-page `window.location.assign`. */ fallbackNavigate?: (path: string) => void; } export interface ExecuteNavigationImperativeArgs { runtime: ChatRuntime | null | undefined; href: string; targetPlatform?: string | null; fallbackNavigate?: (path: string) => void; } /** * Click-handler form. Returns `true` when it took action (called * `preventDefault`); `false` for modifier / non-primary clicks the browser * should handle natively. Spread the result into your anchor's `onClick`. */ export declare function executeNavigation({ event, runtime, href, path, targetPlatform, fallbackNavigate, }: ExecuteNavigationClickArgs): boolean; /** * Imperative form — for buttons, list-row onClicks, and post-action redirects * that aren't anchor clicks. Same decision tree, no event/modifier handling. */ export declare function executeNavigationImperative({ runtime, href, targetPlatform, fallbackNavigate, }: ExecuteNavigationImperativeArgs): void; /** * @deprecated Call {@link executeNavigation} directly. Kept only so external * embedders' imports keep resolving; no lib code path goes through it. */ export declare function handleChatNavClick(event: NavClickEvent, runtime: ChatRuntime | null | undefined, { href, path, targetPlatform }: ChatNavClickInput, fallbackNavigate?: (path: string) => void): boolean; /** @deprecated Argument shape of the deprecated {@link handleChatNavClick}. */ export interface ChatNavClickInput { href: string; path?: string | null; targetPlatform?: string | null; } //# sourceMappingURL=execute-navigation.d.ts.map