"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Definition = exports.CAP_TYPE = void 0;
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
const default_session_1 = require("../../../../session/default-session");
const surfaces_provider_1 = require("../surfaces-provider");
exports.CAP_TYPE = 'Cap';
function Definition(params, surfaceTag) {
    let parameters;
    if ((0, isPlainObject_1.default)(params)) {
        parameters = params;
    }
    else {
        parameters = {
            surfaceTag,
            instrumentCode: params,
        };
    }
    const { outputs, instrumentCode, extendedParams, discountingType } = parameters, instrumentDefinition = __rest(parameters, ["outputs", "instrumentCode", "extendedParams", "discountingType"]);
    const requestItem = Object.assign(Object.assign({}, instrumentDefinition), { underlyingDefinition: {
            instrumentCode,
            discountingType,
        }, underlyingType: exports.CAP_TYPE });
    return {
        getData(session = (0, default_session_1.getDefault)()) {
            const financialContracts = new surfaces_provider_1.SurfacesProvider(session);
            return financialContracts.getSurfaces([requestItem], { extendedParams, outputs });
        },
        /** @internal */
        getInstrument() {
            return requestItem;
        },
    };
}
exports.Definition = Definition;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5pdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jb250ZW50L2lwYS9zdXJmYWNlcy9jYXAvZGVmaW5pdGlvbi50cyJdLCJuYW1lcyI6W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