"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createGroupOp = exports.createInsertOp = exports.createInsertSegmentOp = exports.createObliterateRangeOp = exports.createRemoveRangeOp = exports.createAnnotateRangeOp = exports.createAnnotateMarkerOp = void 0;
const ops_1 = require("./ops.cjs");
/**
 * 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
 * @returns The annotate op
 *
 * @internal
 */
function createAnnotateMarkerOp(marker, props) {
    const id = marker.getId();
    if (!id) {
        return undefined;
    }
    return {
        props,
        relativePos1: { id, before: true },
        relativePos2: { id },
        type: ops_1.MergeTreeDeltaType.ANNOTATE,
    };
}
exports.createAnnotateMarkerOp = createAnnotateMarkerOp;
/**
 * 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
 * @returns The annotate op
 *
 * @internal
 */
function createAnnotateRangeOp(start, end, props) {
    return {
        pos1: start,
        pos2: end,
        props,
        type: ops_1.MergeTreeDeltaType.ANNOTATE,
    };
}
exports.createAnnotateRangeOp = createAnnotateRangeOp;
/**
 * 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
 *
 * @internal
 */
function createRemoveRangeOp(start, end) {
    return {
        pos1: start,
        pos2: end,
        type: ops_1.MergeTreeDeltaType.REMOVE,
    };
}
exports.createRemoveRangeOp = createRemoveRangeOp;
/**
 * Creates the op to obliterate a range
 *
 * @param start - The inclusive start of the range to obliterate
 * @param end - The exclusive end of the range to obliterate
 *
 * @internal
 */
// eslint-disable-next-line import/no-deprecated
function createObliterateRangeOp(start, end) {
    return {
        pos1: start,
        pos2: end,
        type: ops_1.MergeTreeDeltaType.OBLITERATE,
    };
}
exports.createObliterateRangeOp = createObliterateRangeOp;
/**
 *
 * @param pos - The position to insert the segment at
 * @param segment - The segment to insert
 *
 * @internal
 */
function createInsertSegmentOp(pos, segment) {
    return createInsertOp(pos, segment.toJSONObject());
}
exports.createInsertSegmentOp = createInsertSegmentOp;
/**
 * @internal
 */
function createInsertOp(pos, segSpec) {
    return {
        pos1: pos,
        seg: segSpec,
        type: ops_1.MergeTreeDeltaType.INSERT,
    };
}
exports.createInsertOp = createInsertOp;
/**
 *
 * @param ops - The ops to group
 *
 * @deprecated The ability to create group ops will be removed in an upcoming
 * release, as group ops are redundant with he native batching capabilities of
 * the runtime
 *
 * @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with he native batching capabilities of the runtime
 * @internal
 */
// eslint-disable-next-line import/no-deprecated
function createGroupOp(...ops) {
    return {
        ops,
        type: ops_1.MergeTreeDeltaType.GROUP,
    };
}
exports.createGroupOp = createGroupOp;
//# sourceMappingURL=opBuilder.cjs.map