import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraAnchorTargetEventMap}from'../../../internal/anchor-target.js';import type{LyraAnchor}from'../document-viewer/anchors.js';import type{LyraViewerDiagnosticEventDetail}from'../viewer-diagnostics.js';export type{LyraViewerDiagnostic,LyraViewerDiagnosticCode,LyraViewerDiagnosticEventDetail,LyraViewerDiagnosticSeverity,}from'../viewer-diagnostics.js';import type{LyraSearchChangeDetail}from'../../../internal/text-viewer-target.js'; /** One entry of `getHeadingTree()`'s document-ordered outline. Same shape as ``'s * own `MarkdownHeadingItem` -- kept as a separate, structurally identical type rather than * importing across component families, matching this library's per-component-family type * boundary. */ export interface DocxHeadingItem{id:string;label:string;level:number;}export interface LyraDocxViewerEventMap extends LyraAnchorTargetEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-viewer-diagnostic':CustomEvent;'lr-search-change':CustomEvent;}declare class LyraDocxViewerBase extends LyraElement{}declare const LyraDocxViewer_base:Omit &(new(...args:ConstructorParameters)=>InstanceType &import("../../../lyra.js").LyraAnchorTarget&{renderAnchorLiveRegion():unknown;}); /** * Renders a DOCX document as sanitized semantic HTML using the optional * `mammoth` converter and `dompurify` sanitizer peers. DOCX content is always * sanitized; there is no unsanitized rendering mode for uploaded documents. * Converted markup then passes through the passive-document profile: anchors, form controls, and * custom elements are unwrapped to ordinary text/children where safe, remote navigation/resource * attributes are removed, and an `` itself never remains. Images render only inline base64 GIF, * JPEG, PNG, or WebP data; same-document SVG fragment references may remain. * * Every rendered heading's slug (computed via the shared GitHub-slugger-style `Slugger` -- the same * algorithm and shared class `` uses, so identical heading text slugs identically * across both viewers) is stamped as its `id` and cached into `getHeadingTree()`'s document-ordered * outline -- unconditional, unlike ``'s opt-in `heading-anchors`, since this * component's rendered HTML is always internal (mammoth's own conversion output), never a raw string * a consumer might serialize verbatim. Adopts `DocumentAnchorTarget`: `fragment` anchors resolve * against that outline, `text-quote` anchors via `internal/text-quote.ts`'s shared scope/resolve * helpers; `highlights` re-resolve by quote after every render (never by node identity), so a * highlight painted before its quote is in the rendered markup yet simply paints once a later load * contains it. At most 100 quotes are painted per pass from a 1,000-entry candidate window; * `activeHighlightId` is retained from anywhere in the bounded host snapshot and resolved first. * Keyboard-accessible * highlight actions are rendered only for quotes that resolved * against the currently loaded document, so an action never presents an enabled no-op. Highlight * painting uses `internal/text-highlights.ts`'s `acquireHighlightHandle()` -- * the CSS Custom Highlight API where the browser supports it (no DOM mutation at all), a ``-wrap * fallback otherwise. `search()`/`searchNext()`/`searchPrevious()`/`clearSearch()` do a * case-insensitive substring search over the rendered content's text and paint every match as a * `` (the active one also carrying `search-match-active`) -- a separate, * always-real-DOM-element mechanism from the tone-based highlight painting above, since search needs * many simultaneously-visible matches rather than one set of themed spans. * A nonempty host `aria-label` makes the host the sole named semantic owner; otherwise the loaded * shadow document owns the explicit-empty, `name`, or localized fallback label. * * @customElement lr-docx-viewer * @event lr-render-error - Fired only when loading, conversion, or sanitization fails terminally. * @event lr-viewer-diagnostic - Structured non-fatal converter diagnostics. `detail.diagnostic` * has code `docx-conversion-message`, severity, source, and the original peer value as `cause`. * @event lr-search-change - Fired whenever the search query, match count, or active match index * changes, including source-reset and effective-locale re-evaluation. `detail: { query, * matchCount, matchCountExact, activeIndex }`. Search accepts at most 4,096 query code units, * scans at most 4,000,000 code units, and retains at most 1,000 matches; a false * `matchCountExact` makes `matchCount` a lower bound after any ceiling is reached. * @event lr-highlight-activate - A painted `text-quote` highlight was clicked or its resolved * keyboard action was activated. `detail: { highlightId }`. * @event lr-text-select - Fired on selection end inside the rendered content. `detail: { text, * anchor, rects }`; `anchor` is a `text-quote` `LyraAnchor` scoped to the rendered content, or * `null` if the selection couldn't be anchored. * @event lr-anchor-result - Fired after an `anchor` property assignment or a `scrollToAnchor()` * call is applied. `detail: { found }`. * @csspart base - The root container with explicit `aria-busy` loading state. * @csspart body - The scrollable document body. * @csspart content - The semantic document content. * @csspart error - The error message region. * @csspart spinner - The visible tokenized loading treatment and ordinary text label. * @csspart highlight - A painted `text-quote` highlight (``, ``-wrap fallback path only). * @csspart highlight-actions - Keyboard-accessible actions for the resolved text highlights. * @csspart highlight-action - One native highlight activation button. * @csspart search-match - A painted in-document search match. * @csspart search-match-active - The currently active search match (also carries `search-match`). * @cssprop [--lr-docx-viewer-max-height=none] - Maximum block size of the scrollable document body before it scrolls internally. Also settable via the `max-height` property. * @cssprop [--lr-docx-viewer-table-header-background=var(--lr-color-brand-quiet)] - Background of a * rendered document table's header row (`th`), independent of the highlight backgrounds below. * @cssprop --lr-docx-viewer-highlight-accent-background - Accent highlight background. * @cssprop --lr-docx-viewer-highlight-success-background - Success highlight background. * @cssprop --lr-docx-viewer-highlight-warning-background - Warning highlight background. * @cssprop --lr-docx-viewer-highlight-danger-background - Danger highlight background. * @cssprop --lr-docx-viewer-highlight-neutral-background - Neutral highlight background. * @cssprop --lr-docx-viewer-highlight-active-background - Active highlight background. * @cssprop --lr-docx-viewer-highlight-active-outline - Active fallback-highlight outline. * @cssprop --lr-docx-viewer-search-match-background - Search-match background. * @cssprop --lr-docx-viewer-search-match-active-background - Active search-match background. * @cssprop --lr-docx-viewer-search-match-active-foreground - Active search-match foreground. * @status stable * @since 4.0.0 */ export declare class LyraDocxViewer extends LyraDocxViewer_base{static styles:import("lit").CSSResultGroup[]; /** URL to fetch and convert as a DOCX document. */ src:string; /** Accessible name for the rendered document when the host has no `aria-label`. Host * `aria-label` wins by attribute presence, including an empty value. */ name:string; /** A CSS `max-height` that caps the scrollable document body; invalid values are ignored. */ maxHeight:string; /** Anchor kinds this viewer resolves via `scrollToAnchor()`. Readonly. */ readonly anchorKinds:readonly['fragment','text-quote'];private fetchState;private searchMatches;private searchMatchCountExact;private searchActiveIndex;private resolvedHighlightActions;private generation;private lastLoadSrc;private loadLibrary;private readonly announcements; /** Document-ordered heading outline, cached on every successful load (see `getHeadingTree()`). */ private headingTree; /** Lazily acquired the first time a highlight needs painting; released on disconnect. */ private highlightHandle?; /** The most recently resolved `text-quote` highlight ranges, kept for `onContentClick()`'s * coordinate hit-test -- the CSS Custom Highlight API paints ranges without creating any DOM * element to attach a click listener to, so activation is resolved by comparing the click point * against each range's own `getClientRects()` instead, uniformly across both paint paths. */ private resolvedHighlightRanges;private pendingResolvedHighlightActions;private resolvedHighlightActionSyncPending;private searchQuery;private paintedSearchMarks; /** Bounded normalized corpus plus reusable occurrence cache for the current loaded document. */ private textIndexCache;private textIndexMappingDirty;private textIndexLocale?;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private contentRoot;private resetSearchForContentChange;private load;private failWithLocalizedMessage; /** Parses the already-sanitized markup once (`DOMParser`), stamps a `Slugger`-computed `id` on * every `h1`-`h6`, and caches the resulting document-ordered outline into `headingTree`. A fresh * `Slugger` per call, matching ``'s own per-parse instance, so re-loading a new * document never carries duplicate-slug state from a previous one. Traversal admits at most the * shared 20,000-node ceiling, and the slugger's monotonic suffix cursor keeps aggregate duplicate * membership work linear across that bounded pass. */ private stampHeadings; /** A document-ordered, flattened heading outline -- empty until a document has finished loading. */ getHeadingTree():DocxHeadingItem[];protected applyAnchor(anchor:LyraAnchor):Promise;private applyFragmentAnchor;private applyTextQuoteAnchor; /** Overrides `DocumentAnchorTarget`'s default (whole render-root) selection scope -- only * `[part="content"]` is a meaningful text-quote scope for this component. */ protected computeSelectionAnchor(range:Range):LyraAnchor|null;private ensureHighlightHandle; /** Re-resolves every `text-quote` highlight against the current rendered content and repaints * via `acquireHighlightHandle()` -- resolution is always by quote text, never by node identity. * `fragment` highlights aren't painted (there is no literal span of text to wrap/underline for a * whole section). When there is no loaded content (idle/loading/error), every tone is explicitly * cleared rather than left as-is, since a previously-loaded document's content (and its painted * ranges) may no longer exist in the DOM at all. */ private repaintHighlights; /** Mirrors the synchronous range-resolution result into render state after the current Lit * update has finished. Repainting runs from `updated()`, so assigning the state there directly * would create a change-in-update warning; coalescing through one microtask also ensures a rapid * loading -> loaded transition exposes only the latest document's resolved entries. */ private syncResolvedHighlightActions; /** Drops both live ranges and render-facing entries before a document can leave the loaded state. * This is synchronous so neither a `src` transition nor reconnect can render an old document's * enabled action beside idle/loading UI while the next repaint microtask is still pending. */ private resetResolvedHighlightActions; /** Hit-tests a click point against every currently-resolved highlight's `getClientRects()`, * topmost (last-resolved) first -- the CSS Custom Highlight API paints ranges without creating * any DOM element to attach a click listener to, so this works identically on both paint paths. */ private hitTestHighlightAt;private onContentClick;private highlightActionLabel;private activateHighlightAction;private renderHighlightActions;private getTextIndex; /** Rebuilds only the node-bearing scope after fallback `` writes, preserving occurrence * offsets and the folded corpus when the normalized text is unchanged. */ private currentTextIndex; /** Case-insensitive substring search over the rendered content's text (via `getTextIndex()`). * An empty/whitespace-only query, or no loaded content, behaves like `clearSearch()` and resolves * `0`. Queries are limited to 4,096 code units, the indexed corpus to 1,000,000 code units and * 20,000 text nodes, and each pass to 4,000,000 scanned code units. Up to 1,000 matches are * retained and a 200-match window is painted (see * `paintSearchMatches()`), with the first one scrolled into view; * `lr-search-change.detail.matchCountExact=false` identifies the resolved return as a lower * bound. */ search(query:string):Promise; /** Advances to the next match, wrapping to the first after the last. Resolves `false` (no-op) * when there are no matches. */ searchNext():Promise; /** Moves to the previous match, wrapping to the last before the first. Resolves `false` (no-op) * when there are no matches. */ searchPrevious():Promise; /** Clears the query, matches, and any painted marks, and resets `lr-search-change` to a * 0-match/no-active-index state. */ clearSearch():void;private emitSearchChange;private scrollToActiveSearchMatch;private clearSearchPaint; /** Unwraps any previously-painted marks, then re-derives fresh `Range`s from every stored * `{ start, end }` match against the *current* DOM (`getTextIndex()`, cached per loaded document * rather than rebuilt on every call -- see `textIndexCache`) and wraps each in a ``. Matches are wrapped in descending offset order deliberately: two * matches sharing one text node would otherwise have the earlier match's stored offset * invalidated by the later match's own `splitText()` calls -- processing highest-offset first * only ever truncates the *end* of a shared node, which never shifts an earlier, not-yet-processed * offset. */ private paintSearchMatches;private renderBody;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-docx-viewer':LyraDocxViewer;}}