"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortPathParameters = void 0;
function sortPathParameters(path, params) {
    if (path && params) {
        const map = new Map();
        for (let i = 0; i < params.length; i++) {
            if (params[i].language.default.serializedName) {
                map.set(`{${params[i].language.default.serializedName}}`, i);
            }
        }
        let index = 0;
        const paths = path.split('/');
        for (let i = 0; i < params.length; i++) {
            if (map.has(paths[i])) {
                // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
                swap(params, index, map.get(paths[i]));
                map.set(paths[i], index++);
            }
        }
    }
    return params;
}
exports.sortPathParameters = sortPathParameters;
function swap(params, left, right) {
    if (!params || left === right) {
        return;
    }
    const tmp = params[left];
    params[left] = params[right];
    params[right] = tmp;
}
//# sourceMappingURL=sort-parameters.js.map