/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert, fail } from "@fluidframework/core-utils/internal";
export function idAllocatorFromMaxId(maxId = undefined) {
    return idAllocatorFromState({ maxId: maxId ?? -1 });
}
export function idAllocatorFromState(state) {
    return {
        allocate: (c) => {
            const count = c ?? 1;
            assert(count > 0, 0x5cf /* Must allocate at least one ID */);
            const id = state.maxId + 1;
            state.maxId += count;
            return id;
        },
        getMaxId: () => state.maxId,
    };
}
export const fakeIdAllocator = {
    allocate: () => fail(0xae6 /* Should not allocate IDs */),
    getMaxId: () => 0,
};
//# sourceMappingURL=idAllocator.js.map