define(['exports', 'aurelia-framework', 'aurelia-event-aggregator', './schema', './toolbar-items', '../../lib/dataset-factory'], function (exports, _aureliaFramework, _aureliaEventAggregator, _schema, _toolbarItems, _datasetFactory) {
    'use strict';

    exports.__esModule = true;
    exports.TemplateReuse = undefined;

    function _initDefineProp(target, property, descriptor, context) {
        if (!descriptor) return;
        Object.defineProperty(target, property, {
            enumerable: descriptor.enumerable,
            configurable: descriptor.configurable,
            writable: descriptor.writable,
            value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
        });
    }

    function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
        var desc = {};
        Object['ke' + 'ys'](descriptor).forEach(function (key) {
            desc[key] = descriptor[key];
        });
        desc.enumerable = !!desc.enumerable;
        desc.configurable = !!desc.configurable;

        if ('value' in desc || desc.initializer) {
            desc.writable = true;
        }

        desc = decorators.slice().reverse().reduce(function (desc, decorator) {
            return decorator(target, property, desc) || desc;
        }, desc);

        if (context && desc.initializer !== void 0) {
            desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
            desc.initializer = undefined;
        }

        if (desc.initializer === void 0) {
            Object['define' + 'Property'](target, property, desc);
            desc = null;
        }

        return desc;
    }

    function _initializerWarningHelper(descriptor, context) {
        throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
    }

    var _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

    let TemplateReuse = exports.TemplateReuse = (_dec = (0, _aureliaFramework.inject)(_aureliaEventAggregator.EventAggregator), _dec(_class = (_class2 = class TemplateReuse {

        constructor(eventAggregator) {
            _initDefineProp(this, 'toolbarItems', _descriptor, this);

            _initDefineProp(this, 'detailToolbarSelectedId', _descriptor2, this);

            _initDefineProp(this, 'schema', _descriptor3, this);

            _initDefineProp(this, 'model', _descriptor4, this);

            this.eventAggregator = eventAggregator;
            this.schema = _schema.template;
            this.factory = new _datasetFactory.DatasetFactory(_schema.template);
        }

        attached() {
            this.toolbarItems = _toolbarItems.toolbarItems;
            this.fetch();
        }

        detached() {
            this.schema = null;
            this.model = null;
            this.toolbarItems = null;
        }

        detailToolbarSelectedIdChanged(newValue) {
            alert(newValue);
        }

        fetch() {
            this.model = this.factory.createDataSet(0);

            this.model.entity.doc = "Entity Doc";
            this.model.entityCollection.doc = "Entity Collection Doc";
            this.model.create.doc = "Create Doc";
            this.model.update.doc = "Update Doc";
            this.model.delete.doc = "Delete Doc";
        }

        print() {
            console.log(this.model);
        }
    }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'toolbarItems', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'detailToolbarSelectedId', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'schema', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'model', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    })), _class2)) || _class);
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlbXBsYXRlLXJldXNlLmpzIl0sIm5hbWVzIjpbIlRlbXBsYXRlUmV1c2UiLCJjb25zdHJ1Y3RvciIsImV2ZW50QWdncmVnYXRvciIsInNjaGVtYSIsImZhY3RvcnkiLCJhdHRhY2hlZCIsInRvb2xiYXJJdGVtcyIsImZldGNoIiwiZGV0YWNoZWQiLCJtb2RlbCIsImRldGFpbFRvb2xiYXJTZWxlY3RlZElkQ2hhbmdlZCIsIm5ld1ZhbHVlIiwiYWxlcnQiLCJjcmVhdGVEYXRhU2V0IiwiZW50aXR5IiwiZG9jIiwiZW50aXR5Q29sbGVjdGlvbiIsImNyZWF0ZSIsInVwZGF0ZSIsImRlbGV0ZSIsInByaW50IiwiY29uc29sZSIsImxvZyJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7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