/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ICriticalContainerError } from "@fluidframework/container-definitions";
import { IBatchMessage } from "@fluidframework/container-definitions/internal";
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { ICompressionRuntimeOptions } from "../containerRuntime.js";
import { IPendingBatchMessage, PendingStateManager } from "../pendingStateManager.js";
import { BatchSequenceNumbers } from "./batchManager.js";
import { BatchMessage, IBatch, IBatchCheckpoint } from "./definitions.js";
import { OpCompressor } from "./opCompressor.js";
import { OpGroupingManager } from "./opGroupingManager.js";
import { OpSplitter } from "./opSplitter.js";
export interface IOutboxConfig {
    readonly compressionOptions: ICompressionRuntimeOptions;
    readonly maxBatchSizeInBytes: number;
    readonly disablePartialFlush: boolean;
}
export interface IOutboxParameters {
    readonly shouldSend: () => boolean;
    readonly pendingStateManager: PendingStateManager;
    readonly submitBatchFn: ((batch: IBatchMessage[], referenceSequenceNumber?: number) => number) | undefined;
    readonly legacySendBatchFn: (batch: IBatch) => void;
    readonly config: IOutboxConfig;
    readonly compressor: OpCompressor;
    readonly splitter: OpSplitter;
    readonly logger: ITelemetryBaseLogger;
    readonly groupingManager: OpGroupingManager;
    readonly getCurrentSequenceNumbers: () => BatchSequenceNumbers;
    readonly reSubmit: (message: IPendingBatchMessage) => void;
    readonly opReentrancy: () => boolean;
    readonly closeContainer: (error?: ICriticalContainerError) => void;
}
/**
 * Temporarily increase the stack limit while executing the provided action.
 * If a negative value is provided for `length`, no stack frames will be collected.
 * If Infinity is provided, all frames will be collected.
 *
 * ADO:4663 - add this to the common packages.
 *
 * @param action - action which returns an error
 * @param length - number of stack frames to collect, 50 if unspecified.
 * @returns the result of the action provided
 */
export declare function getLongStack<T>(action: () => T, length?: number): T;
export declare class Outbox {
    private readonly params;
    private readonly mc;
    private readonly mainBatch;
    private readonly blobAttachBatch;
    private readonly idAllocationBatch;
    private batchRebasesToReport;
    private rebasing;
    /**
     * Track the number of ops which were detected to have a mismatched
     * reference sequence number, in order to self-throttle the telemetry events.
     *
     * This should be removed as part of ADO:2322
     */
    private readonly maxMismatchedOpsToReport;
    private mismatchedOpsReported;
    constructor(params: IOutboxParameters);
    get messageCount(): number;
    get isEmpty(): boolean;
    /**
     * If we detect that the reference sequence number of the incoming message does not match
     * what was already in the batch managers, this means that batching has been interrupted so
     * we will flush the accumulated messages to account for that and create a new batch with the new
     * message as the first message.
     */
    private maybeFlushPartialBatch;
    submit(message: BatchMessage): void;
    submitBlobAttach(message: BatchMessage): void;
    submitIdAllocation(message: BatchMessage): void;
    private addMessageToBatchManager;
    flush(): void;
    private flushAll;
    private flushInternal;
    /**
     * Rebases a batch. All the ops in the batch are resubmitted to the runtime and
     * they will end up back in the same batch manager they were flushed from and subsequently flushed.
     *
     * @param rawBatch - the batch to be rebased
     */
    private rebase;
    private isContextReentrant;
    /**
     * As necessary and enabled, compresses and chunks the given batch.
     *
     * @remarks - If chunking happens, a side effect here is that 1 or more chunks are queued immediately for sending in next JS turn.
     *
     * @param batch - Raw or Grouped batch to consider for compression/chunking
     * @returns Either (A) the original batch, (B) a compressed batch (same length as original),
     * or (C) a batch containing the last chunk (plus empty placeholders from compression if applicable).
     */
    private compressBatch;
    /**
     * Sends the batch object to the container context to be sent over the wire.
     *
     * @param batch - batch to be sent
     */
    private sendBatch;
    private persistBatch;
    checkpoint(): {
        mainBatch: IBatchCheckpoint;
        idAllocationBatch: IBatchCheckpoint;
        blobAttachBatch: IBatchCheckpoint;
    };
}
//# sourceMappingURL=outbox.d.ts.map