import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import type{DocumentLocator}from'../../../ai/types.js';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraClipboardWriteFailure,type LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';export type SelectionAction='ask'|'quote'|'cite'|'copy';export interface SelectionActionDetail{readonly action:SelectionAction;readonly text:string;readonly anchor:DocumentLocator|null;}export interface LyraSelectionToolbarEventMap{'lr-selection-action':CustomEvent>;'lr-dismiss':CustomEvent;'lr-copy':CustomEvent;'lr-error':CustomEvent;'lr-copy-error':CustomEvent;} /** * `` — a nonmodal action toolbar positioned above selected text. It carries * the selected text and a format-neutral document anchor into ask, quote, cite, or copy actions. * Controlled action refreshes preserve a focused action by id, otherwise move to the nearest * survivor, or focus the toolbar when no actions remain, without overriding newer focus moves. * * The four built-in actions are the shipped set; `actions` reorders or subsets them. Anything * beyond them -- "translate", "define", "search web" -- goes in the `actions` slot, which renders * after the built-ins inside the same `role="toolbar"` element and joins the same roving-tabindex * group (Home/End/Arrow, RTL-mirrored), so a fifth action does not mean reimplementing the * positioning, keyboard, and dismissal behavior from scratch. The toolbar traverses open shadow * roots and slots to manage each real action rather than treating a custom-element or wrapper root * as a focus target merely because it exposes `focus()`. A slotted action carries its own * accessible name and click handling; this component only manages its tab stop. Availability, * actionability, and `tabindex` changes are reconciled live; focused removals/unavailable actions * move to the nearest survivor or stable toolbar without overriding newer external focus. * Duplicate built-in names normalize first-wins before rendering, roving focus, or action events. * * Public anchor records and action collections take bounded, clone-owned readonly snapshots. * Create and reassign a new record or array after changes; mutating the assigned value does not * update the view. * * @customElement lr-selection-toolbar * @slot actions - Extra actions rendered after the built-in ask/quote/cite/copy buttons, inside * the same `role="toolbar"` element and roving-tabindex group. * @event lr-selection-action - An action was chosen. `detail: { action, text, anchor }`. * @event lr-dismiss - The toolbar was dismissed with Escape. * @event lr-copy - Clipboard writing fulfilled. Frozen `detail: { ok: true, text }`. * @event lr-error - Clipboard writing failed; generic no-detail notification. * @event lr-copy-error - Clipboard writing failed. Frozen * `detail: { ok: false, text, reason, error }`. * @csspart toolbar - The floating `role="toolbar"` surface. * @csspart action - Every action button. * @csspart action-ask - The ask action. * @csspart action-quote - The quote action. * @csspart action-cite - The cite action. * @csspart action-copy - The copy action. * @cssprop [--lr-selection-toolbar-placement-gap=var(--lr-space-s)] - Non-negative distance * between the selection and toolbar, and between the toolbar and viewport during collision * avoidance. Unitless pixel values and `px`, `rem`, and `em` values are resolved live; invalid values * fall back to the default and negative values clamp to `0`. * @cssprop [--lr-overlay-surface=var(--lr-color-surface-overlay)] - Shared floating-surface fill, * on the toolbar. * @cssprop [--lr-overlay-border=var(--lr-color-border)] - Shared floating-surface edge colour, on * the toolbar. * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on * the toolbar. * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface. * @status stable * @since 7.0.0 */ export declare class LyraSelectionToolbar extends LyraElement{protected static readonly ownedCollectionProperties:readonly string[];static styles:import("lit").CSSResultGroup[];protected static readonly immutableEventDetails:readonly string[];open:boolean;text:string; /** Clone-owned selection anchor. Reassign a new record after changing any path segment. */ anchor:DocumentLocator|null;rect:DOMRectReadOnly|null; /** * Controlled action set. A focused action survives reordering by id; if it is removed, focus * moves to the nearest action or the stable toolbar when the set becomes empty. Duplicate names * normalize first-wins. */ actions:readonly SelectionAction[];label:string;accessibleLabel:string|null;private copyFailed;private toolbar?;private overlay?;private stopPositioning?; /** Announces a copy failure -- the copy button's own `aria-label`/text flipping to * `localize('copyFailed')` is not reliably re-announced by a screen reader without an * explicit live region, unlike every other failure/transition state in this family. */ private sink?;private activeActionIndex;private lifecycleGeneration;private positioningGeneration;private rovingGeneration;private pendingActionFocus?;private focusedAction?;private actionObserver?;private managedActionStops;private actionTabIndexLeases;private get effectiveActions();connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncOpenLifecycle;private dismiss;private activate;private isCurrentLifecycle; /** Every stop in the `role="toolbar"` roving group, in rendered order: the built-in actions * first, then whatever a consumer slotted into `actions`. Slotted stops live in the host's * light DOM (not `renderRoot`), so every containment check below has to accept both. */ private actionButtons;private actionRoots;private actionForStop; /** Whether `button` is still one of this toolbar's own stops -- rendered inside the shadow root, * or slotted as a light-DOM child of the host. */ private ownsActionButton;private onActionsSlotChange;private syncRovingStops; /** A manager-written tabindex must not turn an otherwise non-action element into a permanent * authored action after that manager releases it. */ private hasAuthoredActionTabIndex;private writeActionTabIndex;private releaseActionTabIndex;private releaseManagedActionStops;private setRovingStops;private observeActionChanges;private onActionMutations;private onToolbarFocusIn;private containNativeEvent;private onToolbarFocusOut;private onToolbarKeyDown;private actionPartNames;private actionLabel; /** Coerces a caller-supplied `rect` to finite geometry before it reaches any style sink -- * `rect` is typed `DOMRectReadOnly`, but TS cannot enforce that across the property boundary, * and `coordinates()` feeds a `styleMap()` whose first commit serializes the whole `style` * value as one string (see `sanitizeCssColor`'s doc comment for why that matters). */ private safeRect;private viewportBounds;private px;private coordinates; /** Resolves the shared selection-anchor and collision-edge distance from the host's live * custom property. Placement works in viewport pixels, so it must not pass an unresolved CSS * expression into geometry math; unsupported values retain the historical 8px fallback. */ private placementGapPx;private updateToolbarPosition;private startPositioning;private retirePositioning;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-selection-toolbar':LyraSelectionToolbar;}}