"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.keyAsDetachedField = exports.detachedFieldAsKey = exports.rootField = exports.rootFieldKey = exports.EmptyKey = void 0;
const schema_stored_1 = require("../schema-stored");
const util_1 = require("../../util");
/**
 * The empty key ("") is used for unnamed relationships, such as the indexer
 * of an explicit array node.
 *
 * This key is a hint that this field is the primary function of the node,
 * and in some abstractions the APIs for this field should be inlined onto the node.
 *
 * TODO:
 * This has to be a FieldKey since different nodes will have different TreeFieldStoredSchema for it.
 * This makes it prone to collisions and suggests
 * that this intention may be better conveyed by metadata on the ITreeSchema.
 * @alpha
 */
exports.EmptyKey = (0, util_1.brand)("");
/**
 * FieldKey to use for the root of documents in places that need to refer to detached sequences or the root.
 * TODO: if we do want to standardize on a single value for this,
 * it likely should be namespaced or a UUID to avoid risk of collisions.
 * @alpha
 */
exports.rootFieldKey = (0, util_1.brand)("rootFieldKey");
/**
 * @alpha
 */
exports.rootField = keyAsDetachedField(exports.rootFieldKey);
/**
 * Some code abstracts the root as a node with detached fields as its fields.
 * This maps detached field to field keys for thus use.
 *
 * @returns `field` as a {@link FieldKey} usable on a special root node serving as a parent of detached fields.
 * @alpha
 */
function detachedFieldAsKey(field) {
    return (0, util_1.brand)((0, util_1.extractFromOpaque)(field));
}
exports.detachedFieldAsKey = detachedFieldAsKey;
/**
 * The inverse of {@link detachedFieldAsKey}.
 * Thus must only be used on {@link FieldKey}s which were produced via {@link detachedFieldAsKey},
 * and with the same scope (ex: forest) as the detachedFieldAsKey was originally from.
 * @alpha
 */
function keyAsDetachedField(key) {
    return (0, util_1.brand)(key);
}
exports.keyAsDetachedField = keyAsDetachedField;
//# sourceMappingURL=types.js.map