/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ICodecFamily, ICodecOptions } from "../../codec";
import { ChangeFamily, EditBuilder, ChangeRebaser, FieldKindIdentifier, UpPath, TaggedChange, RevisionTag, ChangeFamilyEditor, FieldUpPath, ChangesetLocalId, RevisionMetadataSource, RevisionInfo, ChangeAtomIdMap, ITreeCursor, DeltaRoot, StoredSchemaCollection, DeltaDetachedNodeId } from "../../core";
import { EncodedChunk } from "../chunked-forest";
import { FieldChangeHandler, RebaseRevisionMetadata } from "./fieldChangeHandler";
import { FieldKind, FieldKindWithEditor, FullSchemaPolicy } from "./fieldKind";
import { FieldChangeset, ModularChangeset } from "./modularChangeTypes";
/**
 * Implementation of ChangeFamily which delegates work in a given field to the appropriate FieldKind
 * as determined by the schema.
 */
export declare class ModularChangeFamily implements ChangeFamily<ModularEditBuilder, ModularChangeset>, ChangeRebaser<ModularChangeset> {
    readonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindWithEditor>;
    static readonly emptyChange: ModularChangeset;
    readonly codecs: ICodecFamily<ModularChangeset>;
    constructor(fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindWithEditor>, codecOptions: ICodecOptions);
    get rebaser(): ChangeRebaser<ModularChangeset>;
    /**
     * Produces an equivalent list of `FieldChangeset`s that all target the same {@link FieldKind}.
     * @param changes - The list of `FieldChange`s whose `FieldChangeset`s needs to be normalized.
     * @returns An object that contains both the equivalent list of `FieldChangeset`s that all
     * target the same {@link FieldKind}, and the `FieldKind` that they target.
     * The returned `FieldChangeset`s may be a shallow copy of the input `FieldChange`s.
     */
    private normalizeFieldChanges;
    compose(changes: TaggedChange<ModularChangeset>[]): ModularChangeset;
    private composeFieldMaps;
    private composeNodeChanges;
    /**
     * @param change - The change to invert.
     * @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when
     * performing a sandwich rebase.
     * @param repairStore - The store to query for repair data.
     */
    invert(change: TaggedChange<ModularChangeset>, isRollback: boolean): ModularChangeset;
    private invertFieldMap;
    private invertNodeChange;
    rebase(change: ModularChangeset, over: TaggedChange<ModularChangeset>, revisionMetadata: RevisionMetadataSource): ModularChangeset;
    private rebaseFieldMap;
    private rebaseNodeChange;
    private pruneFieldMap;
    private pruneNodeChange;
    buildEditor(changeReceiver: (change: ModularChangeset) => void): ModularEditBuilder;
}
/**
 * Returns the set of removed roots that should be in memory for the given change to be applied.
 * A removed root is relevant if any of the following is true:
 * - It is being inserted
 * - It is being restored
 * - It is being edited
 * - The ID it is associated with is being changed
 *
 * May be conservative by returning more removed roots than strictly necessary.
 *
 * Will never return IDs for non-root trees, even if they are removed.
 *
 * @param change - The change to be applied.
 * @param fieldKinds - The field kinds to delegate to.
 */
export declare function relevantRemovedRoots({ change, revision }: TaggedChange<ModularChangeset>, fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindWithEditor>): Iterable<DeltaDetachedNodeId>;
/**
 * @param change - The change to convert into a delta.
 * @param fieldKinds - The field kinds to delegate to.
 */
export declare function intoDelta(taggedChange: TaggedChange<ModularChangeset>, fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindWithEditor>): DeltaRoot;
/**
 * @alpha
 * @param revInfos - This should describe all revisions in the rebase path, even if not part of the current base changeset.
 * For example, when rebasing change B from a local branch [A, B, C] over a branch [X, Y], the `revInfos` must include
 * the changes [A⁻¹ X, Y, A'] for each rebase step of B.
 * @param baseRevisions - The set of revisions in the changeset being rebased over.
 * For example, when rebasing change B from a local branch [A, B, C] over a branch [X, Y], the `baseRevisions` must include
 * revisions [A⁻¹ X, Y, A'] if rebasing over the composition of all those changes, or
 * revision [A⁻¹] for the first rebase, then [X], etc. if rebasing over edits individually.
 * @returns - RebaseRevisionMetadata to be passed to `FieldChangeRebaser.rebase`*
 */
export declare function rebaseRevisionMetadataFromInfo(revInfos: readonly RevisionInfo[], baseRevisions: (RevisionTag | undefined)[]): RebaseRevisionMetadata;
export declare function getFieldKind(fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKind>, kind: FieldKindIdentifier): FieldKindWithEditor;
export declare function getChangeHandler(fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKind>, kind: FieldKindIdentifier): FieldChangeHandler<unknown>;
export declare class ModularEditBuilder extends EditBuilder<ModularChangeset> {
    private transactionDepth;
    private idAllocator;
    constructor(family: ChangeFamily<ChangeFamilyEditor, ModularChangeset>, changeReceiver: (change: ModularChangeset) => void);
    enterTransaction(): void;
    exitTransaction(): void;
    apply(change: ModularChangeset): void;
    buildTrees(firstId: ChangesetLocalId, newContent: ITreeCursor | readonly ITreeCursor[], shapeInfo?: {
        schema: StoredSchemaCollection;
        policy: FullSchemaPolicy;
    }): GlobalEditDescription;
    /**
     * Adds a change to the edit builder
     * @param field - the field which is being edited
     * @param fieldKind - the kind of the field
     * @param change - the change to the field
     * @param maxId - the highest `ChangesetLocalId` used in this change
     */
    submitChange(field: FieldUpPath, fieldKind: FieldKindIdentifier, change: FieldChangeset, maxId?: ChangesetLocalId): void;
    submitChanges(changes: EditDescription[], maxId?: ChangesetLocalId): void;
    generateId(count?: number): ChangesetLocalId;
    private buildChangeMap;
    addNodeExistsConstraint(path: UpPath): void;
}
/**
 * @alpha
 */
export interface FieldEditDescription {
    type: "field";
    field: FieldUpPath;
    fieldKind: FieldKindIdentifier;
    change: FieldChangeset;
}
/**
 * @alpha
 */
export interface GlobalEditDescription {
    type: "global";
    builds?: ChangeAtomIdMap<EncodedChunk>;
}
/**
 * @alpha
 */
export type EditDescription = FieldEditDescription | GlobalEditDescription;
//# sourceMappingURL=modularChangeFamily.d.ts.map