"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.idAllocatorFromState = exports.idAllocatorFromMaxId = void 0;
const core_utils_1 = require("@fluidframework/core-utils");
/**
 * @public
 */
function idAllocatorFromMaxId(maxId = undefined) {
    return idAllocatorFromState({ maxId: maxId ?? -1 });
}
exports.idAllocatorFromMaxId = idAllocatorFromMaxId;
function idAllocatorFromState(state) {
    return (c) => {
        const count = c ?? 1;
        (0, core_utils_1.assert)(count > 0, 0x5cf /* Must allocate at least one ID */);
        const id = state.maxId + 1;
        state.maxId += count;
        return id;
    };
}
exports.idAllocatorFromState = idAllocatorFromState;
//# sourceMappingURL=idAllocator.js.map