/**
 * DevExtreme (exporter/exceljs/export_data_grid.js)
 * Version: 20.2.0 (build 20182-0310)
 * Build date: Tue Jun 30 2020
 *
 * Copyright (c) 2012 - 2020 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.exportDataGrid = void 0;
var _type = require("../../core/utils/type");
var _export = require("./export");
var _errors = require("../../core/errors");
var _errors2 = _interopRequireDefault(_errors);

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        "default": obj
    }
}
var privateOptions = {
    _setAutoFilter: function(dataProvider, worksheet, cellRange, autoFilterEnabled) {
        if (autoFilterEnabled) {
            if (!(0, _type.isDefined)(worksheet.autoFilter) && dataProvider.getRowsCount() > 0) {
                worksheet.autoFilter = cellRange
            }
        }
    },
    _setFont: function(excelCell, bold) {
        if ((0, _type.isDefined)(bold)) {
            excelCell.font = excelCell.font || {};
            excelCell.font.bold = bold
        }
    },
    _getWorksheetFrozenState: function(dataProvider, cellRange) {
        return {
            state: "frozen",
            ySplit: cellRange.from.row + dataProvider.getFrozenArea().y - 1
        }
    },
    _trySetOutlineLevel: function(dataProvider, row, rowIndex, headerRowCount) {
        if (rowIndex >= headerRowCount) {
            row.outlineLevel = dataProvider.getGroupLevel(rowIndex)
        }
    },
    _getCustomizeCellOptions: function(excelCell, gridCell) {
        var options = {
            excelCell: excelCell,
            gridCell: gridCell
        };
        Object.defineProperty(options, "cell", {
            get: function() {
                _errors2.default.log("W0003", "CustomizeCell handler argument", "cell", "20.1", "Use the 'excelCell' field instead");
                return excelCell
            }
        });
        return options
    },
    _needMergeRange: function(rowIndex, headerRowCount) {
        return rowIndex < headerRowCount
    }
};

function exportDataGrid(options) {
    return _export.Export.export(_getFullOptions(options), privateOptions)
}

function _getFullOptions(options) {
    var fullOptions = _export.Export.getFullOptions(options);
    if (!(0, _type.isDefined)(fullOptions.selectedRowsOnly)) {
        fullOptions.selectedRowsOnly = false
    }
    if (!(0, _type.isDefined)(fullOptions.autoFilterEnabled)) {
        fullOptions.autoFilterEnabled = false
    }
    return fullOptions
}
exports.exportDataGrid = exportDataGrid;
