/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { makeRandom } from "@fluid-private/stochastic-test-utils";
import { unreachableCase } from "@fluidframework/core-utils";
import { SequenceField as SF } from "../../../feature-libraries/index.js";
import { brand } from "../../../util/index.js";
var Operation;
(function (Operation) {
    Operation[Operation["EditChild"] = 0] = "EditChild";
    Operation[Operation["Remove"] = 1] = "Remove";
    Operation[Operation["Insert"] = 2] = "Insert";
})(Operation || (Operation = {}));
/**
 * @param seed - Random seed used to generate the change.
 * @param maxIndex - Maximum child index for the generated change.
 * @returns Randomly generated change.
 */
export function generateRandomChange(seed, maxIndex, childChangeGenerator) {
    const random = makeRandom(seed);
    const builder = SF.sequenceFieldEditor;
    const operation = random.integer(Operation.EditChild, Operation.Insert);
    switch (operation) {
        case Operation.EditChild:
            return builder.buildChildChange(random.integer(0, maxIndex), childChangeGenerator(random.integer(0, Number.MAX_SAFE_INTEGER)));
        case Operation.Insert:
            return builder.insert(random.integer(0, maxIndex), 1, brand(0));
        case Operation.Remove:
            return builder.remove(random.integer(0, maxIndex), random.integer(1, 10), brand(0));
        default:
            unreachableCase(operation);
    }
}
//# sourceMappingURL=randomChangeGenerator.js.map