"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var wjcGrid = require("wijmo/wijmo.grid");
'use strict';
var DataService = /** @class */ (function () {
    function DataService() {
        this._products = ['Widget', 'Gadget', 'Doohickey'];
        this._countries = ['US', 'Germany', 'UK', 'Japan', 'Italy', 'Greece'];
        this.data = this.getData(50);
    }
    Object.defineProperty(DataService.prototype, "products", {
        get: function () {
            return this._products;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(DataService.prototype, "countries", {
        get: function () {
            return this._countries;
        },
        enumerable: true,
        configurable: true
    });
    // get matches for a search term
    DataService.prototype.getData = function (count) {
        var data = [], i = 0, countryId, productId;
        for (var i = 0; i < count; i++) {
            countryId = Math.floor(Math.random() * this._countries.length);
            productId = Math.floor(Math.random() * this._products.length);
            data.push({
                id: i,
                countryId: countryId,
                productId: productId,
                date: new Date(2014, i % 12, i % 28),
                amount: Math.random() * 10000,
                active: i % 4 === 0
            });
        }
        return data;
    };
    DataService.prototype.getTableData = function (count) {
        var data = [], i = 0, country, product;
        for (var i = 0; i < count; i++) {
            country = this._countries[Math.floor(Math.random() * this._countries.length)];
            product = this._products[Math.floor(Math.random() * this._products.length)];
            data.push({
                ID: i,
                Country: country,
                Product: product,
                Date: new Date(2014, i % 12, i % 28),
                Amount: Math.random() * 10000
            });
        }
        return data;
    };
    // initialize the dataMap for the bound sheet.
    DataService.prototype.initDataMapForBindingSheet = function (flexSheet) {
        var column;
        if (flexSheet) {
            column = flexSheet.columns.getColumn('countryId');
            if (column && !column.dataMap) {
                column.dataMap = this._buildDataMap(DataService.default.countries);
            }
            column = flexSheet.columns.getColumn('productId');
            if (column && !column.dataMap) {
                column.width = 100;
                column.dataMap = this._buildDataMap(DataService.default.products);
            }
            column = flexSheet.columns.getColumn('amount');
            if (column) {
                column.format = 'c2';
            }
        }
    };
    // build a data map from a string array using the indices as keys
    DataService.prototype._buildDataMap = function (items) {
        var map = [];
        for (var i = 0; i < items.length; i++) {
            map.push({ key: i, value: items[i] });
        }
        return new wjcGrid.DataMap(map, 'key', 'value');
    };
    DataService.default = new DataService();
    return DataService;
}());
exports.DataService = DataService;
//# sourceMappingURL=DataSvc.js.map