import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{HighlightActivateDetail,LyraAnchor,LyraHighlight}from'../document-viewer/anchors.js';export type DocumentPreviewStatus='idle'|'converting'|'ready'|'error';export interface LyraDocumentPreviewEventMap{'lr-render-error':CustomEvent<{error:unknown;}>;'lr-download':CustomEvent<{src:string;filename:string;}>;'lr-highlight-activate':CustomEvent;} /** * `` — a format-dispatching viewer for one document/ * attachment, plus the visual state machine for an async server-side * conversion a host app runs in front of it. * * Format dispatch is intentionally minimal (see this family's scope * guidance): only `text/*`/`application/json` (plain, scrollable `
` —
* no syntax highlighting; compose `` yourself via the
* `unsupported` slot for that) and `image/*` (a contained ``) render
* inline. Everything else — PDF, office documents, video, audio, or any
* unrecognized MIME type — falls back to a generic "can't preview this"
* state: a file glyph, a short message, and (when `src` is set) a native
* `` link. This is a deliberate ceiling, not a gap: this
* component ships a dispatch *shell*, not a format registry. The
* `unsupported` slot is the escape hatch for every format left out of the
* built-in three — plug in a PDF.js viewer, an office-doc renderer, a
* ``, or anything else keyed off `mime-type` yourself.
*
* `status="converting"` is a second, independent axis from format dispatch.
* This component does not know your backend's conversion API shape and
* therefore owns none of the actual polling/fetch — a host that's converting
* a non-natively-previewable format server-side (e.g. .docx → .pdf) polls
* its own backend and updates `status`/`progress`/`src` here as that
* proceeds. This component only *visualizes* that state: an indeterminate
* spinner, or a determinate one once `progress` is supplied. Once the host
* flips `status` to `"ready"` (typically alongside a new `src`/`mime-type`
* pointing at the converted artifact), normal format dispatch resumes.
*
* The one piece of async work this component *does* own is fetching a
* `text/*`/`application/json` `src` itself (there's no other way to get a
* `
`'s text content from a URL) — gated behind the same generation-
* counter guard ``'s `resolve()` uses, plus an
* `AbortController`, so a `src` reassigned mid-fetch cancels the obsolete
* request and can't have a stale response clobber a newer one. A
* failure here (network error, non-2xx response) renders inline via
* `[part="error"]` and fires `lr-render-error`, independently of the
* host-owned `status` prop — mirrors ``'s identical stance
* that a *rendering* failure and a host's own state machine are different
* concerns.
*
* Every `src` is validated for the DOM/API sink that consumes it. Text
* fetches and image sources allow relative URLs plus `http:`, `https:`,
* `blob:`, and `data:`. Download links deliberately exclude `data:` because
* following a `data:text/html` URL can create an active document. Unsafe or
* malformed URLs never reach `fetch()`, an image `src`, or an anchor `href`;
* they render a non-interactive fallback/error instead.
*
* Accessibility: entering an indeterminate converting/loading state is announced through the
* pre-mounted shared document-level polite region, while its visible `[part="spinner"]` remains
* ordinary shadow content. Once real `progress` is available, the spinner becomes a standard
* `role="progressbar"`, self-describing via `aria-valuenow`. Error transitions use the shared
* assertive region; `[part="error"]` remains visible ordinary text so it is still encountered in
* reading order without relying on a shadow-root live region.
*
* @customElement lr-document-preview
* @slot unsupported - Escape hatch: when populated, its content renders
*   *instead of* the generic download fallback for any `mime-type` this
*   component doesn't natively support (i.e. whenever format dispatch would
*   otherwise fall through to "generic"). Ignored while `mime-type` resolves
*   to `text`/`image` dispatch, or while `status` is `"converting"`/`"error"`.
* @event lr-download - `detail: { src, filename }` — fired when the safe
*   generic-download fallback link is activated. The browser download itself
*   needs no JS (a plain `` handles it); this is purely for a host
*   that wants to observe/log the download.
* @event lr-render-error - `detail: { error }` — fired when this
*   component rejects an unsafe text/JSON URL or when its own
*   `text/*`/`application/json` `fetch(src)` fails. Distinct from
*   `status="error"`, which is entirely host-driven (see the class doc).
* @event lr-highlight-activate - A region highlight was activated (image format only).
*   `detail: { highlightId }`.
* @csspart base - The root container.
* @csspart header - The row above the body, holding `filename`. Hidden entirely when `filename` is unset.
* @csspart filename - The filename text.
* @csspart body - The wrapper around whichever content is currently showing (text/image preview, the generic fallback, the spinner, or the error message).
* @csspart spinner - The converting/loading indicator — ordinary content while indeterminate or, once numeric progress is known, a determinate `role="progressbar"`. Used both for `status="converting"` and for this component's own in-flight text fetch.
* @csspart error - The visible ordinary-text error region, used both for `status="error"` and for a failed text fetch; transitions announce through the shared assertive sink.
* @csspart download-link - The `` affordance in the generic fallback. Only rendered when `src` is set and safe for link navigation.
* @csspart frame-viewport - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart frame-content - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart frame-controls - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart frame-zoom-in - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart frame-zoom-out - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart frame-reset - Forwarded from the internal `` when `zoomable` (image format only).
* @csspart highlight-layer - The wrapper around every rendered region highlight (image format only).
* @csspart region-highlight - One region highlight (`data-tone`, `data-active`) (image format only).
* @csspart region-highlight-target - Transparent activation geometry around a region highlight,
*   with a minimum pointer/focus area independent of the visual rectangle (image format only).
* @csspart highlight-actions - Non-overlapping actions used when multiple region highlights would
*   otherwise create overlapping minimum hit areas (image format only).
* @csspart region-highlight-action - One action in the non-overlapping highlight action list.
*   ArrowDown/ArrowUp (or ArrowLeft/ArrowRight under RTL) plus Home/End move focus across this
*   list, matching ``'s roving shortcut; every action keeps its own native
*   tabindex, so Tab still steps through each one individually.
* @cssprop [--lr-document-preview-max-height=none] - Maximum body block size before the preview scrolls internally.
* @cssprop [--lr-document-preview-font=var(--lr-font-mono)] - Font used for plain-text previews.
* @cssprop [--lr-document-preview-download-link-hover-bg=color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-hover))] - Hover background of the generic download link.
* @cssprop [--lr-document-preview-download-link-active-bg=color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active))] - Pressed background of the generic download link.
* @cssprop [--lr-document-preview-spin-duration=var(--lr-transition-ambient)] - Timing of one
*   indeterminate loading-indicator rotation.
* @cssprop [--lr-document-preview-progress=0] - Unitless 0-100 completion of the determinate
*   loading ring (multiplied by `1%` in its conic gradient). Written inline by the component from
*   the clamped `progress` value, so it is a read-out rather than a consumer knob.
* @cssprop [--lr-document-preview-active-border=var(--lr-color-warning, var(--lr-color-brand))] -
*   Border color of the `[part="region-highlight"]` matching `activeHighlightId` (image format
*   only). Distinct from the resting highlight border.
* @cssprop [--lr-document-preview-highlight-accent-color=var(--lr-color-brand)] - Accent highlight border and hover tint.
* @cssprop [--lr-document-preview-highlight-success-color=var(--lr-color-success)] - Success highlight border and hover tint.
* @cssprop [--lr-document-preview-highlight-warning-color=var(--lr-color-warning)] - Warning highlight border and hover tint.
* @cssprop [--lr-document-preview-highlight-danger-color=var(--lr-color-danger)] - Danger highlight border and hover tint.
* @cssprop [--lr-document-preview-highlight-neutral-color=var(--lr-color-neutral)] - Neutral highlight border and hover tint.
* @status stable
* @since 4.0.0
*/
export declare class LyraDocumentPreview extends LyraElement{static styles:import("lit").CSSResultGroup[];
/** URL to fetch (for `text`/`application/json`) or display (`image`, or as
*  the generic fallback's download `href`). The value is validated against
*  a sink-specific scheme allowlist before use. Optional — gracefully
*  absent while, e.g., a conversion is still in progress. */
src:string;
/** Drives format dispatch using the case-insensitive MIME essence before parameters.
* Removing the attribute is treated as an absent format at render time. */
mimeType:string;
/** Shown in the header and used as the download link's suggested filename. */
filename:string;
/** Alternative text for an image preview. When omitted, `filename` (or a
* localized generic fallback) is used. Set this explicitly to an empty
* string when the preview image is decorative. */
alt?:string;
/** Host-owned lifecycle state. `"converting"` shows the spinner regardless
*  of `mime-type`/`src`; `"error"` shows `errorText` regardless of
*  either. `"idle"`/`"ready"` both resume normal format dispatch — this
*  component doesn't require a host that has no conversion step to ever
*  set `"ready"` explicitly. */
status:DocumentPreviewStatus;
/** 0-100. Only consulted while `status="converting"`. Unset (the default)
*  renders the indeterminate spinner instead of a determinate progress bar. */
progress?:number;
/** Shown (via `[part="error"]`) while `status="error"`. Caller-supplied text, not routed through
*  `localize()` -- app/network data, not library copy. */
errorText:string;
/** A CSS length (e.g. `"24rem"`); once set, `[part="body"]` scrolls
*  internally past this height instead of growing the page — same
*  contract as ``'s identically-named prop. Fitting images stay centered;
*  oversized images start inside the reachable scroll range. Invalid values are ignored. */
maxHeight:string;
/** Wraps the rendered image (image format only) in an internal ``. `false`
*  (the default) preserves today's exact DOM -- an inline thumbnail (e.g. in a chat stream) must
*  not unexpectedly grow a focusable zoom-chrome viewport; an inspection surface opts in. */
zoomable:boolean;
/** Omits the generic fallback's download action when a composing shell owns that action.
* Property-only: this is a composition control rather than author-facing markup state. */
suppressDownload:boolean;private _highlights;private _regionHighlights;
/** Display-only region highlights over the image-format preview (see the class doc's format-
* dispatch scope -- text/generic formats never render these). IDs are trimmed and must be
* nonempty; the first record for an ID is retained and blank or later duplicates are ignored. */
get highlights():readonly LyraHighlight[];set highlights(value:readonly LyraHighlight[]);activeHighlightId:string|null;readonly anchorKinds:LyraAnchor['kind'][];private hasUnsupportedSlot;private textFetch;private generation;private invalidUrlReportedFor;private readonly announcements;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncAnnouncementState;private fetchText;private onUnsupportedSlotChange;private onDownloadClick;
/** Renders `[part="spinner"]` -- indeterminate ordinary content plus a
*  visually-hidden label (the spoken transition uses the shared sink) when
*  `progressValue` is absent, or a `role="progressbar"` once it's a finite
*  0-100 number. Shared by the host-driven `"converting"` state and this
*  component's own in-flight text fetch (which never has a numeric
*  progress of its own to report). */
private renderSpinner;private renderError;private renderTextPreview;private renderImagePreview;private stopPanZoomEvent;
/** Wraps `content` in the internal `` when `zoomable`; otherwise renders it
*  (plus the highlight layer, which needs the same relatively-positioned sibling context either
*  way) unwrapped, preserving pre-`zoomable` DOM exactly. Mirrors ``'s identical
*  helper. */
private renderZoomableWrapper;private projectRegionHighlights;private regionHighlights;private highlightActionLabel;private renderHighlightLayer;
/** Moves focus among the `region-highlight-action` list to match ``'s
*  roving arrow-key shortcut. Every action button keeps its own native tabindex (this list
*  isn't a roving-tabindex widget), so this only offers ArrowDown/ArrowUp/Home/End as a
*  faster alternative to repeated Tab, direction-aware under RTL. */
private onHighlightActionKeyDown;private renderHighlightActions;
/** Scrolls a `region` highlight into view (image format only). See ``'s
*  identical method for the id/anchor-reference resolution and no-retry-loop rationale. */
scrollToAnchor(target:LyraAnchor|string):Promise;private renderDownloadFallback;
/** The `` element renders unconditionally (not just while
*  `hasUnsupportedSlot`) so a slot-assignment change is always observable
*  via `slotchange` -- same reasoning as ``'s
*  always-rendered optional slots. */
private renderGenericFallback;private renderBody;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-document-preview':LyraDocumentPreview;}}