/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
import { ClientVersionDispatchingCodecBuilder } from "../../../codec/index.js";
import { type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk } from "../../../core/index.js";
import { type Brand } from "../../../util/index.js";
import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
import type { FieldBatch } from "./fieldBatch.js";
import { EncodedFieldBatchV2 } from "./format/index.js";
import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
/**
 * Reference ID for a chunk that is incrementally encoded.
 */
export type ChunkReferenceId = Brand<number, "forest.ChunkReferenceId">;
/**
 * Properties for incremental encoding.
 * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.
 * @remarks
 * This supports features like incremental summarization where the summary from these fields can be re-used if
 * unchanged between summaries.
 * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes
 * list and identifier table) and does not rely on context from its parent.
 */
export interface IncrementalEncoder {
    /**
     * Returns whether a node / field should be incrementally encoded.
     * @remarks See {@link IncrementalEncodingPolicy}.
     */
    shouldEncodeIncrementally: IncrementalEncodingPolicy;
    /**
     * Called to encode an incremental field at the cursor.
     * The chunks for this field are encoded separately from the main buffer.
     * @param cursor - The cursor pointing to the field to encode.
     * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.
     * @returns The reference IDs of the encoded chunks in the field.
     * This is used to retrieve the encoded chunks later.
     */
    encodeIncrementalField(cursor: ITreeCursorSynchronous, chunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2): ChunkReferenceId[];
}
/**
 * Properties for incremental decoding.
 *
 * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.
 * @remarks
 * See {@link IncrementalEncoder} for more details.
 */
export interface IncrementalDecoder {
    /**
     * Called to decode an incremental chunk with the given reference ID.
     * @param referenceId - The reference ID of the chunk to decode.
     * @param chunkDecoder - A function that decodes the chunk.
     * @returns The decoded chunk.
     */
    decodeIncrementalChunk(referenceId: ChunkReferenceId, chunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk): TreeChunk;
}
/**
 * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.
 */
export interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {
}
export interface FieldBatchEncodingContext {
    readonly encodeType: TreeCompressionStrategy;
    readonly idCompressor: IIdCompressor;
    readonly originatorId: SessionId;
    readonly schema?: SchemaAndPolicy;
    /**
     * An encoder / decoder for encoding and decoding of incremental fields.
     * This will be defined if incremental encoding is supported and enabled.
     */
    readonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;
}
/**
 * @remarks
 * Fields in this batch currently don't have field schema for the root, which limits optimizations.
 */
export type FieldBatchCodec = ReturnType<typeof fieldBatchCodecBuilder.build>;
/**
 * {@link ClientVersionDispatchingCodecBuilder} for field batch codecs.
 */
export declare const fieldBatchCodecBuilder: ClientVersionDispatchingCodecBuilder<import("../../../codec/codec.js").ICodecOptions, FieldBatch, FieldBatchEncodingContext, Brand<1, "FieldBatchFormatVersion"> | Brand<2, "FieldBatchFormatVersion">, "FieldBatch">;
//# sourceMappingURL=codecs.d.ts.map