webpackJsonp([3],{

/***/ 1519:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NspScannerLandingModule", function() { return NspScannerLandingModule; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_ionic_angular__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ngx_translate_core__ = __webpack_require__(87);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__ncinga_sp_nsp_app_core_dist__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__nsp_scanner_landing__ = __webpack_require__(1817);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__providers_data_provider__ = __webpack_require__(74);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__providers_commonenv_provider__ = __webpack_require__(118);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__module_table_core_module__ = __webpack_require__(1820);
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;
};
/**
 * Created by nisitha on 2/28/19.
 */








var NspScannerLandingModule = /** @class */ (function () {
    function NspScannerLandingModule() {
    }
    NspScannerLandingModule = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["NgModule"])({
            declarations: [
                __WEBPACK_IMPORTED_MODULE_4__nsp_scanner_landing__["a" /* NspScannerLanding */],
            ],
            imports: [
                __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["j" /* IonicPageModule */].forChild(__WEBPACK_IMPORTED_MODULE_4__nsp_scanner_landing__["a" /* NspScannerLanding */]),
                __WEBPACK_IMPORTED_MODULE_2__ngx_translate_core__["b" /* TranslateModule */].forChild(),
                __WEBPACK_IMPORTED_MODULE_3__ncinga_sp_nsp_app_core_dist__["j" /* CoreModule */],
                __WEBPACK_IMPORTED_MODULE_7__module_table_core_module__["a" /* GenericTableModule */],
            ],
            exports: [
                __WEBPACK_IMPORTED_MODULE_4__nsp_scanner_landing__["a" /* NspScannerLanding */],
            ],
            entryComponents: [],
            providers: [__WEBPACK_IMPORTED_MODULE_5__providers_data_provider__["a" /* DataProvider */], __WEBPACK_IMPORTED_MODULE_6__providers_commonenv_provider__["a" /* CoEnvProvider */], __WEBPACK_IMPORTED_MODULE_6__providers_commonenv_provider__["b" /* CoServiceEndPoints */]]
        })
    ], NspScannerLandingModule);
    return NspScannerLandingModule;
}());

//# sourceMappingURL=nsp-scanner-landing.module.js.map

/***/ }),

/***/ 1662:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GenericTableComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__pipes_gt_meta_pipe__ = __webpack_require__(1700);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__generic_table_component_template__ = __webpack_require__(1821);
var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
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 GenericTableComponent = /** @class */ (function () {
    function GenericTableComponent(renderer, gtMetaPipe) {
        var _this = this;
        this.renderer = renderer;
        this.gtMetaPipe = gtMetaPipe;
        this.columnWidth = {};
        this.sortOrder = [];
        this.metaInfo = {};
        this.selectedRows = [];
        this.openRows = [];
        this._gtSettings = [];
        this._gtFields = [];
        this.gtDefaultTexts = {
            loading: 'Loading...',
            noData: 'No data',
            noMatchingData: 'No data matching results found',
            noVisibleColumnsHeading: 'No visible columns',
            noVisibleColumns: 'Please select at least one column to be visible.',
            tableInfo: 'Showing #recordFrom to #recordTo of #recordsAfterSearch entries.',
            tableInfoAfterSearch: 'Showing  #recordFrom to #recordTo of #recordsAfterSearch entries (filtered from a total of #recordsAll entries).',
            csvDownload: 'download',
            sortLabel: 'Sort:',
            paginateNext: 'Next page',
            paginatePrevious: 'Previous page',
            inlineEditEdited: 'Press enter to save'
        };
        this.gtTexts = this.gtDefaultTexts;
        this.gtEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
        this.gtDefaultOptions = {
            csvDelimiter: ';',
            stack: false,
            lazyLoad: false,
            cache: false,
            debounceTime: 200,
            highlightSearch: false,
            rowSelection: false,
            rowSelectionAllowMultiple: true,
            rowExpandAllowMultiple: true,
            numberOfRows: 10,
            reportColumnWidth: false,
            allowUnsorted: true,
            mutateData: true
        };
        this._gtOptions = this.gtDefaultOptions;
        this.store = [];
        this.loading = true;
        this.debounceTimer = null;
        this.lazyAllSelected = false;
        this.gtInfo = {
            pageCurrent: 1,
            pageTotal: 0,
            recordFrom: 0,
            recordTo: 0,
            recordLength: this.gtOptions.numberOfRows,
            recordsAll: 0,
            recordsAfterFilter: 0,
            recordsAfterSearch: 0
        };
        this.refreshPipe = false;
        this.refreshTotals = false;
        this.refreshSorting = false;
        this.refreshFilter = false;
        this.refreshPageArray = false;
        this.editedRows = {};
        this.data = { exportData: [] }; // Store filtered data for export
        /**
         * Sort table by object key.
         * @param objectKey - name of key to sort on.
         * @param event - such as key press during sorting.
         */
        this.gtSort = function (objectKey, event) {
            this.inlineEditCancel(); // cancel inline editing
            // loop through current settings
            for (var i = 0; i < this._gtSettings.length; i++) {
                if (this._gtSettings[i].objectKey === objectKey) {
                    // check if sorting is disabled...
                    if (this._gtSettings[i].sort &&
                        this._gtSettings[i].sort.indexOf('disable') !== -1) {
                        // ...if so, exit function without applying any sorting
                        return;
                    }
                    else if (
                    /* check if sorting is undefined... */ typeof this._gtSettings[i]
                        .sort === 'undefined') {
                        // ...is so, set sorting property to enable
                        this._gtSettings[i].sort = 'enable';
                    }
                }
            }
            // check length
            var ctrlKey = event.metaKey || event.ctrlKey;
            var sort = this.sortOrder.slice(0);
            var match = -1;
            var matchDesc = -1;
            var pos = -1;
            // check if property already exits
            for (var i = 0; i < sort.length; i++) {
                var hit = sort[i].indexOf(objectKey);
                if (hit !== -1) {
                    match = this.sortOrder.indexOf(objectKey);
                    matchDesc =
                        match === -1 ? this.sortOrder.indexOf('-' + objectKey) : match;
                    pos = Math.max(match, matchDesc);
                }
            }
            // if ctrl key or meta key is press together with sort...
            if (ctrlKey) {
                if (this.sortOrder[this.sortOrder.length - 1] === '$$gtInitialRowIndex') {
                    this.sortOrder.pop();
                }
                switch (pos) {
                    // ...and property is not sorted before...
                    case -1:
                        // ...add property to sorting
                        this.sortOrder.push(objectKey);
                        break;
                    default:
                        // ...and property is sorted before...
                        if (match !== -1) {
                            // ...change from asc to desc if sorted asc
                            this.sortOrder[pos] = '-' + objectKey;
                        }
                        else if (this.sortOrder.length > 1) {
                            // ...remove sorting if sorted desc
                            if (ctrlKey) {
                                this.sortOrder[pos] = objectKey;
                            }
                            else {
                                this.sortOrder.splice(pos, 1);
                            }
                        }
                        else if (this.sortOrder.length === 1) {
                            // ...set sorting to asc if only sorted property
                            this.sortOrder[pos] = objectKey;
                        }
                        break;
                }
            }
            else {
                /* if ctrl key or meta key is not press together with sort... */
                switch (pos) {
                    // ...and property is not sorted before...
                    case -1:
                        // ...sort by property
                        this.sortOrder = [objectKey];
                        break;
                    default:
                        // ...change from desc to asc and vise versa
                        this.sortOrder =
                            match !== -1
                                ? ['-' + objectKey]
                                : ctrlKey || !this.gtOptions.allowUnsorted
                                    ? [objectKey]
                                    : [];
                        break;
                }
            }
            // update settings object with new sorting information
            for (var i = 0; i < this._gtSettings.length; i++) {
                if (this._gtSettings[i].objectKey === objectKey) {
                    switch (this._gtSettings[i].sort) {
                        // if sorted asc...
                        case 'asc':
                            // ...change to desc
                            this._gtSettings[i].sort = 'desc';
                            break;
                        // if sorted desc...
                        case 'desc':
                            // ...change to asc if it's the only sorted property otherwise remove sorting
                            this._gtSettings[i].sort =
                                (this.sortOrder.length === 1 && sort.length < 2) ||
                                    ctrlKey ||
                                    !this.gtOptions.allowUnsorted
                                    ? 'asc'
                                    : 'enable';
                            break;
                        // if sorting enabled...
                        case 'enable':
                            // ...change to asc
                            this._gtSettings[i].sort = 'asc';
                            break;
                    }
                    this._gtSettings[i].sortOrder =
                        this._gtSettings[i].sort === 'enable'
                            ? this._gtSettings.length - 1
                            : this.sortOrder.indexOf(objectKey) === -1
                                ? this.sortOrder.indexOf('-' + objectKey)
                                : this.sortOrder.indexOf(objectKey);
                }
                else if (this._gtSettings[i].sort &&
                    this._gtSettings[i].sort.indexOf('disable') === -1 &&
                    this.sortOrder.indexOf(this._gtSettings[i].objectKey) === -1 &&
                    this.sortOrder.indexOf('-' + this._gtSettings[i].objectKey) === -1) {
                    this._gtSettings[i].sort = 'enable';
                    this._gtSettings[i].sortOrder = this._gtSettings.length - 1;
                }
            }
            // refresh sorting pipe
            this.refreshSorting = !this.refreshSorting;
            this.refreshPageArray = !this.refreshPageArray;
            // sort by initial sort order as last resort
            this.sortOrder.push('$$gtInitialRowIndex');
            // emit sort event
            this.gtEvent.emit({
                name: 'gt-sorting-applied',
                value: this.sortOrder
            });
        };
        /**
         * Change number of rows to be displayed.
         * @param rowLength - total number of rows.
         * @param reset - should page be reset to first page.
         */
        this.changeRowLength = function (rowLength, reset) {
            var lengthValue = isNaN(parseInt(rowLength, 10))
                ? 0
                : parseInt(rowLength, 10);
            var newPosition = 1;
            if (!lengthValue && this.gtData) {
                lengthValue = this.gtData.length;
            }
            // if reset is not true and we're not lazy loading data...
            if (reset !== true && this._gtOptions.lazyLoad !== true) {
                // ...get current position in record set
                var currentRecord = this.gtInfo.recordLength * (this.gtInfo.pageCurrent - 1);
                var currentPosition = this._gtData.indexOf(this._gtData[currentRecord]) + 1;
                // ...get new position
                newPosition = Math.ceil(currentPosition / lengthValue);
            }
            // change row length
            this.gtInfo.recordLength = lengthValue;
            // go to new position
            this.gtInfo.pageCurrent = newPosition;
            // if lazy loading data...
            if (this._gtOptions.lazyLoad) {
                // ...replace data with place holders for new data
                this._gtData[0] = this.loadingContent(lengthValue);
                // ...empty current store
                this.store = [];
            }
            // this.updateRecordRange();
            this.gtEvent.emit({
                name: 'gt-row-length-changed',
                value: lengthValue
            });
        };
        /**
         * Force a redraw of table rows.
         * As the table uses pure pipes, we need to force a redraw if an object in the array is changed to see the changes.
         */
        this.redraw = function ($event) {
            this.refreshSorting = !this.refreshSorting;
            this.refreshPageArray = !this.refreshPageArray;
            this.refreshPipe = !this.refreshPipe;
        };
        /** Go to next page. */
        this.nextPage = function () {
            var page = this.gtInfo.pageCurrent === this.gtInfo.pageTotal
                ? this.gtInfo.pageTotal
                : this.gtInfo.pageCurrent + 1;
            this.goToPage(page);
        };
        /** Go to previous page. */
        this.previousPage = function () {
            var page = this.gtInfo.pageCurrent === 1 ? 1 : this.gtInfo.pageCurrent - 1;
            this.goToPage(page);
        };
        /** Request more data (used when lazy loading) */
        this.getData = function () {
            // ...emit event requesting for more data
            this.gtEvent.emit({
                name: 'gt-page-changed-lazy',
                value: {
                    pageCurrent: this.gtInfo.pageCurrent,
                    recordLength: this.gtInfo.recordLength
                }
            });
        };
        /**
         * Go to specific page.
         * @param page - page number.
         */
        this.goToPage = function (page) {
            var _this = this;
            var previousPage = this.gtInfo.pageCurrent;
            this.gtInfo.pageCurrent = page;
            this.inlineEditCancel(); // cancel inline edit
            // if lazy loading and if page contains no records...
            if (this._gtOptions.lazyLoad) {
                // ...if data for current page contains no entries...
                if (this._gtOptions.cache === false ||
                    this._gtData[this.gtInfo.pageCurrent - 1].length === 0) {
                    // ...create temporary content while waiting for data
                    this._gtData[this.gtInfo.pageCurrent - 1] = this.loadingContent(this.gtInfo.recordLength);
                    this.loading = true; // loading true
                }
                // ...if first entry in current page equals our loading placeholder...
                if (this._gtData[this.gtInfo.pageCurrent - 1][0][this.loadingProperty] ===
                    this.gtTexts.loading) {
                    // ...get data
                    clearTimeout(this.debounceTimer);
                    this.debounceTimer = setTimeout(function () {
                        _this.getData();
                    }, this._gtOptions.debounceTime);
                }
            }
            // this.updateRecordRange();
            // ...emit page change event
            if (previousPage !== page) {
                this.gtEvent.emit({
                    name: 'gt-page-changed',
                    value: {
                        pageCurrent: this.gtInfo.pageCurrent,
                        pagePrevious: previousPage,
                        recordLength: this.gtInfo.recordLength
                    }
                });
            }
        };
        // TODO: move to helper functions
        /** Sort by sort order */
        this.getSortOrder = function (a, b) {
            if (a.sortOrder < b.sortOrder) {
                return -1;
            }
            if (a.sortOrder > b.sortOrder || typeof a.sortOrder === 'undefined') {
                return 1;
            }
            return 0;
        };
        // TODO: move to helper functions
        /** Sort by column order */
        this.getColumnOrder = function (a, b) {
            if (a.columnOrder === undefined) {
                return -1;
            }
            if (a.columnOrder < b.columnOrder) {
                return -1;
            }
            if (a.columnOrder > b.columnOrder) {
                return 1;
            }
            return 0;
        };
        // TODO: move to helper functions
        /** Create a deep copy of data */
        this.cloneDeep = function (o) {
            return JSON.parse(JSON.stringify(o));
        };
        /** Return property */
        this.getProperty = function (array, key) {
            for (var i = 0; i < array.length; i++) {
                if (array[i].objectKey === key) {
                    return array[i];
                }
            }
        };
        this.restructureSorting = function () {
            /** Check and store sort order upon initialization.
             *  This is done by checking sort properties in the settings array of the table, if no sorting is defined
             *  we'll sort the data by the first visible and enabled column in the table(ascending). Please note that actually
             *  sorting have to be done server side when lazy loading data for obvious reasons.  */
            // create sorting array
            var sorting = [];
            if (this._gtSettings) {
                // ...sort settings by sort order
                this._gtSettings.sort(this.getSortOrder);
                // ...loop through settings
                for (var i = 0; i < this._gtSettings.length; i++) {
                    var setting = this._gtSettings[i];
                    // ...if sorted ascending...
                    if (setting.sort === 'asc') {
                        // ... add to sorting
                        sorting.push(setting.objectKey);
                    }
                    else if (setting.sort === 'desc') {
                        /* ...else if sorted descending... */ // ... add to sorting
                        sorting.push('-' + setting.objectKey);
                    }
                }
                // ...if no sorting applied...
                if (sorting.length === 0) {
                    sorting.push('$$gtRowId');
                    /*// ...sort settings by column order
                    this._gtSettings.sort(this.getColumnOrder);
    
                    // ...loop through settings
                    for (let i = 0; i < this._gtSettings.length; i++) {
                        const setting = this._gtSettings[i];
    
                        // ...if column is enabled and visible...
                        if (setting.enabled !== false && setting.visible !== false) {
                            // ...add first match and exit function
                            this.sortOrder = [this._gtSettings[i].objectKey];
                            return;
                        }
                    }*/
                }
            }
            if (this.sortOrder.length === 0) {
                this.sortOrder = sorting;
            }
        };
        /**
         *  Extend object function.
         */
        this.extend = function (a, b) {
            for (var key in b) {
                if (b.hasOwnProperty(key)) {
                    a[key] = b[key];
                }
            }
            return a;
        };
        this.gtEvent.subscribe(function ($event) {
            if ($event.name === 'gt-info') {
                _this.updateRecordRange();
            }
            if ($event.name === 'gt-row-updated') {
                _this.updateTotals();
            }
        });
    }
    Object.defineProperty(GenericTableComponent.prototype, "gtRowComponent", {
        get: function () {
            return this._gtRowComponent;
        },
        set: function (value) {
            console.warn('GtRowComponent has been deprecated and support will be removed in a future release, see https://github.com/hjalmers/angular-generic-table/issues/34');
            this._gtRowComponent = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "hasEdits", {
        get: function () {
            return Object.keys(this.editedRows).length > 0;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "gtOptions", {
        get: function () {
            return this._gtOptions;
        },
        set: function (value) {
            this._gtOptions = value;
            // if number of rows is passed and if number of rows differs from current record length...
            if (this.gtOptions.numberOfRows &&
                this.gtInfo.recordLength !== this.gtOptions.numberOfRows) {
                // ...update record length and redraw table
                this.gtInfo.recordLength = this.gtOptions.numberOfRows;
                this.redraw();
            }
            // ...extend gtOptions default values with values passed into component
            this._gtOptions = this.extend(this.gtDefaultOptions, this._gtOptions);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "gtTotals", {
        get: function () {
            return this._gtTotals;
        },
        set: function (value) {
            this._gtTotals = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "gtFields", {
        get: function () {
            return this._gtFields;
        },
        set: function (value) {
            this._gtFields = value;
            var COLUMNS_WITH_CLASS_NAMES = this._gtFields
                .map(function (column) { return column; })
                .filter(function (column) { return column.classNames; });
            // TODO: remove deprecated warning when setting has been removed
            if (COLUMNS_WITH_CLASS_NAMES.length > 0) {
                console.warn('Field setting "classNames" have been deprecated in favor for "columnClass" and will be removed in the future, please update field settings for column with object key: ' +
                    COLUMNS_WITH_CLASS_NAMES[0].objectKey);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "gtSettings", {
        get: function () {
            return this._gtSettings;
        },
        set: function (value) {
            this._gtSettings = value;
            // loop through current settings
            for (var i = 0; i < this._gtSettings.length; i++) {
                // set sort enabled/disabled setting
                this._gtSettings[i].sortEnabled =
                    this._gtSettings[i].sortEnabled !== false
                        ? (this._gtSettings[i].sortEnabled = !(this._gtSettings[i].sort &&
                            this._gtSettings[i].sort.indexOf('disable') !== -1))
                        : false;
                // check if sorting is undefined...
                if (typeof this._gtSettings[i].sort === 'undefined') {
                    // ...is so, set sorting property to enable
                    this._gtSettings[i].sort = 'enable';
                }
                // check if column order is undefined...
                if (typeof this._gtSettings[i].columnOrder === 'undefined' &&
                    this._gtSettings[i].enabled !== false) {
                    // ...is so, set sorting property to enable
                    this._gtSettings[i].columnOrder = this._gtSettings[i - 1]
                        ? this._gtSettings[i - 1].columnOrder + 1
                        : 0;
                }
                // check if column lock settings are undefined...
                if (typeof this._gtSettings[i].lockSettings === 'undefined') {
                    // ...if so, set lock settings to false unless field is disabled (enable === false)
                    this._gtSettings[i].lockSettings =
                        this._gtSettings[i].enabled === false || false;
                }
            }
            this.restructureSorting();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GenericTableComponent.prototype, "gtData", {
        get: function () {
            return this._gtData;
        },
        set: function (initialData) {
            var _this = this;
            var data = this._gtOptions.mutateData
                ? initialData.slice() : this.cloneDeep(initialData);
            if (this.gtOptions.lazyLoad && this.gtInfo) {
                this.gtMetaPipe.transform(data, this.gtOptions.rowIndex, this.gtInfo.pageCurrent - 1, this.gtInfo.recordLength);
                if (this.lazyAllSelected) {
                    var UNIQUE_ROWS_1 = this.selectedRows.map(function (row) { return row.$$gtRowId; });
                    data.map(function (row) {
                        if (UNIQUE_ROWS_1.indexOf(row.$$gtRowId) === -1) {
                            _this.selectedRows.push(row);
                        }
                    });
                    this._updateMetaInfo(this.selectedRows, 'isSelected', true);
                }
            }
            else {
                this.gtMetaPipe.transform(data, this.gtOptions.rowIndex);
            }
            if (this.gtOptions.rowSelectionInitialState) {
                data.map(function (row) {
                    var selected = typeof _this.gtOptions.rowSelectionInitialState === 'function'
                        ? _this.gtOptions.rowSelectionInitialState(row)
                        : _this.gtOptions.rowSelectionInitialState;
                    if (selected) {
                        if (typeof _this.metaInfo[row.$$gtRowId] === 'undefined') {
                            _this.metaInfo[row.$$gtRowId] = { isSelected: true };
                        }
                        else {
                            _this.metaInfo[row.$$gtRowId].isSelected = true;
                        }
                        _this.selectedRows.push(row);
                    }
                });
            }
            if (this.gtOptions.rowExpandInitialState &&
                this.gtOptions.rowExpandInitialComponent) {
                data.map(function (row) {
                    var expanded = typeof _this.gtOptions.rowExpandInitialState === 'function'
                        ? _this.gtOptions.rowExpandInitialState(row)
                        : _this.gtOptions.rowExpandInitialState;
                    _this.expandedRow = _this.gtOptions.rowExpandInitialComponent;
                    if (expanded) {
                        if (typeof _this.metaInfo[row.$$gtRowId] === 'undefined') {
                            _this.metaInfo[row.$$gtRowId] = { isOpen: true };
                        }
                        else {
                            _this.metaInfo[row.$$gtRowId].isOpen = true;
                        }
                    }
                });
            }
            this._gtData = data;
        },
        enumerable: true,
        configurable: true
    });
    /** Update record range. */
    GenericTableComponent.prototype.updateRecordRange = function () {
        this.gtInfo.recordFrom =
            this.gtInfo.recordsAfterSearch === 0
                ? 0
                : (this.gtInfo.pageCurrent - 1) * this.gtInfo.recordLength + 1;
        this.gtInfo.recordTo =
            this.gtInfo.recordsAfterSearch <
                this.gtInfo.pageCurrent * this.gtInfo.recordLength
                ? this.gtInfo.recordsAfterSearch
                : this.gtInfo.pageCurrent * this.gtInfo.recordLength;
    };
    /** Update totals. */
    GenericTableComponent.prototype.updateTotals = function () {
        this.refreshTotals = !this.refreshTotals;
    };
    /**
     * Get meta data for row.
     */
    GenericTableComponent.prototype.getRowState = function (row) {
        return typeof this.metaInfo[row.$$gtRowId] === 'undefined'
            ? null
            : this.metaInfo[row.$$gtRowId];
    };
    /**
     * Expand all rows.
     * @param expandedRow - component to render when rows are expanded.
     */
    GenericTableComponent.prototype.expandAllRows = function (expandedRow) {
        this.expandedRow = expandedRow;
        this._toggleAllRowProperty('isOpen', true);
    };
    /**
     * Collapse all rows.
     */
    GenericTableComponent.prototype.collapseAllRows = function () {
        this._toggleAllRowProperty('isOpen', false);
    };
    /**
     * Select all rows.
     */
    GenericTableComponent.prototype.selectAllRows = function () {
        this._toggleAllRowProperty('isSelected', true);
    };
    /**
     * Deselect all rows.
     */
    GenericTableComponent.prototype.deselectAllRows = function () {
        this._toggleAllRowProperty('isSelected', false);
    };
    /**
     * Toggle all rows.
     */
    GenericTableComponent.prototype.toggleAllRows = function () {
        if (this._gtOptions.lazyLoad) {
            if (!this.lazyAllSelected || this.selectedRows.length === 0) {
                this.selectAllRows();
                this.lazyAllSelected = true;
            }
            else {
                this.deselectAllRows();
                this.lazyAllSelected = false;
            }
        }
        else {
            if (this.selectedRows.length !== this.gtData.length) {
                this.selectAllRows();
            }
            else {
                this.deselectAllRows();
            }
        }
    };
    /**
     * Toggle row collapsed state ie. expanded/open or collapsed/closed.
     * @param row - row object that should be expanded/collapsed.
     * @param expandedRow - component to render when row is expanded.
     */
    GenericTableComponent.prototype.toggleCollapse = function (row, expandedRow) {
        if (expandedRow) {
            this.expandedRow = expandedRow;
        }
        this._toggleRowProperty(row, 'isOpen');
    };
    /**
     * Toggle row selected state ie. selected or not.
     * @param row - row object that should be selected/deselected.
     */
    GenericTableComponent.prototype.toggleSelect = function (row) {
        this._toggleRowProperty(row, 'isSelected');
    };
    GenericTableComponent.prototype.rowClick = function (row, $event) {
        this.gtEvent.emit({
            name: 'gt-row-clicked',
            value: { row: row, event: $event }
        });
    };
    /**
     * Update row data.
     * @param row - row object that has been edited.
     * @param oldValue - row object before edit.
     */
    GenericTableComponent.prototype.updateRow = function (row, oldValue) {
        this._toggleRowProperty(row, 'isUpdated', oldValue);
    };
    /**
     * removes a row from the table
     * @param row - the row object to remove
     */
    GenericTableComponent.prototype.removeRow = function (row) {
        if (this.isRowSelected(row)) {
            this.toggleSelect(row);
        }
        var index = this._gtData.indexOf(row);
        this._gtData.splice(index, 1);
    };
    /**
     * check if a row is selected
     * @param row - row object
     */
    GenericTableComponent.prototype.isRowSelected = function (row) {
        return (this.metaInfo[row.$$gtRowId] && this.metaInfo[row.$$gtRowId].isSelected);
    };
    /**
     * Update meta info for all rows, ie. isSelected, isOpen.
     * @param array - array that holds rows that need to be updated.
     * @param property - name of property that should be changed/toggled.
     * @param active - should rows be expanded/open, selected.
     * @param exception - update all rows except this one.
     */
    GenericTableComponent.prototype._updateMetaInfo = function (array, property, active, exception) {
        for (var i = 0; i < array.length; i++) {
            if (!this.metaInfo[array[i].$$gtRowId]) {
                this.metaInfo[array[i].$$gtRowId] = {};
            }
            if (exception && array[i].$$gtRowId === exception.$$gtRowId) {
            }
            else {
                this.metaInfo[array[i].$$gtRowId][property] = active;
            }
        }
    };
    /**
     * Push selected/expanded lazy loaded rows to array with meta data.
     * @param target - array to which rows should be added.
     * @param source - array that holds rows that should be added.
     * @returns array with added rows.
     */
    GenericTableComponent.prototype._pushLazyRows = function (target, source) {
        var UNIQUE_ROWS = target.map(function (row) { return row.$$gtRowId; });
        for (var i = 0; i < source.length; i++) {
            // only add if not already in list
            if (UNIQUE_ROWS.indexOf(source[i].$$gtRowId) === -1) {
                target.push(source[i]);
            }
        }
        return target;
    };
    /**
     * Toggle meta info for all rows, ie. isSelected, isOpen.
     * @param property - name of property that should be changed/toggled.
     * @param active - should rows be expanded/open, selected.
     */
    GenericTableComponent.prototype._toggleAllRowProperty = function (property, active) {
        var eventName;
        var eventValue;
        switch (property) {
            case 'isOpen':
                // check if multiple expanded rows are allowed...
                if (this._gtOptions.rowExpandAllowMultiple === false) {
                    // ...if not, exit function
                    console.log('feature disabled: enable by setting "rowExpandAllowMultiple = true"');
                    return;
                }
                if (active) {
                    eventName = 'expand-all';
                    this.openRows = this._gtOptions.lazyLoad
                        ? this._pushLazyRows(this.openRows, this._gtData[this.gtInfo.pageCurrent - 1].slice())
                        : this._gtData.slice();
                    this._updateMetaInfo(this.openRows, property, active);
                }
                else {
                    eventName = 'collapse-all';
                    this._updateMetaInfo(this.openRows, property, active);
                    this.openRows = [];
                }
                eventValue = {
                    expandedRows: this.openRows,
                    changedRow: 'all'
                };
                break;
            case 'isSelected':
                // check if multi row selection is allowed...
                if (this._gtOptions.rowSelectionAllowMultiple === false) {
                    // ...if not, exit function
                    console.log('feature disabled: enable by setting "rowSelectionAllowMultiple = true"');
                    return;
                }
                if (active) {
                    eventName = 'select-all';
                    this.selectedRows = this._gtOptions.lazyLoad
                        ? this._pushLazyRows(this.selectedRows, this._gtData[this.gtInfo.pageCurrent - 1].slice())
                        : this._gtData.slice();
                    this._updateMetaInfo(this.selectedRows, property, active);
                }
                else {
                    eventName = 'deselect-all';
                    this._updateMetaInfo(this.selectedRows, property, active);
                    this.selectedRows = [];
                }
                eventValue = {
                    selectedRows: this.selectedRows,
                    changedRow: 'all'
                };
                break;
        }
        this.gtEvent.emit({
            name: 'gt-row-' + eventName,
            value: eventValue
        });
    };
    /**
     * Toggle meta info for row, ie. isSelected, isOpen.
     * @param row - row object.
     * @param property - name of property that should be changed/toggled.
     * @param propertyValues - optional property values that can be passed.
     */
    GenericTableComponent.prototype._toggleRowProperty = function (row, property, propertyValues) {
        var eventName;
        var eventValue;
        // make sure gtRowId exists on row object
        if (typeof row.$$gtRowId !== 'undefined') {
            // check if meta info exists for row
            if (!this.metaInfo[row.$$gtRowId]) {
                // if not, add object to store meta info
                this.metaInfo[row.$$gtRowId] = {};
            }
            switch (property) {
                case 'isOpen':
                    var opened = this.metaInfo[row.$$gtRowId][property];
                    // check if multiple expanded rows are allowed...
                    if (this._gtOptions.rowExpandAllowMultiple === false) {
                        // ...if not, collapse all rows except current row
                        this._updateMetaInfo(this.openRows, property, false, row);
                        this.openRows = [];
                    }
                    // check if row is expanded
                    if (!opened) {
                        eventName = 'expand';
                        // add row to expanded rows
                        this.openRows.push(row);
                    }
                    else {
                        eventName = 'collapse';
                        // loop through expanded rows...
                        for (var i = 0; i < this.openRows.length; i++) {
                            // if expanded row equals passed row...
                            if (this.openRows[i].$$gtRowId === row.$$gtRowId) {
                                // ...remove row from expanded rows...
                                this.openRows.splice(i, 1);
                                // ...and exit loop
                                break;
                            }
                        }
                    }
                    eventValue = {
                        expandedRows: this.openRows,
                        changedRow: row
                    };
                    break;
                case 'isSelected':
                    var selected = this.metaInfo[row.$$gtRowId][property];
                    // check if multi row selection is allowed...
                    if (this._gtOptions.rowSelectionAllowMultiple === false) {
                        // ...if not, deselect all rows except current row
                        this._updateMetaInfo(this.selectedRows, property, false, row);
                        this.selectedRows = [];
                    }
                    // check if row is selected
                    if (!selected) {
                        eventName = 'select';
                        // add row to selected rows
                        this.selectedRows.push(row);
                    }
                    else {
                        if (this.gtOptions.lazyLoad && this.lazyAllSelected) {
                            this.lazyAllSelected = false;
                        }
                        eventName = 'deselect';
                        // loop through selected rows...
                        for (var i = 0; i < this.selectedRows.length; i++) {
                            // if selected row equals passed row...
                            if (this.selectedRows[i].$$gtRowId === row.$$gtRowId) {
                                // ...remove row from selected rows...
                                this.selectedRows.splice(i, 1);
                                // ...and exit loop
                                break;
                            }
                        }
                    }
                    eventValue = {
                        selectedRows: this.selectedRows,
                        changedRow: row
                    };
                    break;
                case 'isUpdated':
                    eventName = 'updated';
                    var oldValue = propertyValues;
                    // check if edit object exists for row
                    if (typeof this.metaInfo[row.$$gtRowId][property] === 'undefined') {
                        this.metaInfo[row.$$gtRowId][property] = {
                            originalValue: oldValue,
                            oldValue: oldValue,
                            newValue: row
                        };
                    }
                    else {
                        this.metaInfo[row.$$gtRowId][property].oldValue = oldValue;
                        this.metaInfo[row.$$gtRowId][property].newValue = row;
                    }
                    eventValue = this.metaInfo[row.$$gtRowId][property];
                    this.redraw();
                    this.inlineEditCancel(row);
                    // this.gtData = [...this.gtData.map((r) => { return{...r}; })];
                    break;
            }
            this.gtEvent.emit({
                name: 'gt-row-' + eventName,
                value: eventValue
            });
            if (property !== 'isUpdated') {
                this.metaInfo[row.$$gtRowId][property] = !this.metaInfo[row.$$gtRowId][property];
            }
        }
    };
    /**
     * Update column.
     * @param $event - key up event.
     * @param row - row object.
     * @param column - column object.
     */
    GenericTableComponent.prototype.gtUpdateColumn = function ($event, row, column) {
        this._editRow(row, column);
    };
    /**
     * Dropdown select.
     * @param row - row object.
     * @param column - column object.
     */
    GenericTableComponent.prototype.gtDropdownSelect = function (row, column) {
        var oldValue = __assign({}, row);
        row[column.objectKey] = column.renderValue;
        this.updateRow(row, oldValue);
    };
    GenericTableComponent.prototype._editRow = function (row, column) {
        var OBJECT_KEY = column.objectKey; // declare object key which contains changes
        // check if cell has changed value
        column.edited = row[column.objectKey] !== column.renderValue;
        // check if row contains changes...
        if (!this.editedRows[row.$$gtRowId]) {
            // if not, create an object for the changed row
            this.editedRows[row.$$gtRowId] = {
                changes: {},
                row: row // store reference to the row that should be updated
            };
        }
        // store changed column under changes if it has been edited
        if (column.edited) {
            this.editedRows[row.$$gtRowId].changes[OBJECT_KEY] = column;
        }
        else {
            // delete change object if column is unchanged
            delete this.editedRows[row.$$gtRowId].changes[OBJECT_KEY];
            // check how many columns have been changed
            var CHANGED_COLUMNS = Object.keys(this.editedRows[row.$$gtRowId].changes).length;
            if (CHANGED_COLUMNS === 0) {
                // delete row from edited rows if no columns have been edited
                delete this.editedRows[row.$$gtRowId];
            }
        }
        // if no listener is present...
        if (!this.globalInlineEditListener) {
            // ...listen for update event
            this._listenForKeydownEvent();
        }
    };
    /**
     * Listen for key down event - listen for key down event during inline edit.
     */
    GenericTableComponent.prototype._listenForKeydownEvent = function () {
        var _this = this;
        // add global listener for key down events
        this.globalInlineEditListener = this.renderer.listen('document', 'keydown', function ($event) {
            switch ($event.key) {
                case 'Enter':// update data object
                    _this.inlineEditUpdate();
                    break;
                case 'Escape':// cancel
                    _this.inlineEditCancel();
                    break;
            }
        });
    };
    /**
     * Inline edit update - accept changes and update row values.
     */
    GenericTableComponent.prototype.inlineEditUpdate = function () {
        var _this = this;
        // loop through rows that have been edited
        Object.keys(this.editedRows).map(function (key) {
            var ROW = _this.editedRows[key].row; // row to update
            var CHANGES = _this.editedRows[key].changes; // changes to the row
            // loop through changes in row
            Object.keys(CHANGES).map(function (objectKey) {
                var oldValue = __assign({}, ROW);
                ROW[objectKey] = CHANGES[objectKey].renderValue; // update data value
                _this.updateRow(ROW, oldValue); // update meta info for row and send event
                CHANGES[objectKey].edited = false; // disable edit mode
            });
        });
        // clear rows marked as edited as the rows have been updated
        this.editedRows = {};
        // remove listener
        this._stopListeningForKeydownEvent();
    };
    /**
     * Inline edit cancel - cancel and reset inline edits.
     */
    GenericTableComponent.prototype.inlineEditCancel = function (row) {
        var _this = this;
        if (row) {
            delete this.editedRows[row.$$gtRowId];
            // remove listener
            this._stopListeningForKeydownEvent();
            return;
        }
        // loop through rows that have been edited
        Object.keys(this.editedRows).map(function (key) {
            var ROW = _this.editedRows[key].row; // row to update
            var CHANGES = _this.editedRows[key].changes; // changes to the row
            // loop through changes in row
            Object.keys(CHANGES).map(function (objectKey) {
                CHANGES[objectKey].renderValue = ROW[objectKey]; // reset rendered value
                CHANGES[objectKey].edited = false; // disable edit mode
            });
        });
        // clear rows marked as edited as the rows have been updated
        this.editedRows = {};
        // remove listener
        this._stopListeningForKeydownEvent();
    };
    /**
     * Stop listening for key down event - stop listening for key down events passed during inline edit.
     */
    GenericTableComponent.prototype._stopListeningForKeydownEvent = function () {
        if (this.globalInlineEditListener) {
            this.globalInlineEditListener();
            this.globalInlineEditListener = null;
        }
    };
    /**
     * Apply filter(s).
     * @param filter - object containing key value pairs, where value should be array of values.
     */
    GenericTableComponent.prototype.gtApplyFilter = function (filter) {
        this.gtInfo.filter = filter;
        // go to first page
        this.goToPage(1);
        this.updateTotals();
    };
    /** Clear/remove applied filter(s). */
    GenericTableComponent.prototype.gtClearFilter = function () {
        this.gtInfo.filter = false;
        this.updateTotals();
        // this.updateRecordRange();
    };
    /**
     * Search
     * @param value - string containing one or more words
     */
    GenericTableComponent.prototype.gtSearch = function (value) {
        this.gtInfo.searchTerms = value;
        // always go to first page when searching
        this.goToPage(1);
        this.updateTotals();
    };
    /**
     * Add rows
     * @param rows - rows to add
     * @returns new data array.
     */
    GenericTableComponent.prototype.gtAdd = function (rows) {
        this.gtData = this.gtData.concat(rows);
        return this.gtData.slice();
    };
    /**
     * Delete row
     * @param objectKey - object key you want to find match with
     * @param value - the value that should be deleted
     * @param match - all: delete all matches, first: delete first match (default)
     * @returns new data array.
     */
    GenericTableComponent.prototype.gtDelete = function (objectKey, value, match) {
        if (match === void 0) { match = 'first'; }
        if (match === 'first') {
            for (var i = 0; i < this.gtData.length; i++) {
                if (this.gtData[i][objectKey] === value) {
                    if (this.isRowSelected(this.gtData[i])) {
                        this.toggleSelect(this.gtData[i]);
                    }
                    this.gtData.splice(i, 1);
                    this.gtData = this.gtData.slice();
                    if (match === 'first') {
                        break;
                    }
                }
            }
        }
        else {
            for (var i = this.gtData.length; i > 0; i--) {
                if (this.gtData[i - 1][objectKey] === value) {
                    if (this.isRowSelected(this.gtData[i - 1])) {
                        this.toggleSelect(this.gtData[i - 1]);
                    }
                    this.gtData.splice(i - 1, 1);
                    this.gtData = this.gtData.slice();
                }
            }
        }
        return this.gtData.slice();
    };
    /**
     * Create store to hold previously loaded records.
     * @param records - total number of records in store.
     * @param perPage - how many records to show per page.
     * @returns a nested array to hold records per page.
     */
    GenericTableComponent.prototype.createStore = function (records, perPage) {
        var stores = Math.ceil(records / perPage);
        var store = [];
        for (var i = 0; i < stores; i++) {
            store[i] = [];
        }
        return store;
    };
    /**
     * Create placeholders for rows while loading data from back-end.
     * @param perPage - how many records to show per page.
     * @returns an array containing empty records to be presented while fetching real data.
     */
    GenericTableComponent.prototype.loadingContent = function (perPage) {
        // create row object
        var rowObject = {
            $$loading: true
        };
        var order = 0;
        // sort settings by column order
        this._gtSettings.sort(this.getColumnOrder);
        // loop through all settings objects...
        for (var i = 0; i < this._gtSettings.length; i++) {
            var setting = this._gtSettings[i];
            // ...if column is visible and enabled...
            if (setting.visible !== false && setting.enabled !== false) {
                // ...if first column, set value to loading text otherwise leave it empty
                if (order === 0) {
                    rowObject[setting.objectKey] = this.gtTexts.loading;
                    this.loadingProperty = setting.objectKey;
                }
                else {
                    rowObject[setting.objectKey] = '';
                }
                order++;
            }
            else {
                rowObject[setting.objectKey] = '';
            }
        }
        // create content placeholder
        var contentPlaceholder = [];
        // create equal number of rows as rows per page
        for (var i = 0; i < perPage; i++) {
            // ...add temporary row object
            contentPlaceholder.push(rowObject);
        }
        return contentPlaceholder;
    };
    /** Export data as CSV
     * @param fileName - optional file name (overrides default file name).
     * @param useBOM - use BOM (byte order marker).
     */
    GenericTableComponent.prototype.exportCSV = function (fileName, useBOM) {
        var _this = this;
        if (useBOM === void 0) { useBOM = false; }
        var data = this.data.exportData;
        var csv = '';
        var BOM = '\uFEFF';
        // csv export headers
        for (var i = 0; i < this._gtSettings.length; i++) {
            if (this._gtSettings[i].export !== false) {
                csv += this.getProperty(this._gtFields, this._gtSettings[i].objectKey)
                    .name;
                if (i < this._gtSettings.length - 1) {
                    csv += this._gtOptions.csvDelimiter;
                }
            }
        }
        // csv export body
        data.forEach(function (row) {
            csv += '\n';
            for (var i = 0; i < _this._gtSettings.length; i++) {
                if (_this._gtSettings[i].export !== false) {
                    // get field settings
                    var fieldSetting = _this.getProperty(_this._gtFields, _this._gtSettings[i].objectKey);
                    // get export value, if export function is defined use it otherwise check for value function and as a last resort export raw data
                    var exportValue = fieldSetting.export && typeof fieldSetting.export === 'function'
                        ? fieldSetting.export(row)
                        : fieldSetting.value && typeof fieldSetting.value === 'function'
                            ? fieldSetting.value(row)
                            : row[_this._gtSettings[i].objectKey];
                    // escape export value using double quotes (") if export value contains delimiter
                    exportValue =
                        typeof exportValue === 'string' &&
                            exportValue.indexOf(_this._gtOptions.csvDelimiter) !== -1
                            ? '"' + exportValue + '"'
                            : exportValue;
                    csv += exportValue;
                    if (i < _this._gtSettings.length - 1) {
                        csv += _this._gtOptions.csvDelimiter;
                    }
                }
            }
        });
        var blob = new Blob([(useBOM ? BOM : '') + csv], {
            type: 'text/csv;charset=utf-8'
        });
        if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveOrOpenBlob(blob, fileName ? fileName + '.csv' : this.gtTexts.csvDownload + '.csv');
        }
        else {
            var link = document.createElement('a');
            link.style.display = 'none';
            document.body.appendChild(link);
            if (link.download !== undefined) {
                link.setAttribute('href', 'data:text/csv;charset=utf-8,' +
                    encodeURIComponent((useBOM ? BOM : '') + csv)); // URL.createObjectURL(blob));
                link.setAttribute('download', fileName ? fileName + '.csv' : this.gtTexts.csvDownload + '.csv');
                document.body.appendChild(link);
                link.click();
            }
            else {
                csv = 'data:text/csv;charset=utf-8,' + (useBOM ? BOM : '') + csv;
                window.open(encodeURIComponent(csv));
            }
            document.body.removeChild(link);
        }
        // emit export event
        this.gtEvent.emit({
            name: 'gt-exported-csv',
            value: fileName ? fileName : this.gtTexts.csvDownload + '.csv'
        });
    };
    GenericTableComponent.prototype.ngOnInit = function () {
        // if number of row to display from start is set to null or 0...
        if (!this.gtOptions.numberOfRows) {
            // ...change row length
            this.changeRowLength(this.gtOptions.numberOfRows);
        }
        this.restructureSorting();
    };
    GenericTableComponent.prototype.ngOnChanges = function (changes) {
        // if gt texts have changed...
        if (changes['gtTexts']) {
            // ...extend gtOptions default values with values passed into component
            this.gtTexts = this.extend(this.gtDefaultTexts, this.gtTexts);
        }
        // if lazy loading data and paging information is available...
        if (this.gtOptions.lazyLoad && this.gtInfo) {
            // ...calculate total number of pages
            this.gtInfo.pageTotal = Math.ceil(this.gtInfo.recordsAfterSearch / this.gtInfo.recordLength);
            // ...declare store position
            var storePosition = this.gtInfo.pageCurrent - 1;
            // ...and if store is empty or page length has changed...
            if (this.store.length === 0 ||
                this.store[0].length !== this.gtInfo.recordLength) {
                // ...create store
                this.store = this.createStore(this.gtInfo.recordsAfterSearch, this.gtInfo.recordLength);
            }
            // ...store retrieved data in store at store position
            this.store[storePosition] = this.gtData;
            this.gtInfo.visibleRecords = this.gtData.slice(); // add visible rows
            // replace data with store
            this._gtData = this.store;
            this.loading = false;
            this.updateRecordRange();
            this.gtEvent.emit({
                name: 'gt-info',
                value: this.gtInfo
            });
        }
        else if (this._gtData &&
            this._gtData.length >= 0 &&
            changes['gtData'] &&
            changes['gtData'].previousValue) {
            this.loading = false;
        }
        else if (changes['gtData'] &&
            changes['gtData'].firstChange &&
            this._gtData &&
            this._gtData.length > 0) {
            this.loading = false;
        }
    };
    GenericTableComponent.prototype.trackByFn = function (index, item) {
        return item.$$gtRowId;
    };
    GenericTableComponent.prototype.trackByColumnFn = function (index, item) {
        return item.objectKey;
    };
    GenericTableComponent.prototype.ngOnDestroy = function () {
        // remove listener
        this._stopListeningForKeydownEvent();
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [Object])
    ], GenericTableComponent.prototype, "gtOptions", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [Object])
    ], GenericTableComponent.prototype, "gtTotals", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array),
        __metadata("design:paramtypes", [Array])
    ], GenericTableComponent.prototype, "gtFields", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array),
        __metadata("design:paramtypes", [Array])
    ], GenericTableComponent.prototype, "gtSettings", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array),
        __metadata("design:paramtypes", [Array])
    ], GenericTableComponent.prototype, "gtData", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Type"]),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["Type"]])
    ], GenericTableComponent.prototype, "gtRowComponent", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GenericTableComponent.prototype, "gtTexts", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String)
    ], GenericTableComponent.prototype, "gtClasses", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"])
    ], GenericTableComponent.prototype, "gtEvent", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GenericTableComponent.prototype, "gtInfo", void 0);
    GenericTableComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'generic-table',
            template: __WEBPACK_IMPORTED_MODULE_2__generic_table_component_template__["a" /* GENERIC_TABLE_COMPONENT */]
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["Renderer2"], __WEBPACK_IMPORTED_MODULE_1__pipes_gt_meta_pipe__["a" /* GtMetaPipe */]])
    ], GenericTableComponent);
    return GenericTableComponent;
}());

//# sourceMappingURL=generic-table.component.js.map

/***/ }),

/***/ 1700:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtMetaPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtMetaPipe = /** @class */ (function () {
    function GtMetaPipe() {
    }
    GtMetaPipe.prototype.transform = function (allRows, rowIndex, page, recordLength) {
        for (var i = 0; i < allRows.length; i++) {
            if (!allRows[i].$$gtRowId) {
                allRows[i].$$gtRowId = rowIndex
                    ? allRows[i][rowIndex]
                    : page
                        ? page * recordLength +
                            i +
                            '_' +
                            Math.random()
                                .toString(36)
                                .substr(2, 16)
                        : i +
                            '_' +
                            Math.random()
                                .toString(36)
                                .substr(2, 16);
            }
            if (!allRows[i].$$gtInitialRowIndex) {
                allRows[i].$$gtInitialRowIndex = i;
            }
        }
        return allRows;
    };
    GtMetaPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtMeta'
        })
    ], GtMetaPipe);
    return GtMetaPipe;
}());

//# sourceMappingURL=gt-meta.pipe.js.map

/***/ }),

/***/ 1701:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtHighlightPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser__ = __webpack_require__(73);
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 GtHighlightPipe = /** @class */ (function () {
    function GtHighlightPipe(sanitizer) {
        this.sanitizer = sanitizer;
    }
    GtHighlightPipe.prototype.transform = function (text, searchTerm) {
        var haystackAlwaysString = text + '';
        var highlightedText = haystackAlwaysString; // fallback
        var searchPattern;
        try {
            searchPattern = new RegExp('(' +
                searchTerm
                    .toLowerCase()
                    .match(/".*?"|[^ ]+/g) // extract words
                    .map(function (needle) { return needle.replace(/"(.*?)"/, '$1'); } // strip away '"'
                )
                    .join('|') + // combine words
                ')', 'ig');
        }
        catch (error) {
            return this.sanitizer.bypassSecurityTrustHtml(highlightedText);
        }
        var containsTagPattern = /(<.*?>)(.*)(<\/.*?>)/gi;
        var containsTagMatches = containsTagPattern.exec(haystackAlwaysString);
        if (containsTagMatches) {
            // tag exists in haystack
            highlightedText =
                containsTagMatches[1] +
                    containsTagMatches[2].replace(searchPattern, '<span class="gt-highlight-search">$1</span>') +
                    containsTagMatches[3];
        }
        else {
            highlightedText = haystackAlwaysString.replace(searchPattern, '<span class="gt-highlight-search">$1</span>');
        }
        return this.sanitizer.bypassSecurityTrustHtml(highlightedText);
    };
    GtHighlightPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtHighlight'
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__angular_platform_browser__["c" /* DomSanitizer */]])
    ], GtHighlightPipe);
    return GtHighlightPipe;
}());

//# sourceMappingURL=gt-highlight.pipe.js.map

/***/ }),

/***/ 1702:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtExpandedRow; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GtExpandingRowComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtExpandedRow = /** @class */ (function () {
    function GtExpandedRow() {
        this.redrawEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
        this.toggleRowEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
    }
    GtExpandedRow.prototype.$hide = function () {
        this.toggleRowEvent.emit(this.row);
    };
    GtExpandedRow.prototype.$redraw = function ($event) {
        this.redrawEvent.emit(this.row);
    };
    GtExpandedRow.prototype.$rowClick = function (row, $event) {
        this.gtEvent.emit({
            name: 'gt-row-clicked',
            value: { row: row, event: $event }
        });
    };
    return GtExpandedRow;
}());

var GtExpandingRowComponent = /** @class */ (function () {
    function GtExpandingRowComponent() {
        this.redrawEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
        this.toggleRowEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
    }
    GtExpandingRowComponent.prototype.newInstance = function (instance) {
        instance.row = this.row;
        instance.columnWidth = this.columnWidth;
        instance.gtSettings = this.gtSettings;
        instance.gtFields = this.gtFields;
        instance.gtOptions = this.gtOptions;
        instance.gtInfo = this.gtInfo;
        instance.data =
            typeof this.data === 'function' ? this.data(this.row) : this.data;
        instance.redrawEvent.subscribe(this.redrawEvent);
        instance.toggleRowEvent.subscribe(this.toggleRowEvent);
        instance.gtEvent = this.gtEvent;
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Type"])
    ], GtExpandingRowComponent.prototype, "type", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "row", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "columnWidth", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array)
    ], GtExpandingRowComponent.prototype, "gtSettings", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array)
    ], GtExpandingRowComponent.prototype, "gtFields", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "gtOptions", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "gtInfo", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "data", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "redrawEvent", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "toggleRowEvent", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtExpandingRowComponent.prototype, "gtEvent", void 0);
    GtExpandingRowComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-expanding-row',
            template: "\n        <div gtComponentAnchor\n             [ctor]=\"type\" (instance)=\"newInstance($event)\"></div>"
        })
    ], GtExpandingRowComponent);
    return GtExpandingRowComponent;
}());

//# sourceMappingURL=gt-expanding-row.component.js.map

/***/ }),

/***/ 1817:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NspScannerLanding; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_ionic_angular__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_ngx_logger__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__nsp_scanner_landing_html__ = __webpack_require__(1818);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__providers_data_provider__ = __webpack_require__(74);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_modals_selecLines__ = __webpack_require__(1024);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_qrious__ = __webpack_require__(1819);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_qrious___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_qrious__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__providers_tagGroup_provider__ = __webpack_require__(220);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__providers_nsp_scanner_provider__ = __webpack_require__(157);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__ncinga_sp_nsp_app_core_dist__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__providers_base_scanner_transaction_provider__ = __webpack_require__(384);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__providers_nsp_cmaster_data_service__ = __webpack_require__(383);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__providers_event_provider__ = __webpack_require__(218);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__components_modals_line_validate_modal__ = __webpack_require__(1025);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__ncinga_sp_nsp_app_core_dist_providers_app_events__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_ionic_angular_util_util__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16_timers__ = __webpack_require__(378);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16_timers___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_16_timers__);
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) {
    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) : new P(function (resolve) { resolve(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 (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, 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 };
    }
};
/**
 * Created by nisitha on 2/28/19.
 */

















var NspScannerLanding = /** @class */ (function () {
    function NspScannerLanding(logger, navParams, alertCtrl, modalCtrl, dataPv, tagProvider, scanningService, navManager, baseSc, appMasterPro, appCache, EventCtrl, appStateService, appCtx) {
        this.logger = logger;
        this.navParams = navParams;
        this.alertCtrl = alertCtrl;
        this.modalCtrl = modalCtrl;
        this.dataPv = dataPv;
        this.tagProvider = tagProvider;
        this.scanningService = scanningService;
        this.navManager = navManager;
        this.baseSc = baseSc;
        this.appMasterPro = appMasterPro;
        this.appCache = appCache;
        this.EventCtrl = EventCtrl;
        this.appStateService = appStateService;
        this.appCtx = appCtx;
        this.slideindex = 0;
        this.tools = {};
        this.NumberOftags = 0;
        this.curentStationLines = [];
        this.selecMissingDetails = [];
        this.currentMethod = 'camera';
        this.currentScannerType = 'initial';
        this.activeId = '';
        this.newAddedDetail = [];
        this.tableData = [];
        this.ctx = [];
        this.dataMapping = [];
        this.subscribers = [];
        this.appChange = false;
        this.workingSubjects = [];
        this.waitingList = [];
        this.processWItems = true;
        this.data = [];
        this.testId = 10;
        this.startCount = 10;
        this.timeInterval = 1000;
        this.tools = {
            line: false,
            menu: false,
            shift: true,
            user: false,
            apps: false
        };
        this.shiftDis = true;
        this.subjectDis = true;
    }
    NspScannerLanding.prototype.startLoadTest = function () {
        var _this = this;
        this.startCount = parseInt(this.startCount + '');
        this.timeInterval = parseInt(this.timeInterval + '');
        this.startLoad = this.startLoad ? false : true;
        var _thisScope = this;
        this.runningInterval = Object(__WEBPACK_IMPORTED_MODULE_16_timers__["setInterval"])(function () {
            if (_this.startLoad) {
                _this.scanningService.dummyScanner(true, '', 'loadTest', _this.startCount);
                _this.startCount = _this.startCount + 1;
                _this.subscribeToTagUpdate();
            }
            else if (_thisScope.runningInterval) {
                clearInterval(_thisScope.runningInterval);
            }
        }, this.timeInterval);
    };
    NspScannerLanding.prototype.sendUniqueWithId = function () {
        this.scanningService.dummyScanner(true, '', '', 0, this.testId);
    };
    NspScannerLanding.prototype.ionViewWillEnter = function () {
        this.config = this.navParams.get('conf');
        this.curentStationLines = [];
        if (this.config) {
            this.setupPage(this.config);
            if (this.config['tag_mappings']) {
                this.dataMapping = this.config['tag_mappings'];
            }
            if (this.config['scanner_conf']) {
                this.scanningService.init(this.config['scanner_conf']);
                if (this.config['scanner_conf']['external']) {
                    this.subscribeToExternalDevice();
                }
            }
        }
        this.initEventListeners();
        this.updateViewWithServiceData();
        if (!this.appCtx.getCurrentShift().id) {
            this.appStateService.notifyDataChanged(__WEBPACK_IMPORTED_MODULE_14__ncinga_sp_nsp_app_core_dist_providers_app_events__["b" /* APPEvents */].SET_RUNING_SHIFT, Math.random());
        }
    };
    NspScannerLanding.prototype.addNewTagToWaitingList = function (data) {
        var tag = data['tag'];
        var index = this.waitingList.findIndex(function (wTag) { return wTag.tag['tag_id'] === tag['tag_id']; });
        if (index === -1) {
            this.waitingList.push(data);
        }
    };
    NspScannerLanding.prototype.processWaitingItems = function () {
        var _this = this;
        this.waitingList.forEach(function (tag, index) {
            _this.handleTagUpdate(tag);
            _this.waitingList.splice(index, 1);
        });
    };
    NspScannerLanding.prototype.addNewSubject = function (subject, cache) {
        var id = subject && subject['subject'] ? subject['subject']['subject'] : '';
        var index = this.workingSubjects.findIndex(function (wSub) { return (wSub.subject && (wSub.subject.subject === id)); });
        if (index === -1) {
            this.workingSubjects.push(subject);
        }
        this.workingSubjects.sort(function (a, b) {
            return a.name.localeCompare(b.name);
        });
        if (cache) {
            this.updateSubjectsDetailsInCache();
        }
    };
    NspScannerLanding.prototype.removeSubject = function (subject) {
        var id = subject && subject['subject'] ? subject['subject'] : '';
        var index = this.workingSubjects.findIndex(function (wSub) { return (wSub.subject && (wSub.subject.subject === id)); });
        if (index > -1) {
            this.workingSubjects.splice(index, 1);
        }
    };
    NspScannerLanding.prototype.selectSubject = function (subject, cache, setToAll) {
        var id = subject && subject['subject'] ? subject['subject'] : '';
        var index = this.workingSubjects.findIndex(function (wSub) { return (wSub.subject && (wSub.subject.subject === id)); });
        this.deselectAllSubject();
        if (index > -1) {
            this.workingSubjects[index]['isSelected'] = true;
        }
        if (setToAll) {
            this.setCurrentSubjectToAllTags();
        }
        if (cache) {
            this.updateSubjectsDetailsInCache();
        }
        if (this.processWItems) {
            this.processWaitingItems();
        }
    };
    NspScannerLanding.prototype.deselectAllSubject = function () {
        this.workingSubjects.forEach(function (wSub) {
            wSub['isSelected'] = false;
        });
    };
    NspScannerLanding.prototype.isSubjectSelected = function () {
        var index = this.workingSubjects.findIndex(function (wSub) { return wSub.isSelected; });
        return index > -1;
    };
    NspScannerLanding.prototype.getSelectedSubject = function () {
        var index = this.workingSubjects.findIndex(function (wSub) { return wSub.isSelected; });
        if (index > -1) {
            return this.workingSubjects[index].subject;
        }
        return null;
    };
    NspScannerLanding.prototype.ionViewDidLeave = function () {
        try {
            if (this.tagdata) {
                this.tagdata.unsubscribe();
            }
        }
        catch (e) {
            this.logger.error(e);
        }
    };
    NspScannerLanding.prototype.updateSubjectsDetailsInCache = function () {
        this.appCache.saveSubjectDetails(this.workingSubjects);
    };
    NspScannerLanding.prototype.initEventListeners = function () {
        var _this = this;
        var s1 = this.appStateService.subscribe('APP_CHANGE_SUCCESS', function (res) {
            _this.deselectAllSubject();
        });
        this.subscribers.push(s1);
    };
    // config setup
    NspScannerLanding.prototype.setupPage = function (data) {
        this.tagProvider.setup(data);
        if (data && data && data.title) {
            this.title = data.title;
        }
        if (data && data && data.missing_details) {
            this.missingDetails = data.missing_details;
        }
        var tools = data.tools;
        if (tools) {
            this.tools = Object.assign(this.tools, tools);
        }
        if (data && data.sub_title) {
            this.moduleTitle = data.sub_title;
        }
        if (data && data.imgPath) {
            this.imgPath = data.imgPath;
        }
        if (data && data.appState) {
            this.appState = data.appState;
        }
        if (data && data.subject_disable) {
            this.subjectDis = data.subject_disable;
        }
        if (data && data.shift_disabled) {
            this.shiftDis = data.shift_disabled;
        }
        if (data && data.slide) {
            this.slideView = data.slide;
        }
        if (data && data.horizontal_button) {
            this.horizontalView = data.horizontal_button;
        }
        if (data && data.vertical_button) {
            this.verticalView = data.vertical_button;
        }
        if (data && data.table) {
            this.tableView = data.table;
        }
        this.subjectConfirmation = data && data.subject_confirmation ? true : false;
        this.syncWithCacheData(data);
    };
    NspScannerLanding.prototype.syncWithCacheData = function (conf) {
        var _this = this;
        if (conf && conf.meta_data && conf.meta_data['line_meta']) {
            this.appCache.loadMasterData(conf.meta_data['line_meta']).then(function (d) {
                _this.appCache.getWorkingSubjects().then(function (subs) {
                    _this.workingSubjects = subs;
                    if (_this.tagProvider.appChanged) {
                        _this.deselectAllSubject();
                    }
                });
            });
        }
    };
    NspScannerLanding.prototype.setTableColumnConfigs = function (conf) {
        this.configObject = {
            settings: conf['table_setting'],
            fields: conf['table_headers'],
            data: JSON.parse(JSON.stringify(this.tableData))
        };
        this.NumberOftags = this.tableData.length;
    };
    NspScannerLanding.prototype.tableDataSet = function (data) {
        if (data && data.tag['info']) {
            if (this.dataMapping) {
                this.dataMapping.forEach(function (map) {
                    var dataKey = Object.keys(data.tag['info']);
                });
                this.getTntData(data.tag);
            }
        }
    };
    NspScannerLanding.prototype.getTntData = function (tagdata) {
        return __awaiter(this, void 0, void 0, function () {
            var subjectKey, subject, tagId, businessData;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        subjectKey = this.appCtx.getKeySubject();
                        subject = this.appCtx.getCurrentSubject().id;
                        tagId = tagdata['tag_id'];
                        return [4 /*yield*/, this.dataPv.getCurrentBusinessForTag({
                                'subject_key': subjectKey,
                                'subject': subject,
                                'tag_id': tagId,
                                'datetime': Date.now()
                            })];
                    case 1:
                        businessData = _a.sent();
                        if (businessData && businessData.status === 'success') {
                            if (businessData.missing) {
                                tagdata.info['missing'] = businessData.missing;
                            }
                            else {
                                tagdata.info['missing'] = 0;
                            }
                            if (businessData.sample) {
                                tagdata.info['sample'] = businessData.sample;
                            }
                            else {
                                tagdata.info['sample'] = 0;
                            }
                            if (businessData.pd) {
                                tagdata.info['pd'] = businessData.pd;
                            }
                            else {
                                tagdata.info['pd'] = 0;
                            }
                            if (businessData.fd) {
                                tagdata.info['fd'] = businessData.fd;
                            }
                            else {
                                tagdata.info['fd'] = 0;
                            }
                            if (businessData.rec_qty) {
                                tagdata.info['rec_qty'] = businessData.rec_qty;
                            }
                            else {
                                tagdata.info['rec_qty'] = 0;
                            }
                        }
                        this.tableData.push(tagdata.info);
                        this.setTableColumnConfigs(this.config);
                        return [2 /*return*/];
                }
            });
        });
    };
    NspScannerLanding.prototype.tableDataClear = function () {
        this.tableData = [];
    };
    NspScannerLanding.prototype.addNewDetail = function () {
        var _this = this;
        this.newAddedDetail = [];
        var prompt = this.alertCtrl.create({
            title: this.config['table_popup_title'],
            inputs: [
                {
                    name: 'Box No',
                    placeholder: 'Box No',
                    type: 'number'
                },
            ],
            buttons: [
                {
                    text: 'Cancel',
                    handler: function (data) {
                    }
                },
                {
                    text: 'Save',
                    handler: function (data) {
                        _this.newAddedDetail.push(data);
                        if (data) {
                            _this.sendSubmitEvent(_this.newAddedDetail);
                        }
                    }
                }
            ]
        });
        prompt.present();
    };
    NspScannerLanding.prototype.sendSubmitEvent = function (addedDetail) {
        var _this = this;
        var conf, args = {}, bundle_qty, event_name = 'checkin';
        if (this.config['table_headers']) {
            conf = JSON.parse(JSON.stringify(this.config['table_headers']));
        }
        if (this.tableData && this.tableData.length > 0) {
            this.tableData.forEach(function (item) {
                bundle_qty = 0;
                _this.ctx = [];
                var key = Object.keys(item);
                key.forEach(function (keys) {
                    conf.forEach(function (config) {
                        if (config.objectKey === keys) {
                            _this.ctx.push({ k: keys, v: item[keys] });
                        }
                        if (config.objectKey === 'qty') {
                            bundle_qty = item[config.objectKey];
                        }
                    });
                });
                args['ctx'] = _this.ctx;
                args['box_no'] = addedDetail;
                _this.EventCtrl.sendEvent(event_name, bundle_qty, args);
            });
        }
    };
    NspScannerLanding.prototype.updateViewWithServiceData = function () {
        this.tagGroups = this.tagProvider.getCurrentTagGroup();
        if (this.tagGroups && this.tagGroups.tags && this.tagGroups.tags.length > 0) {
            this.tagGroupView = this.tagGroups.tags;
            this.tagGroupView.sort(function (a, b) { return new Date(b.datetime).getTime() - new Date(a.datetime).getTime(); });
            this.NumberOftags = this.tagGroupView.length;
        }
    };
    // all line select modal
    NspScannerLanding.prototype.openSubjectSettingsModal = function () {
        var _this = this;
        if (this.config) {
            this.config['linePopup'] = 'check';
        }
        var popup = this.modalCtrl.create(__WEBPACK_IMPORTED_MODULE_5__components_modals_selecLines__["a" /* SelecLinesModal */], { conf: this.config, data: this.workingSubjects }, { cssClass: 'cutbankline', enableBackdropDismiss: false });
        popup.onDidDismiss(function (data) {
            _this.workingSubjects = [];
            if (data && data.length > 0) {
                data.forEach(function (sub) {
                    _this.addNewSubject(Object.assign({}, sub));
                });
            }
        });
        popup.present();
        this.logger.trace('current-lines', this.curentStationLines);
    };
    // set tag data
    NspScannerLanding.prototype.setQRdata = function (index) {
        if (this.tagGroupView.length > index) {
            var rawData = this.tagGroupView[index].raw_data;
            if (rawData && Object(__WEBPACK_IMPORTED_MODULE_15_ionic_angular_util_util__["e" /* isArray */])(rawData) && rawData.length > 0) {
                this.qrData = rawData[0];
            }
            else if (rawData) {
                this.qrData = rawData;
            }
            else {
                this.createQRString(this.tagGroupView[index]);
            }
            this.qrGenerate(this.qrData);
        }
        else {
            this.qrData = 'QR not detected';
            this.qrGenerate(this.qrData);
        }
    };
    NspScannerLanding.prototype.createQRString = function (data) {
        var tagData = data;
        if (data && data.length > 0 && data.info) {
            for (var i = 0; i < tagData.length; i++) {
                this.qrData.push('"_n.c.k_id,by,sty,qty,schd,clr,cut,cpo,oref,shd,sz,sr,itm,bn,rs,sq_n.c.v_' +
                    tagData[i].tag_id + ',' +
                    tagData[i].info.buyer + ',' +
                    tagData[i].info.style + ',' +
                    tagData[i].info.qty + ',' +
                    tagData[i].info.schedule + ',' +
                    tagData[i].info.color + ',' +
                    tagData[i].info.cut + ',' +
                    tagData[i].info.cpo + ',' +
                    tagData[i].info.order_ref + ',' +
                    tagData[i].info.shade + ',' +
                    tagData[i].info.size + ',' +
                    tagData[i].info.sticker_range + ',' +
                    tagData[i].info.item + ',' +
                    tagData[i].info.bundle + ',' + '"');
                // console.log(this.qrData[i]);
            }
        }
    };
    // generate qr
    NspScannerLanding.prototype.qrGenerate = function (value) {
        var res;
        var qrCode = new __WEBPACK_IMPORTED_MODULE_6_qrious___default.a({
            level: 'L',
            size: 300,
            value: value
        });
        res = qrCode.toDataURL();
        this.tagString = res;
    };
    // scanner
    NspScannerLanding.prototype.startScan = function () {
        if (this.missingDetails) {
            if (!this.isSubjectSelected() && this.appState) {
                this.presentLineAlert();
            }
            else {
                //  this.scanningService.dummyScanner(true);
                this.scanningService.openCamera();
                this.logger.trace(':::: selected-line', this.selecMissingDetails);
                this.subscribeToTagUpdate();
            }
        }
        if (!this.missingDetails) {
            this.scanningService.openCamera();
            this.subscribeToTagUpdate();
        }
        // this.slideToLatest(0);
    };
    NspScannerLanding.prototype.subscribeToTagUpdate = function () {
        var _this = this;
        if (!this.tagdata || (this.tagdata && this.tagdata.closed)) {
            this.tagdata = this.tagProvider.tagdata.subscribe(function (data) {
                if (_this.missingDetails) {
                    _this.handleTagUpdate(data);
                }
                if (!_this.missingDetails) {
                    _this.tableDataSet(data);
                }
            });
        }
    };
    NspScannerLanding.prototype.presentLineAlert = function (manualtagAlert) {
        var _this = this;
        var msg = !manualtagAlert ? 'Please Select a Line before scan' : 'Please Select a Line Manually before scan';
        if (!this.lineAlert) {
            this.lineAlert = this.alertCtrl.create({
                title: '!',
                message: msg,
                cssClass: 'scanner-alert',
                buttons: [
                    {
                        text: 'OK',
                        role: 'ok'
                    }
                ]
            });
            this.lineAlert.present();
            this.lineAlert.didLeave.subscribe(function (data) {
                _this.lineAlert = void 0;
            });
        }
    };
    NspScannerLanding.prototype.presentLineConfirmModal = function () {
        var _this = this;
        var popup = this.modalCtrl.create(__WEBPACK_IMPORTED_MODULE_13__components_modals_line_validate_modal__["a" /* LineValidateModal */], { conf: this.config, data: this.workingSubjects }, { cssClass: 'cutbankline', enableBackdropDismiss: false });
        popup.onDidDismiss(function (data) {
            if (data && data.length > 0) {
                _this.isSubjectValidated = true;
                _this.selectSubject(data[0], true);
                _this.setCurrentSubjectToAllTags();
            }
        });
        popup.present();
    };
    NspScannerLanding.prototype.organizeSlider = function () {
        try {
            if (this.tagGroups && this.tagGroups.tags && this.tagGroups.tags.length > 0) {
                this.tagGroupView = this.tagGroups.tags;
                this.tagGroupView.sort(function (a, b) { return new Date(b.datetime).getTime() - new Date(a.datetime).getTime(); });
                this.NumberOftags = this.tagGroupView.length;
            }
        }
        catch (e) {
            this.logger.error(e);
        }
        this.slideToLatestTag();
    };
    NspScannerLanding.prototype.handleTagUpdate = function (data) {
        try {
            if (data && (data['topic'] === 'camera' || data['topic'] === 'WIRED' || data['topic'] === 'manual')) {
                var tag = data['tag'];
                if (!this.isSubjectSelected() && !this.isLineAvailable(tag)) {
                    this.tagProvider.removeTag(tag['tag_id']);
                }
                else if (this.isSubjectSelected() && !this.isLineAvailable(tag)) {
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else if (!this.isSubjectSelected() && this.isLineAvailable(tag)) {
                    var resSub = tag.info['receiver_subject'];
                    this.addNewSubject({ subject: resSub, name: resSub.dis_name }, true);
                    this.selectSubject(resSub, true);
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else if (this.isSubjectSelected() && this.isLineAvailable(tag)) {
                    this.deselectAllSubject();
                    var resSub = tag.info['receiver_subject'];
                    this.addNewSubject({ subject: resSub, name: resSub.dis_name }, true);
                    this.selectSubject(resSub, true);
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else {
                    var flag = this.missingDetails ? false : true;
                    this.presentLineAlert(flag);
                }
            }
            else if (data && data['topic'] === 'BLUETOOTH') {
                var tag = data['tag'];
                if (!this.missingDetails && !this.isSubjectSelected()) {
                    this.presentLineAlert();
                    this.addNewTagToWaitingList(data);
                }
                if (!this.processWItems && !this.isSubjectSelected() && !this.isLineAvailable(tag)) {
                    this.tagProvider.removeTag(tag['tag_id']);
                }
                else if (this.isSubjectSelected() && !this.isLineAvailable(tag)) {
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else if (!this.isSubjectSelected() && this.isLineAvailable(tag)) {
                    var resSub = tag.info['receiver_subject'];
                    this.addNewSubject({ subject: resSub, name: resSub.dis_name }, true);
                    this.selectSubject(resSub, true);
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else if (this.isSubjectSelected() && this.isLineAvailable(tag)) {
                    this.deselectAllSubject();
                    var resSub = tag.info['receiver_subject'];
                    this.addNewSubject({ subject: resSub, name: resSub.dis_name }, true);
                    this.selectSubject(resSub, true);
                    this.activeId = tag ? tag['tag_id'] : '';
                    this.setCurrentSubjectToLatestTag(this.activeId);
                }
                else {
                    var flag = this.missingDetails ? false : true;
                    this.presentLineAlert(flag);
                }
                if (this.startLoad) {
                    this.confirm();
                }
            }
        }
        catch (e) {
            this.logger.error(e);
        }
    };
    NspScannerLanding.prototype.setCurrentSubjectToLatestTag = function (tag_id) {
        var tagGroups = this.tagProvider.getCurrentTagGroup();
        var index = tagGroups.tags.findIndex(function (tag) { return tag.tag_id === tag_id; });
        if (index > -1) {
            var subject = this.getSelectedSubject();
            if (subject !== null) {
                tagGroups.tags[index].info['line'] = subject.dis_name;
                tagGroups.tags[index].info['receiver_subject'] = subject;
            }
        }
        this.tagGroups = tagGroups;
        this.organizeSlider();
    };
    NspScannerLanding.prototype.setCurrentSubjectToAllTags = function () {
        var tagGroups = this.tagProvider.getCurrentTagGroup();
        var subject = this.getSelectedSubject();
        if (tagGroups && subject !== null) {
            tagGroups.tags.forEach(function (tag) {
                tag.info['line'] = subject.dis_name;
                tag.info['receiver_subject'] = subject;
            });
        }
        this.tagGroups = tagGroups;
        this.organizeSlider();
        if (this.confirmTrigger) {
            this.confirm();
        }
    };
    NspScannerLanding.prototype.slideToLatestTag = function () {
        var _this = this;
        try {
            var index = this.activeId !== '' && this.tagGroupView ? this.tagGroupView.findIndex(function (tg) { return tg.tag_id === _this.activeId; }) : null;
            if (index !== null) {
                index = index > 0 ? index - 1 : 0;
                this.slideToLatest(index);
                this.setQRdata(index);
            }
        }
        catch (e) {
            this.logger.error(e);
        }
    };
    NspScannerLanding.prototype.subscribeToExternalDevice = function () {
        this.subscribeToTagUpdate();
    };
    NspScannerLanding.prototype.slideToLatest = function (index) {
        var _this = this;
        try {
            setTimeout(function () {
                if (_this.slides) {
                    _this.slides.slideTo(index, 500);
                }
            }, 500);
        }
        catch (e) {
            this.logger.trace(e);
        }
    };
    NspScannerLanding.prototype.slideToPrev = function () {
        var _this = this;
        try {
            setTimeout(function () {
                if (_this.slides) {
                    _this.slides.slidePrev(500);
                }
            }, 500);
        }
        catch (e) {
            this.logger.trace(e);
        }
    };
    NspScannerLanding.prototype.isLineAvailable = function (tag) {
        return tag && tag['info']['line'] && tag['info']['line'] !== '';
    };
    NspScannerLanding.prototype.validateThenAddLine = function (tag) {
        var subject = this.getSelectedSubject();
        if (subject !== null && subject.dis_name !== tag['info']['line']) {
            this.workingSubjects = [];
            this.activeId = tag ? tag['tag_id'] : '';
            this.setCurrentSubjectToLatestTag(this.activeId);
            // this.addLineToCurrentAddedLines(tag['info']['line'], tag['info']['receiver_subject']);
        }
        else {
            this.activeId = tag ? tag['tag_id'] : '';
            this.setCurrentSubjectToLatestTag(this.activeId);
        }
    };
    NspScannerLanding.prototype.addLineToCurrentAddedLines = function (line, subject) {
        var index = this.workingSubjects.findIndex(function (cl) { return cl.name === line; });
        if (index < 0) {
            //  this.curentStationLines = [];
            this.resetSelectedLines();
            this.curentStationLines.push({ 'name': line, 'isChecked': true, subject: subject });
        }
        this.updateSubjectsDetailsInCache();
    };
    NspScannerLanding.prototype.resetSelectedLines = function () {
        this.curentStationLines.forEach(function (cs) {
            cs['isChecked'] = false;
        });
        this.updateSubjectsDetailsInCache();
    };
    NspScannerLanding.prototype.manualTagId = function () {
        var _this = this;
        if (!this.isSubjectSelected() && this.appState && this.missingDetails) {
            this.presentLineAlert();
        }
        else {
            var alert_1 = this.alertCtrl.create({
                title: 'Enter Tag Id',
                inputs: [
                    {
                        name: 'tag_id',
                        placeholder: 'Tag Id',
                        type: 'Text'
                    }
                ],
                buttons: [
                    {
                        text: 'Cancel',
                        role: 'cancel',
                    },
                    {
                        text: 'Ok',
                        handler: function (data) {
                            var tagId = data['tag_id'];
                            _this.scanningService.searchTag('manual', tagId);
                        }
                    }
                ],
                'cssClass': 'tr-tag-alert'
            });
            alert_1.present();
            this.subscribeToTagUpdate();
        }
    };
    NspScannerLanding.prototype.slideonChange = function () {
        try {
            var currentIndex = this.slides.getActiveIndex();
            // this.setBundleQty(currentIndex);
            this.slideindex = currentIndex;
            this.slides.slideTo(currentIndex, 500);
            if (this.tagGroupView.length > currentIndex) {
                this.setQRdata(currentIndex);
                var tagInfo = this.tagGroupView[currentIndex].info;
                this.selectSubject(tagInfo['receiver_subject']);
            }
        }
        catch (e) {
            this.logger.error(e);
        }
    };
    NspScannerLanding.prototype.removeTagGroup = function (param) {
        var _this = this;
        if (param === 0) {
            var alert_2 = this.alertCtrl.create({
                title: 'Delete Confirmation',
                message: 'Confirm Delete all Tags',
                cssClass: '',
                buttons: [
                    {
                        text: 'Confirm',
                        role: 'ok',
                        handler: function () {
                            _this.tagGroups = void 0;
                            _this.tagGroupView = [];
                            _this.NumberOftags = 0;
                            _this.tagProvider.removeTagGroup();
                            console.log('confirm clicked');
                        }
                    },
                    {
                        text: 'Cancel',
                        role: 'cancel',
                    }
                ]
            });
            alert_2.present();
        }
        else if (param === 1) {
            this.tagGroups = void 0;
            this.tagGroupView = [];
            this.NumberOftags = 0;
            this.tagProvider.removeTagGroup();
        }
    };
    NspScannerLanding.prototype.removeTag = function () {
        var _this = this;
        this.logger.trace('------------->', this.tagGroupView);
        var alert = this.alertCtrl.create({
            title: 'Delete Confirmation',
            message: 'Confirm Delete Selected Tag',
            cssClass: '',
            buttons: [
                {
                    text: 'Confirm',
                    role: 'ok',
                    handler: function () {
                        if (_this.tagGroupView && _this.tagGroupView.length > _this.slideindex) {
                            var id_1 = _this.tagGroupView[_this.slides.getActiveIndex()]['tag_id'];
                            var tempView = _this.tagGroupView;
                            var index = tempView.findIndex(function (t) { return t.tag_id === id_1; });
                            if (index > -1) {
                                _this.tagGroupView.splice(index, 1);
                                var len = _this.tagGroupView.length;
                                _this.NumberOftags = len;
                                if (len === 0) {
                                    _this.tagGroupView = [];
                                }
                            }
                            _this.tagGroups.removeTag(id_1);
                            _this.tagProvider.removeTag(id_1);
                            // this.NumberOftags = 0;
                            _this.logger.trace(':::::::::::', _this.tagGroupView);
                            // this.slideToLatest(-1);
                            _this.slideToPrev();
                        }
                    }
                },
                {
                    text: 'Cancel',
                    role: 'cancel',
                }
            ]
        });
        alert.present();
    };
    NspScannerLanding.prototype.confirm = function () {
        if (this.validateSubjects()) {
            this.tagProvider.confirmTagGroup();
            this.removeTagGroup(1);
            this.NumberOftags = 0;
            if (!this.startLoad) {
                this.deselectAllSubject();
                this.updateSubjectsDetailsInCache();
            }
            this.isSubjectValidated = false;
        }
    };
    NspScannerLanding.prototype.validateSubjects = function () {
        var result = true;
        var subjects = [];
        if (this.tagGroups) {
            this.tagGroups.tags.forEach(function (tag) {
                if (tag.info && tag.info.receiver_subject) {
                    var resSub_1 = tag.info.receiver_subject;
                    var index = subjects.findIndex(function (sub) { return sub.subject === resSub_1.subject; });
                    if (index === -1) {
                        subjects.push(resSub_1);
                    }
                }
            });
        }
        if (subjects.length >= 1 && !this.isSubjectValidated && this.subjectConfirmation) {
            this.confirmTrigger = true;
            result = false;
            //  mutiple lines
            this.presentLineConfirmModal();
        }
        else if (subjects.length < 1) {
            // no line seleted
            result = false;
            this.presentLineAlert();
            this.confirmTrigger = true;
        }
        else if (this.isSubjectValidated || !this.subjectConfirmation) {
            this.confirmTrigger = false;
            result = true;
        }
        /* else if (subjects.length === 1) {
            this.confirmTrigger = false;
            result = true;

        } else {
            this.confirmTrigger = false;
            result = true;

        }*/
        return result;
    };
    NspScannerLanding.prototype.floatingMenuHandler = function (config) {
        try {
            switch (config.type) {
                case 'page': {
                    this.navManager.nextView(config.next_view_ref, {});
                    break;
                }
                case 'paired_modal': {
                    this.scanningService.openBluetoothSettings();
                    break;
                }
            }
        }
        catch (e) {
            this.logger.error('Action not found ');
        }
    };
    NspScannerLanding.prototype.scanDummy = function ($event) {
        this.scanningService.dummyScanner($event);
        this.subscribeToTagUpdate();
    };
    NspScannerLanding.prototype.ngOnDestroy = function () {
        var _this = this;
        try {
            this.subscribers.forEach(function (val) {
                if (val) {
                    _this.appStateService.unsubscribeMe(val);
                }
            });
        }
        catch (e) {
            this.logger.debug(e);
        }
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewChild"])(__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["u" /* Slides */]),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["u" /* Slides */])
    ], NspScannerLanding.prototype, "slides", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewChild"])('slider'),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["u" /* Slides */])
    ], NspScannerLanding.prototype, "slider", void 0);
    NspScannerLanding = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["i" /* IonicPage */])(),
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'nsp-scanner-landing',
            template: __WEBPACK_IMPORTED_MODULE_3__nsp_scanner_landing_html__["a" /* NSP_SCANNER_LANDING */]
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_ngx_logger__["b" /* NGXLogger */],
            __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["p" /* NavParams */],
            __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["a" /* AlertController */],
            __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["m" /* ModalController */],
            __WEBPACK_IMPORTED_MODULE_4__providers_data_provider__["a" /* DataProvider */],
            __WEBPACK_IMPORTED_MODULE_7__providers_tagGroup_provider__["a" /* TagGroupProvider */],
            __WEBPACK_IMPORTED_MODULE_8__providers_nsp_scanner_provider__["a" /* NspScanningProvider */],
            __WEBPACK_IMPORTED_MODULE_9__ncinga_sp_nsp_app_core_dist__["m" /* NavigationManager */],
            __WEBPACK_IMPORTED_MODULE_10__providers_base_scanner_transaction_provider__["a" /* BaseScanningTransactionService */],
            __WEBPACK_IMPORTED_MODULE_9__ncinga_sp_nsp_app_core_dist__["c" /* AppMasterProvider */],
            __WEBPACK_IMPORTED_MODULE_11__providers_nsp_cmaster_data_service__["a" /* CMatserDataService */],
            __WEBPACK_IMPORTED_MODULE_12__providers_event_provider__["a" /* EventManage */],
            __WEBPACK_IMPORTED_MODULE_9__ncinga_sp_nsp_app_core_dist__["e" /* ApplicationService */],
            __WEBPACK_IMPORTED_MODULE_9__ncinga_sp_nsp_app_core_dist__["d" /* ApplicationContext */]])
    ], NspScannerLanding);
    return NspScannerLanding;
}());

//# sourceMappingURL=nsp-scanner-landing.js.map

/***/ }),

/***/ 1818:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NSP_SCANNER_LANDING; });
/**
 * Created by nisitha on 2/28/19.
 */
var NSP_SCANNER_LANDING = "<ion-header>\n    <common-main-header [title]=\"title\" [tools]=\"tools\"\n    [header_disabled]=\"subjectDis\"\n  [shift_disabled]=\"false\">\n    </common-main-header>\n</ion-header>\n<ion-content>\n    <ion-grid class=\"pg-cnt-grid\">\n        <div class=\"app-type\" *ngIf=\"config && config['subtitle_view']\">\n            <div><img [src]=\"'assets/imgs/'+ imgPath +'.png'\"></div>\n            <div>{{moduleTitle}}</div>\n        </div>\n        <ion-row *ngIf=\"config && config['test']\">\n            <button ion-button (click)=\"scanDummy(false)\">send-dup</button>\n            <button ion-button (click)=\"scanDummy(true)\">send-unique</button>\n            <ion-input type=\"text\" [(ngModel)]=\"testId\"></ion-input>\n            <button ion-button (click)=\"sendUniqueWithId(true)\">send-unique-with-id</button>\n                <ion-label>Tag Id Prefix</ion-label>                                \n            <ion-input type=\"number\" [(ngModel)]=\"startCount\"></ion-input>\n            <ion-label>Time Interval</ion-label>                                \n            <ion-input type=\"number\" [(ngModel)]=\"timeInterval\"></ion-input>\n            <button ion-button class=\"load-test\" (click)=\"startLoadTest()\">DO NOT PRESS: Start Load test</button></ion-row>\n        <ion-row class=\"scan-info-horizontal\" *ngIf=\"horizontalView\">\n       <div class=\"scan-info-row-horizontal tol-scan v-center\">\n                            <div class=\"flx-1 tot-scan-lbl\">Total Scanned</div>\n                            <div class=\"vlue\">{{NumberOftags}}</div>\n                </div>\n                <div class=\"flx-1\"></div>\n                <div class=\"scan-btm-row-horizontal\"><button class=\"sc-blue-btn\" ion-button (click)=\"manualTagId()\">Enter Id</button></div>\n                    <div class=\"scan-btm-row-horizontal\">\n                    <button class=\"sc-grn-btn\" ion-button (click)=\"startScan()\">\n                        <ion-icon name=\"qr-scanner\"></ion-icon>\n                        Scan\n                    </button></div>\n        </ion-row>\n        <ion-row class=\"pg-cnt-row\">\n            <ion-col col-2 class=\"li-slct\" *ngIf=\"missingDetails\">\n                <div class=\"sec-hdr\">\n                    <div class=\"lbl flx-1\">Select Sewing Line</div>\n                    <button ion-button class=\"add-line-btn\" (click)=\"openSubjectSettingsModal()\">\n                        <ion-icon name=\"build\"></ion-icon>\n                    </button>\n                </div>\n                <div class=\"lin-radio-btn-lst\">\n                    <ion-list radio-group>\n                        <ion-item *ngFor=\"let subject of workingSubjects  let i=index;\">\n                            <ion-label>{{subject.name}}</ion-label>\n                            <ion-radio [value]=subject.name (ionSelect)=\"selectSubject(subject.subject, true, true)\"\n                            [checked]=\"subject.isSelected\"></ion-radio>\n                        </ion-item>\n                    </ion-list>\n                </div>\n            </ion-col>\n            <ion-col col-7 class=\"sca-tg-view\"  *ngIf=\"slideView && tagGroupView && (tagGroupView.length > 0) &&  NumberOftags > 0\">\n                <div class=\"sec-hdr\">\n                    <div class=\"lbl flx1\">Scanned Tag Preview</div>\n                </div>\n                <div class=\"slide-wrap\">\n                    <ion-slides pager (ionSlideDidChange)=\"slideonChange()\">\n                        <ion-slide\n                                   *ngFor=\"let tag of tagGroupView; let i = index\">\n                            <ion-grid class=\"scaned-tag-preview\">\n                                <div id=bundleItemTag class=\"bundleTag\">\n                                    <table class=\"tBundleItemTag tag-table\">\n                                        <tr>\n                                            <td class=\"tag-td buyer-cell\"> Buyer\n                                                <div class=\"ft8 factory\">\n                                                    <pre>{{tag.info.buyer}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td style-cell\"> Style\n                                                <div class=\"ft8 style\">\n                                                    <pre>{{tag.info.style}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                    </table>\n                                    <table class=\"tBundleItemTag tag-table\">\n                                        <tr>\n                                            <td class=\"tag-td qr-cell\" rowspan=\"3\">\n                                                <div class=\"main\"><img class=\"qrImg1\" [src]=\"tagString\">\n                                                    <div class=\"qr\">\n                                                        <div class=\"vertical tagId\">{{tag.tag_id}}</div>\n                                                    </div>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td qty-cell\"> QTY\n                                                <div class=\"ft40 color no-margin\">\n                                                    <pre>{{tag.info.qty}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                        <tr>\n                                            <td class=\"tag-td sche-cell\" *ngIf=\"!config.tag_name_change\"> Schedule#\n                                                <div class=\"ft8 color no-margin\">\n                                                    <pre>{{tag.info.schedule}}</pre>\n                                                </div>\n                                            </td>\n                                             <td class=\"tag-td sche-cell\" *ngIf=\"config.tag_name_change\"> Unit No#\n                                                <div class=\"ft8 color no-margin\">\n                                                    <pre>{{tag.info.unit}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                        <tr>\n                                            <td class=\"tag-td sche-cell\"> Color\n                                                <div class=\"ft8 color no-margin\">\n                                                    <pre>{{tag.info.color}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                    </table>\n                                    <table class=\"t1A tag-table\">\n                                        <tr>\n                                            <td class=\"tag-td cpo-cell\" *ngIf=\"!config['tag_name_change']\"> CPO #\n                                                <div class=\"ft8 gno\">\n                                                    <pre>{{tag.info.po}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\"*ngIf=\"config['tag_name_change']\" > PO #\n                                                <div class=\"ft8 gno\">\n                                                    <pre>{{tag.info.po}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\" *ngIf=\"!config['tag_name_change']\"> Order ref#\n                                                <div class=\"ft8 box\">\n                                                    <pre>{{tag.info.order_ref}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\" *ngIf=\"config['tag_name_change']\"> OCS#\n                                                <div class=\"ft8 box\">\n                                                    <pre>{{tag.info.order_ref}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cut-cell\"> Cut#\n                                                <div class=\"ft11 range\">\n                                                    <pre>{{tag.info.cut}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                        <tr>\n                                            <td class=\"tag-td cpo-cell\"> Shade\n                                                <div class=\"ft8 gno\">\n                                                    <pre>{{tag.info.shade}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\"> Size\n                                                <div class=\"ft8 box\">\n                                                    <pre>{{tag.info.size}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cut-cell\" rowspan=\"2\"> Sticker Range\n                                                <div class=\"ft16 range\">\n                                                    <pre>{{tag.info.sticker_range}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                        <tr>\n                                            <td class=\"tag-td cpo-cell\"> Item\n                                                <div class=\"ft8 gno\">\n                                                    <pre>{{tag.info.product_type}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\" *ngIf=\"!config['tag_name_change']\"> Bundle#\n                                                <div class=\"ft8 box\">\n                                                    <pre>{{tag.info.bundle}}</pre>\n                                                </div>\n                                            </td>\n                                            <td class=\"tag-td cpo-cell\" *ngIf=\"config['tag_name_change']\"> Bundle#\n                                                <div class=\"ft8 box\">\n                                                    <pre>{{tag.info.bundle_no}}</pre>\n                                                </div>\n                                            </td>\n                                        </tr>\n                                    </table>\n                                </div>\n                            </ion-grid>\n                        </ion-slide>\n                    </ion-slides>\n                </div>\n                <div class=\"tag-cncel-btn\">\n                    <div class=\"flx-1\"></div>\n                    <button ion-button class=\"cancel-all\" (click)=\"removeTagGroup(0)\">Remove All Tags</button>\n                    <button ion-button class=\"cancel-one\" (click)=\" removeTag()\">Remove Selected Tag</button>\n                    <div class=\"flx-1\"></div>\n                </div>\n            </ion-col>\n            <ion-col class=\"emt-mesg\" *ngIf=\"NumberOftags === 0\">\n                <div>\n                    {{config && config['landing_massage']}}\n                </div>\n            </ion-col>\n                                 <ion-col class=\"tbl-class\" *ngIf=\"config && config['table'] && NumberOftags > 0\">\n  <generic-table  #myTable  [gtSettings]=\"configObject.settings\" [gtFields]=\"configObject.fields\"\n  [gtData]=\"configObject.data\"></generic-table>\n   <ion-row>\n   <div style=\"flex: 1\"></div>\n    <button ion-button class=\"cancel-one\" (click)=\"tableDataClear()\"> Clear All</button>\n     <button ion-button (click)=\"addNewDetail()\"> Done</button>\n  </ion-row>\n    </ion-col>\n            <ion-col col-3 class=\"scan-info\" *ngIf=\"verticalView\">\n                <ion-row class=\"scan-btm-row\">\n                    <button class=\"sc-blue-btn\" ion-button (click)=\"manualTagId()\">Enter Id</button>\n                    <button class=\"sc-grn-btn\" ion-button (click)=\"startScan()\">\n                        <ion-icon name=\"qr-scanner\"></ion-icon>\n                        Scan\n                    </button>\n                </ion-row>\n                <ion-row class=\"scan-info-row\">\n                    <ion-col col-12 no-padding>\n                        <ion-row class=\"tol-scan v-center\">\n                            <div class=\"flx-1\">Total Scanned</div>\n                            <div class=\"vlue\">{{NumberOftags}}</div>\n                        </ion-row>\n                    </ion-col>\n                </ion-row>\n                <ion-row>\n                    <button ion-button class=\"black-btn\" (click)=\"confirm()\"\n                    [disabled]=\"NumberOftags === 0\">Done</button>\n                </ion-row>\n            </ion-col>\n        </ion-row>\n    </ion-grid>\n  <ion-fab left bottom class=\"flting-btn-main\">\n    <button ion-fab color=\"dark\">\n        <ion-icon name=\"arrow-dropright\"></ion-icon>\n    </button>\n    <ion-fab-list side=\"right\">\n        <button class=\"sub-btn\" color=\"dark\" ion-fab *ngFor=\"let item of config?.floating_menu\" [title]=\"item.name\"\n                (click)=\"floatingMenuHandler(item)\">\n            <ion-icon [name]=\"item.icon\"></ion-icon>\n        </button>\n    </ion-fab-list>\n</ion-fab>\n</ion-content>";
//# sourceMappingURL=nsp-scanner-landing-html.js.map

/***/ }),

/***/ 1819:
/***/ (function(module, exports, __webpack_require__) {

/*
 * QRious v4.0.2
 * Copyright (C) 2017 Alasdair Mercer
 * Copyright (C) 2010 Tom Zerucha
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
(function (global, factory) {
   true ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global.QRious = factory());
}(this, (function () { 'use strict';

  /*
   * Copyright (C) 2017 Alasdair Mercer, !ninja
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in all
   * copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   * SOFTWARE.
   */

  /**
   * A bare-bones constructor for surrogate prototype swapping.
   *
   * @private
   * @constructor
   */
  var Constructor = /* istanbul ignore next */ function() {};
  /**
   * A reference to <code>Object.prototype.hasOwnProperty</code>.
   *
   * @private
   * @type {Function}
   */
  var hasOwnProperty = Object.prototype.hasOwnProperty;
  /**
   * A reference to <code>Array.prototype.slice</code>.
   *
   * @private
   * @type {Function}
   */
  var slice = Array.prototype.slice;

  /**
   * Creates an object which inherits the given <code>prototype</code>.
   *
   * Optionally, the created object can be extended further with the specified <code>properties</code>.
   *
   * @param {Object} prototype - the prototype to be inherited by the created object
   * @param {Object} [properties] - the optional properties to be extended by the created object
   * @return {Object} The newly created object.
   * @private
   */
  function createObject(prototype, properties) {
    var result;
    /* istanbul ignore next */
    if (typeof Object.create === 'function') {
      result = Object.create(prototype);
    } else {
      Constructor.prototype = prototype;
      result = new Constructor();
      Constructor.prototype = null;
    }

    if (properties) {
      extendObject(true, result, properties);
    }

    return result;
  }

  /**
   * Extends the constructor to which this method is associated with the <code>prototype</code> and/or
   * <code>statics</code> provided.
   *
   * If <code>name</code> is provided, it will be used as the class name and can be accessed via a special
   * <code>class_</code> property on the child constructor, otherwise the class name of the super constructor will be used
   * instead. The class name may also be used string representation for instances of the child constructor (via
   * <code>toString</code>), but this is not applicable to the <i>lite</i> version of Nevis.
   *
   * If <code>constructor</code> is provided, it will be used as the constructor for the child, otherwise a simple
   * constructor which only calls the super constructor will be used instead.
   *
   * The super constructor can be accessed via a special <code>super_</code> property on the child constructor.
   *
   * @param {string} [name=this.class_] - the class name to be used for the child constructor
   * @param {Function} [constructor] - the constructor for the child
   * @param {Object} [prototype] - the prototype properties to be defined for the child
   * @param {Object} [statics] - the static properties to be defined for the child
   * @return {Function} The child <code>constructor</code> provided or the one created if none was given.
   * @public
   */
  function extend(name, constructor, prototype, statics) {
    var superConstructor = this;

    if (typeof name !== 'string') {
      statics = prototype;
      prototype = constructor;
      constructor = name;
      name = null;
    }

    if (typeof constructor !== 'function') {
      statics = prototype;
      prototype = constructor;
      constructor = function() {
        return superConstructor.apply(this, arguments);
      };
    }

    extendObject(false, constructor, superConstructor, statics);

    constructor.prototype = createObject(superConstructor.prototype, prototype);
    constructor.prototype.constructor = constructor;

    constructor.class_ = name || superConstructor.class_;
    constructor.super_ = superConstructor;

    return constructor;
  }

  /**
   * Extends the specified <code>target</code> object with the properties in each of the <code>sources</code> provided.
   *
   * if any source is <code>null</code> it will be ignored.
   *
   * @param {boolean} own - <code>true</code> to only copy <b>own</b> properties from <code>sources</code> onto
   * <code>target</code>; otherwise <code>false</code>
   * @param {Object} target - the target object which should be extended
   * @param {...Object} [sources] - the source objects whose properties are to be copied onto <code>target</code>
   * @return {void}
   * @private
   */
  function extendObject(own, target, sources) {
    sources = slice.call(arguments, 2);

    var property;
    var source;

    for (var i = 0, length = sources.length; i < length; i++) {
      source = sources[i];

      for (property in source) {
        if (!own || hasOwnProperty.call(source, property)) {
          target[property] = source[property];
        }
      }
    }
  }

  var extend_1 = extend;

  /**
   * The base class from which all others should extend.
   *
   * @public
   * @constructor
   */
  function Nevis() {}
  Nevis.class_ = 'Nevis';
  Nevis.super_ = Object;

  /**
   * Extends the constructor to which this method is associated with the <code>prototype</code> and/or
   * <code>statics</code> provided.
   *
   * If <code>name</code> is provided, it will be used as the class name and can be accessed via a special
   * <code>class_</code> property on the child constructor, otherwise the class name of the super constructor will be used
   * instead. The class name may also be used string representation for instances of the child constructor (via
   * <code>toString</code>), but this is not applicable to the <i>lite</i> version of Nevis.
   *
   * If <code>constructor</code> is provided, it will be used as the constructor for the child, otherwise a simple
   * constructor which only calls the super constructor will be used instead.
   *
   * The super constructor can be accessed via a special <code>super_</code> property on the child constructor.
   *
   * @param {string} [name=this.class_] - the class name to be used for the child constructor
   * @param {Function} [constructor] - the constructor for the child
   * @param {Object} [prototype] - the prototype properties to be defined for the child
   * @param {Object} [statics] - the static properties to be defined for the child
   * @return {Function} The child <code>constructor</code> provided or the one created if none was given.
   * @public
   * @static
   * @memberof Nevis
   */
  Nevis.extend = extend_1;

  var nevis = Nevis;

  var lite = nevis;

  /**
   * Responsible for rendering a QR code {@link Frame} on a specific type of element.
   *
   * A renderer may be dependant on the rendering of another element, so the ordering of their execution is important.
   *
   * The rendering of a element can be deferred by disabling the renderer initially, however, any attempt get the element
   * from the renderer will result in it being immediately enabled and the element being rendered.
   *
   * @param {QRious} qrious - the {@link QRious} instance to be used
   * @param {*} element - the element onto which the QR code is to be rendered
   * @param {boolean} [enabled] - <code>true</code> this {@link Renderer} is enabled; otherwise <code>false</code>.
   * @public
   * @class
   * @extends Nevis
   */
  var Renderer = lite.extend(function(qrious, element, enabled) {
    /**
     * The {@link QRious} instance.
     *
     * @protected
     * @type {QRious}
     * @memberof Renderer#
     */
    this.qrious = qrious;

    /**
     * The element onto which this {@link Renderer} is rendering the QR code.
     *
     * @protected
     * @type {*}
     * @memberof Renderer#
     */
    this.element = element;
    this.element.qrious = qrious;

    /**
     * Whether this {@link Renderer} is enabled.
     *
     * @protected
     * @type {boolean}
     * @memberof Renderer#
     */
    this.enabled = Boolean(enabled);
  }, {

    /**
     * Draws the specified QR code <code>frame</code> on the underlying element.
     *
     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
     *
     * @param {Frame} frame - the {@link Frame} to be drawn
     * @return {void}
     * @protected
     * @abstract
     * @memberof Renderer#
     */
    draw: function(frame) {},

    /**
     * Returns the element onto which this {@link Renderer} is rendering the QR code.
     *
     * If this method is called while this {@link Renderer} is disabled, it will be immediately enabled and rendered
     * before the element is returned.
     *
     * @return {*} The element.
     * @public
     * @memberof Renderer#
     */
    getElement: function() {
      if (!this.enabled) {
        this.enabled = true;
        this.render();
      }

      return this.element;
    },

    /**
     * Calculates the size (in pixel units) to represent an individual module within the QR code based on the
     * <code>frame</code> provided.
     *
     * Any configured padding will be excluded from the returned size.
     *
     * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.
     * This is done so that the inevitable clipping is handled more gracefully since this way at least something is
     * displayed instead of just a blank space filled by the background color.
     *
     * @param {Frame} frame - the {@link Frame} from which the module size is to be derived
     * @return {number} The pixel size for each module in the QR code which will be no less than one.
     * @protected
     * @memberof Renderer#
     */
    getModuleSize: function(frame) {
      var qrious = this.qrious;
      var padding = qrious.padding || 0;
      var pixels = Math.floor((qrious.size - (padding * 2)) / frame.width);

      return Math.max(1, pixels);
    },

    /**
     * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the <code>frame</code>
     * provided.
     *
     * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its
     * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally
     * and it is not clipped from all directions.
     *
     * @param {Frame} frame - the {@link Frame} from which the offset is to be derived
     * @return {number} The pixel offset for the QR code which will be no less than zero.
     * @protected
     * @memberof Renderer#
     */
    getOffset: function(frame) {
      var qrious = this.qrious;
      var padding = qrious.padding;

      if (padding != null) {
        return padding;
      }

      var moduleSize = this.getModuleSize(frame);
      var offset = Math.floor((qrious.size - (moduleSize * frame.width)) / 2);

      return Math.max(0, offset);
    },

    /**
     * Renders a QR code on the underlying element based on the <code>frame</code> provided.
     *
     * @param {Frame} frame - the {@link Frame} to be rendered
     * @return {void}
     * @public
     * @memberof Renderer#
     */
    render: function(frame) {
      if (this.enabled) {
        this.resize();
        this.reset();
        this.draw(frame);
      }
    },

    /**
     * Resets the underlying element, effectively clearing any previously rendered QR code.
     *
     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
     *
     * @return {void}
     * @protected
     * @abstract
     * @memberof Renderer#
     */
    reset: function() {},

    /**
     * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.
     *
     * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
     *
     * @return {void}
     * @protected
     * @abstract
     * @memberof Renderer#
     */
    resize: function() {}

  });

  var Renderer_1 = Renderer;

  /**
   * An implementation of {@link Renderer} for working with <code>canvas</code> elements.
   *
   * @public
   * @class
   * @extends Renderer
   */
  var CanvasRenderer = Renderer_1.extend({

    /**
     * @override
     */
    draw: function(frame) {
      var i, j;
      var qrious = this.qrious;
      var moduleSize = this.getModuleSize(frame);
      var offset = this.getOffset(frame);
      var context = this.element.getContext('2d');

      context.fillStyle = qrious.foreground;
      context.globalAlpha = qrious.foregroundAlpha;

      for (i = 0; i < frame.width; i++) {
        for (j = 0; j < frame.width; j++) {
          if (frame.buffer[(j * frame.width) + i]) {
            context.fillRect((moduleSize * i) + offset, (moduleSize * j) + offset, moduleSize, moduleSize);
          }
        }
      }
    },

    /**
     * @override
     */
    reset: function() {
      var qrious = this.qrious;
      var context = this.element.getContext('2d');
      var size = qrious.size;

      context.lineWidth = 1;
      context.clearRect(0, 0, size, size);
      context.fillStyle = qrious.background;
      context.globalAlpha = qrious.backgroundAlpha;
      context.fillRect(0, 0, size, size);
    },

    /**
     * @override
     */
    resize: function() {
      var element = this.element;

      element.width = element.height = this.qrious.size;
    }

  });

  var CanvasRenderer_1 = CanvasRenderer;

  /* eslint no-multi-spaces: "off" */



  /**
   * Contains alignment pattern information.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var Alignment = lite.extend(null, {

    /**
     * The alignment pattern block.
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof Alignment
     */
    BLOCK: [
      0,  11, 15, 19, 23, 27, 31,
      16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
      26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28
    ]

  });

  var Alignment_1 = Alignment;

  /* eslint no-multi-spaces: "off" */



  /**
   * Contains error correction information.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var ErrorCorrection = lite.extend(null, {

    /**
     * The error correction blocks.
     *
     * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally
     * the ECC width.
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof ErrorCorrection
     */
    BLOCKS: [
      1,  0,  19,  7,     1,  0,  16,  10,    1,  0,  13,  13,    1,  0,  9,   17,
      1,  0,  34,  10,    1,  0,  28,  16,    1,  0,  22,  22,    1,  0,  16,  28,
      1,  0,  55,  15,    1,  0,  44,  26,    2,  0,  17,  18,    2,  0,  13,  22,
      1,  0,  80,  20,    2,  0,  32,  18,    2,  0,  24,  26,    4,  0,  9,   16,
      1,  0,  108, 26,    2,  0,  43,  24,    2,  2,  15,  18,    2,  2,  11,  22,
      2,  0,  68,  18,    4,  0,  27,  16,    4,  0,  19,  24,    4,  0,  15,  28,
      2,  0,  78,  20,    4,  0,  31,  18,    2,  4,  14,  18,    4,  1,  13,  26,
      2,  0,  97,  24,    2,  2,  38,  22,    4,  2,  18,  22,    4,  2,  14,  26,
      2,  0,  116, 30,    3,  2,  36,  22,    4,  4,  16,  20,    4,  4,  12,  24,
      2,  2,  68,  18,    4,  1,  43,  26,    6,  2,  19,  24,    6,  2,  15,  28,
      4,  0,  81,  20,    1,  4,  50,  30,    4,  4,  22,  28,    3,  8,  12,  24,
      2,  2,  92,  24,    6,  2,  36,  22,    4,  6,  20,  26,    7,  4,  14,  28,
      4,  0,  107, 26,    8,  1,  37,  22,    8,  4,  20,  24,    12, 4,  11,  22,
      3,  1,  115, 30,    4,  5,  40,  24,    11, 5,  16,  20,    11, 5,  12,  24,
      5,  1,  87,  22,    5,  5,  41,  24,    5,  7,  24,  30,    11, 7,  12,  24,
      5,  1,  98,  24,    7,  3,  45,  28,    15, 2,  19,  24,    3,  13, 15,  30,
      1,  5,  107, 28,    10, 1,  46,  28,    1,  15, 22,  28,    2,  17, 14,  28,
      5,  1,  120, 30,    9,  4,  43,  26,    17, 1,  22,  28,    2,  19, 14,  28,
      3,  4,  113, 28,    3,  11, 44,  26,    17, 4,  21,  26,    9,  16, 13,  26,
      3,  5,  107, 28,    3,  13, 41,  26,    15, 5,  24,  30,    15, 10, 15,  28,
      4,  4,  116, 28,    17, 0,  42,  26,    17, 6,  22,  28,    19, 6,  16,  30,
      2,  7,  111, 28,    17, 0,  46,  28,    7,  16, 24,  30,    34, 0,  13,  24,
      4,  5,  121, 30,    4,  14, 47,  28,    11, 14, 24,  30,    16, 14, 15,  30,
      6,  4,  117, 30,    6,  14, 45,  28,    11, 16, 24,  30,    30, 2,  16,  30,
      8,  4,  106, 26,    8,  13, 47,  28,    7,  22, 24,  30,    22, 13, 15,  30,
      10, 2,  114, 28,    19, 4,  46,  28,    28, 6,  22,  28,    33, 4,  16,  30,
      8,  4,  122, 30,    22, 3,  45,  28,    8,  26, 23,  30,    12, 28, 15,  30,
      3,  10, 117, 30,    3,  23, 45,  28,    4,  31, 24,  30,    11, 31, 15,  30,
      7,  7,  116, 30,    21, 7,  45,  28,    1,  37, 23,  30,    19, 26, 15,  30,
      5,  10, 115, 30,    19, 10, 47,  28,    15, 25, 24,  30,    23, 25, 15,  30,
      13, 3,  115, 30,    2,  29, 46,  28,    42, 1,  24,  30,    23, 28, 15,  30,
      17, 0,  115, 30,    10, 23, 46,  28,    10, 35, 24,  30,    19, 35, 15,  30,
      17, 1,  115, 30,    14, 21, 46,  28,    29, 19, 24,  30,    11, 46, 15,  30,
      13, 6,  115, 30,    14, 23, 46,  28,    44, 7,  24,  30,    59, 1,  16,  30,
      12, 7,  121, 30,    12, 26, 47,  28,    39, 14, 24,  30,    22, 41, 15,  30,
      6,  14, 121, 30,    6,  34, 47,  28,    46, 10, 24,  30,    2,  64, 15,  30,
      17, 4,  122, 30,    29, 14, 46,  28,    49, 10, 24,  30,    24, 46, 15,  30,
      4,  18, 122, 30,    13, 32, 46,  28,    48, 14, 24,  30,    42, 32, 15,  30,
      20, 4,  117, 30,    40, 7,  47,  28,    43, 22, 24,  30,    10, 67, 15,  30,
      19, 6,  118, 30,    18, 31, 47,  28,    34, 34, 24,  30,    20, 61, 15,  30
    ],

    /**
     * The final format bits with mask (level << 3 | mask).
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof ErrorCorrection
     */
    FINAL_FORMAT: [
      // L
      0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976,
      // M
      0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0,
      // Q
      0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed,
      // H
      0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b
    ],

    /**
     * A map of human-readable ECC levels.
     *
     * @public
     * @static
     * @type {Object.<string, number>}
     * @memberof ErrorCorrection
     */
    LEVELS: {
      L: 1,
      M: 2,
      Q: 3,
      H: 4
    }

  });

  var ErrorCorrection_1 = ErrorCorrection;

  /**
   * Contains Galois field information.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var Galois = lite.extend(null, {

    /**
     * The Galois field exponent table.
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof Galois
     */
    EXPONENT: [
      0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
      0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,
      0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,
      0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,
      0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,
      0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,
      0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,
      0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,
      0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,
      0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,
      0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,
      0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,
      0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,
      0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,
      0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,
      0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00
    ],

    /**
     * The Galois field log table.
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof Galois
     */
    LOG: [
      0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,
      0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,
      0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,
      0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,
      0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,
      0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,
      0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,
      0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,
      0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,
      0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,
      0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,
      0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,
      0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,
      0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,
      0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,
      0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
    ]

  });

  var Galois_1 = Galois;

  /**
   * Contains version pattern information.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var Version = lite.extend(null, {

    /**
     * The version pattern block.
     *
     * @public
     * @static
     * @type {number[]}
     * @memberof Version
     */
    BLOCK: [
      0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,
      0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,
      0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69
    ]

  });

  var Version_1 = Version;

  /**
   * Generates information for a QR code frame based on a specific value to be encoded.
   *
   * @param {Frame~Options} options - the options to be used
   * @public
   * @class
   * @extends Nevis
   */
  var Frame = lite.extend(function(options) {
    var dataBlock, eccBlock, index, neccBlock1, neccBlock2;
    var valueLength = options.value.length;

    this._badness = [];
    this._level = ErrorCorrection_1.LEVELS[options.level];
    this._polynomial = [];
    this._value = options.value;
    this._version = 0;
    this._stringBuffer = [];

    while (this._version < 40) {
      this._version++;

      index = ((this._level - 1) * 4) + ((this._version - 1) * 16);

      neccBlock1 = ErrorCorrection_1.BLOCKS[index++];
      neccBlock2 = ErrorCorrection_1.BLOCKS[index++];
      dataBlock = ErrorCorrection_1.BLOCKS[index++];
      eccBlock = ErrorCorrection_1.BLOCKS[index];

      index = (dataBlock * (neccBlock1 + neccBlock2)) + neccBlock2 - 3 + (this._version <= 9);

      if (valueLength <= index) {
        break;
      }
    }

    this._dataBlock = dataBlock;
    this._eccBlock = eccBlock;
    this._neccBlock1 = neccBlock1;
    this._neccBlock2 = neccBlock2;

    /**
     * The data width is based on version.
     *
     * @public
     * @type {number}
     * @memberof Frame#
     */
    // FIXME: Ensure that it fits instead of being truncated.
    var width = this.width = 17 + (4 * this._version);

    /**
     * The image buffer.
     *
     * @public
     * @type {number[]}
     * @memberof Frame#
     */
    this.buffer = Frame._createArray(width * width);

    this._ecc = Frame._createArray(dataBlock + ((dataBlock + eccBlock) * (neccBlock1 + neccBlock2)) + neccBlock2);
    this._mask = Frame._createArray(((width * (width + 1)) + 1) / 2);

    this._insertFinders();
    this._insertAlignments();

    // Insert single foreground cell.
    this.buffer[8 + (width * (width - 8))] = 1;

    this._insertTimingGap();
    this._reverseMask();
    this._insertTimingRowAndColumn();
    this._insertVersion();
    this._syncMask();
    this._convertBitStream(valueLength);
    this._calculatePolynomial();
    this._appendEccToData();
    this._interleaveBlocks();
    this._pack();
    this._finish();
  }, {

    _addAlignment: function(x, y) {
      var i;
      var buffer = this.buffer;
      var width = this.width;

      buffer[x + (width * y)] = 1;

      for (i = -2; i < 2; i++) {
        buffer[x + i + (width * (y - 2))] = 1;
        buffer[x - 2 + (width * (y + i + 1))] = 1;
        buffer[x + 2 + (width * (y + i))] = 1;
        buffer[x + i + 1 + (width * (y + 2))] = 1;
      }

      for (i = 0; i < 2; i++) {
        this._setMask(x - 1, y + i);
        this._setMask(x + 1, y - i);
        this._setMask(x - i, y - 1);
        this._setMask(x + i, y + 1);
      }
    },

    _appendData: function(data, dataLength, ecc, eccLength) {
      var bit, i, j;
      var polynomial = this._polynomial;
      var stringBuffer = this._stringBuffer;

      for (i = 0; i < eccLength; i++) {
        stringBuffer[ecc + i] = 0;
      }

      for (i = 0; i < dataLength; i++) {
        bit = Galois_1.LOG[stringBuffer[data + i] ^ stringBuffer[ecc]];

        if (bit !== 255) {
          for (j = 1; j < eccLength; j++) {
            stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^
              Galois_1.EXPONENT[Frame._modN(bit + polynomial[eccLength - j])];
          }
        } else {
          for (j = ecc; j < ecc + eccLength; j++) {
            stringBuffer[j] = stringBuffer[j + 1];
          }
        }

        stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois_1.EXPONENT[Frame._modN(bit + polynomial[0])];
      }
    },

    _appendEccToData: function() {
      var i;
      var data = 0;
      var dataBlock = this._dataBlock;
      var ecc = this._calculateMaxLength();
      var eccBlock = this._eccBlock;

      for (i = 0; i < this._neccBlock1; i++) {
        this._appendData(data, dataBlock, ecc, eccBlock);

        data += dataBlock;
        ecc += eccBlock;
      }

      for (i = 0; i < this._neccBlock2; i++) {
        this._appendData(data, dataBlock + 1, ecc, eccBlock);

        data += dataBlock + 1;
        ecc += eccBlock;
      }
    },

    _applyMask: function(mask) {
      var r3x, r3y, x, y;
      var buffer = this.buffer;
      var width = this.width;

      switch (mask) {
      case 0:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!((x + y) & 1) && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 1:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!(y & 1) && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 2:
        for (y = 0; y < width; y++) {
          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
            }

            if (!r3x && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 3:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) {
            r3y = 0;
          }

          for (r3x = r3y, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
            }

            if (!r3x && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 4:
        for (y = 0; y < width; y++) {
          for (r3x = 0, r3y = (y >> 1) & 1, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
              r3y = !r3y;
            }

            if (!r3y && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 5:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) {
            r3y = 0;
          }

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
            }

            if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 6:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) {
            r3y = 0;
          }

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
            }

            if (!((x & y & 1) + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      case 7:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) {
            r3y = 0;
          }

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
            }

            if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {
              buffer[x + (y * width)] ^= 1;
            }
          }
        }

        break;
      }
    },

    _calculateMaxLength: function() {
      return (this._dataBlock * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2;
    },

    _calculatePolynomial: function() {
      var i, j;
      var eccBlock = this._eccBlock;
      var polynomial = this._polynomial;

      polynomial[0] = 1;

      for (i = 0; i < eccBlock; i++) {
        polynomial[i + 1] = 1;

        for (j = i; j > 0; j--) {
          polynomial[j] = polynomial[j] ? polynomial[j - 1] ^
            Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[j]] + i)] : polynomial[j - 1];
        }

        polynomial[0] = Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[0]] + i)];
      }

      // Use logs for generator polynomial to save calculation step.
      for (i = 0; i <= eccBlock; i++) {
        polynomial[i] = Galois_1.LOG[polynomial[i]];
      }
    },

    _checkBadness: function() {
      var b, b1, h, x, y;
      var bad = 0;
      var badness = this._badness;
      var buffer = this.buffer;
      var width = this.width;

      // Blocks of same colour.
      for (y = 0; y < width - 1; y++) {
        for (x = 0; x < width - 1; x++) {
          // All foreground colour.
          if ((buffer[x + (width * y)] &&
            buffer[x + 1 + (width * y)] &&
            buffer[x + (width * (y + 1))] &&
            buffer[x + 1 + (width * (y + 1))]) ||
            // All background colour.
            !(buffer[x + (width * y)] ||
            buffer[x + 1 + (width * y)] ||
            buffer[x + (width * (y + 1))] ||
            buffer[x + 1 + (width * (y + 1))])) {
            bad += Frame.N2;
          }
        }
      }

      var bw = 0;

      // X runs.
      for (y = 0; y < width; y++) {
        h = 0;

        badness[0] = 0;

        for (b = 0, x = 0; x < width; x++) {
          b1 = buffer[x + (width * y)];

          if (b === b1) {
            badness[h]++;
          } else {
            badness[++h] = 1;
          }

          b = b1;
          bw += b ? 1 : -1;
        }

        bad += this._getBadness(h);
      }

      if (bw < 0) {
        bw = -bw;
      }

      var count = 0;
      var big = bw;
      big += big << 2;
      big <<= 1;

      while (big > width * width) {
        big -= width * width;
        count++;
      }

      bad += count * Frame.N4;

      // Y runs.
      for (x = 0; x < width; x++) {
        h = 0;

        badness[0] = 0;

        for (b = 0, y = 0; y < width; y++) {
          b1 = buffer[x + (width * y)];

          if (b === b1) {
            badness[h]++;
          } else {
            badness[++h] = 1;
          }

          b = b1;
        }

        bad += this._getBadness(h);
      }

      return bad;
    },

    _convertBitStream: function(length) {
      var bit, i;
      var ecc = this._ecc;
      var version = this._version;

      // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanumeric, or kanji not supported).
      for (i = 0; i < length; i++) {
        ecc[i] = this._value.charCodeAt(i);
      }

      var stringBuffer = this._stringBuffer = ecc.slice();
      var maxLength = this._calculateMaxLength();

      if (length >= maxLength - 2) {
        length = maxLength - 2;

        if (version > 9) {
          length--;
        }
      }

      // Shift and re-pack to insert length prefix.
      var index = length;

      if (version > 9) {
        stringBuffer[index + 2] = 0;
        stringBuffer[index + 3] = 0;

        while (index--) {
          bit = stringBuffer[index];

          stringBuffer[index + 3] |= 255 & (bit << 4);
          stringBuffer[index + 2] = bit >> 4;
        }

        stringBuffer[2] |= 255 & (length << 4);
        stringBuffer[1] = length >> 4;
        stringBuffer[0] = 0x40 | (length >> 12);
      } else {
        stringBuffer[index + 1] = 0;
        stringBuffer[index + 2] = 0;

        while (index--) {
          bit = stringBuffer[index];

          stringBuffer[index + 2] |= 255 & (bit << 4);
          stringBuffer[index + 1] = bit >> 4;
        }

        stringBuffer[1] |= 255 & (length << 4);
        stringBuffer[0] = 0x40 | (length >> 4);
      }

      // Fill to end with pad pattern.
      index = length + 3 - (version < 10);

      while (index < maxLength) {
        stringBuffer[index++] = 0xec;
        stringBuffer[index++] = 0x11;
      }
    },

    _getBadness: function(length) {
      var i;
      var badRuns = 0;
      var badness = this._badness;

      for (i = 0; i <= length; i++) {
        if (badness[i] >= 5) {
          badRuns += Frame.N1 + badness[i] - 5;
        }
      }

      // FBFFFBF as in finder.
      for (i = 3; i < length - 1; i += 2) {
        if (badness[i - 2] === badness[i + 2] &&
          badness[i + 2] === badness[i - 1] &&
          badness[i - 1] === badness[i + 1] &&
          badness[i - 1] * 3 === badness[i] &&
          // Background around the foreground pattern? Not part of the specs.
          (badness[i - 3] === 0 || i + 3 > length ||
          badness[i - 3] * 3 >= badness[i] * 4 ||
          badness[i + 3] * 3 >= badness[i] * 4)) {
          badRuns += Frame.N3;
        }
      }

      return badRuns;
    },

    _finish: function() {
      // Save pre-mask copy of frame.
      this._stringBuffer = this.buffer.slice();

      var currentMask, i;
      var bit = 0;
      var mask = 30000;

      /*
       * Using for instead of while since in original Arduino code if an early mask was "good enough" it wouldn't try for
       * a better one since they get more complex and take longer.
       */
      for (i = 0; i < 8; i++) {
        // Returns foreground-background imbalance.
        this._applyMask(i);

        currentMask = this._checkBadness();

        // Is current mask better than previous best?
        if (currentMask < mask) {
          mask = currentMask;
          bit = i;
        }

        // Don't increment "i" to a void redoing mask.
        if (bit === 7) {
          break;
        }

        // Reset for next pass.
        this.buffer = this._stringBuffer.slice();
      }

      // Redo best mask as none were "good enough" (i.e. last wasn't bit).
      if (bit !== i) {
        this._applyMask(bit);
      }

      // Add in final mask/ECC level bytes.
      mask = ErrorCorrection_1.FINAL_FORMAT[bit + (this._level - 1 << 3)];

      var buffer = this.buffer;
      var width = this.width;

      // Low byte.
      for (i = 0; i < 8; i++, mask >>= 1) {
        if (mask & 1) {
          buffer[width - 1 - i + (width * 8)] = 1;

          if (i < 6) {
            buffer[8 + (width * i)] = 1;
          } else {
            buffer[8 + (width * (i + 1))] = 1;
          }
        }
      }

      // High byte.
      for (i = 0; i < 7; i++, mask >>= 1) {
        if (mask & 1) {
          buffer[8 + (width * (width - 7 + i))] = 1;

          if (i) {
            buffer[6 - i + (width * 8)] = 1;
          } else {
            buffer[7 + (width * 8)] = 1;
          }
        }
      }
    },

    _interleaveBlocks: function() {
      var i, j;
      var dataBlock = this._dataBlock;
      var ecc = this._ecc;
      var eccBlock = this._eccBlock;
      var k = 0;
      var maxLength = this._calculateMaxLength();
      var neccBlock1 = this._neccBlock1;
      var neccBlock2 = this._neccBlock2;
      var stringBuffer = this._stringBuffer;

      for (i = 0; i < dataBlock; i++) {
        for (j = 0; j < neccBlock1; j++) {
          ecc[k++] = stringBuffer[i + (j * dataBlock)];
        }

        for (j = 0; j < neccBlock2; j++) {
          ecc[k++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
        }
      }

      for (j = 0; j < neccBlock2; j++) {
        ecc[k++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
      }

      for (i = 0; i < eccBlock; i++) {
        for (j = 0; j < neccBlock1 + neccBlock2; j++) {
          ecc[k++] = stringBuffer[maxLength + i + (j * eccBlock)];
        }
      }

      this._stringBuffer = ecc;
    },

    _insertAlignments: function() {
      var i, x, y;
      var version = this._version;
      var width = this.width;

      if (version > 1) {
        i = Alignment_1.BLOCK[version];
        y = width - 7;

        for (;;) {
          x = width - 7;

          while (x > i - 3) {
            this._addAlignment(x, y);

            if (x < i) {
              break;
            }

            x -= i;
          }

          if (y <= i + 9) {
            break;
          }

          y -= i;

          this._addAlignment(6, y);
          this._addAlignment(y, 6);
        }
      }
    },

    _insertFinders: function() {
      var i, j, x, y;
      var buffer = this.buffer;
      var width = this.width;

      for (i = 0; i < 3; i++) {
        j = 0;
        y = 0;

        if (i === 1) {
          j = width - 7;
        }
        if (i === 2) {
          y = width - 7;
        }

        buffer[y + 3 + (width * (j + 3))] = 1;

        for (x = 0; x < 6; x++) {
          buffer[y + x + (width * j)] = 1;
          buffer[y + (width * (j + x + 1))] = 1;
          buffer[y + 6 + (width * (j + x))] = 1;
          buffer[y + x + 1 + (width * (j + 6))] = 1;
        }

        for (x = 1; x < 5; x++) {
          this._setMask(y + x, j + 1);
          this._setMask(y + 1, j + x + 1);
          this._setMask(y + 5, j + x);
          this._setMask(y + x + 1, j + 5);
        }

        for (x = 2; x < 4; x++) {
          buffer[y + x + (width * (j + 2))] = 1;
          buffer[y + 2 + (width * (j + x + 1))] = 1;
          buffer[y + 4 + (width * (j + x))] = 1;
          buffer[y + x + 1 + (width * (j + 4))] = 1;
        }
      }
    },

    _insertTimingGap: function() {
      var x, y;
      var width = this.width;

      for (y = 0; y < 7; y++) {
        this._setMask(7, y);
        this._setMask(width - 8, y);
        this._setMask(7, y + width - 7);
      }

      for (x = 0; x < 8; x++) {
        this._setMask(x, 7);
        this._setMask(x + width - 8, 7);
        this._setMask(x, width - 8);
      }
    },

    _insertTimingRowAndColumn: function() {
      var x;
      var buffer = this.buffer;
      var width = this.width;

      for (x = 0; x < width - 14; x++) {
        if (x & 1) {
          this._setMask(8 + x, 6);
          this._setMask(6, 8 + x);
        } else {
          buffer[8 + x + (width * 6)] = 1;
          buffer[6 + (width * (8 + x))] = 1;
        }
      }
    },

    _insertVersion: function() {
      var i, j, x, y;
      var buffer = this.buffer;
      var version = this._version;
      var width = this.width;

      if (version > 6) {
        i = Version_1.BLOCK[version - 7];
        j = 17;

        for (x = 0; x < 6; x++) {
          for (y = 0; y < 3; y++, j--) {
            if (1 & (j > 11 ? version >> j - 12 : i >> j)) {
              buffer[5 - x + (width * (2 - y + width - 11))] = 1;
              buffer[2 - y + width - 11 + (width * (5 - x))] = 1;
            } else {
              this._setMask(5 - x, 2 - y + width - 11);
              this._setMask(2 - y + width - 11, 5 - x);
            }
          }
        }
      }
    },

    _isMasked: function(x, y) {
      var bit = Frame._getMaskBit(x, y);

      return this._mask[bit] === 1;
    },

    _pack: function() {
      var bit, i, j;
      var k = 1;
      var v = 1;
      var width = this.width;
      var x = width - 1;
      var y = width - 1;

      // Interleaved data and ECC codes.
      var length = ((this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2;

      for (i = 0; i < length; i++) {
        bit = this._stringBuffer[i];

        for (j = 0; j < 8; j++, bit <<= 1) {
          if (0x80 & bit) {
            this.buffer[x + (width * y)] = 1;
          }

          // Find next fill position.
          do {
            if (v) {
              x--;
            } else {
              x++;

              if (k) {
                if (y !== 0) {
                  y--;
                } else {
                  x -= 2;
                  k = !k;

                  if (x === 6) {
                    x--;
                    y = 9;
                  }
                }
              } else if (y !== width - 1) {
                y++;
              } else {
                x -= 2;
                k = !k;

                if (x === 6) {
                  x--;
                  y -= 8;
                }
              }
            }

            v = !v;
          } while (this._isMasked(x, y));
        }
      }
    },

    _reverseMask: function() {
      var x, y;
      var width = this.width;

      for (x = 0; x < 9; x++) {
        this._setMask(x, 8);
      }

      for (x = 0; x < 8; x++) {
        this._setMask(x + width - 8, 8);
        this._setMask(8, x);
      }

      for (y = 0; y < 7; y++) {
        this._setMask(8, y + width - 7);
      }
    },

    _setMask: function(x, y) {
      var bit = Frame._getMaskBit(x, y);

      this._mask[bit] = 1;
    },

    _syncMask: function() {
      var x, y;
      var width = this.width;

      for (y = 0; y < width; y++) {
        for (x = 0; x <= y; x++) {
          if (this.buffer[x + (width * y)]) {
            this._setMask(x, y);
          }
        }
      }
    }

  }, {

    _createArray: function(length) {
      var i;
      var array = [];

      for (i = 0; i < length; i++) {
        array[i] = 0;
      }

      return array;
    },

    _getMaskBit: function(x, y) {
      var bit;

      if (x > y) {
        bit = x;
        x = y;
        y = bit;
      }

      bit = y;
      bit += y * y;
      bit >>= 1;
      bit += x;

      return bit;
    },

    _modN: function(x) {
      while (x >= 255) {
        x -= 255;
        x = (x >> 8) + (x & 255);
      }

      return x;
    },

    // *Badness* coefficients.
    N1: 3,
    N2: 3,
    N3: 40,
    N4: 10

  });

  var Frame_1 = Frame;

  /**
   * The options used by {@link Frame}.
   *
   * @typedef {Object} Frame~Options
   * @property {string} level - The ECC level to be used.
   * @property {string} value - The value to be encoded.
   */

  /**
   * An implementation of {@link Renderer} for working with <code>img</code> elements.
   *
   * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from
   * the rendered <code>canvas</code> element as the <code>src</code> for the <code>img</code> element being rendered.
   *
   * @public
   * @class
   * @extends Renderer
   */
  var ImageRenderer = Renderer_1.extend({

    /**
     * @override
     */
    draw: function() {
      this.element.src = this.qrious.toDataURL();
    },

    /**
     * @override
     */
    reset: function() {
      this.element.src = '';
    },

    /**
     * @override
     */
    resize: function() {
      var element = this.element;

      element.width = element.height = this.qrious.size;
    }

  });

  var ImageRenderer_1 = ImageRenderer;

  /**
   * Defines an available option while also configuring how values are applied to the target object.
   *
   * Optionally, a default value can be specified as well a value transformer for greater control over how the option
   * value is applied.
   *
   * If no value transformer is specified, then any specified option will be applied directly. All values are maintained
   * on the target object itself as a field using the option name prefixed with a single underscore.
   *
   * When an option is specified as modifiable, the {@link OptionManager} will be required to include a setter for the
   * property that is defined on the target object that uses the option name.
   *
   * @param {string} name - the name to be used
   * @param {boolean} [modifiable] - <code>true</code> if the property defined on target objects should include a setter;
   * otherwise <code>false</code>
   * @param {*} [defaultValue] - the default value to be used
   * @param {Option~ValueTransformer} [valueTransformer] - the value transformer to be used
   * @public
   * @class
   * @extends Nevis
   */
  var Option = lite.extend(function(name, modifiable, defaultValue, valueTransformer) {
    /**
     * The name for this {@link Option}.
     *
     * @public
     * @type {string}
     * @memberof Option#
     */
    this.name = name;

    /**
     * Whether a setter should be included on the property defined on target objects for this {@link Option}.
     *
     * @public
     * @type {boolean}
     * @memberof Option#
     */
    this.modifiable = Boolean(modifiable);

    /**
     * The default value for this {@link Option}.
     *
     * @public
     * @type {*}
     * @memberof Option#
     */
    this.defaultValue = defaultValue;

    this._valueTransformer = valueTransformer;
  }, {

    /**
     * Transforms the specified <code>value</code> so that it can be applied for this {@link Option}.
     *
     * If a value transformer has been specified for this {@link Option}, it will be called upon to transform
     * <code>value</code>. Otherwise, <code>value</code> will be returned directly.
     *
     * @param {*} value - the value to be transformed
     * @return {*} The transformed value or <code>value</code> if no value transformer is specified.
     * @public
     * @memberof Option#
     */
    transform: function(value) {
      var transformer = this._valueTransformer;
      if (typeof transformer === 'function') {
        return transformer(value, this);
      }

      return value;
    }

  });

  var Option_1 = Option;

  /**
   * Returns a transformed value for the specified <code>value</code> to be applied for the <code>option</code> provided.
   *
   * @callback Option~ValueTransformer
   * @param {*} value - the value to be transformed
   * @param {Option} option - the {@link Option} for which <code>value</code> is being transformed
   * @return {*} The transform value.
   */

  /**
   * Contains utility methods that are useful throughout the library.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var Utilities = lite.extend(null, {

    /**
     * Returns the absolute value of a given number.
     *
     * This method is simply a convenient shorthand for <code>Math.abs</code> while ensuring that nulls are returned as
     * <code>null</code> instead of zero.
     *
     * @param {number} value - the number whose absolute value is to be returned
     * @return {number} The absolute value of <code>value</code> or <code>null</code> if <code>value</code> is
     * <code>null</code>.
     * @public
     * @static
     * @memberof Utilities
     */
    abs: function(value) {
      return value != null ? Math.abs(value) : null;
    },

    /**
     * Returns whether the specified <code>object</code> has a property with the specified <code>name</code> as an own
     * (not inherited) property.
     *
     * @param {Object} object - the object on which the property is to be checked
     * @param {string} name - the name of the property to be checked
     * @return {boolean} <code>true</code> if <code>object</code> has an own property with <code>name</code>.
     * @public
     * @static
     * @memberof Utilities
     */
    hasOwn: function(object, name) {
      return Object.prototype.hasOwnProperty.call(object, name);
    },

    /**
     * A non-operation method that does absolutely nothing.
     *
     * @return {void}
     * @public
     * @static
     * @memberof Utilities
     */
    noop: function() {},

    /**
     * Transforms the specified <code>string</code> to upper case while remaining null-safe.
     *
     * @param {string} string - the string to be transformed to upper case
     * @return {string} <code>string</code> transformed to upper case if <code>string</code> is not <code>null</code>.
     * @public
     * @static
     * @memberof Utilities
     */
    toUpperCase: function(string) {
      return string != null ? string.toUpperCase() : null;
    }

  });

  var Utilities_1 = Utilities;

  /**
   * Manages multiple {@link Option} instances that are intended to be used by multiple implementations.
   *
   * Although the option definitions are shared between targets, the values are maintained on the targets themselves.
   *
   * @param {Option[]} options - the options to be used
   * @public
   * @class
   * @extends Nevis
   */
  var OptionManager = lite.extend(function(options) {
    /**
     * The available options for this {@link OptionManager}.
     *
     * @public
     * @type {Object.<string, Option>}
     * @memberof OptionManager#
     */
    this.options = {};

    options.forEach(function(option) {
      this.options[option.name] = option;
    }, this);
  }, {

    /**
     * Returns whether an option with the specified <code>name</code> is available.
     *
     * @param {string} name - the name of the {@link Option} whose existence is to be checked
     * @return {boolean} <code>true</code> if an {@link Option} exists with <code>name</code>; otherwise
     * <code>false</code>.
     * @public
     * @memberof OptionManager#
     */
    exists: function(name) {
      return this.options[name] != null;
    },

    /**
     * Returns the value of the option with the specified <code>name</code> on the <code>target</code> object provided.
     *
     * @param {string} name - the name of the {@link Option} whose value on <code>target</code> is to be returned
     * @param {Object} target - the object from which the value of the named {@link Option} is to be returned
     * @return {*} The value of the {@link Option} with <code>name</code> on <code>target</code>.
     * @public
     * @memberof OptionManager#
     */
    get: function(name, target) {
      return OptionManager._get(this.options[name], target);
    },

    /**
     * Returns a copy of all of the available options on the <code>target</code> object provided.
     *
     * @param {Object} target - the object from which the option name/value pairs are to be returned
     * @return {Object.<string, *>} A hash containing the name/value pairs of all options on <code>target</code>.
     * @public
     * @memberof OptionManager#
     */
    getAll: function(target) {
      var name;
      var options = this.options;
      var result = {};

      for (name in options) {
        if (Utilities_1.hasOwn(options, name)) {
          result[name] = OptionManager._get(options[name], target);
        }
      }

      return result;
    },

    /**
     * Initializes the available options for the <code>target</code> object provided and then applies the initial values
     * within the speciifed <code>options</code>.
     *
     * This method will throw an error if any of the names within <code>options</code> does not match an available option.
     *
     * This involves setting the default values and defining properties for all of the available options on
     * <code>target</code> before finally calling {@link OptionMananger#setAll} with <code>options</code> and
     * <code>target</code>. Any options that are configured to be modifiable will have a setter included in their defined
     * property that will allow its corresponding value to be modified.
     *
     * If a change handler is specified, it will be called whenever the value changes on <code>target</code> for a
     * modifiable option, but only when done so via the defined property's setter.
     *
     * @param {Object.<string, *>} options - the name/value pairs of the initial options to be set
     * @param {Object} target - the object on which the options are to be initialized
     * @param {Function} [changeHandler] - the function to be called whenever the value of an modifiable option changes on
     * <code>target</code>
     * @return {void}
     * @throws {Error} If <code>options</code> contains an invalid option name.
     * @public
     * @memberof OptionManager#
     */
    init: function(options, target, changeHandler) {
      if (typeof changeHandler !== 'function') {
        changeHandler = Utilities_1.noop;
      }

      var name, option;

      for (name in this.options) {
        if (Utilities_1.hasOwn(this.options, name)) {
          option = this.options[name];

          OptionManager._set(option, option.defaultValue, target);
          OptionManager._createAccessor(option, target, changeHandler);
        }
      }

      this._setAll(options, target, true);
    },

    /**
     * Sets the value of the option with the specified <code>name</code> on the <code>target</code> object provided to
     * <code>value</code>.
     *
     * This method will throw an error if <code>name</code> does not match an available option or matches an option that
     * cannot be modified.
     *
     * If <code>value</code> is <code>null</code> and the {@link Option} has a default value configured, then that default
     * value will be used instead. If the {@link Option} also has a value transformer configured, it will be used to
     * transform whichever value was determined to be used.
     *
     * This method returns whether the value of the underlying field on <code>target</code> was changed as a result.
     *
     * @param {string} name - the name of the {@link Option} whose value is to be set
     * @param {*} value - the value to be set for the named {@link Option} on <code>target</code>
     * @param {Object} target - the object on which <code>value</code> is to be set for the named {@link Option}
     * @return {boolean} <code>true</code> if the underlying field on <code>target</code> was changed; otherwise
     * <code>false</code>.
     * @throws {Error} If <code>name</code> is invalid or is for an option that cannot be modified.
     * @public
     * @memberof OptionManager#
     */
    set: function(name, value, target) {
      return this._set(name, value, target);
    },

    /**
     * Sets all of the specified <code>options</code> on the <code>target</code> object provided to their corresponding
     * values.
     *
     * This method will throw an error if any of the names within <code>options</code> does not match an available option
     * or matches an option that cannot be modified.
     *
     * If any value within <code>options</code> is <code>null</code> and the corresponding {@link Option} has a default
     * value configured, then that default value will be used instead. If an {@link Option} also has a value transformer
     * configured, it will be used to transform whichever value was determined to be used.
     *
     * This method returns whether the value for any of the underlying fields on <code>target</code> were changed as a
     * result.
     *
     * @param {Object.<string, *>} options - the name/value pairs of options to be set
     * @param {Object} target - the object on which the options are to be set
     * @return {boolean} <code>true</code> if any of the underlying fields on <code>target</code> were changed; otherwise
     * <code>false</code>.
     * @throws {Error} If <code>options</code> contains an invalid option name or an option that cannot be modiifed.
     * @public
     * @memberof OptionManager#
     */
    setAll: function(options, target) {
      return this._setAll(options, target);
    },

    _set: function(name, value, target, allowUnmodifiable) {
      var option = this.options[name];
      if (!option) {
        throw new Error('Invalid option: ' + name);
      }
      if (!option.modifiable && !allowUnmodifiable) {
        throw new Error('Option cannot be modified: ' + name);
      }

      return OptionManager._set(option, value, target);
    },

    _setAll: function(options, target, allowUnmodifiable) {
      if (!options) {
        return false;
      }

      var name;
      var changed = false;

      for (name in options) {
        if (Utilities_1.hasOwn(options, name) && this._set(name, options[name], target, allowUnmodifiable)) {
          changed = true;
        }
      }

      return changed;
    }

  }, {

    _createAccessor: function(option, target, changeHandler) {
      var descriptor = {
        get: function() {
          return OptionManager._get(option, target);
        }
      };

      if (option.modifiable) {
        descriptor.set = function(value) {
          if (OptionManager._set(option, value, target)) {
            changeHandler(value, option);
          }
        };
      }

      Object.defineProperty(target, option.name, descriptor);
    },

    _get: function(option, target) {
      return target['_' + option.name];
    },

    _set: function(option, value, target) {
      var fieldName = '_' + option.name;
      var oldValue = target[fieldName];
      var newValue = option.transform(value != null ? value : option.defaultValue);

      target[fieldName] = newValue;

      return newValue !== oldValue;
    }

  });

  var OptionManager_1 = OptionManager;

  /**
   * Called whenever the value of a modifiable {@link Option} is changed on a target object via the defined property's
   * setter.
   *
   * @callback OptionManager~ChangeHandler
   * @param {*} value - the new value for <code>option</code> on the target object
   * @param {Option} option - the modifable {@link Option} whose value has changed on the target object.
   * @return {void}
   */

  /**
   * A basic manager for {@link Service} implementations that are mapped to simple names.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var ServiceManager = lite.extend(function() {
    this._services = {};
  }, {

    /**
     * Returns the {@link Service} being managed with the specified <code>name</code>.
     *
     * @param {string} name - the name of the {@link Service} to be returned
     * @return {Service} The {@link Service} is being managed with <code>name</code>.
     * @throws {Error} If no {@link Service} is being managed with <code>name</code>.
     * @public
     * @memberof ServiceManager#
     */
    getService: function(name) {
      var service = this._services[name];
      if (!service) {
        throw new Error('Service is not being managed with name: ' + name);
      }

      return service;
    },

    /**
     * Sets the {@link Service} implementation to be managed for the specified <code>name</code> to the
     * <code>service</code> provided.
     *
     * @param {string} name - the name of the {@link Service} to be managed with <code>name</code>
     * @param {Service} service - the {@link Service} implementation to be managed
     * @return {void}
     * @throws {Error} If a {@link Service} is already being managed with the same <code>name</code>.
     * @public
     * @memberof ServiceManager#
     */
    setService: function(name, service) {
      if (this._services[name]) {
        throw new Error('Service is already managed with name: ' + name);
      }

      if (service) {
        this._services[name] = service;
      }
    }

  });

  var ServiceManager_1 = ServiceManager;

  var optionManager = new OptionManager_1([
    new Option_1('background', true, 'white'),
    new Option_1('backgroundAlpha', true, 1, Utilities_1.abs),
    new Option_1('element'),
    new Option_1('foreground', true, 'black'),
    new Option_1('foregroundAlpha', true, 1, Utilities_1.abs),
    new Option_1('level', true, 'L', Utilities_1.toUpperCase),
    new Option_1('mime', true, 'image/png'),
    new Option_1('padding', true, null, Utilities_1.abs),
    new Option_1('size', true, 100, Utilities_1.abs),
    new Option_1('value', true, '')
  ]);
  var serviceManager = new ServiceManager_1();

  /**
   * Enables configuration of a QR code generator which uses HTML5 <code>canvas</code> for rendering.
   *
   * @param {QRious~Options} [options] - the options to be used
   * @throws {Error} If any <code>options</code> are invalid.
   * @public
   * @class
   * @extends Nevis
   */
  var QRious = lite.extend(function(options) {
    optionManager.init(options, this, this.update.bind(this));

    var element = optionManager.get('element', this);
    var elementService = serviceManager.getService('element');
    var canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas();
    var image = element && elementService.isImage(element) ? element : elementService.createImage();

    this._canvasRenderer = new CanvasRenderer_1(this, canvas, true);
    this._imageRenderer = new ImageRenderer_1(this, image, image === element);

    this.update();
  }, {

    /**
     * Returns all of the options configured for this {@link QRious}.
     *
     * Any changes made to the returned object will not be reflected in the options themselves or their corresponding
     * underlying fields.
     *
     * @return {Object.<string, *>} A copy of the applied options.
     * @public
     * @memberof QRious#
     */
    get: function() {
      return optionManager.getAll(this);
    },

    /**
     * Sets all of the specified <code>options</code> and automatically updates this {@link QRious} if any of the
     * underlying fields are changed as a result.
     *
     * This is the preferred method for updating multiple options at one time to avoid unnecessary updates between
     * changes.
     *
     * @param {QRious~Options} options - the options to be set
     * @return {void}
     * @throws {Error} If any <code>options</code> are invalid or cannot be modified.
     * @public
     * @memberof QRious#
     */
    set: function(options) {
      if (optionManager.setAll(options, this)) {
        this.update();
      }
    },

    /**
     * Returns the image data URI for the generated QR code using the <code>mime</code> provided.
     *
     * @param {string} [mime] - the MIME type for the image
     * @return {string} The image data URI for the QR code.
     * @public
     * @memberof QRious#
     */
    toDataURL: function(mime) {
      return this.canvas.toDataURL(mime || this.mime);
    },

    /**
     * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.
     *
     * @return {void}
     * @protected
     * @memberof QRious#
     */
    update: function() {
      var frame = new Frame_1({
        level: this.level,
        value: this.value
      });

      this._canvasRenderer.render(frame);
      this._imageRenderer.render(frame);
    }

  }, {

    /**
     * Configures the <code>service</code> provided to be used by all {@link QRious} instances.
     *
     * @param {Service} service - the {@link Service} to be configured
     * @return {void}
     * @throws {Error} If a {@link Service} has already been configured with the same name.
     * @public
     * @static
     * @memberof QRious
     */
    use: function(service) {
      serviceManager.setService(service.getName(), service);
    }

  });

  Object.defineProperties(QRious.prototype, {

    canvas: {
      /**
       * Returns the <code>canvas</code> element being used to render the QR code for this {@link QRious}.
       *
       * @return {*} The <code>canvas</code> element.
       * @public
       * @memberof QRious#
       * @alias canvas
       */
      get: function() {
        return this._canvasRenderer.getElement();
      }
    },

    image: {
      /**
       * Returns the <code>img</code> element being used to render the QR code for this {@link QRious}.
       *
       * @return {*} The <code>img</code> element.
       * @public
       * @memberof QRious#
       * @alias image
       */
      get: function() {
        return this._imageRenderer.getElement();
      }
    }

  });

  var QRious_1$2 = QRious;

  /**
   * The options used by {@link QRious}.
   *
   * @typedef {Object} QRious~Options
   * @property {string} [background="white"] - The background color to be applied to the QR code.
   * @property {number} [backgroundAlpha=1] - The background alpha to be applied to the QR code.
   * @property {*} [element] - The element to be used to render the QR code which may either be an <code>canvas</code> or
   * <code>img</code>. The element(s) will be created if needed.
   * @property {string} [foreground="black"] - The foreground color to be applied to the QR code.
   * @property {number} [foregroundAlpha=1] - The foreground alpha to be applied to the QR code.
   * @property {string} [level="L"] - The error correction level to be applied to the QR code.
   * @property {string} [mime="image/png"] - The MIME type to be used to render the image for the QR code.
   * @property {number} [padding] - The padding for the QR code in pixels.
   * @property {number} [size=100] - The size of the QR code in pixels.
   * @property {string} [value=""] - The value to be encoded within the QR code.
   */

  var index = QRious_1$2;

  /**
   * Defines a service contract that must be met by all implementations.
   *
   * @public
   * @class
   * @extends Nevis
   */
  var Service = lite.extend({

    /**
     * Returns the name of this {@link Service}.
     *
     * @return {string} The service name.
     * @public
     * @abstract
     * @memberof Service#
     */
    getName: function() {}

  });

  var Service_1 = Service;

  /**
   * A service for working with elements.
   *
   * @public
   * @class
   * @extends Service
   */
  var ElementService = Service_1.extend({

    /**
     * Creates an instance of a canvas element.
     *
     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
     *
     * @return {*} The newly created canvas element.
     * @public
     * @abstract
     * @memberof ElementService#
     */
    createCanvas: function() {},

    /**
     * Creates an instance of a image element.
     *
     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
     *
     * @return {*} The newly created image element.
     * @public
     * @abstract
     * @memberof ElementService#
     */
    createImage: function() {},

    /**
     * @override
     */
    getName: function() {
      return 'element';
    },

    /**
     * Returns whether the specified <code>element</code> is a canvas.
     *
     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
     *
     * @param {*} element - the element to be checked
     * @return {boolean} <code>true</code> if <code>element</code> is a canvas; otherwise <code>false</code>.
     * @public
     * @abstract
     * @memberof ElementService#
     */
    isCanvas: function(element) {},

    /**
     * Returns whether the specified <code>element</code> is an image.
     *
     * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
     *
     * @param {*} element - the element to be checked
     * @return {boolean} <code>true</code> if <code>element</code> is an image; otherwise <code>false</code>.
     * @public
     * @abstract
     * @memberof ElementService#
     */
    isImage: function(element) {}

  });

  var ElementService_1 = ElementService;

  /**
   * An implementation of {@link ElementService} intended for use within a browser environment.
   *
   * @public
   * @class
   * @extends ElementService
   */
  var BrowserElementService = ElementService_1.extend({

    /**
     * @override
     */
    createCanvas: function() {
      return document.createElement('canvas');
    },

    /**
     * @override
     */
    createImage: function() {
      return document.createElement('img');
    },

    /**
     * @override
     */
    isCanvas: function(element) {
      return element instanceof HTMLCanvasElement;
    },

    /**
     * @override
     */
    isImage: function(element) {
      return element instanceof HTMLImageElement;
    }

  });

  var BrowserElementService_1 = BrowserElementService;

  index.use(new BrowserElementService_1());

  var QRious_1 = index;

  return QRious_1;

})));

//# sourceMappingURL=qrious.js.map

/***/ }),

/***/ 1820:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GenericTableModule; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_common__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_forms__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_generic_table_component__ = __webpack_require__(1662);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__pipes_gt_render_pipe__ = __webpack_require__(1822);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__pipes_gt_visible_pipe__ = __webpack_require__(1823);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__pipes_dash_case_pipe__ = __webpack_require__(1824);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__pipes_gt_property_pipe__ = __webpack_require__(1825);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__pipes_gt_chunk_pipe__ = __webpack_require__(1826);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__pipes_gt_filter_pipe__ = __webpack_require__(1827);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__pipes_gt_order_by_pipe__ = __webpack_require__(1828);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_gt_expanding_row_component__ = __webpack_require__(1702);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__pipes_gt_search_pipe__ = __webpack_require__(1829);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__directives_component_anchor_directive__ = __webpack_require__(1830);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__components_gt_pagination_component__ = __webpack_require__(1831);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__components_gt_table_info_component__ = __webpack_require__(1832);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__components_gt_custom_component_factory__ = __webpack_require__(1833);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__pipes_gt_meta_pipe__ = __webpack_require__(1700);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__components_gt_dropdown_component__ = __webpack_require__(1834);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__pipes_gt_totals_pipe__ = __webpack_require__(1836);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__pipes_gt_totals_position_pipe__ = __webpack_require__(1837);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__pipes_gt_row_class_pipe__ = __webpack_require__(1838);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__pipes_gt_column_class_pipe__ = __webpack_require__(1839);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__directives_gt_column_width_directive__ = __webpack_require__(1840);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__components_gt_drilldown_component__ = __webpack_require__(1841);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__components_gt_checkbox_gt_checkbox_component__ = __webpack_require__(1842);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__pipes_gt_highlight_pipe__ = __webpack_require__(1701);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__pipes_gt_is_observable_pipe__ = __webpack_require__(1843);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__pipes_gt_is_editable_pipe__ = __webpack_require__(1844);
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 GenericTableModule = /** @class */ (function () {
    function GenericTableModule() {
    }
    GenericTableModule = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["NgModule"])({
            declarations: [
                __WEBPACK_IMPORTED_MODULE_13__directives_component_anchor_directive__["a" /* ComponentAnchorDirective */],
                __WEBPACK_IMPORTED_MODULE_3__components_generic_table_component__["a" /* GenericTableComponent */],
                __WEBPACK_IMPORTED_MODULE_14__components_gt_pagination_component__["a" /* GtPaginationComponent */],
                __WEBPACK_IMPORTED_MODULE_5__pipes_gt_visible_pipe__["a" /* GtVisiblePipe */],
                __WEBPACK_IMPORTED_MODULE_4__pipes_gt_render_pipe__["a" /* GtRenderPipe */],
                __WEBPACK_IMPORTED_MODULE_6__pipes_dash_case_pipe__["a" /* DashCasePipe */],
                __WEBPACK_IMPORTED_MODULE_7__pipes_gt_property_pipe__["a" /* GtPropertyPipe */],
                __WEBPACK_IMPORTED_MODULE_8__pipes_gt_chunk_pipe__["a" /* GtChunkPipe */],
                __WEBPACK_IMPORTED_MODULE_9__pipes_gt_filter_pipe__["a" /* GtFilterPipe */],
                __WEBPACK_IMPORTED_MODULE_10__pipes_gt_order_by_pipe__["a" /* GtOrderByPipe */],
                __WEBPACK_IMPORTED_MODULE_11__components_gt_expanding_row_component__["b" /* GtExpandingRowComponent */],
                __WEBPACK_IMPORTED_MODULE_16__components_gt_custom_component_factory__["a" /* GtCustomComponentFactory */],
                __WEBPACK_IMPORTED_MODULE_12__pipes_gt_search_pipe__["a" /* GtSearchPipe */],
                __WEBPACK_IMPORTED_MODULE_14__components_gt_pagination_component__["b" /* PaginationPipe */],
                __WEBPACK_IMPORTED_MODULE_15__components_gt_table_info_component__["a" /* GtTableInfoComponent */],
                __WEBPACK_IMPORTED_MODULE_15__components_gt_table_info_component__["b" /* TableInfoPipe */],
                __WEBPACK_IMPORTED_MODULE_17__pipes_gt_meta_pipe__["a" /* GtMetaPipe */],
                __WEBPACK_IMPORTED_MODULE_19__pipes_gt_totals_pipe__["a" /* GtTotalsPipe */],
                __WEBPACK_IMPORTED_MODULE_20__pipes_gt_totals_position_pipe__["a" /* GtTotalsPositionPipe */],
                __WEBPACK_IMPORTED_MODULE_21__pipes_gt_row_class_pipe__["a" /* GtRowClassPipe */],
                __WEBPACK_IMPORTED_MODULE_22__pipes_gt_column_class_pipe__["a" /* GtColumnClassPipe */],
                __WEBPACK_IMPORTED_MODULE_26__pipes_gt_highlight_pipe__["a" /* GtHighlightPipe */],
                __WEBPACK_IMPORTED_MODULE_27__pipes_gt_is_observable_pipe__["a" /* GtIsObservablePipe */],
                __WEBPACK_IMPORTED_MODULE_28__pipes_gt_is_editable_pipe__["a" /* GtIsEditablePipe */],
                __WEBPACK_IMPORTED_MODULE_18__components_gt_dropdown_component__["a" /* GtDropdownComponent */],
                __WEBPACK_IMPORTED_MODULE_23__directives_gt_column_width_directive__["a" /* GtColumnWidthDirective */],
                __WEBPACK_IMPORTED_MODULE_24__components_gt_drilldown_component__["a" /* GtDrilldownComponent */],
                __WEBPACK_IMPORTED_MODULE_25__components_gt_checkbox_gt_checkbox_component__["a" /* GtCheckboxComponent */]
            ],
            imports: [__WEBPACK_IMPORTED_MODULE_1__angular_common__["CommonModule"], __WEBPACK_IMPORTED_MODULE_2__angular_forms__["FormsModule"]],
            exports: [
                __WEBPACK_IMPORTED_MODULE_3__components_generic_table_component__["a" /* GenericTableComponent */],
                __WEBPACK_IMPORTED_MODULE_14__components_gt_pagination_component__["a" /* GtPaginationComponent */],
                __WEBPACK_IMPORTED_MODULE_15__components_gt_table_info_component__["a" /* GtTableInfoComponent */],
                __WEBPACK_IMPORTED_MODULE_7__pipes_gt_property_pipe__["a" /* GtPropertyPipe */],
                __WEBPACK_IMPORTED_MODULE_26__pipes_gt_highlight_pipe__["a" /* GtHighlightPipe */],
                __WEBPACK_IMPORTED_MODULE_11__components_gt_expanding_row_component__["b" /* GtExpandingRowComponent */],
                __WEBPACK_IMPORTED_MODULE_18__components_gt_dropdown_component__["a" /* GtDropdownComponent */],
                __WEBPACK_IMPORTED_MODULE_24__components_gt_drilldown_component__["a" /* GtDrilldownComponent */],
                __WEBPACK_IMPORTED_MODULE_25__components_gt_checkbox_gt_checkbox_component__["a" /* GtCheckboxComponent */]
            ],
            entryComponents: [__WEBPACK_IMPORTED_MODULE_24__components_gt_drilldown_component__["a" /* GtDrilldownComponent */], __WEBPACK_IMPORTED_MODULE_25__components_gt_checkbox_gt_checkbox_component__["a" /* GtCheckboxComponent */]],
            providers: [__WEBPACK_IMPORTED_MODULE_17__pipes_gt_meta_pipe__["a" /* GtMetaPipe */], __WEBPACK_IMPORTED_MODULE_26__pipes_gt_highlight_pipe__["a" /* GtHighlightPipe */]],
            bootstrap: []
        })
    ], GenericTableModule);
    return GenericTableModule;
}());

//# sourceMappingURL=core.module.js.map

/***/ }),

/***/ 1821:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GENERIC_TABLE_COMPONENT; });
var GENERIC_TABLE_COMPONENT = "<table class=\"table\" ngClass=\"{{gtClasses}} {{gtOptions.stack ? 'table-stacked':''}}\"\n       *ngIf=\"gtFields && gtSettings && (gtFields | gtVisible:gtSettings:refreshPipe).length > 0\">\n  <thead>\n  <tr>\n    <th class=\"gt-sort-label\" *ngIf=\"gtOptions.stack\">{{gtTexts.sortLabel}}</th>\n    <th *ngFor=\"let column of gtSettings | gtVisible:gtSettings:refreshPipe\"\n        ngClass=\"{{column.objectKey +'-column' | dashCase}} {{gtFields | gtProperty:column.objectKey:'classNames'}} {{column.sortEnabled ? 'sort-'+column.sort:''}} {{column.sortEnabled && column.sortOrder >= 0  ? 'sort-order-'+column.sortOrder:''}} {{ gtFields | gtColumnClass:column }}\"\n        (click)=\"column.sortEnabled ? gtSort(column.objectKey,$event):'';\">\n      <span *ngIf=\"!(gtFields | gtProperty:column.objectKey:'header')\">{{gtFields | gtProperty:column.objectKey:'name'}}</span>\n      <gt-custom-component-factory *ngIf=\"(gtFields | gtProperty:column.objectKey:'header')\"\n                                   [type]=\"(gtFields | gtProperty:column.objectKey:'header')?.type\"\n                                   [injector]=\"(gtFields | gtProperty:column.objectKey:'header')?.injector\"\n                                   [column]=\"gtFields | gtProperty:column.objectKey:'name'\"></gt-custom-component-factory>\n      <gt-checkbox *ngIf=\"(gtFields | gtProperty:column.objectKey:'columnComponent')?.type === 'checkbox'\" [checked]=\"(gtOptions.lazyLoad ? lazyAllSelected:selectedRows.length === gtData.length)\" (changed)=\"toggleAllRows()\"></gt-checkbox>\n    </th>\n  </tr>\n  </thead>\n  <ng-template\n    [ngIf]=\"gtTotals && (gtOptions.lazyLoad === false ? (gtData | gtFilter:gtInfo.filter:gtInfo:refreshFilter:gtData.length | gtSearch:gtInfo.searchTerms:gtInfo:gtSettings:gtFields:gtData.length).length > 0 : gtData.length > 0)\">\n    <thead class=\"gt-totals\">\n    <tr *ngFor=\"let total of gtTotals | gtTotalsPosition\">\n      <td *ngFor=\"let column of gtSettings | gtVisible:gtSettings:refreshPipe;let i = index;\"\n          ngClass=\"{{column.objectKey +'-totals-column' | dashCase}} {{gtFields | gtProperty:column.objectKey:'classNames'}} {{ gtFields | gtColumnClass:column }}\">\n        <span *ngIf=\"i === 0\" class=\"float-left\">{{total.name}}</span><span\n        [innerHTML]=\"total.fields[column.objectKey] | gtTotals:(total.update === false || gtOptions.lazyLoad === true) ? gtData:(gtData | gtFilter:gtInfo.filter:gtInfo:refreshFilter:gtData.length | gtSearch:gtInfo.searchTerms:gtInfo:gtSettings:gtFields:gtData.length):column.objectKey:refreshTotals\"></span>\n      </td>\n    </tr>\n    </thead>\n    <tfoot class=\"gt-totals\">\n    <tr *ngFor=\"let total of gtTotals | gtTotalsPosition:'footer'\">\n      <td *ngFor=\"let column of gtSettings | gtVisible:gtSettings:refreshPipe;let i = index;\"\n          ngClass=\"{{column.objectKey +'-totals-column' | dashCase}} {{gtFields | gtProperty:column.objectKey:'classNames'}} {{ gtFields | gtColumnClass:column }}\">\n        <span *ngIf=\"i === 0\" class=\"float-left\">{{total.name}}</span><span\n        [innerHTML]=\"total.fields[column.objectKey] | gtTotals:(total.update === false || gtOptions.lazyLoad === true) ? gtData:(gtData | gtFilter:gtInfo.filter:gtInfo:refreshFilter:gtData.length | gtSearch:gtInfo.searchTerms:gtInfo:gtSettings:gtFields:gtData.length):column.objectKey:refreshTotals\"></span>\n      </td>\n    </tr>\n    </tfoot>\n  </ng-template>\n  <tbody *ngIf=\"gtData && gtInfo\">\n  <ng-template class=\"table-rows\" ngFor let-row let-last=\"last\" [ngForTrackBy]=\"trackByFn\"\n               [ngForOf]=\"gtOptions.lazyLoad && gtInfo ? (gtData[gtInfo.pageCurrent-1]) : (gtData | gtFilter:gtInfo.filter:gtInfo:refreshFilter:gtData.length | gtSearch:gtInfo.searchTerms:gtInfo:gtSettings:gtFields:gtData.length | gtOrderBy:sortOrder:gtFields:refreshSorting:gtData.length | gtChunk:gtInfo:gtInfo.recordLength:gtInfo.pageCurrent:refreshPageArray:gtData.length:gtEvent:data | gtRowClass:gtFields)\">\n    <tr [ngClass]=\"{'row-selected':metaInfo[row.$$gtRowId]?.isSelected, 'row-open':metaInfo[row.$$gtRowId]?.isOpen, 'row-loading':loading, 'row-expandable':gtRowComponent}\"\n        class=\"{{row.$$gtRowClass}}\"\n        (click)=\"gtOptions.rowSelection ? toggleSelect(row):rowClick(row, $event)\">\n      <td *ngFor=\"let column of row | gtRender:gtSettings:gtFields:refreshPipe:loading:gtOptions.highlightSearch:gtInfo.searchTerms;trackBy:trackByColumnFn\"\n          ngClass=\"{{column.objectKey +'-column' | dashCase}} {{gtFields | gtProperty:column.objectKey:'classNames'}} {{(gtFields | gtProperty:column.objectKey:'inlineEdit') ? 'gt-inline-edit':''}} {{column.edited ? 'gt-edited':''}} {{ gtFields | gtColumnClass:column:row }}\">\n                        <span class=\"gt-row-label\"\n                              *ngIf=\"gtOptions.stack\">{{(gtFields | gtProperty:column.objectKey:'stackedHeading') ? (gtFields | gtProperty:column.objectKey:'stackedHeading') : (gtFields | gtProperty:column.objectKey:'name')}}</span>\n        <gt-custom-component-factory *ngIf=\"column.columnComponent && column.columnComponent.type !== 'checkbox'\" class=\"gt-row-content\"\n                                     [type]=\"column.columnComponent.type\"\n                                     [injector]=\"column.columnComponent.injector\" [row]=\"row\"\n                                     [column]=\"column\" (redrawEvent)=\"redraw($event)\"\n                                     [searchTerms]=\"gtInfo.searchTerms\"  (searchEvent)=\"redraw($event)\"\n                                     (click)=\"column.click ? column.click(row,column,$event):'';column.expand ? toggleCollapse(row, column.expand):''\"></gt-custom-component-factory>\n        <span *ngIf=\"!column.columnComponent && (!(gtFields | gtProperty:column.objectKey:'inlineEdit') || ((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | gtIsObservable) && !((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | async) || (!((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | gtIsObservable) && !((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | gtIsEditable:row:refreshPipe)))\"\n              class=\"gt-row-content\" [innerHTML]=\"column.renderValue\"\n              (click)=\"column.click ? column.click(row,column,$event):'';column.expand ? toggleCollapse(row, column.expand):''\"></span>\n        <ng-template\n          [ngIf]=\"!column.columnComponent && (((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | gtIsObservable) && ((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | async) || ((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active | gtIsEditable:row:refreshPipe))\">\n          <ng-template [ngIf]=\"([true,'email','number','password', 'text'].indexOf((gtFields | gtProperty:column.objectKey:'inlineEdit').type) !== -1) || !(gtFields | gtProperty:column.objectKey:'inlineEdit').type\">\n            <input class=\"inline-edit\" [attr.type]=\"!(gtFields | gtProperty:column.objectKey:'inlineEdit').type ? 'text' : !((gtFields | gtProperty:column.objectKey:'inlineEdit').type | gtIsObservable) ? (gtFields | gtProperty:column.objectKey:'inlineEdit').type:(gtFields | gtProperty:column.objectKey:'inlineEdit').type | async\" [(ngModel)]=\"column.renderValue\"\n                   (input)=\"gtUpdateColumn($event,row, column)\">\n            <span class=\"gt-inline-edit-notice\">{{gtTexts.inlineEditEdited}}</span>\n          </ng-template>\n          <gt-dropdown\n            *ngIf=\"(((gtFields | gtProperty:column.objectKey:'inlineEdit').type) && ((gtFields | gtProperty:column.objectKey:'inlineEdit').type).length > 0) || ((gtFields | gtProperty:column.objectKey:'inlineEdit').type | gtIsObservable)\"\n            [options]=\"!((gtFields | gtProperty:column.objectKey:'inlineEdit').type | gtIsObservable) ? (gtFields | gtProperty:column.objectKey:'inlineEdit').type : (gtFields | gtProperty:column.objectKey:'inlineEdit').type | async\"\n            [id]=\"'_' + row.$$gtRowId + '_' + column.objectKey\"\n            [(selected)]=\"column.renderValue\" (selectedChange)=\"gtDropdownSelect(row, column)\">Add\n            inline editing module\n          </gt-dropdown>\n        </ng-template>\n        <ng-template [ngIf]=\"!column.columnComponent && !((gtFields | gtProperty:column.objectKey:'inlineEdit')?.active) \">\n          <ng-template\n            [ngIf]=\"[true,'email','number','password'].indexOf(gtFields | gtProperty:column.objectKey:'inlineEdit') !== -1\">\n            <input class=\"inline-edit\" [attr.type]=\"(gtFields | gtProperty:column.objectKey:'inlineEdit') === true ? 'text':(gtFields | gtProperty:column.objectKey:'inlineEdit')\" [(ngModel)]=\"column.renderValue\"\n                   (input)=\"gtUpdateColumn($event,row, column)\">\n            <span class=\"gt-inline-edit-notice\">{{gtTexts.inlineEditEdited}}</span>\n          </ng-template>\n          <gt-dropdown\n            *ngIf=\"(gtFields | gtProperty:column.objectKey:'inlineEdit') && [true,'email','number','password'].indexOf(gtFields | gtProperty:column.objectKey:'inlineEdit') === -1\"\n            [options]=\"gtFields | gtProperty:column.objectKey:'inlineEdit'\"\n            [id]=\"'_' + row.$$gtRowId + '_' + column.objectKey\"\n            [(selected)]=\"column.renderValue\" (selectedChange)=\"gtDropdownSelect(row, column)\">Add\n            inline editing module\n          </gt-dropdown>\n        </ng-template>\n        <gt-checkbox *ngIf=\"column.columnComponent && column.columnComponent.type === 'checkbox'\" [checked]=\"metaInfo[row.$$gtRowId]?.isSelected\" (changed)=\"toggleSelect(row)\"></gt-checkbox>\n      </td>\n    </tr>\n    <tr class=\"row-expanded\" *ngIf=\"metaInfo[row.$$gtRowId]?.isOpen\">\n      <td [attr.colspan]=\"(gtFields | gtVisible:gtSettings:refreshPipe).length\">\n        <gt-expanding-row [row]=\"row\"\n                          [type]=\"expandedRow.component ? expandedRow.component:gtRowComponent\"\n                          [columnWidth]=\"columnWidth\"\n                          [gtFields]=\"gtFields\"\n                          [gtOptions]=\"gtOptions\"\n                          [gtEvent]=\"gtEvent\"\n                          [gtInfo]=\"gtInfo\"\n                          [gtSettings]=\"gtSettings\"\n                          [data]=\"expandedRow.data ? expandedRow.data:row\"\n                          (redrawEvent)=\"redraw($event)\"\n                          (toggleRowEvent)=\"toggleCollapse($event)\"></gt-expanding-row>\n      </td>\n    </tr>\n    <tr *ngIf=\"gtOptions.reportColumnWidth && last\">\n      <td style=\"padding: 0; border:none;\"\n          *ngFor=\"let column of gtSettings | gtVisible:gtSettings:refreshPipe\" gtColumnWidth\n          [objectKey]=\"column.objectKey\" [widths]=\"columnWidth\"></td>\n    </tr>\n  </ng-template>\n  <tr *ngIf=\"gtInfo.pageTotal === 0 && (gtInfo.searchTerms || gtInfo.filter) && !loading\">\n    <td class=\"gt-no-matching-results\" [attr.colspan]=\"(gtFields | gtVisible:gtSettings).length\">\n      {{gtTexts.noMatchingData}}\n    </td>\n  </tr>\n  <tr *ngIf=\"gtInfo.pageTotal === 0 && !(gtInfo.searchTerms || gtInfo.filter) && !loading\">\n    <td class=\"gt-no-results\" [attr.colspan]=\"(gtFields | gtVisible:gtSettings).length\">{{gtTexts.noData}}\n    </td>\n  </tr>\n  <tr *ngIf=\"gtInfo.pageTotal === 0 && loading\">\n    <td class=\"gt-loading-data\" [attr.colspan]=\"(gtFields | gtVisible:gtSettings).length\">{{gtTexts.loading}}</td>\n  </tr>\n  </tbody>\n</table>\n<table class=\"table\" ngClass=\"{{gtClasses}} {{gtOptions.stack ? 'table-stacked':''}}\"\n       *ngIf=\"gtFields && gtSettings && (gtFields | gtVisible:gtSettings:refreshPipe).length === 0\">\n  <thead>\n  <tr>\n    <th class=\"gt-no-visible-columns\">{{gtTexts.noVisibleColumnsHeading}}</th>\n  </tr>\n  </thead>\n  <tbody>\n  <tr>\n    <td class=\"gt-no-visible-columns\">{{gtTexts.noVisibleColumns}}</td>\n  </tr>\n  </tbody>\n</table>\n<table class=\"table\" ngClass=\"{{gtClasses}} {{gtOptions.stack ? 'table-stacked':''}}\"\n       *ngIf=\"!gtFields || !gtSettings\">\n  <thead>\n  <tr>\n    <th class=\"gt-loading-config\">&nbsp;</th>\n  </tr>\n  </thead>\n  <tbody>\n  <tr>\n    <td class=\"gt-loading-config\">&nbsp;</td>\n  </tr>\n  </tbody>\n</table>";
//# sourceMappingURL=generic-table.component-template.js.map

/***/ }),

/***/ 1822:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtRenderPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser__ = __webpack_require__(73);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__gt_highlight_pipe__ = __webpack_require__(1701);
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 GtRenderPipe = /** @class */ (function () {
    function GtRenderPipe(sanitizer, gtHighlightPipe) {
        this.sanitizer = sanitizer;
        this.gtHighlightPipe = gtHighlightPipe;
        // TODO: move to helper functions
        /** Sort by column order */
        this.getColumnOrder = function (a, b) {
            if (a.columnOrder < b.columnOrder) {
                return -1;
            }
            if (a.columnOrder > b.columnOrder || typeof a.columnOrder === 'undefined') {
                return 1;
            }
            return 0;
        };
        /** Sort by length */
        this.getOrderByLength = function (a, b) {
            return b.length - a.length;
        };
        /** Return property */
        this.getProperty = function (array, key) {
            for (var i = 0; i < array.length; i++) {
                if (array[i].objectKey === key) {
                    return array[i];
                }
            }
        };
    }
    GtRenderPipe.prototype.transform = function (row, settings, fields, updated, loading, highlight, searchString) {
        // let arr = [{"temp":123,"name":"happy"},{"temp":456,"name":"dfgdfg"},{"temp":789,"name":"asdasd"}];
        // console.log(arr,arr.map(function(item){return item.temp}));
        // console.log(settings.map('objectKey'));
        if (highlight === void 0) { highlight = false; }
        // console.log('render');
        var columns = [];
        for (var i = 0; i < settings.length; i++) {
            if (settings[i].visible !== false && settings[i].enabled !== false) {
                columns.push(settings[i].objectKey);
            }
        }
        for (var i = 0; i < fields.length; i++) {
            // console.log(!row[fields[i].objectKey]);
            if (fields[i].value &&
                typeof fields[i].value === 'function' &&
                !row.hasOwnProperty(fields[i].objectKey)) {
                row[fields[i].objectKey] = loading ? '' : fields[i].value(row);
            }
        }
        // console.log(row);
        var keys = [];
        for (var key in row) {
            // console.log(key);
            if (columns.indexOf(key) !== -1) {
                var fieldSetting = void 0;
                for (var i = 0; i < fields.length; i++) {
                    if (fields[i].objectKey === key) {
                        fieldSetting = fields[i];
                        // console.log(fieldSetting);
                    }
                }
                var columnObject = {
                    objectKey: key,
                    sortValue: row[key]
                };
                // add component if defined
                if (fieldSetting.columnComponent) {
                    columnObject.columnComponent = fieldSetting.columnComponent;
                }
                if (loading) {
                    columnObject.renderValue = row[key] !== null ? row[key] : '';
                }
                else if (highlight &&
                    searchString &&
                    this.getProperty(settings, key).search !== false) {
                    columnObject.renderValue =
                        fieldSetting.render && typeof fieldSetting.render === 'function'
                            ? this.gtHighlightPipe.transform(fieldSetting.render(row), searchString)
                            : this.gtHighlightPipe.transform(row[key] !== null ? row[key] : '', searchString);
                }
                else {
                    columnObject.renderValue =
                        fieldSetting.render && typeof fieldSetting.render === 'function'
                            ? this.sanitizer.bypassSecurityTrustHtml(fieldSetting.render(row))
                            : row[key] !== null
                                ? row[key]
                                : '';
                }
                if (fieldSetting.click && typeof fieldSetting.click === 'function') {
                    columnObject.click = fieldSetting.click;
                }
                if (fieldSetting.expand) {
                    columnObject.expand = fieldSetting.expand;
                }
                keys.push(columnObject);
            }
        }
        keys.sort(function (a, b) {
            return columns.indexOf(a.objectKey) < columns.indexOf(b.objectKey)
                ? -1
                : 1;
        });
        return keys;
    };
    GtRenderPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtRender'
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__angular_platform_browser__["c" /* DomSanitizer */],
            __WEBPACK_IMPORTED_MODULE_2__gt_highlight_pipe__["a" /* GtHighlightPipe */]])
    ], GtRenderPipe);
    return GtRenderPipe;
}());

//# sourceMappingURL=gt-render.pipe.js.map

/***/ }),

/***/ 1823:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtVisiblePipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtVisiblePipe = /** @class */ (function () {
    function GtVisiblePipe() {
        // TODO: move to helper functions
        /** Sort by column order */
        this.getColumnOrder = function (a, b) {
            if (a.columnOrder < b.columnOrder) {
                return -1;
            }
            if (a.columnOrder > b.columnOrder || typeof a.columnOrder === 'undefined') {
                return 1;
            }
            return 0;
        };
    }
    GtVisiblePipe.prototype.transform = function (array, settings, refreshPipe) {
        var visibleColumns = settings
            .sort(this.getColumnOrder)
            .map(function (setting) {
            if (setting.visible !== false && setting.enabled !== false) {
                return setting.objectKey;
            }
        });
        return array
            .filter(function (column) {
            return visibleColumns.indexOf(column.objectKey) !== -1;
        })
            .sort(function (a, b) {
            return visibleColumns.indexOf(a.objectKey) <
                visibleColumns.indexOf(b.objectKey)
                ? -1
                : 1;
        });
    };
    GtVisiblePipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtVisible'
        })
    ], GtVisiblePipe);
    return GtVisiblePipe;
}());

//# sourceMappingURL=gt-visible.pipe.js.map

/***/ }),

/***/ 1824:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DashCasePipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 DashCasePipe = /** @class */ (function () {
    function DashCasePipe() {
    }
    DashCasePipe.prototype.transform = function (string) {
        return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
    };
    DashCasePipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'dashCase'
        })
    ], DashCasePipe);
    return DashCasePipe;
}());

//# sourceMappingURL=dash-case.pipe.js.map

/***/ }),

/***/ 1825:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtPropertyPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtPropertyPipe = /** @class */ (function () {
    function GtPropertyPipe() {
    }
    GtPropertyPipe.prototype.transform = function (config, objectKey, property, refresh) {
        var output = null;
        try {
            for (var i = 0; i < config.length; i++) {
                if (config[i].objectKey === objectKey) {
                    output = config[i][property];
                }
            }
        }
        catch (error) {
            console.log('cannot read property: "' +
                property +
                '" on missing key: "' +
                objectKey +
                '" in config.', error);
        }
        return output;
    };
    GtPropertyPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtProperty'
        })
    ], GtPropertyPipe);
    return GtPropertyPipe;
}());

//# sourceMappingURL=gt-property.pipe.js.map

/***/ }),

/***/ 1826:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtChunkPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtChunkPipe = /** @class */ (function () {
    function GtChunkPipe() {
    }
    GtChunkPipe.prototype.transform = function (array, gtInfo, chunkSize, page, refreshPageArray, refreshData, gtEvent, data) {
        if (!Array.isArray(array)) {
            return array;
        }
        data.exportData = array; // store data for export
        var PAGES = [];
        var ENTRIES = array.length;
        for (var i = 0; i < ENTRIES; i += chunkSize) {
            PAGES.push(array.slice(i, i + chunkSize));
        }
        gtInfo.visibleRecords = !PAGES[page - 1] ? [] : PAGES[page - 1].slice(); // add visible rows
        gtInfo.pageTotal = PAGES.length; // add number of pages
        setTimeout(function () {
            return gtEvent.emit({
                name: 'gt-info',
                value: gtInfo
            });
        }, 0);
        return PAGES[page - 1];
    };
    GtChunkPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtChunk'
        })
    ], GtChunkPipe);
    return GtChunkPipe;
}());

//# sourceMappingURL=gt-chunk.pipe.js.map

/***/ }),

/***/ 1827:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtFilterPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtFilterPipe = /** @class */ (function () {
    function GtFilterPipe() {
    }
    // @Output() filterInfo = new EventEmitter();
    GtFilterPipe.prototype.transform = function (allRows, filterBy, gtInfo, refreshFilter, refreshData) {
        // console.log(allRows,filterBy);
        gtInfo.recordsAll = allRows.length;
        if (!Array.isArray(allRows) || !filterBy) {
            // gtInfo.filtered = false;
            var length_1 = allRows === null ? 0 : allRows.length;
            gtInfo.recordsAfterFilter = length_1;
            return allRows;
        }
        var output = [];
        for (var i = 0; i < allRows.length; i++) {
            var rowObject = allRows[i];
            var match = true;
            for (var property in filterBy) {
                if (filterBy.hasOwnProperty(property)) {
                    // console.log(property);
                    // console.log(filter[property].indexOf(obj[property]));
                    if (filterBy[property].indexOf(rowObject[property]) === -1) {
                        match = false;
                    }
                }
            }
            if (match) {
                output.push(rowObject);
            }
        }
        gtInfo.recordsAfterFilter = output.length; // .emit(output.length);
        return output;
    };
    GtFilterPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtFilter'
        })
    ], GtFilterPipe);
    return GtFilterPipe;
}());

//# sourceMappingURL=gt-filter.pipe.js.map

/***/ }),

/***/ 1828:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtOrderByPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtOrderByPipe = /** @class */ (function () {
    function GtOrderByPipe() {
        /** Return property */
        this.getProperty = function (array, key) {
            for (var i = 0; i < array.length; i++) {
                if (array[i].objectKey === key) {
                    return array[i];
                }
            }
        };
    }
    GtOrderByPipe_1 = GtOrderByPipe;
    GtOrderByPipe._orderByComparator = function (a, b) {
        // sort boolean values as strings
        if (typeof a === 'boolean') {
            a = a.toString();
        }
        if (typeof b === 'boolean') {
            b = b.toString();
        }
        if (isNaN(parseFloat(a)) ||
            !isFinite(a) ||
            (isNaN(parseFloat(b)) || !isFinite(b))) {
            if (b === null ||
                (typeof b === 'undefined' && (a !== null && typeof a !== 'undefined'))) {
                return 1;
            }
            if (a === null ||
                (typeof a === 'undefined' && (b !== null && typeof b !== 'undefined'))) {
                return -1;
            }
            // isn't a number so lowercase the string to properly compare
            try {
                if (a.toLowerCase() < b.toLowerCase()) {
                    return -1;
                }
                if (a.toLowerCase() > b.toLowerCase()) {
                    return 1;
                }
            }
            catch (error) {
                return 0;
            }
        }
        else {
            // parse strings as numbers to compare properly
            if (parseFloat(a) < parseFloat(b)) {
                return -1;
            }
            if (parseFloat(a) > parseFloat(b)) {
                return 1;
            }
        }
        return 0; // equal each other
    };
    /** Return sort function */
    GtOrderByPipe.prototype.getSortFunction = function (field) {
        if (!field) {
            // console.log('error trying to sort undefined field');
            return false;
        }
        if (typeof field.sort === 'function') {
            return field.sort;
        }
        else if (typeof field.value === 'function') {
            return field.value;
        }
        else {
            return false;
        }
    };
    GtOrderByPipe.prototype.transform = function (input, sortByProperties, fields, refreshSorting, refreshData) {
        var _this = this;
        if (!Array.isArray(input) || input === null) {
            return input;
        }
        if (!Array.isArray(sortByProperties) ||
            (Array.isArray(sortByProperties) && sortByProperties.length === 1)) {
            var propertyToCheck = sortByProperties[0];
            var desc_1 = propertyToCheck.substr(0, 1) === '-';
            // basic array
            if (!propertyToCheck ||
                propertyToCheck === '-' ||
                propertyToCheck === '+') {
                return !desc_1 ? input.sort() : input.sort().reverse();
            }
            else {
                var property_1 = propertyToCheck.substr(0, 1) === '+' ||
                    propertyToCheck.substr(0, 1) === '-'
                    ? propertyToCheck.substr(1)
                    : propertyToCheck;
                // check if custom sort function is defined
                var sortFunction_1 = this.getSortFunction(this.getProperty(fields, property_1));
                // console.log(property);
                return input.sort(function (a, b) {
                    // use custom sort function if one is defined
                    var propertyA = sortFunction_1 === false
                        ? property_1 === '$$gtRowId'
                            ? +a.$$gtRowId.split('_')[0]
                            : a[property_1]
                        : sortFunction_1(a);
                    var propertyB = sortFunction_1 === false
                        ? property_1 === '$$gtRowId'
                            ? +b.$$gtRowId.split('_')[0]
                            : b[property_1]
                        : sortFunction_1(b);
                    // if both values are undefined...
                    if (typeof propertyA === 'undefined' &&
                        typeof propertyB === 'undefined') {
                        // ...skip comparison
                        return;
                    }
                    return !desc_1
                        ? GtOrderByPipe_1._orderByComparator(propertyA, propertyB)
                        : -GtOrderByPipe_1._orderByComparator(propertyA, propertyB);
                });
            }
        }
        else {
            // loop over property of the array in order and sort
            return input.sort(function (a, b) {
                // console.log('multiple');
                for (var i = 0; i < sortByProperties.length; i++) {
                    var desc = sortByProperties[i].substr(0, 1) === '-';
                    var property = sortByProperties[i].substr(0, 1) === '+' ||
                        sortByProperties[i].substr(0, 1) === '-'
                        ? sortByProperties[i].substr(1)
                        : sortByProperties[i];
                    // console.log(property);
                    // check if custom sort function is defined
                    var sortFunction = _this.getSortFunction(_this.getProperty(fields, property));
                    // use custom sort function if one is defined
                    var propertyA = sortFunction === false
                        ? property === '$$gtRowId'
                            ? +a.$$gtRowId.split('_')[0]
                            : a[property]
                        : sortFunction(a);
                    var propertyB = sortFunction === false
                        ? property === '$$gtRowId'
                            ? +b.$$gtRowId.split('_')[0]
                            : b[property]
                        : sortFunction(b);
                    var comparison = !desc
                        ? GtOrderByPipe_1._orderByComparator(propertyA, propertyB)
                        : -GtOrderByPipe_1._orderByComparator(propertyA, propertyB);
                    // don't return 0 yet in case of needing to sort by next property
                    if (comparison !== 0) {
                        return comparison;
                    }
                }
                return 0; // equal each other
            });
        }
    };
    GtOrderByPipe = GtOrderByPipe_1 = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtOrderBy'
        })
    ], GtOrderByPipe);
    return GtOrderByPipe;
    var GtOrderByPipe_1;
}());

//# sourceMappingURL=gt-order-by.pipe.js.map

/***/ }),

/***/ 1829:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtSearchPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtSearchPipe = /** @class */ (function () {
    function GtSearchPipe() {
        /** Return property */
        this.getProperty = function (array, key) {
            for (var i = 0; i < array.length; i++) {
                if (array[i].objectKey === key) {
                    return array[i];
                }
            }
        };
    }
    GtSearchPipe.prototype.transform = function (allRows, searchTerms, gtInfo, settings, fields, refreshData) {
        //  if no search terms are defined...
        if (!searchTerms || searchTerms.replace(/"/g, '').length === 0) {
            // ...return all rows
            var length_1 = allRows === null ? 0 : allRows.length;
            gtInfo.recordsAfterSearch = length_1;
            return allRows;
        }
        var searchFunction = {};
        var fieldsTemp = [];
        for (var k = 0; k < fields.length; k++) {
            var field = fields[k];
            // check if field should be included in global search
            var include = this.getProperty(settings, field.objectKey).search === false
                ? false
                : true;
            // if include...
            if (include) {
                // ...and if search function is defined...
                if (typeof field.search === 'function') {
                    // ...add it as search function for field
                    searchFunction[field.objectKey] = field.search;
                }
                else if (typeof field.value === 'function') {
                    // ...add it as search function for field
                    searchFunction[field.objectKey] = field.value;
                }
                // ...push it to our fields array
                fieldsTemp.push(field);
            }
        }
        var filteredRows = [];
        searchTerms = typeof searchTerms === 'undefined' ? '' : searchTerms;
        var searchTermsArray = searchTerms.toLowerCase().match(/(".*"|[^\s]+)/g);
        for (var i = 0; i < allRows.length; i++) {
            var row = allRows[i];
            var string = '';
            for (var j = 0; j < fieldsTemp.length; j++) {
                var separator = j === 0 ? '' : ' & ';
                string += searchFunction[fieldsTemp[j].objectKey]
                    ? separator + searchFunction[fieldsTemp[j].objectKey](row, j)
                    : separator + row[fieldsTemp[j].objectKey];
            }
            string = string.toLowerCase();
            var match = true;
            for (var k = 0; k < searchTermsArray.length; k++) {
                var term = searchTermsArray[k].replace(/"/g, '');
                match = string.indexOf(term) !== -1;
                if (!match) {
                    break;
                }
            }
            if (match) {
                filteredRows.push(row);
            }
        }
        gtInfo.recordsAfterSearch = filteredRows.length;
        // gtInfo.refresh(filteredRows.length,gt);
        return filteredRows;
    };
    GtSearchPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtSearch'
        })
    ], GtSearchPipe);
    return GtSearchPipe;
}());

//# sourceMappingURL=gt-search.pipe.js.map

/***/ }),

/***/ 1830:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ComponentAnchorDirective; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 ComponentAnchorDirective = /** @class */ (function () {
    function ComponentAnchorDirective(componentFactoryResolver, viewContainer) {
        this.componentFactoryResolver = componentFactoryResolver;
        this.viewContainer = viewContainer;
        this.instance = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
    }
    ComponentAnchorDirective.prototype.ngOnInit = function () {
        var factory = this.componentFactoryResolver.resolveComponentFactory(this.ctor);
        var component = this.viewContainer.createComponent(factory, 0, this.injector);
        this.instance.emit(component.instance);
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Type"])
    ], ComponentAnchorDirective.prototype, "ctor", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Injector"])
    ], ComponentAnchorDirective.prototype, "injector", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"])
    ], ComponentAnchorDirective.prototype, "instance", void 0);
    ComponentAnchorDirective = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Directive"])({
            selector: '[gtComponentAnchor]'
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["ComponentFactoryResolver"],
            __WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewContainerRef"]])
    ], ComponentAnchorDirective);
    return ComponentAnchorDirective;
}());

//# sourceMappingURL=component-anchor.directive.js.map

/***/ }),

/***/ 1831:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtPaginationComponent; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return PaginationPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__generic_table_component__ = __webpack_require__(1662);
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 GtPaginationComponent = /** @class */ (function () {
    function GtPaginationComponent() {
        this.ready = false;
    }
    Object.defineProperty(GtPaginationComponent.prototype, "genericTable", {
        get: function () {
            return this._genericTable;
        },
        set: function (value) {
            var _this = this;
            if (value) {
                value.gtEvent.subscribe(function (res) {
                    if (res.name === 'gt-info' && res.value.pageTotal > 0) {
                        _this.ready = true;
                    }
                });
            }
            this._genericTable = value;
        },
        enumerable: true,
        configurable: true
    });
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_1__generic_table_component__["a" /* GenericTableComponent */]),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__generic_table_component__["a" /* GenericTableComponent */]])
    ], GtPaginationComponent.prototype, "genericTable", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String)
    ], GtPaginationComponent.prototype, "gtClasses", void 0);
    GtPaginationComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-pagination',
            template: "<nav class=\"gt-pagination\" aria-label=\"Table navigation\" *ngIf=\"genericTable && genericTable.gtInfo && ready && genericTable.gtData?.length > 0\" [ngClass]=\"{'no-data':genericTable.gtInfo.pageTotal === 0}\">\n  <ul class=\"pagination\" [ngClass]=\"gtClasses\">\n    <li class=\"page-item\" [ngClass]=\"{'disabled' : genericTable.gtInfo.pageCurrent === 1 || genericTable.loading }\"><a class=\"page-link\" href=\"javascript:void(0);\" (click)=\"genericTable.gtInfo.pageCurrent > 1 && genericTable.previousPage()\" [attr.aria-label]=\"genericTable.gtTexts.paginatePrevious\"><span aria-hidden=\"true\">&laquo;</span><span class=\"sr-only\">{{genericTable.gtTexts.paginatePrevious}}</span></a></li>\n    <li class=\"page-item\" [ngClass]=\"{'disabled' : genericTable.loading && genericTable.gtInfo.pageCurrent !== page, 'active' : genericTable.gtInfo.pageCurrent === page }\" *ngFor=\"let page of genericTable.gtInfo.pageTotal | gtPaginationPipe:genericTable.gtInfo.pageCurrent\"><a class=\"page-link\" [tabindex]=\"page === true ? -1:0\" href=\"javascript:void(0);\" (click)=\"page === true ? '':genericTable.goToPage(page)\">{{page === true ? '&hellip;':page}}</a></li>\n    <li class=\"page-item\" [ngClass]=\"{'disabled' : genericTable.gtInfo.pageCurrent === genericTable.gtInfo.pageTotal || genericTable.loading }\"><a class=\"page-link gt-link\" href=\"javascript:void(0);\" (click)=\"genericTable.gtInfo.pageCurrent !== genericTable.gtInfo.pageTotal && genericTable.nextPage()\" [attr.aria-label]=\"genericTable.gtTexts.paginateNext\"><span aria-hidden=\"true\">&raquo;</span><span class=\"sr-only\">{{genericTable.gtTexts.paginateNext}}</span></a></li>\n  </ul>\n  </nav>\n    ",
            styles: ['.gt-link {cursor: pointer;}']
        })
    ], GtPaginationComponent);
    return GtPaginationComponent;
}());


var PaginationPipe = /** @class */ (function () {
    function PaginationPipe() {
    }
    PaginationPipe.prototype.transform = function (totalPages, currentPage) {
        if (totalPages === 0) {
            return [1];
        }
        var pagination = []; // create new empty array for pagination
        var siblings = 2; // sibling elements ie. number of elements on each side of current page
        var paginationLength = totalPages < siblings * 2 + 1 ? totalPages : siblings * 2 + 1; // number of elements in pagination array
        var start = currentPage <= siblings ? 1 : currentPage - siblings; // starting position for array
        var modifier = totalPages - (currentPage + siblings) <= 0
            ? totalPages - (currentPage + siblings)
            : 0; // modifier for pagination values
        var modifiedPosition = start + modifier <= 0 ? 1 : start + modifier;
        // push pages to pagination array
        for (var i = 0; i < paginationLength; i++) {
            pagination.push(modifiedPosition + i);
        }
        // if first page is not included in pagination...
        if (pagination.indexOf(1) === -1) {
            // ...check if second page is in pagination...
            if (pagination.indexOf(2) === -1) {
                // ...if not check if total number of pages equals seven and number of siblings are two...
                if (totalPages === 7 && siblings === 2) {
                    // ...add second page and don't convert page number to ellipsis
                    pagination.unshift(2);
                }
                else {
                    // ...if not, use this placeholder for ellipsis instead of actual page number
                    pagination[0] = true;
                }
            }
            // ...add first page as first array item
            pagination.unshift(1);
        }
        else if (totalPages > paginationLength) {
            // if first page is included add extra page to keep number of items consistent
            pagination.splice(paginationLength, 0, paginationLength + 1);
        }
        // check if last page is included in pagination...
        if (pagination.indexOf(totalPages) === -1) {
            // ...if not, page next to last should either show ellipsis or actual page number for the page
            pagination[pagination.length - 1] =
                pagination[pagination.length - 1] === totalPages - 1
                    ? totalPages - 1
                    : true;
            // ...add last page to pagination
            pagination.push(totalPages);
        }
        return pagination;
    };
    PaginationPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtPaginationPipe'
        })
    ], PaginationPipe);
    return PaginationPipe;
}());

//# sourceMappingURL=gt-pagination.component.js.map

/***/ }),

/***/ 1832:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtTableInfoComponent; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return TableInfoPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__generic_table_component__ = __webpack_require__(1662);
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 GtTableInfoComponent = /** @class */ (function () {
    function GtTableInfoComponent(_changeDetectionRef) {
        this._changeDetectionRef = _changeDetectionRef;
    }
    GtTableInfoComponent.prototype.ngAfterViewChecked = function () {
        this._changeDetectionRef.detectChanges();
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_1__generic_table_component__["a" /* GenericTableComponent */])
    ], GtTableInfoComponent.prototype, "genericTable", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String)
    ], GtTableInfoComponent.prototype, "customText", void 0);
    GtTableInfoComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-table-info',
            template: "<span *ngIf=\"genericTable.gtInfo\">{{(customText? customText:genericTable.gtTexts) | gtTableInfo:\n\t\tgenericTable.gtInfo:\n\t\tgenericTable.gtInfo.recordsAfterSearch:\n\t\tgenericTable.gtInfo.recordFrom:\n\t\tgenericTable.gtInfo.recordTo:\n\t\tgenericTable.gtInfo.recordsAll:\n\t\tgenericTable.gtTexts.loading:\n\t\tgenericTable.gtTexts.tableInfoAfterSearch}}</span>"
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["ChangeDetectorRef"]])
    ], GtTableInfoComponent);
    return GtTableInfoComponent;
}());


var TableInfoPipe = /** @class */ (function () {
    function TableInfoPipe() {
    }
    TableInfoPipe.prototype.transform = function (texts, keys, recordsAfterSearch, recordFrom, recordTo, recordsAll, loading, tableInfoAfterSearch) {
        var text = typeof texts === 'object' ? texts.tableInfo : '';
        if (keys.recordsAfterSearch !== keys.recordsAll) {
            text = typeof texts === 'object' ? texts.tableInfoAfterSearch : '';
        }
        for (var key in keys) {
            if (keys.hasOwnProperty(key)) {
                var searchString = new RegExp('#' + key, 'g');
                text = text.replace(searchString, keys[key]);
            }
        }
        return text;
    };
    TableInfoPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtTableInfo'
        })
    ], TableInfoPipe);
    return TableInfoPipe;
}());

//# sourceMappingURL=gt-table-info.component.js.map

/***/ }),

/***/ 1833:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export GtCustomComponent */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtCustomComponentFactory; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_ReplaySubject__ = __webpack_require__(155);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_ReplaySubject___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_rxjs_ReplaySubject__);
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 GtCustomComponent = /** @class */ (function () {
    function GtCustomComponent() {
        this.redrawEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
        this.$searchTerms = new __WEBPACK_IMPORTED_MODULE_1_rxjs_ReplaySubject__["ReplaySubject"](1);
    }
    GtCustomComponent.prototype.$redraw = function ($event) {
        this.redrawEvent.emit({ row: this.row, column: this.column });
    };
    GtCustomComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.$searchTerms.subscribe(function (terms) { return (_this.searchTerms = terms); });
    };
    return GtCustomComponent;
}());

var GtCustomComponentFactory = /** @class */ (function () {
    function GtCustomComponentFactory() {
        this.$searchTerms = new __WEBPACK_IMPORTED_MODULE_1_rxjs_ReplaySubject__["ReplaySubject"](1);
        this.redrawEvent = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
    }
    Object.defineProperty(GtCustomComponentFactory.prototype, "searchTerms", {
        set: function (value) {
            this.$searchTerms.next(value);
        },
        enumerable: true,
        configurable: true
    });
    GtCustomComponentFactory.prototype.instance = function (instance) {
        instance.row = this.row;
        instance.column = this.column;
        instance.$searchTerms = this.$searchTerms;
        instance.redrawEvent.subscribe(this.redrawEvent);
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String),
        __metadata("design:paramtypes", [String])
    ], GtCustomComponentFactory.prototype, "searchTerms", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Type"])
    ], GtCustomComponentFactory.prototype, "type", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["Injector"])
    ], GtCustomComponentFactory.prototype, "injector", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtCustomComponentFactory.prototype, "row", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtCustomComponentFactory.prototype, "column", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", Object)
    ], GtCustomComponentFactory.prototype, "redrawEvent", void 0);
    GtCustomComponentFactory = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-custom-component-factory',
            template: "<div gtComponentAnchor [ctor]=\"type\"\n                    [injector]=\"injector\"\n                    (instance)=\"instance($event)\"></div>"
        })
    ], GtCustomComponentFactory);
    return GtCustomComponentFactory;
}());

//# sourceMappingURL=gt-custom-component-factory.js.map

/***/ }),

/***/ 1834:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtDropdownComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_Subject__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_Subject___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_rxjs_Subject__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_tether__ = __webpack_require__(1835);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_tether___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_tether__);
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 GtDropdownComponent = /** @class */ (function () {
    function GtDropdownComponent(renderer) {
        this.renderer = renderer;
        this.selectedChange = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
        this.active = false; // is dropdown active or not
        this.state = new __WEBPACK_IMPORTED_MODULE_1_rxjs_Subject__["Subject"](); // current state of dropdown
    }
    Object.defineProperty(GtDropdownComponent.prototype, "selected", {
        get: function () {
            return this._selected;
        },
        set: function (selection) {
            this._selected = selection;
        },
        enumerable: true,
        configurable: true
    });
    GtDropdownComponent.prototype.select = function (option) {
        this.active = false;
        this.state.next(this.active);
        if (this._selected !== option) {
            this.selectedChange.emit(option);
        }
    };
    GtDropdownComponent.prototype.toggleDropdown = function () {
        var _this = this;
        this.active = !this.active;
        setTimeout(function () {
            _this.state.next(_this.active);
        }, 0);
    };
    GtDropdownComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.state.subscribe(function (state) {
            if (state) {
                _this.tether = new __WEBPACK_IMPORTED_MODULE_2_tether__({
                    element: '#' + _this.id + '_menu',
                    target: '#' + _this.id,
                    attachment: 'top left',
                    targetAttachment: 'bottom left',
                    constraints: [
                        {
                            to: 'window',
                            attachment: 'together'
                        }
                    ]
                });
                _this.tether.position();
                // set up click listener and listen for click outside dropdown
                _this.clickListener = _this.renderer.listen('document', 'click', function (event) {
                    _this.active = false;
                    _this.state.next(_this.active);
                });
                // set up keyboard listener and listen for escape key up
                _this.keyupListener = _this.renderer.listen('document', 'keyup', function (event) {
                    switch (event.key) {
                        case 'Escape':
                            _this.active = false;
                            _this.state.next(_this.active);
                            break;
                    }
                });
            }
            else {
                _this.tether.destroy();
                _this.removeListeners();
            }
        });
    };
    GtDropdownComponent.prototype.ngOnDestroy = function () {
        this.removeListeners();
    };
    GtDropdownComponent.prototype.removeListeners = function () {
        if (this.clickListener) {
            this.clickListener();
        }
        if (this.keyupListener) {
            this.keyupListener();
        }
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [Object])
    ], GtDropdownComponent.prototype, "selected", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Array)
    ], GtDropdownComponent.prototype, "options", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String)
    ], GtDropdownComponent.prototype, "id", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"])
    ], GtDropdownComponent.prototype, "selectedChange", void 0);
    GtDropdownComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-dropdown',
            template: "\n        <div class=\"dropdown gt-dropdown\" [ngClass]=\"{'show':active}\" [attr.id]=\"id\">\n            <div class=\"dropdown-toggle\" (click)=\"toggleDropdown()\" [attr.aria-expanded]=\"active\">{{selected}}</div>\n            <div class=\"gt-dropdown-menu dropdown-menu\" *ngIf=\"active\" [ngClass]=\"{'show':active}\" [attr.id]=\"id+'_menu'\">\n                <button *ngFor=\"let option of options;\" class=\"dropdown-item\" (click)=\"select(option)\"\n                        [ngClass]=\"{'active':option === selected}\">{{option}}</button>\n            </div>\n        </div>\n    ",
            styles: [
                "\n            .gt-dropdown .dropdown-toggle {\n                cursor: pointer;\n            }\n\n            .gt-dropdown .dropdown-toggle::after {\n                transition: opacity 0.4s ease-in-out;\n                opacity: 0;\n            }\n\n            .gt-dropdown .dropdown-toggle:hover::after {\n                opacity: 1;\n            }\n        "
            ]
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["Renderer2"]])
    ], GtDropdownComponent);
    return GtDropdownComponent;
}());

//# sourceMappingURL=gt-dropdown.component.js.map

/***/ }),

/***/ 1835:
/***/ (function(module, exports, __webpack_require__) {

var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! tether 1.4.6 */

(function(root, factory) {
  if (true) {
    !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
				__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
				(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  } else if (typeof exports === "object") {
    module.exports = factory();
  } else {
    root.Tether = factory();
  }
})(this, function() {
  "use strict";

  var _createClass = (function() {
    function defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
      }
    }
    return function(Constructor, protoProps, staticProps) {
      if (protoProps) defineProperties(Constructor.prototype, protoProps);
      if (staticProps) defineProperties(Constructor, staticProps);
      return Constructor;
    };
  })();

  function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
  }

  var TetherBase = undefined;
  if (typeof TetherBase === "undefined") {
    TetherBase = { modules: [] };
  }

  var zeroElement = null;

  // Same as native getBoundingClientRect, except it takes into account parent <frame> offsets
  // if the element lies within a nested document (<frame> or <iframe>-like).
  function getActualBoundingClientRect(node) {
    var boundingRect = node.getBoundingClientRect();

    // The original object returned by getBoundingClientRect is immutable, so we clone it
    // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
    var rect = {};
    for (var k in boundingRect) {
      rect[k] = boundingRect[k];
    }

    if (node.ownerDocument !== document) {
      var _frameElement = node.ownerDocument.defaultView.frameElement;
      if (_frameElement) {
        var frameRect = getActualBoundingClientRect(_frameElement);
        rect.top += frameRect.top;
        rect.bottom += frameRect.top;
        rect.left += frameRect.left;
        rect.right += frameRect.left;
      }
    }

    return rect;
  }

  function getScrollParents(el) {
    // In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
    // https://bugzilla.mozilla.org/show_bug.cgi?id=548397
    var computedStyle = getComputedStyle(el) || {};
    var position = computedStyle.position;
    var parents = [];

    if (position === "fixed") {
      return [el];
    }

    var parent = el;
    while ((parent = parent.parentNode) && parent && parent.nodeType === 1) {
      var style = undefined;
      try {
        style = getComputedStyle(parent);
      } catch (err) {}

      if (typeof style === "undefined" || style === null) {
        parents.push(parent);
        return parents;
      }

      var _style = style;
      var overflow = _style.overflow;
      var overflowX = _style.overflowX;
      var overflowY = _style.overflowY;

      if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
        if (
          position !== "absolute" ||
          ["relative", "absolute", "fixed"].indexOf(style.position) >= 0
        ) {
          parents.push(parent);
        }
      }
    }

    parents.push(el.ownerDocument.body);

    // If the node is within a frame, account for the parent window scroll
    if (el.ownerDocument !== document) {
      parents.push(el.ownerDocument.defaultView);
    }

    return parents;
  }

  var uniqueId = (function() {
    var id = 0;
    return function() {
      return ++id;
    };
  })();

  var zeroPosCache = {};
  var getOrigin = function getOrigin() {
    // getBoundingClientRect is unfortunately too accurate.  It introduces a pixel or two of
    // jitter as the user scrolls that messes with our ability to detect if two positions
    // are equivilant or not.  We place an element at the top left of the page that will
    // get the same jitter, so we can cancel the two out.
    var node = zeroElement;
    if (!node || !document.body.contains(node)) {
      node = document.createElement("div");
      node.setAttribute("data-tether-id", uniqueId());
      extend(node.style, {
        top: 0,
        left: 0,
        position: "absolute"
      });

      document.body.appendChild(node);

      zeroElement = node;
    }

    var id = node.getAttribute("data-tether-id");
    if (typeof zeroPosCache[id] === "undefined") {
      zeroPosCache[id] = getActualBoundingClientRect(node);

      // Clear the cache when this position call is done
      defer(function() {
        delete zeroPosCache[id];
      });
    }

    return zeroPosCache[id];
  };

  function removeUtilElements() {
    if (zeroElement) {
      document.body.removeChild(zeroElement);
    }
    zeroElement = null;
  }

  function getBounds(el) {
    var doc = undefined;
    if (el === document) {
      doc = document;
      el = document.documentElement;
    } else {
      doc = el.ownerDocument;
    }

    var docEl = doc.documentElement;

    var box = getActualBoundingClientRect(el);

    var origin = getOrigin();

    box.top -= origin.top;
    box.left -= origin.left;

    if (typeof box.width === "undefined") {
      box.width = document.body.scrollWidth - box.left - box.right;
    }
    if (typeof box.height === "undefined") {
      box.height = document.body.scrollHeight - box.top - box.bottom;
    }

    box.top = box.top - docEl.clientTop;
    box.left = box.left - docEl.clientLeft;
    box.right = doc.body.clientWidth - box.width - box.left;
    box.bottom = doc.body.clientHeight - box.height - box.top;

    return box;
  }

  function getOffsetParent(el) {
    return el.offsetParent || document.documentElement;
  }

  var _scrollBarSize = null;
  function getScrollBarSize() {
    if (_scrollBarSize) {
      return _scrollBarSize;
    }
    var inner = document.createElement("div");
    inner.style.width = "100%";
    inner.style.height = "200px";

    var outer = document.createElement("div");
    extend(outer.style, {
      position: "absolute",
      top: 0,
      left: 0,
      pointerEvents: "none",
      visibility: "hidden",
      width: "200px",
      height: "150px",
      overflow: "hidden"
    });

    outer.appendChild(inner);

    document.body.appendChild(outer);

    var widthContained = inner.offsetWidth;
    outer.style.overflow = "scroll";
    var widthScroll = inner.offsetWidth;

    if (widthContained === widthScroll) {
      widthScroll = outer.clientWidth;
    }

    document.body.removeChild(outer);

    var width = widthContained - widthScroll;

    _scrollBarSize = { width: width, height: width };
    return _scrollBarSize;
  }

  function extend() {
    var out =
      arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

    var args = [];

    Array.prototype.push.apply(args, arguments);

    args.slice(1).forEach(function(obj) {
      if (obj) {
        for (var key in obj) {
          if ({}.hasOwnProperty.call(obj, key)) {
            out[key] = obj[key];
          }
        }
      }
    });

    return out;
  }

  function removeClass(el, name) {
    if (typeof el.classList !== "undefined") {
      name.split(" ").forEach(function(cls) {
        if (cls.trim()) {
          el.classList.remove(cls);
        }
      });
    } else {
      var regex = new RegExp(
        "(^| )" + name.split(" ").join("|") + "( |$)",
        "gi"
      );
      var className = getClassName(el).replace(regex, " ");
      setClassName(el, className);
    }
  }

  function addClass(el, name) {
    if (typeof el.classList !== "undefined") {
      name.split(" ").forEach(function(cls) {
        if (cls.trim()) {
          el.classList.add(cls);
        }
      });
    } else {
      removeClass(el, name);
      var cls = getClassName(el) + (" " + name);
      setClassName(el, cls);
    }
  }

  function hasClass(el, name) {
    if (typeof el.classList !== "undefined") {
      return el.classList.contains(name);
    }
    var className = getClassName(el);
    return new RegExp("(^| )" + name + "( |$)", "gi").test(className);
  }

  function getClassName(el) {
    // Can't use just SVGAnimatedString here since nodes within a Frame in IE have
    // completely separately SVGAnimatedString base classes
    if (
      el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString
    ) {
      return el.className.baseVal;
    }
    return el.className;
  }

  function setClassName(el, className) {
    el.setAttribute("class", className);
  }

  function updateClasses(el, add, all) {
    // Of the set of 'all' classes, we need the 'add' classes, and only the
    // 'add' classes to be set.
    all.forEach(function(cls) {
      if (add.indexOf(cls) === -1 && hasClass(el, cls)) {
        removeClass(el, cls);
      }
    });

    add.forEach(function(cls) {
      if (!hasClass(el, cls)) {
        addClass(el, cls);
      }
    });
  }

  var deferred = [];

  var defer = function defer(fn) {
    deferred.push(fn);
  };

  var flush = function flush() {
    var fn = undefined;
    while ((fn = deferred.pop())) {
      fn();
    }
  };

  var Evented = (function() {
    function Evented() {
      _classCallCheck(this, Evented);
    }

    _createClass(Evented, [
      {
        key: "on",
        value: function on(event, handler, ctx) {
          var once =
            arguments.length <= 3 || arguments[3] === undefined
              ? false
              : arguments[3];

          if (typeof this.bindings === "undefined") {
            this.bindings = {};
          }
          if (typeof this.bindings[event] === "undefined") {
            this.bindings[event] = [];
          }
          this.bindings[event].push({ handler: handler, ctx: ctx, once: once });
        }
      },
      {
        key: "once",
        value: function once(event, handler, ctx) {
          this.on(event, handler, ctx, true);
        }
      },
      {
        key: "off",
        value: function off(event, handler) {
          if (
            typeof this.bindings === "undefined" ||
            typeof this.bindings[event] === "undefined"
          ) {
            return;
          }

          if (typeof handler === "undefined") {
            delete this.bindings[event];
          } else {
            var i = 0;
            while (i < this.bindings[event].length) {
              if (this.bindings[event][i].handler === handler) {
                this.bindings[event].splice(i, 1);
              } else {
                ++i;
              }
            }
          }
        }
      },
      {
        key: "trigger",
        value: function trigger(event) {
          if (typeof this.bindings !== "undefined" && this.bindings[event]) {
            var i = 0;

            for (
              var _len = arguments.length,
                args = Array(_len > 1 ? _len - 1 : 0),
                _key = 1;
              _key < _len;
              _key++
            ) {
              args[_key - 1] = arguments[_key];
            }

            while (i < this.bindings[event].length) {
              var _bindings$event$i = this.bindings[event][i];
              var handler = _bindings$event$i.handler;
              var ctx = _bindings$event$i.ctx;
              var once = _bindings$event$i.once;

              var context = ctx;
              if (typeof context === "undefined") {
                context = this;
              }

              handler.apply(context, args);

              if (once) {
                this.bindings[event].splice(i, 1);
              } else {
                ++i;
              }
            }
          }
        }
      }
    ]);

    return Evented;
  })();

  TetherBase.Utils = {
    getActualBoundingClientRect: getActualBoundingClientRect,
    getScrollParents: getScrollParents,
    getBounds: getBounds,
    getOffsetParent: getOffsetParent,
    extend: extend,
    addClass: addClass,
    removeClass: removeClass,
    hasClass: hasClass,
    updateClasses: updateClasses,
    defer: defer,
    flush: flush,
    uniqueId: uniqueId,
    Evented: Evented,
    getScrollBarSize: getScrollBarSize,
    removeUtilElements: removeUtilElements
  };
  /* globals TetherBase, performance */

  ("use strict");

  var _slicedToArray = (function() {
    function sliceIterator(arr, i) {
      var _arr = [];
      var _n = true;
      var _d = false;
      var _e = undefined;
      try {
        for (
          var _i = arr[Symbol.iterator](), _s;
          !(_n = (_s = _i.next()).done);
          _n = true
        ) {
          _arr.push(_s.value);
          if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;
        _e = err;
      } finally {
        try {
          if (!_n && _i["return"]) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }
      return _arr;
    }
    return function(arr, i) {
      if (Array.isArray(arr)) {
        return arr;
      } else if (Symbol.iterator in Object(arr)) {
        return sliceIterator(arr, i);
      } else {
        throw new TypeError(
          "Invalid attempt to destructure non-iterable instance"
        );
      }
    };
  })();

  var _createClass = (function() {
    function defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
      }
    }
    return function(Constructor, protoProps, staticProps) {
      if (protoProps) defineProperties(Constructor.prototype, protoProps);
      if (staticProps) defineProperties(Constructor, staticProps);
      return Constructor;
    };
  })();

  var _get = function get(_x6, _x7, _x8) {
    var _again = true;
    _function: while (_again) {
      var object = _x6,
        property = _x7,
        receiver = _x8;
      _again = false;
      if (object === null) object = Function.prototype;
      var desc = Object.getOwnPropertyDescriptor(object, property);
      if (desc === undefined) {
        var parent = Object.getPrototypeOf(object);
        if (parent === null) {
          return undefined;
        } else {
          _x6 = parent;
          _x7 = property;
          _x8 = receiver;
          _again = true;
          desc = parent = undefined;
          continue _function;
        }
      } else if ("value" in desc) {
        return desc.value;
      } else {
        var getter = desc.get;
        if (getter === undefined) {
          return undefined;
        }
        return getter.call(receiver);
      }
    }
  };

  function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
  }

  function _inherits(subClass, superClass) {
    if (typeof superClass !== "function" && superClass !== null) {
      throw new TypeError(
        "Super expression must either be null or a function, not " +
          typeof superClass
      );
    }
    subClass.prototype = Object.create(superClass && superClass.prototype, {
      constructor: {
        value: subClass,
        enumerable: false,
        writable: true,
        configurable: true
      }
    });
    if (superClass)
      Object.setPrototypeOf
        ? Object.setPrototypeOf(subClass, superClass)
        : (subClass.__proto__ = superClass);
  }

  if (typeof TetherBase === "undefined") {
    throw new Error("You must include the utils.js file before tether.js");
  }

  var _TetherBase$Utils = TetherBase.Utils;
  var getScrollParents = _TetherBase$Utils.getScrollParents;
  var getBounds = _TetherBase$Utils.getBounds;
  var getOffsetParent = _TetherBase$Utils.getOffsetParent;
  var extend = _TetherBase$Utils.extend;
  var addClass = _TetherBase$Utils.addClass;
  var removeClass = _TetherBase$Utils.removeClass;
  var updateClasses = _TetherBase$Utils.updateClasses;
  var defer = _TetherBase$Utils.defer;
  var flush = _TetherBase$Utils.flush;
  var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
  var removeUtilElements = _TetherBase$Utils.removeUtilElements;

  function within(a, b) {
    var diff =
      arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];

    return a + diff >= b && b >= a - diff;
  }

  var transformKey = (function() {
    if (typeof document === "undefined") {
      return "";
    }
    var el = document.createElement("div");

    var transforms = [
      "transform",
      "WebkitTransform",
      "OTransform",
      "MozTransform",
      "msTransform"
    ];
    for (var i = 0; i < transforms.length; ++i) {
      var key = transforms[i];
      if (el.style[key] !== undefined) {
        return key;
      }
    }
  })();

  var tethers = [];

  var position = function position() {
    tethers.forEach(function(tether) {
      tether.position(false);
    });
    flush();
  };

  function now() {
    if (
      typeof performance === "object" &&
      typeof performance.now === "function"
    ) {
      return performance.now();
    }
    return +new Date();
  }

  (function() {
    var lastCall = null;
    var lastDuration = null;
    var pendingTimeout = null;

    var tick = function tick() {
      if (typeof lastDuration !== "undefined" && lastDuration > 16) {
        // We voluntarily throttle ourselves if we can't manage 60fps
        lastDuration = Math.min(lastDuration - 16, 250);

        // Just in case this is the last event, remember to position just once more
        pendingTimeout = setTimeout(tick, 250);
        return;
      }

      if (typeof lastCall !== "undefined" && now() - lastCall < 10) {
        // Some browsers call events a little too frequently, refuse to run more than is reasonable
        return;
      }

      if (pendingTimeout != null) {
        clearTimeout(pendingTimeout);
        pendingTimeout = null;
      }

      lastCall = now();
      position();
      lastDuration = now() - lastCall;
    };

    if (
      typeof window !== "undefined" &&
      typeof window.addEventListener !== "undefined"
    ) {
      ["resize", "scroll", "touchmove"].forEach(function(event) {
        window.addEventListener(event, tick);
      });
    }
  })();

  var MIRROR_LR = {
    center: "center",
    left: "right",
    right: "left"
  };

  var MIRROR_TB = {
    middle: "middle",
    top: "bottom",
    bottom: "top"
  };

  var OFFSET_MAP = {
    top: 0,
    left: 0,
    middle: "50%",
    center: "50%",
    bottom: "100%",
    right: "100%"
  };

  var autoToFixedAttachment = function autoToFixedAttachment(
    attachment,
    relativeToAttachment
  ) {
    var left = attachment.left;
    var top = attachment.top;

    if (left === "auto") {
      left = MIRROR_LR[relativeToAttachment.left];
    }

    if (top === "auto") {
      top = MIRROR_TB[relativeToAttachment.top];
    }

    return { left: left, top: top };
  };

  var attachmentToOffset = function attachmentToOffset(attachment) {
    var left = attachment.left;
    var top = attachment.top;

    if (typeof OFFSET_MAP[attachment.left] !== "undefined") {
      left = OFFSET_MAP[attachment.left];
    }

    if (typeof OFFSET_MAP[attachment.top] !== "undefined") {
      top = OFFSET_MAP[attachment.top];
    }

    return { left: left, top: top };
  };

  function addOffset() {
    var out = { top: 0, left: 0 };

    for (
      var _len = arguments.length, offsets = Array(_len), _key = 0;
      _key < _len;
      _key++
    ) {
      offsets[_key] = arguments[_key];
    }

    offsets.forEach(function(_ref) {
      var top = _ref.top;
      var left = _ref.left;

      if (typeof top === "string") {
        top = parseFloat(top, 10);
      }
      if (typeof left === "string") {
        left = parseFloat(left, 10);
      }

      out.top += top;
      out.left += left;
    });

    return out;
  }

  function offsetToPx(offset, size) {
    if (typeof offset.left === "string" && offset.left.indexOf("%") !== -1) {
      offset.left = (parseFloat(offset.left, 10) / 100) * size.width;
    }
    if (typeof offset.top === "string" && offset.top.indexOf("%") !== -1) {
      offset.top = (parseFloat(offset.top, 10) / 100) * size.height;
    }

    return offset;
  }

  var parseOffset = function parseOffset(value) {
    var _value$split = value.split(" ");

    var _value$split2 = _slicedToArray(_value$split, 2);

    var top = _value$split2[0];
    var left = _value$split2[1];

    return { top: top, left: left };
  };
  var parseAttachment = parseOffset;

  var TetherClass = (function(_Evented) {
    _inherits(TetherClass, _Evented);

    function TetherClass(options) {
      var _this = this;

      _classCallCheck(this, TetherClass);

      _get(
        Object.getPrototypeOf(TetherClass.prototype),
        "constructor",
        this
      ).call(this);
      this.position = this.position.bind(this);

      tethers.push(this);

      this.history = [];

      this.setOptions(options, false);

      TetherBase.modules.forEach(function(module) {
        if (typeof module.initialize !== "undefined") {
          module.initialize.call(_this);
        }
      });

      this.position();
    }

    _createClass(TetherClass, [
      {
        key: "getClass",
        value: function getClass() {
          var key =
            arguments.length <= 0 || arguments[0] === undefined
              ? ""
              : arguments[0];
          var classes = this.options.classes;

          if (typeof classes !== "undefined" && classes[key]) {
            return this.options.classes[key];
          } else if (this.options.classPrefix) {
            return this.options.classPrefix + "-" + key;
          } else {
            return key;
          }
        }
      },
      {
        key: "setOptions",
        value: function setOptions(options) {
          var _this2 = this;

          var pos =
            arguments.length <= 1 || arguments[1] === undefined
              ? true
              : arguments[1];

          var defaults = {
            offset: "0 0",
            targetOffset: "0 0",
            targetAttachment: "auto auto",
            classPrefix: "tether"
          };

          this.options = extend(defaults, options);

          var _options = this.options;
          var element = _options.element;
          var target = _options.target;
          var targetModifier = _options.targetModifier;

          this.element = element;
          this.target = target;
          this.targetModifier = targetModifier;

          if (this.target === "viewport") {
            this.target = document.body;
            this.targetModifier = "visible";
          } else if (this.target === "scroll-handle") {
            this.target = document.body;
            this.targetModifier = "scroll-handle";
          }

          ["element", "target"].forEach(function(key) {
            if (typeof _this2[key] === "undefined") {
              throw new Error(
                "Tether Error: Both element and target must be defined"
              );
            }

            if (typeof _this2[key].jquery !== "undefined") {
              _this2[key] = _this2[key][0];
            } else if (typeof _this2[key] === "string") {
              _this2[key] = document.querySelector(_this2[key]);
            }
          });

          addClass(this.element, this.getClass("element"));
          if (!(this.options.addTargetClasses === false)) {
            addClass(this.target, this.getClass("target"));
          }

          if (!this.options.attachment) {
            throw new Error("Tether Error: You must provide an attachment");
          }

          this.targetAttachment = parseAttachment(
            this.options.targetAttachment
          );
          this.attachment = parseAttachment(this.options.attachment);
          this.offset = parseOffset(this.options.offset);
          this.targetOffset = parseOffset(this.options.targetOffset);

          if (typeof this.scrollParents !== "undefined") {
            this.disable();
          }

          if (this.targetModifier === "scroll-handle") {
            this.scrollParents = [this.target];
          } else {
            this.scrollParents = getScrollParents(this.target);
          }

          if (!(this.options.enabled === false)) {
            this.enable(pos);
          }
        }
      },
      {
        key: "getTargetBounds",
        value: function getTargetBounds() {
          if (typeof this.targetModifier !== "undefined") {
            if (this.targetModifier === "visible") {
              if (this.target === document.body) {
                return {
                  top: pageYOffset,
                  left: pageXOffset,
                  height: innerHeight,
                  width: innerWidth
                };
              } else {
                var bounds = getBounds(this.target);

                var out = {
                  height: bounds.height,
                  width: bounds.width,
                  top: bounds.top,
                  left: bounds.left
                };

                out.height = Math.min(
                  out.height,
                  bounds.height - (pageYOffset - bounds.top)
                );
                out.height = Math.min(
                  out.height,
                  bounds.height -
                    (bounds.top + bounds.height - (pageYOffset + innerHeight))
                );
                out.height = Math.min(innerHeight, out.height);
                out.height -= 2;

                out.width = Math.min(
                  out.width,
                  bounds.width - (pageXOffset - bounds.left)
                );
                out.width = Math.min(
                  out.width,
                  bounds.width -
                    (bounds.left + bounds.width - (pageXOffset + innerWidth))
                );
                out.width = Math.min(innerWidth, out.width);
                out.width -= 2;

                if (out.top < pageYOffset) {
                  out.top = pageYOffset;
                }
                if (out.left < pageXOffset) {
                  out.left = pageXOffset;
                }

                return out;
              }
            } else if (this.targetModifier === "scroll-handle") {
              var bounds = undefined;
              var target = this.target;
              if (target === document.body) {
                target = document.documentElement;

                bounds = {
                  left: pageXOffset,
                  top: pageYOffset,
                  height: innerHeight,
                  width: innerWidth
                };
              } else {
                bounds = getBounds(target);
              }

              var style = getComputedStyle(target);

              var hasBottomScroll =
                target.scrollWidth > target.clientWidth ||
                [style.overflow, style.overflowX].indexOf("scroll") >= 0 ||
                this.target !== document.body;

              var scrollBottom = 0;
              if (hasBottomScroll) {
                scrollBottom = 15;
              }

              var height =
                bounds.height -
                parseFloat(style.borderTopWidth) -
                parseFloat(style.borderBottomWidth) -
                scrollBottom;

              var out = {
                width: 15,
                height: height * 0.975 * (height / target.scrollHeight),
                left:
                  bounds.left +
                  bounds.width -
                  parseFloat(style.borderLeftWidth) -
                  15
              };

              var fitAdj = 0;
              if (height < 408 && this.target === document.body) {
                fitAdj =
                  -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58;
              }

              if (this.target !== document.body) {
                out.height = Math.max(out.height, 24);
              }

              var scrollPercentage =
                this.target.scrollTop / (target.scrollHeight - height);
              out.top =
                scrollPercentage * (height - out.height - fitAdj) +
                bounds.top +
                parseFloat(style.borderTopWidth);

              if (this.target === document.body) {
                out.height = Math.max(out.height, 24);
              }

              return out;
            }
          } else {
            return getBounds(this.target);
          }
        }
      },
      {
        key: "clearCache",
        value: function clearCache() {
          this._cache = {};
        }
      },
      {
        key: "cache",
        value: function cache(k, getter) {
          // More than one module will often need the same DOM info, so
          // we keep a cache which is cleared on each position call
          if (typeof this._cache === "undefined") {
            this._cache = {};
          }

          if (typeof this._cache[k] === "undefined") {
            this._cache[k] = getter.call(this);
          }

          return this._cache[k];
        }
      },
      {
        key: "enable",
        value: function enable() {
          var _this3 = this;

          var pos =
            arguments.length <= 0 || arguments[0] === undefined
              ? true
              : arguments[0];

          if (!(this.options.addTargetClasses === false)) {
            addClass(this.target, this.getClass("enabled"));
          }
          addClass(this.element, this.getClass("enabled"));
          this.enabled = true;

          this.scrollParents.forEach(function(parent) {
            if (parent !== _this3.target.ownerDocument) {
              parent.addEventListener("scroll", _this3.position);
            }
          });

          if (pos) {
            this.position();
          }
        }
      },
      {
        key: "disable",
        value: function disable() {
          var _this4 = this;

          removeClass(this.target, this.getClass("enabled"));
          removeClass(this.element, this.getClass("enabled"));
          this.enabled = false;

          if (typeof this.scrollParents !== "undefined") {
            this.scrollParents.forEach(function(parent) {
              parent.removeEventListener("scroll", _this4.position);
            });
          }
        }
      },
      {
        key: "destroy",
        value: function destroy() {
          var _this5 = this;

          this.disable();

          tethers.forEach(function(tether, i) {
            if (tether === _this5) {
              tethers.splice(i, 1);
            }
          });

          // Remove any elements we were using for convenience from the DOM
          if (tethers.length === 0) {
            removeUtilElements();
          }
        }
      },
      {
        key: "updateAttachClasses",
        value: function updateAttachClasses(elementAttach, targetAttach) {
          var _this6 = this;

          elementAttach = elementAttach || this.attachment;
          targetAttach = targetAttach || this.targetAttachment;
          var sides = ["left", "top", "bottom", "right", "middle", "center"];

          if (
            typeof this._addAttachClasses !== "undefined" &&
            this._addAttachClasses.length
          ) {
            // updateAttachClasses can be called more than once in a position call, so
            // we need to clean up after ourselves such that when the last defer gets
            // ran it doesn't add any extra classes from previous calls.
            this._addAttachClasses.splice(0, this._addAttachClasses.length);
          }

          if (typeof this._addAttachClasses === "undefined") {
            this._addAttachClasses = [];
          }
          var add = this._addAttachClasses;

          if (elementAttach.top) {
            add.push(
              this.getClass("element-attached") + "-" + elementAttach.top
            );
          }
          if (elementAttach.left) {
            add.push(
              this.getClass("element-attached") + "-" + elementAttach.left
            );
          }
          if (targetAttach.top) {
            add.push(this.getClass("target-attached") + "-" + targetAttach.top);
          }
          if (targetAttach.left) {
            add.push(
              this.getClass("target-attached") + "-" + targetAttach.left
            );
          }

          var all = [];
          sides.forEach(function(side) {
            all.push(_this6.getClass("element-attached") + "-" + side);
            all.push(_this6.getClass("target-attached") + "-" + side);
          });

          defer(function() {
            if (!(typeof _this6._addAttachClasses !== "undefined")) {
              return;
            }

            updateClasses(_this6.element, _this6._addAttachClasses, all);
            if (!(_this6.options.addTargetClasses === false)) {
              updateClasses(_this6.target, _this6._addAttachClasses, all);
            }

            delete _this6._addAttachClasses;
          });
        }
      },
      {
        key: "position",
        value: function position() {
          var _this7 = this;

          var flushChanges =
            arguments.length <= 0 || arguments[0] === undefined
              ? true
              : arguments[0];

          // flushChanges commits the changes immediately, leave true unless you are positioning multiple
          // tethers (in which case call Tether.Utils.flush yourself when you're done)

          if (!this.enabled) {
            return;
          }

          this.clearCache();

          // Turn 'auto' attachments into the appropriate corner or edge
          var targetAttachment = autoToFixedAttachment(
            this.targetAttachment,
            this.attachment
          );

          this.updateAttachClasses(this.attachment, targetAttachment);

          var elementPos = this.cache("element-bounds", function() {
            return getBounds(_this7.element);
          });

          var width = elementPos.width;
          var height = elementPos.height;

          if (
            width === 0 &&
            height === 0 &&
            typeof this.lastSize !== "undefined"
          ) {
            var _lastSize = this.lastSize;

            // We cache the height and width to make it possible to position elements that are
            // getting hidden.
            width = _lastSize.width;
            height = _lastSize.height;
          } else {
            this.lastSize = { width: width, height: height };
          }

          var targetPos = this.cache("target-bounds", function() {
            return _this7.getTargetBounds();
          });
          var targetSize = targetPos;

          // Get an actual px offset from the attachment
          var offset = offsetToPx(attachmentToOffset(this.attachment), {
            width: width,
            height: height
          });
          var targetOffset = offsetToPx(
            attachmentToOffset(targetAttachment),
            targetSize
          );

          var manualOffset = offsetToPx(this.offset, {
            width: width,
            height: height
          });
          var manualTargetOffset = offsetToPx(this.targetOffset, targetSize);

          // Add the manually provided offset
          offset = addOffset(offset, manualOffset);
          targetOffset = addOffset(targetOffset, manualTargetOffset);

          // It's now our goal to make (element position + offset) == (target position + target offset)
          var left = targetPos.left + targetOffset.left - offset.left;
          var top = targetPos.top + targetOffset.top - offset.top;

          for (var i = 0; i < TetherBase.modules.length; ++i) {
            var _module2 = TetherBase.modules[i];
            var ret = _module2.position.call(this, {
              left: left,
              top: top,
              targetAttachment: targetAttachment,
              targetPos: targetPos,
              elementPos: elementPos,
              offset: offset,
              targetOffset: targetOffset,
              manualOffset: manualOffset,
              manualTargetOffset: manualTargetOffset,
              scrollbarSize: scrollbarSize,
              attachment: this.attachment
            });

            if (ret === false) {
              return false;
            } else if (typeof ret === "undefined" || typeof ret !== "object") {
              continue;
            } else {
              top = ret.top;
              left = ret.left;
            }
          }

          // We describe the position three different ways to give the optimizer
          // a chance to decide the best possible way to position the element
          // with the fewest repaints.
          var next = {
            // It's position relative to the page (absolute positioning when
            // the element is a child of the body)
            page: {
              top: top,
              left: left
            },

            // It's position relative to the viewport (fixed positioning)
            viewport: {
              top: top - pageYOffset,
              bottom: pageYOffset - top - height + innerHeight,
              left: left - pageXOffset,
              right: pageXOffset - left - width + innerWidth
            }
          };

          var doc = this.target.ownerDocument;
          var win = doc.defaultView;

          var scrollbarSize = undefined;
          if (win.innerHeight > doc.documentElement.clientHeight) {
            scrollbarSize = this.cache("scrollbar-size", getScrollBarSize);
            next.viewport.bottom -= scrollbarSize.height;
          }

          if (win.innerWidth > doc.documentElement.clientWidth) {
            scrollbarSize = this.cache("scrollbar-size", getScrollBarSize);
            next.viewport.right -= scrollbarSize.width;
          }

          if (
            ["", "static"].indexOf(doc.body.style.position) === -1 ||
            ["", "static"].indexOf(doc.body.parentElement.style.position) === -1
          ) {
            // Absolute positioning in the body will be relative to the page, not the 'initial containing block'
            next.page.bottom = doc.body.scrollHeight - top - height;
            next.page.right = doc.body.scrollWidth - left - width;
          }

          if (
            typeof this.options.optimizations !== "undefined" &&
            this.options.optimizations.moveElement !== false &&
            !(typeof this.targetModifier !== "undefined")
          ) {
            (function() {
              var offsetParent = _this7.cache(
                "target-offsetparent",
                function() {
                  return getOffsetParent(_this7.target);
                }
              );
              var offsetPosition = _this7.cache(
                "target-offsetparent-bounds",
                function() {
                  return getBounds(offsetParent);
                }
              );
              var offsetParentStyle = getComputedStyle(offsetParent);
              var offsetParentSize = offsetPosition;

              var offsetBorder = {};
              ["Top", "Left", "Bottom", "Right"].forEach(function(side) {
                offsetBorder[side.toLowerCase()] = parseFloat(
                  offsetParentStyle["border" + side + "Width"]
                );
              });

              offsetPosition.right =
                doc.body.scrollWidth -
                offsetPosition.left -
                offsetParentSize.width +
                offsetBorder.right;
              offsetPosition.bottom =
                doc.body.scrollHeight -
                offsetPosition.top -
                offsetParentSize.height +
                offsetBorder.bottom;

              if (
                next.page.top >= offsetPosition.top + offsetBorder.top &&
                next.page.bottom >= offsetPosition.bottom
              ) {
                if (
                  next.page.left >= offsetPosition.left + offsetBorder.left &&
                  next.page.right >= offsetPosition.right
                ) {
                  // We're within the visible part of the target's scroll parent
                  var scrollTop = offsetParent.scrollTop;
                  var scrollLeft = offsetParent.scrollLeft;

                  // It's position relative to the target's offset parent (absolute positioning when
                  // the element is moved to be a child of the target's offset parent).
                  next.offset = {
                    top:
                      next.page.top -
                      offsetPosition.top +
                      scrollTop -
                      offsetBorder.top,
                    left:
                      next.page.left -
                      offsetPosition.left +
                      scrollLeft -
                      offsetBorder.left
                  };
                }
              }
            })();
          }

          // We could also travel up the DOM and try each containing context, rather than only
          // looking at the body, but we're gonna get diminishing returns.

          this.move(next);

          this.history.unshift(next);

          if (this.history.length > 3) {
            this.history.pop();
          }

          if (flushChanges) {
            flush();
          }

          return true;
        }

        // THE ISSUE
      },
      {
        key: "move",
        value: function move(pos) {
          var _this8 = this;

          if (!(typeof this.element.parentNode !== "undefined")) {
            return;
          }

          var same = {};

          for (var type in pos) {
            same[type] = {};

            for (var key in pos[type]) {
              var found = false;

              for (var i = 0; i < this.history.length; ++i) {
                var point = this.history[i];
                if (
                  typeof point[type] !== "undefined" &&
                  !within(point[type][key], pos[type][key])
                ) {
                  found = true;
                  break;
                }
              }

              if (!found) {
                same[type][key] = true;
              }
            }
          }

          var css = { top: "", left: "", right: "", bottom: "" };

          var transcribe = function transcribe(_same, _pos) {
            var hasOptimizations =
              typeof _this8.options.optimizations !== "undefined";
            var gpu = hasOptimizations
              ? _this8.options.optimizations.gpu
              : null;
            if (gpu !== false) {
              var yPos = undefined,
                xPos = undefined;
              if (_same.top) {
                css.top = 0;
                yPos = _pos.top;
              } else {
                css.bottom = 0;
                yPos = -_pos.bottom;
              }

              if (_same.left) {
                css.left = 0;
                xPos = _pos.left;
              } else {
                css.right = 0;
                xPos = -_pos.right;
              }

              if (
                typeof window.devicePixelRatio === "number" &&
                devicePixelRatio % 1 === 0
              ) {
                xPos = Math.round(xPos * devicePixelRatio) / devicePixelRatio;
                yPos = Math.round(yPos * devicePixelRatio) / devicePixelRatio;
              }

              css[transformKey] =
                "translateX(" + xPos + "px) translateY(" + yPos + "px)";

              if (transformKey !== "msTransform") {
                // The Z transform will keep this in the GPU (faster, and prevents artifacts),
                // but IE9 doesn't support 3d transforms and will choke.
                css[transformKey] += " translateZ(0)";
              }
            } else {
              if (_same.top) {
                css.top = _pos.top + "px";
              } else {
                css.bottom = _pos.bottom + "px";
              }

              if (_same.left) {
                css.left = _pos.left + "px";
              } else {
                css.right = _pos.right + "px";
              }
            }
          };

          var moved = false;
          if (
            (same.page.top || same.page.bottom) &&
            (same.page.left || same.page.right)
          ) {
            css.position = "absolute";
            transcribe(same.page, pos.page);
          } else if (
            (same.viewport.top || same.viewport.bottom) &&
            (same.viewport.left || same.viewport.right)
          ) {
            css.position = "fixed";
            transcribe(same.viewport, pos.viewport);
          } else if (
            typeof same.offset !== "undefined" &&
            same.offset.top &&
            same.offset.left
          ) {
            (function() {
              css.position = "absolute";
              var offsetParent = _this8.cache(
                "target-offsetparent",
                function() {
                  return getOffsetParent(_this8.target);
                }
              );

              if (getOffsetParent(_this8.element) !== offsetParent) {
                defer(function() {
                  _this8.element.parentNode.removeChild(_this8.element);
                  offsetParent.appendChild(_this8.element);
                });
              }

              transcribe(same.offset, pos.offset);
              moved = true;
            })();
          } else {
            css.position = "absolute";
            transcribe({ top: true, left: true }, pos.page);
          }

          if (!moved) {
            if (this.options.bodyElement) {
              if (this.element.parentNode !== this.options.bodyElement) {
                this.options.bodyElement.appendChild(this.element);
              }
            } else {
              var isFullscreenElement = function isFullscreenElement(e) {
                var d = e.ownerDocument;
                var fe =
                  d.fullscreenElement ||
                  d.webkitFullscreenElement ||
                  d.mozFullScreenElement ||
                  d.msFullscreenElement;
                return fe === e;
              };

              var offsetParentIsBody = true;

              var currentNode = this.element.parentNode;
              while (
                currentNode &&
                currentNode.nodeType === 1 &&
                currentNode.tagName !== "BODY" &&
                !isFullscreenElement(currentNode)
              ) {
                if (getComputedStyle(currentNode).position !== "static") {
                  offsetParentIsBody = false;
                  break;
                }

                currentNode = currentNode.parentNode;
              }

              if (!offsetParentIsBody) {
                this.element.parentNode.removeChild(this.element);
                this.element.ownerDocument.body.appendChild(this.element);
              }
            }
          }

          // Any css change will trigger a repaint, so let's avoid one if nothing changed
          var writeCSS = {};
          var write = false;
          for (var key in css) {
            var val = css[key];
            var elVal = this.element.style[key];

            if (elVal !== val) {
              write = true;
              writeCSS[key] = val;
            }
          }

          if (write) {
            defer(function() {
              extend(_this8.element.style, writeCSS);
              _this8.trigger("repositioned");
            });
          }
        }
      }
    ]);

    return TetherClass;
  })(Evented);

  TetherClass.modules = [];

  TetherBase.position = position;

  var Tether = extend(TetherClass, TetherBase);
  /* globals TetherBase */

  ("use strict");

  var _slicedToArray = (function() {
    function sliceIterator(arr, i) {
      var _arr = [];
      var _n = true;
      var _d = false;
      var _e = undefined;
      try {
        for (
          var _i = arr[Symbol.iterator](), _s;
          !(_n = (_s = _i.next()).done);
          _n = true
        ) {
          _arr.push(_s.value);
          if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;
        _e = err;
      } finally {
        try {
          if (!_n && _i["return"]) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }
      return _arr;
    }
    return function(arr, i) {
      if (Array.isArray(arr)) {
        return arr;
      } else if (Symbol.iterator in Object(arr)) {
        return sliceIterator(arr, i);
      } else {
        throw new TypeError(
          "Invalid attempt to destructure non-iterable instance"
        );
      }
    };
  })();

  var _TetherBase$Utils = TetherBase.Utils;
  var getBounds = _TetherBase$Utils.getBounds;
  var extend = _TetherBase$Utils.extend;
  var updateClasses = _TetherBase$Utils.updateClasses;
  var defer = _TetherBase$Utils.defer;

  var BOUNDS_FORMAT = ["left", "top", "right", "bottom"];

  function getBoundingRect(tether, to) {
    if (to === "scrollParent") {
      to = tether.scrollParents[0];
    } else if (to === "window") {
      to = [
        pageXOffset,
        pageYOffset,
        innerWidth + pageXOffset,
        innerHeight + pageYOffset
      ];
    }

    if (to === document) {
      to = to.documentElement;
    }

    if (typeof to.nodeType !== "undefined") {
      (function() {
        var node = to;
        var size = getBounds(to);
        var pos = size;
        var style = getComputedStyle(to);

        to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];

        // Account any parent Frames scroll offset
        if (node.ownerDocument !== document) {
          var win = node.ownerDocument.defaultView;
          to[0] += win.pageXOffset;
          to[1] += win.pageYOffset;
          to[2] += win.pageXOffset;
          to[3] += win.pageYOffset;
        }

        BOUNDS_FORMAT.forEach(function(side, i) {
          side = side[0].toUpperCase() + side.substr(1);
          if (side === "Top" || side === "Left") {
            to[i] += parseFloat(style["border" + side + "Width"]);
          } else {
            to[i] -= parseFloat(style["border" + side + "Width"]);
          }
        });
      })();
    }

    return to;
  }

  TetherBase.modules.push({
    position: function position(_ref) {
      var _this = this;

      var top = _ref.top;
      var left = _ref.left;
      var targetAttachment = _ref.targetAttachment;

      if (!this.options.constraints) {
        return true;
      }

      var _cache = this.cache("element-bounds", function() {
        return getBounds(_this.element);
      });

      var height = _cache.height;
      var width = _cache.width;

      if (width === 0 && height === 0 && typeof this.lastSize !== "undefined") {
        var _lastSize = this.lastSize;

        // Handle the item getting hidden as a result of our positioning without glitching
        // the classes in and out
        width = _lastSize.width;
        height = _lastSize.height;
      }

      var targetSize = this.cache("target-bounds", function() {
        return _this.getTargetBounds();
      });

      var targetHeight = targetSize.height;
      var targetWidth = targetSize.width;

      var allClasses = [
        this.getClass("pinned"),
        this.getClass("out-of-bounds")
      ];

      this.options.constraints.forEach(function(constraint) {
        var outOfBoundsClass = constraint.outOfBoundsClass;
        var pinnedClass = constraint.pinnedClass;

        if (outOfBoundsClass) {
          allClasses.push(outOfBoundsClass);
        }
        if (pinnedClass) {
          allClasses.push(pinnedClass);
        }
      });

      allClasses.forEach(function(cls) {
        ["left", "top", "right", "bottom"].forEach(function(side) {
          allClasses.push(cls + "-" + side);
        });
      });

      var addClasses = [];

      var tAttachment = extend({}, targetAttachment);
      var eAttachment = extend({}, this.attachment);

      this.options.constraints.forEach(function(constraint) {
        var to = constraint.to;
        var attachment = constraint.attachment;
        var pin = constraint.pin;

        if (typeof attachment === "undefined") {
          attachment = "";
        }

        var changeAttachX = undefined,
          changeAttachY = undefined;
        if (attachment.indexOf(" ") >= 0) {
          var _attachment$split = attachment.split(" ");

          var _attachment$split2 = _slicedToArray(_attachment$split, 2);

          changeAttachY = _attachment$split2[0];
          changeAttachX = _attachment$split2[1];
        } else {
          changeAttachX = changeAttachY = attachment;
        }

        var bounds = getBoundingRect(_this, to);

        if (changeAttachY === "target" || changeAttachY === "both") {
          if (top < bounds[1] && tAttachment.top === "top") {
            top += targetHeight;
            tAttachment.top = "bottom";
          }

          if (top + height > bounds[3] && tAttachment.top === "bottom") {
            top -= targetHeight;
            tAttachment.top = "top";
          }
        }

        if (changeAttachY === "together") {
          if (tAttachment.top === "top") {
            if (eAttachment.top === "bottom" && top < bounds[1]) {
              top += targetHeight;
              tAttachment.top = "bottom";

              top += height;
              eAttachment.top = "top";
            } else if (
              eAttachment.top === "top" &&
              top + height > bounds[3] &&
              top - (height - targetHeight) >= bounds[1]
            ) {
              top -= height - targetHeight;
              tAttachment.top = "bottom";

              eAttachment.top = "bottom";
            }
          }

          if (tAttachment.top === "bottom") {
            if (eAttachment.top === "top" && top + height > bounds[3]) {
              top -= targetHeight;
              tAttachment.top = "top";

              top -= height;
              eAttachment.top = "bottom";
            } else if (
              eAttachment.top === "bottom" &&
              top < bounds[1] &&
              top + (height * 2 - targetHeight) <= bounds[3]
            ) {
              top += height - targetHeight;
              tAttachment.top = "top";

              eAttachment.top = "top";
            }
          }

          if (tAttachment.top === "middle") {
            if (top + height > bounds[3] && eAttachment.top === "top") {
              top -= height;
              eAttachment.top = "bottom";
            } else if (top < bounds[1] && eAttachment.top === "bottom") {
              top += height;
              eAttachment.top = "top";
            }
          }
        }

        if (changeAttachX === "target" || changeAttachX === "both") {
          if (left < bounds[0] && tAttachment.left === "left") {
            left += targetWidth;
            tAttachment.left = "right";
          }

          if (left + width > bounds[2] && tAttachment.left === "right") {
            left -= targetWidth;
            tAttachment.left = "left";
          }
        }

        if (changeAttachX === "together") {
          if (left < bounds[0] && tAttachment.left === "left") {
            if (eAttachment.left === "right") {
              left += targetWidth;
              tAttachment.left = "right";

              left += width;
              eAttachment.left = "left";
            } else if (eAttachment.left === "left") {
              left += targetWidth;
              tAttachment.left = "right";

              left -= width;
              eAttachment.left = "right";
            }
          } else if (left + width > bounds[2] && tAttachment.left === "right") {
            if (eAttachment.left === "left") {
              left -= targetWidth;
              tAttachment.left = "left";

              left -= width;
              eAttachment.left = "right";
            } else if (eAttachment.left === "right") {
              left -= targetWidth;
              tAttachment.left = "left";

              left += width;
              eAttachment.left = "left";
            }
          } else if (tAttachment.left === "center") {
            if (left + width > bounds[2] && eAttachment.left === "left") {
              left -= width;
              eAttachment.left = "right";
            } else if (left < bounds[0] && eAttachment.left === "right") {
              left += width;
              eAttachment.left = "left";
            }
          }
        }

        if (changeAttachY === "element" || changeAttachY === "both") {
          if (top < bounds[1] && eAttachment.top === "bottom") {
            top += height;
            eAttachment.top = "top";
          }

          if (top + height > bounds[3] && eAttachment.top === "top") {
            top -= height;
            eAttachment.top = "bottom";
          }
        }

        if (changeAttachX === "element" || changeAttachX === "both") {
          if (left < bounds[0]) {
            if (eAttachment.left === "right") {
              left += width;
              eAttachment.left = "left";
            } else if (eAttachment.left === "center") {
              left += width / 2;
              eAttachment.left = "left";
            }
          }

          if (left + width > bounds[2]) {
            if (eAttachment.left === "left") {
              left -= width;
              eAttachment.left = "right";
            } else if (eAttachment.left === "center") {
              left -= width / 2;
              eAttachment.left = "right";
            }
          }
        }

        if (typeof pin === "string") {
          pin = pin.split(",").map(function(p) {
            return p.trim();
          });
        } else if (pin === true) {
          pin = ["top", "left", "right", "bottom"];
        }

        pin = pin || [];

        var pinned = [];
        var oob = [];

        if (top < bounds[1]) {
          if (pin.indexOf("top") >= 0) {
            top = bounds[1];
            pinned.push("top");
          } else {
            oob.push("top");
          }
        }

        if (top + height > bounds[3]) {
          if (pin.indexOf("bottom") >= 0) {
            top = bounds[3] - height;
            pinned.push("bottom");
          } else {
            oob.push("bottom");
          }
        }

        if (left < bounds[0]) {
          if (pin.indexOf("left") >= 0) {
            left = bounds[0];
            pinned.push("left");
          } else {
            oob.push("left");
          }
        }

        if (left + width > bounds[2]) {
          if (pin.indexOf("right") >= 0) {
            left = bounds[2] - width;
            pinned.push("right");
          } else {
            oob.push("right");
          }
        }

        if (pinned.length) {
          (function() {
            var pinnedClass = undefined;
            if (typeof _this.options.pinnedClass !== "undefined") {
              pinnedClass = _this.options.pinnedClass;
            } else {
              pinnedClass = _this.getClass("pinned");
            }

            addClasses.push(pinnedClass);
            pinned.forEach(function(side) {
              addClasses.push(pinnedClass + "-" + side);
            });
          })();
        }

        if (oob.length) {
          (function() {
            var oobClass = undefined;
            if (typeof _this.options.outOfBoundsClass !== "undefined") {
              oobClass = _this.options.outOfBoundsClass;
            } else {
              oobClass = _this.getClass("out-of-bounds");
            }

            addClasses.push(oobClass);
            oob.forEach(function(side) {
              addClasses.push(oobClass + "-" + side);
            });
          })();
        }

        if (pinned.indexOf("left") >= 0 || pinned.indexOf("right") >= 0) {
          eAttachment.left = tAttachment.left = false;
        }
        if (pinned.indexOf("top") >= 0 || pinned.indexOf("bottom") >= 0) {
          eAttachment.top = tAttachment.top = false;
        }

        if (
          tAttachment.top !== targetAttachment.top ||
          tAttachment.left !== targetAttachment.left ||
          eAttachment.top !== _this.attachment.top ||
          eAttachment.left !== _this.attachment.left
        ) {
          _this.updateAttachClasses(eAttachment, tAttachment);
          _this.trigger("update", {
            attachment: eAttachment,
            targetAttachment: tAttachment
          });
        }
      });

      defer(function() {
        if (!(_this.options.addTargetClasses === false)) {
          updateClasses(_this.target, addClasses, allClasses);
        }
        updateClasses(_this.element, addClasses, allClasses);
      });

      return { top: top, left: left };
    }
  });
  /* globals TetherBase */

  ("use strict");

  var _TetherBase$Utils = TetherBase.Utils;
  var getBounds = _TetherBase$Utils.getBounds;
  var updateClasses = _TetherBase$Utils.updateClasses;
  var defer = _TetherBase$Utils.defer;

  TetherBase.modules.push({
    position: function position(_ref) {
      var _this = this;

      var top = _ref.top;
      var left = _ref.left;

      var _cache = this.cache("element-bounds", function() {
        return getBounds(_this.element);
      });

      var height = _cache.height;
      var width = _cache.width;

      var targetPos = this.getTargetBounds();

      var bottom = top + height;
      var right = left + width;

      var abutted = [];
      if (top <= targetPos.bottom && bottom >= targetPos.top) {
        ["left", "right"].forEach(function(side) {
          var targetPosSide = targetPos[side];
          if (targetPosSide === left || targetPosSide === right) {
            abutted.push(side);
          }
        });
      }

      if (left <= targetPos.right && right >= targetPos.left) {
        ["top", "bottom"].forEach(function(side) {
          var targetPosSide = targetPos[side];
          if (targetPosSide === top || targetPosSide === bottom) {
            abutted.push(side);
          }
        });
      }

      var allClasses = [];
      var addClasses = [];

      var sides = ["left", "top", "right", "bottom"];
      allClasses.push(this.getClass("abutted"));
      sides.forEach(function(side) {
        allClasses.push(_this.getClass("abutted") + "-" + side);
      });

      if (abutted.length) {
        addClasses.push(this.getClass("abutted"));
      }

      abutted.forEach(function(side) {
        addClasses.push(_this.getClass("abutted") + "-" + side);
      });

      defer(function() {
        if (!(_this.options.addTargetClasses === false)) {
          updateClasses(_this.target, addClasses, allClasses);
        }
        updateClasses(_this.element, addClasses, allClasses);
      });

      return true;
    }
  });
  /* globals TetherBase */

  ("use strict");

  var _slicedToArray = (function() {
    function sliceIterator(arr, i) {
      var _arr = [];
      var _n = true;
      var _d = false;
      var _e = undefined;
      try {
        for (
          var _i = arr[Symbol.iterator](), _s;
          !(_n = (_s = _i.next()).done);
          _n = true
        ) {
          _arr.push(_s.value);
          if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;
        _e = err;
      } finally {
        try {
          if (!_n && _i["return"]) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }
      return _arr;
    }
    return function(arr, i) {
      if (Array.isArray(arr)) {
        return arr;
      } else if (Symbol.iterator in Object(arr)) {
        return sliceIterator(arr, i);
      } else {
        throw new TypeError(
          "Invalid attempt to destructure non-iterable instance"
        );
      }
    };
  })();

  TetherBase.modules.push({
    position: function position(_ref) {
      var top = _ref.top;
      var left = _ref.left;

      if (!this.options.shift) {
        return;
      }

      var shift = this.options.shift;
      if (typeof this.options.shift === "function") {
        shift = this.options.shift.call(this, { top: top, left: left });
      }

      var shiftTop = undefined,
        shiftLeft = undefined;
      if (typeof shift === "string") {
        shift = shift.split(" ");
        shift[1] = shift[1] || shift[0];

        var _shift = shift;

        var _shift2 = _slicedToArray(_shift, 2);

        shiftTop = _shift2[0];
        shiftLeft = _shift2[1];

        shiftTop = parseFloat(shiftTop, 10);
        shiftLeft = parseFloat(shiftLeft, 10);
      } else {
        shiftTop = shift.top;
        shiftLeft = shift.left;
      }

      top += shiftTop;
      left += shiftLeft;

      return { top: top, left: left };
    }
  });
  return Tether;
});


/***/ }),

/***/ 1836:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtTotalsPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtTotalsPipe = /** @class */ (function () {
    function GtTotalsPipe() {
    }
    GtTotalsPipe.prototype.transform = function (value, data, objectKey, refresh) {
        var output;
        if (data.length === 0) {
            return;
        }
        if (typeof value === 'function') {
            output = value(data, objectKey);
        }
        else if (value) {
            output = value;
        }
        else {
            output = '';
        }
        return output;
    };
    GtTotalsPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtTotals'
        })
    ], GtTotalsPipe);
    return GtTotalsPipe;
}());

//# sourceMappingURL=gt-totals.pipe.js.map

/***/ }),

/***/ 1837:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtTotalsPositionPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtTotalsPositionPipe = /** @class */ (function () {
    function GtTotalsPositionPipe() {
    }
    GtTotalsPositionPipe.prototype.transform = function (array, position) {
        if (position === void 0) { position = 'header'; }
        return array.filter(function (total) {
            // if no position is defined assume position to be header
            var totalPosition = total.position ? total.position : 'header';
            return totalPosition === position;
        });
    };
    GtTotalsPositionPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtTotalsPosition'
        })
    ], GtTotalsPositionPipe);
    return GtTotalsPositionPipe;
}());

//# sourceMappingURL=gt-totals-position.pipe.js.map

/***/ }),

/***/ 1838:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtRowClassPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtRowClassPipe = /** @class */ (function () {
    function GtRowClassPipe() {
    }
    GtRowClassPipe.prototype.transform = function (array, gtFields) {
        if (array) {
            // find columns with rowClass property defined
            var COLUMNS_WITH_CLASS = gtFields
                .map(function (column) { return column; })
                .filter(function (column) { return column.rowClass; });
            COLUMNS_WITH_CLASS.map(function (column) {
                // for each column with rowClass property defined...
                array.map(function (row) {
                    // loop through rows and set row class
                    if (typeof column.rowClass === 'function') {
                        // if row class is a function, try using the function...
                        try {
                            if (row.$$gtRowClass) {
                                row.$$gtRowClass = row.$$gtRowClass.concat(' ' + column.rowClass(row, column));
                            }
                            else {
                                row.$$gtRowClass = column.rowClass(row, column);
                            }
                        }
                        catch (error) {
                            console.log('Error when trying to get row class name using formula.', error);
                        }
                    }
                    else {
                        // if not a function, return plain string value
                        if (row.$$gtRowClass) {
                            row.$$gtRowClass = row.$$gtRowClass.concat(' ' + column.rowClass);
                        }
                        else {
                            row.$$gtRowClass = column.rowClass;
                        }
                    }
                });
            });
        }
        return array;
    };
    GtRowClassPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtRowClass'
        })
    ], GtRowClassPipe);
    return GtRowClassPipe;
}());

//# sourceMappingURL=gt-row-class.pipe.js.map

/***/ }),

/***/ 1839:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtColumnClassPipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtColumnClassPipe = /** @class */ (function () {
    function GtColumnClassPipe() {
    }
    GtColumnClassPipe.prototype.transform = function (gtFields, column, row) {
        // find columns with columnClass property defined
        var COLUMN_WITH_CLASS = gtFields
            .map(function (field) { return field; })
            .filter(function (field) { return field.columnClass && field.objectKey === column.objectKey; })[0];
        if (!COLUMN_WITH_CLASS) {
            return;
        }
        else if (typeof COLUMN_WITH_CLASS.columnClass === 'function') {
            // if column class is a function, try using the function...
            try {
                return COLUMN_WITH_CLASS.columnClass(row, column);
            }
            catch (error) {
                console.log('Error when trying to get column class name using formula.', error);
            }
        }
        else {
            // if not a function, return plain string value
            return COLUMN_WITH_CLASS.columnClass;
        }
    };
    GtColumnClassPipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtColumnClass'
        })
    ], GtColumnClassPipe);
    return GtColumnClassPipe;
}());

//# sourceMappingURL=gt-column-class.pipe.js.map

/***/ }),

/***/ 1840:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtColumnWidthDirective; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtColumnWidthDirective = /** @class */ (function () {
    function GtColumnWidthDirective(hostElement, cdRef) {
        this.hostElement = hostElement;
        this.cdRef = cdRef;
    }
    GtColumnWidthDirective.prototype.onResize = function ($event) {
        this.checkSize();
    };
    GtColumnWidthDirective.prototype.ngOnInit = function () {
        this.checkSize();
    };
    GtColumnWidthDirective.prototype.checkSize = function () {
        this.widths[this.objectKey] = window
            .getComputedStyle(this.hostElement.nativeElement, null)
            .getPropertyValue('width');
        this.cdRef.detectChanges();
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", String)
    ], GtColumnWidthDirective.prototype, "objectKey", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Object)
    ], GtColumnWidthDirective.prototype, "widths", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["HostListener"])('window:resize', ['$event']),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", [Object]),
        __metadata("design:returntype", void 0)
    ], GtColumnWidthDirective.prototype, "onResize", null);
    GtColumnWidthDirective = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Directive"])({
            selector: '[gtColumnWidth]'
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_core__["ElementRef"],
            __WEBPACK_IMPORTED_MODULE_0__angular_core__["ChangeDetectorRef"]])
    ], GtColumnWidthDirective);
    return GtColumnWidthDirective;
}());

//# sourceMappingURL=gt-column-width.directive.js.map

/***/ }),

/***/ 1841:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtDrilldownComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__gt_expanding_row_component__ = __webpack_require__(1702);
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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 GtDrilldownComponent = /** @class */ (function (_super) {
    __extends(GtDrilldownComponent, _super);
    function GtDrilldownComponent() {
        return _super.call(this) || this;
    }
    GtDrilldownComponent.prototype.ngOnInit = function () { };
    GtDrilldownComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-drilldown',
            template: "\n      <table class=\"table\">\n          <tr *ngFor=\"let row of data\" (click)=\"$rowClick(row, $event)\">\n              <!--<td *ngFor=\"let column of gtSettings\" [style.width]=\"columnWidth[column.objectKey]\">{{column.objectKey}}</td>-->\n              <td *ngFor=\"let column of row | gtRender:gtSettings:gtFields:null:null:gtOptions.highlightSearch:gtInfo.searchTerms;\"\n                  ngClass=\"{{column.objectKey +'-column' | dashCase}} {{gtFields | gtProperty:column.objectKey:'classNames'}} {{(gtFields | gtProperty:column.objectKey:'inlineEdit') ? 'gt-inline-edit':''}} {{column.edited ? 'gt-edited':''}} {{ gtFields | gtColumnClass:row:column }}\" [style.width]=\"columnWidth[column.objectKey]\" [style.max-width]=\"columnWidth[column.objectKey]\">\n                        <span class=\"gt-row-label\"\n                              *ngIf=\"gtOptions.stack\">{{(gtFields | gtProperty:column.objectKey:'stackedHeading') ? (gtFields | gtProperty:column.objectKey:'stackedHeading') : (gtFields | gtProperty:column.objectKey:'name')}}</span>\n                  <gt-custom-component-factory *ngIf=\"column.columnComponent\" class=\"gt-row-content\"\n                                               [type]=\"column.columnComponent.type\"\n                                               [injector]=\"column.columnComponent.injector\" [row]=\"row\"\n                                               [column]=\"column\" (redrawEvent)=\"$redraw($event)\"\n                                               (click)=\"column.click ? column.click(row,column,$event):'';\"></gt-custom-component-factory>\n                  <span *ngIf=\"!column.columnComponent\"\n                        class=\"gt-row-content\" [innerHTML]=\"column.renderValue\"\n                        (click)=\"column.click ? column.click(row,column,$event):''\"></span>\n              </td>\n\n          </tr>\n      </table>\n  ",
            styles: []
        }),
        __metadata("design:paramtypes", [])
    ], GtDrilldownComponent);
    return GtDrilldownComponent;
}(__WEBPACK_IMPORTED_MODULE_1__gt_expanding_row_component__["a" /* GtExpandedRow */]));

//# sourceMappingURL=gt-drilldown.component.js.map

/***/ }),

/***/ 1842:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtCheckboxComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtCheckboxComponent = /** @class */ (function () {
    function GtCheckboxComponent() {
        this.class = 'd-flex justify-content-end';
        this.changed = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"]();
    }
    Object.defineProperty(GtCheckboxComponent.prototype, "initialValue", {
        get: function () {
            return this._initialValue;
        },
        set: function (value) {
            this._initialValue = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GtCheckboxComponent.prototype, "checked", {
        get: function () {
            return this._checked;
        },
        set: function (value) {
            this._checked = value;
        },
        enumerable: true,
        configurable: true
    });
    GtCheckboxComponent.prototype.ngOnInit = function () {
    };
    GtCheckboxComponent.prototype.toggle = function (checked) {
        this.changed.emit(this.checked);
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["HostBinding"])('class'),
        __metadata("design:type", Object)
    ], GtCheckboxComponent.prototype, "class", void 0);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [Boolean])
    ], GtCheckboxComponent.prototype, "initialValue", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Input"])(),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [Boolean])
    ], GtCheckboxComponent.prototype, "checked", null);
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Output"])(),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["EventEmitter"])
    ], GtCheckboxComponent.prototype, "changed", void 0);
    GtCheckboxComponent = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'gt-checkbox',
            template: "\n        <label class=\"custom-control custom-checkbox p-0\" (click)=\"$event.stopPropagation()\">\n            <input #checkbox type=\"checkbox\" class=\"custom-control-input\" [(checked)]=\"checked\" (change)=\"toggle($event);\">\n            <span class=\"custom-control-label\"></span>\n        </label>\n    ",
            styles: []
        }),
        __metadata("design:paramtypes", [])
    ], GtCheckboxComponent);
    return GtCheckboxComponent;
}());

//# sourceMappingURL=gt-checkbox.component.js.map

/***/ }),

/***/ 1843:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtIsObservablePipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_Observable__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_rxjs_Observable___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_rxjs_Observable__);
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 GtIsObservablePipe = /** @class */ (function () {
    function GtIsObservablePipe() {
    }
    GtIsObservablePipe.prototype.transform = function (input) {
        return input instanceof __WEBPACK_IMPORTED_MODULE_1_rxjs_Observable__["Observable"];
    };
    GtIsObservablePipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtIsObservable'
        })
    ], GtIsObservablePipe);
    return GtIsObservablePipe;
}());

//# sourceMappingURL=gt-is-observable.pipe.js.map

/***/ }),

/***/ 1844:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GtIsEditablePipe; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
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 GtIsEditablePipe = /** @class */ (function () {
    function GtIsEditablePipe() {
    }
    GtIsEditablePipe.prototype.transform = function (property, row, refreshPipe) {
        if (typeof property === 'function') {
            return property(row);
        }
        else {
            return false;
        }
    };
    GtIsEditablePipe = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Pipe"])({
            name: 'gtIsEditable'
        })
    ], GtIsEditablePipe);
    return GtIsEditablePipe;
}());

//# sourceMappingURL=gt-is-editable.pipe.js.map

/***/ })

});
//# sourceMappingURL=3.js.map