"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePlace = exports.endpointPosAndSide = exports.Side = void 0;
/**
 * Defines a side relative to a character in a sequence.
 *
 * @remarks See {@link SequencePlace} for additional context on usage.
 * @legacy @beta
 */
var Side;
(function (Side) {
    Side[Side["Before"] = 0] = "Before";
    Side[Side["After"] = 1] = "After";
})(Side || (exports.Side = Side = {}));
/**
 * Returns the position and side of the start and end of a sequence.
 *
 * @legacy @beta
 */
function endpointPosAndSide(start, end) {
    const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
    const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
    const startSide = startIsPlainEndpoint ? Side.Before : start?.side;
    const endSide = endIsPlainEndpoint ? Side.Before : end?.side;
    const startPos = startIsPlainEndpoint ? start : start?.pos;
    const endPos = endIsPlainEndpoint ? end : end?.pos;
    return {
        startSide,
        endSide,
        startPos,
        endPos,
    };
}
exports.endpointPosAndSide = endpointPosAndSide;
/**
 * Returns the given place in InteriorSequencePlace form.
 */
function normalizePlace(place) {
    if (typeof place === "number") {
        return { pos: place, side: Side.Before };
    }
    if (place === "start") {
        return { pos: -1, side: Side.After };
    }
    if (place === "end") {
        return { pos: -1, side: Side.Before };
    }
    return place;
}
exports.normalizePlace = normalizePlace;
//# sourceMappingURL=sequencePlace.js.map