/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { TypedEventEmitter } from "@fluid-internal/client-utils";
import { IDisposable, IEvent, IEventProvider, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { IThrottler } from "../throttler.js";
import { ISummarizerClientElection } from "./summarizerClientElection.js";
import { EnqueueSummarizeResult, IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, ISummarizeResults, ISummarizer, ISummarizerEvents } from "./summarizerTypes.js";
import { SummaryCollection } from "./summaryCollection.js";
export declare enum SummaryManagerState {
    Off = 0,
    Starting = 1,
    Running = 2,
    Stopping = 3
}
export interface IConnectedEvents extends IEvent {
    (event: "connected", listener: (clientId: string) => void): any;
    (event: "disconnected", listener: () => void): any;
}
/**
 * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.
 *
 * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced
 * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.
 */
export interface IConnectedState extends IEventProvider<IConnectedEvents> {
    readonly connected: boolean;
    /**
     * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our
     * latest connection (even if we've since disconnected!).  Although this happens to be the behavior we want in
     * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId
     * undefined while disconnected).  To protect against this, let's assume this field can't be trusted while
     * disconnected and instead separately track "latest clientId" in SummaryManager.
     */
    readonly clientId: string | undefined;
}
export interface ISummaryManagerConfig {
    initialDelayMs: number;
    opsToBypassInitialDelay: number;
}
/**
 * SummaryManager is created by parent container (i.e. interactive container with clientType !== "summarizer") only.
 * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or
 * stopping existing summarizer client.
 */
export declare class SummaryManager extends TypedEventEmitter<ISummarizerEvents> implements IDisposable {
    private readonly clientElection;
    private readonly connectedState;
    private readonly summaryCollection;
    /** Creates summarizer by asking interactive container to spawn summarizing container and
     * get back its Summarizer instance. */
    private readonly createSummarizerFn;
    private readonly startThrottler;
    private readonly logger;
    private readonly opsToBypassInitialDelay;
    private readonly initialDelayMs;
    private latestClientId;
    private state;
    private summarizer?;
    private _disposed;
    get disposed(): boolean;
    get currentState(): SummaryManagerState;
    constructor(clientElection: ISummarizerClientElection, connectedState: IConnectedState, summaryCollection: Pick<SummaryCollection, "opsSinceLastAck" | "addOpListener" | "removeOpListener">, parentLogger: ITelemetryBaseLogger, 
    /** Creates summarizer by asking interactive container to spawn summarizing container and
     * get back its Summarizer instance. */
    createSummarizerFn: () => Promise<ISummarizer>, startThrottler: IThrottler, { initialDelayMs, opsToBypassInitialDelay, }?: Readonly<Partial<ISummaryManagerConfig>>);
    /**
     * Until start is called, the SummaryManager won't begin attempting to start summarization.  This ensures there's
     * a window between construction and starting where the caller can attach listeners.
     */
    start(): void;
    private readonly handleConnected;
    private readonly handleDisconnected;
    private readonly handleSummarizeEvent;
    private static readonly isStartingOrRunning;
    private getShouldSummarizeState;
    private readonly refreshSummarizer;
    private startSummarization;
    private stop;
    /**
     * Implements initial delay before creating summarizer
     * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).
     * `false` if summarizer should start immediately due to too many unsummarized ops.
     */
    private delayBeforeCreatingSummarizer;
    summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;
    enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
    dispose(): void;
}
//# sourceMappingURL=summaryManager.d.ts.map