"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.footerDataSource = footerDataSource;
exports.footerRowMetaSymbol = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol"));
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
var footerRowMetaSymbol = exports.footerRowMetaSymbol = (0, _symbol.default)('footer-row');
function footerDataSource() {
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  return function footerDataSourceStep(pipeline) {
    var _a, _b;
    var footerDataSource = (_a = opts.dataSource) !== null && _a !== void 0 ? _a : pipeline.getFooterDataSource();
    var footerRowMetaKey = (_b = opts.footerRowMetaKey) !== null && _b !== void 0 ? _b : footerRowMetaSymbol;
    pipeline.setFeatureOptions('footerRowMetaKey', footerRowMetaKey);
    if (footerDataSource) {
      pipeline.footerDataSource((0, _map.default)(footerDataSource).call(footerDataSource, function (row) {
        return (0, _extends3.default)((0, _defineProperty2.default)({}, footerRowMetaKey, true), row);
      }));
    } else {
      console.warn('调用 pipeline.use(features.footerDataSource()) 前请先设置页脚数据源，设置方法有：pipeline.use(features.footerDataSource({dataSource:any[]})) 或者 pipeline.footerDataSource(any[])');
    }
    return pipeline;
  };
}