"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return _default;
    }
});
const _object = require("../../../helpers/object");
const _string = require("../../../helpers/string");
/**
 * @private
 */ class BaseType {
    /**
   * Default options.
   *
   * @returns {object}
   */ static get DEFAULT_OPTIONS() {
        return {
            mimeType: 'text/plain',
            fileExtension: 'txt',
            filename: 'Handsontable [YYYY]-[MM]-[DD]',
            encoding: 'utf-8',
            bom: false,
            colHeaders: false,
            rowHeaders: false,
            exportHiddenColumns: false,
            exportHiddenRows: false,
            range: []
        };
    }
    /**
   * Whether the format produces binary (asynchronous) output.
   *
   * @returns {boolean}
   */ get binary() {
        return false;
    }
    /**
   * Merge options provided by users with defaults.
   *
   * @param {object} options An object with options to merge with.
   * @returns {object} Returns new options object.
   */ _mergeOptions(options) {
        let _options = (0, _object.clone)(this.constructor.DEFAULT_OPTIONS);
        const date = new Date();
        _options = (0, _object.extend)((0, _object.clone)(BaseType.DEFAULT_OPTIONS), _options);
        // Legacy alias: `columnHeaders` was renamed to `colHeaders`. When a caller
        // passes the old name and does not also pass the new name, promote it so
        // that the rest of the code only needs to read `colHeaders`.
        if (options && 'columnHeaders' in options && !('colHeaders' in options)) {
            options = {
                ...options,
                colHeaders: options.columnHeaders
            };
        }
        _options = (0, _object.extend)(_options, options);
        _options.filename = (0, _string.substitute)(_options.filename, {
            YYYY: date.getFullYear(),
            MM: `${date.getMonth() + 1}`.padStart(2, '0'),
            DD: `${date.getDate()}`.padStart(2, '0')
        });
        return _options;
    }
    constructor(dataProvider, options){
        this.dataProvider = dataProvider;
        this.options = this._mergeOptions(options);
        this.dataProvider.setOptions(this.options);
    }
}
const _default = BaseType;
