define(['exports', 'aurelia-framework', './../../lib/search-filter'], function (exports, _aureliaFramework, _searchFilter) {
    'use strict';

    exports.__esModule = true;
    exports.PragmaList = 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, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3;

    let PragmaList = exports.PragmaList = (_dec = (0, _aureliaFramework.customElement)('pragma-list'), _dec2 = (0, _aureliaFramework.inject)(Element), _dec(_class = _dec2(_class = (_class2 = class PragmaList {

        constructor(element) {
            _initDefineProp(this, 'items', _descriptor, this);

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

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

            this.element = element;
        }

        attached() {}

        detached() {}

        itemsChanged() {
            if (this.busySearching) {
                this.busySearching = false;
                return;
            }

            this.itemsBackup = this.items.slice(0);
        }

        searchTextChanged(newValue) {
            this.busySearching = true;

            if (newValue.length == 0) {
                return this.items = this.itemsBackup.slice(0);
            }

            (0, _searchFilter.SearchFilter)(newValue, this.itemsBackup, this.searchField).then(result => this.items = result);
        }
    }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'items', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'searchField', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'searchText', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    })), _class2)) || _class) || _class);
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByYWdtYS1saXN0LmpzIl0sIm5hbWVzIjpbIlByYWdtYUxpc3QiLCJFbGVtZW50IiwiY29uc3RydWN0b3IiLCJlbGVtZW50IiwiYXR0YWNoZWQiLCJkZXRhY2hlZCIsIml0ZW1zQ2hhbmdlZCIsImJ1c3lTZWFyY2hpbmciLCJpdGVtc0JhY2t1cCIsIml0ZW1zIiwic2xpY2UiLCJzZWFyY2hUZXh0Q2hhbmdlZCIsIm5ld1ZhbHVlIiwibGVuZ3RoIiwic2VhcmNoRmllbGQiLCJ0aGVuIiwicmVzdWx0Il0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7UUFLYUEsVSxXQUFBQSxVLFdBRloscUNBQWMsYUFBZCxDLFVBQ0EsOEJBQU9DLE9BQVAsQywwQ0FDTSxNQUFNRCxVQUFOLENBQWlCOztBQWtCcEJFLG9CQUFZQyxPQUFaLEVBQXFCO0FBQUE7O0FBQUE7O0FBQUE7O0FBQ2pCLGlCQUFLQSxPQUFMLEdBQWVBLE9BQWY7QUFJSDs7QUFFREMsbUJBQVcsQ0FFVjs7QUFFREMsbUJBQVcsQ0FFVjs7QUFFREMsdUJBQWU7QUFDWCxnQkFBSSxLQUFLQyxhQUFULEVBQXdCO0FBQ3B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