import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export interface LyraGenerationMetricsEventMap{'lr-stop':CustomEvent;}export type GenerationMetricsStatus='idle'|'running'|'complete'; /** * `` — a compact, ticking status readout shown * alongside an in-progress AI response: elapsed time, token count, and * token-throughput, plus a built-in Stop button. Renders as e.g. * `12.3s · 340 tokens · 27 tok/s [Stop]`. * * This is deliberately a *different* concern than the already-landed * ``: that component is about transport/connection * health (idle/connecting/streaming/stalled, heartbeat-aware stall * detection), while this one is a user-facing metrics readout for a * generation that both components' hosts typically already know is * healthily in progress. Neither imports or depends on the other, and a * consumer building a full generation UI is expected to compose both side by * side rather than pick one. * * `status="running"` drives an internal ~1s `setInterval` ticker that recomputes the * elapsed-time display (a plain interval is sufficient here -- unlike * ``'s stall timer, this never needs to be armed with a * precise deadline, only to refresh a display roughly once a second). The * elapsed clock's start instant is `started-at` when set (an epoch-ms * timestamp -- lets a host that already knows exactly when generation began, * e.g. from its own request-dispatch timestamp, feed that in directly and * survive this component being created slightly later than that instant); * when `started-at` is unset, this component captures `Date.now()` when * `status` enters `running`. Entering `complete` clears the ticker and freezes * the elapsed summary; entering `idle` clears it and resets the readout to * zero. This keeps never-started and completed generations distinct. * * `tokens-per-second`, when the host supplies a finite value directly (e.g. from its own * smoothed/windowed rate calculation), is clamped to zero or above and used. Non-finite values * are treated as omitted. When omitted, * this component derives a live figure itself from `token-count` divided by * elapsed seconds -- but only once at least one full second of elapsed time * has accumulated, since dividing by a sub-second elapsed window can produce * wildly-swinging, misleading early readings (e.g. 3 tokens in 40ms reading * as "75 tok/s"). A host that wants a stable figure from the very first tick * should supply `tokens-per-second` itself. The tokens segment and the * throughput segment are independently optional: either, both, or neither * may render depending on what's available, per each property's own doc. * * Accessibility: this readout ticks roughly once per second while running, * which is exactly the kind of high-frequency update * ``/`Announcer` (`../../internal/announcer.js`) exists to * *prevent* from being read aloud verbatim -- routing a per-second numeric * tick through even a throttled announcer would still narrate a new number * to a screen-reader user roughly once every throttle window for as long as * generation runs, which is noise, not information. This component * therefore carries no `role="status"`/`aria-live` of its own and never * announces anything; a host that wants generation-start/-end announced * should pair this with something that announces state *transitions* (e.g. * ``'s mount-time announcement), not this ticking * readout. The one genuinely actionable, infrequent control here -- the Stop * button -- gets a normal, always-present `aria-label`, no different from * any other icon-only button in this library. * * @customElement lr-generation-metrics * @event lr-stop - The built-in Stop button was clicked. No detail payload. * @csspart base - The root inline layout container. * @csspart elapsed - The elapsed-time segment, e.g. `"12.3s"`. Always rendered (reads `"0.0s"` while idle). * @csspart tokens - The token-count segment, e.g. `"340 tokens"`. Only rendered when `token-count` is set. * @csspart throughput - The throughput segment, e.g. `"27 tok/s"`. Only rendered when a value is available (host-supplied or derived; see the class doc). * @csspart stop-button - The built-in Stop button. Only rendered while `status="running"` and `show-stop` is true. * @status stable * @since 9.0.0 */ export declare class LyraGenerationMetrics extends LyraElement{static styles:import("lit").CSSResultGroup[];private _status; /** Generation lifecycle. `idle` is never-started/reset, `running` ticks and permits Stop, and * `complete` freezes the final metrics. Invalid attribute or JavaScript writes fail closed to * `idle`. */ get status():GenerationMetricsStatus;set status(next:GenerationMetricsStatus); /** Epoch-ms timestamp of when generation began. Optional -- when unset (or * when set to a value that fails to parse as a finite number, e.g. an * ISO-8601 date string) while `status` is `running`, this component captures * the current time itself the moment `status` becomes `running` and counts * from there instead (see the class doc). */ startedAt?:number; /** Running token count so far. Finite values are rounded to a non-negative integer; unset or * non-finite values omit the `tokens` segment entirely. */ tokenCount?:number; /** Host-computed tokens/sec figure. Finite values are clamped to zero or above; unset and * non-finite values fall back to a derived `token-count / elapsed-seconds` rate once at least * one second has elapsed. */ tokensPerSecond?:number; /** Whether the built-in Stop button renders at all. Defaults to `true`. * Uses {@link showStopConverter} rather than Lit's default presence-based * `type: Boolean` handling, so a plain-HTML consumer with no way to write * a `.showStop` property binding can still turn this off with * `show-stop="false"`; a Lit template can do the same with either that * attribute string or a `.showStop=${false}` property binding. */ showStop:boolean;private elapsedMs;private tickTimer?;private tickTimerOwner?;private tickTimerDocument?;private tickerGeneration;private fallbackStartMs?;constructor();connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private startTicker;private stopTicker;private get validStartedAt();private computeElapsedMs; /** `tokenCount` normalized to a finite, non-negative integer -- `undefined` while unset or * non-finite (the `tokens` segment is omitted entirely; see the class doc). */ private get validTokenCount(); /** `tokens-per-second` when set; otherwise a derived figure once enough * elapsed time has accumulated for it to be meaningful; otherwise * `undefined` (the throughput segment doesn't render at all). */ private get effectiveTokensPerSecond();private onStopClick;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-generation-metrics':LyraGenerationMetrics;}}