/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { MergeTreeDeltaType, } from "./ops";
/**
 * Creates the op for annotating the markers with the provided properties
 * @param marker - The marker to annotate
 * @param props - The properties to annotate the marker with
 * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
 * @returns The annotate op
 */
export function createAnnotateMarkerOp(marker, props, combiningOp) {
    const id = marker.getId();
    if (!id) {
        return undefined;
    }
    return {
        combiningOp,
        props,
        relativePos1: { id, before: true },
        relativePos2: { id },
        type: MergeTreeDeltaType.ANNOTATE,
    };
}
/**
 * Creates the op for annotating the range with the provided properties
 * @param start - The inclusive start position of the range to annotate
 * @param end - The exclusive end position of the range to annotate
 * @param props - The properties to annotate the range with
 * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
 * @returns The annotate op
 */
export function createAnnotateRangeOp(start, end, props, combiningOp) {
    return {
        combiningOp,
        pos1: start,
        pos2: end,
        props,
        type: MergeTreeDeltaType.ANNOTATE,
    };
}
/**
 * Creates the op to remove a range
 *
 * @param start - The inclusive start of the range to remove
 * @param end - The exclusive end of the range to remove
 */
export function createRemoveRangeOp(start, end) {
    return {
        pos1: start,
        pos2: end,
        type: MergeTreeDeltaType.REMOVE,
    };
}
/**
 *
 * @param pos - The position to insert the segment at
 * @param segment - The segment to insert
 */
export function createInsertSegmentOp(pos, segment) {
    return createInsertOp(pos, segment.toJSONObject());
}
export function createInsertOp(pos, segSpec) {
    return {
        pos1: pos,
        seg: segSpec,
        type: MergeTreeDeltaType.INSERT,
    };
}
/**
 *
 * @param ops - The ops to group
 */
export function createGroupOp(...ops) {
    return {
        ops,
        type: MergeTreeDeltaType.GROUP,
    };
}
//# sourceMappingURL=opBuilder.js.map