"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIScheduler = exports.UISchedulerEvent = exports.UISchedulerCell = exports.UISchedulerColumn = exports.Draggable = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var dragula_1 = __importDefault(require("dragula"));
var moment_1 = __importDefault(require("moment"));
var ui_internal_1 = require("../../utils/ui-internal");
var debounce_1 = require("debounce");
var date_utils_1 = require("../../utils/date-utils");
var Draggable = exports.Draggable = (function () {
    function Draggable() {
    }
    Draggable.DraggableClassName = "draggable";
    Draggable.PlanningColumnClassName = "planning-column";
    Draggable.DraggableHandleClassName = "draggable-handle";
    return Draggable;
}());
var UISchedulerColumn = (function () {
    function UISchedulerColumn(init) {
        Object.assign(this, init);
    }
    return UISchedulerColumn;
}());
exports.UISchedulerColumn = UISchedulerColumn;
var UISchedulerCell = (function () {
    function UISchedulerCell(init) {
        this.isShowMoreBtnOpen = false;
        this.nbOfEvents = 0;
        this.nbOfShownedEvents = 0;
        Object.assign(this, init);
    }
    return UISchedulerCell;
}());
exports.UISchedulerCell = UISchedulerCell;
var UISchedulerEvent = exports.UISchedulerEvent = (function () {
    function UISchedulerEvent(data, startTime, endTime) {
        if (startTime === void 0) { startTime = null; }
        if (endTime === void 0) { endTime = null; }
        this.data = data;
        this.startTime = startTime;
        this.endTime = endTime;
        this.fixed = false;
        this.isSelectable = false;
        this.isSelected = false;
        this.removeAfterDrop = true;
    }
    Object.defineProperty(UISchedulerEvent.prototype, "height", {
        get: function () {
            if (this.startTime == null || this.endTime == null)
                return "height: initial;";
            if (this.view == "TimelineMonth")
                return "";
            if (this.view == "TimelineWeek")
                return "";
            if (this.view == "TimelineDay")
                return "height: initial;";
            var style = "";
            var startTimeM = (0, moment_1.default)(this.startTime);
            var minutes = startTimeM.minutes();
            var top = 0;
            if (minutes != 0 && minutes != 30) {
                if (minutes > 30)
                    minutes -= 30;
                top = minutes * 2;
            }
            var duration = moment_1.default.duration((0, moment_1.default)(this.endTime).diff((0, moment_1.default)(this.startTime)));
            var height = duration.asMinutes() * 2;
            if (top > 0) {
                style += "top: ".concat(top, "px; ");
            }
            style += "height: ".concat(height, "px;");
            return style;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UISchedulerEvent.prototype, "width", {
        get: function () {
            var _a, _b;
            if (this.view == "Week")
                return "width: initial;";
            if (this.view == "TimelineMonth") {
                if (this.durationDays <= 1)
                    return "width: initial;";
                else {
                    return "width: calc(".concat(this.durationDays * 100, "% + ").concat(this.durationDays - 2, "px);");
                }
            }
            else if (this.view == "TimelineDay") {
                if (this.element == null)
                    return;
                var $schedulerContent = $(this.element).parents(".scheduler-content");
                var contentWidth = $schedulerContent.width() - 20;
                var offset = $schedulerContent.get(0).offsetLeft;
                var xOffset = this.element.offsetLeft - offset;
                var columnWidth = (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.parentElement.clientWidth) !== null && _b !== void 0 ? _b : 70;
                var duration = (0, moment_1.default)(this.endTime).diff((0, moment_1.default)(this.startTime), 'minute') / 60;
                var width = duration * columnWidth;
                var totalWidth = width + xOffset;
                if (totalWidth > contentWidth) {
                    width = contentWidth - xOffset;
                }
                return "width: ".concat(width, "px;");
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UISchedulerEvent.prototype, "leftOffset", {
        get: function () {
            var _a, _b;
            if (this.view == "TimelineDay") {
                if (this.element == null)
                    return;
                var minutes = (0, moment_1.default)(this.startTime).minute();
                var columnWidth = (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.parentElement.clientWidth) !== null && _b !== void 0 ? _b : 70;
                var duration = minutes / 60;
                var offset = duration * columnWidth;
                return "left: ".concat(offset, "px;");
            }
        },
        enumerable: false,
        configurable: true
    });
    UISchedulerEvent.prototype.getFirstDayOfCurrentMonth = function () {
        var tempDate = new Date(this.selectedDate.getUTCFullYear(), this.selectedDate.getUTCMonth(), 1, 15);
        tempDate.setUTCHours(0);
        return tempDate;
    };
    UISchedulerEvent.prototype.getLastDayOfCurrentMonth = function () {
        var tempDate = new Date(this.selectedDate.getUTCFullYear(), this.selectedDate.getUTCMonth(), 1, 12);
        tempDate.setUTCHours(23);
        var mTempDate = (0, moment_1.default)(tempDate).add(1, 'months');
        mTempDate = mTempDate.subtract(1, "days");
        return mTempDate.toDate();
        ;
    };
    Object.defineProperty(UISchedulerEvent.prototype, "durationDays", {
        get: function () {
            var endDate = new Date(this.endTime).setUTCHours(24);
            var startDate = new Date(this.startTime).setUTCHours(0);
            if (this.startTime.getTime() < this.getFirstDayOfCurrentMonth().getTime()) {
                startDate = new Date(this.getFirstDayOfCurrentMonth()).getTime();
            }
            if (this.endTime.getTime() > this.getLastDayOfCurrentMonth().getTime()) {
                endDate = new Date(this.getLastDayOfCurrentMonth()).getTime();
            }
            var duration = moment_1.default.duration((0, moment_1.default)(endDate).diff((0, moment_1.default)(startDate)));
            var days = duration.asDays();
            return Math.ceil(days);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UISchedulerEvent.prototype, "computedStyle", {
        get: function () {
            var height = this.height;
            var width = this.width;
            var style = "";
            if (height != null && height.length > 0)
                style += height;
            if (width != null && width.length > 0)
                style += width;
            if (this.leftOffset != null && this.leftOffset.length > 0)
                style += this.leftOffset;
            if (this.style != null && this.style.length > 0)
                style += this.style;
            return style;
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        (0, aurelia_framework_1.computedFrom)("startTime", "endTime", "view"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UISchedulerEvent.prototype, "height", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)("startTime", "endTime", "view", "element"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UISchedulerEvent.prototype, "width", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)("startTime", "view", "element"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UISchedulerEvent.prototype, "leftOffset", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)("startTime", "endTime"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UISchedulerEvent.prototype, "durationDays", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)("height", "width", "leftOffset", "style"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UISchedulerEvent.prototype, "computedStyle", null);
    return UISchedulerEvent;
}());
var UIScheduler = exports.UIScheduler = (function () {
    function UIScheduler(element, taskQueue, bindingEngine, dateUtils) {
        this.element = element;
        this.taskQueue = taskQueue;
        this.bindingEngine = bindingEngine;
        this.dateUtils = dateUtils;
        this.group = [];
        this.showModalIcon = true;
        this.startHour = 7;
        this.endHour = 19;
        this.view = "Week";
        this.hasGroup = false;
        this.sidebarCollapsed = false;
        this.sidebarWidth = "24rem";
        this.sortGroupAscendant = true;
        this.enableDragAndDrop = true;
        this.beginFromMonday = true;
        this.displayWeekend = true;
        this.shiftKeyPressed = false;
        this.getMore = function () { };
        this.nbWeeksToShow = 1;
        this.maxSelectedEvents = null;
        this.displaySidebar = true;
        this.columnList = [];
        this.usageMatrix = [];
        this.disposables = [];
        this.dayOffs = [];
    }
    UIScheduler.prototype.internalGetMore = function (topIndex, isAtBottom, isAtTop) {
        if (this.getMore != null) {
            return this.getMore({
                "topIndex": topIndex,
                "isAtBottom": isAtBottom,
                "isAtTop": isAtTop
            });
        }
    };
    Object.defineProperty(UIScheduler.prototype, "displayDate", {
        get: function () {
            if (this.view == "Week" || this.view == "TimelineWeek") {
                var month = this.selectedDate.toLocaleString('fr', { month: 'short' });
                var fixMonth = month[0].toUpperCase() + month.substring(1);
                var year = this.selectedDate.getFullYear();
                var start = this.dateUtils.format(this.dateUtils.getStartOfWeek(this.selectedDate), 'D');
                var end = this.dateUtils.format(this.dateUtils.getEndOfWeek(this.selectedDate), 'D');
                return "".concat(fixMonth, " ").concat(start, "-").concat(end, ", ").concat(year);
            }
            else if (this.view == "TimelineMonth") {
                var month = this.selectedDate.toLocaleString('fr', { month: 'short' });
                var fixMonth = month[0].toUpperCase() + month.substring(1);
                var year = this.selectedDate.getFullYear();
                return "".concat(fixMonth, " ").concat(year);
            }
            else {
                return this.selectedDate.toLocaleDateString('fr');
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UIScheduler.prototype, "dateSelector", {
        get: function () {
            if (this.view == "Week" || this.view == "TimelineWeek") {
                return "Week";
            }
            return "Month";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UIScheduler.prototype, "allowMultipleEventsPerCell", {
        get: function () {
            return (this.view == "TimelineWeek" && this.group.length > 0) || this.view == "TimelineDay" || this.view == "Week";
        },
        enumerable: false,
        configurable: true
    });
    UIScheduler.prototype.bind = function () {
        this.generateColumns();
        this.initialize();
        this.constructUI();
        this.registerObservers();
    };
    UIScheduler.prototype.detached = function () {
        var _a;
        this.resizeObserver.unobserve(this.element);
        (_a = this.drake) === null || _a === void 0 ? void 0 : _a.destroy();
        this.disposables.forEach(function (disposable) {
            disposable.dispose();
        });
    };
    UIScheduler.prototype.registerObservers = function () {
        var _this = this;
        this.disposables.push(this.bindingEngine.propertyObserver(this, "selectedDate").subscribe(function (newVal, oldVal) {
            if (!(0, moment_1.default)(newVal).isSame(oldVal, "day")) {
                _this.selectedDate.setUTCHours(12);
                _this.generateColumns();
            }
        }), this.bindingEngine.propertyObserver(this, "view").subscribe(function () {
            _this.generateColumns();
            _this.triggerEventsChanged();
        }), this.bindingEngine.collectionObserver(this.events).subscribe(function (changes) {
            if (changes.length > 0) {
                _this.eventsCollectionChanged(changes);
            }
        }), this.bindingEngine.collectionObserver(this.dayOffs).subscribe(function (changes) {
            _this.setDayOffColumns();
        }), this.bindingEngine.propertyObserver(this, "displayWeekend").subscribe(function () {
            _this.generateColumns();
            _this.triggerEventsChanged();
        }), this.bindingEngine.propertyObserver(this, "nbWeeksToShow").subscribe(function () {
            _this.generateColumns();
            _this.triggerEventsChanged();
        }));
        if (this.ressources != null) {
            this.disposables.push(this.bindingEngine.collectionObserver(this.ressources).subscribe(function (changes) {
                if (changes.length > 0) {
                    _this.ressourcesChanged(changes);
                }
            }));
        }
    };
    UIScheduler.prototype.setDayOffColumns = function () {
        var e_1, _a;
        var _b;
        var _loop_1 = function (dayOff) {
            var dayOffDate;
            if (dayOff instanceof Date) {
                dayOffDate = dayOff;
            }
            else {
                dayOffDate = dayOff.date;
            }
            var column = this_1.columnList.find(function (x) { return !x.rowGroupColumn && (0, moment_1.default)(x.key).isSame((0, moment_1.default)(dayOffDate), "day"); });
            if (column != null) {
                (_b = column.class) !== null && _b !== void 0 ? _b : (column.class = "");
                column.class += " day-off";
                if (!(dayOff instanceof Date) && dayOff.label != null) {
                    column.dataBefore = dayOff.label;
                }
            }
        };
        var this_1 = this;
        try {
            for (var _c = __values(this.dayOffs), _d = _c.next(); !_d.done; _d = _c.next()) {
                var dayOff = _d.value;
                _loop_1(dayOff);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            finally { if (e_1) throw e_1.error; }
        }
    };
    UIScheduler.prototype.generateColumns = function () {
        var _a;
        var columnList = [];
        if (this.view == "Week") {
            columnList.push.apply(columnList, __spreadArray([], __read(this.generateWeekColumns()), false));
        }
        else if (this.view.startsWith("Timeline")) {
            if (this.group == null || this.group.length == 0) {
                columnList.push.apply(columnList, __spreadArray([], __read(this.generateTimelineColumns()), false));
            }
            else {
                columnList.push.apply(columnList, __spreadArray([], __read(this.generateGroupedTimelineColumns()), false));
            }
        }
        (_a = this.columnList).splice.apply(_a, __spreadArray([0, this.columnList.length], __read(columnList), false));
        this.setDayOffColumns();
    };
    UIScheduler.prototype.generateWeekColumns = function () {
        var columnList = [];
        var nbDays = this.displayWeekend ? 7 : 5;
        for (var i = 0; i < nbDays; i++) {
            var currDate = (0, moment_1.default)(this.selectedDate).weekday(i);
            columnList.push(new UISchedulerColumn({
                key: currDate.toDate(),
                day: currDate.format("dddd").charAt(0).toUpperCase() + currDate.format("dddd").substr(1),
                dayNumber: currDate.format("DD/MM"),
                contextMenuDisabled: true,
                cells: this.generateColumnCells(currDate.toDate()),
                class: (currDate.format('yyyy MM DD') == (0, moment_1.default)().format('yyyy MM DD')) ? 'current-date' : ''
            }));
        }
        return columnList;
    };
    UIScheduler.prototype.computeStartDate = function () {
        if (this.view == "TimelineMonth") {
            return this.dateUtils.getStartOfMonth((0, moment_1.default)(this.selectedDate).utc());
        }
        else if (this.view == "TimelineWeek") {
            return this.dateUtils.getStartOfWeek((0, moment_1.default)(this.selectedDate).utc());
        }
        else if (this.view == "TimelineDay") {
            return this.dateUtils.setHours(this.selectedDate, this.startHour);
        }
    };
    UIScheduler.prototype.computedEndDate = function (startDate) {
        if (this.view == "TimelineMonth") {
            return this.dateUtils.getEndOfMonth((0, moment_1.default)(startDate).utc());
        }
        else if (this.view == "TimelineWeek") {
            var endWeek = this.dateUtils.getEndOfWeek((0, moment_1.default)(startDate).utc());
            if (!this.displayWeekend) {
                endWeek = this.dateUtils.subtractDays(endWeek, 2);
            }
            return this.dateUtils.addWeeks(endWeek, this.nbWeeksToShow - 1);
        }
        else if (this.view == "TimelineDay") {
            return this.dateUtils.setHours(startDate, this.endHour);
        }
    };
    UIScheduler.prototype.generateTimelineColumns = function () {
        var _this = this;
        var columnList = [];
        var startDate = this.computeStartDate();
        var mStartDate = (0, moment_1.default)(startDate);
        var colIndex = 0;
        var endDate = this.computedEndDate(startDate);
        var mEndDate = (0, moment_1.default)(endDate);
        while (mStartDate <= mEndDate) {
            var cells = this.generateColumnCells(mStartDate.toDate());
            if (this.view == "TimelineDay") {
                columnList.push(new UISchedulerColumn({
                    key: mStartDate.toDate(),
                    day: mStartDate.format("H") + " h",
                    dayNumber: null,
                    contextMenuDisabled: true,
                    cells: cells,
                    class: ''
                }));
                mStartDate.add(1, 'hour');
            }
            else {
                if (this.displayWeekend == true || !this.dateUtils.isWeekend(mStartDate)) {
                    var isLastDayForWeek = mStartDate != mEndDate ? this.displayWeekend == true ? mStartDate.isoWeekday() == 7 : mStartDate.isoWeekday() == 5 : false;
                    var isWeekend = this.displayWeekend == true ? this.dateUtils.isWeekend(mStartDate) : false;
                    columnList.push(new UISchedulerColumn({
                        key: mStartDate.toDate(),
                        day: null,
                        dayNumber: mStartDate.format("DD/MM"),
                        contextMenuDisabled: true,
                        cells: cells,
                        class: ((mStartDate.format('yyyy MM DD') == (0, moment_1.default)().format('yyyy MM DD')) ? 'current-date' : '') + (isLastDayForWeek ? ' last-day-for-week' : '') + (isWeekend ? ' ui-scheduler-week-end' : '')
                    }));
                }
                mStartDate.add(24, 'hour');
            }
            this.usageMatrix.push([]);
            cells.forEach(function (c, i) {
                _this.usageMatrix[colIndex][i] = false;
            });
            colIndex++;
        }
        return columnList;
    };
    UIScheduler.prototype.generateGroupedTimelineColumns = function () {
        var _this = this;
        var columnList = [];
        this.group.forEach(function (g) {
            var ressource = _this.ressources.find(function (r) { return r.name == g; });
            if (ressource != null) {
                columnList.push(new UISchedulerColumn({
                    rowGroupColumn: true,
                    cells: _this.generateColumnCells(),
                    class: 'group'
                }));
            }
        });
        columnList.push.apply(columnList, __spreadArray([], __read(this.generateTimelineColumns()), false));
        return columnList;
    };
    UIScheduler.prototype.generateColumnCells = function (currDate) {
        var _this = this;
        if (currDate === void 0) { currDate = null; }
        var cells = [];
        if (this.view == "Week") {
            currDate.setHours(this.startHour);
            var currDay = currDate.getDate();
            while (currDate.getHours() <= this.endHour && currDay == currDate.getDate()) {
                var cell = new UISchedulerCell({
                    startTime: currDate,
                    endTime: (0, moment_1.default)(currDate).add(30, 'minute').toDate()
                });
                cells.push(cell);
                currDate = new Date(cell.endTime);
            }
        }
        else if (this.view.startsWith("Timeline") && this.group.length == 0) {
            for (var i = 0; i < 20; i++) {
                var cell = new UISchedulerCell({
                    startTime: currDate,
                    endTime: (0, moment_1.default)(currDate).add(24, 'hours').toDate()
                });
                cells.push(cell);
            }
        }
        else if (this.view.startsWith("Timeline")) {
            if (currDate == null) {
                this.group.forEach(function (gr) {
                    var ressource = _this.ressources.find(function (r) { return r.name == gr; });
                    ressource.dataSource.forEach(function (data) {
                        var cell = new UISchedulerCell({
                            rowGroupCell: true,
                            rowGroupData: data,
                            style: "border-left-color: ".concat(data.color, "; border-left-width: 5px; border-left-style: solid;\n              display: flex;\n              align-items: center;\n              justify-content: center;")
                        });
                        cells.push(cell);
                    });
                });
            }
            else {
                this.group.forEach(function (gr) {
                    var ressource = _this.ressources.find(function (r) { return r.name == gr; });
                    ressource.dataSource.forEach(function (data) {
                        var cell = new UISchedulerCell({
                            startTime: currDate,
                            rowGroupData: data,
                            endTime: (0, moment_1.default)(currDate).add(24, 'hours').toDate()
                        });
                        cells.push(cell);
                    });
                });
            }
        }
        return cells;
    };
    UIScheduler.prototype.attached = function () {
        var _this = this;
        $(".scheduler-content").scroll(function () {
            var left = $(".scheduler-container")[0].getBoundingClientRect().left;
            $(".scheduler-header").offset({ left: -1 * this.scrollLeft + left });
        });
        $(document).on("keydown", function (event) {
            if (event.shiftKey === true) {
                _this.shiftKeyPressed = true;
            }
        });
        $(document).on("keyup", function (event) {
            if (event.shiftKey === false) {
                _this.shiftKeyPressed = false;
            }
        });
        this.resizeObserver = new ResizeObserver((0, debounce_1.debounce)(function () {
            _this.constructUI();
        }, 500));
        this.resizeObserver.observe(this.element);
    };
    UIScheduler.prototype.computeOverflowness = function (cell) {
        var _this = this;
        this.taskQueue.queueTask(function () {
            var e_2, _a;
            if (cell != null && _this.allowMultipleEventsPerCell && _this.view != "Week") {
                var nbOfShownedEvents = 0;
                var nbOfEvents = 0;
                if (cell.event != null && isArray(cell.event) && cell.element != null) {
                    nbOfEvents = cell.event.length;
                    var totalHeight = 0;
                    try {
                        for (var _b = __values(cell.event), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var event_1 = _c.value;
                            if (event_1.element != null) {
                                totalHeight += event_1.element.clientHeight;
                                if (totalHeight <= cell.element.clientHeight - 20) {
                                    nbOfShownedEvents++;
                                }
                            }
                        }
                    }
                    catch (e_2_1) { e_2 = { error: e_2_1 }; }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                        }
                        finally { if (e_2) throw e_2.error; }
                    }
                    if (totalHeight <= cell.element.clientHeight) {
                        nbOfShownedEvents = nbOfEvents;
                    }
                }
                cell.nbOfShownedEvents = nbOfShownedEvents;
                cell.nbOfEvents = nbOfEvents;
            }
            return;
        });
    };
    UIScheduler.prototype.unplannedEventsCount = function () {
        if (this.events == null)
            return 0;
        return this.events.filter(function (e) { return e.startTime == null; }).length;
    };
    UIScheduler.prototype.eventsCollectionChanged = function (changes) {
        this.constructUI();
    };
    UIScheduler.prototype.initialize = function () {
        var _this = this;
        this.taskQueue.queueTask({
            call: function () {
                if (_this.drake != null) {
                    _this.drake.destroy();
                    _this.drake = null;
                }
                if (_this.enableDragAndDrop === true) {
                    var drake = new dragula_1.default(new Array(), {
                        accepts: function (el, target, source) {
                            if (target.classList.contains(Draggable.DraggableClassName) && !_this.hasParent(source, target)) {
                                var targetModel = _this.getModelFromElement(target);
                                if (_this.accepts != null) {
                                    var event_2 = _this.getModelFromElement(el);
                                    var sourceModel = _this.getModelFromElement(source);
                                    return _this.accepts({ event: event_2, target: targetModel, source: sourceModel });
                                }
                                else if (targetModel != null) {
                                    return targetModel.event == null || _this.allowMultipleEventsPerCell;
                                }
                                return true;
                            }
                            return false;
                        },
                        moves: function (el, source, handle, sibling) {
                            if (el.classList.contains('scheduler-event')) {
                                if (_this.canMove != null) {
                                    var eventEl = _this.getModelFromElement(el);
                                    return _this.canMove({ "event": eventEl });
                                }
                                return true;
                            }
                            return false;
                        },
                        isContainer: function (el) {
                            return el.classList.contains(Draggable.DraggableClassName);
                        },
                        revertOnSpill: false,
                        copy: function (el, source) {
                            var _a;
                            if ((_a = source.classList) === null || _a === void 0 ? void 0 : _a.contains("scheduler-unplanned-events"))
                                return false;
                            if (_this.view == "Week")
                                return true;
                            if (_this.shiftKeyPressed === true)
                                return true;
                            return false;
                        }
                    })
                        .on('cloned', function (clone, original, type) {
                        if (_this.shiftKeyPressed === true) {
                            clone.classList.add('gu-copy');
                        }
                    })
                        .on('drop', function (el, target, source) { return __awaiter(_this, void 0, void 0, function () {
                        var event_3, sourceModel, targetModel, findEvent, selectedEvents, executeIndividually, selectedEvents_1, selectedEvents_1_1, selectedEvent, e_3_1, _a;
                        var e_3, _b;
                        return __generator(this, function (_c) {
                            switch (_c.label) {
                                case 0:
                                    _c.trys.push([0, 13, , 14]);
                                    event_3 = this.getModelFromElement(el);
                                    sourceModel = this.getModelFromElement(source);
                                    targetModel = this.getModelFromElement(target);
                                    if (event_3 == null) {
                                        event_3 = sourceModel.event;
                                        if (Array.isArray(event_3)) {
                                            findEvent = event_3.find(function (e) { return e.element.auTargetId == el.auTargetId; });
                                            if (findEvent != null)
                                                event_3 = findEvent;
                                        }
                                    }
                                    if (!(this.onUpdate != null && event_3 != null && !event_3.fixed)) return [3, 11];
                                    selectedEvents = this.events.filter(function (x) { return !x.fixed && x.isSelected; });
                                    if (!selectedEvents.includes(event_3)) {
                                        selectedEvents.push(event_3);
                                    }
                                    executeIndividually = selectedEvents.length <= 1 || this.onUpdateMultiple == null;
                                    if (!!executeIndividually) return [3, 2];
                                    return [4, this.onUpdateMultiple({ events: selectedEvents, target: targetModel, source: sourceModel })];
                                case 1:
                                    executeIndividually = !(_c.sent());
                                    _c.label = 2;
                                case 2:
                                    _c.trys.push([2, 8, 9, 10]);
                                    selectedEvents_1 = __values(selectedEvents), selectedEvents_1_1 = selectedEvents_1.next();
                                    _c.label = 3;
                                case 3:
                                    if (!!selectedEvents_1_1.done) return [3, 7];
                                    selectedEvent = selectedEvents_1_1.value;
                                    if (!executeIndividually) return [3, 5];
                                    return [4, this.onUpdate({ event: selectedEvent, target: targetModel, source: sourceModel })];
                                case 4:
                                    if (!(_c.sent())) {
                                        this.events.splice(this.events.indexOf(selectedEvent), 1, Object.create(selectedEvent));
                                    }
                                    _c.label = 5;
                                case 5:
                                    if (selectedEvent.removeAfterDrop) {
                                        el.parentElement.removeChild(el);
                                    }
                                    if (selectedEvent.cell != null) {
                                        selectedEvent.cell.isShowMoreBtnOpen = false;
                                    }
                                    selectedEvent.isSelected = false;
                                    _c.label = 6;
                                case 6:
                                    selectedEvents_1_1 = selectedEvents_1.next();
                                    return [3, 3];
                                case 7: return [3, 10];
                                case 8:
                                    e_3_1 = _c.sent();
                                    e_3 = { error: e_3_1 };
                                    return [3, 10];
                                case 9:
                                    try {
                                        if (selectedEvents_1_1 && !selectedEvents_1_1.done && (_b = selectedEvents_1.return)) _b.call(selectedEvents_1);
                                    }
                                    finally { if (e_3) throw e_3.error; }
                                    return [7];
                                case 10:
                                    this.triggerEventsChanged();
                                    return [3, 12];
                                case 11:
                                    this.drake.cancel(true);
                                    _c.label = 12;
                                case 12: return [3, 14];
                                case 13:
                                    _a = _c.sent();
                                    this.drake.cancel(true);
                                    return [3, 14];
                                case 14: return [2];
                            }
                        });
                    }); });
                    _this.drake = drake;
                }
            }
        });
    };
    UIScheduler.prototype.constructUI = function () {
        var _this = this;
        this.taskQueue.queueTask(function () {
            var e_4, _a, e_5, _b;
            _this.resetMatrix();
            _this.resetCells();
            _this.assignEventsToCorrespondingCells();
            try {
                for (var _c = __values(_this.columnList), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var column = _d.value;
                    try {
                        for (var _e = (e_5 = void 0, __values(column.cells)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var cell = _f.value;
                            _this.computeOverflowness(cell);
                        }
                    }
                    catch (e_5_1) { e_5 = { error: e_5_1 }; }
                    finally {
                        try {
                            if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                        }
                        finally { if (e_5) throw e_5.error; }
                    }
                }
            }
            catch (e_4_1) { e_4 = { error: e_4_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_4) throw e_4.error; }
            }
            ui_internal_1.UIInternal.broadcast(ui_internal_1.UIInternal.EVT_SCHEDULER_REFRESHED);
        });
    };
    UIScheduler.prototype.ressourcesChanged = function (changes) {
        this.generateColumns();
    };
    UIScheduler.prototype.assignEventsToCorrespondingCells = function () {
        var e_6, _a;
        if (this.events != null && this.events.length > 0) {
            var plannedEvents = this.events.filter(function (e) { return e.startTime != null; });
            try {
                for (var plannedEvents_1 = __values(plannedEvents), plannedEvents_1_1 = plannedEvents_1.next(); !plannedEvents_1_1.done; plannedEvents_1_1 = plannedEvents_1.next()) {
                    var event_4 = plannedEvents_1_1.value;
                    event_4.view = this.view;
                    event_4.selectedDate = this.selectedDate;
                    var startTime = event_4.startTime;
                    var cell = this.findCell(event_4);
                    if (cell != null) {
                        if (cell.event != null) {
                            if (this.allowMultipleEventsPerCell) {
                                cell.event.push(event_4);
                            }
                            else {
                                throw "Cannot assign multiple events to a cell";
                            }
                        }
                        else {
                            if (this.allowMultipleEventsPerCell) {
                                if (cell.event == null)
                                    cell.event = [];
                                cell.event.push(event_4);
                            }
                            else {
                                cell.event = event_4;
                            }
                        }
                        event_4.cell = cell;
                    }
                    else {
                        console.info("Cannot find a cell to put event with starttime " + startTime);
                    }
                }
            }
            catch (e_6_1) { e_6 = { error: e_6_1 }; }
            finally {
                try {
                    if (plannedEvents_1_1 && !plannedEvents_1_1.done && (_a = plannedEvents_1.return)) _a.call(plannedEvents_1);
                }
                finally { if (e_6) throw e_6.error; }
            }
        }
    };
    UIScheduler.prototype.resetCells = function () {
        this.columnList.forEach(function (column) {
            column.cells.filter(function (c) { return c.event != null; }).forEach(function (cell) {
                cell.event = null;
            });
        });
    };
    UIScheduler.prototype.resetMatrix = function () {
        var i = 0;
        while (i < this.usageMatrix.length) {
            var j = 0;
            while (j < this.usageMatrix[i].length) {
                this.usageMatrix[i][j] = false;
                j++;
            }
            i++;
        }
    };
    UIScheduler.prototype.triggerEventsChanged = function () {
        var _this = this;
        var copy = this.events.splice(0);
        this.taskQueue.queueMicroTask(function () {
            var _a;
            return (_a = _this.events).push.apply(_a, __spreadArray([], __read(copy), false));
        });
    };
    UIScheduler.prototype.findCell = function (event) {
        var _this = this;
        if (this.columnList == null || this.columnList.length == 0)
            return null;
        if (this.view == "Week") {
            var startTime = event.startTime;
            var copyStartTime_1 = new Date(startTime);
            copyStartTime_1.setUTCHours(0, 0, 0, 0);
            var column = this.columnList.find(function (c) { return (0, moment_1.default)(copyStartTime_1).isSame((0, moment_1.default)(c.key), 'day'); });
            if (column == null)
                return null;
            copyStartTime_1 = new Date(startTime);
            if (startTime.getHours() < this.startHour) {
                copyStartTime_1.setUTCHours(this.startHour, 0, 0);
            }
            var cell = column.cells.find(function (c) { return copyStartTime_1 >= c.startTime && copyStartTime_1 < c.endTime; });
            return cell;
        }
        else if (this.view == "TimelineMonth" && this.group.length == 0) {
            var startTime = new Date(event.startTime);
            var endTime = new Date(event.endTime);
            if (startTime.getMonth() < this.selectedDate.getMonth() || startTime.getFullYear() < this.selectedDate.getFullYear()) {
                startTime.setUTCFullYear(this.selectedDate.getFullYear());
                startTime.setUTCMonth(this.selectedDate.getMonth());
                startTime.setUTCDate(1);
            }
            startTime.setUTCHours(0, 0, 0, 0);
            endTime.setUTCHours(0, 0, 0, 0);
            var mStartTime_1 = (0, moment_1.default)(startTime);
            var columnIndex = this.columnList.findIndex(function (c) { return _this.dateUtils.isSameDay(c.key, mStartTime_1); });
            var column = this.columnList[columnIndex];
            if (column != null) {
                var found = false;
                event.selectedDate = this.selectedDate;
                var duration = event.durationDays;
                var colIndex = 0;
                var rowIndex = 0;
                while (found == false) {
                    while (colIndex < duration) {
                        if (this.usageMatrix[columnIndex + colIndex][rowIndex] == true) {
                            break;
                        }
                        colIndex++;
                    }
                    if (colIndex == duration)
                        found = true;
                    rowIndex++;
                }
                if (found) {
                    rowIndex--;
                    colIndex = 0;
                    while (colIndex < duration) {
                        this.usageMatrix[columnIndex + colIndex][rowIndex] = true;
                        colIndex++;
                    }
                    return column.cells[rowIndex];
                }
            }
            return null;
        }
        else if (this.view == "TimelineWeek" && this.group.length > 0) {
            var startTime = new Date(event.startTime);
            var g_1 = this.group[0];
            var ressource = this.ressources.find(function (x) { return x.name == g_1; });
            var fieldName = ressource.field;
            var fieldVal_1 = event.data[fieldName];
            startTime.setUTCHours(0, 0, 0, 0);
            var mStartTime_2 = (0, moment_1.default)(startTime);
            var column = this.columnList.find(function (c) { return _this.dateUtils.isSameDay(mStartTime_2, c.key); });
            if (column != null) {
                return column.cells.find(function (c) { return _this.dateUtils.isSameDay(mStartTime_2, c.startTime) && c.rowGroupData.id == fieldVal_1; });
            }
            return null;
        }
        else if (this.view == "TimelineDay" && this.group.length > 0) {
            var startTime = new Date(event.startTime);
            var g_2 = this.group[0];
            var ressource = this.ressources.find(function (x) { return x.name == g_2; });
            var fieldName = ressource.field;
            var fieldVal_2 = event.data[fieldName];
            var mStartTime_3 = (0, moment_1.default)(startTime);
            var columnIndex = this.columnList.findIndex(function (c) { return (0, moment_1.default)(c.key).diff(mStartTime_3, 'hour', false) == 0; });
            if (columnIndex > -1) {
                var column = this.columnList[columnIndex];
                var cell = column.cells.find(function (c) { return c.rowGroupData.id == fieldVal_2; });
                return cell;
            }
            return null;
        }
    };
    UIScheduler.prototype.editEvent = function ($event, event) {
        if ($event.detail == 1) {
            if (event.isSelectable) {
                if (!event.isSelected) {
                    event.isSelected = this.maxSelectedEvents == null || this.events.filter(function (x) { return x.isSelected; }).length < this.maxSelectedEvents;
                }
                else {
                    event.isSelected = false;
                }
            }
            if (this.onEditFn != null) {
                this.onEditFn({ "event": event });
            }
        }
        else if ($event.detail == 2) {
            if (this.onDblClickFn != null) {
                this.onDblClickFn({ "event": event });
            }
        }
    };
    UIScheduler.prototype.hasParent = function (element, parent) {
        if (element.parentElement != null && element.parentElement == parent) {
            return true;
        }
        if (element.parentElement != null) {
            return this.hasParent(element.parentElement, parent);
        }
        else {
            return false;
        }
    };
    UIScheduler.prototype.getModelFromElement = function (element) {
        var modelProperty = Object.keys(element).find(function (k) { return k == 'model'; });
        if (modelProperty != null) {
            return element['model'];
        }
        else if (element.parentElement != null) {
            return this.getModelFromElement(element.parentElement);
        }
        else {
            return null;
        }
    };
    UIScheduler.prototype.today = function () {
        this.selectedDate = new Date();
    };
    UIScheduler.prototype.prevDate = function () {
        if (this.view == "Week" || this.view == "TimelineWeek") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(-1, "week").toDate();
        }
        else if (this.view == "TimelineMonth") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(-1, "month").toDate();
        }
        else if (this.view == "TimelineDay") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(-1, 'day').toDate();
            ;
        }
    };
    UIScheduler.prototype.nextDate = function () {
        if (this.view == "Week" || this.view == "TimelineWeek") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(1, "week").toDate();
        }
        else if (this.view == "TimelineMonth") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(1, "month").toDate();
        }
        else if (this.view == "TimelineDay") {
            this.selectedDate = (0, moment_1.default)(this.selectedDate).add(1, 'day').toDate();
            ;
        }
    };
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Array)
    ], UIScheduler.prototype, "columnList", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Array)
    ], UIScheduler.prototype, "events", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Array)
    ], UIScheduler.prototype, "ressources", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Array)
    ], UIScheduler.prototype, "group", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Date)
    ], UIScheduler.prototype, "selectedDate", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "showModalIcon", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "onUpdate", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "onUpdateMultiple", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "onEditFn", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "onDblClickFn", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "accepts", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "canMove", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Number)
    ], UIScheduler.prototype, "startHour", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Number)
    ], UIScheduler.prototype, "endHour", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", String)
    ], UIScheduler.prototype, "view", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", String)
    ], UIScheduler.prototype, "sidebarLabel", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "hasGroup", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "sidebarCollapsed", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", String)
    ], UIScheduler.prototype, "sidebarWidth", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "sortGroupAscendant", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Array)
    ], UIScheduler.prototype, "dayOffs", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "enableDragAndDrop", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.fromView }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "beginFromMonday", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "displayWeekend", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.fromView }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "shiftKeyPressed", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", Function)
    ], UIScheduler.prototype, "getMore", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Number)
    ], UIScheduler.prototype, "nbWeeksToShow", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Number)
    ], UIScheduler.prototype, "maxSelectedEvents", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.toView }),
        __metadata("design:type", Boolean)
    ], UIScheduler.prototype, "displaySidebar", void 0);
    __decorate([
        (0, aurelia_framework_1.computedFrom)('selectedDate'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIScheduler.prototype, "displayDate", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)('view'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIScheduler.prototype, "dateSelector", null);
    __decorate([
        (0, aurelia_framework_1.computedFrom)('view', 'group'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIScheduler.prototype, "allowMultipleEventsPerCell", null);
    UIScheduler = __decorate([
        aurelia_framework_1.autoinject,
        (0, aurelia_framework_1.customElement)('ui-scheduler'),
        __metadata("design:paramtypes", [Element, aurelia_framework_1.TaskQueue, aurelia_framework_1.BindingEngine, date_utils_1.DateUtils])
    ], UIScheduler);
    return UIScheduler;
}());

//# sourceMappingURL=ui-scheduler.js.map
