"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
exports.__esModule = true;
var RMOAS = __importStar(require("../rmoas.types"));
/**
 * With an array of common parameters filter down them to what isn't already present in a list of
 * non-common parameters.
 *
 * @param parameters Array of parameters defined at the operation level.
 * @param commonParameters Array of **common** parameters defined at the path item level.
 */
function dedupeCommonParameters(parameters, commonParameters) {
    return commonParameters.filter(function (param) {
        return !parameters.find(function (param2) {
            if (param.name && param2.name) {
                return param.name === param2.name && param["in"] === param2["in"];
            }
            else if (RMOAS.isRef(param) && RMOAS.isRef(param2)) {
                return param.$ref === param2.$ref;
            }
            return false;
        });
    });
}
exports["default"] = dedupeCommonParameters;
