"use strict";
var angular = require("angular");
var _ = require("lodash");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var __transform = typescript_angular_utilities_1.services.transform.transform;
exports.moduleName = 'rl.ui.components.commaList';
exports.componentName = 'rlCommaList';
exports.controllerName = 'CommaListController';
var CommaListController = (function () {
    function CommaListController(object) {
        this.remainingItems = 0;
        this.list = this.getFirstItems(this.inList);
    }
    CommaListController.prototype.getFirstItems = function (list) {
        var _this = this;
        if (this.transform != null) {
            list = _.map(list, function (item) {
                return __transform.getValue(item, _this.transform);
            });
        }
        ;
        var newList;
        if (this.max != null) {
            newList = _.take(list, this.max);
            this.remainingItems = list.length - this.max;
        }
        else {
            newList = _.clone(list);
        }
        return newList;
    };
    return CommaListController;
}());
CommaListController.$inject = [typescript_angular_utilities_1.downgrade.objectServiceName];
exports.CommaListController = CommaListController;
var commaList = {
    template: "\n\t\t<span>\n\t\t\t<span ng-repeat=\"item in commaList.list track by $index\">\n\t\t\t\t<span>{{item}}</span><span ng-hide=\"$last\">, </span>\n\t\t\t</span>\n\t\t\t<span ng-show=\"commaList.remainingItems > 0\">... {{commaList.remainingItems}} more items</span>\n\t\t</span>\n\t",
    controller: exports.controllerName,
    controllerAs: 'commaList',
    bindings: {
        inList: '<list',
        max: '<?',
        transform: '<?',
    },
};
angular.module(exports.moduleName, [typescript_angular_utilities_1.downgrade.moduleName])
    .component(exports.componentName, commaList)
    .controller(exports.controllerName, CommaListController);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFMaXN0Lm5nMS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImNvbW1hTGlzdC5uZzEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGlDQUFtQztBQUNuQywwQkFBNEI7QUFFNUIsNkVBQW1FO0FBR25FLElBQU8sV0FBVyxHQUFHLHVDQUFRLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQztBQUV2Qy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