/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { IExperimentalIncrementalSummaryContext, ITelemetryContext, IGarbageCollectionData, CreateChildSummarizerNodeParam, IGarbageCollectionDetailsBase, ISummarizeInternalResult, ISummarizeResult, ISummarizerNodeConfigWithGC, ISummarizerNodeWithGC, SummarizeInternalFn } from "@fluidframework/runtime-definitions/internal";
import { SummarizerNode } from "./summarizerNode.js";
import { EscapedPath, IStartSummaryResult, ISummarizerNodeRootContract, SummaryNode, ValidateSummaryResult } from "./summarizerNodeUtils.js";
export interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {
}
/**
 * Extends the functionality of SummarizerNode to manage this node's garbage collection data:
 *
 * - Adds a new API `getGCData` to return GC data of this node.
 *
 * - Caches the result of `getGCData` to be used if nothing changes between summaries.
 *
 * - Manages the used routes of this node. These are used to identify if this node is referenced in the document
 * and to determine if the node's used state changed since last summary.
 *
 * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls
 * directly into summarizeInternal method.
 */
export declare class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {
    private readonly summarizeFn;
    private readonly getGCDataFn?;
    private wipSerializedUsedRoutes;
    private referenceUsedRoutes;
    private readonly baseGCDetailsP;
    private baseGCDetailsLoaded;
    private readonly childNodesBaseGCDetailsP;
    private gcData;
    private usedRoutes;
    private readonly gcDisabled;
    /**
     * Do not call constructor directly.
     * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.
     */
    constructor(logger: ITelemetryBaseLogger, summarizeFn: (fullTree: boolean, trackState: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext) => Promise<ISummarizeInternalResult>, config: ISummarizerNodeConfigWithGC, changeSequenceNumber: number, 
    /** Undefined means created without summary */
    latestSummary?: SummaryNode, wipSummaryLogger?: ITelemetryBaseLogger, getGCDataFn?: ((fullGC?: boolean) => Promise<IGarbageCollectionData>) | undefined, getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>, 
    /** A unique id of this node to be logged when sending telemetry. */
    telemetryId?: string);
    /**
     * Loads state from this node's initial GC summary details. This contains the following data from the last summary
     * seen by the server for this client:
     * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.
     * - gcData: The garbage collection data of this node that is required for running GC.
     */
    private loadBaseGCDetails;
    summarize(fullTree: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
    /**
     * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from
     * the previous summary. Else, it gets new GC data from the underlying Fluid object.
     * @param fullGC - true to bypass optimizations and force full generation of GC data.
     */
    getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
    /**
     * Called during the start of a summary. Updates the work-in-progress used routes.
     */
    startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryBaseLogger, latestSummaryRefSeqNum: number): IStartSummaryResult;
    /**
     * Validates that the in-progress summary is correct for all nodes, i.e., GC should have run for non-skipped nodes.
     * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when running GC.
     * In that case, the children will not have work-in-progress state.
     *
     * @returns ValidateSummaryResult which contains a boolean success indicating whether the validation was successful.
     * In case of failure, additional information is returned indicating type of failure and where it was.
     */
    protected validateSummaryCore(parentSkipRecursion: boolean): ValidateSummaryResult;
    private wasGCMissed;
    /**
     * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending
     * summary queue. We track this until we get an ack from the server for this summary.
     * @param proposalHandle - The handle of the summary that was uploaded to the server.
     * @param parentPath - The path of the parent node which is used to build the path of this node.
     * @param parentSkipRecursion - true if the parent of this node skipped recursing the child nodes when summarizing.
     * In that case, the children will not have work-in-progress state.
     */
    protected completeSummaryCore(proposalHandle: string, parentPath: EscapedPath | undefined, parentSkipRecursion: boolean): void;
    /**
     * Clears the work-in-progress state.
     */
    clearSummary(): void;
    /**
     * Called when we get an ack from the server for a summary we sent. Update the reference state of this node
     * from the state in the pending summary queue.
     */
    protected refreshLatestSummaryFromPending(proposalHandle: string, referenceSequenceNumber: number): void;
    /**
     * Override the createChild method to return an instance of SummarizerNodeWithGC.
     */
    createChild(
    /** Summarize function */
    summarizeInternalFn: SummarizeInternalFn, 
    /** Initial id or path part of this node */
    id: string, 
    /**
     * Information needed to create the node.
     * If it is from a base summary, it will assert that a summary has been seen.
     * Attach information if it is created from an attach op.
     */
    createParam: CreateChildSummarizerNodeParam, config?: ISummarizerNodeConfigWithGC, getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>): ISummarizerNodeWithGC;
    /**
     * Updates the state of the child if required. For example, if a summary is currently being  tracked, the child's
     * summary tracking state needs to be updated too.
     * Also, in case a child node gets realized in between Summary Op and Summary Ack, let's initialize the child's
     * pending summary as well. Finally, if the pendingSummaries entries have serializedRoutes, replicate them to the
     * pendingSummaries from the child nodes.
     * @param child - The child node whose state is to be updated.
     * @param id - Initial id or path part of this node
     */
    protected maybeUpdateChildState(child: SummarizerNodeWithGC, id: string): void;
    /**
     * Deletes the child node with the given id.
     */
    deleteChild(id: string): void;
    /**
     * Override the getChild method to return an instance of SummarizerNodeWithGC.
     */
    getChild(id: string): ISummarizerNodeWithGC | undefined;
    isReferenced(): boolean;
    updateUsedRoutes(usedRoutes: string[]): void;
    /**
     * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.
     */
    protected hasChanged(): boolean;
    /**
     * This tells whether the data in this node has changed or not.
     */
    private hasDataChanged;
    /**
     * This tells whether the used state of this node has changed since last successful summary. If the used routes
     * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes
     * was previously used and became unused (or vice versa), its used state has changed.
     */
    private hasUsedStateChanged;
}
/**
 * Creates a root summarizer node with GC functionality built-in.
 * @param logger - Logger to use within SummarizerNode
 * @param summarizeInternalFn - Function to generate summary
 * @param changeSequenceNumber - Sequence number of latest change to new node/subtree
 * @param referenceSequenceNumber - Reference sequence number of last acked summary,
 * or undefined if not loaded from summary
 * @param config - Configure behavior of summarizer node
 * @param getGCDataFn - Function to get the GC data of this node
 * @param baseGCDetailsP - Function to get the initial GC details of this node
 */
export declare const createRootSummarizerNodeWithGC: (logger: ITelemetryBaseLogger, summarizeInternalFn: SummarizeInternalFn, changeSequenceNumber: number, referenceSequenceNumber: number | undefined, config?: ISummarizerNodeConfigWithGC, getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>, getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>) => IRootSummarizerNodeWithGC;
//# sourceMappingURL=summarizerNodeWithGc.d.ts.map