/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { SchemaAndPolicy, IForestSubscription, TreeFieldStoredSchema, TreeTypeSet } from "../core/index.js";
import { type FlexTreeContext, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type FlexibleNodeContent } from "../feature-libraries/index.js";
import type { ImplicitAnnotatedFieldSchema } from "./fieldSchema.js";
import { type InsertableContent } from "./unhydratedFlexTreeFromInsertable.js";
import { type ImplicitAnnotatedAllowedTypes, type UnhydratedFlexTreeNode } from "./core/index.js";
/**
 * Prepare content from a user for insertion into a tree.
 * @remarks
 * This validates and converts the input, and if necessary invokes {@link prepareContentForHydration}.
 *
 * The next edit made to `destinationContext`'s forest must be the creation of a detached field containing this content,
 * (Triggering {@link ForestEvents.afterRootFieldCreated}) otherwise hydration will break.
 */
export declare function prepareForInsertion<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitAnnotatedFieldSchema, destinationContext: FlexTreeContext, destinationSchema: TreeFieldStoredSchema): TIn extends undefined ? undefined : FlexibleNodeContent;
/**
 * {@link prepareForInsertion} but batched for array content.
 * @remarks
 * This is for inserting items into an array, not a inserting a {@link TreeArrayNode} (that would use {@link prepareForInsertion}).
 *
 * The next edits made to `destinationContext`'s forest must be the creation of a detached field.
 * One edit for each item in `data`, in order.
 *
 * @privateRemarks
 * This has to be done as a single operation for all items in data
 * (as opposed to mapping {@link prepareForInsertion} over the array)
 * due to how the eventing in prepareContentForHydration works.
 */
export declare function prepareArrayContentForInsertion(data: readonly InsertableContent[], schema: ImplicitAnnotatedAllowedTypes, destinationContext: FlexTreeContext, destinationSchema: TreeTypeSet): FlexibleFieldContent;
/**
 * Split out from {@link prepareForInsertion} as to allow use without a context.
 *
 * @param hydratedData - If specified, the `mapTrees` will be prepared for hydration into this context.
 * `undefined` when `mapTrees` are being inserted into an {@link Unhydrated} tree.
 *
 * @remarks
 * Adding this entry point is a workaround for initialize not currently having a context.
 */
export declare function prepareForInsertionContextless<TIn extends InsertableContent | undefined>(data: TIn, schema: ImplicitAnnotatedFieldSchema, schemaAndPolicy: SchemaAndPolicy, hydratedData: FlexTreeHydratedContextMinimal | undefined, destinationSchema: TreeFieldStoredSchema): TIn extends undefined ? undefined : FlexibleNodeContent;
/**
 * Records any {@link TreeNode}s in the given `content` tree and does the necessary bookkeeping to ensure they are synchronized with subsequent reads of the tree.
 * Additionally populates any {@link UnhydratedFlexTreeField.pendingDefault}s using the provided `context`.
 *
 * @remarks If the content tree contains has any associated {@link TreeNode}s, this function must be called just prior to inserting the content into the tree.
 * Specifically, no other content may be inserted into the tree between the invocation of this function and the insertion of `content`.
 * The insertion of `content` must occur or else this function will cause memory leaks.
 *
 * Exported for testing purposes: otherwise should not be used outside this module.
 * @param content - the content subsequence to be inserted, of which might deeply contain {@link TreeNode}s which need to be hydrated.
 * @param forest - the forest the content is being inserted into.
 */
export declare function prepareContentForHydration(content: readonly UnhydratedFlexTreeNode[], forest: IForestSubscription, context: FlexTreeHydratedContextMinimal): void;
//# sourceMappingURL=prepareForInsertion.d.ts.map