From e92d9213602dadcc075f29add9938c0c855f6f7a Mon Sep 17 00:00:00 2001 From: steve wirts Date: Wed, 23 Dec 2015 11:17:18 -0500 Subject: [PATCH] v0.1.2 fixes for 205 and 208 --- examples/autosizeissue/index.js | 1245 ++++++++++++++++++++++---- examples/autosizeissue/index.min.js | 12 +- examples/bclys/index.js | 99 +- examples/bclys/index.min.js | 10 +- examples/bclys/js/json-web-worker.js | 161 ---- examples/polymerwrapper/index.js | 99 +- examples/polymerwrapper/index.min.js | 10 +- 7 files changed, 1279 insertions(+), 357 deletions(-) delete mode 100644 examples/bclys/js/json-web-worker.js diff --git a/examples/autosizeissue/index.js b/examples/autosizeissue/index.js index f2a28d56c..0c0893cc4 100644 --- a/examples/autosizeissue/index.js +++ b/examples/autosizeissue/index.js @@ -1,5 +1,5 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o See {@link DataNodeGroup#initialize|initialize()} method for constructor parameters. + * @constructor + * @extends DataNodeBase + */ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { extendable: true, + /** + * @memberOf DataNodeGroup.prototype + * @param key + */ initialize: function(key) { this.children = new Map(); }, - prune: function(depth) { + /** + * @memberOf DataNodeGroup.prototype + * @param depth + */ + toArray: function(depth) { this.depth = depth; - this.children = this.children.values; // TODO: why? + this.children = this.children.values; this.children.forEach(function(child) { - child.prune(depth + 1); + child.toArray(depth + 1); }); this.data[0] = this.computeDepthString(); }, + /** + * @memberOf DataNodeGroup.prototype + * @returns {string} + */ computeDepthString: function() { return Array(this.depth + 1).join(this.INDENT) + expandedMap[this.expanded] + ' ' + this.label; }, + /** + * @memberOf DataNodeGroup.prototype + * @returns {*} + */ getIndex: function() { if (this.index.length === 0) { this.index = this.computeIndex(); @@ -4458,7 +4576,11 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { return this.index; }, - computeIndex: function() { // TODO: formerly computerAllRowIndexes + /** + * @memberOf DataNodeGroup.prototype + * @returns {Array} + */ + computeIndex: function() { // TODO: formerly computeAllRowIndexes var result = []; result.append = append; this.children.forEach(function(child) { @@ -4467,6 +4589,10 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { return result; }, + /** + * @memberOf DataNodeGroup.prototype + * @param aggregator + */ toggleExpansionState: function(aggregator) { /* aggregator */ this.expanded = !this.expanded; this.data[0] = this.computeDepthString(); @@ -4475,6 +4601,10 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { } }, + /** + * @memberOf DataNodeGroup.prototype + * @param aggregator + */ computeAggregates: function(aggregator) { DataNodeBase.prototype.computeAggregates.call(this, aggregator); // call base class's version if (this.expanded) { @@ -4484,6 +4614,10 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { } }, + /** + * @memberOf DataNodeGroup.prototype + * @param aggregator + */ buildView: function(aggregator) { aggregator.view.push(this); if (this.expanded) { @@ -4493,6 +4627,10 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { } }, + /** + * @memberOf DataNodeGroup.prototype + * @returns {number} + */ computeHeight: function() { var height = 1; @@ -4508,6 +4646,7 @@ var DataNodeGroup = DataNodeBase.extend('DataNodeGroup', { }); /** + * @private * @summary Array mixin to append another array to end of `this` one. * @desc Appends in place, unlike `this.concat()` which creates a new array. * Uses less memory than concat, important when `appendix` is huge. @@ -4522,26 +4661,46 @@ function append(appendix) { module.exports = DataNodeGroup; -},{"./DataNodeBase":9,"./util/Mappy":21}],11:[function(require,module,exports){ +},{"./DataNodeBase":10,"./util/Mappy":21}],12:[function(require,module,exports){ 'use strict'; var DataNodeBase = require('./DataNodeBase'); +/** + * @constructor + * @extends DataNodeBase + */ var DataNodeLeaf = DataNodeBase.extend('DataNodeLeaf', { - prune: function(depth) { + /** + * @memberOf DataNodeLeaf.prototype + * @param depth + */ + toArray: function(depth) { this.depth = depth; this.data[0] = this.computeDepthString(); }, + /** + * @memberOf DataNodeLeaf.prototype + * @returns {numer[]} + */ getIndex: function() { return this.index; }, + /** + * @memberOf DataNodeLeaf.prototype + * @param aggregator + */ buildView: function(aggregator) { aggregator.addView(this); }, + /** + * @memberOf DataNodeLeaf.prototype + * @returns {number} + */ computeHeight: function() { return 1; } @@ -4549,31 +4708,52 @@ var DataNodeLeaf = DataNodeBase.extend('DataNodeLeaf', { }); module.exports = DataNodeLeaf; -},{"./DataNodeBase":9}],12:[function(require,module,exports){ + +},{"./DataNodeBase":10}],13:[function(require,module,exports){ 'use strict'; var DataNodeGroup = require('./DataNodeGroup'); +/** + * See {@link DataNodeGroup#initialize|initialize()} method for parameters. + * @constructor + * @extends DataNodeGroup + */ var DataNodeTree = DataNodeGroup.extend('DataNodeTree', { + /** + * @memberOf DataNodeGroup.prototype + * @param {string} key + */ initialize: function(key) { this.height = 0; this.expanded = true; }, - prune: function() { + /** + * @memberOf DataNodeGroup.prototype + */ + toArray: function() { this.children = this.children.values; this.children.forEach(function(child) { - child.prune(0); + child.toArray(0); }); }, + /** + * @memberOf DataNodeGroup.prototype + * @param aggregator + */ buildView: function(aggregator) { this.children.forEach(function(child) { child.buildView(aggregator); }); }, + /** + * @memberOf DataNodeGroup.prototype + * @returns {number} + */ computeHeight: function() { var height = 1; @@ -4587,13 +4767,26 @@ var DataNodeTree = DataNodeGroup.extend('DataNodeTree', { }); module.exports = DataNodeTree; -},{"./DataNodeGroup":10}],13:[function(require,module,exports){ + +},{"./DataNodeGroup":11}],14:[function(require,module,exports){ 'use strict'; var headerify = require('./util/headerify'); +/** + * @constructor + * @param {object[]} data + * @param {string[]} fields + */ function DataSource(data, fields) { + /** + * @type {string[]} + */ this.fields = fields || computeFieldNames(data[0]); + + /** + * @type {object[]} + */ this.data = data; } @@ -4602,10 +4795,21 @@ DataSource.prototype = { isNullObject: false, + /** + * @memberOf DataSource.prototype + * @param y + * @returns {object[]} + */ getRow: function(y) { return this.data[y]; }, + /** + * @memberOf DataSource.prototype + * @param x + * @param y + * @returns {*} + */ getValue: function(x, y) { var row = this.getRow(y); if (!row) { @@ -4614,22 +4818,44 @@ DataSource.prototype = { return row[this.fields[x]]; }, + /** + * @memberOf DataSource.prototype + * @param {number} x + * @param {number} y + * @param value + */ setValue: function(x, y, value) { this.getRow(y)[this.fields[x]] = value; }, + /** + * @memberOf DataSource.prototype + * @returns {number} + */ getRowCount: function() { return this.data.length; }, + /** + * @memberOf DataSource.prototype + * @returns {number} + */ getColumnCount: function() { return this.getFields().length; }, + /** + * @memberOf DataSource.prototype + * @returns {number[]} + */ getFields: function() { return this.fields; }, + /** + * @memberOf DataSource.prototype + * @returns {string[]} + */ getHeaders: function() { return ( this.headers = this.headers || this.getDefaultHeaders().map(function(each) { @@ -4638,14 +4864,26 @@ DataSource.prototype = { ); }, + /** + * @memberOf DataSource.prototype + * @returns {string[]} + */ getDefaultHeaders: function() { return this.getFields(); }, + /** + * @memberOf DataSource.prototype + * @param {string[]} fields + */ setFields: function(fields) { this.fields = fields; }, + /** + * @memberOf DataSource.prototype + * @param {string[]} headers + */ setHeaders: function(headers) { if (!(headers instanceof Array)) { error('setHeaders', 'param #1 `headers` not array'); @@ -4653,11 +4891,17 @@ DataSource.prototype = { this.headers = headers; }, + /** + * @memberOf DataSource.prototype + */ getGrandTotals: function() { //nothing here - return; }, + /** + * @memberOf DataSource.prototype + * @param arrayOfUniformObjects + */ setData: function(arrayOfUniformObjects) { this.data = arrayOfUniformObjects; } @@ -4667,46 +4911,102 @@ function error(methodName, message) { throw new Error('DataSource.' + methodName + ': ' + message); } +/** + * @private + * @param {object} object + * @returns {string[]} + */ function computeFieldNames(object) { - if (!object) { - return []; - } - var fields = [].concat(Object.getOwnPropertyNames(object).filter(function(e) { + return Object.getOwnPropertyNames(object || []).filter(function(e) { return e.substr(0, 2) !== '__'; - })); - return fields; + }); } module.exports = DataSource; -},{"./util/headerify":23}],14:[function(require,module,exports){ +},{"./util/headerify":23}],15:[function(require,module,exports){ 'use strict'; -var _ = require('object-iterators'); - var DataSourceSorter = require('./DataSourceSorter'); var DataNodeTree = require('./DataNodeTree'); var DataNodeGroup = require('./DataNodeGroup'); var DataNodeLeaf = require('./DataNodeLeaf'); var headerify = require('./util/headerify'); -//?[t,c,b,a] -// t is a dataSource, -// a is a dictionary of aggregates, columnName:function -// b is a dictionary of groupbys, columnName:sourceColumnName -// c is a list of constraints, - +/** + * @constructor + * @param {DataSource} dataSource + */ function DataSourceAggregator(dataSource) { + + /** + * @memberOf DataSourceAggregator.prototype + * @type {DataSource} + */ this.dataSource = dataSource; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {DataNodeTree} + */ this.tree = new DataNodeTree('Totals'); + + /** + * @memberOf DataSourceAggregator.prototype + * @type {number[]} + * @default [] + */ this.index = []; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {Array} + * @default [] + */ this.aggregates = []; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {string[]} + * @default [] + */ this.headers = []; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {Array} + * @default [] + */ this.groupBys = []; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {Array} + * @default [] + */ this.view = []; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {object} + * @default {} + */ this.sorterInstance = {}; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {boolean} + * @default true + */ this.presortGroups = true; + + /** + * @memberOf DataSourceAggregator.prototype + * @type {object} + * @default {} + */ this.lastAggregate = {}; + this.setAggregates({}); } @@ -4715,6 +5015,10 @@ DataSourceAggregator.prototype = { isNullObject: false, + /** + * @memberOf DataSourceAggregator.prototype + * @param aggregations + */ setAggregates: function(aggregations) { this.lastAggregate = aggregations; this.clearAggregations(); @@ -4724,17 +5028,25 @@ DataSourceAggregator.prototype = { this.headers.push('Tree'); } - var self = this; - _(aggregations).each(function(aggregation, key) { - self.addAggregate(key, aggregation); - }); + for (var key in aggregations) { + this.addAggregate(key, aggregations[key]); + } }, + /** + * @memberOf DataSourceAggregator.prototype + * @param label + * @param func + */ addAggregate: function(label, func) { this.headers.push(headerify(label)); this.aggregates.push(func); }, + /** + * @memberOf DataSourceAggregator.prototype + * @param columnIndexArray + */ setGroupBys: function(columnIndexArray) { var groupBys = this.groupBys; groupBys.length = 0; @@ -4744,31 +5056,55 @@ DataSourceAggregator.prototype = { this.setAggregates(this.lastAggregate); }, + /** + * @memberOf DataSourceAggregator.prototype + * @param index + */ addGroupBy: function(index) { this.groupBys.push(index); }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {boolean} + */ hasGroups: function() { return !!this.groupBys.length; }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {boolean} + */ hasAggregates: function() { return !!this.aggregates.length; }, + /** + * @memberOf DataSourceAggregator.prototype + */ apply: function() { this.buildGroupTree(); }, + /** + * @memberOf DataSourceAggregator.prototype + */ clearGroups: function() { this.groupBys.length = 0; }, + /** + * @memberOf DataSourceAggregator.prototype + */ clearAggregations: function() { this.aggregates.length = 0; this.headers.length = 0; }, + /** + * @memberOf DataSourceAggregator.prototype + */ buildGroupTree: function() { var groupBys = this.groupBys, leafDepth = groupBys.length - 1, @@ -4789,52 +5125,77 @@ DataSourceAggregator.prototype = { groupBys.forEach(function(g, c) { // eslint-disable-line no-loop-func var key = source.getValue(g, r), - terminalNode = (c === leafDepth), - Constructor = terminalNode ? DataNodeLeaf : DataNodeGroup, - ifAbsentFunc = createNode.bind(this, Constructor); - path = path.children.getIfAbsent(key, ifAbsentFunc); + factoryDataNode = (c === leafDepth) ? factoryDataNodeLeaf : factoryDataNodeGroup; + path = path.children.getIfUndefined(key, factoryDataNode); }); path.index.push(r); } this.sorterInstance = new DataSourceSorter(source); - tree.prune(); + tree.toArray(); tree.computeAggregates(this); this.buildView(); }, + /** + * @memberOf DataSourceAggregator.prototype + * @param dataNode + */ addView: function(dataNode) { this.view.push(dataNode); }, + /** + * @memberOf DataSourceAggregator.prototype + */ buildView: function() { this.view.length = 0; this.tree.computeHeight(); this.tree.buildView(this); }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {*|boolean} + */ viewMakesSense: function() { return this.hasAggregates(); }, + /** + * @memberOf DataSourceAggregator.prototype + * @param x + * @param y + * @returns {*} + */ getValue: function(x, y) { if (!this.viewMakesSense()) { return this.dataSource.getValue(x, y); } + var row = this.view[y]; - if (!row) { - return null; - } - return row.getValue(x); // TODO: what kind of object is row... ? should it be unfiltred? + + return row ? row.getValue(x) : null; // TODO: what kind of object is row... ? should it be unfiltred? }, + /** + * @memberOf DataSourceAggregator.prototype + * @param x + * @param y + * @param value + * @returns {*} + */ setValue: function(x, y, value) { if (!this.viewMakesSense()) { return this.dataSource.setValue(x, y, value); } }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {*} + */ getColumnCount: function() { if (!this.viewMakesSense()) { return this.dataSource.getColumnCount(); @@ -4842,6 +5203,10 @@ DataSourceAggregator.prototype = { return this.getHeaders().length; }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {*} + */ getRowCount: function() { if (!this.viewMakesSense()) { return this.dataSource.getRowCount(); @@ -4849,12 +5214,20 @@ DataSourceAggregator.prototype = { return this.view.length; //header column }, + /** + * @memberOf DataSourceAggregator.prototype + * @param y + */ click: function(y) { var group = this.view[y]; group.toggleExpansionState(this); this.buildView(); }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {*} + */ getHeaders: function() { if (!this.viewMakesSense()) { return this.dataSource.getHeaders(); @@ -4862,23 +5235,45 @@ DataSourceAggregator.prototype = { return this.headers; // TODO: Views override dataSource headers with their own headers? }, + /** + * @memberOf DataSourceAggregator.prototype + * @param headers + */ setHeaders: function(headers) { this.dataSource.setHeaders(headers); }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {*|number[]} + */ getFields: function() { return this.dataSource.getFields(); }, + /** + * @memberOf DataSourceAggregator.prototype + * @param fields + * @returns {*} + */ setFields: function(fields) { return this.dataSource.setFields(fields); }, + /** + * @memberOf DataSourceAggregator.prototype + * @returns {object[]} + */ getGrandTotals: function() { var view = this.tree; return [view.data]; }, + /** + * @memberOf DataSourceAggregator.prototype + * @param y + * @returns {*} + */ getRow: function(y) { if (!this.viewMakesSense()) { return this.dataSource.getRow(y); @@ -4889,24 +5284,35 @@ DataSourceAggregator.prototype = { return rollups ? rollups : this.tree; }, + /** + * @memberOf DataSourceAggregator.prototype + * @param arrayOfUniformObjects + */ setData: function(arrayOfUniformObjects) { this.dataSource.setData(arrayOfUniformObjects); this.apply(); } }; -function createNode(DataNodeConstructor, key, map) { - var value = new DataNodeConstructor(key); - map.set(key, value); - return value; +function factoryDataNodeLeaf(key) { + return new DataNodeLeaf(key); +} + +function factoryDataNodeGroup(key) { + return new DataNodeGroup(key); } module.exports = DataSourceAggregator; -},{"./DataNodeGroup":10,"./DataNodeLeaf":11,"./DataNodeTree":12,"./DataSourceSorter":18,"./util/headerify":23,"object-iterators":28}],15:[function(require,module,exports){ + +},{"./DataNodeGroup":11,"./DataNodeLeaf":12,"./DataNodeTree":13,"./DataSourceSorter":19,"./util/headerify":23}],16:[function(require,module,exports){ 'use strict'; var DataSourceIndexed = require('./DataSourceIndexed'); +/** + * @constructor + * @extends DataSourceIndexed + */ var DataSourceFilter = DataSourceIndexed.extend('DataSourceFilter', { initialize: function() { @@ -4951,22 +5357,51 @@ function applyFilters(r, rowObject) { // called in context from .buildIndex() module.exports = DataSourceFilter; -},{"./DataSourceIndexed":17}],16:[function(require,module,exports){ +},{"./DataSourceIndexed":18}],17:[function(require,module,exports){ 'use strict'; var DataSourceIndexed = require('./DataSourceIndexed'); +/** + * @typedef {function} filterFunction + * @param cellValue + * @param {object} rowObject - Reference to `this.dataSource.data[r]`. + * @param {number} r - Row number (index within `this.dataSource.data`). + */ + +/** + * @constructor + * @extends DataSourceIndexed + */ var DataSourceGlobalFilter = DataSourceIndexed.extend('DataSourceGlobalFilter', { + /** + * + * @memberOf DataSourceGlobalFilter.prototype + * @param filter + */ set: function(filter) { + /** + * @type {filterFunction} + * @memberOf DataSourceGlobalFilter.prototype + */ this.filter = filter; }, + /** + * + * @memberOf DataSourceGlobalFilter.prototype + */ clear: function() { delete this.filter; this.clearIndex(); }, + /** + * + * @memberOf DataSourceGlobalFilter.prototype + * @param {object} visibleColumns + */ apply: function(visibleColumns) { if (!this.filter) { this.clearIndex(); @@ -4979,11 +5414,21 @@ var DataSourceGlobalFilter = DataSourceIndexed.extend('DataSourceGlobalFilter', } }, + /** + * + * @memberOf DataSourceGlobalFilter.prototype + * @returns {number} + */ getRowCount: function() { return this.filter ? this.index.length : this.dataSource.getRowCount(); } }); +/** + * *private + * @param {nubmer} r + * @param {object} rowObject + */ function applyFilter(r, rowObject) { // called in context from .buildIndex() var self = this; return this.visibleColumnMap.find(function(columnIndex, mapIndex) { @@ -4994,72 +5439,147 @@ function applyFilter(r, rowObject) { // called in context from .buildIndex() module.exports = DataSourceGlobalFilter; -},{"./DataSourceIndexed":17}],17:[function(require,module,exports){ +},{"./DataSourceIndexed":18}],18:[function(require,module,exports){ 'use strict'; var Base = require('extend-me').Base; +/** + * @constructor + */ var DataSourceIndexed = Base.extend('DataSourceIndexed', { + /** + * + */ isNullObject: false, + /** + * @memberOf DataSourceIndexed.prototype + * @param dataSource + */ initialize: function(dataSource) { this.dataSource = dataSource; this.index = []; }, + /** + * @memberOf DataSourceIndexed.prototype + * @param y + * @returns {*} + */ transposeY: function(y) { return this.index.length ? this.index[y] : y; }, + /** + * @memberOf DataSourceIndexed.prototype + * @param y + * @returns {object} + */ getRow: function(y) { return this.dataSource.getRow(this.transposeY(y)); }, + /** + * @memberOf DataSourceIndexed.prototype + * @param x + * @param y + * @returns {*|Mixed} + */ getValue: function(x, y) { return this.dataSource.getValue(x, this.transposeY(y)); }, + /** + * @memberOf DataSourceIndexed.prototype + * @param {number} x + * @param {number} y + * @param {*} value + */ setValue: function(x, y, value) { this.dataSource.setValue(x, this.transposeY(y), value); }, + /** + * @memberOf DataSourceIndexed.prototype + * @returns {Number|*} + */ getRowCount: function() { return this.index.length || this.dataSource.getRowCount(); }, + /** + * + * @returns {*} + */ getColumnCount: function() { return this.dataSource.getColumnCount(); }, + /** + * @memberOf DataSourceIndexed.prototype + * @returns {*} + */ getFields: function() { return this.dataSource.getFields(); }, + /** + * @memberOf DataSourceIndexed.prototype + * @param fields + * @returns {*} + */ setFields: function(fields) { return this.dataSource.setFields(fields); }, + /** + * @memberOf DataSourceIndexed.prototype + * @param {string[]} headers + * @returns {string[]} + */ setHeaders: function(headers) { return this.dataSource.setHeaders(headers); }, + /** + * + * @returns {string[]} + */ getHeaders: function() { return this.dataSource.getHeaders(); }, + /** + * @memberOf DataSourceIndexed.prototype + * @returns {*} + */ getGrandTotals: function() { return this.dataSource.getGrandTotals(); }, + /** + * @memberOf DataSourceIndexed.prototype + * @param {object[]} arrayOfUniformObjects + * @returns {object[]} + */ setData: function(arrayOfUniformObjects) { return this.dataSource.setData(arrayOfUniformObjects); }, + /** + * @memberOf DataSourceIndexed.prototype + */ clearIndex: function() { this.index.length = 0; }, + /** + * @memberOf DataSourceIndexed.prototype + * @param predicate + * @returns {number[]} + */ buildIndex: function(predicate) { var rowCount = this.dataSource.getRowCount(), index = this.index; @@ -5079,17 +5599,34 @@ var DataSourceIndexed = Base.extend('DataSourceIndexed', { module.exports = DataSourceIndexed; -},{"extend-me":3}],18:[function(require,module,exports){ +},{"extend-me":3}],19:[function(require,module,exports){ 'use strict'; var DataSourceIndexed = require('./DataSourceIndexed'); var stableSort = require('./util/stableSort'); +/** + * @constructor + * @extends DataSourceIndexed + */ var DataSourceSorter = DataSourceIndexed.extend('DataSourceSorter', { + + /** + * @memberOf DataSourceSorter.prototype + */ initialize: function() { + /** + * @memberOf DataSourceSorter.prototype + * @type {boolean} + */ this.descendingSort = false; // TODO: this does not seem to be in use }, + /** + * @memberOf DataSourceSorter.prototype + * @param {number} colIdx + * @param {number} [direction=1] + */ sortOn: function(colIdx, direction) { switch (direction) { case 0: @@ -5110,30 +5647,72 @@ var DataSourceSorter = DataSourceIndexed.extend('DataSourceSorter', { } }); +/** + * @private + * @param {*|function} valOrFunc + * @returns {*} + */ function valOrFuncCall(valOrFunc) { return typeof valOrFunc === 'function' ? valOrFunc() : valOrFunc; } module.exports = DataSourceSorter; -},{"./DataSourceIndexed":17,"./util/stableSort":24}],19:[function(require,module,exports){ + +},{"./DataSourceIndexed":18,"./util/stableSort":24}],20:[function(require,module,exports){ 'use strict'; var DataSourceIndexed = require('./DataSourceIndexed'); var DataSourceSorter = require('./DataSourceSorter'); +/** + * @constructor + * @extends DataSourceIndexed + */ var DataSourceSorterComposite = DataSourceIndexed.extend('DataSourceSorterComposite', { + + /** + * @memberOf DataSourceSorterComposite.prototype + */ initialize: function() { + /** + * Caveats: + * + * 1. Columns should be uniquely represented (i.e., no repeats with same columnIndex) + * 2. Columns should be added low- to high-order (i.e., most grouped columns come last) + * + * @type {number[]} + * @memberOf DataSourceSorterComposite.prototype + */ this.sorts = []; + + /** + * @type {DataSource} + * @memberOf DataSourceSorterComposite.prototype + */ this.last = this.dataSource; }, - // Caveats regarding this.sorts: - // 1. Columns should be uniquely represented (i.e., no repeats with same columnIndex) - // 2. Columns should be added low- to high-order (i.e., most grouped columns come last) + /** + * @memberOf DataSourceSorterComposite.prototype + * @param {number} y + * @returns {Object} + */ + getRow: function(y) { + return this.last.getRow(y); + }, + + /** + * @memberOf DataSourceSorterComposite.prototype + * @param columnIndex + * @param direction + */ sortOn: function(columnIndex, direction) { this.sorts.push([columnIndex, direction]); }, + /** + * @memberOf DataSourceSorterComposite.prototype + */ applySorts: function() { var each = this.dataSource; @@ -5145,38 +5724,43 @@ var DataSourceSorterComposite = DataSourceIndexed.extend('DataSourceSorterCompos this.last = each; }, + /** + * @memberOf DataSourceSorterComposite.prototype + */ clearSorts: function() { this.sorts.length = 0; this.last = this.dataSource; }, + /** + * @memberOf DataSourceSorterComposite.prototype + * @param {number} x + * @param {number} y + * @returns {*} + */ getValue: function(x, y) { return this.last.getValue(x, y); }, + /** + * @memberOf DataSourceSorterComposite.prototype + * @param {number} x + * @param {number} y + * @param {*} value + */ setValue: function(x, y, value) { this.last.setValue(x, y, value); } }); module.exports = DataSourceSorterComposite; -},{"./DataSourceIndexed":17,"./DataSourceSorter":18}],20:[function(require,module,exports){ -'use strict'; -module.exports = { - JSDataSource: require('./DataSource'), - DataSourceSorter: require('./DataSourceSorter'), - DataSourceSorterComposite: require('./DataSourceSorterComposite'), - DataSourceFilter: require('./DataSourceFilter'), - DataSourceGlobalFilter: require('./DataSourceGlobalFilter'), - DataSourceAggregator: require('./DataSourceAggregator'), - util: { - aggregations: require('./util/aggregations') - } -}; -},{"./DataSource":13,"./DataSourceAggregator":14,"./DataSourceFilter":15,"./DataSourceGlobalFilter":16,"./DataSourceSorter":18,"./DataSourceSorterComposite":19,"./util/aggregations":22}],21:[function(require,module,exports){ +},{"./DataSourceIndexed":18,"./DataSourceSorter":19}],21:[function(require,module,exports){ 'use strict'; +/** + * @constructor + */ function Mappy() { this.keys = []; this.data = {}; @@ -5187,6 +5771,11 @@ Mappy.prototype = { constructor: Mappy.prototype.constructor, // preserve constructor + /** + * @memberOf Mappy.prototype + * @param key + * @param value + */ set: function(key, value) { var hashCode = hash(key); if (!(hashCode in this.data)) { @@ -5196,15 +5785,28 @@ Mappy.prototype = { this.data[hashCode] = value; }, + /** + * @memberOf Mappy.prototype + * @param key + * @returns {*} + */ get: function(key) { var hashCode = hash(key); return this.data[hashCode]; }, - getIfAbsent: function(key, ifAbsentFunc) { + /** + * + * @memberOf Mappy.prototype + * @param key + * @param {function} ifUndefinedFunc - Value getter when value is otherwise undefined. + * @returns {*} + */ + getIfUndefined: function(key, ifUndefinedFunc) { var value = this.get(key); if (value === undefined) { - value = ifAbsentFunc(key, this); + value = ifUndefinedFunc(key); + this.set(key, value); } return value; }, @@ -5213,12 +5815,19 @@ Mappy.prototype = { return this.keys.length; }, + /** + * @memberOf Mappy.prototype + */ clear: function() { this.keys.length = 0; - // TODO: Is there a reason why this.values is not being truncated here as well? + this.values.length = 0; this.data = {}; }, + /** + * @memberOf Mappy.prototype + * @param key + */ delete: function(key) { var hashCode = hash(key); if (this.data[hashCode] !== undefined) { @@ -5229,27 +5838,47 @@ Mappy.prototype = { } }, - forEach: function(func) { - var keys = this.keys, - self = this; - keys.forEach(function(key) { - var value = self.get(key); - func(value, key, self); - }); + /** + * @memberOf Mappy.prototype + * @param {function} iteratee + */ + forEach: function(iteratee) { + if (typeof iteratee === 'function') { + var keys = this.keys, + self = this; + keys.forEach(function(key) { + var value = self.get(key); + iteratee(value, key, self); + }); + } }, - map: function(func) { + /** + * @memberOf Mappy.prototype + * @param {function} iteratee + * @returns {Mappy} + */ + map: function(iteratee) { var keys = this.keys, newMap = new Mappy(), self = this; + + if (!(typeof iteratee === 'function')) { + iteratee = reflection; + } + keys.forEach(function(key) { var value = self.get(key), - transformed = func(value, key, self); + transformed = iteratee(value, key, self); newMap.set(key, transformed); }); return newMap; }, + /** + * @memberOf Mappy.prototype + * @returns {Mappy} + */ copy: function() { var keys = this.keys, newMap = new Mappy(), @@ -5277,24 +5906,33 @@ function hash(key) { return OID_PREFIX + typeOf + '_' + key; case 'undefined': - return OID_PREFIX + 'undefined'; + return 'UNDEFINED'; case 'object': - // TODO: what about handling null (special case of object)? + if (key === null) { + return 'NULL'; + } + // fall through when not null: case 'function': - return (key.___finhash = key.___finhash || OID_PREFIX + counter++); // eslint-disable-line + return (key.___finhash = key.___finhash || OID_PREFIX + counter++); // eslint-disable-line no-underscore-dangle } } // Object.is polyfill, courtesy of @WebReflection var is = Object.is || function(a, b) { - return a === b ? a !== 0 || 1 / a == 1 / b : a != a && b != b; // eslint-disable-line + return a === b ? a !== 0 || 1 / a == 1 / b : a != a && b != b; // eslint-disable-line eqeqeq }; +function reflection(val) { + return val; +} + // More reliable indexOf, courtesy of @WebReflection function betterIndexOf(arr, value) { - if (value != value || value === 0) { // eslint-disable-line - for (var i = arr.length; i-- && !is(arr[i], value);) { // eslint-disable-line + if (value != value || value === 0) { // eslint-disable-line eqeqeq + var i = arr.length; + while (i-- && !is(arr[i], value)) { + // eslint-disable-line no-empty } } else { i = [].indexOf.call(arr, value); @@ -5303,9 +5941,96 @@ function betterIndexOf(arr, value) { } module.exports = Mappy; + },{}],22:[function(require,module,exports){ 'use strict'; +/** + * @module aggregations + */ + +/** + * @typedef {function} aggregationFunction + * @summary A bound function. + * @desc An aggregation function bound to the `columnIndex` value supplied to one of the above factory functions. + * @param {object} group + * @returns {*} Aggregated value. + */ + +module.exports = { + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + count: function(columnIndex) { + return count; + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + sum: function(columnIndex) { + return sum.bind(this, columnIndex); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + min: function(columnIndex) { + return minmax.bind(this, columnIndex, Math.min, Infinity); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + max: function(columnIndex) { + return minmax.bind(this, columnIndex, Math.max, -Infinity); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + avg: function(columnIndex) { + return avg.bind(this, columnIndex); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + first: function(columnIndex) { + return first.bind(this, columnIndex); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + last: function(columnIndex) { + return last.bind(this, columnIndex); + }, + + /** + * @instance + * @param {number} columnIndex + * @returns {aggregationFunction} Bound function. + */ + stddev: function(columnIndex) { + return stddev.bind(this, columnIndex); + } +}; + function count(group) { return group.getRowCount(); } @@ -5354,32 +6079,6 @@ function stddev(columnIndex, group) { return Math.sqrt(variance / rows); } -module.exports = { - count: function(columnIndex) { - return count; - }, - sum: function(columnIndex) { - return sum.bind(this, columnIndex); - }, - min: function(columnIndex) { - return minmax.bind(this, columnIndex, Math.min, Infinity); - }, - max: function(columnIndex) { - return minmax.bind(this, columnIndex, Math.max, -Infinity); - }, - avg: function(columnIndex) { - return avg.bind(this, columnIndex); - }, - first: function(columnIndex) { - return first.bind(this, columnIndex); - }, - last: function(columnIndex) { - return last.bind(this, columnIndex); - }, - stddev: function(columnIndex) { - return stddev.bind(this, columnIndex); - } -}; },{}],23:[function(require,module,exports){ 'use strict'; @@ -5398,6 +6097,20 @@ module.exports = headerify; },{}],24:[function(require,module,exports){ 'use strict'; +/** + * Note that {@link module:stableSort#sort|sort()} is the only exposed method. + * @module stableSort + */ + +/** + * @private + * @instance + * @param {function} comparator + * @param {boolean} descending + * @param {Array} arr1 + * @param {Array} arr2 + * @returns {function} + */ function stabilize(comparator, descending, arr1, arr2) { // eslint-disable-line no-shadow var x = arr1[0]; var y = arr2[0]; @@ -5417,30 +6130,76 @@ function stabilize(comparator, descending, arr1, arr2) { // eslint-disable-line return comparator(x, y); } +/** + * @private + * @instance + * @param x + * @param y + * @returns {number} + */ function ascendingNumbers(x, y) { return x - y; } +/** + * @private + * @instance + * @param x + * @param y + * @returns {number} + */ function descendingNumbers(x, y) { return y - x; } +/** + * @private + * @instance + * @param x + * @param y + * @returns {number} + */ function ascendingAllOthers(x, y) { return x < y ? -1 : 1; } +/** + * @private + * @instance + * @param x + * @param y + * @returns {number} + */ function descendingAllOthers(x, y) { return y < x ? -1 : 1; } +/** + * @private + * @instance + * @param typeOfData + * @returns {function(this:ascending)} + */ function ascending(typeOfData) { return stabilize.bind(this, typeOfData === 'number' ? ascendingNumbers : ascendingAllOthers, false); } +/** + * @private + * @instance + * @param typeOfData + * @returns {function(this:descending)} + */ function descending(typeOfData) { return stabilize.bind(this, typeOfData === 'number' ? descendingNumbers : descendingAllOthers, true); } +/** + * @instance + * @param {number} index + * @param {function} getValue + * @param {number} [direction=1] + */ function sort(index, getValue, direction) { var compare, i; @@ -5486,6 +6245,7 @@ function sort(index, getValue, direction) { } exports.sort = sort; + },{}],25:[function(require,module,exports){ // list-dragon node module // https://github.com/openfin/list-dragon @@ -6425,7 +7185,7 @@ function Entry (key, value, lu, length, now, maxAge) { define(['exports'], factory); // AMD } else { global.Mustache = {}; - factory(Mustache); // script, wsh, asp + factory(global.Mustache); // script, wsh, asp } }(this, function mustacheFactory (mustache) { @@ -6476,11 +7236,13 @@ function Entry (key, value, lu, length, now, maxAge) { '>': '>', '"': '"', "'": ''', - '/': '/' + '/': '/', + '`': '`', + '=': '=' }; function escapeHtml (string) { - return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { return entityMap[s]; }); } @@ -6680,19 +7442,19 @@ function Entry (key, value, lu, length, now, maxAge) { token = tokens[i]; switch (token[0]) { - case '#': - case '^': - collector.push(token); - sections.push(token); - collector = token[4] = []; - break; - case '/': - section = sections.pop(); - section[5] = token[2]; - collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens; - break; - default: - collector.push(token); + case '#': + case '^': + collector.push(token); + sections.push(token); + collector = token[4] = []; + break; + case '/': + section = sections.pop(); + section[5] = token[2]; + collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens; + break; + default: + collector.push(token); } } @@ -6742,16 +7504,16 @@ function Entry (key, value, lu, length, now, maxAge) { var index = this.tail.search(re), match; switch (index) { - case -1: - match = this.tail; - this.tail = ''; - break; - case 0: - match = ''; - break; - default: - match = this.tail.substring(0, index); - this.tail = this.tail.substring(index); + case -1: + match = this.tail; + this.tail = ''; + break; + case 0: + match = ''; + break; + default: + match = this.tail.substring(0, index); + this.tail = this.tail.substring(index); } this.pos += match.length; @@ -6978,7 +7740,7 @@ function Entry (key, value, lu, length, now, maxAge) { }; mustache.name = 'mustache.js'; - mustache.version = '2.2.0'; + mustache.version = '2.2.1'; mustache.tags = [ '{{', '}}' ]; // All high-level mustache.* functions use this writer. @@ -7046,16 +7808,15 @@ function Entry (key, value, lu, length, now, maxAge) { * The methods below operate on objects (but not arrays) similarly * to Underscore (http://underscorejs.org/#collections). * - * Recommended usage: - * - * var _ = require('object-iterators'); + * For more information: + * https://github.com/joneit/object-iterators */ 'use strict'; /** * @constructor - * @summary Wrap an object for one method. + * @summary Wrap an object for one method call. * @Desc Note that the `new` keyword is not necessary. * @param {object|null|undefined} object - `null` or `undefined` is treated as an empty plain object. * @return {Wrapper} The wrapped object. @@ -7073,7 +7834,7 @@ function Wrapper(object) { /** * @name Wrapper.chain - * @summary Wrap an object for a chain of methods. + * @summary Wrap an object for a chain of method calls. * @Desc Calls the constructor `Wrapper()` and modifies the wrapper for chaining. * @param {object} object * @return {Wrapper} The wrapped object. @@ -7103,27 +7864,69 @@ Wrapper.prototype = { */ each: function (iteratee, context) { var o = this.o; - context = context || o; Object.keys(o).forEach(function (key) { - iteratee.call(context, o[key], key, o); - }); + iteratee.call(this, o[key], key, o); + }, context || o); return this; }, /** - * @desc Mimics Underscore's [find](http://underscorejs.org/#find) method: Look through each member of the wrapped object, returning the first one that passes a truth test (predicate), or `undefined` if no value passes the test. The function returns the value of the first acceptable member, and doesn't necessarily traverse the entire object. + * @desc Mimics Underscore's [find](http://underscorejs.org/#find) method: Look through each member of the wrapped object, returning the first one that passes a truth test (`predicate`), or `undefined` if no value passes the test. The function returns the value of the first acceptable member, and doesn't necessarily traverse the entire object. * @param {function} predicate - For each member of the wrapped object, this function is called with three arguments: `(value, key, object)`. The return value of this function should be truthy if the member passes the test and falsy otherwise. * @param {object} [context] - If given, `predicate` is bound to this object. In other words, this object becomes the `this` value in the calls to `predicate`. (Otherwise, the `this` value will be the unwrapped object.) - * @return {*} The found property's value. + * @return {*} The found property's value, or undefined if not found. * @memberOf Wrapper.prototype */ find: function (predicate, context) { var o = this.o; - context = context || o; - var result = Object.keys(o).find(function (key) { - return predicate.call(context, o[key], key, o); - }); - return result === undefined ? undefined : o[result]; + var result; + if (o) { + result = Object.keys(o).find(function (key) { + return predicate.call(this, o[key], key, o); + }, context || o); + if (result !== undefined) { + result = o[result]; + } + } + return result; + }, + + /** + * @desc Mimics Underscore's [filter](http://underscorejs.org/#filter) method: Look through each member of the wrapped object, returning the values of all members that pass a truth test (`predicate`), or empty array if no value passes the test. The function always traverses the entire object. + * @param {function} predicate - For each member of the wrapped object, this function is called with three arguments: `(value, key, object)`. The return value of this function should be truthy if the member passes the test and falsy otherwise. + * @param {object} [context] - If given, `predicate` is bound to this object. In other words, this object becomes the `this` value in the calls to `predicate`. (Otherwise, the `this` value will be the unwrapped object.) + * @return {*} An array containing the filtered values. + * @memberOf Wrapper.prototype + */ + filter: function (predicate, context) { + var o = this.o; + var result = []; + if (o) { + Object.keys(o).forEach(function (key) { + if (predicate.call(this, o[key], key, o)) { + result.push(o[key]); + } + }, context || o); + } + return result; + }, + + /** + * @desc Mimics Underscore's [map](http://underscorejs.org/#map) method: Produces a new array of values by mapping each value in list through a transformation function (`iteratee`). The function always traverses the entire object. + * @param {function} iteratee - For each member of the wrapped object, this function is called with three arguments: `(value, key, object)`. The return value of this function is concatenated to the end of the new array. + * @param {object} [context] - If given, `iteratee` is bound to this object. In other words, this object becomes the `this` value in the calls to `predicate`. (Otherwise, the `this` value will be the unwrapped object.) + * @return {*} An array containing the filtered values. + * @memberOf Wrapper.prototype + */ + map: function (iteratee, context) { + var o = this.o; + var result = []; + if (o) { + Object.keys(o).forEach(function (key) { + result.push(iteratee.call(this, o[key], key, o)); + }, context || o); + } + return result; }, /** @@ -7136,10 +7939,11 @@ Wrapper.prototype = { */ reduce: function (iteratee, memo, context) { var o = this.o; - context = context || o; - Object.keys(o).forEach(function (key, idx) { - memo = (!idx && memo === undefined) ? o[key] : iteratee.call(context, memo, o[key], key, o); - }); + if (o) { + Object.keys(o).forEach(function (key, idx) { + memo = (!idx && memo === undefined) ? o[key] : iteratee(memo, o[key], key, o); + }, context || o); + } return memo; }, @@ -7179,6 +7983,30 @@ Wrapper.prototype = { } }; +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find +if (!Array.prototype.find) { + Array.prototype.find = function (predicate) { // eslint-disable-line no-extend-native + if (this === null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; +} + module.exports = Wrapper; },{}],29:[function(require,module,exports){ @@ -12087,7 +12915,8 @@ function defaultProperties() { columnAutosizing: true, rowNumberAutosizing: true, headerTextWrapping: false, - rowResize: false + rowResize: false, + editOnDoubleClick: true }; return properties; @@ -15784,6 +16613,10 @@ DataModelDecorator.prototype = { return this.getComponent().getTopTotals(); }, + getData: function(y) { + return this.getComponent().getData(); + }, + setData: function(y) { return this.getComponent().setData(y); }, @@ -16152,7 +16985,7 @@ var JSON = Behavior.extend('behaviors.JSON', { module.exports = JSON; -},{"../dataModels/JSON":53,"../features/index":71,"../stylesheets":73,"./Behavior":36,"./DataModelDecorator":38,"hyper-analytics":20,"list-dragon":25}],40:[function(require,module,exports){ +},{"../dataModels/JSON":53,"../features/index":71,"../stylesheets":73,"./Behavior":36,"./DataModelDecorator":38,"hyper-analytics":9,"list-dragon":25}],40:[function(require,module,exports){ 'use strict'; var Behavior = require('./Behavior'); @@ -16913,7 +17746,50 @@ var Textfield = Simple.extend('Textfield', { selectAll: function() { this.input.setSelectionRange(0, this.input.value.length); - } + }, + + initializeInput: function(input) { + var self = this; + input.addEventListener('keyup', function(e) { + if (e && (e.keyCode === 13 || e.keyCode === 27)) { + e.preventDefault(); + if (e.keyCode === 27) { + self.cancelEditing(); + } else { + self.stopEditing(); + } + self.getGrid().repaint(); + self.getGrid().takeFocus(); + } + if (self.getGrid().isFilterRow(self.getEditorPoint().y)) { + setTimeout(function() { + self.saveEditorValue(); + self._moveEditor(); + }); + } + self.getGrid().fireSyntheticEditorKeyUpEvent(self, e); + }); + input.addEventListener('keydown', function(e) { + self.getGrid().fireSyntheticEditorKeyDownEvent(self, e); + }); + input.addEventListener('keypress', function(e) { + self.getGrid().fireSyntheticEditorKeyPressEvent(self, e); + }); + // input.addEventListener('focusout', function() { + // self.stopEditing(); + // }); + // input.addEventListener('blur', function() { + // self.stopEditing(); + // }); + input.style.position = 'absolute'; + input.style.display = 'none'; + input.style.border = 'solid 2px black'; + input.style.outline = 0; + input.style.padding = 0; + input.style.zIndex = 1000; + //input.style.fontSize = '8pt'; + input.style.boxShadow = 'white 0px 0px 1px 1px'; + }, }); module.exports = Textfield; @@ -17298,6 +18174,11 @@ var JSON = DataModel.extend('dataModels.JSON', { return this.getDataSource().getFields(); }, + + getData: function() { + return this.source; + }, + /** * @memberOf dataModels.JSON.prototype * @param {object[]} dataRows @@ -17722,7 +18603,7 @@ function textMatchFilter(string) { module.exports = JSON; -},{"./DataModel":52,"hyper-analytics":20}],54:[function(require,module,exports){ +},{"./DataModel":52,"hyper-analytics":9}],54:[function(require,module,exports){ /* eslint-env browser */ 'use strict'; @@ -17825,6 +18706,7 @@ var CellEditing = Feature.extend('CellEditing', { module.exports = CellEditing; + },{"./Feature.js":63}],57:[function(require,module,exports){ 'use strict'; @@ -20331,6 +21213,7 @@ var Feature = Base.extend('Feature', { module.exports = Feature; },{"extend-me":3}],64:[function(require,module,exports){ + 'use strict'; var Feature = require('./Feature.js'); @@ -20342,13 +21225,43 @@ var Filters = Feature.extend('Filters', { alias: 'Filters', + handleDoubleClick: function(grid, event) { + var isDoubleClickEditorActivation = grid.resolveProperty('editOnDoubleClick'); + if (this.checkActivateEditor(grid, event, isDoubleClickEditorActivation)) { + grid._activateEditor(event); + } else if (this.next) { + this.next.handleDoubleClick(grid, event); + } + }, + handleTap: function(grid, event) { - var gridCell = event.gridCell; - if (grid.isFilterRow(gridCell.y) && gridCell.x !== -1) { - grid.filterClicked(event); + var isDoubleClickEditorActivation = grid.resolveProperty('editOnDoubleClick'); + if (this.checkActivateEditor(grid, event, !isDoubleClickEditorActivation)) { + grid._activateEditor(event); } else if (this.next) { this.next.handleTap(grid, event); } + }, + + /** + * @memberOf CellEditing.prototype + * @desc handle this event down the feature chain of responsibility + * @param {Hypergrid} grid + * @param {Object} event - the event details + */ + handleHoldPulse: function(grid, event) { + var isDoubleClickEditorActivation = grid.resolveProperty('editOnDoubleClick'); + if (this.checkActivateEditor(grid, event, !isDoubleClickEditorActivation)) { + grid._activateEditor(event); + } else if (this.next) { + this.next.handleHoldPulse(grid, event); + } + }, + + checkActivateEditor: function(grid, event, isDoubleClickEditorActivation) { + var isFilterRow = grid.isFilterRow(event.gridCell.y); + var activateEditor = isDoubleClickEditorActivation && isFilterRow; + return activateEditor; } }); @@ -21468,4 +22381,4 @@ function addStylesheet(key, referenceElement) { module.exports = addStylesheet; },{"css-injector":2}]},{},[54]) -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9zdGV2ZXdpcnRzL1Byb2plY3RzL2Rldi9maW4taHlwZXJncmlkL25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvVXNlcnMvc3RldmV3aXJ0cy9Qcm9qZWN0cy9kZXYvZmluLWh5cGVyZ3JpZC9pbWFnZXMvaW5kZXguanMiLCIvVXNlcnMvc3RldmV3aXJ0cy9Qcm9qZWN0cy9kZXYvZmluLWh5cGVyZ3JpZC9ub2RlX21vZHVsZXMvY3NzLWluamVjdG9yL2luZGV4LmpzIiwiL1VzZXJzL3N0ZXZld2lydHMvUHJvamVjdHMvZGV2L2Zpbi1oeXBlcmdyaWQvbm9kZV9tb2R1bGVzL2V4dGVuZC1tZS9pbmRleC5qcyIsIi9Vc2Vycy9zdGV2ZXdpcnRzL1Byb2plY3RzL2Rldi9maW4taHlwZXJncmlkL25vZGVfbW9kdWxlcy9maW5iYXJzL2luZGV4LmpzIiwiL1Vz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lwZSk7XG4gICAgcHJvdG90eXBlLmNvbnN0cnVjdG9yID0gQ29uc3RydWN0b3I7XG5cbiAgICBpZiAoZXh0ZW5kZWRDbGFzc05hbWUgJiYgZXh0ZW5kLmRlYnVnKSB7XG4gICAgICAgIHByb3RvdHlwZS4kJENMQVNTX05BTUUgPSBleHRlbmRlZENsYXNzTmFtZTtcbiAgICB9XG5cbiAgICBmb3IgKHZhciBrZXkgaW4gcHJvdG90eXBlQWRkaXRpb25zKSB7XG4gICAgICAgIGlmIChwcm90b3R5cGVBZGRpdGlvbnMuaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgdmFyIHZhbHVlID0gcHJvdG90eXBlQWRkaXRpb25zW2tleV07XG4gICAgICAgICAgICBzd2l0Y2ggKGtleSkge1xuICAgICAgICAgICAgICAgIGNhc2UgJ2luaXRpYWxpemVPd24nOlxuICAgICAgICAgICAgICAgICAgICAvLyBhbHJlYWR5IGNhbGxlZCBhYm92ZTsgbm90IG5lZWRlZCBpbiBwcm90b3R5cGVcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnYWxpYXNlcyc6XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGFsaWFzIGluIHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUuaGFzT3duUHJvcGVydHkoYWxpYXMpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUFsaWFzKHZhbHVlW2FsaWFzXSwgYWxpYXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIHZhbHVlWzBdID09PSAnIycpIHtcbiAgICAgICAgICAgICAgICAgIC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W5kZXggPSAwO1xuICAgIHRoaXMuX21heCA9IDEwMDtcblxuICAgIC8vIG9wdGlvbnNcbiAgICBmb3IgKHZhciBrZXkgaW4gb3B0aW9ucykge1xuICAgICAgICBpZiAob3B0aW9ucy5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICB2YXIgb3B0aW9uID0gb3B0aW9uc1trZXldO1xuICAgICAgICAgICAgc3dpdGNoIChrZXkpIHtcblxuICAgICAgICAgICAgY2FzZSAnaW5kZXgnOlxuICAgICAgICAgICAgICAgIHRoaXMuX2luZGV4ID0gb3B0aW9uO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBjYXNlICdyYW5nZSc6XG4gICAgICAgICAgICAgICAgdmFsaWRSYW5nZShvcHRpb24pO1xuICAgICAgICAgICAgICAgIHRoaXMuX21pbiA9IG9wdGlvbi5taW47XG4gICAgICAgICAgICAgICAgdGhpcy5fbWF4ID0gb3B0aW9uLm1heDtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRTaXplID0gb3B0aW9uLm1heCAtIG9wdGlvbi5taW4gKyAxO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICAgICAga2V5LmNoYXJBdCgwKSAhPT0gJ18nICYmXG4gICAgICAgICAgICAgICAgICAgIHR5cGVvZiBGaW5CYXIucHJvdG90eXBlW2tleV0gIT09ICdmdW5jdGlvbidcbiAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gb3ZlcnJpZGUgcHJvdG90eXBlIGRlZmF1bHRzIGZvciBzdGFuZGFyZCA7XG4gICAgICAgICAgICAgICAgICAgIC8vIGV4dGVuZCB3aXRoIGFkZGl0aW9uYWwgcHJvcGVydGllcyAoZm9yIHVzZSBpbiBvbmNoYW5nZSBldmVudCBoYW5kbGVycylcbiAgICAgICA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YXIucGFyZW50RWxlbWVudCxcbiAgICAgICAgICAgICAgICBjb250YWluZXJSZWN0ID0gY29udGFpbmVyLmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpLFxuICAgICAgICAgICAgICAgIG9oID0gdGhpcy5vaDtcblxuICAgICAgICAgICAgLy8gQmVmb3JlIGFwcGx5aW5nIG5ldyBzdHlsZXMsIHJldmVydCBhbGwgc3R5bGVzIHRvIHZhbHVlcyBpbmhlcml0ZWQgZnJvbSBzdHlsZXNoZWV0c1xuICAgICAgICAgICAgYmFyLnJlbW92ZUF0dHJpYnV0ZSgnc3R5bGUnKTtcblxuICAgICAgICAgICAga2V5cy5mb3JFYWNoKGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsID0gc3R5bGVzW2tleV07XG5cbiAgICAgICAgICAgICAgICBpZiAoa2V5IGluIG9oKSB7XG4gICAgICAgICAgICAgICAgICAgIGtleSA9IG9oW2tleV07XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCFpc05hTihOdW1iZXIodmFsKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsID0gKHZhbCB8fCAwKSArICdweCc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgvJSQvLnRlc3QodmFsKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBXaGVuIGJhciBzaXplIGdpdmVuIGFzIHBlcmNlbnRhZ2Ugb2YgY29udGFpbmVyLCBpZiBiYXIgaGFzIG1hcmdpbnMsIHJlc3RhdGUgc2l6ZSBpbiBwaXhlbHMgbGVzcyBtYXJnaW5zLlxuICAgICAgICAgICAgICAgICAgICAvLyAoSWYgbGVmdCBhcyBwZXJjZW50YWdlLCBDU1MncyBjYWxjdWxhdGlvbiB3aWxsIG5vdCBleGNsdWRlIG1hcmdpbnMuKVxuICAgICAgICAgICAgICAgICAgICB2YXIgb3JpZW50ZWQgPSBheGlzW2tleV0sXG4gICAgICAgICAgICAgIC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5cbiAgICAgICAgdmFyIHRodW1iQm94ID0gdGhpcy50aHVtYi5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKTtcbiAgICAgICAgaWYgKFxuICAgICAgICAgICAgdGh1bWJCb3gubGVmdCA8PSBldnQuY2xpZW50WCAmJiBldnQuY2xpZW50WCA8PSB0aHVtYkJveC5yaWdodCAmJlxuICAgICAgICAgICAgdGh1bWJCb3gudG9wIDw9IGV2dC5jbGllbnRZICYmIGV2dC5jbGllbnRZIDw9IHRodW1iQm94LmJvdHRvbVxuICAgICAgICApIHtcbiAgICAgICAgICAgIHRoaXMuX2JvdW5kLm9ubW91c2VvdmVyKGV2dCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9ib3VuZC5vbm1vdXNlb3V0KGV2dCk7XG4gICAgICAgIH1cblxuICAgICAgICBldnQuc3RvcFByb3BhZ2F0aW9uKCk7XG4gICAgICAgIGV2dC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgIH1cbn07XG5cbnZhciBvcmllbnRhdGlvbkhhc2hlcyA9IHtcbiAgICB2ZXJ0aWNhbDoge1xuICAgICAgICBjb29yZGluYXRlOiAgICAgJ2NsaWVudFknLFxuICAgICAgICBheGlzOiAgICAgICAgICAgJ3BhZ2VZJyxcbiAgICAgICAgc2l6ZTogICAgICAgICAgICdoZWlnaHQnLFxuICAgICAgICBvdXRzaWRlOiAgICAgICAgJ3JpZ2h0JyxcbiAgICAgICAgaW5zaWRlOiAgICAgICAgICdsZWZ0JyxcbiAgICAgICAgbGVhZGluZzogICAgICAgICd0b3AnLFxuICAgICAgICB0cmFpbGluZzogICAgICAgJ2JvdHRvbScsXG4gICAgICAgIG1hcmdpbkxlYWRpbmc6ICAnbWFyZ2luVG9wJyxcbiAgICAgICAgbWFyZ2luVHJhaWxpbmc6ICdtYXJnaW5Cb3R0b20nLFxuICAgICAgICB0aGlja25lc3M6ICAgICAgJ3dpZHRoJyxcbiAgICAgICAgZGVsdGE6ICAgICAgICAgICdkZWx0YVknXG4gICAgfSxcbiAgICBob3Jpem9udGFsOiB7XG4gICAgICAgIGNvb3JkaW5hdGU6ICAgICAnY2xpZW50WCcsXG4gICAgICAgIGF4aXM6ICAgICAgICAgICAncGFnZVgnLFxuICAgICAgICBzaXplOiAgICAgICAgICAgJ3dpZHRoJyxcbiAgICAgICAgb3V0c2lkZTogICAgICAgICdib3R0b20nLFxuICAgICAgICBpbnNpZGU6ICAgICAgICAgJ3RvcCcsXG4gICAgICAgIGxlYWRpbmc6ICAgICAgICAnbGVmdCcsXG4gICAgICAgIHRyYWlsaW5nOiAgICAgICAncmlnaHQnLFxuICAgICAgICBtYXJnaW5MZWFkaW5nOiAgJ21hcmdpbkxlZnQnLFxuICAgICAgICBtYXJnaW5UcmFpbGluZzogJ21hcmdpblJpZ2h0JyxcbiAgICAgICAgdGhpY2tuZXNzOiAgICAgICdoZWlnaHQnLFxuICAgICAgICBkZWx0YTogICAgICAgICAgJ2RlbHRhWCdcbiAgICB9XG59O1xuXG52YXIgYXhpcyA9IHtcbiAgICB0b3A6ICAgICd2ZXJ0aWNhbCcsXG4gICAgYm90dG9tOiAndmVydGljYWwnLFxuICAgIGhlaWdodDogJ3ZlcnRpY2FsJyxcbiAgICBsZWZ0OiAgICdob3Jpem9udGFsJyxcbiAgICByaWdodDogICdob3Jpem9udGFsJyxcbiAgICB3aWR0aDogICdob3Jpem9udGFsJ1xufTtcblxudmFyIGNzc0ZpbkJhcnM7IC8vIGRlZmluaXRpb24gaW5zZXJ0ZWQgYnkgZ3VscGZpbGUgYmV0d2VlbiBmb2xsb3dpbmcgY29tbWVudHNcbi8qIGluamVjdDpjc3MgKi9cbmNzc0ZpbkJhcnMgPSAnZGl2LmZpbmJhci1ob3Jpem9udGFsLGRpdi5maW5iYXItdmVydGljYWx7cG9zaXRpb246YWJzb2x1dGU7bWFyZ2luOjNweH1kaXYuZmluYmFyLWhvcml6b250YWw+LnRodW1iLGRpdi5maW5iYXItdmVydGljYWw+L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0S2V5OiBudWxsLFxuICAgIHJlcGVhdEtleVN0YXJ0VGltZTogMCxcbiAgICBjdXJyZW50S2V5czogW10sXG4gICAgaGFzTW91c2U6IGZhbHNlLFxuICAgIGxhc3REb3VibGVDbGlja1RpbWU6IDAsXG4gICAgZHJhZ0VuZFRpbWU6IDAsXG4gICAgbGFzdFJlcGFpbnRUaW1lOiAwLFxuXG4gICAgYWRkRXZlbnRMaXN0ZW5lcjogZnVuY3Rpb24obmFtZSwgY2FsbGJhY2spIHtcbiAgICAgICAgdGhpcy5jYW52YXMuYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBjYWxsYmFjayk7XG4gICAgfSxcblxuICAgIHN0b3BQYWludExvb3A6IGZ1bmN0aW9uKCkge1xuICAgICAgICBwYWludExvb3BSdW5uaW5nID0gZmFsc2U7XG4gICAgfSxcblxuICAgIHJlc3RhcnRQYWludExvb3A6IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAocGFpbnRMb29wUnVubmluZykge1xuICAgICAgICAgICAgcmV0dXJuOyAvLyBhbHJlYWR5IHJ1bm5pbmdcbiAgICAgICAgfVxuICAgICAgICBwYWludExvb3BSdW5uaW5nID0gdHJ1ZTtcbiAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKHBhaW50TG9vcEZ1bmN0aW9uKTtcbiAgICB9LFxuXG4gICAgc3RvcFJlc2l6ZUxvb3A6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXNpemVMb29wUnVubmluZyA9IGZhbHNlO1xuICAgIH0sXG5cbiAgICByZXN0YXJ0UmVzaXplTG9vcDogZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmIChyZXNpemVMb29wUnVubmluZykge1xuICAgICAgICAgICAgcmV0dXJuOyAvLyBhbHJlYWR5IHJ1bm5pbmdcbiAgICAgICAgfVxuICAgICAgICByZXNpemVMb29wUnVubmluZyA9IHRydWU7XG4gICAgICAgIHNldEludGVydmFsKHJlc2l6YWJsZXNMb29wRnVuY3Rp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oKSB7XG4gICAgICAgIC8vdG8gYmUgb3ZlcnJpZGRlblxuICAgIH0sXG5cbiAgICBnZXRCb3VuZHM6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5ib3VuZHM7XG4gICAgfSxcblxuICAgIHBhaW50Tm93OiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgICAgICB0aGlzLnNhZmVQYWludEltbWVkaWF0ZWx5KGZ1bmN0aW9uKGdjKSB7XG4gICAgICAgICAgICBnYy5jbGVhclJlY3QoMCwgMCwgc2VsZi5jYW52YXMud2lkdGgsIHNlbGYuY2FudmFzLmhlaWdodCk7XG5cbiAgICAgICAgICAgIHZhciBjb21wID0gc2VsZi5fY29tcG9uZW50O1xuICAgICAgICAgICAgaWYgKGNvbXApIHtcbiAgICAgICAgICAgICAgICBjb21wLl9wYWludChnYyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHNlbGYuZGlydHkgPSBmYWxzZTtcbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIHNhZmVQYWludEltbWVkaWF0ZWx5OiBmdW5jdGlvbihwYWludEZ1bmN0aW9uKSB7XG4gICAgICAgIHZhciB1c2VCaXRCbGl0ID0gdGhpcy51c2VCaXRCbGl0KCksXG4gICAgICAgICAgICBnYyA9IHVzZUJpdEJsaXQgPyB0aGlzLmJ1ZmZlckdDIDogdGhpcy5nYztcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGdjLnNhdmUoKTtcbiAgICAgICAgICAgIHBhaW50RnVuY3Rpb24oZ2MpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpO1xuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgZ2MucmVzdG9yZSgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh1c2VCaXRCbGl0KSB7XG4gICAgICAgICAgICB0aGlzLmZsdXNoQnV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gbm93IC0gdGhpcy5sYXN0RG91YmxlQ2xpY2tUaW1lO1xuICAgICAgICBpZiAoZGlmIDwgMzAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgLy9kcmFnZW5kIGlzIGFsc28gY2F1c2luZyBhIHRhcFxuICAgICAgICAvL2xldHMgZml4IHRoaXMgaGVyZVxuICAgICAgICBpZiAobm93IC0gdGhpcy5kcmFnRW5kdGltZSA8IDEwMCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBzZWxmLl9maW50YXAoZSk7XG4gICAgICAgIH0sIDE4MCk7XG4gICAgfSxcblxuICAgIF9maW50YXA6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgLy90aGlzIG5vbnNlbnNlIGlzIHRvIGhvbGQgYSB0YXAgaWYgaXQncyByZWFsbHkgYSBkb3VibGUgY2xpY2tcbiAgICAgICAgdmFyIG5vdyA9IERhdGUubm93KCk7XG4gICAgICAgIHZhciBkaWYgPSBub3cgLSB0aGlzLmxhc3REb3VibGVDbGlja1RpbWU7XG4gICAgICAgIGlmIChkaWYgPCAzMDApIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICAvL3RoaXMubW91c2VMb2NhdGlvbiA9IHRoaXMuZ2V0TG9jYWwoZSk7XG4gICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdNb3VzZUtleXNFdmVudChlLCAnZmluLWNhbnZhcy10YXAnLCB7XG4gICAgICAgICAgICBpc1JpZ2h0Q2xpY2s6IHRoaXMuaXNSaWdodENsaWNrKGUpXG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBmaW5kYmxjbGljazogZnVuY3Rpb24oZSkge1xuICAgICAgICB0aGlzLm1vdXNlTG9jYXRpb24gPSB0aGlzLmdldExvY2FsKGUpO1xuICAgICAgICB0aGlzLmxhc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ICAgICAgdGhpcy5yZXBlYXRLZXkgPSBudWxsO1xuICAgICAgICAgICAgdGhpcy5yZXBlYXRLZXlDb3VudCA9IDA7XG4gICAgICAgICAgICB0aGlzLnJlcGVhdEtleVN0YXJ0VGltZSA9IDA7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuY3VycmVudEtleXMuaW5kZXhPZihrZXlDaGFyKSA9PT0gLTEpIHtcbiAgICAgICAgICAgIHRoaXMuY3VycmVudEtleXMucHVzaChrZXlDaGFyKTtcbiAgICAgICAgfVxuICAgICAgICAvL2NvbnNvbGUubG9nKGtleUNoYXIsIGUua2V5Q29kZSk7XG4gICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdFdmVudChlLCAnZmluLWNhbnZhcy1rZXlkb3duJywge1xuICAgICAgICAgICAgYWx0OiBlLmFsdEtleSxcbiAgICAgICAgICAgIGN0cmw6IGUuY3RybEtleSxcbiAgICAgICAgICAgIGNoYXI6IGtleUNoYXIsXG4gICAgICAgICAgICBjb2RlOiBlLmNoYXJDb2RlLFxuICAgICAgICAgICAga2V5OiBlLmtleUNvZGUsXG4gICAgICAgICAgICBtZXRhOiBlLm1ldGFLZXksXG4gICAgICAgICAgICByZXBlYXRDb3VudDogdGhpcy5yZXBlYXRLZXlDb3VudCxcbiAgICAgICAgICAgIHJlcGVhdFN0YXJ0VGltZTogdGhpcy5yZXBlYXRLZXlTdGFydFRpbWUsXG4gICAgICAgICAgICBzaGlmdDogZS5zaGlmdEtleSxcbiAgICAgICAgICAgIGlkZW50aWZpZXI6IGUua2V5SWRlbnRpZmllcixcbiAgICAgICAgICAgIGN1cnJlbnRLZXlzOiB0aGlzLmN1cnJlbnRLZXlzLnNsaWNlKDApXG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBmaW5rZXl1cDogZnVuY3Rpb24oZSkge1xuICAgICAgICB2YXIga2V5Q2hhciA9IGUuc2hpZnRLZXkgPyBjaGFyTWFwW2Uua2V5Q29kZV1bMV0gOiBja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bnQoZSwgJ2Zpbi1jYW52YXMtZm9jdXMtbG9zdCcpO1xuICAgIH0sXG5cbiAgICBmaW5jb250ZXh0bWVudTogZnVuY3Rpb24oZSkge1xuICAgICAgICBpZiAoZS5jdHJsS2V5ICYmIHRoaXMuY3VycmVudEtleXMuaW5kZXhPZignQ1RSTCcpID09PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50S2V5cy5wdXNoKCdDVFJMJyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKERhdGUubm93KCkgLSB0aGlzLmxhc3RDbGlja1RpbWUgPCAyNTApIHtcbiAgICAgICAgICAgIC8vdGhpcyBpcyBhIGRvdWJsZSBjbGljay4uLlxuICAgICAgICAgICAgdGhpcy5maW5kYmxjbGljayhlKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmRpc3BhdGNoTmV3TW91c2VLZXlzRXZlbnQoZSwgJ2Zpbi1jYW52YXMtY29udGV4dC1tZW51Jywge1xuICAgICAgICAgICAgaXNSaWdodENsaWNrOiB0aGlzLmlzUmlnaHRDbGljayhlKVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5sYXN0Q2xpY2tUaW1lID0gRGF0ZS5ub3coKTtcbiAgICB9LFxuXG4gICAgcmVwYWludDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBmcHMgPSB0aGlzLmdldEZQUygpO1xuICAgICAgICB0aGlzLmRpcnR5ID0gdHJ1ZTtcbiAgICAgICAgaWYgKCFwYWludExvb3BSdW5uaW5nIHx8IGZwcyA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5wYWludE5vdygpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGdldE1vdXNlTG9jYXRpb246IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5tb3VzZUxvY2F0aW9uO1xuICAgIH0sXG5cbiAgICBnZXRPcmlnaW46IGZ1bmN0aW9uKCkge1xuICAgIC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gLy8gSUUsIE9wZXJhXG4gICAgICAgICAgICBpc1JpZ2h0TUIgPSBlLmJ1dHRvbiA9PT0gMjtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gaXNSaWdodE1CO1xuICAgIH0sXG5cbiAgICBkaXNwYXRjaEV2ZW50OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGUpO1xuICAgIH1cbn07XG5cbmZ1bmN0aW9uIHBhaW50TG9vcEZ1bmN0aW9uKG5vdykge1xuICAgIGlmICghcGFpbnRMb29wUnVubmluZykge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcGFpbnRhYmxlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcGFpbnRhYmxlc1tpXS50aWNrUGFpbnRlcihub3cpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShwYWludExvb3BGdW5jdGlvbik7XG59XG5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUocGFpbnRMb29wRnVuY3Rpb24pO1xuXG5mdW5jdGlvbiByZXNpemFibGVzTG9vcEZ1bmN0aW9uKG5vdykge1xuICAgIGlmICghcmVzaXplTG9vcFJ1bm5pbmcpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHJlc2l6YWJsZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJlc2l6YWJsZXNbaV0udGlja1Jlc2l6ZXIobm93KTtcbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihlKTtcbiAgICAgICAgfVxuICAgIH1cbn1cbnNldEludGVydmFsKHJlc2l6YWJsZXNMb29wRnVuY3Rpb24sIFJFU0laRV9QT0xMSU5HX0lOVEVSVkFMKTtcblxuZnVuY3Rpb24gbWFrZUNoYXJNYXAoKSB7XG4gICAgdmFyIG1hcCA9IFtdO1xuXG4gICAgdmFyIGVtcHR5ID0gWycnLCAnJ107XG5cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IDI1NjsgaSsrKSB7XG4gICAgICAgIG1hcFtpXSA9IGVtcHR5O1xuICAgIH1cblxuICAgIG1hcFsyN10gPSBbJ0VTQycsICdFU0NTSElGVCddO1xuICAgIG1hcFsxOTJdID0gWydgJywgJ34nXTtcbiAgICBtYXBbNDldID0gWycxJywgJyEnXTtcbiAgICBtYXBbNTBdID0gWycyJywgJ0AnXTtcbiAgICBtYXBbNTFdID0gWyczJywgJyMnXTtcbiAgICBtYXBbNTJdID0gWyc0JywgJyQnXTtcbiAgICBtYXBbNTNdID0gWyc1JywgJyUnXTtcbiAgICBtYXBbNTRdID0gWyc2JywgJ14nXTtcbiAgICBtYXBbNTVdID0gWyc3JywgJyYnXTtcbiAgICBtYXBbNTZdID0gWyc4JywgJyonXTtcbiAgICBtYXBbNTddID0gWyc5JywgJygnXTtcbiAgICBtYXBbNDhdID0gWycwJywgJyknXTtcbiAgICBtYXBbMTg5XSA9IFsnLScsICdfJ107XG4gICAgbWFwWzE4N10gPSBbJz0nLCAnKyddO1xuICAgIG1hcFs4XSA9IFsnREVMRVRFJywgJ0RFTEVURVNISUZUJ107XG4gICAgbWFwWzldID0gWydUQUInLCAnVEFCU0hJRlQnXTtcbiAgICBtYXBbODFdID0gWydxJywgJ1EnXTtcbiAgICBtYXBbODddID0gWyd3JywgJ1cnXTtcbiAgICBtYXBbNjldID0gWydlJywgJ0UnXTtcbiAgICBtYXBbODJdID0gWydyJywgJ1InXTtcbiAgICBtYXBbODRdID0gWyd0JywgJ1QnXTtcbiAgICBtYXBbODldID0gWyd5JywgJ1knXTtcbiAgICBtYXBbODVdID0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uICAgICAgICAgICAgfTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShzZWxmLCBrZXksIHtcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2Nba2V5XTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxvZ2dlciA/IGxvZ2dlcihrZXksICdnZXR0ZXInLCByZXN1bHQpIDogcmVzdWx0O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBnY1trZXldID0gbG9nZ2VyID8gbG9nZ2VyKGtleSwgJ3NldHRlcicsIHZhbHVlKSA6IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IEdyYXBoaWNzQ29udGV4dDtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIFlJRUxEUyA9ICdcXHUyN0Y5JzsgLy8gTE9ORyBSSUdIVFdBUkRTIERPVUJMRSBBUlJPV1xuXG5mdW5jdGlvbiBjb25zb2xlTG9nZ2VyKHByZWZpeCwgbmFtZSwgYXJncywgdmFsdWUpIHtcbiAgICB2YXIgcmVzdWx0ID0gdmFsdWU7XG5cbiAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJykge1xuICAgICAgICByZXN1bHQgPSAnXCInICsgcmVzdWx0ICsgJ1wiJztcbiAgICB9XG5cbiAgICBuYW1lID0gcHJlZml4ICsgbmFtZTtcblxuICAgIHN3aXRjaCAoYXJncykge1xuICAgICAgICBjYXNlICdnZXR0ZXInOlxuICAgICAgICAgICAgY29uc29sZS5sb2cobmFtZSwgJz0nLCByZXN1bHQpO1xuICAgICAgICAgICAgYnJlYW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XG4gICAgICAgIHZhciBldiA9IG5ldyBDdXN0b21FdmVudCgndGVzdHBhdGgnLCB7XG4gICAgICAgICAgICBidWJibGVzOiB0cnVlXG4gICAgICAgIH0pO1xuICAgICAgICAvLyBtdXN0IGFkZCBub2RlIHRvIERPTSB0byB0cmlnZ2VyIGV2ZW50IGxpc3RlbmVyXG4gICAgICAgIGRvY3VtZW50LmhlYWQuYXBwZW5kQ2hpbGQocGF0aFRlc3QpO1xuICAgICAgICBzLmRpc3BhdGNoRXZlbnQoZXYpO1xuICAgICAgICBwYXRoVGVzdC5wYXJlbnROb2RlLnJlbW92ZUNoaWxkKHBhdGhUZXN0KTtcbiAgICAgICAgc3IgPSBzID0gbnVsbDtcbiAgICB9XG4gICAgcGF0aFRlc3QgPSBudWxsO1xuXG4gICAgdmFyIHRhcmdldCA9IHtcbiAgICAgICAgc2hhZG93OiBmdW5jdGlvbihpbkVsKSB7XG4gICAgICAgICAgICBpZiAoaW5FbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpbkVsLnNoYWRvd1Jvb3QgfHwgaW5FbC53ZWJraXRTaGFkb3dSb290O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBjYW5UYXJnZXQ6IGZ1bmN0aW9uKHNoYWRvdykge1xuICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyAmJiBCb29sZWFuKHNoYWRvdy5lbGVtZW50RnJvbVBvaW50KTtcbiAgICAgICAgfSxcbiAgICAgICAgdGFyZ2V0aW5nU2hhZG93OiBmdW5jdGlvbihpbkVsKSB7XG4gICAgICAgICAgICB2YXIgcyA9IHRoaXMuc2hhZG93KGluRWwpO1xuICAgICAgICAgICAgaWYgKHRoaXMuY2FuVGFyZ2V0KHMpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHM7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG9sZGVyU2hhZG93OiBmdW5jdGlvbihzaGFkb3cpIHtcbiAgICAgICAgICAgIHZhciBvcyA9IHNoYWRvdy5vbGRlclNoYWRvd1Jvb3Q7XG4gICAgICAgICAgICBpZiAoIW9zKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNlID0gc2hhZG93LnF1ZXJ5U2VsZWN0b3IoJ3NoYWRvdycpO1xuICAgICAgICAgICAgICAgIGlmIChzZSkge1xuICAgICAgICAgICAgICAgICAgICBvcyA9IHNlLm9sZGVyU2hhZG93Um9vdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gb3M7XG4gICAgICAgIH0sXG4gICAgICAgIGFsbFNoYWRvd3M6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBzaGFkb3dzID0gW10sXG4gICAgICAgICAgICAgICAgcyA9IHRoaXMuc2hhZG93KGVsZW1lbnQpO1xuICAgICAgICAgICAgd2hpbGUgKHMpIHtcbiAgICAgICAgICAgICAgICBzaGFkb3dzLnB1c2gocyk7XG4gICAgICAgICAgICAgICAgcyA9IHRoaXMub2xkZXJTaGFkb3cocyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gc2hhZG93cztcbiAgICAgICAgfSxcbiAgICAgICAgc2VhcmNoUm9vdDogZnVuY3Rpb24oaW5Sb290LCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgdCwgc3QsIHNyLCBvcztcbiAgICAgICAgICAgIGlmIChpblJvb3QpIHtcbiAgICAgICAgICAgICAgICB0ID0gaW5Sb290LmVsZW1lbnRGcm9tUG9pbnQoeCwgeSk7XG4gICAgICAgICAgICAgICAgaWYgKHQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZm91bmQgZWxlbWVudCwgY2hlY2sgaWYgaXQgaGFzIGEgU2hhZG93Um9vdFxuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMudGFyZ2V0aW5nU2hhZG93KHQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5Sb290ICE9PSBkb2N1bWVudCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBjaGVjayBmb3Igc2libGluZyByb290c1xuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMub2xkZXJTaGFkb3coaW5Sb290KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gc2VhcmNoIG90aGVyIHJvb3RzLCBmYWxsIGJhY2sgdG8gbGlnaHQgZG9tIGVsZW1lbnRcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zZWFyY2hSb290KHNyLCB4LCB5KSB8fCB0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBvd25lcjogZnVuY3Rpb24oZWxlbWVudCkge1xuICAgICAgICAgICAgaWYgKCFlbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHMgPSBlbGVtZW50O1xuICAgICAgICAgICAgLy8gd2FsayB1cCB1bnRpbCB5b3UgaGl0IHRoZSBzaGFkb3cgcm9vdCBvciBkb2N1bWVudFxuICAgICAgICAgICAgd2hpbGUgKHMucGFyZW50Tm9kZSkge1xuICAgICAgICAgICAgICAgIHMgPSBzLnBhcmVudE5vZGU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyB0aGUgb3duZXIgZWxlbWVudCBpcyBleHBlY3RlZCB0byBiZSBhIERvY3VtZW50IG9yIFNoYWRvd1Jvb3RcbiAgICAgICAgICAgIGlmIChzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfTk9ERSAmJiBzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfRlJBR01FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICB9LFxuICAgICAgICBmaW5kVGFyZ2V0OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5FdmVudC5wYXRoWzBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgeSA9IGluRXZlbnQuY2xpZW50WTtcbiAgICAgICAgICAgIC8vIGlmIHRoZSBsaXN0ZW5lciBpcyBpbiB0aGUgc2hhZG93IHJvb3QsIGl0IGlzIG11Y2ggZmFzdGVyIHRvIHN0YXJ0IHRoZXJlXG4gICAgICAgICAgICB2YXIgcyA9IHRoaXMub3duZXIoaW5FdmVudC50YXJnZXQpO1xuICAgICAgICAgICAgLy8gaWYgeCwgeSBpcyBub3QgaW4gdGhpcyByb290LCBmYWxsIGJhY2sgdG8gZG9jdW1lbnQgc2VhcmNoXG4gICAgICAgICAgICBpZiAoIXMuZWxlbWVudEZyb21Qb2ludCh4LCB5KSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzLnNlYXJjaFJvb3QocywgeCwgeSk7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaEFjdGlvbjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIG47XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcGF0aCA9IGluRXZlbnQucGF0aDtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgbiA9IHBhdGhbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChuLm5vZGVUeXBlID09PSBOb2RlLkVMRU1FTlRfTk9ERSAmJiBuLmhhc0F0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuLmdldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG4gPSBpbkV2ZW50LnRhcmdldDtcbiAgICAgICAgICAgICAgICB3aGlsZSAobikge1xuICAgICAgICAgICAgICAgICAgICBpZiAobi5ub2RlVHlwZSA9PT0gTm9kZS5FTEVNRU5UX05PREUgJiYgbi5oYXNBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbi5nZXRBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGF1dG8gaXMgZGVmYXVsdFxuICAgICAgICAgICAgcmV0dXJuIFwiYXV0b1wiO1xuICAgICAgICB9LFxuICAgICAgICBMQ0E6IGZ1bmN0aW9uKGEsIGIpIHtcbiAgICAgICAgICAgIGlmIChhID09PSBiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYSAmJiAhYikge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIgJiYgIWEpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghYiAmJiAhYSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGZhc3QgY2FzZSwgYSBpcyBhIGRpcmVjdCBkZXNjZW5kYW50IG9mIGIgb3IgdmljZSB2ZXJzYVxuICAgICAgICAgICAgaWYgKGEuY29udGFpbnMgJiYgYS5jb250YWlucyhiKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIuY29udGFpbnMgJiYgYi5jb250YWlucyhhKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGFkZXB0aCA9IHRoaXMuZGVwdGgoYSk7XG4gICAgICAgICAgICB2YXIgYmRlcHRoID0gdGhpcy5kZXB0aChiKTtcbiAgICAgICAgICAgIHZhciBkID0gYWRlcHRoIC0gYmRlcHRoO1xuICAgICAgICAgICAgaWYgKGQgPj0gMCkge1xuICAgICAgICAgICAgICAgIGEgPSB0aGlzLndhbGsoYSwgZCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGIgPSB0aGlzLndhbGsoYiwgLWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2hpbGUgKGEgJiYgYiAmJiBhICE9PSBiKSB7XG4gICAgICAgICAgICAgICAgYSA9IGEucGFyZW50Tm9kZSB8fCBhLmhvc3Q7XG4gICAgICAgICAgICAgICAgYiA9IGIucGFyZW50Tm9kZSB8fCBiLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgfSxcbiAgICAgICAgd2FsazogZnVuY3Rpb24obiwgdSkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IG4gJiYgKGkgPCB1KTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbiA9IG4ucGFyZW50Tm9kZSB8fCBuLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbjtcbiAgICAgICAgfSxcbiAgICAgICAgZGVwdGg6IGZ1bmN0aW9uKG4pIHtcbiAgICAgICAgICAgIHZhciBkID0gMDtcbiAgICAgICAgICAgIHdoaWxlIChuKSB7XG4gICAgICAgICAgICAgICAgZCsrO1xuICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGQ7XG4gICAgICAgIH0sXG4gICAgICAgIGRlZXBDb250YWluczogZnVuY3Rpb24oYSwgYikge1xuICAgICAgICAgICAgdmFyIGNvbW1vbiA9IHRoaXMuTENBKGEsIGIpO1xuICAgICAgICAgICAgLy8gaWYgYSBpcyB0aGUgY29tbW9uIGFuY2VzdG9yLCBpdCBtdXN0IFwiZGVlcGx5XCIgY29udGFpbiBiXG4gICAgICAgICAgICByZXR1cm4gY29tbW9uID09PSBhO1xuICAgICAgICB9LFxuICAgICAgICBpbnNpZGVOb2RlOiBmdW5jdGlvbihub2RlLCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgcmVjdCA9IG5vZGUuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7XG4gICAgICAgICAgICByZXR1cm4gKHJlY3QubGVmdCA8PSB4KSAmJiAoeCA8PSByZWN0LnJpZ2h0KSAmJiAocmVjdC50b3AgPD0geSkgJiYgKHkgPD0gcmVjdC5ib3R0b20pO1xuICAgICAgICB9LFxuICAgICAgICBwYXRoOiBmdW5jdGlvbihldmVudCkge1xuICAgICAgICAgICAgdmFyIHA7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgZXZlbnQucGF0aCAmJiBldmVudC5wYXRoLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHAgPSBldmVudC5wYXRoO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwID0gW107XG4gICAgICAgICAg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zLmZvckVhY2goZnVuY3Rpb24ocikge1xuICAgICAgICAgICAgaWYgKFN0cmluZyhyKSA9PT0gcikge1xuICAgICAgICAgICAgICAgIHN0eWxlcyArPSBzZWxlY3RvcihyKSArIHJ1bGUocikgKyAnXFxuJztcbiAgICAgICAgICAgICAgICBpZiAoaGFzU2hhZG93Um9vdCkge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZXMgKz0gc2hhZG93U2VsZWN0b3IocikgKyBydWxlKHIpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHlsZXMgKz0gci5zZWxlY3RvcnMubWFwKHNlbGVjdG9yKSArIHJ1bGUoci5ydWxlKSArICdcXG4nO1xuICAgICAgICAgICAgICAgIGlmIChoYXNTaGFkb3dSb290KSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlcyArPSByLnNlbGVjdG9ycy5tYXAoc2hhZG93U2VsZWN0b3IpICsgcnVsZShyLnJ1bGUpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICB2YXIgZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzdHlsZScpO1xuICAgICAgICBlbC50ZXh0Q29udGVudCA9IHN0eWxlcztcbiAgICAgICAgZG9jdW1lbnQuaGVhZC5hcHBlbmRDaGlsZChlbCk7XG4gICAgfVxufSkoKTtcblxuLyoqXG4gKiBUaGlzIGlzIHRoZSBjb25zdHJ1Y3RvciBmb3IgbmV3IFBvaW50ZXJFdmVudHMuXG4gKlxuICogTmV3IFBvaW50ZXIgRXZlbnRzIG11c3QgYmUgZ2l2ZW4gYSB0eXBlLCBhbmQgYW4gb3B0aW9uYWwgZGljdGlvbmFyeSBvZlxuICogaW5pdGlhbGl6YXRpb24gcHJvcGVydGllcy5cbiAqXG4gKiBEdWUgdG8gY2VydGFpbiBwbGF0Zm9ybSByZ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tleXMgPSBPYmplY3Qua2V5cyhpbkRpY3QpLCBrOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGsgPSBrZXlzW2ldO1xuICAgICAgICAgICAgICAgIGlmIChrICE9PSAnYnViYmxlcycgJiYgayAhPT0gJ2NhbmNlbGFibGUnKSB7XG4gICAgICAgICAgICAgICAgICAgIGVba10gPSBpbkRpY3Rba107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIG1ha2VQb2ludGVyRXZlbnQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5EaWN0KSB7XG4gICAgICAgICAgICBpbkRpY3QgPSBpbkRpY3QgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTtcblxuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLm1ha2VCYXNlRXZlbnQoaW5UeXBlLCBpbkRpY3QpO1xuICAgICAgICAgICAgLy8gZGVmaW5lIGluaGVyaXRlZCBNb3VzZUV2ZW50IHByb3BlcnRpZXNcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAyLCBwOyBpIDwgTU9VU0VfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gTU9VU0VfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZVtwXSA9IGluRGljdFtwXSB8fCBNT1VTRV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGUuYnV0dG9ucyA9IGluRGljdC5idXR0b25zIHx8IDA7XG5cbiAgICAgICAgICAgIC8vIFNwZWMgcmVxdWlyZXMgdGhhdCBwb2ludGVycyB3aXRob3V0IHByZXNzdXJlIHNwZWNpZmllZCB1c2UgMC41IGZvciBkb3duXG4gICAgICAgICAgICAvLyBzdGF0ZSBhbmQgMCBmb3IgdXAgc3RhdGUuXG4gICAgICAgICAgICB2YXIgcHJlc3N1cmUgPSAwO1xuICAgICAgICAgICAgaWYgKGluRGljdC5wcmVzc3VyZSkge1xuICAgICAgICAgICAgICAgIHByZXNzdXJlID0gaW5EaWN0LnByZXNzdXJlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwcmVzc3VyZSA9IGUuYnV0dG9ucyA/IDAuNSA6IDA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIGFkZCB4L3kgcHJvcGVydGllcyBhbGlhc2VkIHRvIGNsaWVudFgvWVxuICAgICAgICAgICAgZS54ID0gZS5jbGllbnRYO1xuICAgICAgICAgICAgZS55ID0gZS5jbGllbnRZO1xuXG4gICAgICAgICAgICAvLyBkZWZpbmUgdGhlIHByb3BlcnRpZXMgb2YgdGhlIFBvaW50ZXJFdmVudCBpbnRlcmZhY2VcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gaW5EaWN0LnBvaW50ZXJJZCB8fCAwO1xuICAgICAgICAgICAgZS53aWR0aCA9IGluRGljdC53aWR0aCB8fCAwO1xuICAgICAgICAgICAgZS5oZWlnaHQgPSBpbkRpY3QuaGVpZ2h0IHx8IDA7XG4gICAgICAgICAgICBlLnByZXNzdXJlID0gcHJlc3N1cmU7XG4gICAgICAgICAgICBlLnRpbHRYID0gaW5EaWN0LnRpbHRYIHx8IDA7XG4gICAgICAgICAgICBlLnRpbHRZID0gaW5EaWN0LnRpbHRZIHx8IDA7XG4gICAgICAgICAgICBlLnBvaW50ZXJUeXBlID0gaW5EaWN0LnBvaW50ZXJUeXBlIHx8ICcnO1xuICAgICAgICAgICAgZS5od1RpbWVzdGFtcCA9IGluRGljdC5od1RpbWVzdGFtcCB8fCAwO1xuICAgICAgICAgICAgZS5pc1ByaW1hcnkgPSBpbkRpY3QuaXNQcmltYXJ5IHx8IGZhbHNlO1xuICAgICAgICAgICAgZS5fc291cmNlID0gaW5EaWN0Ll9zb3VyY2UgfHwgJyc7XG4gICAgICAgICAgICByZXR1cm4gZTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBzY29wZS5ldmVudEZhY3RvcnkgPSBldmVudEZhY3Rvcnk7XG59KShleHBvcnRzKTtcblxuLyoqXG4gKiBUaGlzIG1vZHVsZSBpbXBsZW1lbnRzIGFuIG1hcCBvZiBwb2ludGVyIHN0YXRlc1xuICovXG4oZnVuY3Rpb24oc2NvcGUpIHtcbiAgICB2YXIgVVNFX01BUCA9IHdpbmRvdy5NYXAgJiYgd2luZG93Lk1hcC5wcm90b3R5cGUuZm9yRWFjaDtcbiAgICB2YXIgUE9JTlRFUlNfRk4gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc2l6ZTtcbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gUG9pbnRlck1hcCgpIHtcbiAgICAgICAgaWYgKFVTRV9NQVApIHtcbiAgICAgICAgICAgIHZhciBtID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgbS5wb2ludGVycyA9IFBPSU5URVJTX0ZOO1xuICAgICAgICAgICAgcmV0dXJuIG07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmtleXMgPSBbXTtcbiAgICAgICAgICAgIHRoaXMudmFsdWVzID0gW107XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBQb2ludGVyTWFwLnByb3RvdHlwZSA9IHtcbiAgICAgICAgc2V0OiBmdW5jdGlvbihpbklkLCBpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgaSA9IHRoaXMua2V5cy5pbmRleE9mKGluSWQpO1xuICAgICAgICAgICAgaWYgKGkgPiAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMudmFsdWVzW2ldID0gaW5FdmVudDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5rZXlzLnB1c2goaW5JZCk7XG4gICAgICAgICAgICAgICAgdGhpcy52YWx1ZXMucHVzaChpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgaGFzOiBmdW5jdGlvbihpbklkKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCkgPiAtMTtcbiAgICAgICAgfSxcbiAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uKGluSWQpIHtcbiAgICAgICAgICAgIHZhciBpID0gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCk7XG4gICAgICAgICAgICBpZiAoaSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5rZXlzLnNwbGljZShpLCAxKTtcbiAgICAgICAgICAgICAgICB0aGlzLnZhbHVlcy5zcGxpY2UoaSwgMSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGdldDogZnVuY3Rpb24oaW5JZCkge1xuICAgICAgICAgICAgdmFyIGkgPSB0aGlzLmtleXMuaW5kZXhPZihpbklkKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnZhbHVlc1tpXTtcbiAgICAgICAgfSxcbiAgICAgICAgY2xlYXI6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdGhpcy5rZXlzLmxlbmd0aCA9IDA7XG4gICAgICAgICAgICB0aGlzLnZhbHVlcy5sZW5ndGggPSAwO1xuICAgICAgICB9LFxuICAgICAgICAvLyByZXR1cm4gdmFsdWUsIGtleSwgbWFwXG4gICAgICAgIGZvckVhY2g6IGZ1bmN0aW9uKGNhbGxiYWNrLCB0aGlzQXJnKSB7XG4gICAgICAgICAgICB0aGlzLnZhbHVlcy5mb3JFYWNoKGZ1bmN0aW9uKHYsIGkpIHtcbiAgICAgICAgICAgICAgICBjYWxsYmFjay5jYWxsKHRoaXNBcmcsIHYsIHRoaXMua2V5c1tpXSwgdGhpcyk7XG4gICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgfSxcbiAgICAgICAgcG9pbnRlcnM6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMua2V5cy5sZW5ndGg7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2NvcGUuUG9pbnRlck1hcCA9IFBvaW50ZXJNYXA7XG59KShleHBvcnRzKTtcblxuKGZ1bmN0aW9uKHNjb3BlKSB7XG4gICAgdmFyIENMT05FX1BST1BTID0gW1xuICAgICAgICAvLyBNb3VzZUV2ZW50XG4gICAgICAgICdidWJibGVzJyxcbiAgICAgICAgJ2NhbmNlbGFibGUnLFxuICAgICAgICAndmlldycsXG4gICAgICAgICdkZXRhaWwnLFxuICAgICAgICAnc2NyZWVuWCcsXG4gICAgICAgICdzY3JlZW5ZJyxcbiAgICAgICAgJ2NsaWVudFgnLFxuICAgICAgICAnY2xpZW50WScsXG4gICAgICAgICdjdHJsS2V5JyxcbiAgICAgICAgJ2FsdEtleScsXG4gICAgICAgICdzaGlmdEtleScsXG4gICAgICAgICdtZXRhS2V5JyxcbiAgICAgICAgJ2J1dHRvbicsXG4gICAgICAgICdyZWxhdGVkVGFyZ2V0JyxcbiAgICAgICAgLy8gRE9NIExldmVsIDNcbiAgICAgICAgJ2J1dHRvbnMnLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgJ3BvaW50ZXJJZCcsXG4gICAgICAgICd3aWR0aCcsXG4gICAgICAgICdoZWlnaHQnLFxuICAgICAgICAncHJlc3N1cmUnLFxuICAgICAgICAndGlsdFgnLFxuICAgICAgICAndGlsdFknLFxuICAgICAgICAncG9pbnRlclR5cGUnLFxuICAgICAgICAnaHdUaW1lc3RhbXAnLFxuICAgICAgICAnaXNQcmltYXJ5JyxcbiAgICAgICAgLy8gZXZlbnQgaW5zdGFuY2VcbiAgICAgICAgJ3R5cGUnLFxuICAgICAgICAndGFyZ2V0JyxcbiAgICAgICAgJ2N1cnJlbnRUYXJnZXQnLFxuICAgICAgICAnd2hpY2gnLFxuICAgICAgICAncGFnZVgnLFxuICAgICAgICAncGFnZVknLFxuICAgICAgICAndGltZVN0YW1wJyxcbiAgICAgICAgLy8gZ2VzdHVyZSBhZGRvbnNcbiAgICAgICAgJ3ByZXZlbnRUYXAnLFxuICAgICAgICAndGFwUHJldmVudGVkJyxcbiAgICAgICAgJ19zb3VyY2UnXG4gICAgXTtcblxuICAgIHZhciBDTE9ORV9ERUZBVUxUUyA9IFtcbiAgICAgICAgLy8gTW91c2VFdmVudFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIG51bGwsXG4gICAgICAgIG51bGwsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAwLFxuICAgICAgICBudWxsLFxuICAgICAgICAvLyBET00gTGV2ZWwgM1xuICAgICAgICAwLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgJycsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAvLyBldmVudCBpbnN0YW5jZVxuICAgICAgICAnJyxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgZnVuY3Rpb24oKSB7fSxcbiAgICAgICAgZmFsc2VcbiAgICBdO1xuXG4gICAgdmFyIEhBU19TVkdfSU5TVEFOQ0UgPSAodHlwZW9mIFNWR0VsZW1lbnRJbnN0YW5jZSAhPT0gJ3VuZGVmaW5lZCcpO1xuXG4gICAgdmFyIGV2ZW50RmFjdG9yeSA9IHNjb3BlLmV2ZW50RmFjdG9yeTtcblxuICAgIC8vIHNldCBvZiByZWNvZ25pemVycyB0byBydW4gZm9yIHRoZSBjdX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Qgc291cmNlXG4gICAgICAgICAqIEBwYXJhbSB7T2JqZWN0fSBzb3VyY2UgQSBuZXcgc291cmNlIG9mIHBsYXRmb3JtIGV2ZW50cy5cbiAgICAgICAgICovXG4gICAgICAgIHJlZ2lzdGVyU291cmNlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBzID0gc291cmNlO1xuICAgICAgICAgICAgdmFyIG5ld0V2ZW50cyA9IHMuZXZlbnRzO1xuICAgICAgICAgICAgaWYgKG5ld0V2ZW50cykge1xuICAgICAgICAgICAgICAgIG5ld0V2ZW50cy5mb3JFYWNoKGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNbZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXZlbnRNYXBbZV0gPSBzW2VdLmJpbmQocyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgICAgICAgICB0aGlzLmV2ZW50U291cmNlc1tuYW1lXSA9IHM7XG4gICAgICAgICAgICAgICAgdGhpcy5ldmVudFNvdXJjZUxpc3QucHVzaChzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXJHZXN0dXJlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgb2JqLmxpc3RlbmVycyA9IDA7XG4gICAgICAgICAgICBvYmouaW5kZXggPSB0aGlzLmdlc3R1cmVzLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBnOyBpIDwgc291cmNlLmV4cG9zZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBnID0gc291cmNlLmV4cG9zZXNbaV0udG9Mb3dlckNhc2UoKTtcbiAgICAgICAgICAgICAgICB0aGlzLmRlcGVuZGVuY3lNYXBbZ10gPSBvYmo7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmdlc3R1cmVzLnB1c2goc291cmNlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQsIGluaXRpYWwpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMucmVnaXN0ZXIuY2FsbChlcywgZWxlbWVudCwgaW5pdGlhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVucmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMudW5yZWdpc3Rlci5jYWxsKGVzLCBlbGVtZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gRVZFTlRTXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5zZXQoaW5FdmVudC5wb2ludGVySWQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgnZG93bicsIGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBtb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBwaXBlIG1vdmUgZXZlbnRzIGludG8gZ2VzdHVyZSBxdWV1ZSBkaXJlY3RseVxuICAgICAgICAgICAgaW5FdmVudC50eXBlID0gJ21vdmUnO1xuICAgICAgICAgICAgdGhpcy5maWxsR2VzdHVyZVF1ZXVlKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdGhpcy5maXJlRXZlbnQoJ3VwJywgaW5FdmVudCk7XG4gICAgICAgICAgICB0aGlzLnJlcXVpcmVkR2VzdHVyZXMuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpbkV2ZW50LnRhcFByZXZlbnRlZCA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgndXAnLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBhZGRHZXN0dXJlRGVwZW5kZW5jeTogZnVuY3Rpb24obm9kZSwgY3VycmVudEdlc3R1cmVzKSB7XG4gICAgICAgICAgICB2YXIgZ2VzdHVyZXNXYW50ZWQgPSBub2RlLl9wZ0V2ZW50cztcbiAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZCAmJiBjdXJyZW50R2VzdHVyZXMpIHtcbiAgICAgICAgICAgICAgICB2YXIgZ2sgPSBPYmplY3Qua2V5cyhnZXN0dXJlc1dhbnRlZCk7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIHIsIHJpLCBnOyBpIDwgZ2subGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZ2VzdHVyZVxuICAgICAgICAgICAgICAgICAgICBnID0gZ2tbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZFtnXSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb2t1cCBnZXN0dXJlIHJlY29nbml6ZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIHIgPSB0aGlzLmRlcGVuZGVuY3lNYXBbZ107XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyByZWNvZ25pemVyIGluZGV4XG4gICAgICAgICAgICAgICAgICAgICAgICByaSA9IHIgPyByLmluZGV4IDogLTE7XG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXNbcmldID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gTElTVEVORVIgTE9HSUNcbiAgICAgICAgZXZlbnRIYW5kbGVyOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBUaGlzIGlzIHVzZWQgdG8gcHJldmVudCBtdWx0aXBsZSBkaXNwYXRjaCBvZiBldmVudHMgZnJvbVxuICAgICAgICAgICAgLy8gcGxhdGZvcm0gZXZlbnRzLiBUaGlzIGNhbiBoYXBwZW4gd2hlbiB0d28gZWxlbWVudHMgaW4gZGlmZmVyZW50IHNjb3Blc1xuICAgICAgICAgICAgLy8gYXJlIHNldCB1cCB0byBjcmVhdGUgcG9pbnRlciBldmVudHMsIHdoaWNoIGlzIHJlbGV2YW50IHRvIFNoYWRvdyBET00uXG5cbiAgICAgICAgICAgIHZhciB0eXBlID0gaW5FdmVudC50eXBlO1xuXG4gICAgICAgICAgICAvLyBvbmx5IGdlbmVyYXRlIHRoZSBsaXN0IG9mIGRlc2lyZWQgZXZlbnRzIG9uIFwiZG93blwiXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICdtb3VzZWRvd24nIHx8IHR5cGUgPT09ICdwb2ludGVyZG93bicgfHwgdHlwZSA9PT0gJ01TUG9pbnRlckRvd24nKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFpbkV2ZW50Ll9oYW5kbGVkQnlQRykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXMgPSB7fTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBpbiBJT1MgbW9kZSwgdGhlcmUgaXMgb25seSBhIGxpc3RlbmVyIG9uIHRoZSBkb2N1bWVudCwgc28gdGhpcyBpcyBub3QgcmUtZW50cmFudFxuICAgICAgICAgICAgICAgIGlmICh0aGlzLklTX0lPUykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZXYgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3QgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2V0IHVwIGEgZmFrZSBldmVudCB0byBnaXZlIHRvIHRoZSBwYXRoIGJ1aWxkZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaW5FdmVudC50YXJnZXQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WDogY3QuY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiBjdC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IGluRXZlbnQucGF0aFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAvLyB1c2UgZXZlbnQgcGF0aCBpZiBhdmFpbGFibGUsIG90aGVyd2lzZSBidWlsZCBhIHBhdGggZnJvbSB0YXJnZXQgZmluZGluZ1xuICAgICAgICAgICAgICAgICAgICB2YXIgbm9kZXMgPSBpbkV2ZW50LnBhdGggfHwgc2NvcGUudGFyZ2V0RmluZGluZy5wYXRoKGV2KTtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIG47IGkgPCBub2Rlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbiA9IG5vZGVzW2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShuLCBjdXJyZW50R2VzdHVyZXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShpbkV2ZW50LmN1cnJlbnRUYXJnZXQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoaW5FdmVudC5faGFuZGxlZEJ5UEcpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZm4gPSB0aGlzLmV2ZW50TWFwICYmIHRoaXMuZXZlbnRNYXBbdHlwZV07XG4gICAgICAgICAgICBpZiAoZm4pIHtcbiAgICAgICAgICAgICAgICBmbihpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGluRXZlbnQuX2hhbmRsZWRCeVBHID0gdHJ1ZTtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gc2V0IHVwIGV2ZW50IGxp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JucyBhIHNuYXBzaG90IG9mIGluRXZlbnQsIHdpdGggd3JpdGFibGUgcHJvcGVydGllcy5cbiAgICAgICAgICpcbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gaW5FdmVudCBBbiBldmVudCB0aGF0IGNvbnRhaW5zIHByb3BlcnRpZXMgdG8gY29weS5cbiAgICAgICAgICogQHJldHVybiB7T2JqZWN0fSBBbiBvYmplY3QgY29udGFpbmluZyBzaGFsbG93IGNvcGllcyBvZiBgaW5FdmVudGAnc1xuICAgICAgICAgKiAgICBwcm9wZXJ0aWVzLlxuICAgICAgICAgKi9cbiAgICAgICAgY2xvbmVFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGV2ZW50Q29weSA9IE9iamVjdC5jcmVhdGUobnVsbCksXG4gICAgICAgICAgICAgICAgcDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgQ0xPTkVfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gQ0xPTkVfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZXZlbnRDb3B5W3BdID0gaW5FdmVudFtwXSB8fCBDTE9ORV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgICAgICAvLyBXb3JrIGFyb3VuZCBTVkdJbnN0YW5jZUVsZW1lbnQgc2hhZG93IHRyZWVcbiAgICAgICAgICAgICAgICAvLyBSZXR1cm4gdGhlIDx1c2U+IGVsZW1lbnQgdGhhdCBpcyByZXByZXNlbnRlZCBieSB0aGUgaW5zdGFuY2UgZm9yIFNhZmFyaSwgQ2hyb21lLCBJRS5cbiAgICAgICAgICAgICAgICAvLyBUaGlzIGlzIHRoZSBiZWhhdmlvciBpbXBsZW1lbnRlZCBieSBGaXJlZm94LlxuICAgICAgICAgICAgICAgIGlmIChwID09PSAndGFyZ2V0JyB8fCBwID09PSAncmVsYXRlZFRhcmdldCcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKEhBU19TVkdfSU5TVEFOQ0UgJiYgZXZlbnRDb3B5W3BdIGluc3RhbmNlb2YgU1ZHRWxlbWVudEluc3RhbmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudENvcHlbcF0gPSBldmVudENvcHlbcF0uY29ycmVzcG9uZGluZ1VzZUVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBrZWVwIHRoZSBzZW1hbnRpY3Mgb2YgcHJldmVudERlZmF1bHRcbiAgICAgICAgICAgIGV2ZW50Q29weS5wcmV2ZW50RGVmYXVsdCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGluRXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4gZXZlbnRDb3B5O1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogRGlzcGF0Y2hlcyB0aGUgZXZlbnQgdG8gaXRzIHRhcmdldC5cbiAgICAgICAgICpcbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gaW5FdmVudCBUaGUgZXZlbnQgdG8gYmUgZGlzcGF0Y2hlZC5cbiAgICAgICAgICogQHJldHVybiB7Qm9vbGVhbn0gVHJ1ZSBpZiBhbiBldmVudCBoYW5kbGVyIHJldHVybnMgdHJ1ZSwgZmFsc2Ugb3RoZXJ3aXNlLlxuICAgICAgICAgKi9cbiAgICAgICAgZGlzcGF0Y2hFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50Ll90YXJnZXQ7XG4gICAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgICAgIHQuZGlzcGF0Y2hFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICAvLyBjbG9uZSB0aGUgZXZlbnQgZm9yIHRoZSBnZXN0dXJlIHN5c3RlbSB0byBwcm9jZXNzXG4gICAgICAgICAgICAgICAgLy8gY2xvbmUgYWZ0ZXIgZGlzcGF0Y2ggdG8gcGljayB1cCBnZXN0dXJlIHByZXZlbnRpb24gY29kZVxuICAgICAgICAgICAgICAgIHZhciBjbG9uZSA9IHRoaXMuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBjbG9uZS50YXJnZXQgPSB0O1xuICAgICAgICAgICAgICAgIHRoaXMuZmlsbEdlc3R1cmVRdWV1ZShjbG9uZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGdlc3R1cmVUcmlnZ2VyOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIC8vIHByb2Nlc3MgdGhlIGdlc3R1cmUgcXVldWVcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBlLCByZzsgaSA8IHRoaXMuZ2VzdHVyZVF1ZXVlLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgZSA9IHRoaXMuZ2VzdHVyZVF1ZXVlW2ldO1xuICAgICAgICAgICAgICAgIHJnID0gZS5fcmVxdWlyZWRHZXN0dXJlcztcbiAgICAgICAgICAgICAgICBpZiAocmcpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGcsIGZuOyBqIDwgdGhpcy5nZXN0dXJlcy5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gb25seSBydW4gcmVjb2duaXplciBpZiBhbiBlbGVtZW50IGluIHRoZSBzb3VyY2UgZXZlbnQncyBwYXRoIGlzIGxpc3RlbmluZyBmb3IgdGhvc2UgZ2VzdHVyZXNcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZ1tqXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGcgPSB0aGlzLmdlc3R1cmVzW2pdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuID0gZ1tlLnR5cGVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbi5jYWxsKGcsIGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuZ2VzdHVyZVF1ZXVlLmxlbmd0aCA9IDA7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbGxHZXN0dXJlUXVldWU6IGZ1bmN0aW9uKGV2KSB7XG4gICAgICAgICAgICAvLyBvbmx5IHRyaWdnZXIgdGhlIGdlc3R1cmUgcXVldWUgb25jZVxuICAgICAgICAgICAgaWYgKCF0aGlzLmdlc3R1cmVRdWV1ZS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5ib3VuZEdlc3R1cmVUcmlnZ2VyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGV2Ll9yZXF1aXJlZEdlc3R1cmVzID0gdGhpcy5yZXF1aXJlZEdlc3R1cmVzLmdldChldi5wb2ludGVySWQpO1xuICAgICAgICAgICAgdGhpcy5nZXN0dXJlUXVldWUucHVzaChldik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIGRpc3BhdGNoZXIuYm91bmRIYW5kbGVyID0gZGlzcGF0Y2hlci5ldmVudEhhbmRsZXIuYmluZChkaXNwYXRjaGVyKTtcbiAgICBkaXNwYXRjaGVyLmJvdW5kR2VzdHVyZVRyaWdnZXIgPSBkaXNwYXRjaGVyLmdlc3R1cmVUcmlnZ2VyLmJpbmQoZGlzcGF0Y2hlcik7XG4gICAgc2NvcGUuZGlzcGF0Y2hlciA9IGRpc3BhdGNoZXI7XG5cbiAgICAvKipcbiAgICAgKiBMaXN0ZW4gZm9yIGBnZXN0dXJlYCBvb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Vjb2duaXplci5kZWZhdWx0QWN0aW9uc1tnXTtcbiAgICAgICAgICAgICAgICB2YXIgYWN0aW9uTm9kZTtcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKG5vZGUubm9kZVR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBOb2RlLkVMRU1FTlRfTk9ERTpcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbk5vZGUgPSBub2RlO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgTm9kZS5ET0NVTUVOVF9GUkFHTUVOVF9OT0RFOlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG5vZGUuaG9zdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRvdWNoQWN0aW9uICYmIGFjdGlvbk5vZGUgJiYgIWFjdGlvbk5vZGUuaGFzQXR0cmlidXRlKCd0b3VjaC1hY3Rpb24nKSkge1xuICAgICAgICAgICAgICAgICAgICBhY3Rpb25Ob2RlLnNldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJywgdG91Y2hBY3Rpb24pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghbm9kZS5fcGdFdmVudHMpIHtcbiAgICAgICAgICAgICAgICBub2RlLl9wZ0V2ZW50cyA9IHt9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbm9kZS5fcGdFdmVudHNbZ10gPSAobm9kZS5fcGdFdmVudHNbZ10gfHwgMCkgKyAxO1xuICAgICAgICAgICAgbm9kZS5fcGdMaXN0ZW5lcn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HM6Ly9jb2RlcmV2aWV3LmNocm9taXVtLm9yZy83Mjc1OTMwMDMvI21zZzE2XG4gICAgICAgIGlmIChGSVJFRk9YX0xJTlVYLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBNb3VzZUV2ZW50KCd0ZXN0Jywge1xuICAgICAgICAgICAgICAgIGJ1dHRvbnM6IDFcbiAgICAgICAgICAgIH0pLmJ1dHRvbnMgPT09IDE7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgIH0pKCk7XG5cbiAgICAvLyBoYW5kbGVyIGJsb2NrIGZvciBuYXRpdmUgbW91c2UgZXZlbnRzXG4gICAgdmFyIG1vdXNlRXZlbnRzID0ge1xuICAgICAgICBQT0lOVEVSX0lEOiAxLFxuICAgICAgICBQT0lOVEVSX1RZUEU6ICdtb3VzZScsXG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ21vdXNlZG93bicsXG4gICAgICAgICAgICAnbW91c2Vtb3ZlJyxcbiAgICAgICAgICAgICdtb3VzZXVwJ1xuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICAgICAgJ21vdmUnXG4gICAgICAgIF0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGxhc3RUb3VjaGVzOiBbXSxcbiAgICAgICAgLy8gY29sbGlkZSB3aXRoIHRoZSBnbG9iYWwgbW91c2UgbGlzdGVuZXJcbiAgICAgICAgaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGx0cyA9IHRoaXMubGFzdFRvdWNoZXM7XG4gICAgICAgICAgICB2YXIgeCA9IGluRXZlbnQuY2xpZW50WCxcbiAgICAgICAgICAgICAgICB5ID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBsdHMubGVuZ3RoLCB0OyBpIDwgbCAmJiAodCA9IGx0c1tpXSk7IGkrKykge1xuICAgICAgICAgICAgICAgIC8vIHNpbXVsYXRlZCBtb3VzZSBldmVudHMgd2lsbCBiZSBzd2FsbG93ZWQgbmVhciBhIHByaW1hcnkgdG91Y2hlbmRcbiAgICAgICAgICAgICAgICB2YXIgZHggPSBNYXRoLmFicyh4IC0gdC54KSxcbiAgICAgICAgICAgICAgICAgICAgZHkgPSBNYXRoLmFicyh5IC0gdC55KTtcbiAgICAgICAgICAgICAgICBpZiAoZHggPD0gREVEVVBfRElTVCAmJiBkeSA8PSBERURVUF9ESVNUKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gdGhpcy5QT0lOVEVSX0lEO1xuICAgICAgICAgICAgZS5pc1ByaW1hcnkgPSB0cnVlO1xuICAgICAgICAgICAgZS5wb2ludGVyVHlwZSA9IHRoaXMuUE9JTlRFUl9UWVBFO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ21vdXNlJztcbiAgICAgICAgICAgIGlmICghSEFTX0JVVFRPTlMpIHtcbiAgICAgICAgICAgICAgICB2YXIgdHlwZSA9IGluRXZlbnQudHlwZTtcbiAgICAgICAgICAgICAgICB2YXIgYml0ID0gV0hJQ0hfVE9fQlVUVE9OU1tpbkV2ZW50LndoaWNoXSB8fCAwO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlID09PSAnbW91c2Vkb3duJykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50QnV0dG9ucyB8PSBiaXQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09PSAnbW91c2V1cCcpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudEJ1dHRvbnMgJj0gfmJpdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZS5idXR0b25zID0gY3VycmVudEJ1dHRvbnM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZTtcbiAgICAgICAgfSxcbiAgICAgICAgbW91c2Vkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaChpbkV2ZW50KSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5oYXModGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldCh0aGlzLlBPSU5URVJfSUQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLmRvd24oZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdXNlbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQodGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gdGFyZ2V0O1xuICAgICAgICAgICAgICAgICAgICAvLyBoYW5kbGUgY2FzZSB3aGVyZSB3ZSBtaXNzZWQgYSBtb3VzZXVwXG4gICAgICAgICAgICAgICAgICAgIGlmICgoSEFTX0JVVFRPTlMgPyBlLmJ1dHRvbnMgOiBlLndoaWNoKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFIQVNfQlVUVE9OUykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRCdXR0b25zID0gZS5idXR0b25zID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIuY2FuY2VsKGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhbnVwTW91c2UoZS5idXR0b25zKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubW92ZShlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW91c2V1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldCh0aGlzLlBPSU5URVJfSUQpO1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGVhbnVwTW91c2UoZS5idXR0b25zKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2xlYW51cE1vdXNlOiBmdW5jdGlvbihidXR0b25zKSB7XG4gICAgICAgICAgICBpZiAoYnV0dG9ucyA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuZGVsZXRlKHRoaXMuUE9JTlRFUl9JRCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2NvcGUubW91c2VFdmVudHMgPSBtb3VzZUV2ZW50cztcbn0pKGV4cG9ydHMpO1xuXG4oZnVuY3Rpb24oc2NvcGUpIHtcbiAgICB2YXIgZGlzcGF0Y2hlciA9IHNjb3BlLmRpc3BhdGNoZXI7XG4gICAgdmFyIGFsbFNoYWRvd3MgPSBzY29wZS50YXJnZXRGaW5kaW5nLmFsbFNoYWRvd3MuYmluZChzY29wZS50YXJnZXRGaW5kaW5nKTtcbiAgICB2YXIgcG9pbnRlcm1hcCA9IGRpc3BhdGNoZXIucG9pbnRlcm1hcDtcbiAgICB2YXI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iAgICAgICAgICAgIGlmICh0aGlzLklTX0lPUyA/IGluaXRpYWwgOiAhaW5pdGlhbCkge1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5JU19JT1MpIHtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLnVubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzY3JvbGxUeXBlczoge1xuICAgICAgICAgICAgRU1JVFRFUjogJ25vbmUnLFxuICAgICAgICAgICAgWFNDUk9MTEVSOiAncGFuLXgnLFxuICAgICAgICAgICAgWVNDUk9MTEVSOiAncGFuLXknLFxuICAgICAgICB9LFxuICAgICAgICB0b3VjaEFjdGlvblRvU2Nyb2xsVHlwZTogZnVuY3Rpb24odG91Y2hBY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciB0ID0gdG91Y2hBY3Rpb247XG4gICAgICAgICAgICB2YXIgc3QgPSB0aGlzLnNjcm9sbFR5cGVzO1xuICAgICAgICAgICAgaWYgKHQgPT09IHN0LkVNSVRURVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ25vbmUnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5YU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1gnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5ZU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1knO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1hZJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgUE9JTlRFUl9UWVBFOiAndG91Y2gnLFxuICAgICAgICBmaXJzdFRvdWNoOiBudWxsLFxuICAgICAgICBpc1ByaW1hcnlUb3VjaDogZnVuY3Rpb24oaW5Ub3VjaCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlyc3RUb3VjaCA9PT0gaW5Ub3VjaC5pZGVudGlmaWVyO1xuICAgICAgICB9LFxuICAgICAgICBzZXRQcmltYXJ5VG91Y2g6IGZ1bmN0aW9uKGluVG91Y2gpIHtcbiAgICAgICAgICAgIC8vIHNldCBwcmltYXJ5IHRvdWNoIGlmIHRoZXJlIG5vIHBvaW50ZXJzLCBvciB0aGUgb25seSBwb2ludGVyIGlzIHRoZSBtb3VzZVxuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAucG9pbnRlcnMoKSA9PT0gMCB8fCAocG9pbnRlcm1hcC5wb2ludGVycygpID09PSAxICYmIHBvaW50ZXJtYXAuaGFzKDEpKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyc3RUb3VjaCA9IGluVG91Y2guaWRlbnRpZmllcjtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSB7XG4gICAgICAgICAgICAgICAgICAgIFg6IGluVG91Y2guY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgWTogaW5Ub3VjaC5jbGllbnRZXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0VGFyZ2V0ID0gaW5Ub3VjaC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsUmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHJlbW92ZVByaW1hcnlQb2ludGVyOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGlmIChpblBvaW50ZXIuaXNQcmltYXJ5KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFRvdWNoID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNsaWNrQ291bnQ6IDAsXG4gICAgICAgIHJlc2V0SWQ6IG51bGwsXG4gICAgICAgIHJlc2V0Q2xpY2tDb3VudDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgZm4gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmNsaWNrQ291bnQgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRJZCA9IG51bGw7XG4gICAgICAgICAgICB9LmJpbmQodGhpcyk7XG4gICAgICAgICAgICB0aGlzLnJlc2V0SWQgPSBzZXRUaW1lb3V0KGZuLCBDTElDS19DT1VOVF9USU1FT1VUKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsUmVzZXRDbGlja0NvdW50OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlc2V0SWQpIHtcbiAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5yZXNldElkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdHlwZVRvQnV0dG9uczogZnVuY3Rpb24odHlwZSkge1xuICAgICAgICAgICAgdmFyIHJldCA9IDA7XG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICd0b3VjaG1vdmUnKSB7XG4gICAgICAgICAgICAgICAgcmV0ID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUYXJnZXQ6IGZ1bmN0aW9uKHRvdWNoLCBpZCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudFRvdWNoRXZlbnQudHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNQcmltYXJ5VG91Y2godG91Y2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmYXN0UGF0aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFg6IHRvdWNoLmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiB0b3VjaC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgcGF0aDogdGhpcy5jdXJyZW50VG91Y2hFdmVudC5wYXRoLFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiB0aGlzLmN1cnJlbnRUb3VjaEV2ZW50LnRhcmdldFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2NvcGUuZmluZFRhcmdldChmYXN0UGF0aCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjb3BlLmZpbmRUYXJnZXQodG91Y2gpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIHJldXNlIHRhcmdldCB3ZSBmb3VuZCBpbiB0b3VjaHN0YXJ0XG4gICAgICAgICAgICByZXR1cm4gcG9pbnRlcm1hcC5nZXQoaWQpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaFRvUG9pbnRlcjogZnVuY3Rpb24oaW5Ub3VjaCkge1xuICAgICAgICAgICAgdmFyIGN0ZSA9IHRoaXMuY3VycmVudFRvdWNoRXZlbnQ7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpblRvdWNoKTtcbiAgICAgICAgICAgIC8vIFNwZWMgc3BlY2lmaWVzIHRoYXQgcG9pbnRlcklkIDEgaXMg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mID0gdGhpcztcbiAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHNlbGYuZmlyc3RYWSA9IG51bGw7XG4gICAgICAgICAgICAgICAgY3RlLnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIHByb2Nlc3NUb3VjaGVzOiBmdW5jdGlvbihpbkV2ZW50LCBpbkZ1bmN0aW9uKSB7XG4gICAgICAgICAgICB2YXIgdGwgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzO1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50VG91Y2hFdmVudCA9IGluRXZlbnQ7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgdCwgcDsgaSA8IHRsLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdCA9IHRsW2ldO1xuICAgICAgICAgICAgICAgIHAgPSB0aGlzLnRvdWNoVG9Qb2ludGVyKHQpO1xuICAgICAgICAgICAgICAgIGlmIChpbkV2ZW50LnR5cGUgPT09ICd0b3VjaHN0YXJ0Jykge1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldChwLnBvaW50ZXJJZCwgcC50YXJnZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5oYXMocC5wb2ludGVySWQpKSB7XG4gICAgICAgICAgICAgICAgICAgIGluRnVuY3Rpb24uY2FsbCh0aGlzLCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGluRXZlbnQudHlwZSA9PT0gJ3RvdWNoZW5kJyB8fCBpbkV2ZW50Ll9jYW5jZWwpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhblVwUG9pbnRlcihwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIEZvciBzaW5nbGUgYXhpcyBzY3JvbGxlcnMsIGRldGVybWluZXMgd2hldGhlciB0aGUgZWxlbWVudCBzaG91bGQgZW1pdFxuICAgICAgICAvLyBwb2ludGVyIGV2ZW50cyBvciBiZWhhdmUgYXMgYSBzY3JvbGxlclxuICAgICAgICBzaG91bGRTY3JvbGw6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmV0O1xuICAgICAgICAgICAgICAgIHZhciB0b3VjaEFjdGlvbiA9IHNjb3BlLnRhcmdldEZpbmRpbmcuZmluZFRvdWNoQWN0aW9uKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIHZhciBzY3JvbGxBeGlzID0gdGhpcy50b3VjaEFjdGlvblRvU2Nyb2xsVHlwZSh0b3VjaEFjdGlvbik7XG4gICAgICAgICAgICAgICAgaWYgKHNjcm9sbEF4aXMgPT09ICdub25lJykge1xuICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIGVsZW1lbnQgaXMgYSB0b3VjaC1hY3Rpb246IG5vbmUsIHNob3VsZCBuZXZlciBzY3JvbGxcbiAgICAgICAgICAgICAgICAgICAgcmV0ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzY3JvbGxBeGlzID09PSAnWFknKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIHRoaXMgZWxlbWVudCBzaG91bGQgYWx3YXlzIHNjcm9sbFxuICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdGhlIGludGVuZGVkIHNjcm9sbCBheGlzLCBhbmQgb3RoZXIgYXhpc1xuICAgICAgICAgICAgICAgICAgICB2YXIgYSA9IHNjcm9sbEF4aXM7XG4gICAgICAgICAgICAgICAgICAgIHZhciBvYSA9IHNjcm9sbEF4aXMgPT09ICdZJyA/ICdYJyA6ICdZJztcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRhID0gTWF0aC5hYnModFsnY2xpZW50JyArIGFdIC0gdGhpcy5maXJzdFhZW2FdKTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRvYSA9IE1hdGguYWJzKHRbJ2NsaWVudCcgKyBvYV0gLSB0aGlzLmZpcnN0WFlbb2FdKTtcbiAgICAgICAgICAgICAgICAgICAgLy8gaWYgZGVsdGEgaW4gdGhlIHNjcm9sbCBheGlzID4gZGVsdGEgb3RoZXIgYXhpcywgc2Nyb2xsIGluc3RlYWQgb2ZcbiAgICAgICAgICAgICAgICAgICAgLy8gbWFraW5nIGV2ZW50c1xuICAgICAgICAgICAgICAgICAgICByZXQgPSBkYSA+PSBkb2E7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaDogZnVuY3Rpb24oaW5UTCwgaW5JZCkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBpblRMLmxlbmd0aCwgdDsgaSA8IGwgJiYgKHQgPSBpblRMW2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKHQuaWRlbnRpZmllciA9PT0gaW5JZCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIEluIHNvbWUgaW5zdGFuY2VzLCBhIHRvdWNoc3RhcnQgY2FuIGhhcHBlbiB3aXRob3V0IGEgdG91Y2h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HBvaW50ZXJtYXAuXG4gICAgICAgICAgICAgICAgICAgIGlmIChrZXkgIT09IDEgJiYgIXRoaXMuZmluZFRvdWNoKHRsLCBrZXkgLSAyKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHAgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaChwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRoaXMpO1xuICAgICAgICAgICAgICAgIGQuZm9yRWFjaChmdW5jdGlvbihwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsKHApO1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLmRlbGV0ZShwLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHRvdWNoc3RhcnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMudmFjdXVtVG91Y2hlcyhpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMuc2V0UHJpbWFyeVRvdWNoKGluRXZlbnQuY2hhbmdlZFRvdWNoZXNbMF0pO1xuICAgICAgICAgICAgdGhpcy5kZWR1cFN5bnRoTW91c2UoaW5FdmVudCk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuc2Nyb2xsaW5nKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlja0NvdW50Kys7XG4gICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLmRvd24pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihpblBvaW50ZXIpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChIQVNfVE9VQ0hfQUNUSU9OKSB7XG4gICAgICAgICAgICAgICAgLy8gdG91Y2hldmVudC5jYW5jZWxhYmxlID09IGZhbHNlIGlzIHNlbnQgd2hlbiB0aGUgcGFnZSBpcyBzY3JvbGxpbmcgdW5kZXIgbmF0aXZlIFRvdWNoIEFjdGlvbiBpbiBDaHJvbWUgMzZcbiAgICAgICAgICAgICAgICAvLyBodHRwczovL2dyb3Vwcy5nb29nbGUuY29tL2EvY2hyb21pdW0ub3JnL2QvbXNnL2lucHV0LWRldi93SG55dWtjWUJjQS9iOWttdHdNMWpKUUpcbiAgICAgICAgICAgICAgICBpZiAoaW5FdmVudC5jYW5jZWxhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5tb3ZlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5zY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc2Nyb2xsaW5nID09PSBudWxsICYmIHRoaXMuc2hvdWxkU2Nyb2xsKGluRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5FdmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLm1vdmUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZHggPSB0LmNsaWVudFggLSB0aGlzLmZpcnN0WFkuWDtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGR5ID0gdC5jbGllbnRZIC0gdGhpcy5maXJzdFhZLlk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkZCA9IE1hdGguc3FydChkeCAqIGR4ICsgZHkgKiBkeSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZCA+PSBIWVNURVJFU0lTKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRvdWNoY2FuY2VsKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJzdFhZID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoaW5Qb2ludGVyKTtcbiAgICAgICAgfSxcbiAgICAgICAgdG91Y2hlbmQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuZGVkdXBTeW50aE1vdXNlKGluRXZlbnQpO1xuICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLnVwKTtcbiAgICAgICAgfSxcbiAgICAgICAgdXA6IGZ1bmN0aW9uKGluUG9pbnRlcikge1xuICAgICAgICAgICAgaW5Qb2ludGVyLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluUG9pbnRlcik7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnVwKGluUG9pbnRlcik7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmNhbmNlbChpblBvaW50ZXIpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaGNhbmNlbDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaW5FdmVudC5fY2FuY2VsID0gdHJ1ZTtcbiAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5jYW5jZWwpO1xuICAgICAgICB9LFxuICAgICAgICBjbGVhblVwUG9pbnRlcjogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpblBvaW50ZXIucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlUHJpbWFyeVBvaW50ZXIoaW5Qb2ludGVyKTtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gcHJldmVudCBzeW50aCBtb3VzZSBldmVudHMgZnJvbSBjcmVhdGluZyBwb2ludGVyIGV2ZW50c1xuICAgICAgICBkZWR1cFN5bnRoTW91c2U6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBsdHMgPSBzY29wZS5tb3VzZUV2ZW50cy5sYXN0VG91Y2hlcztcbiAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgIC8vIG9ubHkgdGhlIHByaW1hcnkgZmluZ2VyIHdpbGwgc3ludGggbW91c2UgZXZlbnRzXG4gICAgICAgICAgICBpZiAodGhpcy5pc1ByaW1hcnlUb3VjaCh0KSkge1xuICAgICAgICAgICAgICAgIC8vIHJlbWVtYmVyIHgveSBvZiBsYXN0IHRvdWNoXG4gICAgICAgICAgICAgICAgdmFyIGx0ID0ge1xuICAgICAgICAgICAgICAgICAgICB4OiB0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IHQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbHRzLnB1c2gobHQpO1xuICAgICAgICAgICAgICAgIHZhciBmbiA9IChmdW5jdGlvbihsdHMsIGx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpID0gbHRzLmluZGV4T2YobHQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsdHMuc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkuYmluZChudWxsLCBsdHMsIGx0KTtcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZuLCBERURVUF9USU1FT1VUKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICAvLyBwcmV2ZW50IFwiZ2hvc3QgY2xpY2tzXCIgdGhhdCBjb21lIGZyb20gZWxlbWVudHMgdGhhdCB3ZXJlIHJlbW92ZWQgaW4gYSB0b3VjaCBoYW5kbGVyXG4gICAgdmFyIFNUT1BfUFJPUF9GTiA9IEV2ZW50LnByb3RvdHlwZS5zdG9wSW1tZWRpYXRlUHJvcGFnYXRpb24gfHwgRXZlbnQucHJvdG90eXBlLnN0b3BQcm9wYWdhdGlvbjtcbiAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKGV2KSB7XG4gICAgICAgIHZhciB4ID0gZXYuY2xpZW50WCxcbiAgICAgICAgICAgIHkgPSBldi5jbGllbnRZO1xuICAgICAgICAvLyBjaGVjayBpZiBhIGNsaWNrIGlzIHdpdGhpbiBERURVUF9ESVNUIHB4IHJhZGl1cyBvZiB0aGUgdG91Y2hzdGFydFxuICAgICAgICB2YXIgY2xvc2VUbyA9IGZ1bmN0aW9uKHRvdWNoKSB7XG4gICAgICAgICAgICB2YXIgZHgg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3VuYXZhaWxhYmxlJyxcbiAgICAgICAgICAgICd0b3VjaCcsXG4gICAgICAgICAgICAncGVuJyxcbiAgICAgICAgICAgICdtb3VzZSdcbiAgICAgICAgXSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGluRXZlbnQ7XG4gICAgICAgICAgICBlID0gZGlzcGF0Y2hlci5jbG9uZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKEhBU19CSVRNQVBfVFlQRSkge1xuICAgICAgICAgICAgICAgIGUucG9pbnRlclR5cGUgPSB0aGlzLlBPSU5URVJfVFlQRVNbaW5FdmVudC5wb2ludGVyVHlwZV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlLl9zb3VyY2UgPSAnbXMnO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIE1TUG9pbnRlckRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgZS50YXJnZXQpO1xuICAgICAgICAgICAgZGlzcGF0Y2hlci5kb3duKGUpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJNb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50YXJnZXQgPSB0YXJnZXQ7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci5tb3ZlKGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJVcDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGUucG9pbnRlcklkKTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJDYW5jZWw6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldChlLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmNhbmNlbChlKTtcbiAgICAgICAgICAgIHRoaXMuY2xlYW51cChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2NvcGUubXNFdmVudHMgPSBtc0V2ZW50cztcbn0pKGV4cG9ydHMpO1xuXG4oZnVuY3Rpb24oc2NvcGUpIHtcbiAgICB2YXIgZGlzcGF0Y2hlciA9IHNjb3BlLmRpc3BhdGNoZXI7XG4gICAgdmFyIHBvaW50ZXJtYXAgPSBkaXNwYXRjaGVyLnBvaW50ZXJtYXA7XG4gICAgdmFyIHBvaW50ZXJFdmVudHMgPSB7XG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ3BvaW50ZXJkb3duJyxcbiAgICAgICAgICAgICdwb2ludGVybW92ZScsXG4gICAgICAgICAgICAncG9pbnRlcnVwJyxcbiAgICAgICAgICAgICdwb2ludGVyY2FuY2VsJ1xuICAgICAgICBdLFxuICAgICAgICBwcmVwYXJlRXZlbnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gZGlzcGF0Y2hlci5jbG9uZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ3BvaW50ZXInO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQoZS5wb2ludGVySWQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcG9pbnRlcm1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciB0YXJnZXQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBlLnRhcmdldCA9IHRhcmdldDtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJ1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGUucG9pbnRlcklkKTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBwb2ludGVyY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICA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kcyB0cmFja3N0YXJ0XG4gKi9cblxuKGZ1bmN0aW9uKHNjb3BlKSB7XG4gICAgdmFyIGRpc3BhdGNoZXIgPSBzY29wZS5kaXNwYXRjaGVyO1xuICAgIHZhciBldmVudEZhY3RvcnkgPSBzY29wZS5ldmVudEZhY3Rvcnk7XG4gICAgdmFyIHBvaW50ZXJtYXAgPSBuZXcgc2NvcGUuUG9pbnRlck1hcCgpO1xuICAgIHZhciB0cmFjayA9IHtcbiAgICAgICAgZXZlbnRzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAnbW92ZScsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAndHJhY2tzdGFydCcsXG4gICAgICAgICAgICAndHJhY2snLFxuICAgICAgICAgICAgJ3RyYWNreCcsXG4gICAgICAgICAgICAndHJhY2t5JyxcbiAgICAgICAgICAgICd0cmFja2VuZCdcbiAgICAgICAgXSxcbiAgICAgICAgZGVmYXVsdEFjdGlvbnM6IHtcbiAgICAgICAgICAgICd0cmFjayc6ICdub25lJyxcbiAgICAgICAgICAgICd0cmFja3gnOiAncGFuLXknLFxuICAgICAgICAgICAgJ3RyYWNreSc6ICdwYW4teCdcbiAgICAgICAgfSxcbiAgICAgICAgV0lHR0xFX1RIUkVTSE9MRDogNCxcbiAgICAgICAgY2xhbXBEaXI6IGZ1bmN0aW9uKGluRGVsdGEpIHtcbiAgICAgICAgICAgIHJldHVybiBpbkRlbHRhID4gMCA/IDEgOiAtMTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FsY1Bvc2l0aW9uRGVsdGE6IGZ1bmN0aW9uKGluQSwgaW5CKSB7XG4gICAgICAgICAgICB2YXIgeCA9IDAsXG4gICAgICAgICAgICAgICAgeSA9IDA7XG4gICAgICAgICAgICBpZiAoaW5BICYmIGluQikge1xuICAgICAgICAgICAgICAgIHggPSBpbkIucGFnZVggLSBpbkEucGFnZVg7XG4gICAgICAgICAgICAgICAgeSA9IGluQi5wYWdlWSAtIGluQS5wYWdlWTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuICAgICAgICBmaXJlVHJhY2s6IGZ1bmN0aW9uKGluVHlwZSwgaW5FdmVudCwgaW5UcmFja2luZ0RhdGEpIHtcbiAgICAgICAgICAgIHZhciB0ID0gaW5UcmFja2luZ0RhdGE7XG4gICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEodC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgdmFyIGRkID0gdGhpcy5jYWxjUG9zaXRpb25EZWx0YSh0Lmxhc3RNb3ZlRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKGRkLngpIHtcbiAgICAgICAgICAgICAgICB0LnhEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLngpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGRkLnkpIHtcbiAgICAgICAgICAgICAgICB0LnlEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLnkpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3knKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGdlc3R1cmVQcm90byA9IHtcbiAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgdHJhY2tJbmZvOiB0LnRyYWNrSW5mbyxcbiAgICAgICAgICAgICAgICByZWxhdGVkVGFyZ2V0OiBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQsXG4gICAgICAgICAgICAgICAgcG9pbnRlclR5cGU6IGluRXZlbnQucG9pbnRlclR5cGUsXG4gICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAndHJhY2snXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGluVHlwZSAhPT0gJ3RyYWNreScpIHtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueCA9IGluRXZlbnQueDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uZHggPSBkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmRkeCA9IGRkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmNsaWVudFggPSBpbkV2ZW50LmNsaWVudFg7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnBhZ2VYID0gaW5FdmVudC5wYWdlWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uc2NyZWVuWCA9IGluRXZlbnQuc2NyZWVuWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueERpcmVjdGlvbiA9IHQueERpcmVjdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpblR5cGUgIT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmR5ID0gZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5kZHkgPSBkZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by55ID0gaW5FdmVudC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5jbGllbnRZID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5wYWdlWSA9IGluRXZlbnQucGFnZVk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnNjcmVlblkgPSBpbkV2ZW50LnNjcmVlblk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnlEaXJlY3Rpb24gPSB0LnlEaXJlY3Rpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZSA9IGV2ZW50RmFjdG9yeS5tYWtlR2VzdHVyZUV2ZW50KGluVHlwZSwgZ2VzdHVyZVByb3RvKTtcbiAgICAgICAgICAgIHQuZG93blRhcmdldC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaW5FdmVudC5pc1ByaW1hcnkgJiYgKGluRXZlbnQucG9pbnRlclR5cGUgPT09ICdtb3VzZScgPyBpbkV2ZW50LmJ1dHRvbnMgPT09IDEgOiB0cnVlKSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0ge1xuICAgICAgICAgICAgICAgICAgICBkb3duRXZlbnQ6IGluRXZlbnQsXG4gICAgICAgICAgICAgICAgICAgIGRvd25UYXJnZXQ6IGluRXZlbnQudGFyZ2V0LFxuICAgICAgICAgICAgICAgICAgICB0cmFja0luZm86IHt9LFxuICAgICAgICAgICAgICAgICAgICBsYXN0TW92ZUV2ZW50OiBudWxsLFxuICAgICAgICAgICAgICAgICAgICB4RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB5RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB0cmFja2luZzogZmFsc2VcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHAgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmICghcC50cmFja2luZykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEocC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICB2YXIgbW92ZSA9IGQueCAqIGQueCArIGQueSAqIGQueTtcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnQgdHJhY2tpbmcgb25seSBpZiBmaW5nZXIgbW92ZXMgbW9yZSB0aGFuIFdJR0dMRV9USFJFU0hPTERcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1vdmUgPiB0aGlzLldJR0dMRV9USFJFU0hPTEQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAudHJhY2tpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gcC5kb3duRXZlbnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2tzdGFydCcsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChwLnRyYWNraW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFjaycsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2t4JywgaW5FdmVudCwgcCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFja3knLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gaW5FdmVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdX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xuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAnaG9sZCcsXG4gICAgICAgICAgICAnaG9sZHB1bHNlJyxcbiAgICAgICAgICAgICdyZWxlYXNlJ1xuICAgICAgICBdLFxuICAgICAgICBoZWxkUG9pbnRlcjogbnVsbCxcbiAgICAgICAgaG9sZEpvYjogbnVsbCxcbiAgICAgICAgcHVsc2U6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdmFyIGhvbGQgPSBEYXRlLm5vdygpIC0gdGhpcy5oZWxkUG9pbnRlci50aW1lU3RhbXA7XG4gICAgICAgICAgICB2YXIgdHlwZSA9IHRoaXMuaGVsZCA/ICdob2xkcHVsc2UnIDogJ2hvbGQnO1xuICAgICAgICAgICAgdGhpcy5maXJlSG9sZCh0eXBlLCBob2xkKTtcbiAgICAgICAgICAgIHRoaXMuaGVsZCA9IHRydWU7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBjbGVhckludGVydmFsKHRoaXMuaG9sZEpvYik7XG4gICAgICAgICAgICBpZiAodGhpcy5oZWxkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlSG9sZCgncmVsZWFzZScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5oZWxkID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmhlbGRQb2ludGVyID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMuaG9sZEpvYiA9IG51bGw7XG4gICAgICAgIH0sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChpbkV2ZW50LmlzUHJpbWFyeSAmJiAhdGhpcy5oZWxkUG9pbnRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuaGVsZFBvaW50ZXIgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gaW5FdmVudC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5ob2xkSm9iID0gc2V0SW50ZXJ2YWwodGhpcy5wdWxzZS5iaW5kKHRoaXMpLCB0aGlzLkhPTERfREVMQVkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jYW5jZWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFggLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFg7XG4gICAgICAgICAgICAgICAgdmFyIHkgPSBpbkV2ZW50LmNsaWVudFkgLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFk7XG4gICAgICAgICAgICAgICAgaWYgKCh4ICogeCArIHkgKiB5KSA+IHRoaXMuV0lHR0xFX1RIUkVTSE9MRCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgZmlyZUhvbGQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5Ib2xkVGltZSkge1xuICAgICAgICAgICAgdmFyIHAgPSB7XG4gICAgICAgICAgICAgICAgYnViYmxlczogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjYW5jZWxhY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CxcbiAgICAgICAgICAgICAgICAgICAgYnV0dG9uczogaW5FdmVudC5idXR0b25zLFxuICAgICAgICAgICAgICAgICAgICB4OiBpbkV2ZW50LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IGluRXZlbnQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzaG91bGRUYXA6IGZ1bmN0aW9uKGUsIGRvd25TdGF0ZSkge1xuICAgICAgICAgICAgdmFyIHRhcCA9IHRydWU7XG4gICAgICAgICAgICBpZiAoZS5wb2ludGVyVHlwZSA9PT0gJ21vdXNlJykge1xuICAgICAgICAgICAgICAgIC8vIG9ubHkgYWxsb3cgbGVmdCBjbGljayB0byB0YXAgZm9yIG1vdXNlXG4gICAgICAgICAgICAgICAgdGFwID0gKGUuYnV0dG9ucyBeIDEpICYmIChkb3duU3RhdGUuYnV0dG9ucyAmIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRhcCAmJiAhZS50YXBQcmV2ZW50ZWQ7XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgc3RhcnQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAoc3RhcnQgJiYgdGhpcy5zaG91bGRUYXAoaW5FdmVudCwgc3RhcnQpKSB7XG4gICAgICAgICAgICAgICAgLy8gdXAucmVsYXRlZFRhcmdldCBpcyB0YXJnZXQgY3VycmVudGx5IHVuZGVyIGZpbmdlclxuICAgICAgICAgICAgICAgIHZhciB0ID0gc2NvcGUudGFyZ2V0RmluZGluZy5MQ0Eoc3RhcnQudGFyZ2V0LCBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQpO1xuICAgICAgICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQoJ3RhcCcsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgeDogaW5FdmVudC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICAgICAgeTogaW5FdmVudC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiBpbkV2ZW50LmRldGFpbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiBpbkV2ZW50LnBvaW50ZXJUeXBlLFxuICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFsdEtleTogaW5FdmVudC5hbHRLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBjdHJsS2V5OiBpbkV2ZW50LmN0cmxLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRhS2V5OiBpbkV2ZW50Lm1ldGFLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGlmdEtleTogaW5FdmVudC5zaGlmdEtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgIF9zb3VyY2U6ICd0YXAnXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcG9pbnRlcm1hcC5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICAvLyBwYXRjaCBldmVudEZhY3RvcnkgdG8gcmVtb3ZlIGlkIGZyb20gdGFwJ3MgcG9pbnRlcm1hcCBmb3IgcHJldmVudFRhcCBjYWxsc1xuICAgIGV2Z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J25vbmUnXG4gICAgICAgIH0sXG4gICAgICAgIHJlZmVyZW5jZToge30sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIGlmIChwb2ludGVybWFwLnBvaW50ZXJzKCkgPT0gMikge1xuICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgIHZhciBhbmdsZSA9IHRoaXMuY2FsY0FuZ2xlKHBvaW50cyk7XG4gICAgICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UgPSB7XG4gICAgICAgICAgICAgICAgICAgIGFuZ2xlOiBhbmdsZSxcbiAgICAgICAgICAgICAgICAgICAgZGlhbWV0ZXI6IHBvaW50cy5kaWFtZXRlcixcbiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBzY29wZS50YXJnZXRGaW5kaW5nLkxDQShwb2ludHMuYS50YXJnZXQsIHBvaW50cy5iLnRhcmdldClcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgdGhpcy5maXJlUGluY2goJ3BpbmNoc3RhcnQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgcCA9IHBvaW50ZXJtYXAuZ2V0KGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHZhciBudW0gPSBwb2ludGVybWFwLnBvaW50ZXJzKCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmIChudW0gPT09IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZmlyZSAncGluY2hlbmQnIGJlZm9yZSBkZWxldGluZyBwb2ludGVyXG4gICAgICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2hlbmQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAuaGFzKGluRXZlbnQucG9pbnRlcklkKSkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5wb2ludGVycygpID4gMSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGNQaW5jaFJvdGF0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB0aGlzLnVwKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBmaXJlUGluY2g6IGZ1bmN0aW9uKHR5cGUsIGRpYW1ldGVyLCBwb2ludHMpIHtcbiAgICAgICAgICAgIHZhciB6b29tID0gZGlhbWV0ZXIgLyB0aGlzLnJlZmVyZW5jZS5kaWFtZXRlcjtcbiAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQodHlwZSwge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBzY2FsZTogem9vbSxcbiAgICAgICAgICAgICAgICBjZW50ZXJYOiBwb2ludHMuY2VudGVyLngsXG4gICAgICAgICAgICAgICAgY2VudGVyWTogcG9pbnRzLmNlbnRlci55LFxuICAgICAgICAgICAgICAgIF9zb3VyY2U6ICdwaW5jaCdcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UudGFyZ2V0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgIH0sXG4gICAgICAgIGZpcmVSb3RhdGU6IGZ1bmN0aW9uKGFuZ2xlLCBwb2ludHMpIHtcbiAgICAgICAgICAgIHZhciBkaWZmID0gTWF0aC5yb3VuZCgoYW5nbGUgLSB0aGlzLnJlZmVyZW5jZS5hbmdsZSkgJSAzNjApO1xuICAgICAgICAgICAgdmFyIGUgPSBldmVudEZhY3RvcnkubWFrZUdlc3R1cmVFdmVudCgncm90YXRlJywge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBhbmdsZTogZGlmZixcbiAgICAgICAgICAgICAgICBjZW50ZXJYOiBwb2ludHMuY2VudGVyLngsXG4gICAgICAgICAgICAgICAgY2VudGVyWTogcG9pbnRzLmNlbnRlci55LFxuICAgICAgICAgICAgICAgIF9zb3VyY2U6ICdwaW5jaCdcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UudGFyZ2V0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNQaW5jaFJvdGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgcG9pbnRzID0gdGhpcy5jYWxjQ2hvcmQoKTtcbiAgICAgICAgICAgIHZhciBkaWFtZXRlciA9IHBvaW50cy5kaWFtZXRlcjtcbiAgICAgICAgICAgIHZhciBhbmdsZSA9IHRoaXMuY2FsY0FuZ2xlKHBvaW50cyk7XG4gICAgICAgICAgICBpZiAoZGlhbWV0ZXIgIT0gdGhpcy5yZWZlcmVuY2UuZGlhbWV0ZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2gnLCBkaWFtZXRlciwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChhbmdsZSAhPSB0aGlzLnJlZmVyZW5jZS5hbmdsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZVJvdGF0ZShhbmdsZSwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FsY0Nob3JkOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBwb2ludGVycyA9IFtdO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5mb3JFYWNoKGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICAgICAgICBwb2ludGVycy5wdXNoKHApO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB2YXIgZGlzdCA9IDA7XG4gICAgICAgICAgICAvLyBzdGFydCB3aXRoIGF0IGxlYXN0IHR3byBwb2ludGVyc1xuICAgICAgICAgICAgdmFyIHBvaW50cyA9IHtcbiAgICAgICAgICAgICAgICBhOiBwb2ludGVyc1swXSxcbiAgICAgICAgICAgICAgICBiOiBwb2ludGVyc1sxXVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHZhciB4LCB5LCBkO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwb2ludGVycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBhID0gcG9pbnRlcnNbaV07XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IGkgKyAxOyBqIDwgcG9pbnRlcnMubGVuZ3RoOyBqKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGIgPSBwb2ludGVyc1tqXTtcbiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGguYWJzKGEuY2xpZW50WCAtIGIuY2xpZW50WCk7XG4gICAgICAgICAgICAgICAgICAgIHkgPSBNYXRoLmFicyhhLmNsaWVudFkgLSBiLmNsaWVudFkpO1xuICAgICAgICAgICAgICAgICAgICBkID0geCArIHk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkID4gZGlzdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYTogYSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiOiBiXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgeCA9IE1hdGguYWJzKHBvaW50cy5hLmNsaWVudFggKyBwb2ludHMuYi5jbGllbnRYKSAvIDI7XG4gICAgICAgICAgICB5ID0gTWF0aC5hYnMocG9pbnRzLmEuY2xpZW50WSArIHBvaW50cy5iLmNsaWVudFkpIC8gMjtcbiAgICAgICAgICAgIHBvaW50cy5jZW50ZXIgPSB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcG9pbnRzLmRpYW1ldGVyID0gZGlzdDtcbiAgICAgICAgICAgIHJldHVybiBwb2ludHM7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNBbmdsZTogZnVuY3Rpb24ocG9pbnRzKSB7XG4gICAgICAgICAgICB2YXIgeCA9IHBvaW50cy5hLmNsaWVudFggLSBwb2ludHMuYi5jbGllbnRYO1xuICAgICAgICAgICAgdmFyIHkgPSBwb2ludHMuYS5jbGllbnRZIC0gcG9pbnRzLmIuY2xpZW50WTtcbiAgICAgICAgICAgIHJldHVybiAoMzYwICsgTWF0aC5hdGFu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VwVHJlZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBncm91cEJ5cyA9IHRoaXMuZ3JvdXBCeXMsXG4gICAgICAgICAgICBsZWFmRGVwdGggPSBncm91cEJ5cy5sZW5ndGggLSAxLFxuICAgICAgICAgICAgc291cmNlID0gdGhpcy5kYXRhU291cmNlLFxuICAgICAgICAgICAgcm93Q291bnQgPSBzb3VyY2UuZ2V0Um93Q291bnQoKSxcbiAgICAgICAgICAgIHRyZWUgPSB0aGlzLnRyZWUgPSBuZXcgRGF0YU5vZGVUcmVlKCdUb3RhbHMnKTtcblxuICAgICAgICAvLyBmaXJzdCBzb3J0IGRhdGFcbiAgICAgICAgaWYgKHRoaXMucHJlc29ydEdyb3Vwcykge1xuICAgICAgICAgICAgZ3JvdXBCeXMucmV2ZXJzZSgpLmZvckVhY2goZnVuY3Rpb24oZ3JvdXBCeSkge1xuICAgICAgICAgICAgICAgIHNvdXJjZSA9IG5ldyBEYXRhU291cmNlU29ydGVyKHNvdXJjZSk7XG4gICAgICAgICAgICAgICAgc291cmNlLnNvcnRPbihncm91cEJ5KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yICh2YXIgciA9IDA7IHIgPCByb3dDb3VudDsgcisrKSB7XG4gICAgICAgICAgICB2YXIgcGF0aCA9IHRyZWU7XG5cbiAgICAgICAgICAgIGdyb3VwQnlzLmZvckVhY2goZnVuY3Rpb24oZywgYykgeyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLWxvb3AtZnVuY1xuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBzb3VyY2UuZ2V0VmFsdWUoZywgciksXG4gICAgICAgICAgICAgICAgICAgIHRlcm1pbmFsTm9kZSA9IChjID09PSBsZWFmRGVwdGgpLFxuICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHRlcm1pbmFsTm9kZSA/IERhdGFOb2RlTGVhZiA6IERhdGFOb2RlR3JvdXAsXG4gICA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cjogZnVuY3Rpb24oKSB7XG4gICAgICAgIHRoaXMua2V5cy5sZW5ndGggPSAwO1xuICAgICAgICAvLyBUT0RPOiBJcyB0aGVyZSBhIHJlYXNvbiB3aHkgdGhpcy52YWx1ZXMgaXMgbm90IGJlaW5nIHRydW5jYXRlZCBoZXJlIGFzIHdlbGw/XG4gICAgICAgIHRoaXMuZGF0YSA9IHt9O1xuICAgIH0sXG5cbiAgICBkZWxldGU6IGZ1bmN0aW9uKGtleSkge1xuICAgICAgICB2YXIgaGFzaENvZGUgPSBoYXNoKGtleSk7XG4gICAgICAgIGlmICh0aGlzLmRhdGFbaGFzaENvZGVdICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IGJldHRlckluZGV4T2YodGhpcy5rZXlzLCBrZXkpO1xuICAgICAgICAgICAgdGhpcy5rZXlzLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgICAgICB0aGlzLnZhbHVlcy5zcGxpY2UoaW5kZXgsIDEpO1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMuZGF0YVtoYXNoQ29kZV07XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgZm9yRWFjaDogZnVuY3Rpb24oZnVuYykge1xuICAgICAgICB2YXIga2V5cyA9IHRoaXMua2V5cyxcbiAgICAgICAgICAgIHNlbGYgPSB0aGlzO1xuICAgICAgICBrZXlzLmZvckVhY2goZnVuY3Rpb24oa2V5KSB7XG4gICAgICAgICAgICB2YXIgdmFsdWUgPSBzZWxmLmdldChrZXkpO1xuICAgICAgICAgICAgZnVuYyh2YWx1ZSwga2V5LCBzZWxmKTtcbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIG1hcDogZnVuY3Rpb24oZnVuYykge1xuICAgICAgICB2YXIga2V5cyA9IHRoaXMua2V5cyxcbiAgICAgICAgICAgIG5ld01hcCA9IG5ldyBNYXBweSgpLFxuICAgICAgICAgICAgc2VsZiA9IHRoaXM7XG4gICAgICAgIGtleXMuZm9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5lZCkge1xuICAgICAgICBkaXJlY3Rpb24gPSAxO1xuICAgIH1cblxuICAgIGlmIChpbmRleC5sZW5ndGgpIHsgLy8gc29tZXRoaW5nIHRvIGRvXG4gICAgICAgIHN3aXRjaCAoZGlyZWN0aW9uKSB7XG4gICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgcmV0dXJuOyAvLyBiYWlsOiBub3RoaW5nIHRvIHNvcnRcblxuICAgICAgICAgICAgY2FzZSB1bmRlZmluZWQ6IC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tZmFsbHRocm91Z2hcbiAgICAgICAgICAgICAgICBkaXJlY3Rpb24gPSAxO1xuICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgIGNvbXBhcmUgPSBhc2NlbmRpbmcodHlwZW9mIGdldFZhbHVlKDApKTtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgY2FzZSAtMTpcbiAgICAgICAgICAgICAgICBjb21wYXJlID0gZGVzY2VuZGluZyh0eXBlb2YgZ2V0VmFsdWUoMCkpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gc2V0IHVwIHRoZSBzb3J0Li4uLi5cbiAgICAgICAgdmFyIHRtcCA9IG5ldyBBcnJheShpbmRleC5sZW5ndGgpO1xuXG4gICAgICAgIC8vIGFkZCB0aGUgaW5kZXggZm9yIFwic3RhYmlsaXR5XCJcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGluZGV4Lmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB0bXBbaV0gPSBbZ2V0VmFsdWUoaSksIGldO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gZG8gdGhlIGFjdHVhbCBzb3J0XG4gICAgICAgIHRtcC5zb3J0KGNvbXBhcmUpO1xuXG4gICAgICAgIC8vIGNvcHkgdGhlIHNvcnRlZCB2YWx1ZXMgaW50byBvdXIgaW5kZXggdmVjdG9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Rpb24gKGxpc3QpIHsgcmV0dXJuIGxpc3QuZWxlbWVudCA9PT0gbGlzdEVsZW1lbnQ7IH0pO1xuXG4gICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgLy8gb21pdHRlZDogZGVmYXVsdCB0byB0cnVlXG4gICAgICAgICAgICAgICAgbGlzdC5pc0Ryb3BUYXJnZXQgPT09IHVuZGVmaW5lZCB8fFxuXG4gICAgICAgICAgICAgICAgLy8gZnVuY3Rpb246IHVzZSByZXR1cm4gdmFsdWVcbiAgICAgICAgICAgICAgICB0eXBlb2YgbGlzdC5pc0Ryb3BUYXJnZXQgPT09ICdmdW5jdGlvbicgJiYgbGlzdC5pc0Ryb3BUYXJnZXQoKSB8fFxuXG4gICAgICAgICAgICAgICAgLy8gb3RoZXJ3aXNlOiB1c2UgdHJ1dGhpbmVzcyBvZiBnaXZlbiB2YWx1ZVxuICAgICAgICAgICAgICAgIGxpc3QuaXNEcm9wVGFyZ2V0XG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVjdCA9IGl0ZW1FbGVtZW50LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpLFxuICAgICAgICAgICAgICAgICAgICBib3R0b20gPSByZWN0LmJvdHRvbTtcblxuICAgICAgICAgICAgICAgIGlmIChpdGVtRWxlbWVudCA9PT0gbGlzdEVsZW1lbnQubGFzdEVsZW1lbnRDaGlsZCkge1xuICAgICAgICAgICAgICAgICAgICBib3R0b20gPSBsaXN0RWxlbWVudC5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKS5ib3R0b207XG4gICAgICAgICAgICAgICAgICAgIGlmIChib3R0b20gPCByZWN0LnRvcCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYm90dG9tID0gcmVjdC50b3AgKyAoaGVpZ2h0IHx8IDUwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGhlaWdodCA9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bi5kcm9wLnN0eWxlLmJvcmRlclRvcFdpZHRoID0gcmVjdC5oZWlnaHQgKyAncHgnO1xuXG4gICAgICAgIHRoaXMuc3R5bGUud2lkdGggPSByZWN0LndpZHRoICsgJ3B4JztcbiAgICAgICAgdGhpcy5zdHlsZS50cmFuc2l0aW9uRHVyYXRpb24gPSAnMHMnO1xuICAgICAgICB0aGlzLnN0eWxlW3RyYW5zZm9ybV0gPSB0cmFuc2xhdGUoXG4gICAgICAgICAgICByZWN0LmxlZnQgLSB3aW5kb3cuc2Nyb2xsWCxcbiAgICAgICAgICAgIHJlY3QudG9wICAtIHdpbmRvdy5zY3JvbGxZXG4gICAgICAgICk7XG4gICAgICAgIHRoaXMuY2xhc3NMaXN0LmFkZCgnZHJhZ29uLXBvcCcpO1xuICAgICAgICB0aGlzLnN0eWxlLnpJbmRleCA9IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKGRyYWdvbi5tb2RlbExpc3RzWzBdLmNvbnRhaW5lci5wYXJlbnRFbGVtZW50KS56SW5kZXg7XG5cbiAgICAgICAgaWYgKCFkcmFnb24uY29udGFpbmVyKSB7XG4gICAgICAgICAgICAvLyB3YWxrIGJhY2sgdG8gY2xvc2VzdCBzaGFkb3cgcm9vdCBPUiBib2R5IHRhZyBPUiByb290IHRhZ1xuICAgICAgICAgICAgdmFyIGNvbnRhaW5lciA9IHRoaXM7XG4gICAgICAgICAgICB3aGlsZSAoY29udGFpbmVyLnBhcmVudE5vZGUpIHtcbiAgICAgICAgICAgICAgICBjb250YWluZXIgPSBjb250YWluZXIucGFyZW50Tm9kZTtcbiAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyIGluc3RhbmNlb2YgU2hhZG93Um9vdCB8fCBjb250YWluZXIudGFnTmFtZSA9PT0gJ0JPRFknKXtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZHJhZ29uLmNvbnRhaW5l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RpbWVyKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgb3RoZXIgPSBkcmFnb24ucG9pbnRJbkl0ZW1SZWN0cyh7XG4gICAgICAgICAgICAgICAgeDogZXZ0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgeTogZHJhZ29uLnJlY3QuYm90dG9tICsgd2luZG93LnNjcm9sbFkgKyBkeSArIGhvdmVyTGlzdC5lbGVtZW50LnNjcm9sbFRvcFxuICAgICAgICAgICAgfSwgdGhpcywgZHJhZ29uLmRyb3ApO1xuXG4gICAgICAgICAgICB0aGlzLnN0eWxlW3RyYW5zZm9ybV0gPSB0cmFuc2xhdGUoXG4gICAgICAgICAgICAgICAgZHJhZ29uLnJlY3QubGVmdCAtIHdpbmRvdy5zY3JvbGxYICsgZHgsXG4gICAgICAgICAgICAgICAgZHJhZ29uLnJlY3QudG9wIC0gd2luZG93LnNjcm9sbFkgKyBkeVxuICAgICAgICAgICAgKTtcblxuICAgICAgICAgICAgaWYgKG90aGVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIGVsZW1lbnQgPSBvdGhlci5lbGVtZW50O1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUudHJhbnNpdGlvbiA9IFJFVkVSVF9UT19TVFlMRVNIRUVUX1ZBTFVFO1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUuYm9yZGVyVG9wV2lkdGggPSBkcmFnb24uZHJvcC5zdHlsZS5ib3JkZXJUb3BXaWR0aDtcbiAgICAgICAgICAgICAgICBkcmFnb24uZHJvcC5zdHlsZS5ib3JkZXJUb3BXaWR0aCA9IG51bGw7XG4gICAgICAgICAgICAgICAgZHJhZ29uLmRyb3AgPSBlbGVtZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcblxuICAgIG1vdXNldXA6IGZ1bmN0aW9uIChkcmFnb24sIGV2dCkge1xuICAgICAgICByZXNldEF1dG9TY3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YWluZWRXaXRoaW5SZWN0YW5nbGVgLilfXG4gICAgICogQHBhcmFtIHJlY3Qge1JlY3RhbmdsZX0gLSBSZWN0YW5nbGUgdG8gdGVzdCB0aGlzIHBvaW50IGFnYWluc3QuXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IGB0cnVlYCBpZmYgdGhpcyBwb2ludCBpcyB3aXRoaW4gZ2l2ZW4gYHJlY3RgLlxuICAgICAqIEBtZW1iZXJPZiBQb2ludC5wcm90b3R5cGVcbiAgICAgKi9cbiAgICB3aXRoaW46IGZ1bmN0aW9uKHJlY3QpIHtcbiAgICAgICAgdmFyIG1pblggPSByZWN0Lm9yaWdpbi54LFxuICAgICAgICAgICAgbWF4WCA9IG1pblggKyByZWN0LmV4dGVudC54O1xuICAgICAgICB2YXIgbWluWSA9IHJlY3Qub3JpZ2luLnksXG4gICAgICAgICAgICBtYXhZID0gbWluWSArIHJlY3QuZXh0ZW50Lnk7XG5cbiAgICAgICAgaWYgKHJlY3QuZXh0ZW50LnggPCAwKSB7XG4gICAgICAgICAgICBtaW5YID0gbWF4WDtcbiAgICAgICAgICAgIG1heFggPSByZWN0Lm9yaWdpbi54O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHJlY3QuZXh0ZW50LnkgPCAwKSB7XG4gICAgICAgICAgICBtaW5ZID0gbWF4WTtcbiAgICAgICAgICAgIG1heFkgPSByZWN0Lm9yaWdpbi55O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIChcbiAgICAgICAgICAgIG1pblggPD0gdGhpcy54ICYmIHRoaXMueCA8IG1heFggJiZcbiAgICAgICAgICAgIG1pblkgPD0gdGhpcy55ICYmIHRoaXMueSA8IG1heFlcbiAgICAgICAgKTtcbiAgICB9XG59O1xuXG5Qb2ludC5wcm90b3R5cGUuRVEgPSBQb2ludC5wcm90b3R5cGUuZXF1YWxzO1xuUG9pbnQucHJvdG90eXBlLkdUID0gUG9pbnQucHJvdG90eXBlLmdyZWF0ZXJUaGFu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gIGxlZnRJY29uID0gdmFsWzBdO1xuICAgICAgICAgICAgcmlnaHRJY29uID0gdmFsWzJdO1xuICAgICAgICAgICAgdmFsID0gdmFsWzFdO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICdvYmplY3QnKSB7IC8vIG11c3QgYmUgYW4gaW1hZ2VcbiAgICAgICAgICAgICAgICBjZW50ZXJJY29uID0gdmFsO1xuICAgICAgICAgICAgICAgIHZhbCA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobGVmdEljb24gJiYgbGVmdEljb24ubm9kZU5hbWUgIT09ICdJTUcnKSB7XG4gICAgICAgICAgICAgICAgbGVmdEljb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHJpZ2h0SWNvbiAmJiByaWdodEljb24ubm9kZU5hbWUgIT09ICdJTUcnKSB7XG4gICAgICAgICAgICAgICAgcmlnaHRJY29uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjZW50ZXJJY29uICYmIGNlbnRlckljb24ubm9kZU5hbWUgIT09ICdJTUcnKSB7XG4gICAgICAgICAgICAgICAgY2VudGVySWNvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB2YWwgPSB2YWx1ZU9yRnVuY3Rpb25FeGVjdXRlKGNvbmZpZywgdmFsKTtcblxuICAgICAgICBpZiAoZ2MuZm9udCAhPT0gY29uZmlnLmZvbnQpIHtcbiAgICAgICAgICAgIGdjLmZvbnQgPSBjb25maWcuZm9udDtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZ2MudGV4dEFsaWduICE9PSAnbGVmdCcpIHtcbiAgICAgICAgICAgIGdjLnRleHRBbGlnbiA9ICdsZWZ0JztcbiAgICAgICAgfVxuICAgICAgICBpZiAoZ2MudGV4dEJhc2VsaW5lICE9PSAnbWlkZGxlJykge1xuICAgICAgICAgICAgZ2MudGV4dEJhc2Vsa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jb25maWcudm9mZnNldCxcbiAgICAgICAgICAgIGhhbGlnbiA9IGNvbmZpZy5oYWxpZ24sXG4gICAgICAgICAgICBpc0NvbHVtbkhvdmVyZWQgPSBjb25maWcuaXNDb2x1bW5Ib3ZlcmVkLFxuICAgICAgICAgICAgaXNSb3dIb3ZlcmVkID0gY29uZmlnLmlzUm93SG92ZXJlZCxcbiAgICAgICAgICAgIGlzTGluayA9IGlzTGluayB8fCBmYWxzZTtcblxuICAgICAgICB2YXIgZm9udE1ldHJpY3MgPSBjb25maWcuZ2V0VGV4dEhlaWdodChjb25maWcuZm9udCk7XG4gICAgICAgIHZhciB0ZXh0V2lkdGggPSBjb25maWcuZ2V0VGV4dFdpZHRoKGdjLCB2YWwpO1xuXG4gICAgICAgIC8vd2UgbXVzdCBzZXQgdGhpcyBpbiBvcmRlciB0byBjb21wdXRlIHRoZSBtaW5pbXVtIHdpZHRoXG4gICAgICAgIC8vZm9yIGNvbHVtbiBhdXRvc2l6aW5nIHB1cnBvc2VzXG4gICAgICAgIGNvbmZpZy5taW5XaWR0aCA9IHRleHRXaWR0aCArICgyICogY29sSEVkZ2VPZmZzZXQpO1xuXG4gICAgICAgIHN3aXRjaCAoaGFsaWduKSB7XG4gICAgICAgICAgICBjYXNlICdyaWdodCc6XG4gICAgICAgICAgICAgICAgLy90ZXh0V2lkdGggPSBjb25maWcuZ2V0VGV4dFdpZHRoKGdjLCBjb25maWcudmFsdWUpO1xuICAgICAgICAgICAgICAgIGhhbGlnbk9mZnNldCA9IHdpZHRoIC0gY29sSEVkZ2VPZmZzZXQgLSB0ZXh0V2lkdGg7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdjZW50ZXInOlxuICAgICAgICAgICAgICAgIC8vdGV4dFdpZHRoID0gY29uZmlnLmdldFRleHRXaWR0aChnYywgY29uZmlnLnZhbHVlKTtcbiAgICAgICAgICAgICAgICBoYWxpZ25PZmZzZXQgPSAod2lkdGggLSB0ZXh0V2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ICAgICAgICAgIHJlbmRlck11bHRpTGluZVRleHQ6IHRoaXMucmVuZGVyTXVsdGlMaW5lVGV4dFxuICAgICAgICB9O1xuICAgICAgICB0aGlzLmNlbGxDYWNoZS5zbGlkZXJDZWxsUmVuZGVyZXIgPSB7XG4gICAgICAgICAgICBwYWludDogdGhpcy5wYWludFNsaWRlclxuICAgICAgICB9O1xuICAgICAgICB0aGlzLmNlbGxDYWNoZS5zcGFya2JhckNlbGxSZW5kZXJlciA9IHtcbiAgICAgICAgICAgIHBhaW50OiB0aGlzLnBhaW50U3BhcmtiYXJcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5jZWxsQ2FjaGUuc3BhcmtsaW5lQ2VsbFJlbmRlcmVyID0ge1xuICAgICAgICAgICAgcGFpbnQ6IHRoaXMucGFpbnRTcGFya2xpbmVcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5jZWxsQ2FjaGUudHJlZUNlbGxSZW5kZXJlciA9IHtcbiAgICAgICAgICAgIHBhaW50OiB0aGlzLnRyZWVDZWxsUmVuZGVyZXJcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5jZWxsQ2FjaGUuZW1wdHlDZWxsUmVuZGVyZXIgPSB7XG4gICAgICAgICAgICBwYWludDogdGhpcy5lbXB0eUNlbGxSZW5kZXJlclxuICAgICAgICB9O1xuICAgICAgICB0aGlzLmNlbGxDYWNoZS5idXR0b25SZW5kZXJlciA9IHtcbiAgICAgICAgICAgIHBhaW50OiB0aGlzLnBhaW50QnV0dG9uLFxuICAgICAgICAgICAgLy9kZWZhdWx0Q2VsbFBhaW50OiB0aGlzLmRlZmF1bHRDZWxsUGFpbnRcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5jZWxsQ2FjaGUubGlua0NlbGxSZW5kZXJlciA9IHtcbiAgICAgICAgICAgIHBhaW50OiBmdW5jdGlvbihnYywgeCwgeSwgd2lkdGgsIGhlaWdodCkge1xuICAgICAgICAgICAgICAgIHNlbGYuY29uZmlnID0g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1saW5lIG5vLWFsZXJ0XG4gICAgICAgICAgICAgICAgcmV0dXJuICcnO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBmb3IgKHZhciBoID0gMDsgaCA8IGhlaWdodDsgaCsrKSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgdyA9IDA7IHcgPCB3aWR0aDsgdysrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rvci5wdXNoKHNlbGVjdGlvbnNbd11baF0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAodyA8IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xsZWN0b3IucHVzaCgnXFx0Jyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGggPCBoZWlnaHQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29sbGVjdG9yLnB1c2goJ1xcbicpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IGNvbGxlY3Rvci5qb2luKCcnKTtcblxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gJyc7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IFdlIGhhdmUgZm9jdXMuXG4gICAgICovXG4gICAgaGFzRm9jdXM6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5nZXRDYW52YXMoKS5oYXNGb2N1cygpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgSHlwZXJncmlkLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIENsZWFyIGFsbCB0aGUgc2VsZWN0aW9ucy5cbiAgICAgKi9cbiAgICBjbGVhclNlbGVjdGl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0aW9uKCkge1xuICAgICAgICB2YXIgbm93ID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ3JlcGFpbnRJbW1lZGlhdGVseScpO1xuICAgICAgICB2YXIgY2FudmFzID0gdGhpcy5nZXRDYW52YXMoKTtcbiAgICAgICAgaWYgKGNhbnZhcykge1xuICAgICAgICAgICAgaWYgKG5vdyA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgIGNhbnZhcy5wYWludE5vdygpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjYW52YXMucmVwYWludCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQGRlc2MgUGFpbnQgaW1tZWRpYXRlbHkgaW4gdGhpcyBtaWNyb3Rhc2suXG4gICAgICovXG4gICAgcGFpbnROb3c6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgY2FudmFzID0gdGhpcy5nZXRDYW52YXMoKTtcbiAgICAgICAgY2FudmFzLnBhaW50Tm93KCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IEluIEhpRFBJIG1vZGUgKGhhcyBhbiBhdHRyaWJ1dGUgYXMgc3VjaCkuXG4gICAgICovXG4gICAgdXNlSGlEUEk6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ3VzZUhpRFBJJykgIT09IGZhbHNlO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgSHlwZXJncmlkLnByb3RvdHlwZVxuICAgICAqIEBzdW1tYXJ5IEluaXRpYWxpemUgZHJhd2luZyBzdXJmYWNlLlxuICAgICAqIEBwcml2YXRlXG4gICAgICovXG4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AgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZU1vdXNlTW92ZShtb3VzZUV2ZW50KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLW1vdXNlZG93bicsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vc2VsZi5zdG9wRWRpdGluZygpO1xuICAgICAgICAgICAgdmFyIG1vdXNlID0gZS5kZXRhaWwubW91c2U7XG4gICAgICAgICAgICB2YXIgbW91c2VFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICBtb3VzZUV2ZW50LmtleXMgPSBlLmRldGFpbC5rZXlzO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLm1vdXNlRG93blN0YXRlID0gbW91c2VFdmVudDtcbiAgICAgICAgICAgIHNlbGYuZGVsZWdhdGVNb3VzZURvd24obW91c2VFdmVudCk7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNNb3VzZURvd25FdmVudChtb3VzZUV2ZW50KTtcbiAgICAgICAgICAgIHNlbGYucmVwYWludCgpO1xuICAgICAgICB9KTtcblxuXG4gICAgICAgIC8vIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1jbGljaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgLy8gICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAvLyAgICAgICAgIHJldHVybjtcbiAgICAgICAgLy8gICAgIH1cbiAgICAgICAgLy8gICAgIC8vc2VsZi5zdG9wRWRpdGluZygpO1xuICAgICAgICAvLyAgICAgdmFyIG1vdXNlID0gZS5kZXRhaWwubW91c2U7XG4gICAgICAgIC8vICAgICB2YXIgbW91c2VFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgIC8vICAgICBtb3VzZUV2ZW50LnByaW1pdGl2ZUV2ZW50ID0gZTtcbiAgICAgICAgLy8gICAgIHNlbGYuZmlyZVN5bnRoZXRpY0NsaWNrRXZlbnQobW91c2VFdmVudCk7XG4gICAgICAgIC8vIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1tb3VzZXVwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5kcmFnZ2luZyA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKHNlbGYuaXNTY3JvbGxpbmdOb3coKSkge1xuICAgICAgICAgICAgICAgIHNlbGYuc2V0U2Nyb2xsaW5nTm93KGZhbHNlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzZWxmLmNvbHVtbkRyYWdBdXRvU2Nyb2xsaW5nKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5jb2x1bW5EcmFnQXV0b1Njcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZU1vdXNlVXAobW91c2VFdmVudCk7XG4gICAgICAgICAgICBpZiAoc2VsZi5tb3VzZURvd25TdGF0ZSkge1xuICAgICAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0J1dHRvblByZXNzZWRFdmVudChzZWxmLm1vdXNlRG93blN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNlbGYubW91c2VEb3duU3RhdGUgPSBudWxsO1xuICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljTW91c2VVcEV2ZW50KG1vdXNlRXZlbnQpO1xuICAgICAgICB9KTtcblxuICAgICAgICB0aGlzLmFkZEZpbkV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMtdGFwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciB0YXBFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICB0YXBFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICB0YXBF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VyKCdmaW4tY2FudmFzLWtleXVwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljS2V5dXBFdmVudChlKTtcbiAgICAgICAgICAgIHNlbGYuZGVsZWdhdGVLZXlVcChlKTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLXRyYWNrJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHNlbGYuZHJhZ2dpbmcpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgcHJpbUV2ZW50ID0gZS5kZXRhaWwucHJpbWl0aXZlRXZlbnQ7XG4gICAgICAgICAgICBpZiAoTWF0aC5hYnMocHJpbUV2ZW50LmR5KSA+IE1hdGguYWJzKHByaW1FdmVudC5keCkpIHtcbiAgICAgICAgICAgICAgICBpZiAocHJpbUV2ZW50LnlEaXJlY3Rpb24gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Nyb2xsVkJ5KC0yKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHByaW1FdmVudC55RGlyZWN0aW9uIDwgLTApIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zY3JvbGxWQnkoMik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAocHJpbUV2ZW50LnhEaXJlY3Rpb24gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Nyb2xsSEJ5KC0xKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHByaW1FdmVudC54RGlyZWN0aW9uIDwgLTApIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zY3JvbGxIQnkoMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICAvLyB0aGlzLmFkZEZpbkV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMtaG9sZHB1bHNlJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAvLyAgICAgY29uc29sZS5sb2coJ2hvbGRwdWxzZScpO1xuICAgICAgICAvLyAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgIC8vICAgICAgICAgcmV0dXJuO1xuICAgICAgICAvLyAgICAgfVxuICAgICAgICAvLyAgICAgdmFyIG1vdXNlID0gZS5kZXRhaWwubW91c2U7XG4gICAgICAgIC8vICAgICB2YXIgbW91c2VFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgIC8vICAgICBtb3VzZUV2ZW50LnByaW1pdGl2ZUV2ZW50ID0gZTtcbiAgICAgICAgLy8gICAgIHNlbGYuZGVsZWdhdGVIb2xkUHVsc2UobW91c2VFdmVudCk7XG4gICAgICAgIC8vIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1kYmxjbGljaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG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cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuY2FudmFzLmRpc3BhdGNoRXZlbnQoY2xpY2tFdmVudCk7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNFZGl0b3JLZXlVcEV2ZW50OiBmdW5jdGlvbihpbnB1dENvbnRyb2wsIGtleUV2ZW50KSB7XG4gICAgICAgIHZhciBjbGlja0V2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tZWRpdG9yLWtleS11cCcsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGlucHV0OiBpbnB1dENvbnRyb2wsXG4gICAgICAgICAgICAgICAga2V5RXZlbnQ6IGtleUV2ZW50XG4gICAgICAgICAgICB9LFxuXG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGNsaWNrRXZlbnQpO1xuICAgIH0sXG5cbiAgICBmaXJlU3ludGhldGljRWRpdG9yS2V5RG93bkV2ZW50OiBmdW5jdGlvbihpbnB1dENvbnRyb2wsIGtleUV2ZW50KSB7XG4gICAgICAgIHZhciBjbGlja0V2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tZWRpdG9yLWtleS1kb3duJywge1xuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgaW5wdXQ6IGlucHV0Q29udHJvbCxcbiAgICAgICAgICAgICAgICBrZXlFdmVudDoga2V5RXZlbnRcbiAgICAgICAgICAgIH0sXG5cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuY2FudmFzLmRpc3BhdGNoRXZlbnQoY2xpY2tFdmVudCk7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNFZGl0b3JLZXlQcmVzc0V2ZW50OiBmdW5jdGlvbihpbnB1dENvbnRyb2wsIGtleUV2ZW50KSB7XG4gICAgICAgIHZhciBjbGlja0V2ZW50ID0gbmV3IEN1c3RvbU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AgICAgICB2YXIgb3ggPSByZWN0Lm9yaWdpbi54O1xuICAgICAgICB2YXIgb3kgPSByZWN0Lm9yaWdpbi55O1xuICAgICAgICB2YXIgcmVzdWx0ID0ge307XG4gICAgICAgIHZhciByO1xuICAgICAgICBmb3IgKHZhciBjID0gMDsgYyA8IGNvbENvdW50OyBjKyspIHtcbiAgICAgICAgICAgIHZhciBjb2x1bW4gPSBuZXcgQXJyYXkocm93Q291bnQpO1xuICAgICAgICAgICAgcmVzdWx0W3RoaXMuZ2V0RmllbGQoYyArIG94KV0gPSBjb2x1bW47XG4gICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgcm93Q291bnQ7IHIrKykge1xuICAgICAgICAgICAgICAgIGNvbHVtbltyXSA9IHZhbHVlT3JGdW5jdGlvbkV4ZWN1dGUodGhpcy5nZXRWYWx1ZShveCArIGMsIG95ICsgcikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfSxcblxuICAgIGdldFNlbGVjdGlvbk1hdHJpeDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdmFyIHNlbGVjdGlvbnMgPSB0aGlzLmdldFNlbGVjdGlvbnMoKTtcbiAgICAgICAgdmFyIHJlc3VsdCA9IG5ldyBBcnJheShzZWxlY3Rpb25zLmxlbmd0aCk7XG4gICAgICAgIHNlbGVjdGlvbnMuZm9yRWFjaChmdW5jdGlvbihzZWxlY3Rpb25SZWN0LCBpKSB7XG4gICAgICAgICAgICByZXN1bHRbaV0gPSBzZWxmLl9nZXRTZWxlY3Rpb25NYXRyaXgoc2VsZWN0aW9uUmVjdCk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH0sXG5cbiAgICBfZ2V0U2VsZWN0aW9uTWF0cml4OiBmdW5jdGlvbihyZWN0KSB7XG4gICAgICAgIHJlY3QgPSBub3JtYWxpemVSZWN0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nUnLCB7XG4gICAgICAgICAgICBkZXRhaWw6IHtcbiAgICAgICAgICAgICAgICBncmlkQ2VsbDogZS5ncmlkQ2VsbCxcbiAgICAgICAgICAgICAgICBtb3VzZVBvaW50OiBlLm1vdXNlUG9pbnQsXG4gICAgICAgICAgICAgICAgdmlld1BvaW50OiBlLnZpZXdQb2ludCxcbiAgICAgICAgICAgICAgICBwcmltaXRpdmVFdmVudDogZS5wcmltaXRpdmVFdmVudCxcbiAgICAgICAgICAgICAgICByb3dzOiB0aGlzLmdldFNlbGVjdGVkUm93cygpLFxuICAgICAgICAgICAgICAgIGNvbHVtbnM6IHRoaXMuZ2V0U2VsZWN0ZWRDb2x1bW5zKCksXG4gICAgICAgICAgICAgICAgc2VsZWN0aW9uczogdGhpcy5nZXRTZWxlY3Rpb25Nb2RlbCgpLmdldFNlbGVjdGlvbnMoKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChldmVudCk7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNNb3VzZVVwRXZlbnQ6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgdmFyIGV2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tbW91c2V1cCcsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLmdldFNlbGVjdGlvbk1vZGVsKCkuZ2V0U2VsZWN0aW9ucygpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGV2ZW50KTtcbiAgICB9LFxuXG4gICAgZmlyZVN5bnRoZXRpY01vdXNlRG93bkV2ZW50OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIHZhciBldmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLW1vdXNlZG93bicsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLmdldFNlbGVjdGlvbk1vZGVsKCkuZ2V0U2VsZWN0aW9ucygpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGV2ZW50KTtcbiAgICB9LFxuXG4gICAgaXNWaWV3YWJsZUJ1dHRvbjogZnVuY3Rpb24oYywgcikge1xuICAgICAgICByZXR1cm4gdGhpcy5nZXRSZW5kZXJlcigpLmlzVmlld2FibGVCdXR0b24oYywgcik7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNCdXR0b25QcmVzc2VkRXZlbnQ6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ZGVyZXIuZ2V0VmlzaWJsZVJvd3MoKSxcbiAgICAgICAgICAgIGhlYWRlcnMgPSBuZXcgQXJyYXkoY29sQ291bnQpLFxuICAgICAgICAgICAgcmVzdWx0cyA9IG5ldyBBcnJheShyb3dDb3VudCksXG4gICAgICAgICAgICByb3c7XG5cbiAgICAgICAgaGVhZGVycy5mb3JFYWNoKGZ1bmN0aW9uKGhlYWRlciwgYykge1xuICAgICAgICAgICAgaGVhZGVyc1tjXSA9IGJlaGF2aW9yLmdldENvbHVtbklkKGMsIDApO1xuICAgICAgICB9KTtcblxuICAgICAgICByZXN1bHRzLmZvckVhY2goZnVuY3Rpb24ocmVzdWx0LCByKSB7XG4gICAgICAgICAgICByb3cgPSByZXN1bHRzW3JdID0ge1xuICAgICAgICAgICAgICAgIGhpZXJhcmNoeTogYmVoYXZpb3IuZ2V0Rml4ZWRDb2x1bW5WYWx1ZSgwLCByKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGhlYWRlcnMuZm9yRWFjaChmdW5jdGlvbihmaWVsZCwgYykge1xuICAgICAgICAgICAgICAgIHJvd1tmaWVsZF0gPSBiZWhhdmlvci5nZXRWYWx1ZShjLCByKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcblxuICAgICAgICByZXR1cm4gcmVzdWx0cztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0fSBBbiBvYmplY3QgdGhhdCByZXByZXNlbnRzIHRoZSBjdXJyZW50bHkgc2VsZWN0aW9uIHJvdy5cbiAgICAgKi9cbiAgICBnZXRTZWxlY3RlZFJvdzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxzID0gdGhpcy5nZXRTZWxlY3Rpb25Nb2RlbCgpLmdldFNlbGVjdGlvbnMoKTtcbiAgICAgICAgaWYgKHNlbHMubGVuZ3RoKSB7XG4gICAgICAgICAgICB2YXIgYmVoYXZpb3IgPSB0aGlzLmdldEJlaGF2aW9yKCksXG4gICAgICAgICAgICAgICAgY29sQ291bnQgPSB0aGlzLmdldENvbHVtbkNvdW50KCksXG4gICAgICAgICAgICAgICAgdG9wUm93ID0gc2Vsc1swXS5vcmlnaW4ueSxcbiAgICAgICAgICAgICAgICByb3cgPSB7XG4gICAgICAgICAgICAgICAgICAgIC8vaGllcmFyY2h5OiBiZWhhdmlvci5nZXRGaXhlZENvbHVtblZhbHVlKDAsIHRvcFJvdylcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBmb3IgKHZhciBjID0gMDsgYyA8IGNvbENvdW50OyBjKyspIHtcbiAgICAgICAgICAgICAgICByb3dbYmVoYXZpb3IuZ2V0Q29sdW1uSWQoYywgMCldID0gYmVoYXZpb3IuZ2V0VmFsdWUoYywgdG9wUm93KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHJvdztcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICBmaXJlUmVxdWVzdENlbGxFZGl0OiBmdW5jdGlvbihjZWxsLCB2YWx1ZSkge1xuICAgICAgICB2YXIgY2xpY2tFdmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLXJlcXVlc3QtY2VsbC1lZGl0Jywge1xuICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcbiAgICAgICAgICAgICAgICBncmlkQ2VsbDogY2VsbCxcbiAgICAgICAgICAgICAgICB0aW1lOiBEYXRlLm5vdygpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChjbGlja0V2ZW50KTsgLy9JIHdhc24ndCBjYW5jZWxsZWRcbiAgICB9LFxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiB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GV4T2YoJ0NUUkwnKSA+IC0xO1xuICAgICAgICB2YXIgaGFzU0hJRlQgPSBrZXlzLmluZGV4T2YoJ1NISUZUJykgPiAtMTtcbiAgICAgICAgaWYgKCFoYXNDVFJMICYmICFoYXNTSElGVCkge1xuICAgICAgICAgICAgbW9kZWwuY2xlYXIoKTtcbiAgICAgICAgICAgIGlmICghYWxyZWFkeVNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Q29sdW1uKHgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKGhhc0NUUkwpIHtcbiAgICAgICAgICAgICAgICBpZiAoYWxyZWFkeVNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIG1vZGVsLmRlc2VsZWN0Q29sdW1uKHgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG1vZGVsLnNlbGVjdENvbHVtbih4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaGFzU0hJRlQpIHtcbiAgICAgICAgICAgICAgICBtb2RlbC5jbGVhcigpO1xuICAgICAgICAgICAgICAgIG1vZGVsLnNlbGVjdENvbHVtbih0aGlzLmxhc3RFZGdlU2VsZWN0aW9uWzBdLCB4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoIWFscmVhZHlTZWxlY3RlZCAmJiAhaGFzU0hJRlQpIHtcbiAgICAgICAgICAgIHRoaXMubGFzdEVkZ2VTZWxlY3Rpb25bMF0gPSB4O1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucmVwYWludCgpO1xuICAgICAgICB0aGlzLmZpcmVTeW50aGV0aWNDb2x1bW5TZWxlY3Rpb25DaGFuZ2VkRXZlbnQoKTtcbiAgICB9LFxuXG4gICAgdG9nZ2xlU2VsZWN0Um93OiBmdW5jdGlvbih5LCBrZXlz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xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNTaW5nbGVSb3dTZWxlY3Rpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZGVsLmNsZWFyUm93U2VsZWN0aW9uKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Um93KHkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChoYXNTSElGVCkge1xuICAgICAgICAgICAgICAgIG1vZGVsLmNsZWFyKCk7XG4gICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Um93KHRoaXMubGFzdEVkZ2VTZWxlY3Rpb25bMV0sIHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICghYWxyZWFkeVNlbGVjdGVkICYmICFoYXNTSElGVCkge1xuICAgICAgICAgICAgdGhpcy5sYXN0RWRnZVNlbGVjdGlvblsxXSA9IHk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZXBhaW50KCk7XG4gICAgfSxcblxuICAgIHNlbGVjdFZpZXdwb3J0Q2VsbDogZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICB2YXIgaGVhZGVyUm93Q291bnQgPSB0aGlzLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIHZhciByZW5kZXJlciA9IHRoaXMuZ2V0UmVuZGVyZXIoKTtcbiAgICAgICAgdmFyIHJlYWxYID0gcmVuZGVyZXIuZ2V0VmlzaWJsZUNvbHVtbnMoKVt4XTtcbiAgICAgICAgdmFyIHJlYWxZID0gcmVuZGVyZXIuZ2V0VmlzaWJsZVJvd3MoKVt5XTtcbiAgICAgICAgdGhpcy5jbGVhclNlbGVjdGlvbnMoKTtcbiAgICAgICAgdGhpcy5zZWxlY3QocmVhbFgsIHJlYWxZICsgaGVhZGVyUm93Q291bnQsIDAsIDApO1xuICAgICAgICB0aGlzLnNldE1vdXNlRG93bih0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FZYID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RWWCA9IHZ4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsYXN0VlggPSB2eDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh4ID4gdmlld1dpZHRoIHx8IG51bUNvbHVtbnMgPD0gdngpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHdpZHRoID0gdGhpcy5nZXRDb2x1bW5XaWR0aCh2eCk7XG4gICAgICAgICAgICB4ID0geCArIHdpZHRoO1xuICAgICAgICAgICAgdGhpcy5jb2x1bW5FZGdlc1tjICsgMV0gPSBNYXRoLnJvdW5kKHgpO1xuICAgICAgICAgICAgdGhpcy52aXNpYmxlQ29sdW1uc1tjXSA9IHZ4O1xuICAgICAgICAgICAgdGhpcy5jb2x1bW5FZGdlc0luZGV4TWFwW3Z4XSA9IGM7XG5cbiAgICAgICAgICAgIGluc2VydGlvbkJvdW5kc0N1cnNvciA9IGluc2VydGlvbkJvdW5kc0N1cnNvciArIE1hdGgucm91bmQod2lkdGggLyAyKSArIHByZXZpb3VzSW5zZXJ0aW9uQm91bmRzQ3Vyc29yVmFsdWU7XG4gICAgICAgICAgICB0aGlzLmluc2VydGlvbkJvdW5kcy5wdXNoKGluc2VydGlvbkJvdW5kc0N1cnNvcik7XG4gICAgICAgICAgICBwcmV2aW91c0luc2VydGlvbkJvdW5kc0N1cnNvclZhbHVlID0gTWF0aC5yb3VuZCh3aWR0aCAvIDIpO1xuICAgICAgICB9XG5cbiAgICAgICAgeSA9IDA7XG4gICAgICAgIGZvciAociA9IDA7IHIgPCBudW1Sb3dzOyByKyspIHtcbiAgICAgICAgICAgIHZ5ID0gcjtcbiAgICAgICAgICAgIGlmIChyID49IG51bUZpeGVkUm93cykge1xuICAgICAgICAgICAgICAgIHZ5ID0gdnkgKyBzY3JvbGxUb3A7XG4gICAgIC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3MubGVuZ3RoIC0gMTtcbiAgICB9LFxuXG4gICAgZ2V0VmlzaWJsZVNjcm9sbEhlaWdodDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBncmlkID0gdGhpcy5nZXRHcmlkKCksXG4gICAgICAgICAgICBmcmggPSBncmlkLmdldEZpeGVkUm93c0hlaWdodCgpO1xuXG4gICAgICAgIHJldHVybiB0aGlzLnZpZXdIZWlnaHQgLSBmcmg7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBSZW5kZXJlci5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7bnVtYmVyW119IFJvd3Mgd2UganVzdCByZW5kZXJlZC5cbiAgICAgKi9cbiAgICBnZXRWaXNpYmxlUm93czogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnZpc2libGVSb3dzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gTnVtZXIgb2YgY29sdW1ucyB3ZSBqdXN0IHJlbmRlcmVkLlxuICAgICAqL1xuICAgIGdldFZpc2libGVDb2x1bW5zQ291bnQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy52aXNpYmxlQ29sdW1ucy5sZW5ndGggLSAxO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gQ29sdW1ucyB3ZSBqdXN0IHJlbmRlcmVkLlxuICAgICAqL1xuICAgIGdldFZpc2libGVDb2x1bW5zOiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudmlzaWJsZUNvbHVtbnM7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBSZW5kZXJlci5wcm90b3R5cGVcbiAgICAgKiBA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mdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgLy8gdmFyIGZpeGVkUm93Q291bnQgPSB0aGlzLmdldEZpeGVkUm93Q291bnQoKTtcbiAgICAgICAgdmFyIHNjcm9sbFggPSB0aGlzLmdldFNjcm9sbExlZnQoKTtcbiAgICAgICAgdmFyIHNjcm9sbFkgPSB0aGlzLmdldFNjcm9sbFRvcCgpO1xuXG4gICAgICAgIGZvciAoYyA9IDA7IGMgPCBjb2x1bW5FZGdlcy5sZW5ndGg7IGMrKykge1xuICAgICAgICAgICAgd2lkdGggPSBjb2x1bW5FZGdlc1tjXTtcbiAgICAgICAgICAgIGlmIChwb2ludC54IDwgd2lkdGgpIHtcbiAgICAgICAgICAgICAgICB4ID0gTWF0aC5tYXgoMCwgcG9pbnQueCAtIHByZXZpb3VzIC0gMik7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcmV2aW91cyA9IHdpZHRoO1xuICAgICAgICB9XG4gICAgICAgIGMtLTtcbiAgICAgICAgcHJldmlvdXMgPSAwO1xuICAgICAgICBmb3IgKHIgPSAwOyByIDwgdGhpcy5yb3dFZGdlcy5sZW5ndGg7IHIrKykge1xuICAgICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yb3dFZGdlc1tyXTtcbiAgICAgICAgICAgIGlmIChwb2ludC55IDwgaGVpZ2h0KSB7XG4gICAgICAgICAgICAgICAgeSA9IE1hdGgubWF4KDAsIHBvaW50LnkgLSBwcmV2aW91cyAtIDIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHJldmlvdXMgPSBoZWlnaHQ7XG4gICAgICAgIH1cbiAgICAgICAgci0tO1xuICAgICAgICBpZiAocG9pbnQueCA8IDApIHtcbiAgICAgICAgICAgIGMgPSAtMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocG9pbnQueSA8IDApIHtcbiAgICAgICAgICAgIHIg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AgICB2YXIgbGluZUNvbG9yID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2xpbmVDb2xvcicpO1xuXG4gICAgICAgIGdjLmJlZ2luUGF0aCgpO1xuICAgICAgICBnYy5zdHJva2VTdHlsZSA9IGxpbmVDb2xvcjtcbiAgICAgICAgZ2MubGluZVdpZHRoID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2xpbmVXaWR0aCcpO1xuICAgICAgICBnYy5tb3ZlVG8oMCwgMCk7XG5cbiAgICAgICAgaWYgKGRyYXdUaGVtVikge1xuICAgICAgICAgICAgZm9yIChjID0gMDsgYyA8IGNvbFdpZHRocy5sZW5ndGggKyAxOyBjKyspIHtcbiAgICAgICAgICAgICAgICB4ID0gY29sV2lkdGhzW2NdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbyh4LCAwKTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8oeCwgdmlld0hlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZHJhd1RoZW1IKSB7XG4gICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgcm93SGVpZ2h0cy5sZW5ndGg7IHIrKykge1xuICAgICAgICAgICAgICAgIHkgPSByb3dIZWlnaHRzW3JdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbygwLCB5KTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8odmlld1dpZHRoLCB5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBnYy5zdHJva2UoKTtcbiAgICAgICAgZ2MuY2xvc2VQYXRoKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBSZW5kZXJlci5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0ge0NhbnZhc1JlbmRlcmluZ0NvbnRleHQyRH0gZ2NcbiAgICAgKiBAcGFyYW0geFxuICAgICAqIEBwYXJhbSB5XG4gICAgICovXG4g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F0dGVuZWRZczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgdmFyIHNldCA9IHt9O1xuICAgICAgICB0aGlzLnNlbGVjdGlvbnMuZm9yRWFjaChmdW5jdGlvbihzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciB0b3AgPSBzZWxlY3Rpb24ub3JpZ2luLnk7XG4gICAgICAgICAgICB2YXIgc2l6ZSA9IHNlbGVjdGlvbi5leHRlbnQueSArIDE7XG4gICAgICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IHNpemU7IHIrKykge1xuICAgICAgICAgICAgICAgIHZhciB0aSA9IHIgKyB0b3A7XG4gICAgICAgICAgICAgICAgaWYgKCFzZXRbdGldKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKHRpKTtcbiAgICAgICAgICAgICAgICAgICAgc2V0W3RpXSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgcmVzdWx0LnNvcnQoZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICAgICAgcmV0dXJuIHggLSB5O1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFNlbGVjdGlvbk1vZGVsLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSBvZmZzZXRcbiAgICAgKi9cbiAgICBzZWxlY3RSb3dzRnJvbUNlbGxzOiBmdW5jdGlvbihvZmZzZXQpIHtcbiAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0IHx8IDA7XG5cbiAgICAgICAgdmFyIHNtID0gdGhpcy5yb3dTZWxlY3Rpb25Nb2RlbDtcbiAgICAgICAgdGhpcy5hbGxSb3dzU2VsZWN0ZWQgPSBmYWxzZTtcbiAgICAgICAgc20uY2xlYXIoKTtcblxuICAgICAgICB0aGlzLnNlb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Skge1xuICAgICAgICB2YXIgbGFzdCA9IHRoaXMuc2VsZWN0aW9uc1t0aGlzLnNlbGVjdGlvbnMubGVuZ3RoIC0gMV07XG4gICAgICAgIHJldHVybiBsYXN0ICYmIHRoaXMucmVjdGFuZ2xlQ29udGFpbnMobGFzdCwgeCwgeSk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBTZWxlY3Rpb25Nb2RlbC5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gcmVjdFxuICAgICAqIEBwYXJhbSB4XG4gICAgICogQHBhcmFtIHlcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn1cbiAgICAgKi9cbiAgICByZWN0YW5nbGVDb250YWluczogZnVuY3Rpb24ocmVjdCwgeCwgeSkgeyAvL1RPRE86IGV4cGxvcmUgd2h5IHRoaXMgd29ya3MgYW5kIGNvbnRhaW5zIG9uIHJlY3RhbmdsdWxhciBkb2VzIG5vdFxuICAgICAgICB2YXIgbWluWCA9IHJlY3Qub3JpZ2luLng7XG4gICAgICAgIHZhciBtaW5ZID0gcmVjdC5vcmlnaW4ueTtcbiAgICAgICAgdmFyIG1heFggPSBtaW5YICsgcmVjdC5leHRlbnQueDtcbiAgICAgICAgdmFyIG1heFkgPSBtaW5ZICsgcmVjdC5leHRlbnQueTtcblxuICAgICAgICBpZiAocmVjdC5leHRlbnQueCA8IDApIHtcbiAgICAgICAgICAgIG1pblggPSBtYXhYO1xuICAgICAgICAgICAgbWF4WCA9IHJlY3Qub3JpZ2luLng7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocmVjdC5leHRlbnQueSA8IDApIHtcbiAgICAgICAgICAgIG1pblkgPSBtYXhZO1xuICAgICAgICAgICAgbWF4WSA9IHJlY3Qub3JpZ2luLnk7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgcmVzdWx0ID1cbiAgICAgICAgICAgIHggPj0gbWluWCAmJlxuICAgICAgICAgICAgeSA+PSBtaW5ZICYmXG4gICA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iAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnJvd0hlYWRlciA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJGb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMuY29sdW1uSGVhZGVyID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb250OiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckZvbnQ7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5jb2x1bW5IZWFkZXJDb2x1bW5TZWxlY3Rpb24gPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMuY29sdW1uSGVhZGVyLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5yb3dIZWFkZXJSb3dTZWxlY3Rpb24gPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMucm93SGVhZGVyLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyRm9yZWdyb3VuZFJvd1NlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRSb3dTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyQmFja2dyb3VuZFJvd1NlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRSb3dTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5maWx0ZXJQcm9wZXJ0aWVzID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb250OiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckZvbnQ7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckJhY2tncm91bmRDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjZWxsQm9yZGVyU3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclN0eWxlO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckNlbGxCb3JkZXJTdHlsZSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjZWxsQm9yZGVyVGhpY2tuZXNzOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckNlbGxCb3JkZXJUaGlja25lc3M7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclRoaWNrbmVzcyA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy50cmVlQ29sdW1uUHJvcGVydGllcyA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uRm9udDtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5Gb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnRyZWVDb2x1bW5Qcm9wZXJ0aWVzQ29sdW1uU2VsZWN0aW9uID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLnRyZWVDb2x1bW5Qcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiBwcm9wZXJ0aWVzO1xuICAgIH0sXG5cbiAgICBnZXRDb2x1bW5XaWR0aDogZnVuY3Rpb24oeCkge1xuICAgICAgICB2YXIgY29sID0gdGhpcy5nZXRDb2x1bW4oeCk7XG4gICAgICAgIGlmICghY29sKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2RlZmF1bHRDb2x1bW5XaWR0aCcpO1xuICAgICAgICB9XG4gICAgICAgIHZhciB3aWR0aCA9IGNvbC5nZXRXaWR0aCgpO1xuICAgICAgICByZXR1cm4gd2lkdGg7XG4gICAgfSxcblxuICAgIHNldENvbHVtbldpZHRoOiBmdW5jdGlvbih4LCB3aWR0aCkge1xuICAgICAgICB0aGlzLmdldENvbHVtbih4KS5zZXRXaWR0aCh3aWR0aCk7XG4gICAgICAgIHRoaXMuc3RhdGVDaGFuZ2VkKCk7XG4gICAgfSxcblxuICAgIGdldERhdGFNb2RlbDogZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLmRhdGFNb2RlbCA9PT0gbnVsbCkge1xuICAgICAgICAgICAgdmFyIGRhdGFNb2RlbCA9IHRoaXMuZ2V0RGVmYXVsdERh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ICAgICAgICAgICAgICBvYmouaGFzT3duUHJvcGVydHkoa2V5KSAmJiAoXG4gICAgICAgICAgICAgICAgICAgIGV4cG9ydFByb3BzID09PSB1bmRlZmluZWQgfHxcbiAgICAgICAgICAgICAgICAgICAgIWV4cG9ydFByb3BzICYmIG5vRXhwb3J0UHJvcGVydGllcy5pbmRleE9mKGtleSkgPj0gMCB8fFxuICAgICAgICAgICAgICAgICAgICBleHBvcnRQcm9wcyAmJiBub0V4cG9ydFByb3BlcnRpZXMuaW5kZXhPZihrZXkpIDwgMFxuICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmpba2V5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgQmVoYXZpb3IucHJvdG90eXBlXG4gICAgICogQGRlc2MgZ2V0dGVyIGZvciBhIFtNZW1lbnRvXShodHRwOi8vYzIuY29tL2NnaS93aWtpP01lbWVudG9QYXR0ZXJuKSBPYmplY3RcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0fVxuICAgICAqL1xuICAgIGdldFByaXZhdGVTdGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmICghdGhpcy50YWJsZVN0YXRlKSB7XG4gICAgICAgICAgICB0aGlzLnRhYmxlU3RhdGUgPSB0aGlzLmdldERlZmF1bHRTdGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnRhYmxlU3RhdGU7XG4gICAgfSxcblxuICAgIC8vdGhpcyBpcyBlZmZlY3RpdmVseSBhIGNsb25lLCB3aXRoIGNlcnRhaW4gdGhpbmdzIHJlbW92ZWQuLi4uXG4gICAgZ2V0U3RhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgY29weSA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRQcml2YXRlU3RhdGUoKS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cGVcbiAgICAgKiBAcmV0dXJuIHtib29sZWFufSBDYW4gcmUtb3JkZXIgY29sdW1ucy5cbiAgICAgKi9cbiAgICBpc0NvbHVtblJlb3JkZXJhYmxlOiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBCZWhhdmlvci5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJuIHtPYmplY3R9IFRoZSBwcm9wZXJ0aWVzIGZvciBhIHNwZWNpZmljIGNvbHVtbi4gVGhlc2UgYXJlIHVzZWQgaWYgbm8gY2VsbCBwcm9wZXJ0aWVzIGFyZSBzcGVjaWZpZWQuXG4gICAgICogQHBhcmFtIHtpbmRleH0gY29sdW1uSW5kZXggLSB0aGUgY29sdW1uIGluZGV4IG9mIGludGVyZXN0XG4gICAgICovXG4gICAgZ2V0Q29sdW1uUHJvcGVydGllczogZnVuY3Rpb24oY29sdW1uSW5kZXgpIHtcbiAgICAgICAgdmFyIGNvbCA9IHRoaXMuY29sdW1uc1tjb2x1bW5JbmRleF07XG4gICAgICAgIGlmICghY29sKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGlzTnVsbDogdHJ1ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgcHJvcGVydGllcyA9IGNvbC5nZXRQcm9wZXJ0aWVzKCk7IC8vVE9ETzogcmV0dXJucyBgbnVsbGAgb24gSHlwZXJncmlkLnJlc2V0KCk7XG4gICAgICAgIGlmICghcHJvcGVydGllcykge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICBpc051bGw6IHRydWVcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHByb3BlcnRpZXM7XG4gICAgfSxcbiAgICBzZXRDb2x1bW5Qcm9wZXJ0aWVzOiBmdW5jdGlvbihjb2x1bW5JbmRleCw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aXRvclBvc2l0aW9uRmxhZykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5jaGVja0VkaXRvclBvc2l0aW9uRmxhZyA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5pc0VkaXRpbmcpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgZWRpdG9yUG9pbnQgPSB0aGlzLmdldEVkaXRvclBvaW50KCk7XG4gICAgICAgIGlmICh0aGlzLmdyaWQuaXNEYXRhVmlzaWJsZShlZGl0b3JQb2ludC54LCBlZGl0b3JQb2ludC55KSkge1xuICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9yKCk7XG4gICAgICAgICAgICB0aGlzLnNob3dFZGl0b3IoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuaGlkZUVkaXRvcigpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGdldEdyaWQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5ncmlkO1xuICAgIH0sXG5cbiAgICB0ZW1wbGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIC8qXG5cbiAgICAgICAgICovXG4gICAgfSxcblxuICAgIGdldEhUTUw6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgc3RyaW5nID0gdGhpcy50ZW1wbGF0ZS50b1N0cmluZygpLnNwbGl0KCdcXG4nKTtcbiAgICAgICAgc3RyaW5nLnNoaWZ0KCk7XG4gICAgICAgIHN0cmluZy5zaGlmdCgpO1xuICAgICAgICBzdHJpbmcubGVuZ3RoID0gc3RyaW5nLmxlbmd0aCAtIDI7XG4gICAgICAgIHN0cmluZyA9IHN0cmluZy5qb2luKCdcXG4nKS50cmltKCk7XG4gICAgICAgIHJldHVybiBtdXN0YWNoZS5yZW5kZXIoc3RyaW5nLCB0aGlzKTtcbiAgIC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oJ21vdXNlZG93bicsIHRydWUsIHRydWUsIHdpbmRvdyk7XG4gICAgICAgIGVsZW1lbnQuZGlzcGF0Y2hFdmVudChldmVudCk7XG4gICAgfVxuXG59KTtcblxubW9kdWxlLmV4cG9ydHMgPSBDZWxsRWRpdG9yO1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgU2ltcGxlID0gcmVxdWlyZSgnLi9TaW1wbGUnKTtcblxuLyoqXG4gKiBAY29uc3RydWN0b3JcbiAqL1xudmFyIENob2ljZSA9IFNpbXBsZS5leHRlbmQoJ0Nob2ljZScsIHtcblxuICAgIC8qKlxuICAgICAqIG15IGxvb2t1cCBhbGlhc1xuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICogQG1lbWJlck9mIENob2ljZS5wcm90b3R5cGVcbiAgICAgKi9cbiAgICBhbGlhczogJ2Nob2ljZScsXG5cbiAgICAvKipcbiAgICAgKiB0aGUgbGlzdCBvZiBpdGVtcyB0byBwaWNrIGZyb21cbiAgICAgKiBAdHlwZSB7QXJyYXl9XG4gICAgICogQG1lbWJlck9mIENob2ljZS5wcm90b3R5cGVcbiAgICAgKi9cbiAgICBpdGVtczogWydhJywgJ2InLCAnYyddLFxuXG4gICAgdGVtcGxhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICAvKlxuICAgICAgICAgICAgICAgIDxzZWxlY3QgaWQ9XCJlZGl0b3JcIj5cbiAgICAgICAgICAgICAgICAgICAge3sjaXRlbXN9fVxuICAgICAgICAgICAgICAgICAgICAgICAgPG9wdGlvbiB2YWx1ZT1cInt7Ln19XCI+e3sufX08L29wdGlvbj5cbiAgICAgICAgICAgICAgICAgICAge3svaXRlbXN9fVxuICAgICAgICAgICAgICAgIDwvc2VsZWN0PlxuICAgICAgICAgICAgKi9cbiAgICB9LFxuXG4gICAgLy9ubyBldmVudHMgYXJlIGZpcmVkIHdoaWxlIHRoZSBkcm9wZG93biBpcyBvcGVuXG4gICAgLy9zZWUgaHR0cDovL2pzZ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WRpdG9yLmV4dGVuZCgnU2ltcGxlJywge1xuXG4gICAgLyoqXG4gICAgICogbXkgbG9va3VwIGFsaWFzXG4gICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgKiBAbWVtYmVyT2YgU2ltcGxlLnByb3RvdHlwZVxuICAgICAqL1xuICAgIGFsaWFzOiAnc2ltcGxlJyxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBTaW1wbGUucHJvdG90eXBlXG4gICAgICovXG4gICAgaW5pdGlhbGl6ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIHRoaXMuZWRpdG9yUG9pbnQgPSB7XG4gICAgICAgICAgICB4OiAwLFxuICAgICAgICAgICAgeTogMFxuICAgICAgICB9O1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgU2ltcGxlLnByb3RvdHlwZVxuICAgICAqIEBkZXNjICB0aGUgZnVuY3Rpb24gdG8gb3ZlcnJpZGUgZm9yIGluaXRpYWxpemF0aW9uXG4gICAgICovXG4gICAgaW5pdGlhbGl6ZUlucHV0OiBmdW5jdGlvbihpbnB1dCkge1xuICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2tleXVwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKGUgJiYgKGUua2V5Q29kZSA9PT0gMTMgfHwgZS5rZXlDb2RlID09PSAyNyB8fCBlLmtleUNvZGUgPT09IDgpKSB7XG4gICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgIGlmIChlLmtleUNvZGUgPT09IDgpIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5jbGVhclN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlLmtleUNvZGUgPT09IDI3KSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuY2FuY2VsRWRpdGluZygpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi5nZXRHcmlkKCkucmVwYWludCgpO1xuICAgICAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLnRha2VGb2N1cygpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5nZXRHcmlkKCkuZmlyZVN5bnRoZXRpY0VkaXRvcktleVVwRXZlbnQoc2VsZiwgZSk7XG4gICAgICAgIH0pO1xuICAgICAgICBpbnB1dC5hZGRFdmVudExpc3RlbmVyKCdrZXlkb3duJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgc2VsZi5nZXRHcmlkKCkuZmlyZVN5bnRoZXRpY0VkaXRvcktleURvd25FdmVudChzZWxmLCBlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2tleXByZXNzJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgY29uc29sZS5sb2coJ2tleXByZXNzJywgZS5rZXlDb2RlKTtcbiAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLmZpcmVTeW50aGV0aWNFZGl0b3JLZXlQcmVzc0V2ZW50KHNlbGYsIGUpO1xuICAgICAgICB9KTtcbiAgICAgICAgLy8gaW5wdXQuYWRkRXZlbnRMaXN0ZW5lcignZm9jdXNvdXQnLCBmdW5jdGlvbigpIHtcbiAgICAgICAgLy8gICAgIHNlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgLy8gfSk7XG4gICAgICAgIC8vIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2JsdXInLCBmdW5jdGlvbigpIHtcbiAgICAgICAgLy8gICAgIHNlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgLy8gfSk7XG4gICAgICAgIGlucHV0LnN0eWxlLn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ICAgICAgICB2YXIgaXNIZWFkZXJSb3cgPSBncmlkLmlzU2hvd0hlYWRlclJvdygpO1xuICAgICAgICB2YXIgaXNCb3RoID0gaXNGaWx0ZXJSb3cgJiYgaXNIZWFkZXJSb3c7XG4gICAgICAgIHZhciB0b3BUb3RhbHNPZmZzZXQgPSAoaXNGaWx0ZXJSb3cgPyAxIDogMCkgKyAoaXNIZWFkZXJSb3cgPyAxIDogMCk7XG4gICAgICAgIGlmICh5ID49IHRvcFRvdGFsc09mZnNldCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0VG9wVG90YWxzKClbeSAtIHRvcFRvdGFsc09mZnNldF1beF07XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGZpbHRlciA9IHRoaXMuZ2V0RmlsdGVyKHgpO1xuICAgICAgICB2YXIgaW1hZ2UgPSBmaWx0ZXIubGVuZ3RoID09PSAwID8gJ2ZpbHRlci1vZmYnIDogJ2ZpbHRlci1vbic7XG4gICAgICAgIHZhciBoZWFkZXIsIHNvcnRTdHJpbmc7XG4gICAgICAgIGlmIChpc0JvdGgpIHtcbiAgICAgICAgICAgIGlmICh5ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgaGVhZGVyID0gdGhpcy5nZXRIZWFkZXJzKClbeF07XG4gICAgICAgICAgICAgICAgc29ydFN0cmluZyA9IHRoaXMuZ2V0U29ydEltYWdlRm9yQ29sdW1uKHgsIHRydWUpO1xuICAgICAgICAgICAgICAgIGlmIChzb3J0U3RyaW5nKSB7IGhlYWRlciA9IHNvcnRTdHJpbmcgKyBoZWFkZXI7IH1cbiAgICAgICAgICAgICAgICByZXR1cm4gW251bGwsIGhlYWRlciwgbnVsbF07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBbbnVsbCwgZmlsdGVyLCBiZWhhdmlvci5nZXRJbWFnZShpbWFnZSldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKGlzRmlsdGVyUm93KSB7XG4gICAgICAgICAgICByZXR1cm4gW251bGwsIGZpbHRlciwgYmVoYXZpb3IuZ2V0SW1hZ2UoaW1hZ2UpXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGhlYWRlciA9IHRoaXMuZ2V0SGVhZGVycygpW3hdO1xuICAgICAgICAgICAgc29ydFN0cmluZyA9IHRoaXMuZ2V0U29ydEltYWdlRm9yQ29sdW1uKHgsIHRydWUpO1xuICAgICAgICAgICAgaWYgKHNvcnRTdHJpbmcpIHsgaGVhZGVyID0gc29ydFN0cmluZyArIGhlYWRlcjsgfVxuICAgICAgICAgICAgcmV0dXJuIFtudWxsLCBoZWFkZXIsIG51bGxdO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAnJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0ge251bWJlcn0geFxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB5XG4gICAgICogQHBhcmFtIHZhbHVlXG4gICAgICovXG4gICAgc2V0VmFsdWU6IGZ1bmN0aW9uKHgsIHksIHZhbHVlKSB7XG4gICAgICAgIHZhciBoYXNIaWVyYXJjaHlDb2x1bW4gPSB0aGlzLmhhc0hpZXJhcmNoeUNvbHVtbigpO1xuICAgICAgICB2YXIgZ3JpZCA9IHRoaXMuZ2V0R3JpZCgpO1xuICAgICAgICB2YXIgaGVhZGVyUm93Q291bnQgPSBncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIGlmIChoYXNIaWVyYXJjaHlDb2x1bW4pIHtcbiAgICAgICAgICAgIGlmICh4ID09PSAtMikge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgeCArPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh5IDwgaGVhZGVy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nNbY29sSW5kZXhdO1xuICAgICAgICBpZiAoY29sdW1uKSB7XG4gICAgICAgICAgICByZXR1cm4gY29sdW1uLmdldFByb3BlcnRpZXMoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBjb2xJbmRleFxuICAgICAqIEByZXR1cm5zIHsqfVxuICAgICAqL1xuICAgIGdldEZpbHRlcjogZnVuY3Rpb24oY29sSW5kZXgpIHtcbiAgICAgICAgdmFyIGNvbHVtblByb3BlcnRpZXMgPSB0aGlzLmdldENvbHVtblByb3BlcnRpZXMoY29sSW5kZXgpO1xuICAgICAgICBpZiAoIWNvbHVtblByb3BlcnRpZXMpIHtcbiAgICAgICAgICAgIHJldHVybiAnJztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY29sdW1uUHJvcGVydGllcy5maWx0ZXIgfHwgJyc7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IGNvbEluZGV4XG4gICAgICogQHBhcmFtIHZhbHVlXG4gICAgICovXG4gICAgc2V0RmlsdGVyOiBmdW5jdGlvbihjb2xJbmRleCwgdmFsdWUpIHtcbiAgICAgICAgdmFyIGNvbHVtblByb3BlcnRpZXMgPSB0aGlzLmdldENvbHVtblByb3BlcnRpZXMoY29sSW5kZXgpO1xuICAgICAgICBjb2x1bW5Qcm9wZXJ0aWVzLmZpbHRlciA9IHZhbHVlO1xuICAgICAgICB0aGlzLmFwcGx5QW5hbHl0aWNzKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJld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Gx5QW5hbHl0aWNzKCk7XG4gICAgICAgIHRoaXMuZ2V0R3JpZCgpLmZpcmVTeW50aGV0aWNHcm91cHNDaGFuZ2VkRXZlbnQodGhpcy5nZXRHcm91cHMoKSk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge29iamVjdFtdfVxuICAgICAqL1xuICAgIGdldEdyb3VwczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBoZWFkZXJzID0gdGhpcy5nZXRIZWFkZXJzKCkuc2xpY2UoMCk7XG4gICAgICAgIHZhciBmaWVsZHMgPSB0aGlzLmdldEZpZWxkcygpLnNsaWNlKDApO1xuICAgICAgICB2YXIgZ3JvdXBCeXMgPSB0aGlzLmFuYWx5dGljcy5ncm91cEJ5cztcbiAgICAgICAgdmFyIGdyb3VwcyA9IFtdO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGdyb3VwQnlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB2YXIgZmllbGQgPSBoZWFkZXJzW2dyb3VwQnlzW2ldXTtcbiAgICAgICAgICAgIGdyb3Vwcy5wdXNoKHtcbiAgICAgICAgICAgICAgICBpZDogZ3JvdXBCeXNbaV0sXG4gICAgICAgICAgICAgICAgbGFiZWw6IGZpZWxkLFxuICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZHNcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBncm91cHM7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge29iamVjdFtdfVxuICAgICAqL1xuICAgIGdldEF2YWlsYWJsZUdyb3VwczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBoZWFkZXJzID0gdGhpcy5zb3VyY2UuZ2V0SGVhZGVycygpLnNsaWNlKDApO1xuICAgICAgICB2YXIgZ3JvdXBCeXMgPSB0aGlzLmFuYWx5dGljcy5ncm91cEJ5cztcbiAgICAgICAgdmFyIGdyb3VwcyA9IFtdO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGhlYWRlcnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGlmIChncm91cEJ5cy5pbmRleE9mKGkpID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHZhciBmaWVsZCA9IGhlYWRlcnNbaV07XG4gICAgICAgICAgICAgICAgZ3JvdXBzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICBpZDogaSxcbiAgICAgICAgICAgICAgICAgICAgbGFiZWw6IGZpZWxkLFxuICAgICAgICAgICAgICAgICAgICBmaWVsZDogZmllbGRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZ3JvdXBzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtvYmplY3RbXX1cbiAgICAgKi9cbiAgICBnZXRWaXNpYmxlQ29sdW1uczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBpdGVtcyA9IHRoaXMuZ2V0QmVoYXZpb3IoKS5jb2x1bW5zO1xuICAgICAgICBpdGVtcyA9IGl0ZW1zLmZpbHRlcihmdW5jdGlvbihlYWNoKSB7XG4gICAgICAgICAgICByZXR1cm4gZWFjaC5sYWJlbCAhPT0gJ1RyZWUnO1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIGl0ZW1zO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtvYmplY3RbXX1cbiAgICAgKi9cbiAgICBnZXR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lzLmFwcGx5QW5hbHl0aWNzKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IGNvbEluZGV4XG4gICAgICogQHBhcmFtIHtzdHJpbmdbXX0ga2V5c1xuICAgICAqL1xuICAgIGluY3JlbWVudFNvcnRTdGF0ZTogZnVuY3Rpb24oY29sSW5kZXgsIGtleXMpIHtcbiAgICAgICAgY29sSW5kZXgrKzsgLy9oYWNrIHRvIGdldCBhcm91bmQgMCBpbmRleFxuICAgICAgICB2YXIgc3RhdGUgPSB0aGlzLmdldFByaXZhdGVTdGF0ZSgpO1xuICAgICAgICB2YXIgaGFzQ1RSTCA9IGtleXMuaW5kZXhPZignQ1RSTCcpID4gLTE7XG4gICAgICAgIHN0YXRlLnNvcnRzID0gc3RhdGUuc29ydHMgfHwgW107XG4gICAgICAgIHZhciBhbHJlYWR5ID0gc3RhdGUuc29ydHMuaW5kZXhPZihjb2xJbmRleCk7XG4gICAgICAgIGlmIChhbHJlYWR5ID09PSAtMSkge1xuICAgICAgICAgICAgYWxyZWFkeSA9IHN0YXRlLnNvcnRzLmluZGV4T2YoLTEgKiBjb2xJbmRleCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGFscmVhZHkgPiAtMSkge1xuICAgICAgICAgICAgaWYgKHN0YXRlLnNvcnRzW2FscmVhZHldID4gMCkge1xuICAgICAgICAgICAgICAgIHN0YXRlLnNvcnRzW2FscmVhZHldID0gLTEgKiBzdGF0ZS5zb3J0c1thbHJlYWR5XTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgc3RhdGUuc29ydHMuc3BsaWNlKGFscmVhZHksIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKGhhc0NUUkwgfHwgc3RhdGUuc29ydHMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICA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AgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBzb3J0aW5nU291cmNlLmFwcGx5U29ydHMoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gaW5kZXhcbiAgICAgKiBAcGFyYW0gcmV0dXJuQXNTdHJpbmdcbiAgICAgKiBAcmV0dXJucyB7Kn1cbiAgICAgKi9cbiAgICBnZXRTb3J0SW1hZ2VGb3JDb2x1bW46IGZ1bmN0aW9uKGluZGV4LCByZXR1cm5Bc1N0cmluZykge1xuICAgICAgICBpbmRleCsrO1xuICAgICAgICB2YXIgdXAgPSB0cnVlO1xuICAgICAgICB2YXIgc29ydHMgPSB0aGlzLmdldFByaXZhdGVTdGF0ZSgpLnNvcnRzO1xuICAgICAgICBpZiAoIXNvcnRzKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgcG9zaXRpb24gPSBzb3J0cy5pbmRleE9mKGluZGV4KTtcbiAgICAgICAgaWYgKHBvc2l0aW9uIDwgMCkge1xuICAgICAgICAgICAgcG9zaXRpb24gPSBzb3J0cy5pbmRleE9mKC0xICogaW5kZXgpO1xuICAgICAgICAgICAgdXAgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocG9zaXRpb24gPCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciByYW5rID0gc29ydHMubGVuZ3RoIC0gcG9zaXRpb247XG5cbiAgICAgICAgaWYgKHJldHVybkFzU3RyaW5nKSB7XG4gICAgICAgICAgICB2YXIgYXJyb3cgPSB1cCA/IFVQV0FSRFNfQkxBQ0tfQVJST1cgOiBET1dOV0FSRFNfQkxBQ0tfQVJST1c7XG4gICAgICAgICAgICByZXR1cm4gcmFuayArIGFycm93ICsgJyAnO1xuICAgICAgICB9X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uICAgICAgICB2YXIgaGVhZGVyUm93Q291bnQgPSBiZWhhdmlvci5nZXRIZWFkZXJSb3dDb3VudCgpO1xuICAgICAgICB2YXIgaGVhZGVyQ29sdW1uQ291bnQgPSBiZWhhdmlvci5nZXRIZWFkZXJDb2x1bW5Db3VudCgpO1xuICAgICAgICB2YXIgeCA9IGdyaWRDZWxsLng7XG4gICAgICAgIHZhciB5ID0gZ3JpZENlbGwueTtcbiAgICAgICAgeCA9IE1hdGgubWF4KGhlYWRlckNvbHVtbkNvdW50LCB4KTtcbiAgICAgICAgeSA9IE1hdGgubWF4KGhlYWRlclJvd0NvdW50LCB5KTtcblxuICAgICAgICB2YXIgcHJldmlvdXNEcmFnRXh0ZW50ID0gZ3JpZC5nZXREcmFnRXh0ZW50KCk7XG4gICAgICAgIHZhciBtb3VzZURvd24gPSBncmlkLmdldE1vdXNlRG93bigpO1xuXG4gICAgICAgIC8vdmFyIHNjcm9sbGluZ05vdyA9IGdyaWQuaXNTY3JvbGxpbmdOb3coKTtcblxuICAgICAgICB2YXIgbmV3WCA9IHggLSBtb3VzZURvd24ueDtcbiAgICAgICAgdmFyIG5ld1kgPSB5IC0gbW91c2VEb3duLnk7XG5cbiAgICAgICAgaWYgKHByZXZpb3VzRHJhZ0V4dGVudC54ID09PSBuZXdYICYmIHByZXZpb3VzRHJhZ0V4dGVudC55ID09PSBuZXdZKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBncmlkLmNsZWFyTW9zdFJlY2VudFNlbGVjdGlvbigpO1xuXG4gICAgICAgIGdyaWQuc2VsZWN0KG1vdXNlRG93bi54LCBtb3VzZURvd24ueSwgbmV3WCwgbmV3WSk7XG4gICAgICAgIGdyaWQuc2V0RHJhZ0V4dGVudChncmlkLm5ld1BvaW50KG5ld1gsIG5ld1kpKTtcblxuICAgICAgICBncmlkLnJlcGFpbnQoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENlbG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ICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICogQHBhcmFtIHtPYmplY3R9IGV2ZW50IC0gdGhlIGV2ZW50IGRldGFpbHNcbiAgICAgKi9cbiAgICBoYW5kbGVNb3VzZVVwOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICAvL3ZhciBjb2wgPSBldmVudC5ncmlkQ2VsbC54O1xuICAgICAgICBpZiAodGhpcy5kcmFnZ2luZykge1xuICAgICAgICAgICAgdGhpcy5jdXJzb3IgPSBudWxsO1xuICAgICAgICAgICAgLy9kZWxheSBoZXJlIHRvIGdpdmUgb3RoZXIgZXZlbnRzIGEgY2hhbmNlIHRvIGJlIGRyb3BwZWRcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgICAgIHRoaXMuZW5kRHJhZ0NvbHVtbihncmlkKTtcbiAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5hdHRhY2hDaGFpbigpO1xuICAgICAgICAgICAgfSwgMjAwKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmRyYWdDb2wgPSAtMTtcbiAgICAgICAgdGhpcy5kcmFnZ2luZyA9IGZhbHNlO1xuICAgICAgICB0aGlzLmRyYWdBcm1lZCA9IGZhbHNlO1xuICAgICAgICB0aGlzLmN1cnNvciA9IG51bGw7XG4gICAgICAgIGdyaWQucmVwYWludCgpO1xuXG4gICAgICAgIGlmICh0aGlzLm5leHQpIHtcbiAgICAgICAgICAgIHRoaXMubmV4dC5oYW5kbGVNb3VzZVVwKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgfVxuXG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBDZWxsTW92aW5nLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIGhhbmRsZSB0aGlzIGV2ZW50XG4gICAgICogQHBhcmFtIHtIeXBlcmdyaWR9IGdyaWRcbiAgICA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G4gICAgICAgICAgICBncmlkLnJlcGFpbnQoKTtcbiAgICAgICAgICAgIC8vbmVlZCB0byBjaGFuZ2UgdGhpcyB0byBrZXkgZnJhbWVzXG5cbiAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRDcm9zc0Jyb3dzZXJQcm9wZXJ0eShkLCAndHJhbnNpdGlvbicsICcnKTtcbiAgICAgICAgICAgICAgICBncmlkLnJlbmRlck92ZXJyaWRlc0NhY2hlLmZsb2F0ZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIGdyaWQucmVwYWludCgpO1xuICAgICAgICAgICAgICAgIHNlbGYuZG9GbG9hdGVyQW5pbWF0aW9uKGdyaWQpO1xuICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgZC5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmlzRmxvYXRpbmdOb3cgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0sIGNvbHVtbkFuaW1hdGlvblRpbWUgKyA1MCk7XG4gICAgICAgIH07XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBDZWxsTW92aW5nLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIG1hbmlmZXN0IHRoZSBmbG9hdGVyIGFuaW1hdGlvblxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICovXG4gICAgZG9GbG9hdGVyQW5pbWF0aW9uOiBmdW5jdGlvbihncmlkKSB7XG4gICAgICAgIGlmICh0aGlzLmZsb2F0ZXJBbmltYXRpb25RdWV1ZS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuZmxvYXRpbmdOb3cgPSBmYWxzZTtcbiAgICAgICAgICAgIGdyaWQ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AgICAgICB0aGlzLmN1cnNvciA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLmRyYWdJbmRleCA9IC0yO1xuXG4gICAgICAgICAgICBldmVudC5wcmltaXRpdmVFdmVudC5zdG9wUHJvcGFnYXRpb24oKTtcbiAgICAgICAgICAgIC8vZGVsYXkgaGVyZSB0byBnaXZlIG90aGVyIGV2ZW50cyBhIGNoYW5jZSB0byBiZSBkcm9wcGVkXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgICAgICBncmlkLnN5bmNocm9uaXplU2Nyb2xsaW5nQm91bmRyaWVzKCk7XG4gICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHNlbGYuYXR0YWNoQ2hhaW4oKTtcbiAgICAgICAgICAgIH0sIDIwMCk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VVcChncmlkLCBldmVudCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENvbHVtblJlc2l6aW5nLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIGhhbmRsZSB0aGlzIGV2ZW50IGRvd24gdGhlIGZlYXR1cmUgY2hhaW4gb2YgcmVzcG9uc2liaWxpdHlcbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VNb3ZlOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5kcmFnSW5kZXggPiAtMikge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuY3Vyc29yID0gbnVsbDtcbiAgICAgICAgaWYgKHRoaXMubmV4dC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ID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlVXAoZ3JpZCwgZXZlbnQpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBDb2x1bW5TZWxlY3Rpb24ucHJvdG90eXBlXG4gICAgICogQGRlc2MgKiBAZGVzYyBIYW5kbGUgdGhpcyBldmVudCBkb3duIHRoZSBmZWF0dXJlIGNoYWluIG9mIHJlc3BvbnNpYmlsaXR5LlxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICogQHBhcmFtIHtPYmplY3R9IGV2ZW50IC0gdGhlIGV2ZW50IGRldGFpbHNcbiAgICAgKi9cbiAgICBoYW5kbGVNb3VzZURvd246IGZ1bmN0aW9uKGdyaWQsIGV2ZW50KSB7XG5cbiAgICAgICAgaWYgKCghZ3JpZC5pc0NvbHVtblNlbGVjdGlvbigpIHx8IGV2ZW50Lm1vdXNlUG9pbnQueSA8IDUpICYmIHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRG93bihncmlkLCBldmVudCk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaXNSaWdodENsaWNrID0gZXZlbnQucHJpbWl0aXZlRXZlbnQuZGV0YWlsLmlzUmlnaHRDbGljaztcbiAgICAgICAgdmFyIGNlbGwgPSBldmVudC5ncmlkQ2VsbDtcbiAgICAgICAgdmFyIHZpZXdDZWxsID0gZXZlbnQudmlld1BvaW50O1xuICAgICAgICB2YXIgZHggPSBjZWxsLng7XG4gICAgICAgIHZhciBkeSA9IGNlbGwueTtcblxuICAgICAgICB2YXIgaXNIZWFkZXIgPSBncmlkLmlzU2hvd0hlYWRlclJvdygpICYmIGR5ID09PSAwICYmI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VzcG9uc2liaWxpdHlcbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEcmFnOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuXG4gICAgICAgIGlmICgoIWdyaWQuaXNDb2x1bW5TZWxlY3Rpb24oKSB8fCB0aGlzLmlzQ29sdW1uRHJhZ2dpbmcoZ3JpZCkpICYmIHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRHJhZyhncmlkLCBldmVudCk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaXNSaWdodENsaWNrID0gZXZlbnQucHJpbWl0aXZlRXZlbnQuZGV0YWlsLmlzUmlnaHRDbGljaztcblxuICAgICAgICBpZiAoaXNSaWdodENsaWNrIHx8ICF0aGlzLmRyYWdnaW5nKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRHJhZyhncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcblxuICAgICAgICAgICAgdmFyIGNlbGwgPSBldmVudC5ncmlkQ2VsbDtcbiAgICAgICAgICAgIHZhciB2aWV3Q2VsbCA9IGV2ZW50LnZpZXdQb2ludDtcbiAgICAgICAgICAgIHZhciBkeCA9IGNlbGwueDtcbiAgICAgICAgICAgIHZhciBkeSA9IGNlbGwueTtcblxuICAgICAgICAgICAgLy9pZiB3ZSBhcmUgaW4gdGhlIGZpeGVkIGFyZWEgZG8gbm90IGFwcGx5IHRoZSBzY3JvbG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G52YXIgc3R5bGVzaGVldHMgPSB7XG4gICAgZ3JpZDogW1xuICAgICAgICAnZGl2I2dyaWQtY29udGFpbmVyIHsnLFxuICAgICAgICAnICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsnLFxuICAgICAgICAnICAgIGRpc3BsYXk6IGlubGluZS1ibG9jazsnLFxuICAgICAgICAnICAgIC13ZWJraXQtdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICAtbW96LXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW1zLXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW8tdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICB1c2VyLXNlbGVjdDogbm9uZTsnLFxuICAgICAgICAnICAgIG92ZXJmbG93OiBoaWRkZW47IH0nLFxuICAgICAgICAndmlzaWJsZSB7IG9wYWNpdHk6IDAuNzU7IH0nLFxuICAgICAgICAnaGlkZGVuIHsgb3BhY2l0eTogMC4wOyB9JyxcbiAgICAgICAgJ2VkaXRvciB7JyxcbiAgICAgICAgJyAgICBwb3NpdGlvbjogYWJzb2x1dGU7JyxcbiAgICAgICAgJyAgICBkaXNwbGF5OiBub25lOycsXG4gICAgICAgICcgICAgYm9yZGVyOiBzb2xpZCAycHggYmxhY2s7JyxcbiAgICAgICAgJyAgICBvdXRsaW5lOiAwOycsXG4gICAgICAgICcgICAgcGFkZGluZzogMDsnLFxuICAgICAgICAnICAgIHotaW5kZXg6IDEwMDA7IH0nXG4gICAgXSxcbiAgICAnbGlzdC1kcmFnb24nOiBbXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QsIGxpLmRyYWdvbi1wb3AgeycsXG4gICAgICAgICcgICAgZm9udC1mYW1pbHk6IFJvYm90bywgc2Fucy1zZXJpZjsnLFxuICAgICAgICAnICAgIHRleHQtdHJhbnNmb3JtOiBjYXBpdGFsaXplOyB9JyxcbiAgICAgICAgJ2Rpdi5kcmFn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WUgJiYgZXh0ZW5kLmRlYnVnKSB7XG4gICAgICAgIHByb3RvdHlwZS4kJENMQVNTX05BTUUgPSBleHRlbmRlZENsYXNzTmFtZTtcbiAgICB9XG5cbiAgICBmb3IgKHZhciBrZXkgaW4gcHJvdG90eXBlQWRkaXRpb25zKSB7XG4gICAgICAgIGlmIChwcm90b3R5cGVBZGRpdGlvbnMuaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgdmFyIHZhbHVlID0gcHJvdG90eXBlQWRkaXRpb25zW2tleV07XG4gICAgICAgICAgICBzd2l0Y2ggKGtleSkge1xuICAgICAgICAgICAgICAgIGNhc2UgJ2luaXRpYWxpemVPd24nOlxuICAgICAgICAgICAgICAgICAgICAvLyBhbHJlYWR5IGNhbGxlZCBhYm92ZTsgbm90IG5lZWRlZCBpbiBwcm90b3R5cGVcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnYWxpYXNlcyc6XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGFsaWFzIGluIHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUuaGFzT3duUHJvcGVydHkoYWxpYXMpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUFsaWFzKHZhbHVlW2FsaWFzXSwgYWxpYXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIHZhbHVlWzBdID09PSAnIycpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VBbGlhcyh2YWx1ZSwga2V5LnN1YnN0cigxKSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICA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ucykge1xuICAgICAgICBpZiAob3B0aW9ucy5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICB2YXIgb3B0aW9uID0gb3B0aW9uc1trZXldO1xuICAgICAgICAgICAgc3dpdGNoIChrZXkpIHtcblxuICAgICAgICAgICAgY2FzZSAnaW5kZXgnOlxuICAgICAgICAgICAgICAgIHRoaXMuX2luZGV4ID0gb3B0aW9uO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBjYXNlICdyYW5nZSc6XG4gICAgICAgICAgICAgICAgdmFsaWRSYW5nZShvcHRpb24pO1xuICAgICAgICAgICAgICAgIHRoaXMuX21pbiA9IG9wdGlvbi5taW47XG4gICAgICAgICAgICAgICAgdGhpcy5fbWF4ID0gb3B0aW9uLm1heDtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRTaXplID0gb3B0aW9uLm1heCAtIG9wdGlvbi5taW4gKyAxO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICAgICAga2V5LmNoYXJBdCgwKSAhPT0gJ18nICYmXG4gICAgICAgICAgICAgICAgICAgIHR5cGVvZiBGaW5CYXIucHJvdG90eXBlW2tleV0gIT09ICdmdW5jdGlvbidcbiAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gb3ZlcnJpZGUgcHJvdG90eXBlIGRlZmF1bHRzIGZvciBzdGFuZGFyZCA7XG4gICAgICAgICAgICAgICAgICAgIC8vIGV4dGVuZCB3aXRoIGFkZGl0aW9uYWwgcHJvcGVydGllcyAoZm9yIHVzZSBpbiBvbmNoYW5nZSBldmVudCBoYW5kbGVycylcbiAgICAgICAgICAgICAgICAgICAgdGhpc1trZXldID0gb3B0aW9uO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAg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dCgpLFxuICAgICAgICAgICAgICAgIG9oID0gdGhpcy5vaDtcblxuICAgICAgICAgICAgLy8gQmVmb3JlIGFwcGx5aW5nIG5ldyBzdHlsZXMsIHJldmVydCBhbGwgc3R5bGVzIHRvIHZhbHVlcyBpbmhlcml0ZWQgZnJvbSBzdHlsZXNoZWV0c1xuICAgICAgICAgICAgYmFyLnJlbW92ZUF0dHJpYnV0ZSgnc3R5bGUnKTtcblxuICAgICAgICAgICAga2V5cy5mb3JFYWNoKGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsID0gc3R5bGVzW2tleV07XG5cbiAgICAgICAgICAgICAgICBpZiAoa2V5IGluIG9oKSB7XG4gICAgICAgICAgICAgICAgICAgIGtleSA9IG9oW2tleV07XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCFpc05hTihOdW1iZXIodmFsKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsID0gKHZhbCB8fCAwKSArICdweCc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgvJSQvLnRlc3QodmFsKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBXaGVuIGJhciBzaXplIGdpdmVuIGFzIHBlcmNlbnRhZ2Ugb2YgY29udGFpbmVyLCBpZiBiYXIgaGFzIG1hcmdpbnMsIHJlc3RhdGUgc2l6ZSBpbiBwaXhlbHMgbGVzcyBtYXJnaW5zLlxuICAgICAgICAgICAgICAgICAgICAvLyAoSWYgbGVmdCBhcyBwZXJjZW50YWdlLCBDU1MncyBjYWxjdWxhdGlvbiB3aWxsIG5vdCBleGNsdWRlIG1hcmdpbnMuKVxuICAgICAgICAgICAgICAgICAgICB2YXIgb3JpZW50ZWQgPSBheGlzW2tleV0sXG4gICAgICAgICAgICAgICAgICAgICAgICBtYXJnaW5zID0gYmFyUmVjdFtvcmllbnRlZC5tYXJnaW5MZWFkaW5nXSArIGJhclJlY3Rbb3JpZW50ZWQubWFyZ2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xc3QgYXJnIG9taXR0ZWRcbiAgICAgICAgaWYgKHR5cGVvZiBpbmNyZW1lbnQgPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICBiYXJTdHlsZXMgPSBpbmNyZW1lbnQ7XG4gICAgICAgICAgICBpbmNyZW1lbnQgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnN0eWxlID0gdGhpcy5iYXJTdHlsZXMgPSBiYXJTdHlsZXMgfHwgdGhpcy5iYXJTdHlsZXM7XG5cbiAgICAgICAgLy8gQm91bmQgdG8gcmVhbCBjb250ZW50OiBDb250ZW50IHdhcyBnaXZlbiBidXQgbm8gb25jaGFuZ2UgaGFuZGxlci5cbiAgICAgICAgLy8gU2V0IHVwIC5vbmNoYW5nZSwgLmNvbnRhaW5lclNpemUsIGFuZCAuaW5jcmVtZW50LlxuICAgICAgICAvLyBOb3RlIHRoaXMgb25seSBtYWtlcyBzZW5zZSBpZiB5b3VyIGluZGV4IHVuaXQgaXMgcGl4ZWxzLlxuICAgICAgICBpZiAodGhpcy5jb250ZW50KSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMub25jaGFuZ2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm9uY2hhbmdlID0gdGhpcy5zY3JvbGxSZWFsQ29udGVudDtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRTaXplID0gdGhpcy5jb250ZW50W3RoaXMub2guc2l6ZV07XG4gICAgICAgICAgICAgICAgdGhpcy5fbWluID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLl9tYXggPSB0aGlzLmNvbnRlbnRTaXplIC0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5vbmNoYW5nZSA9PT0gdGhpcy5zY3JvbGxSZWFsQ29udGVudCkge1xuICAgICAgICAgICAgdGhpcy5jb250YWluZXJTaXplID0gY29udGFpbmVyUmVjdFt0aGlzLm9oLnNpemVdO1xuICAgICAgICA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ICAgICAgICAgICAgdGh1bWJCb3gubGVmdCA8PSBldnQuY2xpZW50WCAmJiBldnQuY2xpZW50WCA8PSB0aHVtYkJveC5yaWdodCAmJlxuICAgICAgICAgICAgdGh1bWJCb3gudG9wIDw9IGV2dC5jbGllbnRZICYmIGV2dC5jbGllbnRZIDw9IHRodW1iQm94LmJvdHRvbVxuICAgICAgICApIHtcbiAgICAgICAgICAgIHRoaXMuX2JvdW5kLm9ubW91c2VvdmVyKGV2dCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9ib3VuZC5vbm1vdXNlb3V0KGV2dCk7XG4gICAgICAgIH1cblxuICAgICAgICBldnQuc3RvcFByb3BhZ2F0aW9uKCk7XG4gICAgICAgIGV2dC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgIH1cbn07XG5cbnZhciBvcmllbnRhdGlvbkhhc2hlcyA9IHtcbiAgICB2ZXJ0aWNhbDoge1xuICAgICAgICBjb29yZGluYXRlOiAgICAgJ2NsaWVudFknLFxuICAgICAgICBheGlzOiAgICAgICAgICAgJ3BhZ2VZJyxcbiAgICAgICAgc2l6ZTogICAgICAgICAgICdoZWlnaHQnLFxuICAgICAgICBvdXRzaWRlOiAgICAgICAgJ3JpZ2h0JyxcbiAgICAgICAgaW5zaWRlOiAgICAgICAgICdsZWZ0JyxcbiAgICAgICAgbGVhZGluZzogICAgICAgICd0b3AnLFxuICAgICAgICB0cmFpbGluZzogICAgICAgJ2JvdHRvbScsXG4gICAgICAgIG1hcmdpbkxlYWRpbmc6ICAnbWFyZ2luVG9wJyxcbiAgICAgICAgbWFyZ2luVHJhaWxpbmc6ICdtYXJnaW5Cb3R0b20nLFxuICAgICAgICB0aGlja25lc3M6ICAgICAgJ3dpZHRoJyxcbiAgICAgICAgZGVsdGE6ICAgICAgICAgICdkZWx0YVknXG4gICAgfSxcbiAgICBob3Jpem9udGFsOiB7XG4gICAgICAgIGNvb3JkaW5hdGU6ICAgICAnY2xpZW50WCcsXG4gICAgICAgIGF4aXM6ICAgICAgICAgICAncGFnZVgnLFxuICAgICAgICBzaXplOiAgICAgICAgICAgJ3dpZHRoJyxcbiAgICAgICAgb3V0c2lkZTogICAgICAgICdib3R0b20nLFxuICAgICAgICBpbnNpZGU6ICAgICAgICAgJ3RvcCcsXG4gICAgICAgIGxlYWRpbmc6ICAgICAgICAnbGVmdCcsXG4gICAgICAgIHRyYWlsaW5nOiAgICAgICAncmlnaHQnLFxuICAgICAgICBtYXJnaW5MZWFkaW5nOiAgJ21hcmdpbkxlZnQnLFxuICAgICAgICBtYXJnaW5UcmFpbGluZzogJ21hcmdpblJpZ2h0JyxcbiAgICAgICAgdGhpY2tuZXNzOiAgICAgICdoZWlnaHQnLFxuICAgICAgICBkZWx0YTogICAgICAgICAgJ2RlbHRhWCdcbiAgICB9XG59O1xuXG52YXIgYXhpcyA9IHtcbiAgICB0b3A6ICAgICd2ZXJ0aWNhbCcsXG4gICAgYm90dG9tOiAndmVydGljYWwnLFxuICAgIGhlaWdodDogJ3ZlcnRpY2FsJyxcbiAgICBsZWZ0OiAgICdob3Jpem9udGFsJyxcbiAgICByaWdodDogICdob3Jpem9udGFsJyxcbiAgICB3aWR0aDogICdob3Jpem9udGFsJ1xufTtcblxudmFyIGNzc0ZpbkJhcnM7IC8vIGRlZmluaXRpb24gaW5zZXJ0ZWQgYnkgZ3VscGZpbGUgYmV0d2VlbiBmb2xsb3dpbmcgY29tbWVudHNcbi8qIGluamVjdDpjc3MgKi9cbmNzc0ZpbkJhcnMgPSAnZGl2LmZpbmJhci1ob3Jpem9udGFsLGRpdi5maW5iYXItdmVydGljYWx7cG9zaXRpb246YWJzb2x1dGU7bWFyZ2luOjNweH1kaXYuZmluYmFyLWhvcml6b250YWw+LnRodW1iLGRpdi5maW5iYXItdmVydGljYWw+LnRodW1ie3Bvc2l0aW9uOmFic29sdXRlO2JhY2tncm91bmQtY29sb3I6I2QzZDNkMzstd2Via2l0LWJveC1zaGFkb3c6MCAwIDFweCAj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AgICAgICByZXR1cm4gdGhpcy5ib3VuZHM7XG4gICAgfSxcblxuICAgIHBhaW50Tm93OiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgICAgICB0aGlzLnNhZmVQYWludEltbWVkaWF0ZWx5KGZ1bmN0aW9uKGdjKSB7XG4gICAgICAgICAgICBnYy5jbGVhclJlY3QoMCwgMCwgc2VsZi5jYW52YXMud2lkdGgsIHNlbGYuY2FudmFzLmhlaWdodCk7XG5cbiAgICAgICAgICAgIHZhciBjb21wID0gc2VsZi5fY29tcG9uZW50O1xuICAgICAgICAgICAgaWYgKGNvbXApIHtcbiAgICAgICAgICAgICAgICBjb21wLl9wYWludChnYyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHNlbGYuZGlydHkgPSBmYWxzZTtcbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIHNhZmVQYWludEltbWVkaWF0ZWx5OiBmdW5jdGlvbihwYWludEZ1bmN0aW9uKSB7XG4gICAgICAgIHZhciB1c2VCaXRCbGl0ID0gdGhpcy51c2VCaXRCbGl0KCksXG4gICAgICAgICAgICBnYyA9IHVzZUJpdEJsaXQgPyB0aGlzLmJ1ZmZlckdDIDogdGhpcy5nYztcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGdjLnNhdmUoKTtcbiAgICAgICAgICAgIHBhaW50RnVuY3Rpb24oZ2MpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpO1xuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgZ2MucmVzdG9yZSgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh1c2VCaXRCbGl0KSB7XG4gICAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVyKCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgZmx1c2hCdWZmZXI6IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAodGhpc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AgICAgICAgICAgICAgIGlzUmlnaHRDbGljazogdGhpcy5pc1JpZ2h0Q2xpY2soZSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5kcmFnc3RhcnQgPSBuZXcgcmVjdGFuZ3VsYXIuUG9pbnQodGhpcy5tb3VzZUxvY2F0aW9uLngsIHRoaXMubW91c2VMb2NhdGlvbi55KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm1vdXNlTG9jYXRpb24gPSB0aGlzLmdldExvY2FsKGUpO1xuICAgICAgICAvL2NvbnNvbGUubG9nKHRoaXMubW91c2VMb2NhdGlvbik7XG4gICAgICAgIGlmICh0aGlzLmlzRHJhZ2dpbmcoKSkge1xuICAgICAgICAgICAgdGhpcy5kaXNwYXRjaE5ld01vdXNlS2V5c0V2ZW50KGUsICdmaW4tY2FudmFzLWRyYWcnLCB7XG4gICAgICAgICAgICAgICAgZHJhZ3N0YXJ0OiB0aGlzLmRyYWdzdGFydCxcbiAgICAgICAgICAgICAgICBpc1JpZ2h0Q2xpY2s6IHRoaXMuaXNSaWdodENsaWNrKGUpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5ib3VuZHMuY29udGFpbnModGhpcy5tb3VzZUxvY2F0aW9uKSkge1xuICAgICAgICAgICAgdGhpcy5kaXNwYXRjaE5ld01vdXNlS2V5c0V2ZW50KGUsICdmaW4tY2FudmFzLW1vdXNlbW92ZScpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGZpbm1vdXNlZG93bjogZnVuY3Rpb24oZSkge1xuICAgICAgICB0aGlzLm1vdXNlTG9jYXRpb24gPSB0aGlzLmdldExvY2FsKGUpO1xuICAgICAgICB0aGlzLm1vdXNlZG93biA9IHRydWU7XG5cbiAgICAgICAgdGhpcy5kaXNwYXRjaE5ld01vdXNlS2V5c0V2ZW50KGUsICdmaW4tY2FudmFzLW1vdXNlZG93bicsIHtcbiAgICAgICAgICAgIGlzUmlnaHR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47XG4gICAgICAgIH1cbiAgICAgICAgLy9kcmFnZW5kIGlzIGFsc28gY2F1c2luZyBhIHRhcFxuICAgICAgICAvL2xldHMgZml4IHRoaXMgaGVyZVxuICAgICAgICBpZiAobm93IC0gdGhpcy5kcmFnRW5kdGltZSA8IDEwMCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBzZWxmLl9maW50YXAoZSk7XG4gICAgICAgIH0sIDE4MCk7XG4gICAgfSxcblxuICAgIF9maW50YXA6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgLy90aGlzIG5vbnNlbnNlIGlzIHRvIGhvbGQgYSB0YXAgaWYgaXQncyByZWFsbHkgYSBkb3VibGUgY2xpY2tcbiAgICAgICAgdmFyIG5vdyA9IERhdGUubm93KCk7XG4gICAgICAgIHZhciBkaWYgPSBub3cgLSB0aGlzLmxhc3REb3VibGVDbGlja1RpbWU7XG4gICAgICAgIGlmIChkaWYgPCAzMDApIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICAvL3RoaXMubW91c2VMb2NhdGlvbiA9IHRoaXMuZ2V0TG9jYWwoZSk7XG4gICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdNb3VzZUtleXNFdmVudChlLCAnZmluLWNhbnZhcy10YXAnLCB7XG4gICAgICAgICAgICBpc1JpZ2h0Q2xpY2s6IHRoaXMuaXNSaWdodENsaWNrKGUpXG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBmaW5kYmxjbGljazogZnVuY3Rpb24oZSkge1xuICAgICAgICB0aGlzLm1vdXNlTG9jYXRpb24gPSB0aGlzLmdldExvY2FsKGUpO1xuICAgICAgICB0aGlzLmxhc3REb3VibGVDbGlja1RpbWUgPSBEYXRlLm5vdygpO1xuICAgICAgICB0aGlzLmRpc3BhdGNoTmV3TW91c2VLZXlzRXZlbnQoZSwgJ2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B0aGlzLnJlcGVhdEtleVN0YXJ0VGltZSA9IDA7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuY3VycmVudEtleXMuaW5kZXhPZihrZXlDaGFyKSA9PT0gLTEpIHtcbiAgICAgICAgICAgIHRoaXMuY3VycmVudEtleXMucHVzaChrZXlDaGFyKTtcbiAgICAgICAgfVxuICAgICAgICAvL2NvbnNvbGUubG9nKGtleUNoYXIsIGUua2V5Q29kZSk7XG4gICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdFdmVudChlLCAnZmluLWNhbnZhcy1rZXlkb3duJywge1xuICAgICAgICAgICAgYWx0OiBlLmFsdEtleSxcbiAgICAgICAgICAgIGN0cmw6IGUuY3RybEtleSxcbiAgICAgICAgICAgIGNoYXI6IGtleUNoYXIsXG4gICAgICAgICAgICBjb2RlOiBlLmNoYXJDb2RlLFxuICAgICAgICAgICAga2V5OiBlLmtleUNvZGUsXG4gICAgICAgICAgICBtZXRhOiBlLm1ldGFLZXksXG4gICAgICAgICAgICByZXBlYXRDb3VudDogdGhpcy5yZXBlYXRLZXlDb3VudCxcbiAgICAgICAgICAgIHJlcGVhdFN0YXJ0VGltZTogdGhpcy5yZXBlYXRLZXlTdGFydFRpbWUsXG4gICAgICAgICAgICBzaGlmdDogZS5zaGlmdEtleSxcbiAgICAgICAgICAgIGlkZW50aWZpZXI6IGUua2V5SWRlbnRpZmllcixcbiAgICAgICAgICAgIGN1cnJlbnRLZXlzOiB0aGlzLmN1cnJlbnRLZXlzLnNsaWNlKDApXG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBmaW5rZXl1cDogZnVuY3Rpb24oZSkge1xuICAgICAgICB2YXIga2V5Q2hhciA9IGUuc2hpZnRLZXkgPyBjaGFyTWFwW2Uua2V5Q29kZV1bMV0gOiBjaGFyTWFwW2Uua2V5Q29kZV1bMF07XG4gICAgICAgIHRoaXMuY3VycmVudEtleXMuc3BsaWNlKHRoaXMuY3VycmVudEtleXMuaW5kZXhP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kge1xuICAgICAgICBpZiAoZS5jdHJsS2V5ICYmIHRoaXMuY3VycmVudEtleXMuaW5kZXhPZignQ1RSTCcpID09PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50S2V5cy5wdXNoKCdDVFJMJyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKERhdGUubm93KCkgLSB0aGlzLmxhc3RDbGlja1RpbWUgPCAyNTApIHtcbiAgICAgICAgICAgIC8vdGhpcyBpcyBhIGRvdWJsZSBjbGljay4uLlxuICAgICAgICAgICAgdGhpcy5maW5kYmxjbGljayhlKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmRpc3BhdGNoTmV3TW91c2VLZXlzRXZlbnQoZSwgJ2Zpbi1jYW52YXMtY29udGV4dC1tZW51Jywge1xuICAgICAgICAgICAgaXNSaWdodENsaWNrOiB0aGlzLmlzUmlnaHRDbGljayhlKVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5sYXN0Q2xpY2tUaW1lID0gRGF0ZS5ub3coKTtcbiAgICB9LFxuXG4gICAgcmVwYWludDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBmcHMgPSB0aGlzLmdldEZQUygpO1xuICAgICAgICB0aGlzLmRpcnR5ID0gdHJ1ZTtcbiAgICAgICAgaWYgKCFwYWludExvb3BSdW5uaW5nIHx8IGZwcyA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5wYWludE5vdygpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGdldE1vdXNlTG9jYXRpb246IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5tb3VzZUxvY2F0aW9uO1xuICAgIH0sXG5cbiAgICBnZXRPcmlnaW46IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgcmVjdCA9IHRoaXMuY2FudmFzLmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpO1xuICAgICAgICB2YXIgcCA9IG5ldyByZWN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XR1cm4gaXNSaWdodE1CO1xuICAgIH0sXG5cbiAgICBkaXNwYXRjaEV2ZW50OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGUpO1xuICAgIH1cbn07XG5cbmZ1bmN0aW9uIHBhaW50TG9vcEZ1bmN0aW9uKG5vdykge1xuICAgIGlmICghcGFpbnRMb29wUnVubmluZykge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcGFpbnRhYmxlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcGFpbnRhYmxlc1tpXS50aWNrUGFpbnRlcihub3cpO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGUpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShwYWludExvb3BGdW5jdGlvbik7XG59XG5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUocGFpbnRMb29wRnVuY3Rpb24pO1xuXG5mdW5jdGlvbiByZXNpemFibGVzTG9vcEZ1bmN0aW9uKG5vdykge1xuICAgIGlmICghcmVzaXplTG9vcFJ1bm5pbmcpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHJlc2l6YWJsZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJlc2l6YWJsZXNbaV0udGlja1Jlc2l6ZXIobm93KTtcbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihlKTtcbiAgICAgICAgfVxuICAgIH1cbn1cbnNldEludGVydmFsKHJlc2l6YWJsZXNMb29wRnVuY3Rpb24sIFJFU0laRV9QT0xMSU5HX0lOVEVSVkFMKTtcblxuZnVuY3Rpb24gbWFrZUNoYXJNYXAoKSB7XG4gICAgdmFyIG1hcCA9IFtdO1xuXG4gICAgdmFyIGVtcHR5ID0gWycnLCAnJ107XG5cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IDI1NjsgaSsrKSB7XG4gICAgICAgIG1hcFtpXSA9IGVtcHR5O1xuICAgIH1cblxuICAgIG1hcFsyN10gPSBbJ0VTQycsICdFU0NTSElGVCddO1xuICAgIG1hcFsxOTJdID0gWydgJywgJ34nXTtcbiAgICBtYXBbNDldID0gWycxJywgJyEnXTtcbiAgICBtYXBbNTBdID0gWycyJywgJ0AnXTtcbiAgICBtYXBbNTFdID0gWyczJywgJyMnXTtcbiAgICBtYXBbNTJdID0gWyc0JywgJyQnXTtcbiAgICBtYXBbNTNdID0gWyc1JywgJyUnXTtcbiAgICBtYXBbNTRdID0gWyc2JywgJ14nXTtcbiAgICBtYXBbNTVdID0gWyc3JywgJyYnXTtcbiAgICBtYXBbNTZdID0gWyc4JywgJyonXTtcbiAgICBtYXBbNTddID0gWyc5JywgJygnXTtcbiAgICBtYXBbNDhdID0gWycwJywgJyknXTtcbiAgICBtYXBbMTg5XSA9IFsnLScsICdfJ107XG4gICAgbWFwWzE4N10gPSBbJz0nLCAnKyddO1xuICAgIG1hcFs4XSA9IFsnREVMRVRFJywgJ0RFTEVURVNISUZUJ107XG4gICAgbWFwWzldID0gWydUQUInLCAnVEFCU0hJRlQnXTtcbiAgICBtYXBbODFdID0gWydxJywgJ1EnXTtcbiAgICBtYXBbODddID0gWyd3JywgJ1cnXTtcbiAgICBtYXBbNjldID0gWydlJywgJ0UnXTtcbiAgICBtYXBbODJdID0gWydyJywgJ1InXTtcbiAgICBtYXBbODRdID0gWyd0JywgJ1QnXTtcbiAgICBtYXBbODldID0gWyd5JywgJ1knXTtcbiAgICBtYXBbODVdID0gWyd1JywgJ1UnXTtcbiAgICBtYXBbNzNdID0gWydpJywgJ0knXTtcbiAgICBtYXBbNzldID0gWydvJywgJ08nXTtcbiAgICBtYXBbODBd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IHtcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2Nba2V5XTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxvZ2dlciA/IGxvZ2dlcihrZXksICdnZXR0ZXInLCByZXN1bHQpIDogcmVzdWx0O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBnY1trZXldID0gbG9nZ2VyID8gbG9nZ2VyKGtleSwgJ3NldHRlcicsIHZhbHVlKSA6IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IEdyYXBoaWNzQ29udGV4dDtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIFlJRUxEUyA9ICdcXHUyN0Y5JzsgLy8gTE9ORyBSSUdIVFdBUkRTIERPVUJMRSBBUlJPV1xuXG5mdW5jdGlvbiBjb25zb2xlTG9nZ2VyKHByZWZpeCwgbmFtZSwgYXJncywgdmFsdWUpIHtcbiAgICB2YXIgcmVzdWx0ID0gdmFsdWU7XG5cbiAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJykge1xuICAgICAgICByZXN1bHQgPSAnXCInICsgcmVzdWx0ICsgJ1wiJztcbiAgICB9XG5cbiAgICBuYW1lID0gcHJlZml4ICsgbmFtZTtcblxuICAgIHN3aXRjaCAoYXJncykge1xuICAgICAgICBjYXNlICdnZXR0ZXInOlxuICAgICAgICAgICAgY29uc29sZS5sb2cobmFtZSwgJz0nLCByZXN1bHQpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgY2FzZSAnc2V0dGVyJzpcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKG5hbWUsIFlJRUxEUywgcmVzdWx0KTt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IHNlID0gc2hhZG93LnF1ZXJ5U2VsZWN0b3IoJ3NoYWRvdycpO1xuICAgICAgICAgICAgICAgIGlmIChzZSkge1xuICAgICAgICAgICAgICAgICAgICBvcyA9IHNlLm9sZGVyU2hhZG93Um9vdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gb3M7XG4gICAgICAgIH0sXG4gICAgICAgIGFsbFNoYWRvd3M6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBzaGFkb3dzID0gW10sXG4gICAgICAgICAgICAgICAgcyA9IHRoaXMuc2hhZG93KGVsZW1lbnQpO1xuICAgICAgICAgICAgd2hpbGUgKHMpIHtcbiAgICAgICAgICAgICAgICBzaGFkb3dzLnB1c2gocyk7XG4gICAgICAgICAgICAgICAgcyA9IHRoaXMub2xkZXJTaGFkb3cocyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gc2hhZG93cztcbiAgICAgICAgfSxcbiAgICAgICAgc2VhcmNoUm9vdDogZnVuY3Rpb24oaW5Sb290LCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgdCwgc3QsIHNyLCBvcztcbiAgICAgICAgICAgIGlmIChpblJvb3QpIHtcbiAgICAgICAgICAgICAgICB0ID0gaW5Sb290LmVsZW1lbnRGcm9tUG9pbnQoeCwgeSk7XG4gICAgICAgICAgICAgICAgaWYgKHQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZm91bmQgZWxlbWVudCwgY2hlY2sgaWYgaXQgaGFzIGEgU2hhZG93Um9vdFxuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMudGFyZ2V0aW5nU2hhZG93KHQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5Sb290ICE9PSBkb2N1bWVudCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBjaGVjayBmb3Igc2libGluZyByb290c1xuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMub2xkZXJTaGFkb3coaW5Sb290KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gc2VhcmNoIG90aGVyIHJvb3RzLCBmYWxsIGJhY2sgdG8gbGlnaHQgZG9tIGVsZW1lbnRcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zZWFyY2hSb290KHNyLCB4LCB5KSB8fCB0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBvd25lcjogZnVuY3Rpb24oZWxlbWVudCkge1xuICAgICAgICAgICAgaWYgKCFlbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHMgPSBlbGVtZW50O1xuICAgICAgICAgICAgLy8gd2FsayB1cCB1bnRpbCB5b3UgaGl0IHRoZSBzaGFkb3cgcm9vdCBvciBkb2N1bWVudFxuICAgICAgICAgICAgd2hpbGUgKHMucGFyZW50Tm9kZSkge1xuICAgICAgICAgICAgICAgIHMgPSBzLnBhcmVudE5vZGU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyB0aGUgb3duZXIgZWxlbWVudCBpcyBleHBlY3RlZCB0byBiZSBhIERvY3VtZW50IG9yIFNoYWRvd1Jvb3RcbiAgICAgICAgICAgIGlmIChzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfTk9ERSAmJiBzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfRlJBR01FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICB9LFxuICAgICAgICBmaW5kVGFyZ2V0OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5FdmVudC5wYXRoWzBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgeSA9IGluRXZlbnQuY2xpZW50WTtcbiAgICAgICAgICAgIC8vIGlmIHRoZSBsaXN0ZW5lciBpcyBpbiB0aGUgc2hhZG93IHJvb3QsIGl0IGlzIG11Y2ggZmFzdGVyIHRvIHN0YXJ0IHRoZXJlXG4gICAgICAgICAgICB2YXIgcyA9IHRoaXMub3duZXIoaW5FdmVudC50YXJnZXQpO1xuICAgICAgICAgICAgLy8gaWYgeCwgeSBpcyBub3QgaW4gdGhpcyByb290LCBmYWxsIGJhY2sgdG8gZG9jdW1lbnQgc2VhcmNoXG4gICAgICAgICAgICBpZiAoIXMuZWxlbWVudEZyb21Qb2ludCh4LCB5KSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzLnNlYXJjaFJvb3QocywgeCwgeSk7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaEFjdGlvbjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIG47XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcGF0aCA9IGluRXZlbnQucGF0aDtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgbiA9IHBhdGhbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChuLm5vZGVUeXBlID09PSBOb2RlLkVMRU1FTlRfTk9ERSAmJiBuLmhhc0F0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuLmdldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG4gPSBpbkV2ZW50LnRhcmdldDtcbiAgICAgICAgICAgICAgICB3aGlsZSAobikge1xuICAgICAgICAgICAgICAgICAgICBpZiAobi5ub2RlVHlwZSA9PT0gTm9kZS5FTEVNRU5UX05PREUgJiYgbi5oYXNBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbi5nZXRBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGF1dG8gaXMgZGVmYXVsdFxuICAgICAgICAgICAgcmV0dXJuIFwiYXV0b1wiO1xuICAgICAgICB9LFxuICAgICAgICBMQ0E6IGZ1bmN0aW9uKGEsIGIpIHtcbiAgICAgICAgICAgIGlmIChhID09PSBiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYSAmJiAhYikge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIgJiYgIWEpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghYiAmJiAhYSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGZhc3QgY2FzZSwgYSBpcyBhIGRpcmVjdCBkZXNjZW5kYW50IG9mIGIgb3IgdmljZSB2ZXJzYVxuICAgICAgICAgICAgaWYgKGEuY29udGFpbnMgJiYgYS5jb250YWlucyhiKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIuY29udGFpbnMgJiYgYi5jb250YWlucyhhKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGFkZXB0aCA9IHRoaXMuZGVwdGgoYSk7XG4gICAgICAgICAgICB2YXIgYmRlcHRoID0gdGhpcy5kZXB0aChiKTtcbiAgICAgICAgICAgIHZhciBkID0gYWRlcHRoIC0gYmRlcHRoO1xuICAgICAgICAgICAgaWYgKGQgPj0gMCkge1xuICAgICAgICAgICAgICAgIGEgPSB0aGlzLndhbGsoYSwgZCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGIgPSB0aGlzLndhbGsoYiwgLWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2hpbGUgKGEgJiYgYiAmJiBhICE9PSBiKSB7XG4gICAgICAgICAgICAgICAgYSA9IGEucGFyZW50Tm9kZSB8fCBhLmhvc3Q7XG4gICAgICAgICAgICAgICAgYiA9IGIucGFyZW50Tm9kZSB8fCBiLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgfSxcbiAgICAgICAgd2FsazogZnVuY3Rpb24obiwgdSkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IG4gJiYgKGkgPCB1KTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbiA9IG4ucGFyZW50Tm9kZSB8fCBuLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbjtcbiAgICAgICAgfSxcbiAgICAgICAgZGVwdGg6IGZ1bmN0aW9uKG4pIHtcbiAgICAgICAgICAgIHZhciBkID0gMDtcbiAgICAgICAgICAgIHdoaWxlIChuKSB7XG4gICAgICAgICAgICAgICAgZCsrO1xuICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGQ7XG4gICAgICAgIH0sXG4gICAgICAgIGRlZXBDb250YWluczogZnVuY3Rpb24oYSwgYikge1xuICAgICAgICAgICAgdmFyIGNvbW1vbiA9IHRoaXMuTENBKGEsIGIpO1xuICAgICAgICAgICAgLy8gaWYgYSBpcyB0aGUgY29tbW9uIGFuY2VzdG9yLCBpdCBtdXN0IFwiZGVlcGx5XCIgY29udGFpbiBiXG4gICAgICAgICAgICByZXR1cm4gY29tbW9uID09PSBhO1xuICAgICAgICB9LFxuICAgICAgICBpbnNpZGVOb2RlOiBmdW5jdGlvbihub2RlLCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgcmVjdCA9IG5vZGUuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7XG4gICAgICAgICAgICByZXR1cm4gKHJlY3QubGVmdCA8PSB4KSAmJiAoeCA8PSByZWN0LnJpZ2h0KSAmJiAocmVjdC50b3AgPD0geSkgJiYgKHkgPD0gcmVjdC5ib3R0b20pO1xuICAgICAgICB9LFxuICAgICAgICBwYXRoOiBmdW5jdGlvbihldmVudCkge1xuICAgICAgICAgICAgdmFyIHA7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgZXZlbnQucGF0aCAmJiBldmVudC5wYXRoLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHAgPSBldmVudC5wYXRoO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwID0gW107XG4gICAgICAgICAgICAgICAgdmFyIG4gPSB0aGlzLmZpbmRUYXJnZXQoZXZlbnQpO1xuICAgICAgICAgICAgICAgIHdoaWxlIChuKSB7XG4gICAgICAgICAgIC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1wiXSc7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcnVsZSh2KSB7XG4gICAgICAgIHJldHVybiAneyAtbXMtdG91Y2gtYWN0aW9uOiAnICsgdiArICc7IHRvdWNoLWFjdGlvbjogJyArIHYgKyAnO30nO1xuICAgIH1cbiAgICB2YXIgYXR0cmliMmNzcyA9IFtcbiAgICAgICAgJ25vbmUnLFxuICAgICAgICAnYXV0bycsXG4gICAgICAgICdwYW4teCcsXG4gICAgICAgICdwYW4teScsIHtcbiAgICAgICAgICAgIHJ1bGU6ICdwYW4teCBwYW4teScsXG4gICAgICAgICAgICBzZWxlY3RvcnM6IFtcbiAgICAgICAgICAgICAgICAncGFuLXggcGFuLXknLFxuICAgICAgICAgICAgICAgICdwYW4teSBwYW4teCdcbiAgICAgICAgICAgIF1cbiAgICAgICAgfSxcbiAgICAgICAgJ21hbmlwdWxhdGlvbidcbiAgICBdO1xuICAgIHZhciBzdHlsZXMgPSAnJztcbiAgICAvLyBvbmx5IGluc3RhbGwgc3R5bGVzaGVldCBpZiB0aGUgYnJvd3NlciBoYXMgdG91Y2ggYWN0aW9uIHN1cHBvcnRcbiAgICB2YXIgaGFzVG91Y2hBY3Rpb24gPSB0eXBlb2YgZG9jdW1lbnQuaGVhZC5zdHlsZS50b3VjaEFjdGlvbiA9PT0gJ3N0cmluZyc7XG4gICAgLy8gb25seSBhZGQgc2hhZG93IHNlbGVjdG9ycyBpZiBzaGFkb3dkb20gaXMgc3VwcG9ydGVkXG4gICAgdmFyIGhhc1NoYWRvd1Jvb3QgPSAhd2luZG93LlNoYWRvd0RPTVBvbHlmaWxsICYmIGRvY3VtZW50LmhlYWQuY3JlYXRlU2hhZG93Um9vdDtcblxuICAgIGlmIChoYXNUb3VjaEFjdGlvbikge1xuICAgICAgICBhdHRyaWIyY3NzLmZvckVhY2goZnVuY3Rpb24ocikge1xuICAgICAgICAgICAgaWYgKFN0cmluZyhyKSA9PT0gcikge1xuICAgICAgICAgICAgICAgIHN0eWxlcyArPSBzZWxlY3RvcihyKSArIHJ1bGUocikgKyAnXFxuJztcbiAgICAgICAgICAgICAgICBpZiAoaGFzU2hhZG93Um9vdCkge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZXMgKz0gc2hhZG93U2VsZWN0b3IocikgKyBydWxlKHIpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHlsZXMgKz0gci5zZWxlY3RvcnMubWFwKHNlbGVjdG9yKSArIHJ1bGUoci5ydWxlKSArICdcXG4nO1xuICAgICAgICAgICAgICAgIGlmIChoYXNTaGFkb3dSb290KSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlcyArPSByLnNlbGVjdG9ycy5tYXAoc2hhZG93U2VsZWN0b3IpICsgcnVsZShyLnJ1bGUpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICB2YXIgZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzdHlsZScpO1xuICAgICAgICBlbC50ZXh0Q29udGVudCA9IHN0eWxlcztcbiAgICAgICAgZG9jdW1lbnQuaGVhZC5hcHBlbmRDaGlsZChlbCk7XG4gICAgfVxufSkoKTtcblxuLyoqXG4gKiBUaGlzIGlzIHRoZSBjb25zdHJ1Y3RvciBmb3IgbmV3IFBvaW50ZXJFdmVudHMuXG4gKlxuICogTmV3IFBvaW50ZXIgRXZlbnRzIG11c3QgYmUgZ2l2ZW4gYSB0eXBlLCBhbmQgYW4gb3B0aW9uYWwgZGljdGlvbmFyeSBvZlxuICogaW5pdGlhbGl6YXRpb24gcHJvcGVydGllcy5cbiAqXG4gKiBEdWUgdG8gY2VydGFpbiBwbGF0Zm9ybSByZXF1aXJlbWVudHMsIGV2ZW50cyByZXR1cm5lZCBmcm9tIHRoZSBjb25zdHJ1Y3RvclxuICogaWRlbnRpZnkgYXMgTW91c2VFdmVudHMuXG4gKlxuICogQGNvbnN0cnVjdG9yXG4gKiBAcGFyYW0ge1N0cmluZ30gaW5UeXBlIFRoZSB0eXBlIG9mIHRoZSBldmVudCB0byBjcmVhdGUuXG4gKiBAcGFyYW0ge09iamVjdH0gW2luRGljdF0gQW4gb3B0aW9uYWwgZGljdGlvbmFyeSBvZiBpbml0aWFsIGV2ZW50IHByb3BlcnRpZXMuXG4gKiBAcmV0dXJuIHtFdmVudH0gQSBuZXcgUG9pbnRlckV2ZW50IG9mIHR5cGUgYGluVHlwZWAgYW5kIGluaXRpYWxpemVkIHdpdGggcHJvcGVydGllcyBmcm9tIGBpbkRpY3RgLlxuICovXG4oZnVuY3Rpb24oc2NvcGUpIHtcblxuICAgIHZhciBNT1VTRV9QUk9QUyA9IFtcbiAgICAgICAgJ2J1YmJsZXMnLFxuICAgICAgICAnY2FuY2VsYWJsZScsXG4gICAgICAgICd2aWV3JyxcbiAgICAgICAgJ2RldGFpbCcsXG4gICAgICAgICdzY3JlZW5YJyxcbiAgICAgICAgJ3NjcmVlblknLFxuICAgICAgICAnY2xpZW50WCcsXG4gICAgICAgICdjbGllbnRZJyxcbiAgICAgICAgJ2N0cmxLZXknLFxuICAgICAgICAnYWx0S2V5JyxcbiAgICAgICAgJ3NoaWZ0S2V5JyxcbiAgICAgICAgJ21ldGFLZXknLFxuICAgICAgICAnYnV0dG9uJyxcbiAgICAgICAgJ3JlbGF0ZWRUYXJnZXQnLFxuICAgICAgICAncGFnZVgnLFxuICAgICAgICAncGFnZVknXG4gICAgXTtcblxuICAgIHZhciBNT1VTRV9ERUZBVUxUUyA9IFtcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBudWxsLFxuICAgICAgICBudWxsLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZ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lzW2ldO1xuICAgICAgICAgICAgICAgIGlmIChrICE9PSAnYnViYmxlcycgJiYgayAhPT0gJ2NhbmNlbGFibGUnKSB7XG4gICAgICAgICAgICAgICAgICAgIGVba10gPSBpbkRpY3Rba107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIG1ha2VQb2ludGVyRXZlbnQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5EaWN0KSB7XG4gICAgICAgICAgICBpbkRpY3QgPSBpbkRpY3QgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTtcblxuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLm1ha2VCYXNlRXZlbnQoaW5UeXBlLCBpbkRpY3QpO1xuICAgICAgICAgICAgLy8gZGVmaW5lIGluaGVyaXRlZCBNb3VzZUV2ZW50IHByb3BlcnRpZXNcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAyLCBwOyBpIDwgTU9VU0VfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gTU9VU0VfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZVtwXSA9IGluRGljdFtwXSB8fCBNT1VTRV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGUuYnV0dG9ucyA9IGluRGljdC5idXR0b25zIHx8IDA7XG5cbiAgICAgICAgICAgIC8vIFNwZWMgcmVxdWlyZXMgdGhhdCBwb2ludGVycyB3aXRob3V0IHByZXNzdXJlIHNwZWNpZmllZCB1c2UgMC41IGZvciBkb3duXG4gICAgICAgICAgICAvLyBzdGF0ZSBhbmQgMCBmb3IgdXAgc3RhdGUuXG4gICAgICAgICAgICB2YXIgcHJlc3N1cmUgPSAwO1xuICAgICAgICAgICAgaWYgKGluRGljdC5wcmVzc3VyZSkge1xuICAgICAgICAgICAgICAgIHByZXNzdXJlID0gaW5EaWN0LnByZXNzdXJlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwcmVzc3VyZSA9IGUuYnV0dG9ucyA/IDAuNSA6IDA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIGFkZCB4L3kgcHJvcGVydGllcyBhbGlhc2VkIHRvIGNsaWVudFgvWVxuICAgICAgICAgICAgZS54ID0gZS5jbGllbnRYO1xuICAgICAgICAgICAgZS55ID0gZS5jbGllbnRZO1xuXG4gICAgICAgICAgICAvLyBkZWZpbmUgdGhlIHByb3BlcnRpZXMgb2YgdGhlIFBvaW50ZXJFdmVudCBpbnRlcmZhY2VcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gaW5EaWN0LnBvaW50ZXJJZCB8fCAwO1xuICAgICAgICAgICAgZS53aWR0aCA9IGluRGljdC53aWR0aCB8fCAwO1xuICAgICAgICAgICAgZS5oZWlnaHQgPSBpbkRpY3QuaGVpZ2h0IHx8IDA7XG4gICAgICAgICAgICBlLnByZXNzdXJlID0gcHJlc3N1cmU7XG4gICAgICAgICAgICBlLnRpbHRYID0gaW5EaWN0LnRpbHRYIHx8IDA7XG4gICAgICAgICAgICBlLnRpbHRZID0gaW5EaWN0LnRpbHRZIHx8IDA7XG4gICAgICAgICAgICBlLnBvaW50ZXJUeXBlID0gaW5EaWN0LnBvaW50ZXJUeXBlIHx8ICcnO1xuICAgICAgICAgICAgZS5od1RpbWVzdGFtcCA9IGluRGljdC5od1RpbWVzdGFtcCB8fCAwO1xuICAgICAgICAgICAgZS5pc1ByaW1hcnkgPSBpbkRpY3QuaXNQcmltYXJ5IHx8IGZhbHNlO1xuICAgICAgICAgICAgZS5fc291cmNlID0gaW5EaWN0Ll9zb3VyY2UgfHwgJyc7XG4gICAgICAgICAgICByZXR1cm4gZTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBzY29wZS5ldmVudEZhY3RvcnkgPSBldmVudEZhY3Rvcnk7XG59KShleHBvcnRzKTtcblxuLyoqXG4gKiBUaGlzIG1vZHVsZSBpbXBsZW1lbnRzIGFuIG1hcCBvZiBwb2ludGVyIHN0YXRlc1xuICovXG4oZnVuY3Rpb24oc2NvcGUpIHtcbiAgICB2YXIgVVNFX01BUCA9IHdpbmRvdy5NYXAgJiYgd2luZG93Lk1hcC5wcm90b3R5cGUuZm9yRWFjaDtcbiAgICB2YXIgUE9JTlRFUlNfRk4gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc2l6ZTtcbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gUG9pbnRlck1hcCgpIHtcbiAgICAgICAgaWYgKFVTRV9NQVApIHtcbiAgICAgICAgICAgIHZhciBtID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgbS5wb2ludGVycyA9IFBPSU5URVJTX0ZOO1xuICAgICAgICAgICAgcmV0dXJuIG07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmtleXMgPSBbXTtcbiAgICAgICAgICAgIHRoaXMudmFsdWVzID0gW107XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBQb2ludGVyTWFwLnByb3RvdHlwZSA9IHtcbiAgICAgICAgc2V0OiBmdW5jdGlvbihpbklkLCBpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgaSA9IHRoaXMua2V5cy5pbmRleE9mKGluSWQpO1xuICAgICAgICAgICAgaWYgKGkgPiAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMudmFsdWVzW2ldID0gaW5FdmVudDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5rZXlzLnB1c2goaW5JZCk7XG4gICAgICAgICAgICAgICAgdGhpcy52YWx1ZXMucHVzaChpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgaGFzOiBmdW5jdGlvbihpbklkKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCk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cnRzKTtcblxuKGZ1bmN0aW9uKHNjb3BlKSB7XG4gICAgdmFyIENMT05FX1BST1BTID0gW1xuICAgICAgICAvLyBNb3VzZUV2ZW50XG4gICAgICAgICdidWJibGVzJyxcbiAgICAgICAgJ2NhbmNlbGFibGUnLFxuICAgICAgICAndmlldycsXG4gICAgICAgICdkZXRhaWwnLFxuICAgICAgICAnc2NyZWVuWCcsXG4gICAgICAgICdzY3JlZW5ZJyxcbiAgICAgICAgJ2NsaWVudFgnLFxuICAgICAgICAnY2xpZW50WScsXG4gICAgICAgICdjdHJsS2V5JyxcbiAgICAgICAgJ2FsdEtleScsXG4gICAgICAgICdzaGlmdEtleScsXG4gICAgICAgICdtZXRhS2V5JyxcbiAgICAgICAgJ2J1dHRvbicsXG4gICAgICAgICdyZWxhdGVkVGFyZ2V0JyxcbiAgICAgICAgLy8gRE9NIExldmVsIDNcbiAgICAgICAgJ2J1dHRvbnMnLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgJ3BvaW50ZXJJZCcsXG4gICAgICAgICd3aWR0aCcsXG4gICAgICAgICdoZWlnaHQnLFxuICAgICAgICAncHJlc3N1cmUnLFxuICAgICAgICAndGlsdFgnLFxuICAgICAgICAndGlsdFknLFxuICAgICAgICAncG9pbnRlclR5cGUnLFxuICAgICAgICAnaHdUaW1lc3RhbXAnLFxuICAgICAgICAnaXNQcmltYXJ5JyxcbiAgICAgICAgLy8gZXZlbnQgaW5zdGFuY2VcbiAgICAgICAgJ3R5cGUnLFxuICAgICAgICAndGFyZ2V0JyxcbiAgICAgICAgJ2N1cnJlbnRUYXJnZXQnLFxuICAgICAgICAnd2hpY2gnLFxuICAgICAgICAncGFnZVgnLFxuICAgICAgICAncGFnZVknLFxuICAgICAgICAndGltZVN0YW1wJyxcbiAgICAgICAgLy8gZ2VzdHVyZSBhZGRvbnNcbiAgICAgICAgJ3ByZXZlbnRUYXAnLFxuICAgICAgICAndGFwUHJldmVudGVkJyxcbiAgICAgICAgJ19zb3VyY2UnXG4gICAgXTtcblxuICAgIHZhciBDTE9ORV9ERUZBVUxUUyA9IFtcbiAgICAgICAgLy8gTW91c2VFdmVudFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIG51bGwsXG4gICAgICAgIG51bGwsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAwLFxuICAgICAgICBudWxsLFxuICAgICAgICAvLyBET00gTGV2ZWwgM1xuICAgICAgICAwLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgJycsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAvLyBldmVudCBpbnN0YW5jZVxuICAgICAgICAnJyxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgZnVuY3Rpb24oKSB7fSxcbiAgICAgICAgZmFsc2VcbiAgICBdO1xuXG4gICAgdmFyIEhBU19TVkdfSU5TVEFOQ0UgPSAodHlwZW9mIFNWR0VsZW1lbnRJbnN0YW5jZSAhPT0gJ3VuZGVmaW5lZCcpO1xuXG4gICAgdmFyIGV2ZW50RmFjdG9yeSA9IHNjb3BlLmV2ZW50RmFjdG9yeTtcblxuICAgIC8vIHNldCBvZiByZWNvZ25pemVycyB0byBydW4gZm9yIHRoZSBjdXJyZW50bHkgaGFuZGxlZCBldmVudFxuICAgIHZhciBjdXJyZW50R2VzdHVyZXM7XG5cbiAgICAvKipcbiAgICAgKiBUaGlzIG1vZHVsZ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cbiAgICAgICAgICovXG4gICAgICAgIHJlZ2lzdGVyU291cmNlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBzID0gc291cmNlO1xuICAgICAgICAgICAgdmFyIG5ld0V2ZW50cyA9IHMuZXZlbnRzO1xuICAgICAgICAgICAgaWYgKG5ld0V2ZW50cykge1xuICAgICAgICAgICAgICAgIG5ld0V2ZW50cy5mb3JFYWNoKGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNbZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXZlbnRNYXBbZV0gPSBzW2VdLmJpbmQocyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgICAgICAgICB0aGlzLmV2ZW50U291cmNlc1tuYW1lXSA9IHM7XG4gICAgICAgICAgICAgICAgdGhpcy5ldmVudFNvdXJjZUxpc3QucHVzaChzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXJHZXN0dXJlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgb2JqLmxpc3RlbmVycyA9IDA7XG4gICAgICAgICAgICBvYmouaW5kZXggPSB0aGlzLmdlc3R1cmVzLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBnOyBpIDwgc291cmNlLmV4cG9zZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBnID0gc291cmNlLmV4cG9zZXNbaV0udG9Mb3dlckNhc2UoKTtcbiAgICAgICAgICAgICAgICB0aGlzLmRlcGVuZGVuY3lNYXBbZ10gPSBvYmo7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmdlc3R1cmVzLnB1c2goc291cmNlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQsIGluaXRpYWwpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMucmVnaXN0ZXIuY2FsbChlcywgZWxlbWVudCwgaW5pdGlhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVucmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMudW5yZWdpc3Rlci5jYWxsKGVzLCBlbGVtZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gRVZFTlRTXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5zZXQoaW5FdmVudC5wb2ludGVySWQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgnZG93bicsIGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBtb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBwaXBlIG1vdmUgZXZlbnRzIGludG8gZ2VzdHVyZSBxdWV1ZSBkaXJlY3RseVxuICAgICAgICAgICAgaW5FdmVudC50eXBlID0gJ21vdmUnO1xuICAgICAgICAgICAgdGhpcy5maWxsR2VzdHVyZVF1ZXVlKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdGhpcy5maXJlRXZlbnQoJ3VwJywgaW5FdmVudCk7XG4gICAgICAgICAgICB0aGlzLnJlcXVpcmVkR2VzdHVyZXMuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpbkV2ZW50LnRhcFByZXZlbnRlZCA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgndXAnLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBhZGRHZXN0dXJlRGVwZW5kZW5jeTogZnVuY3Rpb24obm9kZSwgY3VycmVudEdlc3R1cmVzKSB7XG4gICAgICAgICAgICB2YXIgZ2VzdHVyZXNXYW50ZWQgPSBub2RlLl9wZ0V2ZW50cztcbiAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZCAmJiBjdXJyZW50R2VzdHVyZXMpIHtcbiAgICAgICAgICAgICAgICB2YXIgZ2sgPSBPYmplY3Qua2V5cyhnZXN0dXJlc1dhbnRlZCk7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIHIsIHJpLCBnOyBpIDwgZ2subGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZ2VzdHVyZVxuICAgICAgICAgICAgICAgICAgICBnID0gZ2tbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZFtnXSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb2t1cCBnZXN0dXJlIHJlY29nbml6ZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIHIgPSB0aGlzLmRlcGVuZGVuY3lNYXBbZ107XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyByZWNvZ25pemVyIGluZGV4XG4gICAgICAgICAgICAgICAgICAgICAgICByaSA9IHIgPyByLmluZGV4IDogLTE7XG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXNbcmldID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gTElTVEVORVIgTE9HSUNcbiAgICAgICAgZXZlbnRIYW5kbGVyOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBUaGlzIGlzIHVzZWQgdG8gcHJldmVudCBtdWx0aXBsZSBkaXNwYXRjaCBvZiBldmVudHMgZnJvbVxuICAgICAgICAgICAgLy8gcGxhdGZvcm0gZXZlbnRzLiBUaGlzIGNhbiBoYXBwZW4gd2hlbiB0d28gZWxlbWVudHMgaW4gZGlmZmVyZW50IHNjb3Blc1xuICAgICAgICAgICAgLy8gYXJlIHNldCB1cCB0byBjcmVhdGUgcG9pbnRlciBldmVudHMsIHdoaWNoIGlzIHJlbGV2YW50IHRvIFNoYWRvdyBET00uXG5cbiAgICAgICAgICAgIHZhciB0eXBlID0gaW5FdmVudC50eXBlO1xuXG4gICAgICAgICAgICAvLyBvbmx5IGdlbmVyYXRlIHRoZSBsaXN0IG9mIGRlc2lyZWQgZXZlbnRzIG9uIFwiZG93blwiXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICdtb3VzZWRvd24nIHx8IHR5cGUgPT09ICdwb2ludGVyZG93bicgfHwgdHlwZSA9PT0gJ01TUG9pbnRlckRvd24nKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFpbkV2ZW50Ll9oYW5kbGVkQnlQRykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXMgPSB7fTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBpbiBJT1MgbW9kZSwgdGhlcmUgaXMgb25seSBhIGxpc3RlbmVyIG9uIHRoZSBkb2N1bWVudCwgc28gdGhpcyBpcyBub3QgcmUtZW50cmFudFxuICAgICAgICAgICAgICAgIGlmICh0aGlzLklTX0lPUykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZXYgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3QgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2V0IHVwIGEgZmFrZSBldmVudCB0byBnaXZlIHRvIHRoZSBwYXRoIGJ1aWxkZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaW5FdmVudC50YXJnZXQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WDogY3QuY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiBjdC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IGluRXZlbnQucGF0aFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAvLyB1c2UgZXZlbnQgcGF0aCBpZiBhdmFpbGFibGUsIG90aGVyd2lzZSBidWlsZCBhIHBhdGggZnJvbSB0YXJnZXQgZmluZGluZ1xuICAgICAgICAgICAgICAgICAgICB2YXIgbm9kZXMgPSBpbkV2ZW50LnBhdGggfHwgc2NvcGUudGFyZ2V0RmluZGluZy5wYXRoKGV2KTtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIG47IGkgPCBub2Rlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbiA9IG5vZGVzW2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShuLCBjdXJyZW50R2VzdHVyZXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShpbkV2ZW50LmN1cnJlbnRUYXJnZXQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoaW5FdmVudC5faGFuZGxlZEJ5UEcpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZm4gPSB0aGlzLmV2ZW50TWFwICYmIHRoaXMuZXZlbnRNYXBbdHlwZV07XG4gICAgICAgICAgICBpZiAoZm4pIHtcbiAgICAgICAgICAgICAgICBmbihpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGluRXZlbnQuX2hhbmRsZWRCeVBHID0gdHJ1ZTtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gc2V0IHVwIGV2ZW50IGxpc3RlbmVyc1xuICAgICAgICBsaXN0ZW46IGZ1bmN0aW9uKHRhcmdldCwgZXZlbnRzKSB7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IGV2ZW50cy5sZW5ndGgsIGU7XG4gICAgICAgICAgICAgICAgKGkgPCBsKSAmJiAoZSA9IGV2ZW50c1tpXSk7IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuYWRkRXZlbnQodGFyZ2V0LCBlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gcmVtb3ZlIGV2ZW50IGxpc3RlbmVyc1xuICAgICAgICB1bmxpc3RlbjogZnVuY3Rpb24odGFyZ2V0LCBldmVudHMpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsID0gZXZlbnRzLmxlbmd0aCwgZTtcbiAgICAgICAgICAgICAgICAoaSA8IGwpICYmIChlID0gZXZlbnRzW2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVFdmVudCh0YXJnZXQsIGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBhZGRFdmVudDogZnVuY3Rpb24odGFyZ2V0LCBldmVudE5hbWUpIHtcbiAgICAgICAgICAgIHRhcmdldC5hZGRFdmVudExpc3RlbmVyKGV2ZW50TmFtZSwgdGhpcy5ib3VuZEhhbmRsZXIpO1xuICAgICAgICB9LFxuICAgICAgICByZW1vdmVFdmVudDogZnVuY3Rpb24odGFyZ2V0LCBldmVudE5hbWUpIHtcbiAgICAgICAgICAgIHRhcmdldC5yZW1vdmVFdmVudExpc3RlbmVyKGV2ZW50TmFtZSwgdGhpcy5ib3VuZEhhbmRsZXIpO1xuICAgICAgICB9LFxuICAgICAgICAvLyBFVkVOVCBDUkVBVElPTiBBTkQgVFJBQ0tJTkdcbiAgICAgICAgLyoqXG4gICAgICAgICAqIENyZWF0ZXMgYSBuZXcgRXZlbnQgb2YgdHlwZSBgaW5UeXBlYCwgYmFzZWQgb24gdGhlIGluZm9ybWF0aW9uIGluXG4gICAgICAgICAqIGBpbkV2ZW50YC5cbiAgICAgICAgICpcbiAgICAgICAgICog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FtIHtFdmVudH0gaW5FdmVudCBBbiBldmVudCB0aGF0IGNvbnRhaW5zIHByb3BlcnRpZXMgdG8gY29weS5cbiAgICAgICAgICogQHJldHVybiB7T2JqZWN0fSBBbiBvYmplY3QgY29udGFpbmluZyBzaGFsbG93IGNvcGllcyBvZiBgaW5FdmVudGAnc1xuICAgICAgICAgKiAgICBwcm9wZXJ0aWVzLlxuICAgICAgICAgKi9cbiAgICAgICAgY2xvbmVFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGV2ZW50Q29weSA9IE9iamVjdC5jcmVhdGUobnVsbCksXG4gICAgICAgICAgICAgICAgcDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgQ0xPTkVfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gQ0xPTkVfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZXZlbnRDb3B5W3BdID0gaW5FdmVudFtwXSB8fCBDTE9ORV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgICAgICAvLyBXb3JrIGFyb3VuZCBTVkdJbnN0YW5jZUVsZW1lbnQgc2hhZG93IHRyZWVcbiAgICAgICAgICAgICAgICAvLyBSZXR1cm4gdGhlIDx1c2U+IGVsZW1lbnQgdGhhdCBpcyByZXByZXNlbnRlZCBieSB0aGUgaW5zdGFuY2UgZm9yIFNhZmFyaSwgQ2hyb21lLCBJRS5cbiAgICAgICAgICAgICAgICAvLyBUaGlzIGlzIHRoZSBiZWhhdmlvciBpbXBsZW1lbnRlZCBieSBGaXJlZm94LlxuICAgICAgICAgICAgICAgIGlmIChwID09PSAndGFyZ2V0JyB8fCBwID09PSAncmVsYXRlZFRhcmdldCcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKEhBU19TVkdfSU5TVEFOQ0UgJiYgZXZlbnRDb3B5W3BdIGluc3RhbmNlb2YgU1ZHRWxlbWVudEluc3RhbmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudENvcHlbcF0gPSBldmVudENvcHlbcF0uY29ycmVzcG9uZGluZ1VzZUVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBrZWVwIHRoZSBzZW1hbnRpY3Mgb2YgcHJldmVudERlZmF1bHRcbiAgICAgICAgICAgIGV2ZW50Q29weS5wcmV2ZW50RGVmYXVsdCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGluRXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4gZXZlbnRDb3B5O1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogRGlzcGF0Y2hlcyB0aGUgZXZlbnQgdG8gaXRzIHRhcmdldC5cbiAgICAgICAgICpcbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gaW5FdmVudCBUaGUgZXZlbnQgdG8gYmUgZGlzcGF0Y2hlZC5cbiAgICAgICAgICogQHJldHVybiB7Qm9vbGVhbn0gVHJ1ZSBpZiBhbiBldmVudCBoYW5kbGVyIHJldHVybnMgdHJ1ZSwgZmFsc2Ugb3RoZXJ3aXNlLlxuICAgICAgICAgKi9cbiAgICAgICAgZGlzcGF0Y2hFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50Ll90YXJnZXQ7XG4gICAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgICAgIHQuZGlzcGF0Y2hFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICAvLyBjbG9uZSB0aGUgZXZlbnQgZm9yIHRoZSBnZXN0dXJlIHN5c3RlbSB0byBwcm9jZXNzXG4gICAgICAgICAgICAgICAgLy8gY2xvbmUgYWZ0ZXIgZGlzcGF0Y2ggdG8gcGljayB1cCBnZXN0dXJlIHByZXZlbnRpb24gY29kZVxuICAgICAgICAgICAgICAgIHZhciBjbG9uZSA9IHRoaXMuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBjbG9uZS50YXJnZXQgPSB0O1xuICAgICAgICAgICAgICAgIHRoaXMuZmlsbEdlc3R1cmVRdWV1ZShjbG9uZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGdlc3R1cmVUcmlnZ2VyOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIC8vIHByb2Nlc3MgdGhlIGdlc3R1cmUgcXVldWVcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBlLCByZzsgaSA8IHRoaXMuZ2VzdHVyZVF1ZXVlLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgZSA9IHRoaXMuZ2VzdHVyZVF1ZXVlW2ldO1xuICAgICAgICAgICAgICAgIHJnID0gZS5fcmVxdWlyZWRHZXN0dXJlcztcbiAgICAgICAgICAgICAgICBpZiAocmcpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGcsIGZuOyBqIDwgdGhpcy5nZXN0dXJlcy5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gb25seSBydW4gcmVjb2duaXplciBpZiBhbiBlbGVtZW50IGluIHRoZSBzb3VyY2UgZXZlbnQncyBwYXRoIGlzIGxpc3RlbmluZyBmb3IgdGhvc2UgZ2VzdHVyZXNcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZ1tqXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGcgPSB0aGlzLmdlc3R1cmVzW2pdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuID0gZ1tlLnR5cGVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbi5jYWxsKGcsIGUpO1xuICA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2l0Y2ggKG5vZGUubm9kZVR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBOb2RlLkVMRU1FTlRfTk9ERTpcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbk5vZGUgPSBub2RlO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgTm9kZS5ET0NVTUVOVF9GUkFHTUVOVF9OT0RFOlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG5vZGUuaG9zdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRvdWNoQWN0aW9uICYmIGFjdGlvbk5vZGUgJiYgIWFjdGlvbk5vZGUuaGFzQXR0cmlidXRlKCd0b3VjaC1hY3Rpb24nKSkge1xuICAgICAgICAgICAgICAgICAgICBhY3Rpb25Ob2RlLnNldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJywgdG91Y2hBY3Rpb24pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghbm9kZS5fcGdFdmVudHMpIHtcbiAgICAgICAgICAgICAgICBub2RlLl9wZ0V2ZW50cyA9IHt9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbm9kZS5fcGdFdmVudHNbZ10gPSAobm9kZS5fcGdFdmVudHNbZ10gfHwgMCkgKyAxO1xuICAgICAgICAgICAgbm9kZS5fcGdMaXN0ZW5lcnMrKztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gQm9vbGVhbihkZXApO1xuICAgIH07XG5cbiAgICAvKipcbiAgICAgKlxuICAgICAqIExpc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PSBnZXN0dXJlLnRvTG93ZXJDYXNlKCk7XG4gICAgICAgIHZhciBkZXAgPSBkaXNwYXRjaGVyLmRlcGVuZGVuY3lNYXBbZ107XG4gICAgICAgIGlmIChkZXApIHtcbiAgICAgICAgICAgIGlmIChub2RlLl9wZ0xpc3RlbmVycyA+IDApIHtcbiAgICAgICAgICAgICAgICBub2RlLl9wZ0xpc3RlbmVycy0tO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG5vZGUuX3BnTGlzdGVuZXJzID09PSAwKSB7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci51bnJlZ2lzdGVyKG5vZGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG5vZGUuX3BnRXZlbnRzKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5vZGUuX3BnRXZlbnRzW2ddID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBub2RlLl9wZ0V2ZW50c1tnXS0tO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGUuX3BnRXZlbnRzW2ddID0gMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIEJvb2xlYW4oZGVwKTtcbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogU3RvcCBsaXN0ZW5pbmcgZm9yIGBnZXN0dXJlYCBmcm9tIGBub2RlYCB3aXRoIGBoYW5kbGVyYCBmdW5jdGlvbi5cbiAgICAgKlxuICAgICAqIEBwYXJhbSB7RWxlbWVudH0gbm9kZVxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSBnZXN0dXJlXG4gICAgICogQHBhcmFtIHtGdW5jdGlvbn0gaGFuZGxlclxuICAgICAqIEBwYXJhbSB7Qm9vbGVhbn0gY2FwdHVyZVxuICAgICAqL1xuICAgIHNjb3BlLnJlbW92ZUV2ZW50TGlzdGVuZXIgPSBmdW5jdGlvbihub2R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c3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBNb3VzZUV2ZW50KCd0ZXN0Jywge1xuICAgICAgICAgICAgICAgIGJ1dHRvbnM6IDFcbiAgICAgICAgICAgIH0pLmJ1dHRvbnMgPT09IDE7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgIH0pKCk7XG5cbiAgICAvLyBoYW5kbGVyIGJsb2NrIGZvciBuYXRpdmUgbW91c2UgZXZlbnRzXG4gICAgdmFyIG1vdXNlRXZlbnRzID0ge1xuICAgICAgICBQT0lOVEVSX0lEOiAxLFxuICAgICAgICBQT0lOVEVSX1RZUEU6ICdtb3VzZScsXG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ21vdXNlZG93bicsXG4gICAgICAgICAgICAnbW91c2Vtb3ZlJyxcbiAgICAgICAgICAgICdtb3VzZXVwJ1xuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICAgICAgJ21vdmUnXG4gICAgICAgIF0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGxhc3RUb3VjaGVzOiBbXSxcbiAgICAgICAgLy8gY29sbGlkZSB3aXRoIHRoZSBnbG9iYWwgbW91c2UgbGlzdGVuZXJcbiAgICAgICAgaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGx0cyA9IHRoaXMubGFzdFRvdWNoZXM7XG4gICAgICAgICAgICB2YXIgeCA9IGluRXZlbnQuY2xpZW50WCxcbiAgICAgICAgICAgICAgICB5ID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBsdHMubGVuZ3RoLCB0OyBpIDwgbCAmJiAodCA9IGx0c1tpXSk7IGkrKykge1xuICAgICAgICAgICAgICAgIC8vIHNpbXVsYXRlZCBtb3VzZSBldmVudHMgd2lsbCBiZSBzd2FsbG93ZWQgbmVhciBhIHByaW1hcnkgdG91Y2hlbmRcbiAgICAgICAgICAgICAgICB2YXIgZHggPSBNYXRoLmFicyh4IC0gdC54KSxcbiAgICAgICAgICAgICAgICAgICAgZHkgPSBNYXRoLmFicyh5IC0gdC55KTtcbiAgICAgICAgICAgICAgICBpZiAoZHggPD0gREVEVVBfRElTVCAmJiBkeSA8PSBERURVUF9ESVNUKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gdGhpcy5QT0lOVEVSX0lEO1xuICAgICAgICAgICAgZS5pc1ByaW1hcnkgPSB0cnVlO1xuICAgICAgICAgICAgZS5wb2ludGVyVHlwZSA9IHRoaXMuUE9JTlRFUl9UWVBFO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ21vdXNlJztcbiAgICAgICAgICAgIGlmICghSEFTX0JVVFRPTlMpIHtcbiAgICAgICAgICAgICAgICB2YXIgdHlwZSA9IGluRXZlbnQudHlwZTtcbiAgICAgICAgICAgICAgICB2YXIgYml0ID0gV0hJQ0hfVE9fQlVUVE9OU1tpbkV2ZW50LndoaWNoXSB8fCAwO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlID09PSAnbW91c2Vkb3duJykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50QnV0dG9ucyB8PSBiaXQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09PSAnbW91c2V1cCcpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudEJ1dHRvbnMgJj0gfmJpdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZS5idXR0b25zID0gY3VycmVudEJ1dHRvbnM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZTtcbiAgICAgICAgfSxcbiAgICAgICAgbW91c2Vkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaChpbkV2ZW50KSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5oYXModGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldCh0aGlzLlBPSU5URVJfSUQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLmRvd24oZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdXNlbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQodGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gdGFyZ2V0O1xuICAgICAgICAgICAgICAgICAgICAvLyBoYW5kbGUgY2FzZSB3aGVyZSB3ZSBtaXNzZWQgYSBtb3VzZXVwXG4gICAgICAgICAgICAgICAgICAgIGlmICgoSEFTX0JVVFRPTlMgPyBlLmJ1dHRvbnMgOiBlLndoaWNoKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFIQVNfQlVUVE9OUykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRCdXR0b25zID0gZS5idXR0b25zID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIuY2FuY2VsKGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhbnVwTW91c2UoZS5idXR0b25zKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubW92ZShlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW91c2V1cDogZnVuY3Rpb24oaW5Fdm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ubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5JU19JT1MpIHtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLnVubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzY3JvbGxUeXBlczoge1xuICAgICAgICAgICAgRU1JVFRFUjogJ25vbmUnLFxuICAgICAgICAgICAgWFNDUk9MTEVSOiAncGFuLXgnLFxuICAgICAgICAgICAgWVNDUk9MTEVSOiAncGFuLXknLFxuICAgICAgICB9LFxuICAgICAgICB0b3VjaEFjdGlvblRvU2Nyb2xsVHlwZTogZnVuY3Rpb24odG91Y2hBY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciB0ID0gdG91Y2hBY3Rpb247XG4gICAgICAgICAgICB2YXIgc3QgPSB0aGlzLnNjcm9sbFR5cGVzO1xuICAgICAgICAgICAgaWYgKHQgPT09IHN0LkVNSVRURVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ25vbmUnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5YU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1gnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5ZU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1knO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1hZJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgUE9JTlRFUl9UWVBFOiAndG91Y2gnLFxuICAgICAgICBmaXJzdFRvdWNoOiBudWxsLFxuICAgICAgICBpc1ByaW1hcnlUb3VjaDogZnVuY3Rpb24oaW5Ub3VjaCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlyc3RUb3VjaCA9PT0gaW5Ub3VjaC5pZGVudGlmaWVyO1xuICAgICAgICB9LFxuICAgICAgICBzZXRQcmltYXJ5VG91Y2g6IGZ1bmN0aW9uKGluVG91Y2gpIHtcbiAgICAgICAgICAgIC8vIHNldCBwcmltYXJ5IHRvdWNoIGlmIHRoZXJlIG5vIHBvaW50ZXJzLCBvciB0aGUgb25seSBwb2ludGVyIGlzIHRoZSBtb3VzZVxuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAucG9pbnRlcnMoKSA9PT0gMCB8fCAocG9pbnRlcm1hcC5wb2ludGVycygpID09PSAxICYmIHBvaW50ZXJtYXAuaGFzKDEpKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyc3RUb3VjaCA9IGluVG91Y2guaWRlbnRpZmllcjtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSB7XG4gICAgICAgICAgICAgICAgICAgIFg6IGluVG91Y2guY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgWTogaW5Ub3VjaC5jbGllbnRZXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0VGFyZ2V0ID0gaW5Ub3VjaC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsUmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHJlbW92ZVByaW1hcnlQb2ludGVyOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGlmIChpblBvaW50ZXIuaXNQcmltYXJ5KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFRvdWNoID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNsaWNrQ291bnQ6IDAsXG4gICAgICAgIHJlc2V0SWQ6IG51bGwsXG4gICAgICAgIHJlc2V0Q2xpY2tDb3VudDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgZm4gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmNsaWNrQ291bnQgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRJZCA9IG51bGw7XG4gICAgICAgICAgICB9LmJpbmQodGhpcyk7XG4gICAgICAgICAgICB0aGlzLnJlc2V0SWQgPSBzZXRUaW1lb3V0KGZuLCBDTElDS19DT1VOVF9USU1FT1VUKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsUmVzZXRDbGlja0NvdW50OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlc2V0SWQpIHtcbiAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5yZXNldElkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdHlwZVRvQnV0dG9uczogZnVuY3Rpb24odHlwZSkge1xuICAgICAgICAgICAgdmFyIHJldCA9IDA7XG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICd0b3VjaG1vdmUnKSB7XG4gICAgICAgICAgICAgICAgcmV0ID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUYXJnZXQ6IGZ1bmN0aW9uKHRvdWNoLCBpZCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudFRvdWNoRXZlbnQudHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNQcmltYXJ5VG91Y2godG91Y2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmYXN0UGF0aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFg6IHRvdWNoLmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiB0b3VjaC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgcGF0aDogdGhpcy5jdXJyZW50VG91Y2hFdmVudC5wYXRoLFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiB0aGlzLmN1cnJlbnRUb3VjaEV2ZW50LnRhcmdldFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2NvcGUuZmluZFRhcmdldChmYXN0UGF0aCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjb3BlLmZpbmRUYXJnZXQodG91Y2gpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIHJldXNlIHRhcmdldCB3ZSBmb3VuZCBpbiB0b3VjaHN0YXJ0XG4gICAgICAgICAgICByZXR1cm4gcG9pbnRlcm1hcC5nZXQoaWQpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaFRvUG9pbnRlcjogZnVuY3Rpb24oaW5Ub3VjaCkge1xuICAgICAgICAgICAgdmFyIGN0ZSA9IHRoaXMuY3VycmVudFRvdWNoRXZlbnQ7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpblRvdWNoKTtcbiAgICAgICAgICAgIC8vIFNwZWMgc3BlY2lmaWVzIHRoYXQgcG9pbnRlcklkIDEgaXMgcmVzZXJ2ZWQgZm9yIE1vdXNlLlxuICAgICAgICAgICAgLy8gVG91Y2ggaWRlbnRpZmllcnMgY2FuIHN0YXJ0IGF0IDAuXG4g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bGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHNlbGYuZmlyc3RYWSA9IG51bGw7XG4gICAgICAgICAgICAgICAgY3RlLnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIHByb2Nlc3NUb3VjaGVzOiBmdW5jdGlvbihpbkV2ZW50LCBpbkZ1bmN0aW9uKSB7XG4gICAgICAgICAgICB2YXIgdGwgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzO1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50VG91Y2hFdmVudCA9IGluRXZlbnQ7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgdCwgcDsgaSA8IHRsLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdCA9IHRsW2ldO1xuICAgICAgICAgICAgICAgIHAgPSB0aGlzLnRvdWNoVG9Qb2ludGVyKHQpO1xuICAgICAgICAgICAgICAgIGlmIChpbkV2ZW50LnR5cGUgPT09ICd0b3VjaHN0YXJ0Jykge1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldChwLnBvaW50ZXJJZCwgcC50YXJnZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5oYXMocC5wb2ludGVySWQpKSB7XG4gICAgICAgICAgICAgICAgICAgIGluRnVuY3Rpb24uY2FsbCh0aGlzLCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGluRXZlbnQudHlwZSA9PT0gJ3RvdWNoZW5kJyB8fCBpbkV2ZW50Ll9jYW5jZWwpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhblVwUG9pbnRlcihwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIEZvciBzaW5nbGUgYXhpcyBzY3JvbGxlcnMsIGRldGVybWluZXMgd2hldGhlciB0aGUgZWxlbWVudCBzaG91bGQgZW1pdFxuICAgICAgICAvLyBwb2ludGVyIGV2ZW50cyBvciBiZWhhdmUgYXMgYSBzY3JvbGxlclxuICAgICAgICBzaG91bGRTY3JvbGw6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmV0O1xuICAgICAgICAgICAgICAgIHZhciB0b3VjaEFjdGlvbiA9IHNjb3BlLnRhcmdldEZpbmRpbmcuZmluZFRvdWNoQWN0aW9uKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIHZhciBzY3JvbGxBeGlzID0gdGhpcy50b3VjaEFjdGlvblRvU2Nyb2xsVHlwZSh0b3VjaEFjdGlvbik7XG4gICAgICAgICAgICAgICAgaWYgKHNjcm9sbEF4aXMgPT09ICdub25lJykge1xuICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIGVsZW1lbnQgaXMgYSB0b3VjaC1hY3Rpb246IG5vbmUsIHNob3VsZCBuZXZlciBzY3JvbGxcbiAgICAgICAgICAgICAgICAgICAgcmV0ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzY3JvbGxBeGlzID09PSAnWFknKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIHRoaXMgZWxlbWVudCBzaG91bGQgYWx3YXlzIHNjcm9sbFxuICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdGhlIGludGVuZGVkIHNjcm9sbCBheGlzLCBhbmQgb3RoZXIgYXhpc1xuICAgICAgICAgICAgICAgICAgICB2YXIgYSA9IHNjcm9sbEF4aXM7XG4gICAgICAgICAgICAgICAgICAgIHZhciBvYSA9IHNjcm9sbEF4aXMgPT09ICdZJyA/ICdYJyA6ICdZJztcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRhID0gTWF0aC5hYnModFsnY2xpZW50JyArIGFdIC0gdGhpcy5maXJzdFhZW2FdKTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRvYSA9IE1hdGguYWJzKHRbJ2NsaWVudCcgKyBvYV0gLSB0aGlzLmZpcnN0WFlbb2FdKTtcbiAgICAgICAgICAgICAgICAgICAgLy8gaWYgZGVsdGEgaW4gdGhlIHNjcm9sbCBheGlzID4gZGVsdGEgb3RoZXIgYXhpcywgc2Nyb2xsIGluc3RlYWQgb2ZcbiAgICAgICAgICAgICAgICAgICAgLy8gbWFraW5nIGV2ZW50c1xuICAgICAgICAgICAgICAgICAgICByZXQgPSBkYSA+PSBkb2E7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaDogZnVuY3Rpb24oaW5UTCwgaW5JZCkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBpblRMLmxlbmd0aCwgdDsgaSA8IGwgJiYgKHQgPSBpblRMW2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKHQuaWRlbnRpZmllciA9PT0gaW5JZCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIEluIHNvbWUgaW5zdGFuY2VzLCBhIHRvdWNoc3RhcnQgY2FuIGhhcHBlbiB3aXRob3V0IGEgdG91Y2hlbmQuIFRoaXNcbiAgICAgICAgLy8gbGVhdmVzIHRoZSBwb2ludGVybWFwIGluIGEgYnJva2VuIHN0YXRlLlxuICAgICAgICAvLyBUaG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KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHAgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaChwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRoaXMpO1xuICAgICAgICAgICAgICAgIGQuZm9yRWFjaChmdW5jdGlvbihwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsKHApO1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLmRlbGV0ZShwLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHRvdWNoc3RhcnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMudmFjdXVtVG91Y2hlcyhpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMuc2V0UHJpbWFyeVRvdWNoKGluRXZlbnQuY2hhbmdlZFRvdWNoZXNbMF0pO1xuICAgICAgICAgICAgdGhpcy5kZWR1cFN5bnRoTW91c2UoaW5FdmVudCk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuc2Nyb2xsaW5nKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlja0NvdW50Kys7XG4gICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLmRvd24pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihpblBvaW50ZXIpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChIQVNfVE9VQ0hfQUNUSU9OKSB7XG4gICAgICAgICAgICAgICAgLy8gdG91Y2hldmVudC5jYW5jZWxhYmxlID09IGZhbHNlIGlzIHNlbnQgd2hlbiB0aGUgcGFnZSBpcyBzY3JvbGxpbmcgdW5kZXIgbmF0aXZlIFRvdWNoIEFjdGlvbiBpbiBDaHJvbWUgMzZcbiAgICAgICAgICAgICAgICAvLyBodHRwczovL2dyb3Vwcy5nb29nbGUuY29tL2EvY2hyb21pdW0ub3JnL2QvbXNnL2lucHV0LWRldi93SG55dWtjWUJjQS9iOWttdHdNMWpKUUpcbiAgICAgICAgICAgICAgICBpZiAoaW5FdmVudC5jYW5jZWxhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5tb3ZlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5zY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc2Nyb2xsaW5nID09PSBudWxsICYmIHRoaXMuc2hvdWxkU2Nyb2xsKGluRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5FdmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLm1vdmUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZHggPSB0LmNsaWVudFggLSB0aGlzLmZpcnN0WFkuWDtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGR5ID0gdC5jbGllbnRZIC0gdGhpcy5maXJzdFhZLlk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkZCA9IE1hdGguc3FydChkeCAqIGR4ICsgZHkgKiBkeSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZCA+PSBIWVNURVJFU0lTKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRvdWNoY2FuY2VsKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJzdFhZID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoaW5Qb2ludGVyKTtcbiAgICAgICAgfSxcbiAgICAgICAgdG91Y2hlbmQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuZGVkdXBTeW50aE1vdXNlKGluRXZlbnQpO1xuICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLnVwKTtcbiAgICAgICAgfSxcbiAgICAgICAgdXA6IGZ1bmN0aW9uKGluUG9pbnRlcikge1xuICAgICAgICAgICAgaW5Qb2ludGVyLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluUG9pbnRlcik7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnVwKGluUG9pbnRlcik7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmNhbmNlbChpblBvaW50ZXIpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaGNhbmNlbDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaW5FdmVudC5fY2FuY2VsID0gdHJ1ZTtcbiAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5jYW5jZWwpO1xuICAgICAgICB9LFxuICAgICAgICBjbGVhblVwUG9pbnRlcjogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpblBvaW50ZXIucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlUHJpbWFyeVBvaW50ZXIoaW5Qb2ludGVyKTtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gcHJldmVudCBzeW50aCBtb3VzZSBldmVudHMgZnJvbSBjcmVhdGluZyBwb2ludGVyIGV2ZW50c1xuICAgICAgICBkZWR1cFN5bnRoTW91c2U6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBsdHMgPSBzY29wZS5tb3VzZUV2ZW50cy5sYXN0VG91Y2hlcztcbiAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgIC8vIG9ubHkgdGhlIHByaW1hcnkgZmluZ2VyIHdpbGwgc3ludGggbW91c2UgZXZlbnRzXG4gICAgICAgICAgICBpZiAodGhpcy5pc1ByaW1hcnlUb3VjaCh0KSkge1xuICAgICAgICAgICAgICAgIC8vIHJlbWVtYmVyIHgveSBvZiBsYXN0IHRvdWNoXG4gICAgICAgICAgICAgICAgdmFyIGx0ID0ge1xuICAgICAgICAgICAgICAgICAgICB4OiB0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IHQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbHRzLnB1c2gobHQpO1xuICAgICAgICAgICAgICAgIHZhciBmbiA9IChmdW5jdGlvbihsdHMsIGx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpID0gbHRzLmluZGV4T2YobHQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsdHMuc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkuYmluZChudWxsLCBsdHMsIGx0KTtcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZuLCBERURVUF9USU1FT1VUKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICAvLyBwcmV2ZW50IFwiZ2hvc3QgY2xpY2tzXCIgdGhhdCBjb21lIGZyb20gZWxlbWVudHMgdGhhdCB3ZXJlIHJlbW92ZWQgaW4gYSB0b3VjaCBoYW5kbGVyXG4gICAgdmFyIFNUT1BfUFJPUF9GTiA9IEV2ZW50LnByb3RvdHlwZS5zdG9wSW1tZWRpYXRlUHJvcGFnYXRpb24gfHwgRXZlbnQucHJvdG90eXBlLnN0b3BQcm9wYWdhdGlvbjtcbiAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKGV2KSB7XG4gICAgICAgIHZhciB4ID0gZXYuY2xpZW50WCxcbiAgICAgICAgICAgIHkgPSBldi5jbGllbnRZO1xuICAgICAgICAvLyBjaGVjayBpZiBhIGNsaWNrIGlzIHdpdGhpbiBERURVUF9ESVNUIHB4IHJhZGl1cyBvZiB0aGUgdG91Y2hzdGFydFxuICAgICAgICB2YXIgY2xvc2VUbyA9IGZ1bmN0aW9uKHRvdWNoKSB7XG4gICAgICAgICAgICB2YXIgZHggPSBNYXRoLmFicyh4IC0gdG91Y2gueCksXG4gICAgICAgICAgICAgICAgZHkgPSBNYXRoLmFicyh5IC0gdG91Y2gueSk7XG4gICAgICAgICA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J0cyk7XG5cbihmdW5jdGlvbihzY29wZSkge1xuICAgIHZhciBkaXNwYXRjaGVyID0gc2NvcGUuZGlzcGF0Y2hlcjtcbiAgICB2YXIgcG9pbnRlcm1hcCA9IGRpc3BhdGNoZXIucG9pbnRlcm1hcDtcbiAgICB2YXIgSEFTX0JJVE1BUF9UWVBFID0gd2luZG93Lk1TUG9pbnRlckV2ZW50ICYmIHR5cGVvZiB3aW5kb3cuTVNQb2ludGVyRXZlbnQuTVNQT0lOVEVSX1RZUEVfTU9VU0UgPT09ICdudW1iZXInO1xuICAgIHZhciBtc0V2ZW50cyA9IHtcbiAgICAgICAgZXZlbnRzOiBbXG4gICAgICAgICAgICAnTVNQb2ludGVyRG93bicsXG4gICAgICAgICAgICAnTVNQb2ludGVyTW92ZScsXG4gICAgICAgICAgICAnTVNQb2ludGVyVXAnLFxuICAgICAgICAgICAgJ01TUG9pbnRlckNhbmNlbCcsXG4gICAgICAgIF0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIFBPSU5URVJfVFlQRVM6IFtcbiAgICAgICAgICAgICcnLFxuICAgICAgICAgICAgJ3VuYXZhaWxhYmxlJyxcbiAgICAgICAgICAgICd0b3VjaCcsXG4gICAgICAgICAgICAncGVuJyxcbiAgICAgICAgICAgICdtb3VzZSdcbiAgICAgICAgXSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGluRXZlbnQ7XG4gICAgICAgICAgICBlID0gZGlzcGF0Y2hlci5jbG9uZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKEhBU19CSVRNQVBfVFlQRSkge1xuICAgICAgICAgICAgICAgIGUucG9pbnRlclR5cGUgPSB0aGlzLlBPSU5URVJfVFlQRVNbaW5FdmVudC5wb2ludGVyVHlwZV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlLl9zb3VyY2UgPSAnbXMnO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIE1TUG9pbnRlckRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgZS50YXJnZXQpO1xuICAgICAgICAgICAgZGlzcGF0Y2hlci5kb3duKGUpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJNb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50Y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FyIHBvaW50ZXJFdmVudHMgPSB7XG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ3BvaW50ZXJkb3duJyxcbiAgICAgICAgICAgICdwb2ludGVybW92ZScsXG4gICAgICAgICAgICAncG9pbnRlcnVwJyxcbiAgICAgICAgICAgICdwb2ludGVyY2FuY2VsJ1xuICAgICAgICBdLFxuICAgICAgICBwcmVwYXJlRXZlbnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gZGlzcGF0Y2hlci5jbG9uZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ3BvaW50ZXInO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQoZS5wb2ludGVySWQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcG9pbnRlcm1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciB0YXJnZXQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBlLnRhcmdldCA9IHRhcmdldDtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJ1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGUucG9pbnRlcklkKTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBwb2ludGVyY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS5yZWxhdGVkVGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUudGFyZ2V0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wYXRjaGVyO1xuICAgIHZhciBldmVudEZhY3RvcnkgPSBzY29wZS5ldmVudEZhY3Rvcnk7XG4gICAgdmFyIHBvaW50ZXJtYXAgPSBuZXcgc2NvcGUuUG9pbnRlck1hcCgpO1xuICAgIHZhciB0cmFjayA9IHtcbiAgICAgICAgZXZlbnRzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAnbW92ZScsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAndHJhY2tzdGFydCcsXG4gICAgICAgICAgICAndHJhY2snLFxuICAgICAgICAgICAgJ3RyYWNreCcsXG4gICAgICAgICAgICAndHJhY2t5JyxcbiAgICAgICAgICAgICd0cmFja2VuZCdcbiAgICAgICAgXSxcbiAgICAgICAgZGVmYXVsdEFjdGlvbnM6IHtcbiAgICAgICAgICAgICd0cmFjayc6ICdub25lJyxcbiAgICAgICAgICAgICd0cmFja3gnOiAncGFuLXknLFxuICAgICAgICAgICAgJ3RyYWNreSc6ICdwYW4teCdcbiAgICAgICAgfSxcbiAgICAgICAgV0lHR0xFX1RIUkVTSE9MRDogNCxcbiAgICAgICAgY2xhbXBEaXI6IGZ1bmN0aW9uKGluRGVsdGEpIHtcbiAgICAgICAgICAgIHJldHVybiBpbkRlbHRhID4gMCA/IDEgOiAtMTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FsY1Bvc2l0aW9uRGVsdGE6IGZ1bmN0aW9uKGluQSwgaW5CKSB7XG4gICAgICAgICAgICB2YXIgeCA9IDAsXG4gICAgICAgICAgICAgICAgeSA9IDA7XG4gICAgICAgICAgICBpZiAoaW5BICYmIGluQikge1xuICAgICAgICAgICAgICAgIHggPSBpbkIucGFnZVggLSBpbkEucGFnZVg7XG4gICAgICAgICAgICAgICAgeSA9IGluQi5wYWdlWSAtIGluQS5wYWdlWTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuICAgICAgICBmaXJlVHJhY2s6IGZ1bmN0aW9uKGluVHlwZSwgaW5FdmVudCwgaW5UcmFja2luZ0RhdGEpIHtcbiAgICAgICAgICAgIHZhciB0ID0gaW5UcmFja2luZ0RhdGE7XG4gICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEodC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgdmFyIGRkID0gdGhpcy5jYWxjUG9zaXRpb25EZWx0YSh0Lmxhc3RNb3ZlRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKGRkLngpIHtcbiAgICAgICAgICAgICAgICB0LnhEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLngpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGRkLnkpIHtcbiAgICAgICAgICAgICAgICB0LnlEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLnkpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3knKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGdlc3R1cmVQcm90byA9IHtcbiAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgdHJhY2tJbmZvOiB0LnRyYWNrSW5mbyxcbiAgICAgICAgICAgICAgICByZWxhdGVkVGFyZ2V0OiBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQsXG4gICAgICAgICAgICAgICAgcG9pbnRlclR5cGU6IGluRXZlbnQucG9pbnRlclR5cGUsXG4gICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAndHJhY2snXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGluVHlwZSAhPT0gJ3RyYWNreScpIHtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueCA9IGluRXZlbnQueDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uZHggPSBkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmRkeCA9IGRkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmNsaWVudFggPSBpbkV2ZW50LmNsaWVudFg7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnBhZ2VYID0gaW5FdmVudC5wYWdlWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uc2NyZWVuWCA9IGluRXZlbnQuc2NyZWVuWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueERpcmVjdGlvbiA9IHQueERpcmVjdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpblR5cGUgIT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmR5ID0gZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5kZHkgPSBkZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by55ID0gaW5FdmVudC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5jbGllbnRZID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5wYWdlWSA9IGluRXZlbnQucGFnZVk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnNjcmVlblkgPSBpbkV2ZW50LnNjcmVlblk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnlEaXJlY3Rpb24gPSB0LnlEaXJlY3Rpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZSA9IGV2ZW50RmFjdG9yeS5tYWtlR2VzdHVyZUV2ZW50KGluVHlwZSwgZ2VzdHVyZVByb3RvKTtcbiAgICAgICAgICAgIHQuZG93blRhcmdldC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaW5FdmVudC5pc1ByaW1hcnkgJiYgKGluRXZlbnQucG9pbnRlclR5cGUgPT09ICdtb3VzZScgPyBpbkV2ZW50LmJ1dHRvbnMgPT09IDEgOiB0cnVlKSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0ge1xuICAgICAgICAgICAgICAgICAgICBkb3duRXZlbnQ6IGluRXZlbnQsXG4gICAgICAgICAgICAgICAgICAgIGRvd25UYXJnZXQ6IGluRXZlbnQudGFyZ2V0LFxuICAgICAgICAgICAgICAgICAgICB0cmFja0luZm86IHt9LFxuICAgICAgICAgICAgICAgICAgICBsYXN0TW92ZUV2ZW50OiBudWxsLFxuICAgICAgICAgICAgICAgICAgICB4RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB5RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB0cmFja2luZzogZmFsc2VcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHAgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmICghcC50cmFja2luZykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEocC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICB2YXIgbW92ZSA9IGQueCAqIGQueCArIGQueSAqIGQueTtcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnQgdHJhY2tpbmcgb25seSBpZiBmaW5nZXIgbW92ZXMgbW9yZSB0aGFuIFdJR0dMRV9USFJFU0hPTERcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1vdmUgPiB0aGlzLldJR0dMRV9USFJFU0hPTEQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAudHJhY2tpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gcC5kb3duRXZlbnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2tzdGFydCcsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChwLnRyYWNraW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFjaycsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2t4JywgaW5FdmVudCwgcCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFja3knLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gaW5FdmVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQp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ZWxlYXNlJ1xuICAgICAgICBdLFxuICAgICAgICBoZWxkUG9pbnRlcjogbnVsbCxcbiAgICAgICAgaG9sZEpvYjogbnVsbCxcbiAgICAgICAgcHVsc2U6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdmFyIGhvbGQgPSBEYXRlLm5vdygpIC0gdGhpcy5oZWxkUG9pbnRlci50aW1lU3RhbXA7XG4gICAgICAgICAgICB2YXIgdHlwZSA9IHRoaXMuaGVsZCA/ICdob2xkcHVsc2UnIDogJ2hvbGQnO1xuICAgICAgICAgICAgdGhpcy5maXJlSG9sZCh0eXBlLCBob2xkKTtcbiAgICAgICAgICAgIHRoaXMuaGVsZCA9IHRydWU7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBjbGVhckludGVydmFsKHRoaXMuaG9sZEpvYik7XG4gICAgICAgICAgICBpZiAodGhpcy5oZWxkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlSG9sZCgncmVsZWFzZScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5oZWxkID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmhlbGRQb2ludGVyID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMuaG9sZEpvYiA9IG51bGw7XG4gICAgICAgIH0sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChpbkV2ZW50LmlzUHJpbWFyeSAmJiAhdGhpcy5oZWxkUG9pbnRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuaGVsZFBvaW50ZXIgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gaW5FdmVudC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5ob2xkSm9iID0gc2V0SW50ZXJ2YWwodGhpcy5wdWxzZS5iaW5kKHRoaXMpLCB0aGlzLkhPTERfREVMQVkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jYW5jZWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFggLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFg7XG4gICAgICAgICAgICAgICAgdmFyIHkgPSBpbkV2ZW50LmNsaWVudFkgLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFk7XG4gICAgICAgICAgICAgICAgaWYgKCh4ICogeCArIHkgKiB5KSA+IHRoaXMuV0lHR0xFX1RIUkVTSE9MRCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgZmlyZUhvbGQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5Ib2xkVGltZSkge1xuICAgICAgICAgICAgdmFyIHAgPSB7XG4gICAgICAgICAgICAgICAgYnViYmxlczogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiB0aGlzLmhlbGRQb2ludGVyLnBvaW50ZXJUeXBlLFxuICAgICA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WVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IGluRXZlbnQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzaG91bGRUYXA6IGZ1bmN0aW9uKGUsIGRvd25TdGF0ZSkge1xuICAgICAgICAgICAgdmFyIHRhcCA9IHRydWU7XG4gICAgICAgICAgICBpZiAoZS5wb2ludGVyVHlwZSA9PT0gJ21vdXNlJykge1xuICAgICAgICAgICAgICAgIC8vIG9ubHkgYWxsb3cgbGVmdCBjbGljayB0byB0YXAgZm9yIG1vdXNlXG4gICAgICAgICAgICAgICAgdGFwID0gKGUuYnV0dG9ucyBeIDEpICYmIChkb3duU3RhdGUuYnV0dG9ucyAmIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRhcCAmJiAhZS50YXBQcmV2ZW50ZWQ7XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgc3RhcnQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAoc3RhcnQgJiYgdGhpcy5zaG91bGRUYXAoaW5FdmVudCwgc3RhcnQpKSB7XG4gICAgICAgICAgICAgICAgLy8gdXAucmVsYXRlZFRhcmdldCBpcyB0YXJnZXQgY3VycmVudGx5IHVuZGVyIGZpbmdlclxuICAgICAgICAgICAgICAgIHZhciB0ID0gc2NvcGUudGFyZ2V0RmluZGluZy5MQ0Eoc3RhcnQudGFyZ2V0LCBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQpO1xuICAgICAgICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQoJ3RhcCcsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgeDogaW5FdmVudC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICAgICAgeTogaW5FdmVudC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiBpbkV2ZW50LmRldGFpbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiBpbkV2ZW50LnBvaW50ZXJUeXBlLFxuICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFsdEtleTogaW5FdmVudC5hbHRLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBjdHJsS2V5OiBpbkV2ZW50LmN0cmxLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRhS2V5OiBpbkV2ZW50Lm1ldGFLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGlmdEtleTogaW5FdmVudC5zaGlmdEtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgIF9zb3VyY2U6ICd0YXAnXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcG9pbnRlcm1hcC5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICAvLyBwYXRjaCBldmVudEZhY3RvcnkgdG8gcmVtb3ZlIGlkIGZyb20gdGFwJ3MgcG9pbnRlcm1hcCBmb3IgcHJldmVudFRhcCBjYWxsc1xuICAgIGV2ZW50RmFjdG9yeS5wcmV2ZW50VGFwID0gZnVuY3Rpb24oZSkge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgIC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XG4gKiBAcHJvcGVydHkgYW5nbGVcbiAqIEB0eXBlIE51bWJlclxuICovXG4vKipcbiAqIENlbnRlciBYIHBvc2l0aW9uIG9mIHBvaW50ZXJzIGNhdXNpbmcgcm90YXRpb25cbiAqIEBwcm9wZXJ0eSBjZW50ZXJYXG4gKiBAdHlwZSBOdW1iZXJcbiAqL1xuLyoqXG4gKiBDZW50ZXIgWSBwb3NpdGlvbiBvZiBwb2ludGVycyBjYXVzaW5nIHJvdGF0aW9uXG4gKiBAcHJvcGVydHkgY2VudGVyWVxuICogQHR5cGUgTnVtYmVyXG4gKi9cbihmdW5jdGlvbihzY29wZSkge1xuICAgIHZhciBkaXNwYXRjaGVyID0gc2NvcGUuZGlzcGF0Y2hlcjtcbiAgICB2YXIgZXZlbnRGYWN0b3J5ID0gc2NvcGUuZXZlbnRGYWN0b3J5O1xuICAgIHZhciBwb2ludGVybWFwID0gbmV3IHNjb3BlLlBvaW50ZXJNYXAoKTtcbiAgICB2YXIgUkFEX1RPX0RFRyA9IDE4MCAvIE1hdGguUEk7XG4gICAgdmFyIHBpbmNoID0ge1xuICAgICAgICBldmVudHM6IFtcbiAgICAgICAgICAgICdkb3duJyxcbiAgICAgICAgICAgICd1cCcsXG4gICAgICAgICAgICAnbW92ZScsXG4gICAgICAgICAgICAnY2FuY2VsJ1xuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAncGluY2hzdGFydCcsXG4gICAgICAgICAgICAncGluY2gnLFxuICAgICAgICAgICAgJ3BpbmNoZW5kJyxcbiAgICAgICAgICAgICdyb3RhdGUnXG4gICAgICAgIF0sXG4gICAgICAgIGRlZmF1bHRBY3Rpb25zOiB7XG4gICAgICAgICAgICAncGluY2gnOiAnbm9uZScsXG4gICAgICAgICAgICAncm90YXRlJzogJ25vbmUnXG4gICAgICAgIH0sXG4gICAgICAgIHJlZmVyZW5jZToge30sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIGlmIChwb2ludGVybWFwLnBvaW50ZXJzKCkgPT0gMikge1xuICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgIHZhciBhbmdsZSA9IHRoaXMuY2FsY0FuZ2xlKHBvaW50cyk7XG4gICAgICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UgPSB7XG4gICAgICAgICAgICAgICAgICAgIGFuZ2xlOiBhbmdsZSxcbiAgICAgICAgICAgICAgICAgICAgZGlhbWV0ZXI6IHBvaW50cy5kaWFtZXRlcixcbiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBzY29wZS50YXJnZXRGaW5kaW5nLkxDQShwb2ludHMuYS50YXJnZXQsIHBvaW50cy5iLnRhcmdldClcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgdGhpcy5maXJlUGluY2goJ3BpbmNoc3RhcnQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgcCA9IHBvaW50ZXJtYXAuZ2V0KGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHZhciBudW0gPSBwb2ludGVybWFwLnBvaW50ZXJzKCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmIChudW0gPT09IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZmlyZSAncGluY2hlbmQnIGJlZm9yZSBkZWxldGluZyBwb2ludGVyXG4gICAgICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2hlbmQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAuaGFzKGluRXZlbnQucG9pbnRlcklkKSkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5wb2ludGVycygpID4gMSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGNQaW5jaFJvdGF0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB0aGlzLnVwKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBmaXJlUGluY2g6IGZ1bmN0aW9uKHR5cGUsIGRpYW1ldGVyLCBwb2ludHMpIHtcbiAgICAgICAgICAgIHZhciB6b29tID0gZGlhbWV0ZXIgLyB0aGlzLnJlZmVyZW5jZS5kaWFtZXRlcjtcbiAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQodHlwZSwge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBzY2FsZTogem9vbSxcbiAgICAgICAgICAgICAgICBjZW50ZXJYOiBwb2ludHMuY2VudGVyLngsXG4gICAgICAgICAgICAgICAgY2VudGVyWTogcG9pbnR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cbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2gnLCBkaWFtZXRlciwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChhbmdsZSAhPSB0aGlzLnJlZmVyZW5jZS5hbmdsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZVJvdGF0ZShhbmdsZSwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FsY0Nob3JkOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBwb2ludGVycyA9IFtdO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5mb3JFYWNoKGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICAgICAgICBwb2ludGVycy5wdXNoKHApO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB2YXIgZGlzdCA9IDA7XG4gICAgICAgICAgICAvLyBzdGFydCB3aXRoIGF0IGxlYXN0IHR3byBwb2ludGVyc1xuICAgICAgICAgICAgdmFyIHBvaW50cyA9IHtcbiAgICAgICAgICAgICAgICBhOiBwb2ludGVyc1swXSxcbiAgICAgICAgICAgICAgICBiOiBwb2ludGVyc1sxXVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHZhciB4LCB5LCBkO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwb2ludGVycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBhID0gcG9pbnRlcnNbaV07XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IGkgKyAxOyBqIDwgcG9pbnRlcnMubGVuZ3RoOyBqKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGIgPSBwb2ludGVyc1tqXTtcbiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGguYWJzKGEuY2xpZW50WCAtIGIuY2xpZW50WCk7XG4gICAgICAgICAgICAgICAgICAgIHkgPSBNYXRoLmFicyhhLmNsaWVudFkgLSBiLmNsaWVudFkpO1xuICAgICAgICAgICAgICAgICAgICBkID0geCArIHk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkID4gZGlzdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYTogYSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiOiBiXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgeCA9IE1hdGguYWJzKHBvaW50cy5hLmNsaWVudFggKyBwb2ludHMuYi5jbGllbnRYKSAvIDI7XG4gICAgICAgICAgICB5ID0gTWF0aC5hYnMocG9pbnRzLmEuY2xpZW50WSArIHBvaW50cy5iLmNsaWVudFkpIC8gMjtcbiAgICAgICAgICAgIHBvaW50cy5jZW50ZXIgPSB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcG9pbnRzLmRpYW1ldGVyID0gZGlzdDtcbiAgICAgICAgICAgIHJldHVybiBwb2ludHM7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNBbmdsZTogZnVuY3Rpb24ocG9pbnRzKSB7XG4gICAgICAgICAgICB2YXIgeCA9IHBvaW50cy5hLmNsaWVudFggLSBwb2ludHMuYi5jbGllbnRYO1xuICAgICAgICAgICAgdmFyIHkgPSBwb2ludHMuYS5jbGllbnRZIC0gcG9pbnRzLmIuY2xpZW50WTtcbiAgICAgICAgICAgIHJldHVybiAoMzYwICsgTWF0aC5hdGFuMih5LCB4KSAqIFJBRF9UT19ERUcpICUgMzYwO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBkaXNwYXRjaGVyLnJlZ2lzdGVyR2Vzd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ICAgICAqIEBtZW1iZXJPZiBEYXRhTm9kZUJhc2UucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IGtleVxuICAgICAqL1xuICAgIGluaXRpYWxpemU6IGZ1bmN0aW9uKGtleSkge1xuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlck9mIERhdGFOb2RlQmFzZS5wcm90b3R5cGVcbiAgICAgICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgICAgICovXG5cbiAgICAgICAgdGhpcy5sYWJlbCA9IGtleTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlck9mIERhdGFOb2RlQmFzZS5wcm90b3R5cGVcbiAgICAgICAgICogQHR5cGUge3N0cmluZ1tdfVxuICAgICAgICAgKiBAZGVmYXVsdCBmYWxzZVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5kYXRhID0gWycnXTsgLy8gVE9ETzogV2h5IGlzIHRoaXMgZmlyc3QgZWxlbWVudCBuZWVkZWQ/XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEBtZW1iZXJPZiBEYXRhTm9kZUJhc2UucHJvdG90eXBlXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJbXX1cbiAgICAgICAgICogQGRlZmF1bHQgWycnXVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5pbmRleCA9IFtdOyAvLyBUT0RPOiBmb3JtZXJseSByb3dJbmRleFxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAbWVtYmVyT2YgRGF0YU5vZGVCYXNlLnByb3RvdHlwZVxuICAgICAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgICAgICogQGRlZmF1bHQgZmFsc2VcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuaGFzQ2hpbGRyZW4gPSBmYWxzZTsgLy8gVE9ETzogV2hlcmUvaG93IGlzIHRoaXMgdXNlZD9cblxuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlck9mIERhdGFOb2RlQmFzZS5wcm90b3R5cGVcbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICogQGRlZmF1bHQgMFxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5kZXB0aCA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEBtZW1iZXJPZiBEYXRhTm9kZUJhc2UucHJvdG90eXBlXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqIEBkZWZhdWx0IDFcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuaGVpZ2h0ID0gMTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogQG1lbWJlck9mIERhdGFOb2RlQmFzZS5wcm90b3R5cGVcbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqIEBkZWZhdWx0IGZhbHNlXG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLmV4cGFuZGVkID0gZmFsc2U7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBEYXRhTm9kZUxlYWYucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHhcbiAgICAgKiBAcmV0dXJucyB7Kn1cbiAgICAgKi9cbiAgICBnZXRWYWx1ZTogZnVuY3Rpb24oeCkge1xuICAgICAgICByZXR1cm4gdGhpcy5kYXRhW3hdO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgRGF0YU5vZGVMZWFmLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSBkZXB0aFxuICAgICAqL1xuICAgIHRvQXJyYXk6IGZ1bmN0aW9uKGRlcHRoKSB7XG4gICAgICAgIHRoaXMuZGVwdGggPSBkZXB0aDtcbiAgICAgICAgdGhpcy5kYXRhWzBdID0gdGhpcy5jb21wdXRlRGVwdGhTdHJpbmcoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIERhdGFOb2RlTGVhZi5wcm90b3R5cGVcbiAgICAgKi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Zm9yRWFjaChmdW5jdGlvbihjaGlsZCkge1xuICAgICAgICAgICAgY2hpbGQudG9BcnJheShkZXB0aCArIDEpO1xuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5kYXRhWzBdID0gdGhpcy5jb21wdXRlRGVwdGhTdHJpbmcoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIERhdGFOb2RlR3JvdXAucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge3N0cmluZ31cbiAgICAgKi9cbiAgICBjb21wdXRlRGVwdGhTdHJpbmc6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gQXJyYXkodGhpcy5kZXB0aCArIDEpLmpvaW4odGhpcy5JTkRFTlQpICtcbiAgICAgICAgICAgIGV4cGFuZGVkTWFwW3RoaXMuZXhwYW5kZWRdICsgJyAnICtcbiAgICAgICAgICAgIHRoaXMubGFiZWw7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBEYXRhTm9kZUdyb3VwLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHsqfVxuICAgICAqL1xuICAgIGdldEluZGV4OiBmdW5jdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuaW5kZXgubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICB0aGlzLmluZGV4ID0gdGhpcy5jb21wdXRlSW5kZXgoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5pbmRleDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIERhdGFOb2RlR3JvdXAucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge0FycmF5fVxuICAgICAqL1xuICAgIGNvbXB1dGVJbmRleDogZnVuY3Rpb24oKSB7IC8vIFRPRE86IGZvcm1lcmx5IGNvbXB1dGVBbGxSb3dJbmRleGVzXG4gICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgcmVzdWx0LmFwcGVuZCA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G4gICAgICogQHJldHVybnMgeyp9XG4gICAgICovXG4gICAgZ2V0R3JhbmRUb3RhbHM6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5kYXRhU291cmNlLmdldEdyYW5kVG90YWxzKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBEYXRhU291cmNlSW5kZXhlZC5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0ge29iamVjdFtdfSBhcnJheU9mVW5pZm9ybU9iamVjdHNcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0W119XG4gICAgICovXG4gICAgc2V0RGF0YTogZnVuY3Rpb24oYXJyYXlPZlVuaWZvcm1PYmplY3RzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmRhdGFTb3VyY2Uuc2V0RGF0YShhcnJheU9mVW5pZm9ybU9iamVjdHMpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgRGF0YVNvdXJjZUluZGV4ZWQucHJvdG90eXBlXG4gICAgICovXG4gICAgY2xlYXJJbmRleDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHRoaXMuaW5kZXgubGVuZ3RoID0gMDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIERhdGFTb3VyY2VJbmRleGVkLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSBwcmVkaWNhdGVcbiAgICAgKiBAcmV0dXJucyB7bnVtYmVyW119XG4gICAgICovXG4gICAgYnVpbGRJbmRleDogZnVuY3Rpb24ocHJlZGljYXRlKSB7XG4gICAgICAgIHZhciByb3dDb3VudCA9IHRoaXMuZGF0YVNvdXJjZS5nZXRSb3dDb3VudCgpLFxuICAgICAgICAgICAgaW5kZXggPSB0aGlzLmluZGV4O1xuXG4gICAgICAgIHRoaXMuY2xlYXJJbmRleCgpO1xuXG4gICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgcm93Q291bnQ7IHIrKykge1xuICA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gfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgTWFwcHkucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtmdW5jdGlvbn0gaXRlcmF0ZWVcbiAgICAgKi9cbiAgICBmb3JFYWNoOiBmdW5jdGlvbihpdGVyYXRlZSkge1xuICAgICAgICBpZiAodHlwZW9mIGl0ZXJhdGVlID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICB2YXIga2V5cyA9IHRoaXMua2V5cyxcbiAgICAgICAgICAgICAgICBzZWxmID0gdGhpcztcbiAgICAgICAgICAgIGtleXMuZm9yRWFjaChmdW5jdGlvbihrZXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBzZWxmLmdldChrZXkpO1xuICAgICAgICAgICAgICAgIGl0ZXJhdGVlKHZhbHVlLCBrZXksIHNlbGYpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIE1hcHB5LnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7ZnVuY3Rpb259IGl0ZXJhdGVlXG4gICAgICogQHJldHVybnMge01hcHB5fVxuICAgICAqL1xuICAgIG1hcDogZnVuY3Rpb24oaXRlcmF0ZWUpIHtcbiAgICAgICAgdmFyIGtleXMgPSB0aGlzLmtleXMsXG4gICAgICAgICAgICBuZXdNYXAgPSBuZXcgTWFwcHkoKSxcbiAgICAgICAgICAgIHNlbGYgPSB0aGlzO1xuXG4gICAgICAgIGlmICghKHR5cGVvZiBpdGVyYXRlZSA9PT0gJ2Z1bmN0aW9uJykpIHtcbiAgICAgICAgICAgIGl0ZXJhdGVlID0gcmVmbGVjdGlvbjtcbiAgICAgICAgfVxuXG4gICAgICAgIGtleXMuZm9yRWFjaChmdW5jdGlvbihrZXkpIHtcbiAgICAgICAgICAgIHZhciB2YWx1ZSA9IHNlbGYuZ2V0KGtleSksXG4gICAgICAgICAgICAgICAg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lcik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICAvLyB3aGVlbCBldmVudHMgb24gdGhlIGxpc3QgZWxlbWVudHNcbiAgICAgICAgdGhpcy5tb2RlbExpc3RzLmZvckVhY2goZnVuY3Rpb24gKG1vZGVsTGlzdCkge1xuICAgICAgICAgICAgbW9kZWxMaXN0LmVsZW1lbnQucmVtb3ZlRXZlbnRMaXN0ZW5lcignd2hlZWwnLCBjYXB0dXJlRXZlbnQpO1xuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgcG9pbnRJbkxpc3RSZWN0czogZnVuY3Rpb24gKHBvaW50KSB7XG4gICAgICAgIHJldHVybiB0aGlzLm1vZGVsTGlzdHMuZmluZChmdW5jdGlvbiAobW9kZWxMaXN0KSB7XG4gICAgICAgICAgICB2YXIgcmVjdCA9IG1vZGVsTGlzdC5lbGVtZW50LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpO1xuXG4gICAgICAgICAgICByZWN0ID0ge1xuICAgICAgICAgICAgICAgIGxlZnQ6ICAgd2luZG93LnNjcm9sbFggKyByZWN0LmxlZnQsXG4gICAgICAgICAgICAgICAgdG9wOiAgICB3aW5kb3cuc2Nyb2xsWSArIHJlY3QudG9wLFxuICAgICAgICAgICAgICAgIHJpZ2h0OiAgd2luZG93LnNjcm9sbFggKyByZWN0LnJpZ2h0LFxuICAgICAgICAgICAgICAgIGJvdHRvbTogd2luZG93LnNjcm9sbFkgKyByZWN0LmJvdHRvbSxcbiAgICAgICAgICAgICAgICB3aWR0aDogIHJlY3Qud2lkdGgsXG4gICAgICAgICAgICAgICAgaGVpZ2h0OiByZWN0LmhlaWdodFxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgbW9kZWxMaXN0LnJlY3QgPSByZWN0O1xuXG4gICAgICAgICAgICBpZiAocG9pbnRJblJlY3QocG9pbnQsIHJlY3QpKSB7XG4gICAgICAgICAgICAgICAgbW9kZWxMaXN0LnJlY3QgPSByZWN0O1xu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N0cy5maW5kKGZ1bmN0aW9uIChsaXN0KSB7IHJldHVybiBsaXN0LmVsZW1lbnQgPT09IGxpc3RFbGVtZW50OyB9KTtcblxuICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgIC8vIG9taXR0ZWQ6IGRlZmF1bHQgdG8gdHJ1ZVxuICAgICAgICAgICAgICAgIGxpc3QuaXNEcm9wVGFyZ2V0ID09PSB1bmRlZmluZWQgfHxcblxuICAgICAgICAgICAgICAgIC8vIGZ1bmN0aW9uOiB1c2UgcmV0dXJuIHZhbHVlXG4gICAgICAgICAgICAgICAgdHlwZW9mIGxpc3QuaXNEcm9wVGFyZ2V0ID09PSAnZnVuY3Rpb24nICYmIGxpc3QuaXNEcm9wVGFyZ2V0KCkgfHxcblxuICAgICAgICAgICAgICAgIC8vIG90aGVyd2lzZTogdXNlIHRydXRoaW5lc3Mgb2YgZ2l2ZW4gdmFsdWVcbiAgICAgICAgICAgICAgICBsaXN0LmlzRHJvcFRhcmdldFxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlY3QgPSBpdGVtRWxlbWVudC5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKSxcbiAgICAgICAgICAgICAgICAgICAgYm90dG9tID0gcmVjdC5ib3R0b207XG5cbiAgICAgICAgICAgICAgICBpZiAoaXRlbUVsZW1lbnQgPT09IGxpc3RFbGVtZW50Lmxhc3RFbGVtZW50Q2hpbGQpIHtcbiAgICAgICAgICAgICAgICAgICAgYm90dG9tID0gbGlzdEVsZW1lbnQuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCkuYm90dG9tO1xuICAgICAgICAgICAgICAgICAgICBpZiAoYm90dG9tIDwgcmVjdC50b3ApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvdHRvbSA9IHJlY3QudG9wICsgKGhlaWdodCB8fCA1MCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICA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HlsZS5ib3JkZXJUb3BXaWR0aCA9IHJlY3QuaGVpZ2h0ICsgJ3B4JztcblxuICAgICAgICB0aGlzLnN0eWxlLndpZHRoID0gcmVjdC53aWR0aCArICdweCc7XG4gICAgICAgIHRoaXMuc3R5bGUudHJhbnNpdGlvbkR1cmF0aW9uID0gJzBzJztcbiAgICAgICAgdGhpcy5zdHlsZVt0cmFuc2Zvcm1dID0gdHJhbnNsYXRlKFxuICAgICAgICAgICAgcmVjdC5sZWZ0IC0gd2luZG93LnNjcm9sbFgsXG4gICAgICAgICAgICByZWN0LnRvcCAgLSB3aW5kb3cuc2Nyb2xsWVxuICAgICAgICApO1xuICAgICAgICB0aGlzLmNsYXNzTGlzdC5hZGQoJ2RyYWdvbi1wb3AnKTtcbiAgICAgICAgdGhpcy5zdHlsZS56SW5kZXggPSB3aW5kb3cuZ2V0Q29tcHV0ZWRTdHlsZShkcmFnb24ubW9kZWxMaXN0c1swXS5jb250YWluZXIucGFyZW50RWxlbWVudCkuekluZGV4O1xuXG4gICAgICAgIGlmICghZHJhZ29uLmNvbnRhaW5lcikge1xuICAgICAgICAgICAgLy8gd2FsayBiYWNrIHRvIGNsb3Nlc3Qgc2hhZG93IHJvb3QgT1IgYm9keSB0YWcgT1Igcm9vdCB0YWdcbiAgICAgICAgICAgIHZhciBjb250YWluZXIgPSB0aGlzO1xuICAgICAgICAgICAgd2hpbGUgKGNvbnRhaW5lci5wYXJlbnROb2RlKSB7XG4gICAgICAgICAgICAgICAgY29udGFpbmVyID0gY29udGFpbmVyLnBhcmVudE5vZGU7XG4gICAgICAgICAgICAgICAgaWYgKGNvbnRhaW5lciBpbnN0YW5jZW9mIFNoYWRvd1Jvb3QgfHwgY29udGFpbmVyLnRhZ05hbWUgPT09ICdCT0RZJyl7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRyYWdvbi5jb250YWluZXIgPSBjb250YW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ICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIG90aGVyID0gZHJhZ29uLnBvaW50SW5JdGVtUmVjdHMoe1xuICAgICAgICAgICAgICAgIHg6IGV2dC5jbGllbnRYLFxuICAgICAgICAgICAgICAgIHk6IGRyYWdvbi5yZWN0LmJvdHRvbSArIHdpbmRvdy5zY3JvbGxZICsgZHkgKyBob3Zlckxpc3QuZWxlbWVudC5zY3JvbGxUb3BcbiAgICAgICAgICAgIH0sIHRoaXMsIGRyYWdvbi5kcm9wKTtcblxuICAgICAgICAgICAgdGhpcy5zdHlsZVt0cmFuc2Zvcm1dID0gdHJhbnNsYXRlKFxuICAgICAgICAgICAgICAgIGRyYWdvbi5yZWN0LmxlZnQgLSB3aW5kb3cuc2Nyb2xsWCArIGR4LFxuICAgICAgICAgICAgICAgIGRyYWdvbi5yZWN0LnRvcCAtIHdpbmRvdy5zY3JvbGxZICsgZHlcbiAgICAgICAgICAgICk7XG5cbiAgICAgICAgICAgIGlmIChvdGhlcikge1xuICAgICAgICAgICAgICAgIHZhciBlbGVtZW50ID0gb3RoZXIuZWxlbWVudDtcbiAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLnRyYW5zaXRpb24gPSBSRVZFUlRfVE9fU1RZTEVTSEVFVF9WQUxVRTtcbiAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLmJvcmRlclRvcFdpZHRoID0gZHJhZ29uLmRyb3Auc3R5bGUuYm9yZGVyVG9wV2lkdGg7XG4gICAgICAgICAgICAgICAgZHJhZ29uLmRyb3Auc3R5bGUuYm9yZGVyVG9wV2lkdGggPSBudWxsO1xuICAgICAgICAgICAgICAgIGRyYWdvbi5kcm9wID0gZWxlbWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICBtb3VzZXVwOiBmdW5jdGlvbiAoZHJhZ29uLCBldnQpIHtcbiAgICAgICAgcmVzZXRBdXRvU2Nyb2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BhIGAubW9kZWxMaXN0c2AgYXJyYXkgd2l0aCB0aGVzZSA8bGk+IGVsZW1lbnRzJyBwYXJlbnQgPHVsPiBlbGVtZW50c1xuICogQHBhcmFtIHtFbGVtZW50W119IGxpc3RJdGVtRWxlbWVudHNcbiAqIEByZXR1cm5zIHtBcnJheX1cbiAqL1xuZnVuY3Rpb24gY3JlYXRlTW9kZWxMaXN0c0Zyb21MaXN0RWxlbWVudHMobGlzdEl0ZW1FbGVtZW50cykge1xuICAgIHZhciBtb2RlbExpc3RzID0gW107XG5cbiAgICBsaXN0SXRlbUVsZW1lbnRzLmZvckVhY2goZnVuY3Rpb24gKGl0ZW1FbGVtZW50KSB7XG4gICAgICAgIHZhciBsaXN0RWxlbWVudCA9IGl0ZW1FbGVtZW50LnBhcmVudEVsZW1lbnQsXG4gICAgICAgICAgICBjb250YWluZXIgPSBsaXN0RWxlbWVudC5wYXJlbnRFbGVtZW50LFxuICAgICAgICAgICAgbW9kZWxzID0gW107XG4gICAgICAgIGlmICghbW9kZWxMaXN0cy5maW5kKGZ1bmN0aW9uIChsaXN0KSB7IHJldHVybiBsaXN0LmVsZW1lbnQgPT09IGxpc3RFbGVtZW50OyB9KSkge1xuICAgICAgICAgICAgdG9BcnJheShsaXN0RWxlbWVudC5xdWVyeVNlbGVjdG9yQWxsKCdsaScpKS5mb3JFYWNoKGZ1bmN0aW9uIChpdGVtRWxlbWVudCkge1xuICAgICAgICAgICAgICAgIGlmIChpdGVtRWxlbWVudCAhPT0gbGlzdEVsZW1lbnQubGFzdEVsZW1lbnRDaGlsZCkge1xuICAgICAgICAgICAgICAgICAgICBtb2RlbHMucHVzaChpdGVtRWxlbWVudC5pbm5lckhUTUwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgbW9kZWxzLmVsZW1lbnQgPSBsaXN0RWxlbWVudDtcbiAgICAgICAgICAgIG1vZGVscy5jb250YWluZXIgPSBjb250YWluZXI7XG4gICAgICA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aW51czogZnVuY3Rpb24ob2Zmc2V0KSB7XG4gICAgICAgIHJldHVybiBuZXcgUG9pbnQoXG4gICAgICAgICAgICB0aGlzLnggLSBvZmZzZXQueCxcbiAgICAgICAgICAgIHRoaXMueSAtIG9mZnNldC55XG4gICAgICAgICk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEByZXR1cm5zIHtQb2ludH0gQSBuZXcgYFBvaW50YCBwb3NpdGlvbmVkIHRvIGxlYXN0IHggYW5kIGxlYXN0IHkgb2YgdGhpcyBwb2ludCBhbmQgZ2l2ZW4gYG9mZnNldGAuXG4gICAgICogQHBhcmFtIHtQb2ludH0gcG9pbnQgLSBBIHBvaW50IHRvIGNvbXBhcmUgdG8gdGhpcyBwb2ludC5cbiAgICAgKiBAbWVtYmVyT2YgUG9pbnQucHJvdG90eXBlXG4gICAgICovXG4gICAgbWluOiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICByZXR1cm4gbmV3IFBvaW50KFxuICAgICAgICAgICAgTWF0aC5taW4odGhpcy54LCBwb2ludC54KSxcbiAgICAgICAgICAgIE1hdGgubWluKHRoaXMueSwgcG9pbnQueSlcbiAgICAgICAgKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHJldHVybnMge1BvaW50fSBBIG5ldyBgUG9pbnRgIHBvc2l0aW9uZWQgdG8gZ3JlYXRlc3QgeCBhbmQgZ3JlYXRlc3QgeSBvZiB0aGlzIHBvaW50IGFuZCBnaXZlbiBgcG9pbnRgLlxuICAgICAqIEBwYXJhbSB7UG9pbnR9IHBvaW50IC0gQSBwb2ludCB0byBjb21wYXJlIHRvIHRoaXMgcG9pbnQuXG4gICAgICogQG1lbWJlck9mIFBvaW50LnByb3RvdHlwZVxuICAgICAqL1xuICAgIG1heDogZnVuY3Rpb24ocG9pbnQpIHtcbiAgICAgICAgcmV0dXJuIG5ldyBQb2ludChcbiAgICAgICAgICAgIE1hdGgubWF4KHRoaXMueCwgcG9pbnQueCksXG4gICAgICAg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XN1bHQgPSBmYWxzZTtcblxuICAgICAgICBpZiAocG9pbnQpIHtcbiAgICAgICAgICAgIHJlc3VsdCA9XG4gICAgICAgICAgICAgICAgdGhpcy54ID09PSBwb2ludC54ICYmXG4gICAgICAgICAgICAgICAgdGhpcy55ID09PSBwb2ludC55O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IGB0cnVlYCBpZmYgX2JvdGhfIGNvb3JkaW5hdGVzIG9mIHRoaXMgcG9pbnQgYXJlIGdyZWF0ZXIgdGhhbiB0aG9zZSBvZiBnaXZlbiBgcG9pbnRgLlxuICAgICAqIEBwYXJhbSB7UG9pbnR9IHBvaW50IC0gQSBwb2ludCB0byBjb21wYXJlIHRvIHRoaXMgcG9pbnRcbiAgICAgKiBAbWVtYmVyT2YgUG9pbnQucHJvdG90eXBlXG4gICAgICovXG4gICAgZ3JlYXRlclRoYW46IGZ1bmN0aW9uKHBvaW50KSB7XG4gICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICB0aGlzLnggPiBwb2ludC54ICYmXG4gICAgICAgICAgICB0aGlzLnkgPiBwb2ludC55XG4gICAgICAgICk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBgdHJ1ZWAgaWZmIF9ib3RoXyBjb29yZGluYXRlcyBvZiB0aGlzIHBvaW50IGFyZSBsZXNzIHRoYW4gdGhvc2Ugb2YgZ2l2ZW4gYHBvaW50YC5cbiAgICAgKiBAcGFyYW0ge1BvaW50fSBwb2ludCAtIEEgcG9pbnQgdG8gY29tcGFyZSB0byB0aGlzIHBvaW50XG4gICAgICogQG1lbWJlck9mIFBvaW50LnByb3RvdHlwZVxuICAgICAqL1xuICAgIGxlc3NUaGFuOiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgdGhpcy54IDwg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IChcbiAgICAgICAgICAgIHRoaXMueCA8PSBwb2ludC54ICYmXG4gICAgICAgICAgICB0aGlzLnkgPD0gcG9pbnQueVxuICAgICAgICApO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBfKEZvcm1lcmx5IGBpc0NvbnRhaW5lZFdpdGhpblJlY3RhbmdsZWAuKV9cbiAgICAgKiBAcGFyYW0gcmVjdCB7UmVjdGFuZ2xlfSAtIFJlY3RhbmdsZSB0byB0ZXN0IHRoaXMgcG9pbnQgYWdhaW5zdC5cbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gYHRydWVgIGlmZiB0aGlzIHBvaW50IGlzIHdpdGhpbiBnaXZlbiBgcmVjdGAuXG4gICAgICogQG1lbWJlck9mIFBvaW50LnByb3RvdHlwZVxuICAgICAqL1xuICAgIHdpdGhpbjogZnVuY3Rpb24ocmVjdCkge1xuICAgICAgICB2YXIgbWluWCA9IHJlY3Qub3JpZ2luLngsXG4gICAgICAgICAgICBtYXhYID0gbWluWCArIHJlY3QuZXh0ZW50Lng7XG4gICAgICAgIHZhciBtaW5ZID0gcmVjdC5vcmlnaW4ueSxcbiAgICAgICAgICAgIG1heFkgPSBtaW5ZICsgcmVjdC5leHRlbnQueTtcblxuICAgICAgICBpZiAocmVjdC5leHRlbnQueCA8IDApIHtcbiAgICAgICAgICAgIG1pblggPSBtYXhYO1xuICAgICAgICAgICAgbWF4WCA9IHJlY3Qub3JpZ2luLng7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocmVjdC5leHRlbnQueSA8IDApIHtcbiAgICAgICAgICAgIG1pblkgPSBtYXhZO1xuICAgICAgICAgICAgbWF4WSA9IHJlY3Qub3JpZ2luLnk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgbWluWCA8PSB0aGlzLnggJiYgdGhpcy54IDwgbWF4WCAmJlxuICAgICAgICAgICAgbWluWSA8PSB0aGlzLnkgJiYgdGhpcy55IDwgbWF4WVxu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Z1bmN0aW9uIChjZWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zZWxlY3Rpb24uc29tZShmdW5jdGlvbiAoZWFjaCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBlYWNoWzBdIDw9IGNlbGwgJiYgY2VsbCA8PSBlYWNoWzFdO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sXG5cbiAgICAgICAgaXNFbXB0eTogZnVuY3Rpb24gKCl7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zZWxlY3Rpb24ubGVuZ3RoID09PSAwO1xuICAgICAgICB9LFxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAc3VtbWFyeSBSZXR1cm4gdGhlIGluZGV4ZXMgdGhhdCBhcmUgc2VsZWN0ZWQuXG4gICAgICAgICAqIEBkZXNjIFJldHVybiB0aGUgaW5kZXhlcyB0aGF0IGFyZSBzZWxlY3RlZC5cbiAgICAgICAgICogQHJldHVybnMge0FycmF5LkFycmF5Lm51bWJlcn1cbiAgICAgICAgICogQG1lbWJlck9mIFJhbmdlU2VsZWN0aW9uTW9kZWwucHJvdG90eXBlXG4gICAgICAgICAqL1xuICAgICAgICBnZXRTZWxlY3Rpb25zOiBmdW5jdGlvbiAoKXtcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgICAgIHRoaXMuc2VsZWN0aW9uLmZvckVhY2goZnVuY3Rpb24gKGVhY2gpIHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gZWFjaFswXTsgaSA8PSBlYWNoWzFdOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goaSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXN1bHQuc29ydChmdW5jdGlvbiAoYSwgYil7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGEgLSBiO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4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seVxuXG4gICAgICAgIGlmICh2YWwgJiYgdmFsLmNvbnN0cnVjdG9yID09PSBBcnJheSkge1xuICAgICAgICAgICAgbGVmdEljb24gPSB2YWxbMF07XG4gICAgICAgICAgICByaWdodEljb24gPSB2YWxbMl07XG4gICAgICAgICAgICB2YWwgPSB2YWxbMV07XG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gJ29iamVjdCcpIHsgLy8gbXVzdCBiZSBhbiBpbWFnZVxuICAgICAgICAgICAgICAgIGNlbnRlckljb24gPSB2YWw7XG4gICAgICAgICAgICAgICAgdmFsID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChsZWZ0SWNvbiAmJiBsZWZ0SWNvbi5ub2RlTmFtZSAhPT0gJ0lNRycpIHtcbiAgICAgICAgICAgICAgICBsZWZ0SWNvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocmlnaHRJY29uICYmIHJpZ2h0SWNvbi5ub2RlTmFtZSAhPT0gJ0lNRycpIHtcbiAgICAgICAgICAgICAgICByaWdodEljb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGNlbnRlckljb24gJiYgY2VudGVySWNvbi5ub2RlTmFtZSAhPT0gJ0lNRycpIHtcbiAgICAgICAgICAgICAgICBjZW50ZXJJY29uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHZhbCA9IHZhbHVlT3JGdW5jdGlvbkV4ZWN1dGUoY29uZmlnLCB2YWwpO1xuXG4gICAgICAgIGlmIChnYy5mb250ICE9PSBjb25maWcuZm9udCkge1xuICAgICAgICAgICAgZ2MuZm9udCA9IGNvbmZpZy5mb250O1xuICAgICAgICB9XG4gICAgICAgIGlmIChnYy50ZXh0QWxpZ24gIT09ICdsZWZ0Jykge1xuICAgICAgICAgICAgZ2MudGV4dEFsaWduID0gJ2xlZnQnO1xuICAgICAgICB9XG4gICAg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aWdodEljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY2VudGVySWNvbikge1xuICAgICAgICAgICAgaXlvZmZzZXQgPSBNYXRoLnJvdW5kKChoZWlnaHQgLSBjZW50ZXJJY29uLmhlaWdodCkgLyAyKTtcbiAgICAgICAgICAgIGl4b2Zmc2V0ID0gTWF0aC5yb3VuZCgod2lkdGggLSBjZW50ZXJJY29uLndpZHRoKSAvIDIpO1xuICAgICAgICAgICAgZ2MuZHJhd0ltYWdlKGNlbnRlckljb24sIHggKyB3aWR0aCAtIGl4b2Zmc2V0IC0gY2VudGVySWNvbi53aWR0aCwgeSArIGl5b2Zmc2V0KTtcbiAgICAgICAgICAgIGljb25XaWR0aCA9IE1hdGgubWF4KGNlbnRlckljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29uZmlnLmNlbGxCb3JkZXJUaGlja25lc3MpIHtcbiAgICAgICAgICAgIGdjLmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgZ2MucmVjdCh4LCB5LCB3aWR0aCwgaGVpZ2h0KTtcbiAgICAgICAgICAgIGdjLmxpbmVXaWR0aCA9IGNvbmZpZy5jZWxsQm9yZGVyVGhpY2tuZXNzO1xuICAgICAgICAgICAgZ2Muc3Ryb2tlU3R5bGUgPSBjb25maWcuY2VsbEJvcmRlclN0eWxlO1xuXG4gICAgICAgICAgICAvLyBhbmltYXRlIHRoZSBkYXNoZWQgbGluZSBhIGJpdCBoZXJlIGZvciBmdW5cblxuICAgICAgICAgICAgZ2Muc3Ryb2tlKCk7XG4gICAgICAgICAgICBnYy5jbG9zZVBhdGgoKTtcbiAgICAgICAgfVxuICAgICAgICBjb25maWcubWluV2lkdGggPSBjb25maWcubWluV2lkdGggKyAyICogKGljb25XaWR0aCk7XG4gICAgfSxcblxuICAgIHJlbmRlck11bHRpTGluZVRleHQ6IGZ1bmN0aW9uKHgsIHksIGhlaWdodCwgd2lkdGgsIGdjLCBjb25maWcsIHZhbCkge1xuICAgICAgICB2YXIgbGluZXMgPSBmaXRUZXh0KGdjLCBjb25maWcsIHZhbCwgd2lkdGgpO1xuICAgICAgICBpZiAobGluZXMubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5yZW5kZXJTaW5nbGVMaW5lVGV4dCh4LCB5LCBoZWlnaHQsIHdpZHRoLCBnYywgY29uZmlnLCBzcXVlZXplKHZhbCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGNvbEhFZGdlT2Zmc2V0ID0gY29uZmlnLmNlbGxQYWRkaW5nLFxuICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gMCxcbiAgICAgICAgICAgIHZhbGlnbk9mZnNldCA9IGNvbmZpZy52b2Zmc2V0LFxuICAgICAgICAgICAgaGFsaWduID0gY29uZmlnLmhhbGlnbixcbiAgICAgICAgICAgIHRleHRIZWlnaHQgPSBjb25maWcuZ2V0VGV4dEhlaWdodChjb25maWcuZm9udCkuaGVpZ2h0O1xuXG4gICAgICAgIHN3aXRjaCAoaGFsaWduKSB7XG4gICAgICAgICAgICBjYXNlICdyaWdodCc6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gd2lkdGggLSBjb2xIRWRnZU9mZnNldDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ2NlbnRlcic6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gd2lkdGggLyAyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnbGVmdCc6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gY29sSEVkZ2VPZmZzZXQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaE1pbiA9IDAsIHZNaW4gPSBNYXRoLmNlaWwodGV4dEhlaWdodCAvIDIpO1xuXG4gICAgICAgIHZhbGlnb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aW9uKCkge1xuICAgICAgICBpZiAoIXByb3BlcnRpZXNJbml0aWFsaXplZCkge1xuICAgICAgICAgICAgcHJvcGVydGllc0luaXRpYWxpemVkID0gdHJ1ZTtcblxuICAgICAgICAgICAgYnVpbGRQb2x5bWVyVGhlbWUoKTtcblxuICAgICAgICAgICAgdmFyIGNlbGxFZGl0b3JzID0gW1xuICAgICAgICAgICAgICAgICdUZXh0ZmllbGQnLFxuICAgICAgICAgICAgICAgICdDaG9pY2UnLFxuICAgICAgICAgICAgICAgIC8vJ0NvbWJvJyxcbiAgICAgICAgICAgICAgICAnQ29sb3InLFxuICAgICAgICAgICAgICAgICdEYXRlJyxcbiAgICAgICAgICAgICAgICAnU2xpZGVyJyxcbiAgICAgICAgICAgICAgICAnU3Bpbm5lcidcbiAgICAgICAgICAgIF07XG5cbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgICAgIGNlbGxFZGl0b3JzLmZvckVhY2goZnVuY3Rpb24obmFtZSkge1xuICAgICAgICAgICAgICAgIHNlbGYuaW5pdENlbGxFZGl0b3IobmV3IEh5cGVyZ3JpZC5jZWxsRWRpdG9yc1tuYW1lXSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICB0b2dnbGVDb2x1bW5QaWNrZXI6IGZ1bmN0aW9uKCkge1xuICAgICAgICB0aGlzLmdldEJlaGF2aW9yKCkudG9nZ2xlQ29sdW1uUGlja2VyKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IFRoZSBwb2ludGVyIGlzIG92ZXIgdGhlIGdpdmVuIGNlbGwuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHggLSBUaGUgeCBjZWxsIGNvb3JkaW5hdGUuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHkgLSBUaGUgeSBjZWxsIGNvb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fVxuICAgICAgICByZXR1cm4gdGhpcy5tb3VzZURvd25bbGFzdF07XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQGRlc2MgUmVtb3ZlIHRoZSBsYXN0IGl0ZW0gZnJvbSB0aGUgbW91c2UgZG93biBzdGFjay5cbiAgICAgKi9cbiAgICBwb3BNb3VzZURvd246IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5tb3VzZURvd24ubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5tb3VzZURvd24ubGVuZ3RoID0gdGhpcy5tb3VzZURvd24ubGVuZ3RoIC0gMTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBFbXB0eSBvdXQgdGhlIG1vdXNlIGRvd24gc3RhY2suXG4gICAgICovXG4gICAgY2xlYXJNb3VzZURvd246IGZ1bmN0aW9uKCkge1xuICAgICAgICB0aGlzLm1vdXNlRG93biA9IFtuZXcgUG9pbnQoLTEsIC0xKV07XG4gICAgICAgIHRoaXMuZHJhZ0V4dGVudCA9IG51bGw7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgIHNldCB0aGUgbW91c2UgcG9pbnQgdGhhdCBpbml0YXRlZCBhIGNlbGwgZWRpdCBvciBkcmFnIG9wZXJhdGlvblxuICAgICAqXG4gICAgICogQHBhcmFtIHtQb2ludH0gcG9pbnRcbiAgICAgKi9cbiAgICBzZXRNb3VzZURvd246IGZ1bmN0aW9uKHBvaW50KSB7XG4gICAgICAgIHRoaXMubW91c2VEb3duLnB1c2gocG9pbnQpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2Y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A+IDIwMDAwKSB7XG4gICAgICAgICAgICAgICAgYWxlcnQoJ3NlbGVjdGlvbiBzaXplIGlzIHRvbyBiaWcgdG8gY29weSB0byB0aGUgcGFzdGUgYnVmZmVyJyk7IC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tYWxlcnRcbiAgICAgICAgICAgICAgICByZXR1cm4gJyc7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZvciAodmFyIGggPSAwOyBoIDwgaGVpZ2h0OyBoKyspIHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciB3ID0gMDsgdyA8IHdpZHRoOyB3KyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29sbGVjdG9yLnB1c2goc2VsZWN0aW9uc1t3XVtoXSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh3IDwgd2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rvci5wdXNoKCdcXHQnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoaCA8IGhlaWdodCkge1xuICAgICAgICAgICAgICAgICAgICBjb2xsZWN0b3IucHVzaCgnXFxuJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gY29sbGVjdG9yLmpvaW4oJycpO1xuXG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAnJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gV2UgaGF2ZSBmb2N1cy5cbiAgICAgKi9cbiAgICBoYXNGb2N1czogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmdldENhbnZhcygpLmhhc0ZvY3VzKCk7XG4gICAgfSxc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5jdGlvbigpIHtcbiAgICAgICAgdGhpcy5nZXRSZW5kZXJlcigpLmNvbXB1dGVDZWxsc0JvdW5kcygpO1xuICAgICAgICB0aGlzLnJlcGFpbnQoKTtcbiAgICB9LFxuXG4gICAgcmVwYWludDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBub3cgPSB0aGlzLnJlc29sdmVQcm9wZXJ0eSgncmVwYWludEltbWVkaWF0ZWx5Jyk7XG4gICAgICAgIHZhciBjYW52YXMgPSB0aGlzLmdldENhbnZhcygpO1xuICAgICAgICBpZiAoY2FudmFzKSB7XG4gICAgICAgICAgICBpZiAobm93ID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgY2FudmFzLnBhaW50Tm93KCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNhbnZhcy5yZXBhaW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBQYWludCBpbW1lZGlhdGVseSBpbiB0aGlzIG1pY3JvdGFzay5cbiAgICAgKi9cbiAgICBwYWludE5vdzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBjYW52YXMgPSB0aGlzLmdldENhbnZhcygpO1xuICAgICAgICBjYW52YXMucGFpbnROb3coKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gSW4gSGlEUEkgbW9kZSAoaGFzIGFuIGF0dHJpYnV0ZSBhcyBzdWNoKS5cbiAgICAgKi9cbiAgICB1c2VIaURQSTogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnJlc29sdmVQcm9wZXJ0eSgndXNlSGlEUEknKSAhPT0gZmFsc2U7XG4gICAgfSxcblxuICA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F0ZU1vdXNlRG93bihtb3VzZUV2ZW50KTtcbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY01vdXNlRG93bkV2ZW50KG1vdXNlRXZlbnQpO1xuICAgICAgICAgICAgc2VsZi5yZXBhaW50KCk7XG4gICAgICAgIH0pO1xuXG5cbiAgICAgICAgLy8gdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWNsaWNrJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAvLyAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgIC8vICAgICAgICAgcmV0dXJuO1xuICAgICAgICAvLyAgICAgfVxuICAgICAgICAvLyAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgIC8vICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgLy8gICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgLy8gICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAvLyAgICAgc2VsZi5maXJlU3ludGhldGljQ2xpY2tFdmVudChtb3VzZUV2ZW50KTtcbiAgICAgICAgLy8gfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLW1vdXNldXAnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZWxmLmRyYWdnaW5nID0gZmFsc2U7XG4gICAgICAgICAgICBpZiAoc2VsZi5pc1Njcm9sbGluZ05vdygpKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRTY3JvbGxpbmdOb3coZmFsc2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHNlbGYuY29sdW1uRHJhZ0F1dG9TY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICBzZWxmLmNvbHVtbkRyYWdBdXRvU2Nyb2xsaW5nID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL3NlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlTW91c2VVcChtb3VzZUV2ZW50KTtcbiAgICAgICAgICAgIGlmIChzZWxmLm1vdXNlRG93blN0YXRlKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljQnV0dG9uUHJlc3NlZEV2ZW50KHNlbGYubW91c2VEb3duU3RhdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5tb3VzZURvd25TdGF0ZSA9IG51bGw7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNNb3VzZVVwRXZlbnQobW91c2VFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy10YXAnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL3NlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGU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ICAgICAgICAgIH1cbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0tleWRvd25FdmVudChlKTtcbiAgICAgICAgICAgIHNlbGYuZGVsZWdhdGVLZXlEb3duKGUpO1xuICAgICAgICB9KTtcblxuICAgICAgICB0aGlzLmFkZEZpbkV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMta2V5dXAnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNLZXl1cEV2ZW50KGUpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZUtleVVwKGUpO1xuICAgICAgICB9KTtcblxuICAgICAgICB0aGlzLmFkZEZpbkV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMtdHJhY2snLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc2VsZi5kcmFnZ2luZykge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBwcmltRXZlbnQgPSBlLmRldGFpbC5wcmltaXRpdmVFdmVudDtcbiAgICAgICAgICAgIGlmIChNYXRoLmFicyhwcmltRXZlbnQuZHkpID4gTWF0aC5hYnMocHJpbUV2ZW50LmR4KSkge1xuICAgICAgICAgICAgICAgIGlmIChwcmltRXZlbnQueURpcmVjdGlvbiA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zY3JvbGxWQnkoLTIpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocHJpbUV2ZW50LnlEaXJlY3Rpb24gPCAtMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbFZCeSgyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChwcmltRXZlbnQueERpcmVjdGlvbiA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zY3JvbGxIQnkoLTEpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocHJpbUV2ZW50LnhEaXJlY3Rpb24gPCAtMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbEhCeSgxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIC8vIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1ob2xkcHVsc2UnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgIC8vICAgICBjb25zb2xlLmxvZygnaG9sZHB1bHNlJyk7XG4gICAgICAgIC8vICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgLy8gICAgICAgICByZXR1cm47XG4gICAgICAgIC8vICAgICB9XG4gICAgICAgIC8vICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgLy8gICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgLy8gICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAvLyAgICAgc2VsZi5kZWxlZ2F0ZUhvbGRQdWxzZShtb3VzZUV2ZW50KTtcbiAgICAgICAgLy8gfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWRibGNsaWNrJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIG1vdXNlID0gZS5kZXRhaWwubW91c2U7XG4gICAgICAgICAgICB2YXIgbW91c2VFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICBtb3VzZUV2ZW50LnByaW1pdGl2ZUV2ZW50ID0gZTtcbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0RvdWJsZUNsaWNrRXZlbnQobW91c2VFdmVudCwgZSk7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlRG91YmxlQ2xpY2sobW91c2VFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy13aGVlbG1vdmVkJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgdmFyIG1vdXNlID0gZS5kZXRhaWwubW91c2U7XG4gICAgICAgICAgICB2YXIgbW91c2VFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICBtb3VzZUV2ZW50LnByaW1pdGl2ZUV2ZW50ID0gZS5kZXRhaWwucHJpbWl0aXZlRXZlbnQ7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlV2hlZWxNb3ZlZChtb3VzZUV2ZW50KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLW1vdXNlb3V0JywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICA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IGV2ZW50IC0gVGhlIGNhbnZhcyBldmVudC5cbiAgICAgKi9cbiAgICBmaXJlU3ludGhldGljQ29udGV4dE1lbnVFdmVudDogZnVuY3Rpb24oZSkge1xuICAgICAgICBlLmdyaWRDZWxsID0gdGhpcy5jb252ZXJ0Vmlld1BvaW50VG9EYXRhUG9pbnQoZS5ncmlkQ2VsbCk7XG4gICAgICAgIHZhciBldmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWNvbnRleHQtbWVudScsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLmdldFNlbGVjdGlvbk1vZGVsKCkuZ2V0U2VsZWN0aW9ucygpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGV2ZW50KTtcbiAgICB9LFxuXG4gICAgZmlyZVN5bnRoZXRpY01vdXNlVXBFdmVudDogZnVuY3Rpb24oZSkge1xuICAgICAgICB2YXIgZXZlbnQgPSBuZXcgQ3VzdG9tRXZlbnQoJ2Zpbi1tb3VzZXVwJywge1xuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgZ3JpZENlbGw6IGUuZ3JpZENlbGwsXG4gICAgICAgICAgICAgICAgbW91c2VQb2ludDogZS5tb3VzZVBvaW50LFxuICAgICAgICAgICAgICAgIHZpZXdQb2ludDogZS52aWV3UG9pbnQsXG4gICAgICAgICAgICAgICAgcHJpbWl0aXZlRXZlbnQ6IGUucHJpbWl0aXZlRXZlbnQsXG4gICAgICAgICAgICAgICAgcm93czogdGhpcy5nZXRTZWxlY3RlZFJvd3MoKSxcbiAgICAgICAgICAgICAgICBjb2x1bW5zOiB0aGlzLmdldFNlbGVjdGVkQ29sdW1ucygpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGlvbnM6IHRoaXMuZ2V0U2VsZWN0aW9uTW9kZWwoKS5nZXRTZWxlY3Rpb25zKClcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuY2FudmFzLmRpc3BhdGNoRXZlbnQoZXZlbnQpO1xuICAgIH0sXG5cbiAgICBmaXJlU3ludGhldGljTW91c2VEb3duRXZlbnQ6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgdmFyIGV2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tbW91c2Vkb3duJywge1xuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgZ3JpZENlbGw6IGUuZ3JpZENlbGwsXG4gICAgICAgICAgICAgICAgbW91c2VQb2ludDogZS5tb3VzZVBvaW50LFxuICAgICAgICAgICAgICAgIHZpZXdQb2ludDogZS52aWV3UG9pbnQsXG4gICAgICAgICAgICAgICAgcHJpbWl0aXZlRXZlbnQ6IGUucHJpbWl0aXZlRXZlbnQsXG4gICAgICAgICAgICAgICAgcm93czogdGhpcy5nZXRTZWxlY3RlZFJvd3MoKSxcbiAgICAgICAgICAgICAgICBjb2x1bW5zOiB0aGlzLmdldFNlbGVjdGVkQ29sdW1ucygpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGlvbnM6IHRoaXMuZ2V0U2VsZWN0aW9uTW9kZWwoKS5nZXRTZWxlY3Rpb25zKClcbiAgICAgICAgICAgIH1cbi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uZ2V0QmVoYXZpb3IoKTtcbiAgICAgICAgdmFyIGRldGFpbCA9IHtcbiAgICAgICAgICAgIGdyaWRDZWxsOiBjZWxsLFxuICAgICAgICAgICAgbW91c2VQb2ludDogbW91c2VFdmVudC5tb3VzZVBvaW50LFxuICAgICAgICAgICAgdGltZTogRGF0ZS5ub3coKSxcbiAgICAgICAgICAgIGdyaWQ6IHRoaXNcbiAgICAgICAgfTtcbiAgICAgICAgYmVoYXZpb3IuZW5oYW5jZURvdWJsZUNsaWNrRXZlbnQobW91c2VFdmVudCk7XG4gICAgICAgIHZhciBjbGlja0V2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tZG91YmxlLWNsaWNrJywge1xuICAgICAgICAgICAgZGV0YWlsOiBkZXRhaWxcbiAgICAgICAgfSk7XG4gICAgICAgIGJlaGF2aW9yLmNlbGxEb3VibGVDbGlja2VkKGNlbGwsIG1vdXNlRXZlbnQpO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGNsaWNrRXZlbnQpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgSHlwZXJncmlkLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIFN5bnRoZXNpemUgYW5kIGZpcmUgYSByZW5kZXJlZCBldmVudC5cbiAgICAgKi9cbiAgICBmaXJlU3ludGhldGljR3JpZFJlbmRlcmVkRXZlbnQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgZXZlbnQgPSBuZXcgQ3VzdG9tRXZlbnQoJ2Zpbi1ncmlkLXJlbmRlcmVkJywge1xuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLFxuICAgICAgICAgICAgICAgIHRpbWU6IERhdGUubm93KClcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLmNhbnZhcykge1xuICAgICAgICAgICAgdGhpcy5jYW52YXMuZGl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nQ7XG4gICAgICAgIGlmIChlZGl0b3IpIHtcbiAgICAgICAgICAgIGlmIChwb2ludC54ID09PSB4ICYmIHBvaW50LnkgPT09IHkgJiYgZWRpdG9yLmlzRWRpdGluZykge1xuICAgICAgICAgICAgICAgIHJldHVybjsgLy93ZSdyZSBhbHJlYWR5IG9wZW4gYXQgdGhpcyBsb2NhdGlvblxuICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLmlzRWRpdGluZygpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdG9wRWRpdGluZygpOyAvL290aGVyIGVkaXRvciBpcyBvcGVuLCBjbG9zZSBpdCBmaXJzdFxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZXZlbnQuZ3JpZENlbGwgPSB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdGhpcy5lZGl0QXQoZWRpdG9yLCBldmVudCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAc3VtbWFyeSBHZXQgdGhlIGNlbGwgZWRpdG9yLlxuICAgICAqIEBkZXNjIERlbGVnYXRlcyB0byB0aGUgYmVoYXZpb3IuXG4gICAgICogQHJldHVybnMgVGhlIGNlbGwgZWRpdG9yIGF0IHRoZSBnaXZlbiBjb29yZGluYXRlcy5cbiAgICAgKiBAcGFyYW0ge3h9IHggLSBUaGUgaG9yaXpvbnRhbCBjb29yZGluYXRlLlxuICAgICAqIEBwYXJhbSB7eX0geSAtIFRoZSB2ZXJ0aWNhbCBjb29yZGluYXRlLlxuICAgICAqL1xuICAgIGdldENlbGxFZGl0b3JBdDogZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICByZXR1cm4gdGhpcy5nZXRCZWhhdmlvcigpLmdldENlbGxFZGl0b3JBdCh4LCB5KTtcbiAgICB9LFxuXG4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5kZXJlZERhdGE6IGZ1bmN0aW9uKCkge1xuICAgICAgICAvLyBhc3N1bWVzIG9uZSByb3cgb2YgaGVhZGVyc1xuICAgICAgICB2YXIgYmVoYXZpb3IgPSB0aGlzLmdldEJlaGF2aW9yKCksXG4gICAgICAgICAgICByZW5kZXJlciA9IHRoaXMuZ2V0UmVuZGVyZXIoKSxcbiAgICAgICAgICAgIGNvbENvdW50ID0gdGhpcy5nZXRDb2x1bW5Db3VudCgpLFxuICAgICAgICAgICAgcm93Q291bnQgPSByZW5kZXJlci5nZXRWaXNpYmxlUm93cygpLFxuICAgICAgICAgICAgaGVhZGVycyA9IG5ldyBBcnJheShjb2xDb3VudCksXG4gICAgICAgICAgICByZXN1bHRzID0gbmV3IEFycmF5KHJvd0NvdW50KSxcbiAgICAgICAgICAgIHJvdztcblxuICAgICAgICBoZWFkZXJzLmZvckVhY2goZnVuY3Rpb24oaGVhZGVyLCBjKSB7XG4gICAgICAgICAgICBoZWFkZXJzW2NdID0gYmVoYXZpb3IuZ2V0Q29sdW1uSWQoYywgMCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQsIHIpIHtcbiAgICAgICAgICAgIHJvdyA9IHJlc3VsdHNbcl0gPSB7XG4gICAgICAgICAgICAgICAgaGllcmFyY2h5OiBiZWhhdmlvci5nZXRGaXhlZENvbHVtblZhbHVlKDAsIHIpXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaGVhZGVycy5mb3JFYWNoKGZ1bmN0aW9uKGZpZWxkLCBjKSB7XG4gICAgICAgICAgICAgICAgcm93W2ZpZWxkXSA9IGJlaGF2aW9yLmdldFZhbHVlKGMsIHIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiByZXN1bHRzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgSHlwZXJncmlkLnByb3RvdHlwZV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dGlvbih4LCBrZXlzKSB7XG4gICAgICAgIGtleXMgPSBrZXlzIHx8IFtdO1xuICAgICAgICB2YXIgbW9kZWwgPSB0aGlzLmdldFNlbGVjdGlvbk1vZGVsKCk7XG4gICAgICAgIHZhciBhbHJlYWR5U2VsZWN0ZWQgPSBtb2RlbC5pc0NvbHVtblNlbGVjdGVkKHgpO1xuICAgICAgICB2YXIgaGFzQ1RSTCA9IGtleXMuaW5kZXhPZignQ1RSTCcpID4gLTE7XG4gICAgICAgIHZhciBoYXNTSElGVCA9IGtleXMuaW5kZXhPZignU0hJRlQnKSA+IC0xO1xuICAgICAgICBpZiAoIWhhc0NUUkwgJiYgIWhhc1NISUZUKSB7XG4gICAgICAgICAgICBtb2RlbC5jbGVhcigpO1xuICAgICAgICAgICAgaWYgKCFhbHJlYWR5U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RDb2x1bW4oeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoaGFzQ1RSTCkge1xuICAgICAgICAgICAgICAgIGlmIChhbHJlYWR5U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgbW9kZWwuZGVzZWxlY3RDb2x1bW4oeCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Q29sdW1uKHgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChoYXNTSElGVCkge1xuICAgICAgICAgICAgICAgIG1vZGVsLmNsZWFyKCk7XG4gICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Q29sdW1uKHRoaXMubGFzdEVkZ2VTZWxlY3Rpb25bMF0sIHgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICghYWxyZWFkeVNlbGVjdGVkICYmICFoYXNTSElGVCkge1xuICAgICAgIC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9kZWwuc2VsZWN0Um93KHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKGhhc0NUUkwpIHtcbiAgICAgICAgICAgICAgICBpZiAoYWxyZWFkeVNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIG1vZGVsLmRlc2VsZWN0Um93KHkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1NpbmdsZVJvd1NlbGVjdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZWwuY2xlYXJSb3dTZWxlY3Rpb24oKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RSb3coeSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGhhc1NISUZUKSB7XG4gICAgICAgICAgICAgICAgbW9kZWwuY2xlYXIoKTtcbiAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RSb3codGhpcy5sYXN0RWRnZVNlbGVjdGlvblsxXSwgeSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFhbHJlYWR5U2VsZWN0ZWQgJiYgIWhhc1NISUZUKSB7XG4gICAgICAgICAgICB0aGlzLmxhc3RFZGdlU2VsZWN0aW9uWzFdID0geTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlcGFpbnQoKTtcbiAgICB9LFxuXG4gICAgc2VsZWN0Vmlld3BvcnRDZWxsOiBmdW5jdGlvbih4LCB5KSB7XG4gICAgICAgIHZhciBoZWFkZXJSb3dDb3VudCA9IHRoaXMuZ2V0SGVhZGVyUm93Q291bnQoKTtcbiAgICAgICAgdmFyIHJlbmRlcmVyID0gdGhpcy5nZXRSZW5kZXJlcigpO1xuICAgICAgICB2YXIgcmVhbFggPSByZW5kZXJlci5nZXRWaXNpYmxlQ29sdW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tcbiAgICAgICAgICAgIHZ4ID0gYztcbiAgICAgICAgICAgIGlmIChjID49IG51bUZpeGVkQ29sdW1ucykge1xuICAgICAgICAgICAgICAgIHZ4ID0gdnggKyBzY3JvbGxMZWZ0O1xuICAgICAgICAgICAgICAgIGlmIChmaXJzdFZYID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RWWCA9IHZ4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsYXN0VlggPSB2eDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh4ID4gdmlld1dpZHRoIHx8IG51bUNvbHVtbnMgPD0gdngpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHdpZHRoID0gdGhpcy5nZXRDb2x1bW5XaWR0aCh2eCk7XG4gICAgICAgICAgICB4ID0geCArIHdpZHRoO1xuICAgICAgICAgICAgdGhpcy5jb2x1bW5FZGdlc1tjICsgMV0gPSBNYXRoLnJvdW5kKHgpO1xuICAgICAgICAgICAgdGhpcy52aXNpYmxlQ29sdW1uc1tjXSA9IHZ4O1xuICAgICAgICAgICAgdGhpcy5jb2x1bW5FZGdlc0luZGV4TWFwW3Z4XSA9IGM7XG5cbiAgICAgICAgICAgIGluc2VydGlvbkJvdW5kc0N1cnNvciA9IGluc2VydGlvbkJvdW5kc0N1cnNvciArIE1hdGgucm91bmQod2lkdGggLyAyKSArIHByZXZpb3VzSW5zZXJ0aW9uQm91bmRzQ3Vyc29yVmFsdWU7XG4gICAgICAgICAgICB0aGlzLmluc2VydGlvbkJvdW5kcy5wdXNoKGluc2VydGlvbkJvdW5kc0N1cnNvcik7XG4gICAgICAgICAgICBwcmV2aW91c0luc2VydGlvbkJvdW5kc0N1cnNvclZhbHVlID0gTWF0aC5yb3VuZCh3aWR0aCAvIDIpO1xuICAgICAgICB9XG5cbiAgICAgICAgeSA9IDA7XG4gICAgICAgIGZvciAociA9I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WYgKHBpeGVsWCA8IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGMgPiBmaXhlZENvbHVtbkNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGMgPSBjICsgc2Nyb2xsTGVmdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGMgLSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChjID4gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgYyA9IGMgKyBzY3JvbGxMZWZ0O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjIC0gMTtcbiAgICB9LFxuXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQGRlc2MgQW5zd2VyIHNwZWNpZmljIGRhdGEgY2VsbCBjb29yZGluYXRlcyBnaXZlbiBtb3VzZSBjb29yZGluYXRlcyBpbiBwaXhlbHMuXG4gICAgICogQHBhcmFtIHtQb2ludH0gcG9pbnRcbiAgICAgKiBAcmV0dXJucyB7UG9pbnR9IENlbGwgY29vcmRpbmF0ZXNcbiAgICAgKi9cbiAgICBnZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50OiBmdW5jdGlvbihwb2ludCkge1xuXG4gICAgICAgIHZhciBncmlkID0gdGhpcy5nZXRHcmlkKCk7XG4gICAgICAgIHZhciBiZWhhdmlvciA9IGdyaWQuZ2V0QmVoYXZpb3IoKTtcbiAgICAgICAgdmFyIHdpZHRoID0gMDtcbiAgICAgICAgdmFyIGhlaWdodCA9IDA7XG4gICAgICAgIHZhciB4LCB5LCBjLCByO1xuICAgICAgICB2YXIgcHJldmlvdXMgPSAwO1xuICAgICAgICB2YXIgY29sdW1uRWRnZXMgPSB0aGlzLmdldENvbHVtbkVkZ2VzKCk7XG4gICAgICAgIHZhciBmaXhlZENvbHVtbkNvdW50ID0gdGhpcy5nZXRGaXhlZENvbHVtbkNvdW50KCk7IC8vICsgZ3JpZFNpemU7XG4gICAgICAgIHZhciBmaXhlZFJvd0NvdW50ID0gdGhpcy5nZXRGaXhlZFJvd0NvdW50KCk7XG5cbiAgICAgICAgLy8gdmFyIGZpeGVkQ29sdW1uQ291bnQgPSB0aGlzLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgLy8gdmFyIGZpeGVkUm93Q291bnQgPSB0aGlzLmdldEZpeGVkUm93Q291bnQoKTtcbiAgICAgICAgdmFyIHNjcm9sbFggPSB0aGlzLmdldFNjcm9sbExlZnQoKTtcbiAgICAgICAgdmFyIHNjcm9sbFkgPSB0aGlzLmdldFNjcm9sbFRvcCgpO1xuXG4gICAgICAgIGZvciAoYyA9IDA7IGMgPCBjb2x1bW5FZGdlcy5sZW5ndGg7IGMrKykge1xuICAgICAgICAgICAgd2lkdGggPSBjb2x1bW5FZGdlc1tjXTtcbiAgICAgICAgICAgIGlmIChwb2ludC54IDwgd2lkdGgpIHtcbiAgICAgICAgICAgICAgICB4ID0gTWF0aC5tYXgoMCwgcG9pbnQueCAtIHByZXZpb3VzIC0gMik7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcmV2aW91cyA9IHdpZHRoO1xuICAgICAgICB9XG4gICAgICAgIGMtLTtcbiAgICAgICAgcHJldmlvdXMgPSAwO1xuICAgICAgICBmb3IgKHIgPSAwOyByIDwgdGhpcy5yb3dFZGdlcy5sZW5ndGg7IHIrKykge1xuICAgICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yb3dFZGdlc1tyXTtcbiAgICAgICAgICAgIGlmIChwb2ludC55IDwgaGVpZ2h0KSB7XG4gICAgICAgICAgICAgICAgeSA9IE1hdGgubWF4KDAsIHBvaW50LnkgLSBwcmV2aW91cyAtIDIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHJldmlvdXMgPSBoZWlnaHQ7XG4gICAgICAgIH1cbiAgICAgICAgci0tO1xuICAgICAgICBpZiAocG9pbnQueCA8IDApIHtcbiAgICAgICAgICAgIGMgPSAtMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocG9pbnQueSA8IDApIHtcbiAgICAgICAgICAgIHIgPSAtMTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciB2aWV3UG9pbnQgPSBncmlkLm5ld1BvaW50KGMsIHIpO1xuXG4gICAgICAgIC8vY29tcGVuc2F0ZSBpZiB3ZSBhcmUgc2Nyb2xsZWRcbiAgICAgICAgaWYgKGMgPj0gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgYyA9IGMgKyBzY3JvbGxYO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyID49IGZpeGVkUm93Q291bnQpIHtcbiAgICAgICAgICAgIHIgPSByICsgc2Nyb2xsWTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciB0cmFuc2xhdGVkSW5kZXggPSAtMTtcblxuICAgICAgICB2YXIgY29sdW1uID0gYmVoYXZpb3IuZ2V0Q29sdW1uKGMpO1xuICAgICAgICBpZiAoY29sdW1uKSB7XG4gICAgICAgICAgICB0cmFuc2xhdGVkSW5kZXggPSBjb2x1bW4uaW5kZXg7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgZ3JpZENlbGw6IGdyaWQubmV3UG9pbnQoYywgciksXG4gICAgICAgICAgICBtb3VzZVBvaW50OiBncmlkLm5ld1BvaW50KHgsIHkpLFxuICAgICAgICAgICAgdmlld1BvaW50OiB2aWV3UG9pbnQsXG4gICAgICAgICAgICBkYXRhQ2VsbDogZ3JpZC5uZXdQb2ludCh0cmFuc2xhdGVkSW5kZXgsIHIpLFxuICAgICAgICB9O1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHN1bW1hcnkgRGV0ZXJtaW5lcyB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C8vIHZhciBvaCA9IG8uaGVpZ2h0O1xuICAgICAgICB2YXIgZSA9IHRoaXMuX2dldEJvdW5kc09mQ2VsbChkcEVYLCBkcEVZKTtcbiAgICAgICAgdmFyIGV4ID0gTWF0aC5yb3VuZCgoZS54ID09PSB1bmRlZmluZWQpID8gZ3JpZC5nZXRGaXhlZENvbHVtbnNXaWR0aCgpIDogZS54KTtcbiAgICAgICAgdmFyIGV5ID0gTWF0aC5yb3VuZCgoZS55ID09PSB1bmRlZmluZWQpID8gZ3JpZC5nZXRGaXhlZFJvd3NIZWlnaHQoKSA6IGUueSk7XG4gICAgICAgIC8vIHZhciBldyA9IGUud2lkdGg7XG4gICAgICAgIC8vIHZhciBlaCA9IGUuaGVpZ2h0O1xuICAgICAgICB2YXIgeCA9IE1hdGgubWluKG94LCBleCk7XG4gICAgICAgIHZhciB5ID0gTWF0aC5taW4ob3ksIGV5KTtcbiAgICAgICAgdmFyIHdpZHRoID0gMSArIGV4IC0gb3g7XG4gICAgICAgIHZhciBoZWlnaHQgPSAxICsgZXkgLSBveTtcbiAgICAgICAgaWYgKHggPT09IGV4KSB7XG4gICAgICAgICAgICB3aWR0aCA9IG94IC0gZXg7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHkgPT09IGV5KSB7XG4gICAgICAgICAgICBoZWlnaHQgPSBveSAtIGV5O1xuICAgICAgICB9XG4gICAgICAgIGlmICh3aWR0aCAqIGhlaWdodCA8IDEpIHtcbiAgICAgICAgICAgIC8vaWYgd2UgYXJlIG9ubHkgYSBza2lubnkgbGluZSwgZG9uJ3QgcmVuZGVyIGFueXRoaW5nXG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBnYy5yZWN0KHgsIHksIHdpZHRoLCBoZWlnaHQpO1xuICAgICAgICBnYy5maWxsU3R5bGUgPSAncmdiYSgwLCAwLCAwLCAwLjIpJztcbiAgICAgICAgZ2MuZmlsbCgpO1xuICAgICAgICBnYy5saW5lV2lkdGggPSAx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dmFyIGRyYXdUaGVtSCA9IHRoaXMucmVzb2x2ZVByb3BlcnR5KCdncmlkTGluZXNIJyk7XG4gICAgICAgIHZhciBkcmF3VGhlbVYgPSB0aGlzLnJlc29sdmVQcm9wZXJ0eSgnZ3JpZExpbmVzVicpO1xuICAgICAgICB2YXIgbGluZUNvbG9yID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2xpbmVDb2xvcicpO1xuXG4gICAgICAgIGdjLmJlZ2luUGF0aCgpO1xuICAgICAgICBnYy5zdHJva2VTdHlsZSA9IGxpbmVDb2xvcjtcbiAgICAgICAgZ2MubGluZVdpZHRoID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2xpbmVXaWR0aCcpO1xuICAgICAgICBnYy5tb3ZlVG8oMCwgMCk7XG5cbiAgICAgICAgaWYgKGRyYXdUaGVtVikge1xuICAgICAgICAgICAgZm9yIChjID0gMDsgYyA8IGNvbFdpZHRocy5sZW5ndGggKyAxOyBjKyspIHtcbiAgICAgICAgICAgICAgICB4ID0gY29sV2lkdGhzW2NdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbyh4LCAwKTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8oeCwgdmlld0hlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZHJhd1RoZW1IKSB7XG4gICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgcm93SGVpZ2h0cy5sZW5ndGg7IHIrKykge1xuICAgICAgICAgICAgICAgIHkgPSByb3dIZWlnaHRzW3JdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbygwLCB5KTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8odmlld1dpZHRoLCB5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBnYy5zdHJva2UoKTtcbiAgICAgICAgZ2MuY2xvc2VQYXRoKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqI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WxlY3RlZCgpKSB7XG4gICAgICAgICAgICB2YXIgZ3JpZCA9IHRoaXMuZ2V0R3JpZCgpO1xuICAgICAgICAgICAgdmFyIGhlYWRlclJvd3MgPSBncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgICAgICB2YXIgcm93Q291bnQgPSBncmlkLmdldFJvd0NvdW50KCkgLSBoZWFkZXJSb3dzO1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IG5ldyBBcnJheShyb3dDb3VudCk7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHJvd0NvdW50OyBpKyspIHtcbiAgICAgICAgICAgICAgICByZXN1bHRbaV0gPSBpICsgaGVhZGVyUm93cztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMucm93U2VsZWN0aW9uTW9kZWwuZ2V0U2VsZWN0aW9ucygpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgU2VsZWN0aW9uTW9kZWwucHJvdG90eXBlXG4gICAgICogQHJldHVybnMgeyp8QXJyYXkuQXJyYXkubnVtYmVyfVxuICAgICAqL1xuICAgIGdldFNlbGVjdGVkQ29sdW1uczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbHVtblNlbGVjdGlvbk1vZGVsLmdldFNlbGVjdGlvbnMoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFNlbGVjdGlvbk1vZGVsLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtib29sZWFufVxuICAgICAqL1xuICAgICBpc0NvbHVtbk9yUm93U2VsZWN0ZWQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gIXRoaXMuY29sdW1uU2VsZWN0aW9uTW9kZWwuaXNFbXB0eSgpIHx8ICF0aGlzLnJvd1NlbGVjdGlvbk1vZGVsLmlzRW1wdHkoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFNlbGVjdGlvbk1vZGVsLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtBcnJheX1cbiAgICAgKi9cbiAgICBnZXRGbGF0dGVuZWRZczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgdmFyIHNldCA9IHt9O1xuICAgICAgICB0aGlzLnNlbGVjdGlvbnMuZm9yRWFjaChmdW5jdGlvbihzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciB0b3AgPSBzZWxlY3Rpb24ub3JpZ2luLnk7XG4gICAgICAgICAgICB2YXIgc2l6ZSA9IHNlbGVjdGlvbi5leHRlbnQueSArIDE7XG4gICAgICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IHNpemU7IHIrKykge1xuICAgICAgICAgICAgICAgIHZhciB0aSA9IHIgKyB0b3A7XG4gICAgICAgICAgICAgICAgaWYgKCFzZXRbdGldKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKHRpKTtcbiAgICAgICAgICAgICAgICAgICAgc2V0W3RpXSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgcmVzdWx0LnNvcnQoZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICAgICAgcmV0dXJuIHggLSB5O1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFNlbGVjdGlvbk1vZGVsLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSBvZmZzZXRcbiAgICAgKi9cbiAgICBzZWxlY3RSb3dzRnJvbUNlbGxzOiBmdW5jdGlvbihvZmZzZXQpIHtcbiAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0IHx8IDA7XG5cbi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ICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnJvd0hlYWRlciA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJGb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMuY29sdW1uSGVhZGVyID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb250OiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckZvbnQ7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5jb2x1bW5IZWFkZXJDb2x1bW5TZWxlY3Rpb24gPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMuY29sdW1uSGVhZGVyLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5yb3dIZWFkZXJSb3dTZWxlY3Rpb24gPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMucm93SGVhZGVyLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyRm9yZWdyb3VuZFJvd1NlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRSb3dTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyQmFja2dyb3VuZFJvd1NlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRSb3dTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5maWx0ZXJQcm9wZXJ0aWVzID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb250OiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckZvbnQ7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckJhY2tncm91bmRDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjZWxsQm9yZGVyU3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclN0eWxlO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckNlbGxCb3JkZXJTdHlsZSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjZWxsQm9yZGVyVGhpY2tuZXNzOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckNlbGxCb3JkZXJUaGlja25lc3M7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclRoaWNrbmVzcyA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy50cmVlQ29sdW1uUHJvcGVydGllcyA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uRm9udDtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uRm9udCA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5Gb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnRyZWVDb2x1bW5Qcm9wZXJ0aWVzQ29sdW1uU2VsZWN0aW9uID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLnRyZWVDb2x1bW5Qcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiBwcm9wZXJ0aWVzO1xuICAgIH0sXG5cbiAgICBnZXRDb2x1bW5XaWR0aDogZnVuY3Rpb24oeCkge1xuICAgICAgICB2YXIgY29sID0gdGhpcy5nZXRDb2x1bW4oeCk7XG4gICAgICAgIGlmICghY29sKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2RlZmF1bHRDb2x1bW5XaWR0aCcpO1xuICAgICAgICB9XG4gICAgICAgIHZhciB3aWR0aCA9IGNvbC5nZXRXaWR0aCgpO1xuICAgICAgICByZXR1cm4gd2lkdGg7XG4gICAgfSxcblxuICAgIHNldENvbHVtbldpZHRoOiBmdW5jdGlvbih4LCB3aWR0aCkge1xuICAgICAgICB0aGlzLmdldENvbHVtbih4KS5zZXRXaWR0aCh3aWR0aCk7XG4gICAgICAgIHRoaXMuc3RhdGVDaGFuZ2VkKCk7XG4gICAgfS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0aWVzXG4gICAgICovXG4gICAgY2xlYXJPYmplY3RQcm9wZXJ0aWVzOiBmdW5jdGlvbihvYmosIGV4cG9ydFByb3BzKSB7XG4gICAgICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICBvYmouaGFzT3duUHJvcGVydHkoa2V5KSAmJiAoXG4gICAgICAgICAgICAgICAgICAgIGV4cG9ydFByb3BzID09PSB1bmRlZmluZWQgfHxcbiAgICAgICAgICAgICAgICAgICAgIWV4cG9ydFByb3BzICYmIG5vRXhwb3J0UHJvcGVydGllcy5pbmRleE9mKGtleSkgPj0gMCB8fFxuICAgICAgICAgICAgICAgICAgICBleHBvcnRQcm9wcyAmJiBub0V4cG9ydFByb3BlcnRpZXMuaW5kZXhPZihrZXkpIDwgMFxuICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmpba2V5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgQmVoYXZpb3IucHJvdG90eXBlXG4gICAgICogQGRlc2MgZ2V0dGVyIGZvciBhIFtNZW1lbnRvXShodHRwOi8vYzIuY29tL2NnaS93aWtpP01lbWVudG9QYXR0ZXJuKSBPYmplY3RcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0fVxuICAgICAqL1xuICAgIGdldFByaXZhdGVTdGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmICghdGhpcy50YWJsZVN0YXRlKSB7XG4gICAgICAgICAgICB0aGlzLnRhYmxlU3RhdGUgPSB0aGlzLmdldERlZmF1bHRTdGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnRhYmxlU3RhdGU7XG4gICAgfSxcblxuICAgIC8vdGhpcyBpcyBlZmZlY3RpdmVseSBhIGNsb25lLCB3aXRoIGNlcnRha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ICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgICAgICBpZiAoZS5rZXlDb2RlID09PSA4KSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuY2xlYXJTdG9wRWRpdGluZygpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5rZXlDb2RlID09PSAyNykge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmNhbmNlbEVkaXRpbmcoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLnJlcGFpbnQoKTtcbiAgICAgICAgICAgICAgICBzZWxmLmdldEdyaWQoKS50YWtlRm9jdXMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLmZpcmVTeW50aGV0aWNFZGl0b3JLZXlVcEV2ZW50KHNlbGYsIGUpO1xuICAgICAgICB9KTtcbiAgICAgICAgaW5wdXQuYWRkRXZlbnRMaXN0ZW5lcigna2V5ZG93bicsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLmZpcmVTeW50aGV0aWNFZGl0b3JLZXlEb3duRXZlbnQoc2VsZiwgZSk7XG4gICAgICAgIH0pO1xuICAgICAgICBpbnB1dC5hZGRFdmVudExpc3RlbmVyKCdrZXlwcmVzcycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKCdrZXlwcmVzcycsIGUua2V5Q29kZSk7XG4gICAgICAgICAgICBzZWxmLmdldEdyaWQoKS5maXJlU3ludGhldGljRWRpdG9yS2V5UHJlc3NFdmVudChzZWxmLCBlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIC8vIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2Z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nVjdG9yXG4gKi9cbnZhciBUZXh0ZmllbGQgPSBTaW1wbGUuZXh0ZW5kKCdUZXh0ZmllbGQnLCB7XG5cbiAgICAvKipcbiAgICAgKiBteSBsb29rdXAgYWxpYXNcbiAgICAgKiBAdHlwZSB7c3RyaW5nfVxuICAgICAqIEBtZW1iZXJPZiBUZXh0ZmllbGQucHJvdG90eXBlXG4gICAgICovXG4gICAgYWxpYXM6ICd0ZXh0ZmllbGQnLFxuXG4gICAgdGVtcGxhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICAvKlxuICAgICAgICAgICAgPGlucHV0IGlkPVwiZWRpdG9yXCI+XG4gICAgICAgICovXG4gICAgfSxcblxuICAgIHNlbGVjdEFsbDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHRoaXMuaW5wdXQuc2V0U2VsZWN0aW9uUmFuZ2UoMCwgdGhpcy5pbnB1dC52YWx1ZS5sZW5ndGgpO1xuICAgIH0sXG5cbiAgICBpbml0aWFsaXplSW5wdXQ6IGZ1bmN0aW9uKGlucHV0KSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgaW5wdXQuYWRkRXZlbnRMaXN0ZW5lcigna2V5dXAnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoZSAmJiAoZS5rZXlDb2RlID09PSAxMyB8fCBlLmtleUNvZGUgPT09IDI3KSkge1xuICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgICAgICBpZiAoZS5rZXlDb2RlID09PSAyNykge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmNhbmNlbEVkaXRpbmcoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNlbGYuZ2V0R3JpZCgpLnJlcGFpbnQoKTtcbiAgICAgICAgICAgICAgICBzZWxmLmdldEdyaWQoKS50YWtlRm9jdXMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzZWxmLmdldEdyaWQoKS5pc0ZpbHRlclJvdyhzZWxmLmdldEVkaXRvclBvaW50KCkueSkpIHtcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNhdmVFZGl0b3JWYWx1ZSgpO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLl9tb3ZlRWRpdG9yKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZWxmLmdldEdyaWQoKS5maXJlU3ludGhldGljRWRpdG9yS2V5VXBFdmVudChzZWxmLCBlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2tleWRvd24nLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBzZWxmLmdldEdyaWQoKS5maXJlU3ludGhldGljRWRpdG9yS2V5RG93bkV2ZW50KHNlbGYsIGUpO1xuICAgICAgICB9KTtcbiAgICAgICAgaW5wdXQuYWRkRXZlbnRMaXN0ZW5lcigna2V5cHJlc3MnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBzZWxmLmdldEdyaWQoKS5maXJlU3ludGhldGljRWRpdG9yS2V5UHJlc3NFdmVudChzZWxmLCBlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIC8vIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2ZvY3Vzb3V0JywgZnVuY3Rpb24oKSB7XG4gICAgICAgIC8vICAgICBzZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgIC8vIH0pO1xuICAgICAgICAvLyBpbnB1dC5hZGRFdmVudExpc3RlbmVyKCdibHVyJywgZnVuY3Rpb24oKSB7XG4gICAgICAgIC8vICAgICBzZWxmLnN0b3BFZGl0aW5nKCk7XG4gICA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0hlYWRlclJvdyA9IGdyaWQuaXNTaG93SGVhZGVyUm93KCk7XG4gICAgICAgIHZhciBpc0JvdGggPSBpc0ZpbHRlclJvdyAmJiBpc0hlYWRlclJvdztcbiAgICAgICAgdmFyIHRvcFRvdGFsc09mZnNldCA9IChpc0ZpbHRlclJvdyA/IDEgOiAwKSArIChpc0hlYWRlclJvdyA/IDEgOiAwKTtcbiAgICAgICAgaWYgKHkgPj0gdG9wVG90YWxzT2Zmc2V0KSB7XG4gICAgICAgICAgICB0aGlzLmdldFRvcFRvdGFscygpW3kgLSB0b3BUb3RhbHNPZmZzZXRdW3hdID0gdmFsdWU7XG4gICAgICAgIH0gZWxzZSBpZiAoeCA9PT0gLTEpIHtcbiAgICAgICAgICAgIHJldHVybjsgLy8gY2FuJ3QgY2hhbmdlIHRoZSByb3cgbnVtYmVyc1xuICAgICAgICB9IGVsc2UgaWYgKGlzQm90aCkge1xuICAgICAgICAgICAgaWYgKHkgPT09IDApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2V0SGVhZGVyKHgsIHZhbHVlKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRGaWx0ZXIoeCwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKGlzRmlsdGVyUm93KSB7XG4gICAgICAgICAgICB0aGlzLnNldEZpbHRlcih4LCB2YWx1ZSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc2V0SGVhZGVyKHgsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gJyc7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IGNvbEluZGV4XG4gICAgICogQHJldHVybnMgeyp9XG4gICAgICovXG4gICAgZ2V0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ICAgICAgICAgICAgIGZpZWxkOiBmaWVsZHNcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBncm91cHM7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge29iamVjdFtdfVxuICAgICAqL1xuICAgIGdldEF2YWlsYWJsZUdyb3VwczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBoZWFkZXJzID0gdGhpcy5zb3VyY2UuZ2V0SGVhZGVycygpLnNsaWNlKDApO1xuICAgICAgICB2YXIgZ3JvdXBCeXMgPSB0aGlzLmFuYWx5dGljcy5ncm91cEJ5cztcbiAgICAgICAgdmFyIGdyb3VwcyA9IFtdO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGhlYWRlcnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGlmIChncm91cEJ5cy5pbmRleE9mKGkpID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHZhciBmaWVsZCA9IGhlYWRlcnNbaV07XG4gICAgICAgICAgICAgICAgZ3JvdXBzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICBpZDogaSxcbiAgICAgICAgICAgICAgICAgICAgbGFiZWw6IGZpZWxkLFxuICAgICAgICAgICAgICAgICAgICBmaWVsZDogZmllbGRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZ3JvdXBzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtvYmplY3RbXX1cbiAgICAgKi9cbiAgICBnZXRWaXNpYmxlQ29sdW1uczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBpdGVtcyA9IHRoaXMuZ2V0QmVoYXZpb3IoK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ICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNvcnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbEluZGV4ID0gTWF0aC5hYnMoc29ydHNbaV0pIC0gMTtcbiAgICAgICAgICAgICAgICB2YXIgdHlwZSA9IHNvcnRzW2ldIDwgMCA/IC0xIDogMTtcbiAgICAgICAgICAgICAgICBzb3J0aW5nU291cmNlLnNvcnRPbihjb2xJbmRleCAtIGdyb3VwT2Zmc2V0LCB0eXBlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBzb3J0aW5nU291cmNlLmFwcGx5U29ydHMoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gaW5kZXhcbiAgICAgKiBAcGFyYW0gcmV0dXJuQXNTdHJpbmdcbiAgICAgKiBAcmV0dXJucyB7Kn1cbiAgICAgKi9cbiAgICBnZXRTb3J0SW1hZ2VGb3JDb2x1bW46IGZ1bmN0aW9uKGluZGV4LCByZXR1cm5Bc1N0cmluZykge1xuICAgICAgICBpbmRleCsrO1xuICAgICAgICB2YXIgdXAgPSB0cnVlO1xuICAgICAgICB2YXIgc29ydHMgPSB0aGlzLmdldFByaXZhdGVTdGF0ZSgpLnNvcnRzO1xuICAgICAgICBpZiAoIXNvcnRzKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgcG9zaXRpb24gPSBzb3J0cy5pbmRleE9mKGluZGV4KTtcbiAgICAgICAgaWYgKHBvc2l0aW9uIDwgMCkge1xuICAgICAgICAgICAgcG9zaXRpb24gPSBzb3J0cy5pbmRleE9mKC0xICogaW5kZXgpO1xuICAgICAgICAgICAgdXAgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocG9zaXRpb24gPCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciByYW5rID0gc29ydHMubGVuZ3RoIC0gcG9zaXRpb247XG5cbiAgICAgICAgaWYgKHJldHVybkFzU3RyaW5nKSB7XG4gICAgICAgICAgICB2YXIgYXJyb3cgPSB1cCA/IFVQV0FSRFNfQkxBQ0tfQVJST1cgOiBET1dOV0FSRFNfQkxBQ0tfQVJST1c7XG4gICAgICAgICAgICByZXR1cm4gcmFuayArIGFycm93ICsgJyAnO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIG5hbWUgPSByYW5rICsgKHVwID8gJy11cCcgOiAnLWRvd24nKTtcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0QmVoYXZpb3IoKS5nZXRJbWFnZShuYW1lKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gY2VsbFxuICAgICAqIEBwYXJhbSBldmVudFxuICAgICAqL1xuICAgIGNlbGxDbGlja2VkOiBmdW5jdGlvbihjZWxsLCBldmVudCkge1xuICAgICAgICBpZiAoIXRoaXMuaGFzQWdncmVnYXRlcygpKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGV2ZW50LmdyaWRDZWxsLnggIT09IDApIHtcbiAgICAgICAgICAgIHJldHVybjsgLy8gdGhpcyB3YXNuJ3QgYSBjbGljayBvbiB0aGUgaGllcmFyY2h5IGNvbHVtblxuICAgICAgICB9XG4gICAgICAgIHZhciBncmlkID0gdGhpcy5nZXRHcmlkKCk7XG4gICAgICAgIHZhciBoZWFkZXJSb3dDb3VudCA9IGdyaWQuZ2V0SGVhZGVyUm93Q291bnQoKTtcbiAgICAgICAgdmFyIHkgPSBldmVudC5ncmlkQ2VsbC55IC0gaGVhZGVyUm93Q291bnQgKyAxO1xuICA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gICAgICBpZiAodGhpcy5oYXNBZ2dyZWdhdGVzKCkpIHtcbiAgICAgICAgICAgIHJlc3VsdC50cmVlID0gdGhpcy5nZXRWYWx1ZSgtMiwgeSk7XG4gICAgICAgICAgICBmaWVsZHMuc2hpZnQoKTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGNvbENvdW50OyBpKyspIHtcbiAgICAgICAgICAgIHJlc3VsdFtmaWVsZHNbaV1dID0gdGhpcy5nZXRWYWx1ZShpLCB5KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB5XG4gICAgICogQHJldHVybnMge29iamVjdH1cbiAgICAgKi9cbiAgICBnZXRDb21wdXRlZFJvdzogZnVuY3Rpb24oeSkge1xuICAgICAgICB2YXIgcmNmID0gdGhpcy5nZXRSb3dDb250ZXh0RnVuY3Rpb24oW3ldKTtcbiAgICAgICAgdmFyIGZpZWxkcyA9IHRoaXMuZ2V0RmllbGRzKCk7XG4gICAgICAgIHZhciByb3cgPSB7fTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBmaWVsZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBmaWVsZCA9IGZpZWxkc1tpXTtcbiAgICAgICAgICAgIHJvd1tmaWVsZF0gPSByY2YoZmllbGQpWzBdO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByb3c7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IGZpZWxkTmFtZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB5XG4gICAgICogQHJldHVybnMgeyp9XG4gICAgICovXG4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GlzUmlnaHRDbGljayB8fCAhdGhpcy5kcmFnZ2luZykge1xuICAgICAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgICAgIHRoaXMubmV4dC5oYW5kbGVNb3VzZURyYWcoZ3JpZCwgZXZlbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuXG4gICAgICAgICAgICB2YXIgbnVtRml4ZWRDb2x1bW5zID0gZ3JpZC5nZXRGaXhlZENvbHVtbkNvdW50KCk7XG4gICAgICAgICAgICB2YXIgbnVtRml4ZWRSb3dzID0gZ3JpZC5nZXRGaXhlZFJvd0NvdW50KCk7XG5cbiAgICAgICAgICAgIHZhciBjZWxsID0gZXZlbnQuZ3JpZENlbGw7XG4gICAgICAgICAgICB2YXIgdmlld0NlbGwgPSBldmVudC52aWV3UG9pbnQ7XG4gICAgICAgICAgICB2YXIgZHggPSBjZWxsLng7XG4gICAgICAgICAgICB2YXIgZHkgPSBjZWxsLnk7XG5cbiAgICAgICAgICAgIC8vaWYgd2UgYXJlIGluIHRoZSBmaXhlZCBhcmVhIGRvIG5vdCBhcHBseSB0aGUgc2Nyb2xsIHZhbHVlc1xuICAgICAgICAgICAgLy9jaGVjayBib3RoIHggYW5kIHkgdmFsdWVzIGluZGVwZW5kZW50bHlcbiAgICAgICAgICAgIGlmICh2aWV3Q2VsbC54IDwgbnVtRml4ZWRDb2x1bW5zKSB7XG4gICAgICAgICAgICAgICAgZHggPSB2aWV3Q2VsbC54O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodmlld0NlbGwueSA8IG51bUZpeGVkUm93cykge1xuICAgICAgICAgICAgICAgIGR5ID0gdmlld0NlbGwueTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIGRDZWxsID0gZ3JpZC5uZXdQb2ludChkeCwgZHkpO1xuXG4gICAgICAgICAgICB2YXIgcHJpbUV2ZW50ID0gZXZlbnQucHJpbWl0aXZlRXZlbnQ7XG4g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gdmFyIGRyYWdFbmRJbkZpeGVkQXJlYVggPSBsYXN0RHJhZ0NlbGwueCA8IG51bUZpeGVkQ29sdW1ucztcbiAgICAgICAgdmFyIGRyYWdFbmRJbkZpeGVkQXJlYVkgPSBsYXN0RHJhZ0NlbGwueSA8IG51bUZpeGVkUm93cztcblxuICAgICAgICBpZiAoIWRyYWdTdGFydGVkSW5IZWFkZXJBcmVhKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50RHJhZy54IDwgYi5vcmlnaW4ueCkge1xuICAgICAgICAgICAgICAgIHhPZmZzZXQgPSAtMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnREcmFnLnkgPCBiLm9yaWdpbi55KSB7XG4gICAgICAgICAgICAgICAgeU9mZnNldCA9IC0xO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmN1cnJlbnREcmFnLnggPiBiLm9yaWdpbi54ICsgYi5leHRlbnQueCkge1xuICAgICAgICAgICAgeE9mZnNldCA9IDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuY3VycmVudERyYWcueSA+IGIub3JpZ2luLnkgKyBiLmV4dGVudC55KSB7XG4gICAgICAgICAgICB5T2Zmc2V0ID0gMTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBkcmFnQ2VsbE9mZnNldFggPSB4T2Zmc2V0O1xuICAgICAgICB2YXIgZHJhZ0NlbGxPZmZzZXRZID0geU9mZnNldDtcblxuICAgICAgICBpZiAoZHJhZ0VuZEluRml4ZWRBcmVhWCkge1xuICAgICAgICAgICAgZHJhZ0NlbGxPZmZzZXRYID0gMDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChkcmFnRW5kSW5GaXhlZEFyZWFZKSB7XG4gICAgICAgICAgICBkcmFnQ2VsbE9mZnNldFkgPSAwO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5sYXN0RHJhZ0NlbGw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aWQucmVzb2x2ZVByb3BlcnR5KCdzY3JvbGxpbmdFbmFibGVkJykpIHtcbiAgICAgICAgICAgIG1heENvbHVtbnMgPSBNYXRoLm1pbihtYXhDb2x1bW5zLCBtYXhWaWV3YWJsZUNvbHVtbnMpO1xuICAgICAgICAgICAgbWF4Um93cyA9IE1hdGgubWluKG1heFJvd3MsIG1heFZpZXdhYmxlUm93cyk7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgbW91c2VDb3JuZXIgPSBncmlkLmdldE1vdXNlRG93bigpLnBsdXMoZ3JpZC5nZXREcmFnRXh0ZW50KCkpO1xuXG4gICAgICAgIHZhciBuZXdYID0gbW91c2VDb3JuZXIueCArIG9mZnNldFg7XG4gICAgICAgIHZhciBuZXdZID0gbW91c2VDb3JuZXIueSArIG9mZnNldFk7XG5cbiAgICAgICAgbmV3WCA9IE1hdGgubWluKG1heENvbHVtbnMsIE1hdGgubWF4KG1pbkNvbHMsIG5ld1gpKTtcbiAgICAgICAgbmV3WSA9IE1hdGgubWluKG1heFJvd3MsIE1hdGgubWF4KG1pblJvd3MsIG5ld1kpKTtcblxuICAgICAgICBncmlkLmNsZWFyU2VsZWN0aW9ucygpO1xuICAgICAgICBncmlkLnNlbGVjdChuZXdYLCBuZXdZLCAwLCAwKTtcbiAgICAgICAgZ3JpZC5zZXRNb3VzZURvd24oZ3JpZC5uZXdQb2ludChuZXdYLCBuZXdZKSk7XG4gICAgICAgIGdyaWQuc2V0RHJhZ0V4dGVudChncmlkLm5ld1BvaW50KDAsIDApKTtcblxuICAgICAgICBpZiAoZ3JpZC5pbnN1cmVNb2RlbENvbElzVmlzaWJsZShuZXdYLCBvZmZzZXRYKSkge1xuICAgICAgICAgICAgdGhpcy5waW5nQXV0b1Njcm9sbCgpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChncmlkLmluc3VyZU1vZGVsUm93SXNWaXNpYmxlKG5ld1ksIG9mZnNldFkpKSB7XG4gICAgICAgICAgICB0aGlzLnBpbmdBdXR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oc2VsZi5pc1dlYmtpdCA/ICctd2Via2l0LScgOiAnJykgKyAndHJhbnNmb3JtICcgKyBjb2x1bW5BbmltYXRpb25UaW1lICsgJ21zIGVhc2UnKTtcbiAgICAgICAgICAgICAgICBzZWxmLnNldENyb3NzQnJvd3NlclByb3BlcnR5KGQsICd0cmFuc2Zvcm0nLCAndHJhbnNsYXRlKCcgKyBkcmFnZ2VyU3RhcnRYICsgJ3B4LCAnICsgLTIgKyAncHgpJyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGdyaWQucmVwYWludCgpO1xuICAgICAgICAgICAgLy9uZWVkIHRvIGNoYW5nZSB0aGlzIHRvIGtleSBmcmFtZXNcblxuICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBzZWxmLnNldENyb3NzQnJvd3NlclByb3BlcnR5KGQsICd0cmFuc2l0aW9uJywgJycpO1xuICAgICAgICAgICAgICAgIGdyaWQucmVuZGVyT3ZlcnJpZGVzQ2FjaGUuZmxvYXRlciA9IG51bGw7XG4gICAgICAgICAgICAgICAgZ3JpZC5yZXBhaW50KCk7XG4gICAgICAgICAgICAgICAgc2VsZi5kb0Zsb2F0ZXJBbmltYXRpb24oZ3JpZCk7XG4gICAgICAgICAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICBkLnN0eWxlLmRpc3BsYXkgPSAnbm9uZSc7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuaXNGbG9hdGluZ05vdyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSwgY29sdW1uQW5pbWF0aW9uVGltZSArIDUwKTtcbiAgICAgICAgfTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENlbGxNb3ZpbmcucHJvdG90eXBlXG4gICAgICogQGRlc2MgbWFuaWZlc3QgdGhlIGZsb2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gICAgICAgIHZhciBpc1JpZ2h0Q2xpY2sgPSBldmVudC5wcmltaXRpdmVFdmVudC5kZXRhaWwuaXNSaWdodENsaWNrO1xuICAgICAgICB2YXIgY2VsbCA9IGV2ZW50LmdyaWRDZWxsO1xuICAgICAgICB2YXIgdmlld0NlbGwgPSBldmVudC52aWV3UG9pbnQ7XG4gICAgICAgIHZhciBkeCA9IGNlbGwueDtcbiAgICAgICAgdmFyIGR5ID0gY2VsbC55O1xuXG4gICAgICAgIHZhciBpc0hlYWRlciA9IGdyaWQuaXNTaG93SGVhZGVyUm93KCkgJiYgZHkgPT09IDAgJiYgZHggIT09IC0xO1xuXG4gICAgICAgIGlmIChpc1JpZ2h0Q2xpY2sgfHwgIWlzSGVhZGVyKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRG93bihncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcblxuICAgICAgICAgICAgLy9pZiB3ZSBhcmUgaW4gdGhlIGZpeGVkIGFyZWEgZG8gbm90IGFwcGx5IHRoZSBzY3JvbGwgdmFsdWVzXG4gICAgICAgICAgICAvL2NoZWNrIGJvdGggeCBhbmQgeSB2YWx1ZXMgaW5kZXBlbmRlbnRseVxuICAgICAgICAgICAgaWYgKHZpZXdDZWxsLnggPCBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICBkeCA9IHZpZXdDZWxsLng7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBkQ2VsbCA9IGdyaWQubmV3UG9pbnQoZHgsIDApO1xuXG4gICAgICAgICAgICB2YXIgcHJpbUV2ZW50ID0gZXZlbnQucHJpbWl0aXZlRXZlbnQ7XG4gICAgICAgICAgIC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yAgICAgZ3JpZC5yZXBhaW50KCk7XG4gICAgICAgIC8vICAgICByZXR1cm47XG4gICAgICAgIC8vIH1cblxuICAgICAgICAvLyBpZiAoIWhhc0NUUkwgJiYgIWhhc1NISUZUKSB7XG4gICAgICAgIC8vICAgICBncmlkLmNsZWFyU2VsZWN0aW9ucygpO1xuICAgICAgICAvLyB9XG5cbiAgICAgICAgaWYgKGhhc1NISUZUKSB7XG4gICAgICAgICAgICBncmlkLmNsZWFyTW9zdFJlY2VudENvbHVtblNlbGVjdGlvbigpO1xuICAgICAgICAgICAgZ3JpZC5zZWxlY3RDb2x1bW4oeCwgbW91c2VQb2ludC54KTtcbiAgICAgICAgICAgIGdyaWQuc2V0RHJhZ0V4dGVudChncmlkLm5ld1BvaW50KHggLSBtb3VzZVBvaW50LngsIDApKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGdyaWQudG9nZ2xlU2VsZWN0Q29sdW1uKHgsIGtleXMpO1xuICAgICAgICAgICAgZ3JpZC5zZXRNb3VzZURvd24oZ3JpZC5uZXdQb2ludCh4LCB5KSk7XG4gICAgICAgICAgICBncmlkLnNldERyYWdFeHRlbnQoZ3JpZC5uZXdQb2ludCgwLCAwKSk7XG4gICAgICAgIH1cbiAgICAgICAgZ3JpZC5yZXBhaW50KCk7XG4gICAgfSxcblxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENvbHVtblNlbGVjdGlvbi5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBoYW5kbGUgdGhpcyBldmVudFxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICovXG4gICAgaGFuZGxlRE9XTlNISUZUOiBmdW5jdGlvbihncmlkKSB7fSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBDb2x1bW5TZWxlY3Rpb24ucHJvdG90eXBlXG4gICAgICogQGRlc2MgaGFuZGxlIHRoaXMgZXZlbnRcbiAgICAgKiBAcGFyYW0ge0h5cGV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kgPSAnbm9uZSc7XG4gICAgICAgICAgICBncmlkLnRha2VGb2N1cygpO1xuICAgICAgICB9LCBBTklNQVRJT05fVElNRSk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBPdmVybGF5LnByb3RvdHlwZVxuICAgICAqIEBkZXNjIGluaXRpYWxpemUgbXlzZWxmIGludG8gdGhlIGdyaWRcbiAgICAgKiAjIyMjIHJldHVybnM6IHR5cGVcbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqL1xuICAgIGluaXRpYWxpemVPbjogZnVuY3Rpb24oZ3JpZCkge1xuICAgICAgICB0aGlzLmluaXRpYWxpemVPdmVybGF5U3VyZmFjZShncmlkKTtcbiAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmluaXRpYWxpemVPbihncmlkKTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgT3ZlcmxheS5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBpbml0aWFsaXplIHRoZSBvdmVybGF5IHN1cmZhY2UgaW50byB0aGUgZ3JpZFxuICAgICAqICMjIyMgcmV0dXJuczogdHlwZVxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICovXG4gICAgaW5pdGlhbGl6ZU92ZXJsYXlTdXJmYWNlOiBmdW5jdGlvbihncmlkKSB7XG4gICAgICAgIHRoaXMub3ZlcmxheSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpO1xuICAgICAgICB0aGlzLm92ZXJsYXkuc2V0QXR0cmlidXRlKCd0YWJpbmRleCcsIDApO1xuICAgICAgICB0aGlzLm92ZXJsYXkuc3R5bGUub3V0bGluZSA9ICdub25lJztcbiAgICAgICAgdGhpcy5vdmVybGF5LnN0eWxlLmJveFNoYWRvdyA9ICcwIDE5cHggMzhweCByZ2JhKDAsM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gPSBmdW5jdGlvbihwcmVkaWNhdGUpIHtcbiAgICAgICAgaWYgKHRoaXMgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ0FycmF5LnByb3RvdHlwZS5maW5kIGNhbGxlZCBvbiBudWxsIG9yIHVuZGVmaW5lZCcpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0eXBlb2YgcHJlZGljYXRlICE9PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKCdwcmVkaWNhdGUgbXVzdCBiZSBhIGZ1bmN0aW9uJyk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGxpc3QgPSBPYmplY3QodGhpcyk7XG4gICAgICAgIHZhciBsZW5ndGggPSBsaXN0Lmxlbmd0aCA+Pj4gMDtcbiAgICAgICAgdmFyIHRoaXNBcmcgPSBhcmd1bWVudHNbMV07XG4gICAgICAgIHZhciB2YWx1ZTtcblxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB2YWx1ZSA9IGxpc3RbaV07XG4gICAgICAgICAgICBpZiAocHJlZGljYXRlLmNhbGwodGhpc0FyZywgdmFsdWUsIGksIGxpc3QpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfTtcbn1cbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIGNzc0luamVjdG9yID0gcmVxdWlyZSgnY3NzLWluamVjdG9yJyk7XG5cbnZhciBzdHlsZXNoZWV0cyA9IHtcbiAgICBncmlkOiBbXG4gICAgICAgICdkaXYjZ3JpZC1jb250YWluZXIgeycsXG4gICAgICAgICcgICAgcG9zaXRpb246IHJlbGF0aXZlOycsXG4gICAgICAgICcgICAgZGlzcGxheTogaW5saW5lLWJsb2NrOycsXG4gICAgICAgICcgICAgLXdlYmtpdC11c2VyLXNlbGVjdDogbm9uZTsnLFxuICAgICAgICAnICAgIC1tb3otdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICAtbXMtdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICAtby11c2VyLXNlbGVjdDogbm9uZTsnLFxuICAgICAgICAnICAgIHVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgb3ZlcmZsb3c6IGhpZGRlbjsgfScsXG4gICAgICAgICd2aXNpYmxlIHsgb3BhY2l0eTogMC43NTsgfScsXG4gICAgICAgICdoaWRkZW4geyBvcGFjaXR5OiAwLjA7IH0nLFxuICAgICAgICAnZWRpdG9yIHsnLFxuICAgICAgICAnICAgIHBvc2l0aW9uOiBhYnNvbHV0ZTsnLFxuICAgICAgICAnICAgIGRpc3BsYXk6IG5vbmU7JyxcbiAgICAgICAgJyAgICBib3JkZXI6IHNvbGlkIDJweCBibGFjazsnLFxuICAgICAgICAnICAgIG91dGxpbmU6IDA7JyxcbiAgICAgICAgJyAgICBwYWRkaW5nOiAwOycsXG4gICAgICAgICcgICAgei1pbmRleDogMTAwMDsgfSdcbiAgICBdLFxuICAgICdsaXN0LWRyYWdvbic6IFtcbiAgICAgICAgJ2Rpdi5kcmFnb24tbGlzdCwgbGkuZHJhZ29uLXBvcCB7JyxcbiAgICAgICAgJyAgICBmb250LWZhbWlseTogUm9ib3RvLCBzYW5zLXNlcmlmOycsXG4gICAgICAgICcgICAgdGV4dC10cmFuc2Zvcm06IGNhcGl0YWxpemU7IH0nLFxuICAgICAgICAnZGl2LmRyYWdvbi1saXN0IHsnLFxuICAgICAgICAnICAgIHBvc2l0aW9uOiBhYnNvbHV0ZTsnLFxuICAgICAgICAnICAgIHRvcDogNCU7JyxcbiAgICAgICAgJyAgICBsZWZ0OiA0JTsnLFxuICAgICAgICAnICAgIGhlaWdodDogOTIlOycsXG4gICAgICAgICcgICAgd2lkdGg6IDIwJTsgfScsXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3Q6bnRoLWNoaWxkKDIpIHsgbGVmdDogMjglOyB9JyxcbiAgICAgICAgJ2Rpdi5kcmFnb24tbGlzdDpudGgtY2hpbGQoMykgeyBsZWZ0OiA1MiU7IH0nLFxuICAgICAgICAnZGl2LmRyYWdvbi1saXN0Om50aC1jaGlsZCg0KSB7IGxlZnQ6IDc2JTsgfScsXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QgPiBkaXYsIGRpdi5kcmFnb24tbGlzdCA+IHVsID4gbGksIGxpLmRyYWdvbi1wb3AgeyBsaW5lLWhlaWdodDogNDZweDsgfScsXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QgPiB1bCB7IHRvcDogNDZweDsgfScsXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QgPiB1bCA+IGxpOm5vdCg6bGFzdC1jaGlsZCk6OmJlZm9yZSwgbGkuZHJhZ29uLXBvcDo6YmVmb3JlIHsnLFxuICAgICAgICAnICAgIGNvbnRlbnQ6IFxcJ1xcXFwyYjI0XFwnOycsIC8vIEJMQUNLIExBUkdFIENJUkNMRVxuICAgICAgICAnICAgIGNvbG9yOiAjYjZiNmI2OycsXG4gICAgICAgICcgICAgZm9udC1zaXplOiAzMHB4OycsXG4gICAgICAgICcgICAgbWFyZ2luOiA4cHggMTRweCA4cHggOHB4OyB9JyxcbiAgICAgICAgJ2xpLmRyYWdvbi1wb3AgeyBvcGFjaXR5Oi44OyB9J1xuICAgIF1cbn07XG5cbmZ1bmN0aW9uIGFkZFN0eWxlc2hlZXQoa2V5LCByZWZlcmVuY2VFbGVtZW50KSB7XG4gICAgY3NzSW5qZWN0b3Ioc3R5bGVzaGVldHNba2V5XSwga2V5LCByZWZlcmVuY2VFbGVtZW50KTtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBhZGRTdHlsZXNoZWV0O1xuIl19 diff --git a/examples/autosizeissue/index.min.js b/examples/autosizeissue/index.min.js index e33ea8432..80cac7a6d 100644 --- a/examples/autosizeissue/index.min.js +++ b/examples/autosizeissue/index.min.js @@ -1,8 +1,8 @@ !function t(e,i,n){function o(s,l){if(!i[s]){if(!e[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=i[s]={exports:{}};e[s][0].call(u.exports,function(t){var i=e[s][1][t];return o(i?i:t)},u,u.exports,t,e,i,n)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s'+t.replace("mouse","")+""}),e.appendChild(n),t={},i.forEach(function(e){t[e]=n.getElementsByClassName(e)[0]})}return t},_addEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.add("listening"),window.addEventListener(t,this._bound["on"+t])},_removeEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.remove("listening"),window.removeEventListener(t,this._bound["on"+t])}};var a,u={shortStop:function(t){t.stopPropagation()},onwheel:function(t){this.index+=t[this.deltaProp],t.stopPropagation(),t.preventDefault()},onclick:function(t){var e=this.thumb.getBoundingClientRect(),i=t[this.oh.coordinate].thumb,div.finbar-vertical>.thumb{position:absolute;background-color:#d3d3d3;-webkit-box-shadow:0 0 1px #000;-moz-box-shadow:0 0 1px #000;box-shadow:0 0 1px #000;border-radius:4px;margin:2px;opacity:.4;transition:opacity .5s}div.finbar-horizontal>.thumb.hover,div.finbar-vertical>.thumb.hover{opacity:1;transition:opacity .5s}div.finbar-vertical{top:0;bottom:0;right:0;width:11px}div.finbar-vertical>.thumb{top:0;right:0;width:7px}div.finbar-horizontal{left:0;right:0;bottom:0;height:11px}div.finbar-horizontal>.thumb{left:0;bottom:0;height:7px}",e.exports=n},{"css-injector":2}],5:[function(t,e,i){"use strict";function n(t,e){var i=this;this.div=t,this._component=e,this.dragEndtime=Date.now(),this.canvas=document.createElement("canvas"),this.div.appendChild(this.canvas),this.canvas.style.outline="none",this.canvasCTX=this.canvas.getContext("2d"),this.gc=new u(this.canvasCTX),this.buffer=document.createElement("canvas"),this.bufferCTX=this.buffer.getContext("2d"),this.bufferGC=new u(this.bufferCTX),this.mouseLocation=new l.Point(-1,-1),this.dragstart=new l.Point(-1,-1),this.bounds=new l.Rectangle(0,0,0,0),this.hasMouse=!1,document.addEventListener("mousemove",function(t){(i.hasMouse||i.isDragging())&&i.finmousemove(t)}),document.addEventListener("mouseup",function(t){i.finmouseup(t)}),document.addEventListener("wheel",function(t){i.finwheelmoved(t)}),document.addEventListener("keydown",function(t){i.finkeydown(t)}),document.addEventListener("keyup",function(t){i.finkeyup(t)}),this.canvas.onmouseover=function(){i.hasMouse=!0},this.canvas.addEventListener("focus",function(t){i.finfocusgained(t)}),this.canvas.addEventListener("blur",function(t){i.finfocuslost(t)}),this.canvas.addEventListener("mousedown",function(t){i.finmousedown(t)}),this.canvas.addEventListener("mouseout",function(t){i.hasMouse=!1,i.finmouseout(t)}),this.canvas.addEventListener("click",function(t){i.finclick(t)}),this.canvas.addEventListener("contextmenu",function(t){return i.fincontextmenu(t),t.preventDefault(),!1}),a.addEventListener(this.canvas,"tap",function(t){i.fintap(t)}),a.addEventListener(this.canvas,"holdpulse",function(t){i.finholdpulse(t)}),a.addEventListener(this.canvas,"flick",function(t){i.finflick(t)}),a.addEventListener(this.canvas,"release",function(t){i.finrelease(t)}),a.addEventListener(this.canvas,"trackstart",function(t){i.fintrackstart(t)}),a.addEventListener(this.canvas,"track",function(t){i.fintrack(t)}),a.addEventListener(this.canvas,"trackend",function(t){i.fintrackend(t)}),this.canvas.setAttribute("tabindex",0),this.canvas.contentEditable=!0,this.resize(),this.beginResizing(),this.beginPainting()}function o(t){if(g){for(var e=0;ei;i++)t[i]=e;return t[27]=["ESC","ESCSHIFT"],t[192]=["`","~"],t[49]=["1","!"],t[50]=["2","@"],t[51]=["3","#"],t[52]=["4","$"],t[53]=["5","%"],t[54]=["6","^"],t[55]=["7","&"],t[56]=["8","*"],t[57]=["9","("],t[48]=["0",")"],t[189]=["-","_"],t[187]=["=","+"],t[8]=["DELETE","DELETESHIFT"],t[9]=["TAB","TABSHIFT"],t[81]=["q","Q"],t[87]=["w","W"],t[69]=["e","E"],t[82]=["r","R"],t[84]=["t","T"],t[89]=["y","Y"],t[85]=["u","U"],t[73]=["i","I"],t[79]=["o","O"],t[80]=["p","P"],t[219]=["[","{"],t[221]=["]","}"],t[220]=["\\","|"],t[220]=["CAPSLOCK","CAPSLOCKSHIFT"],t[65]=["a","A"],t[83]=["s","S"],t[68]=["d","D"],t[70]=["f","F"],t[71]=["g","G"],t[72]=["h","H"],t[74]=["j","J"],t[75]=["k","K"],t[76]=["l","L"],t[186]=[";",":"],t[222]=["'","|"],t[13]=["RETURN","RETURNSHIFT"],t[16]=["SHIFT","SHIFT"],t[90]=["z","Z"],t[88]=["x","X"],t[67]=["c","C"],t[86]=["v","V"],t[66]=["b","B"],t[78]=["n","N"],t[77]=["m","M"],t[188]=[",","<"],t[190]=[".",">"],t[191]=["/","?"],t[16]=["SHIFT","SHIFT"],t[17]=["CTRL","CTRLSHIFT"],t[18]=["ALT","ALTSHIFT"],t[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"],t[32]=["SPACE","SPACESHIFT"],t[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"],t[18]=["ALT","ALTSHIFT"],t[38]=["UP","UPSHIFT"],t[37]=["LEFT","LEFTSHIFT"],t[40]=["DOWN","DOWNSHIFT"],t[39]=["RIGHT","RIGHTSHIFT"],t[33]=["PAGEUP","PAGEUPSHIFT"],t[34]=["PAGEDOWN","PAGEDOWNSHIFT"],t[35]=["PAGERIGHT","PAGERIGHTSHIFT"],t[36]=["PAGELEFT","PAGELEFTSHIFT"],t}var l=t("rectangular"),a=t("./js/polymergestures.dev.js"),u=t("./js/GraphicsContext.js"),c=200,h=[],d=[],g=!0,f=!0,p=s();n.prototype={constructor:n.prototype.constructor,div:null,_component:null,gestures:a,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,dirty:!1,size:null,mousedown:!1,dragging:!1,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:!1,lastDoubleClickTime:0,dragEndTime:0,lastRepaintTime:0,addEventListener:function(t,e){this.canvas.addEventListener(t,e)},stopPaintLoop:function(){g=!1},restartPaintLoop:function(){g||(g=!0,requestAnimationFrame(o))},stopResizeLoop:function(){f=!1},restartResizeLoop:function(){f||(f=!0,setInterval(r,200))},detached:function(){this.stopPainting(),this.stopResizing()},useHiDPI:function(){return this._component.resolveProperty("useHiDPI")},useBitBlit:function(){return this._component.resolveProperty("useBitBlit")},getFPS:function(){var t=this._component.resolveProperty("repaintIntervalRate");return t?parseInt(t):0},tickPaint:function(t){var e=this.getFPS();if(0!==e){var i=1e3/e,n=t-this.lastRepaintTime;n>i&&this.dirty&&(this.lastRepaintTime=t-n%i,this.paintNow())}},beginPainting:function(){var t=this;this.dirty=!0,this.tickPainter=function(e){t.tickPaint(e)},h.push(this)},stopPainting:function(){h.splice(h.indexOf(this),1)},beginResizing:function(){var t=this;this.tickResizer=function(){t.checksize()},d.push(this)},stopResizing:function(){d.splice(d.indexOf(this),1)},start:function(){this.beginPainting(),this.beginResizing()},stop:function(){this.stopPainting(),this.stopResizing()},checksize:function(){var t=this.div.getBoundingClientRect();(t.width!==this.size.width||t.height!==this.size.height)&&this.sizeChangedNotification()},sizeChangedNotification:function(){this.resize()},resize:function(){var t=this.size=this.div.getBoundingClientRect();this.canvas.width=this.buffer.width=t.width,this.canvas.height=this.buffer.height=t.height;var e=1,i=this.useBitBlit(),n=window.devicePixelRatio&&this.useHiDPI();if(n){var o=window.devicePixelRatio||1,r=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;e=o/r}var s=this.canvas.getAttribute("width"),a=this.canvas.getAttribute("height");this.canvas.width=s*e,this.canvas.height=a*e,this.buffer.width=s*e,this.buffer.height=a*e,this.canvas.style.width=s+"px",this.canvas.style.height=a+"px",this.buffer.style.width=s+"px",this.buffer.style.height=a+"px",this.bufferCTX.scale(e,e),n&&!i&&this.canvasCTX.scale(e,e),this.bounds=new l.Rectangle(0,0,t.width,t.height);var u=this._component;u&&u.setBounds(this.bounds),this.resizeNotification(),this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var t=this;this.safePaintImmediately(function(e){e.clearRect(0,0,t.canvas.width,t.canvas.height);var i=t._component;i&&i._paint(e),t.dirty=!1})},safePaintImmediately:function(t){var e=this.useBitBlit(),i=e?this.bufferGC:this.gc;try{i.save(),t(i)}catch(n){console.error(n)}finally{i.restore()}e&&this.flushBuffer()},flushBuffer:function(){this.buffer.width>0&&this.buffer.height>0&&this.canvasCTX.drawImage(this.buffer,0,0)},dispatchNewEvent:function(t,e,i){return i={detail:i||{}},i.detail.primitiveEvent=t,this.canvas.dispatchEvent(new CustomEvent(e,i))},dispatchNewMouseKeysEvent:function(t,e,i){return i=i||{},i.mouse=this.mouseLocation,i.keys=this.currentKeys,this.dispatchNewEvent(t,e,i)},finmousemove:function(t){!this.isDragging()&&this.mousedown&&(this.beDragging(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragstart",{isRightClick:this.isRightClick(t)}),this.dragstart=new l.Point(this.mouseLocation.x,this.mouseLocation.y)),this.mouseLocation=this.getLocal(t),this.isDragging()&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-drag",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.bounds.contains(this.mouseLocation)&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousemove")},finmousedown:function(t){this.mouseLocation=this.getLocal(t),this.mousedown=!0,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousedown",{isRightClick:this.isRightClick(t)}),this.takeFocus()},finmouseup:function(t){this.isDragging()&&(this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragend",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.beNotDragging(),this.dragEndtime=Date.now()),this.mousedown=!1,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseup",{isRightClick:this.isRightClick(t)})},finmouseout:function(t){this.mousedown||(this.mouseLocation=new l.Point(-1,-1)),this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseout")},finwheelmoved:function(t){!this.isDragging()&&this.hasFocus()&&(t.preventDefault(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-wheelmoved",{isRightClick:this.isRightClick(t)}))},finclick:function(t){return Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-click",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},finrelease:function(t){this.holdPulseCount=0,this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-release")},finflick:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-flick",{isRightClick:this.isRightClick(t)}))},fintrackstart:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackstart"))},fintrack:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-track"))},fintrackend:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackend")},finhold:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-hold",{isRightClick:this.isRightClick(t)})},finholdpulse:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-holdpulse",{count:this.holdPulseCount++})},fintap:function(t){var e=this,i=Date.now(),n=i-this.lastDoubleClickTime;300>n||i-this.dragEndtime<100||setTimeout(function(){e._fintap(t)},180)},_fintap:function(t){var e=Date.now(),i=e-this.lastDoubleClickTime;300>i||this.dispatchNewMouseKeysEvent(t,"fin-canvas-tap",{isRightClick:this.isRightClick(t)})},findblclick:function(t){this.mouseLocation=this.getLocal(t),this.lastDoubleClickTime=Date.now(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dblclick",{isRightClick:this.isRightClick(t)})},getCharMap:function(){return p},finkeydown:function(t){if(this.hasFocus()){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];t.repeat?this.repeatKey===e?this.repeatKeyCount++:(this.repeatKey=e,this.repeatKeyStartTime=Date.now()):(this.repeatKey=null,this.repeatKeyCount=0,this.repeatKeyStartTime=0),-1===this.currentKeys.indexOf(e)&&this.currentKeys.push(e),this.dispatchNewEvent(t,"fin-canvas-keydown",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)})}},finkeyup:function(t){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(e),1),this.hasFocus()&&(this.repeatKeyCount=0,this.repeatKey=null,this.repeatKeyStartTime=0,this.dispatchNewEvent(t,"fin-canvas-keyup",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeat:t.repeat,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)}))},finfocusgained:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-gained")},finfocuslost:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-lost")},fincontextmenu:function(t){return t.ctrlKey&&-1===this.currentKeys.indexOf("CTRL")&&this.currentKeys.push("CTRL"),Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.dispatchNewMouseKeysEvent(t,"fin-canvas-context-menu",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},repaint:function(){var t=this.getFPS();this.dirty=!0,g&&0!==t||this.paintNow()},getMouseLocation:function(){return this.mouseLocation},getOrigin:function(){var t=this.canvas.getBoundingClientRect(),e=new l.Point(t.left,t.top);return e},getLocal:function(t){var e=this.canvas.getBoundingClientRect(),i=new l.Point(t.clientX-e.left,t.clientY-e.top);return i},hasFocus:function(){return document.activeElement===this.canvas},takeFocus:function(){var t=this;this.hasFocus()||setTimeout(function(){t.canvas.focus()},10)},beDragging:function(){this.dragging=!0,this.disableDocumentElementSelection()},beNotDragging:function(){this.dragging=!1,this.enableDocumentElementSelection()},isDragging:function(){return this.dragging},disableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText+"-webkit-user-select: none"},enableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText.replace("-webkit-user-select: none","")},setFocusable:function(t){this.focuser.style.display=t?"":"none"},isRightClick:function(t){var e;return t=t||window.event,"which"in t?e=3===t.which:"button"in t&&(e=2===t.button),e},dispatchEvent:function(t){return this.canvas.dispatchEvent(t)}},requestAnimationFrame(o),setInterval(r,c),e.exports=n},{"./js/GraphicsContext.js":6,"./js/polymergestures.dev.js":8,rectangular:29}],6:[function(t,e,i){"use strict";function n(t,e){function i(i){i in n.prototype||s.test(i)||("function"==typeof t[i]?r[i]=e?function(){return e(i,arguments,t[i].apply(t,arguments))}:t[i].bind(t):Object.defineProperty(r,i,{get:function(){var n=t[i];return e?e(i,"getter",n):n},set:function(n){t[i]=e?e(i,"setter",n):n}}))}this.gc=t;var r=this,s=/^webkit/;switch(typeof e){case"string":e=o.bind(void 0,e+".");break;case"boolean":e===!0&&(e=o.bind(void 0,"gc."));break;case"function":if(3!==e.length)throw"GraphicsContext: User-supplied API logger function does not accept three parameters.";break;default:e=!1}Object.keys(Object.getPrototypeOf(t)).forEach(i),Object.keys(t).forEach(i)}var o=t("./gc-console-logger");e.exports=n},{"./gc-console-logger":7}],7:[function(t,e,i){"use strict";function n(t,e,i,n){var r=n;switch("string"==typeof n&&(r='"'+r+'"'),e=t+e,i){case"getter":console.log(e,"=",r);break;case"setter":console.log(e,o,r);break;default:e+="("+Array.prototype.slice.call(i).join(", ")+")",void 0===r?console.log(e):console.log(e,o,r)}return n}var o="⟹";e.exports=n},{}],8:[function(t,e,i){!function(t){var e=!1,i=document.createElement("meta");if(i.createShadowRoot){var n=i.createShadowRoot(),o=document.createElement("span");n.appendChild(o),i.addEventListener("testpath",function(t){t.path&&(e=t.path[0]===o),t.stopPropagation()});var r=new CustomEvent("testpath",{bubbles:!0});document.head.appendChild(i),o.dispatchEvent(r),i.parentNode.removeChild(i),n=o=null}i=null;var s={shadow:function(t){return t?t.shadowRoot||t.webkitShadowRoot:void 0},canTarget:function(t){return t&&Boolean(t.elementFromPoint)},targetingShadow:function(t){var e=this.shadow(t);return this.canTarget(e)?e:void 0},olderShadow:function(t){var e=t.olderShadowRoot;if(!e){var i=t.querySelector("shadow");i&&(e=i.olderShadowRoot)}return e},allShadows:function(t){for(var e=[],i=this.shadow(t);i;)e.push(i),i=this.olderShadow(i);return e},searchRoot:function(t,e,i){var n,o;return t?(n=t.elementFromPoint(e,i),n?o=this.targetingShadow(n):t!==document&&(o=this.olderShadow(t)),this.searchRoot(o,e,i)||n):void 0},owner:function(t){if(!t)return document;for(var e=t;e.parentNode;)e=e.parentNode;return e.nodeType!=Node.DOCUMENT_NODE&&e.nodeType!=Node.DOCUMENT_FRAGMENT_NODE&&(e=document),e},findTarget:function(t){if(e&&t.path&&t.path.length)return t.path[0];var i=t.clientX,n=t.clientY,o=this.owner(t.target);return o.elementFromPoint(i,n)||(o=document),this.searchRoot(o,i,n)},findTouchAction:function(t){var i;if(e&&t.path&&t.path.length){for(var n=t.path,o=0;o=0?t=this.walk(t,o):e=this.walk(e,-o);t&&e&&t!==e;)t=t.parentNode||t.host,e=e.parentNode||e.host;return t},walk:function(t,e){for(var i=0;t&&e>i;i++)t=t.parentNode||t.host;return t},depth:function(t){for(var e=0;t;)e++,t=t.parentNode||t.host;return e},deepContains:function(t,e){var i=this.LCA(t,e);return i===t},insideNode:function(t,e,i){var n=t.getBoundingClientRect();return n.left<=e&&e<=n.right&&n.top<=i&&i<=n.bottom},path:function(t){var i;if(e&&t.path&&t.path.length)i=t.path;else{i=[];for(var n=this.findTarget(t);n;)i.push(n),n=n.parentNode||n.host}return i}};t.targetFinding=s,t.findTarget=s.findTarget.bind(s),t.deepContains=s.deepContains.bind(s),t.insideNode=s.insideNode}(i),function(){function t(t){return"html /deep/ "+e(t)}function e(t){return'[touch-action="'+t+'"]'}function i(t){return"{ -ms-touch-action: "+t+"; touch-action: "+t+";}"}var n=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],o="",r="string"==typeof document.head.style.touchAction,s=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(r){n.forEach(function(n){String(n)===n?(o+=e(n)+i(n)+"\n",s&&(o+=t(n)+i(n)+"\n")):(o+=n.selectors.map(e)+i(n.rule)+"\n",s&&(o+=n.selectors.map(t)+i(n.rule)+"\n"))});var l=document.createElement("style");l.textContent=o,document.head.appendChild(l)}}(),function(t){var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],i=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],n=function(){return function(){}},o={preventTap:n,makeBaseEvent:function(t,e){var i=document.createEvent("Event");return i.initEvent(t,e.bubbles||!1,e.cancelable||!1),i.preventTap=o.preventTap(i),i},makeGestureEvent:function(t,e){e=e||Object.create(null);for(var i,n=this.makeBaseEvent(t,e),o=0,r=Object.keys(e);o-1?this.values[i]=e:(this.keys.push(t),this.values.push(e))},has:function(t){return this.keys.indexOf(t)>-1},"delete":function(t){var e=this.keys.indexOf(t);e>-1&&(this.keys.splice(e,1),this.values.splice(e,1))},get:function(t){var e=this.keys.indexOf(t);return this.values[e]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(t,e){this.values.forEach(function(i,n){t.call(e,i,this.keys[n],this)},this)},pointers:function(){return this.keys.length}},t.PointerMap=e}(i),function(t){var e,i=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],n=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],o="undefined"!=typeof SVGElementInstance,r=t.eventFactory,s={IS_IOS:!1,pointermap:new t.PointerMap,requiredGestures:new t.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(t,e){var i=e,n=i.events;n&&(n.forEach(function(t){i[t]&&(this.eventMap[t]=i[t].bind(i))},this),this.eventSources[t]=i,this.eventSourceList.push(i))},registerGesture:function(t,e){var i=Object.create(null);i.listeners=0,i.index=this.gestures.length;for(var n,o=0;oo&&(i=this.eventSourceList[o]);o++)i.register.call(i,t,e)},unregister:function(t){for(var e,i=this.eventSourceList.length,n=0;i>n&&(e=this.eventSourceList[n]);n++)e.unregister.call(e,t)},down:function(t){this.requiredGestures.set(t.pointerId,e),this.fireEvent("down",t)},move:function(t){t.type="move",this.fillGestureQueue(t)},up:function(t){this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},cancel:function(t){t.tapPrevented=!0,this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},addGestureDependency:function(t,e){var i=t._pgEvents;if(i&&e)for(var n,o,r,s=Object.keys(i),l=0;l0&&(n=this.dependencyMap[r],o=n?n.index:-1,e[o]=!0)},eventHandler:function(i){var n=i.type;if("touchstart"===n||"mousedown"===n||"pointerdown"===n||"MSPointerDown"===n)if(i._handledByPG||(e={}),this.IS_IOS){var o=i;if("touchstart"===n){var r=i.changedTouches[0];o={target:i.target,clientX:r.clientX,clientY:r.clientY,path:i.path}}for(var s,l=i.path||t.targetFinding.path(o),a=0;an&&(i=e[n]);n++)this.addEvent(t,i)},unlisten:function(t,e){for(var i,n=0,o=e.length;o>n&&(i=e[n]);n++)this.removeEvent(t,i)},addEvent:function(t,e){t.addEventListener(e,this.boundHandler)},removeEvent:function(t,e){t.removeEventListener(e,this.boundHandler)},makeEvent:function(t,e){var i=r.makePointerEvent(t,e);return i.preventDefault=e.preventDefault,i.tapPrevented=e.tapPrevented,i._target=i._target||e.target,i},fireEvent:function(t,e){var i=this.makeEvent(t,e);return this.dispatchEvent(i)},cloneEvent:function(t){for(var e,r=Object.create(null),s=0;s0&&t._pgListeners--,0===t._pgListeners&&s.unregister(t),t._pgEvents&&(t._pgEvents[i]>0?t._pgEvents[i]--:t._pgEvents[i]=0)),Boolean(n)},t.removeEventListener=function(e,i,n,o){n&&(t.deactivateGesture(e,i),e.removeEventListener(i,n,o))}}(i),function(t){var e=t.dispatcher,i=e.pointermap,n=25,o=[0,1,4,2],r=0,s=/Linux.*Firefox\//i,l=function(){if(s.test(navigator.userAgent))return!1;try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}(),a={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(t){for(var e,i=this.lastTouches,o=t.clientX,r=t.clientY,s=0,l=i.length;l>s&&(e=i[s]);s++){var a=Math.abs(o-e.x),u=Math.abs(r-e.y);if(n>=a&&n>=u)return!0}},prepareEvent:function(t){var i=e.cloneEvent(t);if(i.pointerId=this.POINTER_ID,i.isPrimary=!0,i.pointerType=this.POINTER_TYPE,i._source="mouse",!l){var n=t.type,s=o[t.which]||0;"mousedown"===n?r|=s:"mouseup"===n&&(r&=~s),i.buttons=r}return i},mousedown:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=(i.has(this.POINTER_ID),this.prepareEvent(n));o.target=t.findTarget(n),i.set(this.POINTER_ID,o.target),e.down(o)}},mousemove:function(t){if(!this.isEventSimulatedFromTouch(t)){var n=i.get(this.POINTER_ID);if(n){var o=this.prepareEvent(t);o.target=n,0===(l?o.buttons:o.which)?(l||(r=o.buttons=0),e.cancel(o),this.cleanupMouse(o.buttons)):e.move(o)}}},mouseup:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(this.POINTER_ID),e.up(o),this.cleanupMouse(o.buttons)}},cleanupMouse:function(t){0===t&&i["delete"](this.POINTER_ID)}};t.mouseEvents=a}(i),function(t){var e=t.dispatcher,i=(t.targetFinding.allShadows.bind(t.targetFinding),e.pointermap),n=(Array.prototype.map.call.bind(Array.prototype.map),2500),o=25,r=200,s=20,l=!1,a={IS_IOS:!1,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(t,i){(this.IS_IOS?i:!i)&&e.listen(t,this.events)},unregister:function(t){this.IS_IOS||e.unlisten(t,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(t){var e=t,i=this.scrollTypes;return e===i.EMITTER?"none":e===i.XSCROLLER?"X":e===i.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(t){return this.firstTouch===t.identifier},setPrimaryTouch:function(t){(0===i.pointers()||1===i.pointers()&&i.has(1))&&(this.firstTouch=t.identifier,this.firstXY={X:t.clientX,Y:t.clientY},this.firstTarget=t.target,this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(t){t.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var t=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(t,r)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(t){var e=0;return("touchstart"===t||"touchmove"===t)&&(e=1),e},findTarget:function(e,n){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(e)){var o={clientX:e.clientX,clientY:e.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return t.findTarget(o)}return t.findTarget(e)}return i.get(n)},touchToPointer:function(t){var i=this.currentTouchEvent,n=e.cloneEvent(t),o=n.pointerId=t.identifier+2;n.target=this.findTarget(t,o),n.bubbles=!0,n.cancelable=!0,n.detail=this.clickCount,n.buttons=this.typeToButtons(i.type),n.width=t.webkitRadiusX||t.radiusX||0,n.height=t.webkitRadiusY||t.radiusY||0,n.pressure=t.webkitForce||t.force||.5,n.isPrimary=this.isPrimaryTouch(t),n.pointerType=this.POINTER_TYPE,n._source="touch";var r=this;return n.preventDefault=function(){r.scrolling=!1,r.firstXY=null,i.preventDefault()},n},processTouches:function(t,e){var n=t.changedTouches;this.currentTouchEvent=t;for(var o,r,s=0;s=u}return i}},findTouch:function(t,e){for(var i,n=0,o=t.length;o>n&&(i=t[n]);n++)if(i.identifier===e)return!0},vacuumTouches:function(t){var e=t.touches;if(i.pointers()>=e.length){var n=[];i.forEach(function(t,i){if(1!==i&&!this.findTouch(e,i-2)){var o=t;n.push(o)}},this),n.forEach(function(t){this.cancel(t),i["delete"](t.pointerId)},this)}},touchstart:function(t){this.vacuumTouches(t),this.setPrimaryTouch(t.changedTouches[0]),this.dedupSynthMouse(t),this.scrolling||(this.clickCount++,this.processTouches(t,this.down))},down:function(t){e.down(t)},touchmove:function(t){if(l)t.cancelable&&this.processTouches(t,this.move);else if(this.scrolling){if(this.firstXY){var e=t.changedTouches[0],i=e.clientX-this.firstXY.X,n=e.clientY-this.firstXY.Y,o=Math.sqrt(i*i+n*n);o>=s&&(this.touchcancel(t),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(t)?this.scrolling=!0:(this.scrolling=!1,t.preventDefault(),this.processTouches(t,this.move))},move:function(t){e.move(t)},touchend:function(t){this.dedupSynthMouse(t),this.processTouches(t,this.up)},up:function(i){i.relatedTarget=t.findTarget(i),e.up(i)},cancel:function(t){e.cancel(t)},touchcancel:function(t){t._cancel=!0,this.processTouches(t,this.cancel)},cleanUpPointer:function(t){i["delete"](t.pointerId),this.removePrimaryPointer(t)},dedupSynthMouse:function(e){var i=t.mouseEvents.lastTouches,o=e.changedTouches[0];if(this.isPrimaryTouch(o)){var r={x:o.clientX,y:o.clientY};i.push(r);var s=function(t,e){var i=t.indexOf(e);i>-1&&t.splice(i,1)}.bind(null,i,r);setTimeout(s,n)}}},u=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(e){var i=e.clientX,n=e.clientY,r=function(t){var e=Math.abs(i-t.x),r=Math.abs(n-t.y);return o>=e&&o>=r},s=t.mouseEvents.lastTouches.some(r),l=t.targetFinding.path(e);if(s){for(var c=0;c0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],9:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataNodeBase",{isNullObject:!1,INDENT:" ",initialize:function(t){this.label=t,this.data=[""],this.index=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1},getValue:function(t){return this.data[t]},prune:function(t){this.depth=t,this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+" "+this.label},computeHeight:function(){return 1},getIndex:function(){return this.index},computeAggregates:function(t){var e=this.getIndex();if(e.length){var i=Number(t.hasGroups()),n=this.data;n.length=i+t.aggregates.length;var o=t.sorterInstance;o.index=e,t.aggregates.forEach(function(t,e){n[i+e]=t(o)})}},buildView:function(t){t.addView(this)},toggleExpansionState:function(){}});e.exports=o},{"extend-me":3}],10:[function(t,e,i){"use strict";function n(t){return this.splice.bind(this,this.length,0).apply(this,t),this}var o=t("./util/Mappy"),r=t("./DataNodeBase"),s={"true":"▼","false":"▶"},l=r.extend("DataNodeGroup",{extendable:!0,initialize:function(t){this.children=new o},prune:function(t){this.depth=t,this.children=this.children.values,this.children.forEach(function(e){e.prune(t+1)}),this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+s[this.expanded]+" "+this.label},getIndex:function(){return 0===this.index.length&&(this.index=this.computeIndex()),this.index},computeIndex:function(){var t=[];return t.append=n,this.children.forEach(function(e){t.append(e.getIndex())}),t},toggleExpansionState:function(t){this.expanded=!this.expanded,this.data[0]=this.computeDepthString(),this.expanded&&this.computeAggregates(t)},computeAggregates:function(t){r.prototype.computeAggregates.call(this,t),this.expanded&&this.children.forEach(function(e){e.computeAggregates(t)})},buildView:function(t){t.view.push(this),this.expanded&&this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.expanded&&this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=l},{"./DataNodeBase":9,"./util/Mappy":21}],11:[function(t,e,i){"use strict";var n=t("./DataNodeBase"),o=n.extend("DataNodeLeaf",{prune:function(t){this.depth=t,this.data[0]=this.computeDepthString()},getIndex:function(){return this.index},buildView:function(t){t.addView(this)},computeHeight:function(){return 1}});e.exports=o},{"./DataNodeBase":9}],12:[function(t,e,i){"use strict";var n=t("./DataNodeGroup"),o=n.extend("DataNodeTree",{initialize:function(t){this.height=0,this.expanded=!0},prune:function(){this.children=this.children.values,this.children.forEach(function(t){t.prune(0)})},buildView:function(t){this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=o},{"./DataNodeGroup":10}],13:[function(t,e,i){"use strict";function n(t,e){this.fields=e||r(t[0]),this.data=t}function o(t,e){throw new Error("DataSource."+t+": "+e)}function r(t){if(!t)return[];var e=[].concat(Object.getOwnPropertyNames(t).filter(function(t){return"__"!==t.substr(0,2)}));return e}var s=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,getRow:function(t){return this.data[t]},getValue:function(t,e){var i=this.getRow(e);return i?i[this.fields[t]]:null},setValue:function(t,e,i){this.getRow(e)[this.fields[t]]=i},getRowCount:function(){return this.data.length},getColumnCount:function(){return this.getFields().length},getFields:function(){return this.fields},getHeaders:function(){return this.headers=this.headers||this.getDefaultHeaders().map(function(t){return s(t)})},getDefaultHeaders:function(){return this.getFields()},setFields:function(t){this.fields=t},setHeaders:function(t){t instanceof Array||o("setHeaders","param #1 `headers` not array"),this.headers=t},getGrandTotals:function(){},setData:function(t){this.data=t}},e.exports=n},{"./util/headerify":23}],14:[function(t,e,i){"use strict";function n(t){this.dataSource=t,this.tree=new l("Totals"),this.index=[],this.aggregates=[],this.headers=[],this.groupBys=[],this.view=[],this.sorterInstance={},this.presortGroups=!0,this.lastAggregate={},this.setAggregates({})}function o(t,e,i){var n=new t(e);return i.set(e,n),n}var r=t("object-iterators"),s=t("./DataSourceSorter"),l=t("./DataNodeTree"),a=t("./DataNodeGroup"),u=t("./DataNodeLeaf"),c=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,setAggregates:function(t){this.lastAggregate=t,this.clearAggregations(),this.headers.length=0,this.hasGroups()&&this.headers.push("Tree");var e=this;r(t).each(function(t,i){e.addAggregate(i,t)})},addAggregate:function(t,e){this.headers.push(c(t)),this.aggregates.push(e)},setGroupBys:function(t){var e=this.groupBys;e.length=0,t.forEach(function(t){e.push(t)}),this.setAggregates(this.lastAggregate)},addGroupBy:function(t){this.groupBys.push(t)},hasGroups:function(){return!!this.groupBys.length},hasAggregates:function(){return!!this.aggregates.length},apply:function(){this.buildGroupTree()},clearGroups:function(){this.groupBys.length=0},clearAggregations:function(){this.aggregates.length=0,this.headers.length=0},buildGroupTree:function(){var t=this.groupBys,e=t.length-1,i=this.dataSource,n=i.getRowCount(),r=this.tree=new l("Totals");this.presortGroups&&t.reverse().forEach(function(t){i=new s(i),i.sortOn(t)});for(var c=0;n>c;c++){var h=r;t.forEach(function(t,n){var r=i.getValue(t,c),s=n===e,l=s?u:a,d=o.bind(this,l);h=h.children.getIfAbsent(r,d)}),h.index.push(c)}this.sorterInstance=new s(i),r.prune(),r.computeAggregates(this),this.buildView()},addView:function(t){this.view.push(t)},buildView:function(){this.view.length=0,this.tree.computeHeight(),this.tree.buildView(this)},viewMakesSense:function(){return this.hasAggregates()},getValue:function(t,e){if(!this.viewMakesSense())return this.dataSource.getValue(t,e);var i=this.view[e];return i?i.getValue(t):null},setValue:function(t,e,i){return this.viewMakesSense()?void 0:this.dataSource.setValue(t,e,i)},getColumnCount:function(){return this.viewMakesSense()?this.getHeaders().length:this.dataSource.getColumnCount()},getRowCount:function(){return this.viewMakesSense()?this.view.length:this.dataSource.getRowCount()},click:function(t){var e=this.view[t];e.toggleExpansionState(this),this.buildView()},getHeaders:function(){return this.viewMakesSense()?this.headers:this.dataSource.getHeaders()},setHeaders:function(t){this.dataSource.setHeaders(t)},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},getGrandTotals:function(){var t=this.tree;return[t.data]},getRow:function(t){if(!this.viewMakesSense())return this.dataSource.getRow(t);var e=this.view[t];return e?e:this.tree},setData:function(t){this.dataSource.setData(t),this.apply()}},e.exports=n},{"./DataNodeGroup":10,"./DataNodeLeaf":11,"./DataNodeTree":12,"./DataSourceSorter":18,"./util/headerify":23,"object-iterators":28}],15:[function(t,e,i){"use strict";function n(t,e){var i=this;return!this.filters.find(function(n){return!n(i.dataSource.getValue(n.columnIndex,t),e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceFilter",{initialize:function(){this.filters=[]},add:function(t,e){e.columnIndex=t,this.filters.push(e)},clearAll:function(){this.filters.length=0,this.clearIndex()},applyAll:function(){this.filters.length?this.buildIndex(n):this.clearIndex()},getRowCount:function(){return this.filters.length?this.index.length:this.dataSource.getRowCount()},aliases:{set:"add"}});e.exports=r},{"./DataSourceIndexed":17}],16:[function(t,e,i){"use strict";function n(t,e){var i=this;return this.visibleColumnMap.find(function(n,o){var r=i.dataSource.getValue(n,t);return i.filter(r,e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceGlobalFilter",{set:function(t){this.filter=t},clear:function(){delete this.filter,this.clearIndex()},apply:function(t){if(this.filter){var e=this.visibleColumnMap=[];t.forEach(function(t){e.push(t.index)}),this.buildIndex(n)}else this.clearIndex()},getRowCount:function(){return this.filter?this.index.length:this.dataSource.getRowCount()}});e.exports=r},{"./DataSourceIndexed":17}],17:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataSourceIndexed",{isNullObject:!1,initialize:function(t){this.dataSource=t,this.index=[]},transposeY:function(t){return this.index.length?this.index[t]:t},getRow:function(t){return this.dataSource.getRow(this.transposeY(t))},getValue:function(t,e){return this.dataSource.getValue(t,this.transposeY(e))},setValue:function(t,e,i){this.dataSource.setValue(t,this.transposeY(e),i)},getRowCount:function(){return this.index.length||this.dataSource.getRowCount()},getColumnCount:function(){return this.dataSource.getColumnCount()},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},setHeaders:function(t){return this.dataSource.setHeaders(t)},getHeaders:function(){return this.dataSource.getHeaders()},getGrandTotals:function(){return this.dataSource.getGrandTotals()},setData:function(t){return this.dataSource.setData(t)},clearIndex:function(){this.index.length=0},buildIndex:function(t){var e=this.dataSource.getRowCount(),i=this.index;this.clearIndex();for(var n=0;e>n;n++)(!t||t.call(this,n,this.dataSource.getRow(n)))&&i.push(n);return i}});e.exports=o},{"extend-me":3}],18:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}var o=t("./DataSourceIndexed"),r=t("./util/stableSort"),s=o.extend("DataSourceSorter",{initialize:function(){this.descendingSort=!1},sortOn:function(t,e){function i(e){return n(o.dataSource.getValue(t,e))}switch(e){case 0:this.clearIndex();break;case void 0:case 1:case-1:var o=this;r.sort(this.buildIndex(),i,e)}}});e.exports=s},{"./DataSourceIndexed":17,"./util/stableSort":24}],19:[function(t,e,i){"use strict";var n=t("./DataSourceIndexed"),o=t("./DataSourceSorter"),r=n.extend("DataSourceSorterComposite",{initialize:function(){this.sorts=[],this.last=this.dataSource},sortOn:function(t,e){this.sorts.push([t,e])},applySorts:function(){var t=this.dataSource;this.sorts.forEach(function(e){t=new o(t),t.sortOn.apply(t,e)}),this.last=t},clearSorts:function(){this.sorts.length=0,this.last=this.dataSource},getValue:function(t,e){return this.last.getValue(t,e)},setValue:function(t,e,i){this.last.setValue(t,e,i)}});e.exports=r},{"./DataSourceIndexed":17,"./DataSourceSorter":18}],20:[function(t,e,i){"use strict";e.exports={JSDataSource:t("./DataSource"),DataSourceSorter:t("./DataSourceSorter"),DataSourceSorterComposite:t("./DataSourceSorterComposite"),DataSourceFilter:t("./DataSourceFilter"),DataSourceGlobalFilter:t("./DataSourceGlobalFilter"),DataSourceAggregator:t("./DataSourceAggregator"),util:{aggregations:t("./util/aggregations")}}},{"./DataSource":13,"./DataSourceAggregator":14,"./DataSourceFilter":15,"./DataSourceGlobalFilter":16,"./DataSourceSorter":18,"./DataSourceSorterComposite":19,"./util/aggregations":22}],21:[function(t,e,i){"use strict";function n(){this.keys=[],this.data={},this.values=[]}function o(t){var e=typeof t;switch(e){case"number":case"string":case"boolean":case"symbol":return s+e+"_"+t;case"undefined":return s+"undefined";case"object":case"function":return t.___finhash=t.___finhash||s+l++}}function r(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!a(t[i],e););else i=[].indexOf.call(t,e);return i}n.prototype={constructor:n.prototype.constructor,set:function(t,e){var i=o(t);i in this.data||(this.keys.push(t),this.values.push(e)),this.data[i]=e},get:function(t){var e=o(t);return this.data[e]},getIfAbsent:function(t,e){var i=this.get(t);return void 0===i&&(i=e(t,this)),i},size:function(){return this.keys.length},clear:function(){this.keys.length=0,this.data={}},"delete":function(t){var e=o(t);if(void 0!==this.data[e]){var i=r(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},forEach:function(t){var e=this.keys,i=this;e.forEach(function(e){var n=i.get(e);t(n,e,i)})},map:function(t){var e=this.keys,i=new n,o=this;return e.forEach(function(e){var n=o.get(e),r=t(n,e,o);i.set(e,r)}),i},copy:function(){var t=this.keys,e=new n,i=this;return t.forEach(function(t){var n=i.get(t);e.set(t,n)}),e}};var s=".~.#%_",l=0,a=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t){return t.getRowCount()}function o(t,e){for(var i=e.getRowCount(),n=0;i--;)n+=e.getValue(t,i);return n}function r(t,e,i,n){for(var o=n.getRowCount();o--;)i=e(i,n.getValue(t,o));return i}function s(t,e){return o(t,e)/e.getRowCount()}function l(t,e){return e.getValue(t,0)}function a(t,e){return e.getValue(t,e.getRowCount()-1)}function u(t,e){for(var i,n=e.getRowCount(),o=s(t,e),r=n,l=0;r--;l+=i*i)i=e.getValue(t,r)-o;return Math.sqrt(l/n)}e.exports={count:function(t){return n},sum:function(t){return o.bind(this,t)},min:function(t){return r.bind(this,t,Math.min,1/0)},max:function(t){return r.bind(this,t,Math.max,-(1/0))},avg:function(t){return s.bind(this,t)},first:function(t){return l.bind(this,t)},last:function(t){return a.bind(this,t)},stddev:function(t){return u.bind(this,t)}}},{}],23:[function(t,e,i){"use strict";function n(t){return(/[a-z]/.test(t)?t:t.toLowerCase()).replace(/[\s\-_]*([^\s\-_])([^\s\-_]+)/g,o).replace(/[A-Z]/g," $&").trim()}function o(t,e,i){return e.toUpperCase()+i}e.exports=n},{}],24:[function(t,e,i){"use strict";function n(t,e,i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}function o(t,e){return t-e}function r(t,e){return e-t}function s(t,e){return e>t?-1:1}function l(t,e){return t>e?-1:1}function a(t){return n.bind(this,"number"===t?o:s,!1)}function u(t){return n.bind(this,"number"===t?r:l,!0)}function c(t,e,i){var n,o;if(void 0===i&&(i=1),t.length){switch(i){case 0:return;case void 0:i=1;case 1:n=a(typeof e(0));break;case-1:n=u(typeof e(0))}var r=new Array(t.length);for(o=0;op&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=A.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+A.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),A=t("templex"),C=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:w[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=C,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=C,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=C;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":2,templex:31}],26:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0), -this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.0",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return e=e||i,Object.keys(i).forEach(function(n){t.call(e,i[n],n,i)}),this},find:function(t,e){var i=this.o;e=e||i;var n=Object.keys(i).find(function(n){return t.call(e,i[n],n,i)});return void 0===n?void 0:i[n]},reduce:function(t,e,i){var n=this.o;return i=i||n,Object.keys(n).forEach(function(o,r){e=r||void 0!==e?t.call(i,e,n[o],o,n):n[o]}),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(),this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix(); -return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0, -this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n), -o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file +events:["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},POINTER_TYPES:["","unavailable","touch","pen","mouse"],prepareEvent:function(t){var i=t;return i=e.cloneEvent(t),n&&(i.pointerType=this.POINTER_TYPES[t.pointerType]),i._source="ms",i},cleanup:function(t){i["delete"](t)},MSPointerDown:function(n){var o=this.prepareEvent(n);o.target=t.findTarget(n),i.set(n.pointerId,o.target),e.down(o)},MSPointerMove:function(t){var n=i.get(t.pointerId);if(n){var o=this.prepareEvent(t);o.target=n,e.move(o)}},MSPointerUp:function(n){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(o.pointerId),e.up(o),this.cleanup(n.pointerId)},MSPointerCancel:function(n){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(o.pointerId),e.cancel(o),this.cleanup(n.pointerId)}};t.msEvents=o}(i),function(t){var e=t.dispatcher,i=e.pointermap,n={events:["pointerdown","pointermove","pointerup","pointercancel"],prepareEvent:function(t){var i=e.cloneEvent(t);return i._source="pointer",i},register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},cleanup:function(t){i["delete"](t)},pointerdown:function(n){var o=this.prepareEvent(n);o.target=t.findTarget(n),i.set(o.pointerId,o.target),e.down(o)},pointermove:function(t){var n=i.get(t.pointerId);if(n){var o=this.prepareEvent(t);o.target=n,e.move(o)}},pointerup:function(n){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(o.pointerId),e.up(o),this.cleanup(n.pointerId)},pointercancel:function(n){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(o.pointerId),e.cancel(o),this.cleanup(n.pointerId)}};t.pointerEvents=n}(i),function(t){var e=t.dispatcher,i=window.navigator;window.PointerEvent?e.registerSource("pointer",t.pointerEvents):i.msPointerEnabled?e.registerSource("ms",t.msEvents):(e.registerSource("mouse",t.mouseEvents),void 0!==window.ontouchstart&&e.registerSource("touch",t.touchEvents));var n=navigator.userAgent,o=n.match(/iPad|iPhone|iPod/)&&"ontouchstart"in window;e.IS_IOS=o,t.touchEvents.IS_IOS=o,e.register(document,!0)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","move","up"],exposes:["trackstart","track","trackx","tracky","trackend"],defaultActions:{track:"none",trackx:"pan-y",tracky:"pan-x"},WIGGLE_THRESHOLD:4,clampDir:function(t){return t>0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],9:[function(t,e,i){"use strict";e.exports={JSDataSource:t("./js/DataSource"),DataSourceSorter:t("./js/DataSourceSorter"),DataSourceSorterComposite:t("./js/DataSourceSorterComposite"),DataSourceFilter:t("./js/DataSourceFilter"),DataSourceGlobalFilter:t("./js/DataSourceGlobalFilter"),DataSourceAggregator:t("./js/DataSourceAggregator"),util:{aggregations:t("./js/util/aggregations")}}},{"./js/DataSource":14,"./js/DataSourceAggregator":15,"./js/DataSourceFilter":16,"./js/DataSourceGlobalFilter":17,"./js/DataSourceSorter":19,"./js/DataSourceSorterComposite":20,"./js/util/aggregations":22}],10:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataNodeBase",{isNullObject:!1,INDENT:" ",initialize:function(t){this.label=t,this.data=[""],this.index=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1},getValue:function(t){return this.data[t]},toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+" "+this.label},computeHeight:function(){return 1},getIndex:function(){return this.index},computeAggregates:function(t){var e=this.getIndex();if(e.length){var i=Number(t.hasGroups()),n=this.data;n.length=i+t.aggregates.length;var o=t.sorterInstance;o.index=e,t.aggregates.forEach(function(t,e){n[i+e]=t(o)})}},buildView:function(t){t.addView(this)},toggleExpansionState:function(){}});e.exports=o},{"extend-me":3}],11:[function(t,e,i){"use strict";function n(t){return this.splice.bind(this,this.length,0).apply(this,t),this}var o=t("./util/Mappy"),r=t("./DataNodeBase"),s={"true":"▼","false":"▶"},l=r.extend("DataNodeGroup",{extendable:!0,initialize:function(t){this.children=new o},toArray:function(t){this.depth=t,this.children=this.children.values,this.children.forEach(function(e){e.toArray(t+1)}),this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+s[this.expanded]+" "+this.label},getIndex:function(){return 0===this.index.length&&(this.index=this.computeIndex()),this.index},computeIndex:function(){var t=[];return t.append=n,this.children.forEach(function(e){t.append(e.getIndex())}),t},toggleExpansionState:function(t){this.expanded=!this.expanded,this.data[0]=this.computeDepthString(),this.expanded&&this.computeAggregates(t)},computeAggregates:function(t){r.prototype.computeAggregates.call(this,t),this.expanded&&this.children.forEach(function(e){e.computeAggregates(t)})},buildView:function(t){t.view.push(this),this.expanded&&this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.expanded&&this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=l},{"./DataNodeBase":10,"./util/Mappy":21}],12:[function(t,e,i){"use strict";var n=t("./DataNodeBase"),o=n.extend("DataNodeLeaf",{toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},getIndex:function(){return this.index},buildView:function(t){t.addView(this)},computeHeight:function(){return 1}});e.exports=o},{"./DataNodeBase":10}],13:[function(t,e,i){"use strict";var n=t("./DataNodeGroup"),o=n.extend("DataNodeTree",{initialize:function(t){this.height=0,this.expanded=!0},toArray:function(){this.children=this.children.values,this.children.forEach(function(t){t.toArray(0)})},buildView:function(t){this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=o},{"./DataNodeGroup":11}],14:[function(t,e,i){"use strict";function n(t,e){this.fields=e||r(t[0]),this.data=t}function o(t,e){throw new Error("DataSource."+t+": "+e)}function r(t){return Object.getOwnPropertyNames(t||[]).filter(function(t){return"__"!==t.substr(0,2)})}var s=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,getRow:function(t){return this.data[t]},getValue:function(t,e){var i=this.getRow(e);return i?i[this.fields[t]]:null},setValue:function(t,e,i){this.getRow(e)[this.fields[t]]=i},getRowCount:function(){return this.data.length},getColumnCount:function(){return this.getFields().length},getFields:function(){return this.fields},getHeaders:function(){return this.headers=this.headers||this.getDefaultHeaders().map(function(t){return s(t)})},getDefaultHeaders:function(){return this.getFields()},setFields:function(t){this.fields=t},setHeaders:function(t){t instanceof Array||o("setHeaders","param #1 `headers` not array"),this.headers=t},getGrandTotals:function(){},setData:function(t){this.data=t}},e.exports=n},{"./util/headerify":23}],15:[function(t,e,i){"use strict";function n(t){this.dataSource=t,this.tree=new l("Totals"),this.index=[],this.aggregates=[],this.headers=[],this.groupBys=[],this.view=[],this.sorterInstance={},this.presortGroups=!0,this.lastAggregate={},this.setAggregates({})}function o(t){return new u(t)}function r(t){return new a(t)}var s=t("./DataSourceSorter"),l=t("./DataNodeTree"),a=t("./DataNodeGroup"),u=t("./DataNodeLeaf"),c=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,setAggregates:function(t){this.lastAggregate=t,this.clearAggregations(),this.headers.length=0,this.hasGroups()&&this.headers.push("Tree");for(var e in t)this.addAggregate(e,t[e])},addAggregate:function(t,e){this.headers.push(c(t)),this.aggregates.push(e)},setGroupBys:function(t){var e=this.groupBys;e.length=0,t.forEach(function(t){e.push(t)}),this.setAggregates(this.lastAggregate)},addGroupBy:function(t){this.groupBys.push(t)},hasGroups:function(){return!!this.groupBys.length},hasAggregates:function(){return!!this.aggregates.length},apply:function(){this.buildGroupTree()},clearGroups:function(){this.groupBys.length=0},clearAggregations:function(){this.aggregates.length=0,this.headers.length=0},buildGroupTree:function(){var t=this.groupBys,e=t.length-1,i=this.dataSource,n=i.getRowCount(),a=this.tree=new l("Totals");this.presortGroups&&t.reverse().forEach(function(t){i=new s(i),i.sortOn(t)});for(var u=0;n>u;u++){var c=a;t.forEach(function(t,n){var s=i.getValue(t,u),l=n===e?o:r;c=c.children.getIfUndefined(s,l)}),c.index.push(u)}this.sorterInstance=new s(i),a.toArray(),a.computeAggregates(this),this.buildView()},addView:function(t){this.view.push(t)},buildView:function(){this.view.length=0,this.tree.computeHeight(),this.tree.buildView(this)},viewMakesSense:function(){return this.hasAggregates()},getValue:function(t,e){if(!this.viewMakesSense())return this.dataSource.getValue(t,e);var i=this.view[e];return i?i.getValue(t):null},setValue:function(t,e,i){return this.viewMakesSense()?void 0:this.dataSource.setValue(t,e,i)},getColumnCount:function(){return this.viewMakesSense()?this.getHeaders().length:this.dataSource.getColumnCount()},getRowCount:function(){return this.viewMakesSense()?this.view.length:this.dataSource.getRowCount()},click:function(t){var e=this.view[t];e.toggleExpansionState(this),this.buildView()},getHeaders:function(){return this.viewMakesSense()?this.headers:this.dataSource.getHeaders()},setHeaders:function(t){this.dataSource.setHeaders(t)},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},getGrandTotals:function(){var t=this.tree;return[t.data]},getRow:function(t){if(!this.viewMakesSense())return this.dataSource.getRow(t);var e=this.view[t];return e?e:this.tree},setData:function(t){this.dataSource.setData(t),this.apply()}},e.exports=n},{"./DataNodeGroup":11,"./DataNodeLeaf":12,"./DataNodeTree":13,"./DataSourceSorter":19,"./util/headerify":23}],16:[function(t,e,i){"use strict";function n(t,e){var i=this;return!this.filters.find(function(n){return!n(i.dataSource.getValue(n.columnIndex,t),e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceFilter",{initialize:function(){this.filters=[]},add:function(t,e){e.columnIndex=t,this.filters.push(e)},clearAll:function(){this.filters.length=0,this.clearIndex()},applyAll:function(){this.filters.length?this.buildIndex(n):this.clearIndex()},getRowCount:function(){return this.filters.length?this.index.length:this.dataSource.getRowCount()},aliases:{set:"add"}});e.exports=r},{"./DataSourceIndexed":18}],17:[function(t,e,i){"use strict";function n(t,e){var i=this;return this.visibleColumnMap.find(function(n,o){var r=i.dataSource.getValue(n,t);return i.filter(r,e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceGlobalFilter",{set:function(t){this.filter=t},clear:function(){delete this.filter,this.clearIndex()},apply:function(t){if(this.filter){var e=this.visibleColumnMap=[];t.forEach(function(t){e.push(t.index)}),this.buildIndex(n)}else this.clearIndex()},getRowCount:function(){return this.filter?this.index.length:this.dataSource.getRowCount()}});e.exports=r},{"./DataSourceIndexed":18}],18:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataSourceIndexed",{isNullObject:!1,initialize:function(t){this.dataSource=t,this.index=[]},transposeY:function(t){return this.index.length?this.index[t]:t},getRow:function(t){return this.dataSource.getRow(this.transposeY(t))},getValue:function(t,e){return this.dataSource.getValue(t,this.transposeY(e))},setValue:function(t,e,i){this.dataSource.setValue(t,this.transposeY(e),i)},getRowCount:function(){return this.index.length||this.dataSource.getRowCount()},getColumnCount:function(){return this.dataSource.getColumnCount()},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},setHeaders:function(t){return this.dataSource.setHeaders(t)},getHeaders:function(){return this.dataSource.getHeaders()},getGrandTotals:function(){return this.dataSource.getGrandTotals()},setData:function(t){return this.dataSource.setData(t)},clearIndex:function(){this.index.length=0},buildIndex:function(t){var e=this.dataSource.getRowCount(),i=this.index;this.clearIndex();for(var n=0;e>n;n++)(!t||t.call(this,n,this.dataSource.getRow(n)))&&i.push(n);return i}});e.exports=o},{"extend-me":3}],19:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}var o=t("./DataSourceIndexed"),r=t("./util/stableSort"),s=o.extend("DataSourceSorter",{initialize:function(){this.descendingSort=!1},sortOn:function(t,e){function i(e){return n(o.dataSource.getValue(t,e))}switch(e){case 0:this.clearIndex();break;case void 0:case 1:case-1:var o=this;r.sort(this.buildIndex(),i,e)}}});e.exports=s},{"./DataSourceIndexed":18,"./util/stableSort":24}],20:[function(t,e,i){"use strict";var n=t("./DataSourceIndexed"),o=t("./DataSourceSorter"),r=n.extend("DataSourceSorterComposite",{initialize:function(){this.sorts=[],this.last=this.dataSource},getRow:function(t){return this.last.getRow(t)},sortOn:function(t,e){this.sorts.push([t,e])},applySorts:function(){var t=this.dataSource;this.sorts.forEach(function(e){t=new o(t),t.sortOn.apply(t,e)}),this.last=t},clearSorts:function(){this.sorts.length=0,this.last=this.dataSource},getValue:function(t,e){return this.last.getValue(t,e)},setValue:function(t,e,i){this.last.setValue(t,e,i)}});e.exports=r},{"./DataSourceIndexed":18,"./DataSourceSorter":19}],21:[function(t,e,i){"use strict";function n(){this.keys=[],this.data={},this.values=[]}function o(t){var e=typeof t;switch(e){case"number":case"string":case"boolean":case"symbol":return l+e+"_"+t;case"undefined":return"UNDEFINED";case"object":if(null===t)return"NULL";case"function":return t.___finhash=t.___finhash||l+a++}}function r(t){return t}function s(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!u(t[i],e););else i=[].indexOf.call(t,e);return i}n.prototype={constructor:n.prototype.constructor,set:function(t,e){var i=o(t);i in this.data||(this.keys.push(t),this.values.push(e)),this.data[i]=e},get:function(t){var e=o(t);return this.data[e]},getIfUndefined:function(t,e){var i=this.get(t);return void 0===i&&(i=e(t),this.set(t,i)),i},size:function(){return this.keys.length},clear:function(){this.keys.length=0,this.values.length=0,this.data={}},"delete":function(t){var e=o(t);if(void 0!==this.data[e]){var i=s(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},forEach:function(t){if("function"==typeof t){var e=this.keys,i=this;e.forEach(function(e){var n=i.get(e);t(n,e,i)})}},map:function(t){var e=this.keys,i=new n,o=this;return"function"!=typeof t&&(t=r),e.forEach(function(e){var n=o.get(e),r=t(n,e,o);i.set(e,r)}),i},copy:function(){var t=this.keys,e=new n,i=this;return t.forEach(function(t){var n=i.get(t);e.set(t,n)}),e}};var l=".~.#%_",a=0,u=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t){return t.getRowCount()}function o(t,e){for(var i=e.getRowCount(),n=0;i--;)n+=e.getValue(t,i);return n}function r(t,e,i,n){for(var o=n.getRowCount();o--;)i=e(i,n.getValue(t,o));return i}function s(t,e){return o(t,e)/e.getRowCount()}function l(t,e){return e.getValue(t,0)}function a(t,e){return e.getValue(t,e.getRowCount()-1)}function u(t,e){for(var i,n=e.getRowCount(),o=s(t,e),r=n,l=0;r--;l+=i*i)i=e.getValue(t,r)-o;return Math.sqrt(l/n)}e.exports={count:function(t){return n},sum:function(t){return o.bind(this,t)},min:function(t){return r.bind(this,t,Math.min,1/0)},max:function(t){return r.bind(this,t,Math.max,-(1/0))},avg:function(t){return s.bind(this,t)},first:function(t){return l.bind(this,t)},last:function(t){return a.bind(this,t)},stddev:function(t){return u.bind(this,t)}}},{}],23:[function(t,e,i){"use strict";function n(t){return(/[a-z]/.test(t)?t:t.toLowerCase()).replace(/[\s\-_]*([^\s\-_])([^\s\-_]+)/g,o).replace(/[A-Z]/g," $&").trim()}function o(t,e,i){return e.toUpperCase()+i}e.exports=n},{}],24:[function(t,e,i){"use strict";function n(t,e,i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}function o(t,e){return t-e}function r(t,e){return e-t}function s(t,e){return e>t?-1:1}function l(t,e){return t>e?-1:1}function a(t){return n.bind(this,"number"===t?o:s,!1)}function u(t){return n.bind(this,"number"===t?r:l,!0)}function c(t,e,i){var n,o;if(void 0===i&&(i=1),t.length){switch(i){case 0:return;case void 0:i=1;case 1:n=a(typeof e(0));break;case-1:n=u(typeof e(0))}var r=new Array(t.length);for(o=0;op&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=A.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+A.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),A=t("templex"),C=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:w[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=C,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=C,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=C;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":2,templex:31}],26:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1,editOnDoubleClick:!0};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(), +this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[], +this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0,this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},getData:function(){return this.source},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(), +t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file diff --git a/examples/bclys/index.js b/examples/bclys/index.js index 2328312d3..0c0893cc4 100644 --- a/examples/bclys/index.js +++ b/examples/bclys/index.js @@ -1,5 +1,5 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o'+t.replace("mouse","")+""}),e.appendChild(n),t={},i.forEach(function(e){t[e]=n.getElementsByClassName(e)[0]})}return t},_addEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.add("listening"),window.addEventListener(t,this._bound["on"+t])},_removeEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.remove("listening"),window.removeEventListener(t,this._bound["on"+t])}};var a,u={shortStop:function(t){t.stopPropagation()},onwheel:function(t){this.index+=t[this.deltaProp],t.stopPropagation(),t.preventDefault()},onclick:function(t){var e=this.thumb.getBoundingClientRect(),i=t[this.oh.coordinate].thumb,div.finbar-vertical>.thumb{position:absolute;background-color:#d3d3d3;-webkit-box-shadow:0 0 1px #000;-moz-box-shadow:0 0 1px #000;box-shadow:0 0 1px #000;border-radius:4px;margin:2px;opacity:.4;transition:opacity .5s}div.finbar-horizontal>.thumb.hover,div.finbar-vertical>.thumb.hover{opacity:1;transition:opacity .5s}div.finbar-vertical{top:0;bottom:0;right:0;width:11px}div.finbar-vertical>.thumb{top:0;right:0;width:7px}div.finbar-horizontal{left:0;right:0;bottom:0;height:11px}div.finbar-horizontal>.thumb{left:0;bottom:0;height:7px}",e.exports=n},{"css-injector":2}],5:[function(t,e,i){"use strict";function n(t,e){var i=this;this.div=t,this._component=e,this.dragEndtime=Date.now(),this.canvas=document.createElement("canvas"),this.div.appendChild(this.canvas),this.canvas.style.outline="none",this.canvasCTX=this.canvas.getContext("2d"),this.gc=new u(this.canvasCTX),this.buffer=document.createElement("canvas"),this.bufferCTX=this.buffer.getContext("2d"),this.bufferGC=new u(this.bufferCTX),this.mouseLocation=new l.Point(-1,-1),this.dragstart=new l.Point(-1,-1),this.bounds=new l.Rectangle(0,0,0,0),this.hasMouse=!1,document.addEventListener("mousemove",function(t){(i.hasMouse||i.isDragging())&&i.finmousemove(t)}),document.addEventListener("mouseup",function(t){i.finmouseup(t)}),document.addEventListener("wheel",function(t){i.finwheelmoved(t)}),document.addEventListener("keydown",function(t){i.finkeydown(t)}),document.addEventListener("keyup",function(t){i.finkeyup(t)}),this.canvas.onmouseover=function(){i.hasMouse=!0},this.canvas.addEventListener("focus",function(t){i.finfocusgained(t)}),this.canvas.addEventListener("blur",function(t){i.finfocuslost(t)}),this.canvas.addEventListener("mousedown",function(t){i.finmousedown(t)}),this.canvas.addEventListener("mouseout",function(t){i.hasMouse=!1,i.finmouseout(t)}),this.canvas.addEventListener("click",function(t){i.finclick(t)}),this.canvas.addEventListener("contextmenu",function(t){return i.fincontextmenu(t),t.preventDefault(),!1}),a.addEventListener(this.canvas,"tap",function(t){i.fintap(t)}),a.addEventListener(this.canvas,"holdpulse",function(t){i.finholdpulse(t)}),a.addEventListener(this.canvas,"flick",function(t){i.finflick(t)}),a.addEventListener(this.canvas,"release",function(t){i.finrelease(t)}),a.addEventListener(this.canvas,"trackstart",function(t){i.fintrackstart(t)}),a.addEventListener(this.canvas,"track",function(t){i.fintrack(t)}),a.addEventListener(this.canvas,"trackend",function(t){i.fintrackend(t)}),this.canvas.setAttribute("tabindex",0),this.canvas.contentEditable=!0,this.resize(),this.beginResizing(),this.beginPainting()}function o(t){if(g){for(var e=0;ei;i++)t[i]=e;return t[27]=["ESC","ESCSHIFT"],t[192]=["`","~"],t[49]=["1","!"],t[50]=["2","@"],t[51]=["3","#"],t[52]=["4","$"],t[53]=["5","%"],t[54]=["6","^"],t[55]=["7","&"],t[56]=["8","*"],t[57]=["9","("],t[48]=["0",")"],t[189]=["-","_"],t[187]=["=","+"],t[8]=["DELETE","DELETESHIFT"],t[9]=["TAB","TABSHIFT"],t[81]=["q","Q"],t[87]=["w","W"],t[69]=["e","E"],t[82]=["r","R"],t[84]=["t","T"],t[89]=["y","Y"],t[85]=["u","U"],t[73]=["i","I"],t[79]=["o","O"],t[80]=["p","P"],t[219]=["[","{"],t[221]=["]","}"],t[220]=["\\","|"],t[220]=["CAPSLOCK","CAPSLOCKSHIFT"],t[65]=["a","A"],t[83]=["s","S"],t[68]=["d","D"],t[70]=["f","F"],t[71]=["g","G"],t[72]=["h","H"],t[74]=["j","J"],t[75]=["k","K"],t[76]=["l","L"],t[186]=[";",":"],t[222]=["'","|"],t[13]=["RETURN","RETURNSHIFT"],t[16]=["SHIFT","SHIFT"],t[90]=["z","Z"],t[88]=["x","X"],t[67]=["c","C"],t[86]=["v","V"],t[66]=["b","B"],t[78]=["n","N"],t[77]=["m","M"],t[188]=[",","<"],t[190]=[".",">"],t[191]=["/","?"],t[16]=["SHIFT","SHIFT"],t[17]=["CTRL","CTRLSHIFT"],t[18]=["ALT","ALTSHIFT"],t[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"],t[32]=["SPACE","SPACESHIFT"],t[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"],t[18]=["ALT","ALTSHIFT"],t[38]=["UP","UPSHIFT"],t[37]=["LEFT","LEFTSHIFT"],t[40]=["DOWN","DOWNSHIFT"],t[39]=["RIGHT","RIGHTSHIFT"],t[33]=["PAGEUP","PAGEUPSHIFT"],t[34]=["PAGEDOWN","PAGEDOWNSHIFT"],t[35]=["PAGERIGHT","PAGERIGHTSHIFT"],t[36]=["PAGELEFT","PAGELEFTSHIFT"],t}var l=t("rectangular"),a=t("./js/polymergestures.dev.js"),u=t("./js/GraphicsContext.js"),c=200,h=[],d=[],g=!0,f=!0,p=s();n.prototype={constructor:n.prototype.constructor,div:null,_component:null,gestures:a,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,dirty:!1,size:null,mousedown:!1,dragging:!1,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:!1,lastDoubleClickTime:0,dragEndTime:0,lastRepaintTime:0,addEventListener:function(t,e){this.canvas.addEventListener(t,e)},stopPaintLoop:function(){g=!1},restartPaintLoop:function(){g||(g=!0,requestAnimationFrame(o))},stopResizeLoop:function(){f=!1},restartResizeLoop:function(){f||(f=!0,setInterval(r,200))},detached:function(){this.stopPainting(),this.stopResizing()},useHiDPI:function(){return this._component.resolveProperty("useHiDPI")},useBitBlit:function(){return this._component.resolveProperty("useBitBlit")},getFPS:function(){var t=this._component.resolveProperty("repaintIntervalRate");return t?parseInt(t):0},tickPaint:function(t){var e=this.getFPS();if(0!==e){var i=1e3/e,n=t-this.lastRepaintTime;n>i&&this.dirty&&(this.lastRepaintTime=t-n%i,this.paintNow())}},beginPainting:function(){var t=this;this.dirty=!0,this.tickPainter=function(e){t.tickPaint(e)},h.push(this)},stopPainting:function(){h.splice(h.indexOf(this),1)},beginResizing:function(){var t=this;this.tickResizer=function(){t.checksize()},d.push(this)},stopResizing:function(){d.splice(d.indexOf(this),1)},start:function(){this.beginPainting(),this.beginResizing()},stop:function(){this.stopPainting(),this.stopResizing()},checksize:function(){var t=this.div.getBoundingClientRect();(t.width!==this.size.width||t.height!==this.size.height)&&this.sizeChangedNotification()},sizeChangedNotification:function(){this.resize()},resize:function(){var t=this.size=this.div.getBoundingClientRect();this.canvas.width=this.buffer.width=t.width,this.canvas.height=this.buffer.height=t.height;var e=1,i=this.useBitBlit(),n=window.devicePixelRatio&&this.useHiDPI();if(n){var o=window.devicePixelRatio||1,r=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;e=o/r}var s=this.canvas.getAttribute("width"),a=this.canvas.getAttribute("height");this.canvas.width=s*e,this.canvas.height=a*e,this.buffer.width=s*e,this.buffer.height=a*e,this.canvas.style.width=s+"px",this.canvas.style.height=a+"px",this.buffer.style.width=s+"px",this.buffer.style.height=a+"px",this.bufferCTX.scale(e,e),n&&!i&&this.canvasCTX.scale(e,e),this.bounds=new l.Rectangle(0,0,t.width,t.height);var u=this._component;u&&u.setBounds(this.bounds),this.resizeNotification(),this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var t=this;this.safePaintImmediately(function(e){e.clearRect(0,0,t.canvas.width,t.canvas.height);var i=t._component;i&&i._paint(e),t.dirty=!1})},safePaintImmediately:function(t){var e=this.useBitBlit(),i=e?this.bufferGC:this.gc;try{i.save(),t(i)}catch(n){console.error(n)}finally{i.restore()}e&&this.flushBuffer()},flushBuffer:function(){this.buffer.width>0&&this.buffer.height>0&&this.canvasCTX.drawImage(this.buffer,0,0)},dispatchNewEvent:function(t,e,i){return i={detail:i||{}},i.detail.primitiveEvent=t,this.canvas.dispatchEvent(new CustomEvent(e,i))},dispatchNewMouseKeysEvent:function(t,e,i){return i=i||{},i.mouse=this.mouseLocation,i.keys=this.currentKeys,this.dispatchNewEvent(t,e,i)},finmousemove:function(t){!this.isDragging()&&this.mousedown&&(this.beDragging(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragstart",{isRightClick:this.isRightClick(t)}),this.dragstart=new l.Point(this.mouseLocation.x,this.mouseLocation.y)),this.mouseLocation=this.getLocal(t),this.isDragging()&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-drag",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.bounds.contains(this.mouseLocation)&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousemove")},finmousedown:function(t){this.mouseLocation=this.getLocal(t),this.mousedown=!0,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousedown",{isRightClick:this.isRightClick(t)}),this.takeFocus()},finmouseup:function(t){this.isDragging()&&(this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragend",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.beNotDragging(),this.dragEndtime=Date.now()),this.mousedown=!1,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseup",{isRightClick:this.isRightClick(t)})},finmouseout:function(t){this.mousedown||(this.mouseLocation=new l.Point(-1,-1)),this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseout")},finwheelmoved:function(t){!this.isDragging()&&this.hasFocus()&&(t.preventDefault(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-wheelmoved",{isRightClick:this.isRightClick(t)}))},finclick:function(t){return Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-click",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},finrelease:function(t){this.holdPulseCount=0,this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-release")},finflick:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-flick",{isRightClick:this.isRightClick(t)}))},fintrackstart:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackstart"))},fintrack:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-track"))},fintrackend:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackend")},finhold:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-hold",{isRightClick:this.isRightClick(t)})},finholdpulse:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-holdpulse",{count:this.holdPulseCount++})},fintap:function(t){var e=this,i=Date.now(),n=i-this.lastDoubleClickTime;300>n||i-this.dragEndtime<100||setTimeout(function(){e._fintap(t)},180)},_fintap:function(t){var e=Date.now(),i=e-this.lastDoubleClickTime;300>i||this.dispatchNewMouseKeysEvent(t,"fin-canvas-tap",{isRightClick:this.isRightClick(t)})},findblclick:function(t){this.mouseLocation=this.getLocal(t),this.lastDoubleClickTime=Date.now(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dblclick",{isRightClick:this.isRightClick(t)})},getCharMap:function(){return p},finkeydown:function(t){if(this.hasFocus()){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];t.repeat?this.repeatKey===e?this.repeatKeyCount++:(this.repeatKey=e,this.repeatKeyStartTime=Date.now()):(this.repeatKey=null,this.repeatKeyCount=0,this.repeatKeyStartTime=0),-1===this.currentKeys.indexOf(e)&&this.currentKeys.push(e),this.dispatchNewEvent(t,"fin-canvas-keydown",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)})}},finkeyup:function(t){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(e),1),this.hasFocus()&&(this.repeatKeyCount=0,this.repeatKey=null,this.repeatKeyStartTime=0,this.dispatchNewEvent(t,"fin-canvas-keyup",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeat:t.repeat,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)}))},finfocusgained:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-gained")},finfocuslost:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-lost")},fincontextmenu:function(t){return t.ctrlKey&&-1===this.currentKeys.indexOf("CTRL")&&this.currentKeys.push("CTRL"),Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.dispatchNewMouseKeysEvent(t,"fin-canvas-context-menu",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},repaint:function(){var t=this.getFPS();this.dirty=!0,g&&0!==t||this.paintNow()},getMouseLocation:function(){return this.mouseLocation},getOrigin:function(){var t=this.canvas.getBoundingClientRect(),e=new l.Point(t.left,t.top);return e},getLocal:function(t){var e=this.canvas.getBoundingClientRect(),i=new l.Point(t.clientX-e.left,t.clientY-e.top);return i},hasFocus:function(){return document.activeElement===this.canvas},takeFocus:function(){var t=this;this.hasFocus()||setTimeout(function(){t.canvas.focus()},10)},beDragging:function(){this.dragging=!0,this.disableDocumentElementSelection()},beNotDragging:function(){this.dragging=!1,this.enableDocumentElementSelection()},isDragging:function(){return this.dragging},disableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText+"-webkit-user-select: none"},enableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText.replace("-webkit-user-select: none","")},setFocusable:function(t){this.focuser.style.display=t?"":"none"},isRightClick:function(t){var e;return t=t||window.event,"which"in t?e=3===t.which:"button"in t&&(e=2===t.button),e},dispatchEvent:function(t){return this.canvas.dispatchEvent(t)}},requestAnimationFrame(o),setInterval(r,c),e.exports=n},{"./js/GraphicsContext.js":6,"./js/polymergestures.dev.js":8,rectangular:29}],6:[function(t,e,i){"use strict";function n(t,e){function i(i){i in n.prototype||s.test(i)||("function"==typeof t[i]?r[i]=e?function(){return e(i,arguments,t[i].apply(t,arguments))}:t[i].bind(t):Object.defineProperty(r,i,{get:function(){var n=t[i];return e?e(i,"getter",n):n},set:function(n){t[i]=e?e(i,"setter",n):n}}))}this.gc=t;var r=this,s=/^webkit/;switch(typeof e){case"string":e=o.bind(void 0,e+".");break;case"boolean":e===!0&&(e=o.bind(void 0,"gc."));break;case"function":if(3!==e.length)throw"GraphicsContext: User-supplied API logger function does not accept three parameters.";break;default:e=!1}Object.keys(Object.getPrototypeOf(t)).forEach(i),Object.keys(t).forEach(i)}var o=t("./gc-console-logger");e.exports=n},{"./gc-console-logger":7}],7:[function(t,e,i){"use strict";function n(t,e,i,n){var r=n;switch("string"==typeof n&&(r='"'+r+'"'),e=t+e,i){case"getter":console.log(e,"=",r);break;case"setter":console.log(e,o,r);break;default:e+="("+Array.prototype.slice.call(i).join(", ")+")",void 0===r?console.log(e):console.log(e,o,r)}return n}var o="⟹";e.exports=n},{}],8:[function(t,e,i){!function(t){var e=!1,i=document.createElement("meta");if(i.createShadowRoot){var n=i.createShadowRoot(),o=document.createElement("span");n.appendChild(o),i.addEventListener("testpath",function(t){t.path&&(e=t.path[0]===o),t.stopPropagation()});var r=new CustomEvent("testpath",{bubbles:!0});document.head.appendChild(i),o.dispatchEvent(r),i.parentNode.removeChild(i),n=o=null}i=null;var s={shadow:function(t){return t?t.shadowRoot||t.webkitShadowRoot:void 0},canTarget:function(t){return t&&Boolean(t.elementFromPoint)},targetingShadow:function(t){var e=this.shadow(t);return this.canTarget(e)?e:void 0},olderShadow:function(t){var e=t.olderShadowRoot;if(!e){var i=t.querySelector("shadow");i&&(e=i.olderShadowRoot)}return e},allShadows:function(t){for(var e=[],i=this.shadow(t);i;)e.push(i),i=this.olderShadow(i);return e},searchRoot:function(t,e,i){var n,o;return t?(n=t.elementFromPoint(e,i),n?o=this.targetingShadow(n):t!==document&&(o=this.olderShadow(t)),this.searchRoot(o,e,i)||n):void 0},owner:function(t){if(!t)return document;for(var e=t;e.parentNode;)e=e.parentNode;return e.nodeType!=Node.DOCUMENT_NODE&&e.nodeType!=Node.DOCUMENT_FRAGMENT_NODE&&(e=document),e},findTarget:function(t){if(e&&t.path&&t.path.length)return t.path[0];var i=t.clientX,n=t.clientY,o=this.owner(t.target);return o.elementFromPoint(i,n)||(o=document),this.searchRoot(o,i,n)},findTouchAction:function(t){var i;if(e&&t.path&&t.path.length){for(var n=t.path,o=0;o=0?t=this.walk(t,o):e=this.walk(e,-o);t&&e&&t!==e;)t=t.parentNode||t.host,e=e.parentNode||e.host;return t},walk:function(t,e){for(var i=0;t&&e>i;i++)t=t.parentNode||t.host;return t},depth:function(t){for(var e=0;t;)e++,t=t.parentNode||t.host;return e},deepContains:function(t,e){var i=this.LCA(t,e);return i===t},insideNode:function(t,e,i){var n=t.getBoundingClientRect();return n.left<=e&&e<=n.right&&n.top<=i&&i<=n.bottom},path:function(t){var i;if(e&&t.path&&t.path.length)i=t.path;else{i=[];for(var n=this.findTarget(t);n;)i.push(n),n=n.parentNode||n.host}return i}};t.targetFinding=s,t.findTarget=s.findTarget.bind(s),t.deepContains=s.deepContains.bind(s),t.insideNode=s.insideNode}(i),function(){function t(t){return"html /deep/ "+e(t)}function e(t){return'[touch-action="'+t+'"]'}function i(t){return"{ -ms-touch-action: "+t+"; touch-action: "+t+";}"}var n=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],o="",r="string"==typeof document.head.style.touchAction,s=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(r){n.forEach(function(n){String(n)===n?(o+=e(n)+i(n)+"\n",s&&(o+=t(n)+i(n)+"\n")):(o+=n.selectors.map(e)+i(n.rule)+"\n",s&&(o+=n.selectors.map(t)+i(n.rule)+"\n"))});var l=document.createElement("style");l.textContent=o,document.head.appendChild(l)}}(),function(t){var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],i=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],n=function(){return function(){}},o={preventTap:n,makeBaseEvent:function(t,e){var i=document.createEvent("Event");return i.initEvent(t,e.bubbles||!1,e.cancelable||!1),i.preventTap=o.preventTap(i),i},makeGestureEvent:function(t,e){e=e||Object.create(null);for(var i,n=this.makeBaseEvent(t,e),o=0,r=Object.keys(e);o-1?this.values[i]=e:(this.keys.push(t),this.values.push(e))},has:function(t){return this.keys.indexOf(t)>-1},"delete":function(t){var e=this.keys.indexOf(t);e>-1&&(this.keys.splice(e,1),this.values.splice(e,1))},get:function(t){var e=this.keys.indexOf(t);return this.values[e]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(t,e){this.values.forEach(function(i,n){t.call(e,i,this.keys[n],this)},this)},pointers:function(){return this.keys.length}},t.PointerMap=e}(i),function(t){var e,i=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],n=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],o="undefined"!=typeof SVGElementInstance,r=t.eventFactory,s={IS_IOS:!1,pointermap:new t.PointerMap,requiredGestures:new t.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(t,e){var i=e,n=i.events;n&&(n.forEach(function(t){i[t]&&(this.eventMap[t]=i[t].bind(i))},this),this.eventSources[t]=i,this.eventSourceList.push(i))},registerGesture:function(t,e){var i=Object.create(null);i.listeners=0,i.index=this.gestures.length;for(var n,o=0;oo&&(i=this.eventSourceList[o]);o++)i.register.call(i,t,e)},unregister:function(t){for(var e,i=this.eventSourceList.length,n=0;i>n&&(e=this.eventSourceList[n]);n++)e.unregister.call(e,t)},down:function(t){this.requiredGestures.set(t.pointerId,e),this.fireEvent("down",t)},move:function(t){t.type="move",this.fillGestureQueue(t)},up:function(t){this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},cancel:function(t){t.tapPrevented=!0,this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},addGestureDependency:function(t,e){var i=t._pgEvents;if(i&&e)for(var n,o,r,s=Object.keys(i),l=0;l0&&(n=this.dependencyMap[r],o=n?n.index:-1,e[o]=!0)},eventHandler:function(i){var n=i.type;if("touchstart"===n||"mousedown"===n||"pointerdown"===n||"MSPointerDown"===n)if(i._handledByPG||(e={}),this.IS_IOS){var o=i;if("touchstart"===n){var r=i.changedTouches[0];o={target:i.target,clientX:r.clientX,clientY:r.clientY,path:i.path}}for(var s,l=i.path||t.targetFinding.path(o),a=0;an&&(i=e[n]);n++)this.addEvent(t,i)},unlisten:function(t,e){for(var i,n=0,o=e.length;o>n&&(i=e[n]);n++)this.removeEvent(t,i)},addEvent:function(t,e){t.addEventListener(e,this.boundHandler)},removeEvent:function(t,e){t.removeEventListener(e,this.boundHandler)},makeEvent:function(t,e){var i=r.makePointerEvent(t,e);return i.preventDefault=e.preventDefault,i.tapPrevented=e.tapPrevented,i._target=i._target||e.target,i},fireEvent:function(t,e){var i=this.makeEvent(t,e);return this.dispatchEvent(i)},cloneEvent:function(t){for(var e,r=Object.create(null),s=0;s0&&t._pgListeners--,0===t._pgListeners&&s.unregister(t),t._pgEvents&&(t._pgEvents[i]>0?t._pgEvents[i]--:t._pgEvents[i]=0)),Boolean(n)},t.removeEventListener=function(e,i,n,o){n&&(t.deactivateGesture(e,i),e.removeEventListener(i,n,o))}}(i),function(t){var e=t.dispatcher,i=e.pointermap,n=25,o=[0,1,4,2],r=0,s=/Linux.*Firefox\//i,l=function(){if(s.test(navigator.userAgent))return!1;try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}(),a={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(t){for(var e,i=this.lastTouches,o=t.clientX,r=t.clientY,s=0,l=i.length;l>s&&(e=i[s]);s++){var a=Math.abs(o-e.x),u=Math.abs(r-e.y);if(n>=a&&n>=u)return!0}},prepareEvent:function(t){var i=e.cloneEvent(t);if(i.pointerId=this.POINTER_ID,i.isPrimary=!0,i.pointerType=this.POINTER_TYPE,i._source="mouse",!l){var n=t.type,s=o[t.which]||0;"mousedown"===n?r|=s:"mouseup"===n&&(r&=~s),i.buttons=r}return i},mousedown:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=(i.has(this.POINTER_ID),this.prepareEvent(n));o.target=t.findTarget(n),i.set(this.POINTER_ID,o.target),e.down(o)}},mousemove:function(t){if(!this.isEventSimulatedFromTouch(t)){var n=i.get(this.POINTER_ID);if(n){var o=this.prepareEvent(t);o.target=n,0===(l?o.buttons:o.which)?(l||(r=o.buttons=0),e.cancel(o),this.cleanupMouse(o.buttons)):e.move(o)}}},mouseup:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(this.POINTER_ID),e.up(o),this.cleanupMouse(o.buttons)}},cleanupMouse:function(t){0===t&&i["delete"](this.POINTER_ID)}};t.mouseEvents=a}(i),function(t){var e=t.dispatcher,i=(t.targetFinding.allShadows.bind(t.targetFinding),e.pointermap),n=(Array.prototype.map.call.bind(Array.prototype.map),2500),o=25,r=200,s=20,l=!1,a={IS_IOS:!1,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(t,i){(this.IS_IOS?i:!i)&&e.listen(t,this.events)},unregister:function(t){this.IS_IOS||e.unlisten(t,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(t){var e=t,i=this.scrollTypes;return e===i.EMITTER?"none":e===i.XSCROLLER?"X":e===i.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(t){return this.firstTouch===t.identifier},setPrimaryTouch:function(t){(0===i.pointers()||1===i.pointers()&&i.has(1))&&(this.firstTouch=t.identifier,this.firstXY={X:t.clientX,Y:t.clientY},this.firstTarget=t.target,this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(t){t.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var t=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(t,r)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(t){var e=0;return("touchstart"===t||"touchmove"===t)&&(e=1),e},findTarget:function(e,n){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(e)){var o={clientX:e.clientX,clientY:e.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return t.findTarget(o)}return t.findTarget(e)}return i.get(n)},touchToPointer:function(t){var i=this.currentTouchEvent,n=e.cloneEvent(t),o=n.pointerId=t.identifier+2;n.target=this.findTarget(t,o),n.bubbles=!0,n.cancelable=!0,n.detail=this.clickCount,n.buttons=this.typeToButtons(i.type),n.width=t.webkitRadiusX||t.radiusX||0,n.height=t.webkitRadiusY||t.radiusY||0,n.pressure=t.webkitForce||t.force||.5,n.isPrimary=this.isPrimaryTouch(t),n.pointerType=this.POINTER_TYPE,n._source="touch";var r=this;return n.preventDefault=function(){r.scrolling=!1,r.firstXY=null,i.preventDefault()},n},processTouches:function(t,e){var n=t.changedTouches;this.currentTouchEvent=t;for(var o,r,s=0;s=u}return i}},findTouch:function(t,e){for(var i,n=0,o=t.length;o>n&&(i=t[n]);n++)if(i.identifier===e)return!0},vacuumTouches:function(t){var e=t.touches;if(i.pointers()>=e.length){var n=[];i.forEach(function(t,i){if(1!==i&&!this.findTouch(e,i-2)){var o=t;n.push(o)}},this),n.forEach(function(t){this.cancel(t),i["delete"](t.pointerId)},this)}},touchstart:function(t){this.vacuumTouches(t),this.setPrimaryTouch(t.changedTouches[0]),this.dedupSynthMouse(t),this.scrolling||(this.clickCount++,this.processTouches(t,this.down))},down:function(t){e.down(t)},touchmove:function(t){if(l)t.cancelable&&this.processTouches(t,this.move);else if(this.scrolling){if(this.firstXY){var e=t.changedTouches[0],i=e.clientX-this.firstXY.X,n=e.clientY-this.firstXY.Y,o=Math.sqrt(i*i+n*n);o>=s&&(this.touchcancel(t),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(t)?this.scrolling=!0:(this.scrolling=!1,t.preventDefault(),this.processTouches(t,this.move))},move:function(t){e.move(t)},touchend:function(t){this.dedupSynthMouse(t),this.processTouches(t,this.up)},up:function(i){i.relatedTarget=t.findTarget(i),e.up(i)},cancel:function(t){e.cancel(t)},touchcancel:function(t){t._cancel=!0,this.processTouches(t,this.cancel)},cleanUpPointer:function(t){i["delete"](t.pointerId),this.removePrimaryPointer(t)},dedupSynthMouse:function(e){var i=t.mouseEvents.lastTouches,o=e.changedTouches[0];if(this.isPrimaryTouch(o)){var r={x:o.clientX,y:o.clientY};i.push(r);var s=function(t,e){var i=t.indexOf(e);i>-1&&t.splice(i,1)}.bind(null,i,r);setTimeout(s,n)}}},u=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(e){var i=e.clientX,n=e.clientY,r=function(t){var e=Math.abs(i-t.x),r=Math.abs(n-t.y);return o>=e&&o>=r},s=t.mouseEvents.lastTouches.some(r),l=t.targetFinding.path(e);if(s){for(var c=0;c0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],9:[function(t,e,i){"use strict";e.exports={JSDataSource:t("./js/DataSource"),DataSourceSorter:t("./js/DataSourceSorter"),DataSourceSorterComposite:t("./js/DataSourceSorterComposite"),DataSourceFilter:t("./js/DataSourceFilter"),DataSourceGlobalFilter:t("./js/DataSourceGlobalFilter"),DataSourceAggregator:t("./js/DataSourceAggregator"),util:{aggregations:t("./js/util/aggregations")}}},{"./js/DataSource":14,"./js/DataSourceAggregator":15,"./js/DataSourceFilter":16,"./js/DataSourceGlobalFilter":17,"./js/DataSourceSorter":19,"./js/DataSourceSorterComposite":20,"./js/util/aggregations":22}],10:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataNodeBase",{isNullObject:!1,INDENT:" ",initialize:function(t){this.label=t,this.data=[""],this.index=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1},getValue:function(t){return this.data[t]},toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+" "+this.label},computeHeight:function(){return 1},getIndex:function(){return this.index},computeAggregates:function(t){var e=this.getIndex();if(e.length){var i=Number(t.hasGroups()),n=this.data;n.length=i+t.aggregates.length;var o=t.sorterInstance;o.index=e,t.aggregates.forEach(function(t,e){n[i+e]=t(o)})}},buildView:function(t){t.addView(this)},toggleExpansionState:function(){}});e.exports=o},{"extend-me":3}],11:[function(t,e,i){"use strict";function n(t){return this.splice.bind(this,this.length,0).apply(this,t),this}var o=t("./util/Mappy"),r=t("./DataNodeBase"),s={"true":"▼","false":"▶"},l=r.extend("DataNodeGroup",{extendable:!0,initialize:function(t){this.children=new o},toArray:function(t){this.depth=t,this.children=this.children.values,this.children.forEach(function(e){e.toArray(t+1)}),this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+s[this.expanded]+" "+this.label},getIndex:function(){return 0===this.index.length&&(this.index=this.computeIndex()),this.index},computeIndex:function(){var t=[];return t.append=n,this.children.forEach(function(e){t.append(e.getIndex())}),t},toggleExpansionState:function(t){this.expanded=!this.expanded,this.data[0]=this.computeDepthString(),this.expanded&&this.computeAggregates(t)},computeAggregates:function(t){r.prototype.computeAggregates.call(this,t),this.expanded&&this.children.forEach(function(e){e.computeAggregates(t)})},buildView:function(t){t.view.push(this),this.expanded&&this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.expanded&&this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=l},{"./DataNodeBase":10,"./util/Mappy":21}],12:[function(t,e,i){"use strict";var n=t("./DataNodeBase"),o=n.extend("DataNodeLeaf",{toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},getIndex:function(){return this.index},buildView:function(t){t.addView(this)},computeHeight:function(){return 1}});e.exports=o},{"./DataNodeBase":10}],13:[function(t,e,i){"use strict";var n=t("./DataNodeGroup"),o=n.extend("DataNodeTree",{initialize:function(t){this.height=0,this.expanded=!0},toArray:function(){this.children=this.children.values,this.children.forEach(function(t){t.toArray(0)})},buildView:function(t){this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=o},{"./DataNodeGroup":11}],14:[function(t,e,i){"use strict";function n(t,e){this.fields=e||r(t[0]),this.data=t}function o(t,e){throw new Error("DataSource."+t+": "+e)}function r(t){return Object.getOwnPropertyNames(t||[]).filter(function(t){return"__"!==t.substr(0,2)})}var s=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,getRow:function(t){return this.data[t]},getValue:function(t,e){var i=this.getRow(e);return i?i[this.fields[t]]:null},setValue:function(t,e,i){this.getRow(e)[this.fields[t]]=i},getRowCount:function(){return this.data.length},getColumnCount:function(){return this.getFields().length},getFields:function(){return this.fields},getHeaders:function(){return this.headers=this.headers||this.getDefaultHeaders().map(function(t){return s(t)})},getDefaultHeaders:function(){return this.getFields()},setFields:function(t){this.fields=t},setHeaders:function(t){t instanceof Array||o("setHeaders","param #1 `headers` not array"),this.headers=t},getGrandTotals:function(){},setData:function(t){this.data=t}},e.exports=n},{"./util/headerify":23}],15:[function(t,e,i){"use strict";function n(t){this.dataSource=t,this.tree=new l("Totals"),this.index=[],this.aggregates=[],this.headers=[],this.groupBys=[],this.view=[],this.sorterInstance={},this.presortGroups=!0,this.lastAggregate={},this.setAggregates({})}function o(t){return new u(t)}function r(t){return new a(t)}var s=t("./DataSourceSorter"),l=t("./DataNodeTree"),a=t("./DataNodeGroup"),u=t("./DataNodeLeaf"),c=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,setAggregates:function(t){this.lastAggregate=t,this.clearAggregations(),this.headers.length=0,this.hasGroups()&&this.headers.push("Tree");for(var e in t)this.addAggregate(e,t[e])},addAggregate:function(t,e){this.headers.push(c(t)),this.aggregates.push(e)},setGroupBys:function(t){var e=this.groupBys;e.length=0,t.forEach(function(t){e.push(t)}),this.setAggregates(this.lastAggregate)},addGroupBy:function(t){this.groupBys.push(t)},hasGroups:function(){return!!this.groupBys.length},hasAggregates:function(){return!!this.aggregates.length},apply:function(){this.buildGroupTree()},clearGroups:function(){this.groupBys.length=0},clearAggregations:function(){this.aggregates.length=0,this.headers.length=0},buildGroupTree:function(){var t=this.groupBys,e=t.length-1,i=this.dataSource,n=i.getRowCount(),a=this.tree=new l("Totals");this.presortGroups&&t.reverse().forEach(function(t){i=new s(i),i.sortOn(t)});for(var u=0;n>u;u++){var c=a;t.forEach(function(t,n){var s=i.getValue(t,u),l=n===e?o:r;c=c.children.getIfUndefined(s,l)}),c.index.push(u)}this.sorterInstance=new s(i),a.toArray(),a.computeAggregates(this),this.buildView()},addView:function(t){this.view.push(t)},buildView:function(){this.view.length=0,this.tree.computeHeight(),this.tree.buildView(this)},viewMakesSense:function(){return this.hasAggregates()},getValue:function(t,e){if(!this.viewMakesSense())return this.dataSource.getValue(t,e);var i=this.view[e];return i?i.getValue(t):null},setValue:function(t,e,i){return this.viewMakesSense()?void 0:this.dataSource.setValue(t,e,i)},getColumnCount:function(){return this.viewMakesSense()?this.getHeaders().length:this.dataSource.getColumnCount()},getRowCount:function(){return this.viewMakesSense()?this.view.length:this.dataSource.getRowCount()},click:function(t){var e=this.view[t];e.toggleExpansionState(this),this.buildView()},getHeaders:function(){return this.viewMakesSense()?this.headers:this.dataSource.getHeaders()},setHeaders:function(t){this.dataSource.setHeaders(t)},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},getGrandTotals:function(){var t=this.tree;return[t.data]},getRow:function(t){if(!this.viewMakesSense())return this.dataSource.getRow(t);var e=this.view[t];return e?e:this.tree},setData:function(t){this.dataSource.setData(t),this.apply()}},e.exports=n},{"./DataNodeGroup":11,"./DataNodeLeaf":12,"./DataNodeTree":13,"./DataSourceSorter":19,"./util/headerify":23}],16:[function(t,e,i){"use strict";function n(t,e){var i=this;return!this.filters.find(function(n){return!n(i.dataSource.getValue(n.columnIndex,t),e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceFilter",{initialize:function(){this.filters=[]},add:function(t,e){e.columnIndex=t,this.filters.push(e)},clearAll:function(){this.filters.length=0,this.clearIndex()},applyAll:function(){this.filters.length?this.buildIndex(n):this.clearIndex()},getRowCount:function(){return this.filters.length?this.index.length:this.dataSource.getRowCount()},aliases:{set:"add"}});e.exports=r},{"./DataSourceIndexed":18}],17:[function(t,e,i){"use strict";function n(t,e){var i=this;return this.visibleColumnMap.find(function(n,o){var r=i.dataSource.getValue(n,t);return i.filter(r,e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceGlobalFilter",{set:function(t){this.filter=t},clear:function(){delete this.filter,this.clearIndex()},apply:function(t){if(this.filter){var e=this.visibleColumnMap=[];t.forEach(function(t){e.push(t.index)}),this.buildIndex(n)}else this.clearIndex()},getRowCount:function(){return this.filter?this.index.length:this.dataSource.getRowCount()}});e.exports=r},{"./DataSourceIndexed":18}],18:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataSourceIndexed",{isNullObject:!1,initialize:function(t){this.dataSource=t,this.index=[]},transposeY:function(t){return this.index.length?this.index[t]:t},getRow:function(t){return this.dataSource.getRow(this.transposeY(t))},getValue:function(t,e){return this.dataSource.getValue(t,this.transposeY(e))},setValue:function(t,e,i){this.dataSource.setValue(t,this.transposeY(e),i)},getRowCount:function(){return this.index.length||this.dataSource.getRowCount()},getColumnCount:function(){return this.dataSource.getColumnCount()},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},setHeaders:function(t){return this.dataSource.setHeaders(t)},getHeaders:function(){return this.dataSource.getHeaders()},getGrandTotals:function(){return this.dataSource.getGrandTotals()},setData:function(t){return this.dataSource.setData(t)},clearIndex:function(){this.index.length=0},buildIndex:function(t){var e=this.dataSource.getRowCount(),i=this.index;this.clearIndex();for(var n=0;e>n;n++)(!t||t.call(this,n,this.dataSource.getRow(n)))&&i.push(n);return i}});e.exports=o},{"extend-me":3}],19:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}var o=t("./DataSourceIndexed"),r=t("./util/stableSort"),s=o.extend("DataSourceSorter",{initialize:function(){this.descendingSort=!1},sortOn:function(t,e){function i(e){return n(o.dataSource.getValue(t,e))}switch(e){case 0:this.clearIndex();break;case void 0:case 1:case-1:var o=this;r.sort(this.buildIndex(),i,e)}}});e.exports=s},{"./DataSourceIndexed":18,"./util/stableSort":24}],20:[function(t,e,i){"use strict";var n=t("./DataSourceIndexed"),o=t("./DataSourceSorter"),r=n.extend("DataSourceSorterComposite",{initialize:function(){this.sorts=[],this.last=this.dataSource},getRow:function(t){return this.last.getRow(t)},sortOn:function(t,e){this.sorts.push([t,e])},applySorts:function(){var t=this.dataSource;this.sorts.forEach(function(e){t=new o(t),t.sortOn.apply(t,e)}),this.last=t},clearSorts:function(){this.sorts.length=0,this.last=this.dataSource},getValue:function(t,e){return this.last.getValue(t,e)},setValue:function(t,e,i){this.last.setValue(t,e,i)}});e.exports=r},{"./DataSourceIndexed":18,"./DataSourceSorter":19}],21:[function(t,e,i){"use strict";function n(){this.keys=[],this.data={},this.values=[]}function o(t){var e=typeof t;switch(e){case"number":case"string":case"boolean":case"symbol":return l+e+"_"+t;case"undefined":return"UNDEFINED";case"object":if(null===t)return"NULL";case"function":return t.___finhash=t.___finhash||l+a++}}function r(t){return t}function s(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!u(t[i],e););else i=[].indexOf.call(t,e);return i}n.prototype={constructor:n.prototype.constructor,set:function(t,e){var i=o(t);i in this.data||(this.keys.push(t),this.values.push(e)),this.data[i]=e},get:function(t){var e=o(t);return this.data[e]},getIfUndefined:function(t,e){var i=this.get(t);return void 0===i&&(i=e(t),this.set(t,i)),i},size:function(){return this.keys.length},clear:function(){this.keys.length=0,this.values.length=0,this.data={}},"delete":function(t){var e=o(t);if(void 0!==this.data[e]){var i=s(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},forEach:function(t){if("function"==typeof t){var e=this.keys,i=this;e.forEach(function(e){var n=i.get(e);t(n,e,i)})}},map:function(t){var e=this.keys,i=new n,o=this;return"function"!=typeof t&&(t=r),e.forEach(function(e){var n=o.get(e),r=t(n,e,o);i.set(e,r)}),i},copy:function(){var t=this.keys,e=new n,i=this;return t.forEach(function(t){var n=i.get(t);e.set(t,n)}),e}};var l=".~.#%_",a=0,u=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t){return t.getRowCount()}function o(t,e){for(var i=e.getRowCount(),n=0;i--;)n+=e.getValue(t,i);return n}function r(t,e,i,n){for(var o=n.getRowCount();o--;)i=e(i,n.getValue(t,o));return i}function s(t,e){return o(t,e)/e.getRowCount()}function l(t,e){return e.getValue(t,0)}function a(t,e){return e.getValue(t,e.getRowCount()-1)}function u(t,e){for(var i,n=e.getRowCount(),o=s(t,e),r=n,l=0;r--;l+=i*i)i=e.getValue(t,r)-o;return Math.sqrt(l/n)}e.exports={count:function(t){return n},sum:function(t){return o.bind(this,t)},min:function(t){return r.bind(this,t,Math.min,1/0)},max:function(t){return r.bind(this,t,Math.max,-(1/0))},avg:function(t){return s.bind(this,t)},first:function(t){return l.bind(this,t)},last:function(t){return a.bind(this,t)},stddev:function(t){return u.bind(this,t)}}},{}],23:[function(t,e,i){"use strict";function n(t){return(/[a-z]/.test(t)?t:t.toLowerCase()).replace(/[\s\-_]*([^\s\-_])([^\s\-_]+)/g,o).replace(/[A-Z]/g," $&").trim()}function o(t,e,i){return e.toUpperCase()+i}e.exports=n},{}],24:[function(t,e,i){"use strict";function n(t,e,i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}function o(t,e){return t-e}function r(t,e){return e-t}function s(t,e){return e>t?-1:1}function l(t,e){return t>e?-1:1}function a(t){return n.bind(this,"number"===t?o:s,!1)}function u(t){return n.bind(this,"number"===t?r:l,!0)}function c(t,e,i){var n,o;if(void 0===i&&(i=1),t.length){switch(i){case 0:return;case void 0:i=1;case 1:n=a(typeof e(0));break;case-1:n=u(typeof e(0))}var r=new Array(t.length);for(o=0;op&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=A.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+A.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),A=t("templex"),C=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:w[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=C,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=C,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=C;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":2,templex:31}],26:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(),this.checkColumnAutosizing(), -this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0, -this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0,this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){ -var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file +var d=!1;Object.defineProperty(o.prototype,"max",{set:function(t){(!t||"number"!=typeof t||0>=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1,editOnDoubleClick:!0};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(), +this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[], +this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0,this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},getData:function(){return this.source},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(), +t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file diff --git a/examples/bclys/js/json-web-worker.js b/examples/bclys/js/json-web-worker.js deleted file mode 100644 index 7c81ccdda..000000000 --- a/examples/bclys/js/json-web-worker.js +++ /dev/null @@ -1,161 +0,0 @@ -/* globals postMessage, onmessage */ - -'use strict'; - -var validIdentifierMatch = /^(?!(?:abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|let|long|native|new|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|try|typeof|var|void|volatile|while|with|yield)$)[\x24\x41-\x5A\x5F\x61-\x7A\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4-\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A-\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC][\x24\x30-\x39\x41-\x5A\x5F\x61-\x7A\xA0\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7-\u09C8\u09CB-\u09CE\u09D7\u09DC-\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A3C\u0A3E-\u0A42\u0A47-\u0A48\u0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u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2-\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18-\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772-\u1773\u1780-\u17D3\u17D7\u17DC-\u17DD\u17E0-\u17E9\u180B-\u180E\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2000-\u200A\u200C-\u200D\u2028-\u2029\u202F\u203F-\u2040\u2054\u205F\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3000\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC-\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33-\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFEFF\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\uFFFE]*$/; - -var isValidIdentifer = function(string) { - return 0 === (string + '').search(validIdentifierMatch); -}; - -var that = { - data: [], - headers: [], - fields: [] -}; - -that.setData = function(jsonData) { - that.data = jsonData; - that.initDataIndexes(); -}; - -that.initDataIndexes = function() { - //initialize the indexe cache - for (var i = 0; i < that.data.length; i++) { - that.data[i].__si = i; - that.data[i].__i = i; - } -}; - -that.fetchTableData = function(data) { - that.lastFetch = data; - var result = new Array(data.num); - for (var i = 0; i < data.num; i++) { - result[i] = that.data[data.start + i]; - } - postMessage({ - data: result, - headers: that.getHeaders(), - fields: that.getFields(), - rows: that.data.length, - features: { - sorting: true - } - }); -}; - -that.setHeaders = function(headerLabels) { - that.headers = headerLabels; -}; - -that.getHeaders = function() { - if (that.headers.length === 0) { - that.setHeaders(that.getDefaultHeaders()); - } - return that.headers; -}; -that.getHeader = function(x /*, y*/ ) { - return that.headers[x]; -}; - -that.getDefaultHeaders = function() { - var self = that; - var fields = that.getFields(); - if (fields.length === 0) { - return []; - } - var headers = fields.map(function(e) { - return self.headerify(e); - }); - return headers; -}; - -that.headerify = function(string) { - var pieces = string.replace(/[_-]/g, ' ').replace(/[A-Z]/g, ' $&').split(' ').map(function(s) { - return s.charAt(0).toUpperCase() + s.slice(1); - }); - return pieces.join(' '); -}; - -that.setFields = function(fieldNames) { - that.fields = fieldNames; -}; - -that.getFields = function() { - if (that.fields.length === 0) { - that.setFields(that.getDefaultFields()); - } - return that.fields; -}; - -that.getDefaultFields = function() { - if (that.data && that.data.length === 0) { - return []; - } - var fields = Object.getOwnPropertyNames(that.data[0]).filter(function(e) { - return e.substr(0, 2) !== '__'; - }); - return fields; -}; - -that.sortTable = function(data, incrementIt) { - - var columnIndex = data.sortIndex; - var fields = that.getFields(); - var sortStateIndex = data.state; - var i; - - if (incrementIt === undefined) { - incrementIt = 1; - } - - if (columnIndex >= fields.length) { - return; - } - - var colName = fields[columnIndex]; - if (sortStateIndex === 0) { - var newData = new Array(that.data.length); - for (i = 0; i < that.data.length; i++) { - var each = that.data[i]; - newData[each.__si] = each; - } - that.data = newData; - } else if (sortStateIndex === 1) { - if (isValidIdentifer(colName)) { - var theSorter = eval('(function (a, b) {' + /* jshint ignore:line */ - ' if (a.' + colName + ' === b.' + colName + ')' + - ' return a.__i - b.__i;' + - ' if (a.' + colName + ' < b.' + colName + ')' + - ' return -1;' + - ' return 1;' + - '})'); - that.data.sort(theSorter); - } else { - that.data.sort(function(a, b) { - if (a[colName] === b[colName]) { - return a.__i - b.__i; - } - if (a[colName] < b[colName]) { - return -1; - } - return 1; - }); - } - } else { - that.data = that.data.reverse(); - } - for (i = 0; i < that.data.length; i++) { - that.data[i].__i = i; - } - that.changed(); -}; - -that.changed = function() { - that.fetchTableData(that.lastFetch); -}; - -onmessage = function(msg) { /* jslint ignore:line */ - var data = msg.data; - that[data.cmd](data.data); -}; diff --git a/examples/polymerwrapper/index.js b/examples/polymerwrapper/index.js index 2328312d3..0c0893cc4 100644 --- a/examples/polymerwrapper/index.js +++ b/examples/polymerwrapper/index.js @@ -1,5 +1,5 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o'+t.replace("mouse","")+""}),e.appendChild(n),t={},i.forEach(function(e){t[e]=n.getElementsByClassName(e)[0]})}return t},_addEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.add("listening"),window.addEventListener(t,this._bound["on"+t])},_removeEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.remove("listening"),window.removeEventListener(t,this._bound["on"+t])}};var a,u={shortStop:function(t){t.stopPropagation()},onwheel:function(t){this.index+=t[this.deltaProp],t.stopPropagation(),t.preventDefault()},onclick:function(t){var e=this.thumb.getBoundingClientRect(),i=t[this.oh.coordinate].thumb,div.finbar-vertical>.thumb{position:absolute;background-color:#d3d3d3;-webkit-box-shadow:0 0 1px #000;-moz-box-shadow:0 0 1px #000;box-shadow:0 0 1px #000;border-radius:4px;margin:2px;opacity:.4;transition:opacity .5s}div.finbar-horizontal>.thumb.hover,div.finbar-vertical>.thumb.hover{opacity:1;transition:opacity .5s}div.finbar-vertical{top:0;bottom:0;right:0;width:11px}div.finbar-vertical>.thumb{top:0;right:0;width:7px}div.finbar-horizontal{left:0;right:0;bottom:0;height:11px}div.finbar-horizontal>.thumb{left:0;bottom:0;height:7px}",e.exports=n},{"css-injector":2}],5:[function(t,e,i){"use strict";function n(t,e){var i=this;this.div=t,this._component=e,this.dragEndtime=Date.now(),this.canvas=document.createElement("canvas"),this.div.appendChild(this.canvas),this.canvas.style.outline="none",this.canvasCTX=this.canvas.getContext("2d"),this.gc=new u(this.canvasCTX),this.buffer=document.createElement("canvas"),this.bufferCTX=this.buffer.getContext("2d"),this.bufferGC=new u(this.bufferCTX),this.mouseLocation=new l.Point(-1,-1),this.dragstart=new l.Point(-1,-1),this.bounds=new l.Rectangle(0,0,0,0),this.hasMouse=!1,document.addEventListener("mousemove",function(t){(i.hasMouse||i.isDragging())&&i.finmousemove(t)}),document.addEventListener("mouseup",function(t){i.finmouseup(t)}),document.addEventListener("wheel",function(t){i.finwheelmoved(t)}),document.addEventListener("keydown",function(t){i.finkeydown(t)}),document.addEventListener("keyup",function(t){i.finkeyup(t)}),this.canvas.onmouseover=function(){i.hasMouse=!0},this.canvas.addEventListener("focus",function(t){i.finfocusgained(t)}),this.canvas.addEventListener("blur",function(t){i.finfocuslost(t)}),this.canvas.addEventListener("mousedown",function(t){i.finmousedown(t)}),this.canvas.addEventListener("mouseout",function(t){i.hasMouse=!1,i.finmouseout(t)}),this.canvas.addEventListener("click",function(t){i.finclick(t)}),this.canvas.addEventListener("contextmenu",function(t){return i.fincontextmenu(t),t.preventDefault(),!1}),a.addEventListener(this.canvas,"tap",function(t){i.fintap(t)}),a.addEventListener(this.canvas,"holdpulse",function(t){i.finholdpulse(t)}),a.addEventListener(this.canvas,"flick",function(t){i.finflick(t)}),a.addEventListener(this.canvas,"release",function(t){i.finrelease(t)}),a.addEventListener(this.canvas,"trackstart",function(t){i.fintrackstart(t)}),a.addEventListener(this.canvas,"track",function(t){i.fintrack(t)}),a.addEventListener(this.canvas,"trackend",function(t){i.fintrackend(t)}),this.canvas.setAttribute("tabindex",0),this.canvas.contentEditable=!0,this.resize(),this.beginResizing(),this.beginPainting()}function o(t){if(g){for(var e=0;ei;i++)t[i]=e;return t[27]=["ESC","ESCSHIFT"],t[192]=["`","~"],t[49]=["1","!"],t[50]=["2","@"],t[51]=["3","#"],t[52]=["4","$"],t[53]=["5","%"],t[54]=["6","^"],t[55]=["7","&"],t[56]=["8","*"],t[57]=["9","("],t[48]=["0",")"],t[189]=["-","_"],t[187]=["=","+"],t[8]=["DELETE","DELETESHIFT"],t[9]=["TAB","TABSHIFT"],t[81]=["q","Q"],t[87]=["w","W"],t[69]=["e","E"],t[82]=["r","R"],t[84]=["t","T"],t[89]=["y","Y"],t[85]=["u","U"],t[73]=["i","I"],t[79]=["o","O"],t[80]=["p","P"],t[219]=["[","{"],t[221]=["]","}"],t[220]=["\\","|"],t[220]=["CAPSLOCK","CAPSLOCKSHIFT"],t[65]=["a","A"],t[83]=["s","S"],t[68]=["d","D"],t[70]=["f","F"],t[71]=["g","G"],t[72]=["h","H"],t[74]=["j","J"],t[75]=["k","K"],t[76]=["l","L"],t[186]=[";",":"],t[222]=["'","|"],t[13]=["RETURN","RETURNSHIFT"],t[16]=["SHIFT","SHIFT"],t[90]=["z","Z"],t[88]=["x","X"],t[67]=["c","C"],t[86]=["v","V"],t[66]=["b","B"],t[78]=["n","N"],t[77]=["m","M"],t[188]=[",","<"],t[190]=[".",">"],t[191]=["/","?"],t[16]=["SHIFT","SHIFT"],t[17]=["CTRL","CTRLSHIFT"],t[18]=["ALT","ALTSHIFT"],t[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"],t[32]=["SPACE","SPACESHIFT"],t[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"],t[18]=["ALT","ALTSHIFT"],t[38]=["UP","UPSHIFT"],t[37]=["LEFT","LEFTSHIFT"],t[40]=["DOWN","DOWNSHIFT"],t[39]=["RIGHT","RIGHTSHIFT"],t[33]=["PAGEUP","PAGEUPSHIFT"],t[34]=["PAGEDOWN","PAGEDOWNSHIFT"],t[35]=["PAGERIGHT","PAGERIGHTSHIFT"],t[36]=["PAGELEFT","PAGELEFTSHIFT"],t}var l=t("rectangular"),a=t("./js/polymergestures.dev.js"),u=t("./js/GraphicsContext.js"),c=200,h=[],d=[],g=!0,f=!0,p=s();n.prototype={constructor:n.prototype.constructor,div:null,_component:null,gestures:a,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,dirty:!1,size:null,mousedown:!1,dragging:!1,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:!1,lastDoubleClickTime:0,dragEndTime:0,lastRepaintTime:0,addEventListener:function(t,e){this.canvas.addEventListener(t,e)},stopPaintLoop:function(){g=!1},restartPaintLoop:function(){g||(g=!0,requestAnimationFrame(o))},stopResizeLoop:function(){f=!1},restartResizeLoop:function(){f||(f=!0,setInterval(r,200))},detached:function(){this.stopPainting(),this.stopResizing()},useHiDPI:function(){return this._component.resolveProperty("useHiDPI")},useBitBlit:function(){return this._component.resolveProperty("useBitBlit")},getFPS:function(){var t=this._component.resolveProperty("repaintIntervalRate");return t?parseInt(t):0},tickPaint:function(t){var e=this.getFPS();if(0!==e){var i=1e3/e,n=t-this.lastRepaintTime;n>i&&this.dirty&&(this.lastRepaintTime=t-n%i,this.paintNow())}},beginPainting:function(){var t=this;this.dirty=!0,this.tickPainter=function(e){t.tickPaint(e)},h.push(this)},stopPainting:function(){h.splice(h.indexOf(this),1)},beginResizing:function(){var t=this;this.tickResizer=function(){t.checksize()},d.push(this)},stopResizing:function(){d.splice(d.indexOf(this),1)},start:function(){this.beginPainting(),this.beginResizing()},stop:function(){this.stopPainting(),this.stopResizing()},checksize:function(){var t=this.div.getBoundingClientRect();(t.width!==this.size.width||t.height!==this.size.height)&&this.sizeChangedNotification()},sizeChangedNotification:function(){this.resize()},resize:function(){var t=this.size=this.div.getBoundingClientRect();this.canvas.width=this.buffer.width=t.width,this.canvas.height=this.buffer.height=t.height;var e=1,i=this.useBitBlit(),n=window.devicePixelRatio&&this.useHiDPI();if(n){var o=window.devicePixelRatio||1,r=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;e=o/r}var s=this.canvas.getAttribute("width"),a=this.canvas.getAttribute("height");this.canvas.width=s*e,this.canvas.height=a*e,this.buffer.width=s*e,this.buffer.height=a*e,this.canvas.style.width=s+"px",this.canvas.style.height=a+"px",this.buffer.style.width=s+"px",this.buffer.style.height=a+"px",this.bufferCTX.scale(e,e),n&&!i&&this.canvasCTX.scale(e,e),this.bounds=new l.Rectangle(0,0,t.width,t.height);var u=this._component;u&&u.setBounds(this.bounds),this.resizeNotification(),this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var t=this;this.safePaintImmediately(function(e){e.clearRect(0,0,t.canvas.width,t.canvas.height);var i=t._component;i&&i._paint(e),t.dirty=!1})},safePaintImmediately:function(t){var e=this.useBitBlit(),i=e?this.bufferGC:this.gc;try{i.save(),t(i)}catch(n){console.error(n)}finally{i.restore()}e&&this.flushBuffer()},flushBuffer:function(){this.buffer.width>0&&this.buffer.height>0&&this.canvasCTX.drawImage(this.buffer,0,0)},dispatchNewEvent:function(t,e,i){return i={detail:i||{}},i.detail.primitiveEvent=t,this.canvas.dispatchEvent(new CustomEvent(e,i))},dispatchNewMouseKeysEvent:function(t,e,i){return i=i||{},i.mouse=this.mouseLocation,i.keys=this.currentKeys,this.dispatchNewEvent(t,e,i)},finmousemove:function(t){!this.isDragging()&&this.mousedown&&(this.beDragging(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragstart",{isRightClick:this.isRightClick(t)}),this.dragstart=new l.Point(this.mouseLocation.x,this.mouseLocation.y)),this.mouseLocation=this.getLocal(t),this.isDragging()&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-drag",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.bounds.contains(this.mouseLocation)&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousemove")},finmousedown:function(t){this.mouseLocation=this.getLocal(t),this.mousedown=!0,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousedown",{isRightClick:this.isRightClick(t)}),this.takeFocus()},finmouseup:function(t){this.isDragging()&&(this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragend",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.beNotDragging(),this.dragEndtime=Date.now()),this.mousedown=!1,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseup",{isRightClick:this.isRightClick(t)})},finmouseout:function(t){this.mousedown||(this.mouseLocation=new l.Point(-1,-1)),this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseout")},finwheelmoved:function(t){!this.isDragging()&&this.hasFocus()&&(t.preventDefault(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-wheelmoved",{isRightClick:this.isRightClick(t)}))},finclick:function(t){return Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-click",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},finrelease:function(t){this.holdPulseCount=0,this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-release")},finflick:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-flick",{isRightClick:this.isRightClick(t)}))},fintrackstart:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackstart"))},fintrack:function(t){this.hasFocus()&&(this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-track"))},fintrackend:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-trackend")},finhold:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-hold",{isRightClick:this.isRightClick(t)})},finholdpulse:function(t){this.mouseLocation=this.getLocal(t),this.dispatchNewMouseKeysEvent(t,"fin-canvas-holdpulse",{count:this.holdPulseCount++})},fintap:function(t){var e=this,i=Date.now(),n=i-this.lastDoubleClickTime;300>n||i-this.dragEndtime<100||setTimeout(function(){e._fintap(t)},180)},_fintap:function(t){var e=Date.now(),i=e-this.lastDoubleClickTime;300>i||this.dispatchNewMouseKeysEvent(t,"fin-canvas-tap",{isRightClick:this.isRightClick(t)})},findblclick:function(t){this.mouseLocation=this.getLocal(t),this.lastDoubleClickTime=Date.now(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dblclick",{isRightClick:this.isRightClick(t)})},getCharMap:function(){return p},finkeydown:function(t){if(this.hasFocus()){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];t.repeat?this.repeatKey===e?this.repeatKeyCount++:(this.repeatKey=e,this.repeatKeyStartTime=Date.now()):(this.repeatKey=null,this.repeatKeyCount=0,this.repeatKeyStartTime=0),-1===this.currentKeys.indexOf(e)&&this.currentKeys.push(e),this.dispatchNewEvent(t,"fin-canvas-keydown",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)})}},finkeyup:function(t){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(e),1),this.hasFocus()&&(this.repeatKeyCount=0,this.repeatKey=null,this.repeatKeyStartTime=0,this.dispatchNewEvent(t,"fin-canvas-keyup",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeat:t.repeat,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)}))},finfocusgained:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-gained")},finfocuslost:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-lost")},fincontextmenu:function(t){return t.ctrlKey&&-1===this.currentKeys.indexOf("CTRL")&&this.currentKeys.push("CTRL"),Date.now()-this.lastClickTime<250?void this.findblclick(t):(this.dispatchNewMouseKeysEvent(t,"fin-canvas-context-menu",{isRightClick:this.isRightClick(t)}),void(this.lastClickTime=Date.now()))},repaint:function(){var t=this.getFPS();this.dirty=!0,g&&0!==t||this.paintNow()},getMouseLocation:function(){return this.mouseLocation},getOrigin:function(){var t=this.canvas.getBoundingClientRect(),e=new l.Point(t.left,t.top);return e},getLocal:function(t){var e=this.canvas.getBoundingClientRect(),i=new l.Point(t.clientX-e.left,t.clientY-e.top);return i},hasFocus:function(){return document.activeElement===this.canvas},takeFocus:function(){var t=this;this.hasFocus()||setTimeout(function(){t.canvas.focus()},10)},beDragging:function(){this.dragging=!0,this.disableDocumentElementSelection()},beNotDragging:function(){this.dragging=!1,this.enableDocumentElementSelection()},isDragging:function(){return this.dragging},disableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText+"-webkit-user-select: none"},enableDocumentElementSelection:function(){var t=document.body.style;t.cssText=t.cssText.replace("-webkit-user-select: none","")},setFocusable:function(t){this.focuser.style.display=t?"":"none"},isRightClick:function(t){var e;return t=t||window.event,"which"in t?e=3===t.which:"button"in t&&(e=2===t.button),e},dispatchEvent:function(t){return this.canvas.dispatchEvent(t)}},requestAnimationFrame(o),setInterval(r,c),e.exports=n},{"./js/GraphicsContext.js":6,"./js/polymergestures.dev.js":8,rectangular:29}],6:[function(t,e,i){"use strict";function n(t,e){function i(i){i in n.prototype||s.test(i)||("function"==typeof t[i]?r[i]=e?function(){return e(i,arguments,t[i].apply(t,arguments))}:t[i].bind(t):Object.defineProperty(r,i,{get:function(){var n=t[i];return e?e(i,"getter",n):n},set:function(n){t[i]=e?e(i,"setter",n):n}}))}this.gc=t;var r=this,s=/^webkit/;switch(typeof e){case"string":e=o.bind(void 0,e+".");break;case"boolean":e===!0&&(e=o.bind(void 0,"gc."));break;case"function":if(3!==e.length)throw"GraphicsContext: User-supplied API logger function does not accept three parameters.";break;default:e=!1}Object.keys(Object.getPrototypeOf(t)).forEach(i),Object.keys(t).forEach(i)}var o=t("./gc-console-logger");e.exports=n},{"./gc-console-logger":7}],7:[function(t,e,i){"use strict";function n(t,e,i,n){var r=n;switch("string"==typeof n&&(r='"'+r+'"'),e=t+e,i){case"getter":console.log(e,"=",r);break;case"setter":console.log(e,o,r);break;default:e+="("+Array.prototype.slice.call(i).join(", ")+")",void 0===r?console.log(e):console.log(e,o,r)}return n}var o="⟹";e.exports=n},{}],8:[function(t,e,i){!function(t){var e=!1,i=document.createElement("meta");if(i.createShadowRoot){var n=i.createShadowRoot(),o=document.createElement("span");n.appendChild(o),i.addEventListener("testpath",function(t){t.path&&(e=t.path[0]===o),t.stopPropagation()});var r=new CustomEvent("testpath",{bubbles:!0});document.head.appendChild(i),o.dispatchEvent(r),i.parentNode.removeChild(i),n=o=null}i=null;var s={shadow:function(t){return t?t.shadowRoot||t.webkitShadowRoot:void 0},canTarget:function(t){return t&&Boolean(t.elementFromPoint)},targetingShadow:function(t){var e=this.shadow(t);return this.canTarget(e)?e:void 0},olderShadow:function(t){var e=t.olderShadowRoot;if(!e){var i=t.querySelector("shadow");i&&(e=i.olderShadowRoot)}return e},allShadows:function(t){for(var e=[],i=this.shadow(t);i;)e.push(i),i=this.olderShadow(i);return e},searchRoot:function(t,e,i){var n,o;return t?(n=t.elementFromPoint(e,i),n?o=this.targetingShadow(n):t!==document&&(o=this.olderShadow(t)),this.searchRoot(o,e,i)||n):void 0},owner:function(t){if(!t)return document;for(var e=t;e.parentNode;)e=e.parentNode;return e.nodeType!=Node.DOCUMENT_NODE&&e.nodeType!=Node.DOCUMENT_FRAGMENT_NODE&&(e=document),e},findTarget:function(t){if(e&&t.path&&t.path.length)return t.path[0];var i=t.clientX,n=t.clientY,o=this.owner(t.target);return o.elementFromPoint(i,n)||(o=document),this.searchRoot(o,i,n)},findTouchAction:function(t){var i;if(e&&t.path&&t.path.length){for(var n=t.path,o=0;o=0?t=this.walk(t,o):e=this.walk(e,-o);t&&e&&t!==e;)t=t.parentNode||t.host,e=e.parentNode||e.host;return t},walk:function(t,e){for(var i=0;t&&e>i;i++)t=t.parentNode||t.host;return t},depth:function(t){for(var e=0;t;)e++,t=t.parentNode||t.host;return e},deepContains:function(t,e){var i=this.LCA(t,e);return i===t},insideNode:function(t,e,i){var n=t.getBoundingClientRect();return n.left<=e&&e<=n.right&&n.top<=i&&i<=n.bottom},path:function(t){var i;if(e&&t.path&&t.path.length)i=t.path;else{i=[];for(var n=this.findTarget(t);n;)i.push(n),n=n.parentNode||n.host}return i}};t.targetFinding=s,t.findTarget=s.findTarget.bind(s),t.deepContains=s.deepContains.bind(s),t.insideNode=s.insideNode}(i),function(){function t(t){return"html /deep/ "+e(t)}function e(t){return'[touch-action="'+t+'"]'}function i(t){return"{ -ms-touch-action: "+t+"; touch-action: "+t+";}"}var n=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],o="",r="string"==typeof document.head.style.touchAction,s=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(r){n.forEach(function(n){String(n)===n?(o+=e(n)+i(n)+"\n",s&&(o+=t(n)+i(n)+"\n")):(o+=n.selectors.map(e)+i(n.rule)+"\n",s&&(o+=n.selectors.map(t)+i(n.rule)+"\n"))});var l=document.createElement("style");l.textContent=o,document.head.appendChild(l)}}(),function(t){var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],i=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],n=function(){return function(){}},o={preventTap:n,makeBaseEvent:function(t,e){var i=document.createEvent("Event");return i.initEvent(t,e.bubbles||!1,e.cancelable||!1),i.preventTap=o.preventTap(i),i},makeGestureEvent:function(t,e){e=e||Object.create(null);for(var i,n=this.makeBaseEvent(t,e),o=0,r=Object.keys(e);o-1?this.values[i]=e:(this.keys.push(t),this.values.push(e))},has:function(t){return this.keys.indexOf(t)>-1},"delete":function(t){var e=this.keys.indexOf(t);e>-1&&(this.keys.splice(e,1),this.values.splice(e,1))},get:function(t){var e=this.keys.indexOf(t);return this.values[e]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(t,e){this.values.forEach(function(i,n){t.call(e,i,this.keys[n],this)},this)},pointers:function(){return this.keys.length}},t.PointerMap=e}(i),function(t){var e,i=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],n=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],o="undefined"!=typeof SVGElementInstance,r=t.eventFactory,s={IS_IOS:!1,pointermap:new t.PointerMap,requiredGestures:new t.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(t,e){var i=e,n=i.events;n&&(n.forEach(function(t){i[t]&&(this.eventMap[t]=i[t].bind(i))},this),this.eventSources[t]=i,this.eventSourceList.push(i))},registerGesture:function(t,e){var i=Object.create(null);i.listeners=0,i.index=this.gestures.length;for(var n,o=0;oo&&(i=this.eventSourceList[o]);o++)i.register.call(i,t,e)},unregister:function(t){for(var e,i=this.eventSourceList.length,n=0;i>n&&(e=this.eventSourceList[n]);n++)e.unregister.call(e,t)},down:function(t){this.requiredGestures.set(t.pointerId,e),this.fireEvent("down",t)},move:function(t){t.type="move",this.fillGestureQueue(t)},up:function(t){this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},cancel:function(t){t.tapPrevented=!0,this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},addGestureDependency:function(t,e){var i=t._pgEvents;if(i&&e)for(var n,o,r,s=Object.keys(i),l=0;l0&&(n=this.dependencyMap[r],o=n?n.index:-1,e[o]=!0)},eventHandler:function(i){var n=i.type;if("touchstart"===n||"mousedown"===n||"pointerdown"===n||"MSPointerDown"===n)if(i._handledByPG||(e={}),this.IS_IOS){var o=i;if("touchstart"===n){var r=i.changedTouches[0];o={target:i.target,clientX:r.clientX,clientY:r.clientY,path:i.path}}for(var s,l=i.path||t.targetFinding.path(o),a=0;an&&(i=e[n]);n++)this.addEvent(t,i)},unlisten:function(t,e){for(var i,n=0,o=e.length;o>n&&(i=e[n]);n++)this.removeEvent(t,i)},addEvent:function(t,e){t.addEventListener(e,this.boundHandler)},removeEvent:function(t,e){t.removeEventListener(e,this.boundHandler)},makeEvent:function(t,e){var i=r.makePointerEvent(t,e);return i.preventDefault=e.preventDefault,i.tapPrevented=e.tapPrevented,i._target=i._target||e.target,i},fireEvent:function(t,e){var i=this.makeEvent(t,e);return this.dispatchEvent(i)},cloneEvent:function(t){for(var e,r=Object.create(null),s=0;s0&&t._pgListeners--,0===t._pgListeners&&s.unregister(t),t._pgEvents&&(t._pgEvents[i]>0?t._pgEvents[i]--:t._pgEvents[i]=0)),Boolean(n)},t.removeEventListener=function(e,i,n,o){n&&(t.deactivateGesture(e,i),e.removeEventListener(i,n,o))}}(i),function(t){var e=t.dispatcher,i=e.pointermap,n=25,o=[0,1,4,2],r=0,s=/Linux.*Firefox\//i,l=function(){if(s.test(navigator.userAgent))return!1;try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}(),a={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(t){for(var e,i=this.lastTouches,o=t.clientX,r=t.clientY,s=0,l=i.length;l>s&&(e=i[s]);s++){var a=Math.abs(o-e.x),u=Math.abs(r-e.y);if(n>=a&&n>=u)return!0}},prepareEvent:function(t){var i=e.cloneEvent(t);if(i.pointerId=this.POINTER_ID,i.isPrimary=!0,i.pointerType=this.POINTER_TYPE,i._source="mouse",!l){var n=t.type,s=o[t.which]||0;"mousedown"===n?r|=s:"mouseup"===n&&(r&=~s),i.buttons=r}return i},mousedown:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=(i.has(this.POINTER_ID),this.prepareEvent(n));o.target=t.findTarget(n),i.set(this.POINTER_ID,o.target),e.down(o)}},mousemove:function(t){if(!this.isEventSimulatedFromTouch(t)){var n=i.get(this.POINTER_ID);if(n){var o=this.prepareEvent(t);o.target=n,0===(l?o.buttons:o.which)?(l||(r=o.buttons=0),e.cancel(o),this.cleanupMouse(o.buttons)):e.move(o)}}},mouseup:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(this.POINTER_ID),e.up(o),this.cleanupMouse(o.buttons)}},cleanupMouse:function(t){0===t&&i["delete"](this.POINTER_ID)}};t.mouseEvents=a}(i),function(t){var e=t.dispatcher,i=(t.targetFinding.allShadows.bind(t.targetFinding),e.pointermap),n=(Array.prototype.map.call.bind(Array.prototype.map),2500),o=25,r=200,s=20,l=!1,a={IS_IOS:!1,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(t,i){(this.IS_IOS?i:!i)&&e.listen(t,this.events)},unregister:function(t){this.IS_IOS||e.unlisten(t,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(t){var e=t,i=this.scrollTypes;return e===i.EMITTER?"none":e===i.XSCROLLER?"X":e===i.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(t){return this.firstTouch===t.identifier},setPrimaryTouch:function(t){(0===i.pointers()||1===i.pointers()&&i.has(1))&&(this.firstTouch=t.identifier,this.firstXY={X:t.clientX,Y:t.clientY},this.firstTarget=t.target,this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(t){t.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var t=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(t,r)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(t){var e=0;return("touchstart"===t||"touchmove"===t)&&(e=1),e},findTarget:function(e,n){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(e)){var o={clientX:e.clientX,clientY:e.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return t.findTarget(o)}return t.findTarget(e)}return i.get(n)},touchToPointer:function(t){var i=this.currentTouchEvent,n=e.cloneEvent(t),o=n.pointerId=t.identifier+2;n.target=this.findTarget(t,o),n.bubbles=!0,n.cancelable=!0,n.detail=this.clickCount,n.buttons=this.typeToButtons(i.type),n.width=t.webkitRadiusX||t.radiusX||0,n.height=t.webkitRadiusY||t.radiusY||0,n.pressure=t.webkitForce||t.force||.5,n.isPrimary=this.isPrimaryTouch(t),n.pointerType=this.POINTER_TYPE,n._source="touch";var r=this;return n.preventDefault=function(){r.scrolling=!1,r.firstXY=null,i.preventDefault()},n},processTouches:function(t,e){var n=t.changedTouches;this.currentTouchEvent=t;for(var o,r,s=0;s=u}return i}},findTouch:function(t,e){for(var i,n=0,o=t.length;o>n&&(i=t[n]);n++)if(i.identifier===e)return!0},vacuumTouches:function(t){var e=t.touches;if(i.pointers()>=e.length){var n=[];i.forEach(function(t,i){if(1!==i&&!this.findTouch(e,i-2)){var o=t;n.push(o)}},this),n.forEach(function(t){this.cancel(t),i["delete"](t.pointerId)},this)}},touchstart:function(t){this.vacuumTouches(t),this.setPrimaryTouch(t.changedTouches[0]),this.dedupSynthMouse(t),this.scrolling||(this.clickCount++,this.processTouches(t,this.down))},down:function(t){e.down(t)},touchmove:function(t){if(l)t.cancelable&&this.processTouches(t,this.move);else if(this.scrolling){if(this.firstXY){var e=t.changedTouches[0],i=e.clientX-this.firstXY.X,n=e.clientY-this.firstXY.Y,o=Math.sqrt(i*i+n*n);o>=s&&(this.touchcancel(t),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(t)?this.scrolling=!0:(this.scrolling=!1,t.preventDefault(),this.processTouches(t,this.move))},move:function(t){e.move(t)},touchend:function(t){this.dedupSynthMouse(t),this.processTouches(t,this.up)},up:function(i){i.relatedTarget=t.findTarget(i),e.up(i)},cancel:function(t){e.cancel(t)},touchcancel:function(t){t._cancel=!0,this.processTouches(t,this.cancel)},cleanUpPointer:function(t){i["delete"](t.pointerId),this.removePrimaryPointer(t)},dedupSynthMouse:function(e){var i=t.mouseEvents.lastTouches,o=e.changedTouches[0];if(this.isPrimaryTouch(o)){var r={x:o.clientX,y:o.clientY};i.push(r);var s=function(t,e){var i=t.indexOf(e);i>-1&&t.splice(i,1)}.bind(null,i,r);setTimeout(s,n)}}},u=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(e){var i=e.clientX,n=e.clientY,r=function(t){var e=Math.abs(i-t.x),r=Math.abs(n-t.y);return o>=e&&o>=r},s=t.mouseEvents.lastTouches.some(r),l=t.targetFinding.path(e);if(s){for(var c=0;c0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],9:[function(t,e,i){"use strict";e.exports={JSDataSource:t("./js/DataSource"),DataSourceSorter:t("./js/DataSourceSorter"),DataSourceSorterComposite:t("./js/DataSourceSorterComposite"),DataSourceFilter:t("./js/DataSourceFilter"),DataSourceGlobalFilter:t("./js/DataSourceGlobalFilter"),DataSourceAggregator:t("./js/DataSourceAggregator"),util:{aggregations:t("./js/util/aggregations")}}},{"./js/DataSource":14,"./js/DataSourceAggregator":15,"./js/DataSourceFilter":16,"./js/DataSourceGlobalFilter":17,"./js/DataSourceSorter":19,"./js/DataSourceSorterComposite":20,"./js/util/aggregations":22}],10:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataNodeBase",{isNullObject:!1,INDENT:" ",initialize:function(t){this.label=t,this.data=[""],this.index=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1},getValue:function(t){return this.data[t]},toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+" "+this.label},computeHeight:function(){return 1},getIndex:function(){return this.index},computeAggregates:function(t){var e=this.getIndex();if(e.length){var i=Number(t.hasGroups()),n=this.data;n.length=i+t.aggregates.length;var o=t.sorterInstance;o.index=e,t.aggregates.forEach(function(t,e){n[i+e]=t(o)})}},buildView:function(t){t.addView(this)},toggleExpansionState:function(){}});e.exports=o},{"extend-me":3}],11:[function(t,e,i){"use strict";function n(t){return this.splice.bind(this,this.length,0).apply(this,t),this}var o=t("./util/Mappy"),r=t("./DataNodeBase"),s={"true":"▼","false":"▶"},l=r.extend("DataNodeGroup",{extendable:!0,initialize:function(t){this.children=new o},toArray:function(t){this.depth=t,this.children=this.children.values,this.children.forEach(function(e){e.toArray(t+1)}),this.data[0]=this.computeDepthString()},computeDepthString:function(){return Array(this.depth+1).join(this.INDENT)+s[this.expanded]+" "+this.label},getIndex:function(){return 0===this.index.length&&(this.index=this.computeIndex()),this.index},computeIndex:function(){var t=[];return t.append=n,this.children.forEach(function(e){t.append(e.getIndex())}),t},toggleExpansionState:function(t){this.expanded=!this.expanded,this.data[0]=this.computeDepthString(),this.expanded&&this.computeAggregates(t)},computeAggregates:function(t){r.prototype.computeAggregates.call(this,t),this.expanded&&this.children.forEach(function(e){e.computeAggregates(t)})},buildView:function(t){t.view.push(this),this.expanded&&this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.expanded&&this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=l},{"./DataNodeBase":10,"./util/Mappy":21}],12:[function(t,e,i){"use strict";var n=t("./DataNodeBase"),o=n.extend("DataNodeLeaf",{toArray:function(t){this.depth=t,this.data[0]=this.computeDepthString()},getIndex:function(){return this.index},buildView:function(t){t.addView(this)},computeHeight:function(){return 1}});e.exports=o},{"./DataNodeBase":10}],13:[function(t,e,i){"use strict";var n=t("./DataNodeGroup"),o=n.extend("DataNodeTree",{initialize:function(t){this.height=0,this.expanded=!0},toArray:function(){this.children=this.children.values,this.children.forEach(function(t){t.toArray(0)})},buildView:function(t){this.children.forEach(function(e){e.buildView(t)})},computeHeight:function(){var t=1;return this.children.forEach(function(e){t+=e.computeHeight()}),this.height=t}});e.exports=o},{"./DataNodeGroup":11}],14:[function(t,e,i){"use strict";function n(t,e){this.fields=e||r(t[0]),this.data=t}function o(t,e){throw new Error("DataSource."+t+": "+e)}function r(t){return Object.getOwnPropertyNames(t||[]).filter(function(t){return"__"!==t.substr(0,2)})}var s=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,getRow:function(t){return this.data[t]},getValue:function(t,e){var i=this.getRow(e);return i?i[this.fields[t]]:null},setValue:function(t,e,i){this.getRow(e)[this.fields[t]]=i},getRowCount:function(){return this.data.length},getColumnCount:function(){return this.getFields().length},getFields:function(){return this.fields},getHeaders:function(){return this.headers=this.headers||this.getDefaultHeaders().map(function(t){return s(t)})},getDefaultHeaders:function(){return this.getFields()},setFields:function(t){this.fields=t},setHeaders:function(t){t instanceof Array||o("setHeaders","param #1 `headers` not array"),this.headers=t},getGrandTotals:function(){},setData:function(t){this.data=t}},e.exports=n},{"./util/headerify":23}],15:[function(t,e,i){"use strict";function n(t){this.dataSource=t,this.tree=new l("Totals"),this.index=[],this.aggregates=[],this.headers=[],this.groupBys=[],this.view=[],this.sorterInstance={},this.presortGroups=!0,this.lastAggregate={},this.setAggregates({})}function o(t){return new u(t)}function r(t){return new a(t)}var s=t("./DataSourceSorter"),l=t("./DataNodeTree"),a=t("./DataNodeGroup"),u=t("./DataNodeLeaf"),c=t("./util/headerify");n.prototype={constructor:n.prototype.constructor,isNullObject:!1,setAggregates:function(t){this.lastAggregate=t,this.clearAggregations(),this.headers.length=0,this.hasGroups()&&this.headers.push("Tree");for(var e in t)this.addAggregate(e,t[e])},addAggregate:function(t,e){this.headers.push(c(t)),this.aggregates.push(e)},setGroupBys:function(t){var e=this.groupBys;e.length=0,t.forEach(function(t){e.push(t)}),this.setAggregates(this.lastAggregate)},addGroupBy:function(t){this.groupBys.push(t)},hasGroups:function(){return!!this.groupBys.length},hasAggregates:function(){return!!this.aggregates.length},apply:function(){this.buildGroupTree()},clearGroups:function(){this.groupBys.length=0},clearAggregations:function(){this.aggregates.length=0,this.headers.length=0},buildGroupTree:function(){var t=this.groupBys,e=t.length-1,i=this.dataSource,n=i.getRowCount(),a=this.tree=new l("Totals");this.presortGroups&&t.reverse().forEach(function(t){i=new s(i),i.sortOn(t)});for(var u=0;n>u;u++){var c=a;t.forEach(function(t,n){var s=i.getValue(t,u),l=n===e?o:r;c=c.children.getIfUndefined(s,l)}),c.index.push(u)}this.sorterInstance=new s(i),a.toArray(),a.computeAggregates(this),this.buildView()},addView:function(t){this.view.push(t)},buildView:function(){this.view.length=0,this.tree.computeHeight(),this.tree.buildView(this)},viewMakesSense:function(){return this.hasAggregates()},getValue:function(t,e){if(!this.viewMakesSense())return this.dataSource.getValue(t,e);var i=this.view[e];return i?i.getValue(t):null},setValue:function(t,e,i){return this.viewMakesSense()?void 0:this.dataSource.setValue(t,e,i)},getColumnCount:function(){return this.viewMakesSense()?this.getHeaders().length:this.dataSource.getColumnCount()},getRowCount:function(){return this.viewMakesSense()?this.view.length:this.dataSource.getRowCount()},click:function(t){var e=this.view[t];e.toggleExpansionState(this),this.buildView()},getHeaders:function(){return this.viewMakesSense()?this.headers:this.dataSource.getHeaders()},setHeaders:function(t){this.dataSource.setHeaders(t)},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},getGrandTotals:function(){var t=this.tree;return[t.data]},getRow:function(t){if(!this.viewMakesSense())return this.dataSource.getRow(t);var e=this.view[t];return e?e:this.tree},setData:function(t){this.dataSource.setData(t),this.apply()}},e.exports=n},{"./DataNodeGroup":11,"./DataNodeLeaf":12,"./DataNodeTree":13,"./DataSourceSorter":19,"./util/headerify":23}],16:[function(t,e,i){"use strict";function n(t,e){var i=this;return!this.filters.find(function(n){return!n(i.dataSource.getValue(n.columnIndex,t),e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceFilter",{initialize:function(){this.filters=[]},add:function(t,e){e.columnIndex=t,this.filters.push(e)},clearAll:function(){this.filters.length=0,this.clearIndex()},applyAll:function(){this.filters.length?this.buildIndex(n):this.clearIndex()},getRowCount:function(){return this.filters.length?this.index.length:this.dataSource.getRowCount()},aliases:{set:"add"}});e.exports=r},{"./DataSourceIndexed":18}],17:[function(t,e,i){"use strict";function n(t,e){var i=this;return this.visibleColumnMap.find(function(n,o){var r=i.dataSource.getValue(n,t);return i.filter(r,e,t)})}var o=t("./DataSourceIndexed"),r=o.extend("DataSourceGlobalFilter",{set:function(t){this.filter=t},clear:function(){delete this.filter,this.clearIndex()},apply:function(t){if(this.filter){var e=this.visibleColumnMap=[];t.forEach(function(t){e.push(t.index)}),this.buildIndex(n)}else this.clearIndex()},getRowCount:function(){return this.filter?this.index.length:this.dataSource.getRowCount()}});e.exports=r},{"./DataSourceIndexed":18}],18:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("DataSourceIndexed",{isNullObject:!1,initialize:function(t){this.dataSource=t,this.index=[]},transposeY:function(t){return this.index.length?this.index[t]:t},getRow:function(t){return this.dataSource.getRow(this.transposeY(t))},getValue:function(t,e){return this.dataSource.getValue(t,this.transposeY(e))},setValue:function(t,e,i){this.dataSource.setValue(t,this.transposeY(e),i)},getRowCount:function(){return this.index.length||this.dataSource.getRowCount()},getColumnCount:function(){return this.dataSource.getColumnCount()},getFields:function(){return this.dataSource.getFields()},setFields:function(t){return this.dataSource.setFields(t)},setHeaders:function(t){return this.dataSource.setHeaders(t)},getHeaders:function(){return this.dataSource.getHeaders()},getGrandTotals:function(){return this.dataSource.getGrandTotals()},setData:function(t){return this.dataSource.setData(t)},clearIndex:function(){this.index.length=0},buildIndex:function(t){var e=this.dataSource.getRowCount(),i=this.index;this.clearIndex();for(var n=0;e>n;n++)(!t||t.call(this,n,this.dataSource.getRow(n)))&&i.push(n);return i}});e.exports=o},{"extend-me":3}],19:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}var o=t("./DataSourceIndexed"),r=t("./util/stableSort"),s=o.extend("DataSourceSorter",{initialize:function(){this.descendingSort=!1},sortOn:function(t,e){function i(e){return n(o.dataSource.getValue(t,e))}switch(e){case 0:this.clearIndex();break;case void 0:case 1:case-1:var o=this;r.sort(this.buildIndex(),i,e)}}});e.exports=s},{"./DataSourceIndexed":18,"./util/stableSort":24}],20:[function(t,e,i){"use strict";var n=t("./DataSourceIndexed"),o=t("./DataSourceSorter"),r=n.extend("DataSourceSorterComposite",{initialize:function(){this.sorts=[],this.last=this.dataSource},getRow:function(t){return this.last.getRow(t)},sortOn:function(t,e){this.sorts.push([t,e])},applySorts:function(){var t=this.dataSource;this.sorts.forEach(function(e){t=new o(t),t.sortOn.apply(t,e)}),this.last=t},clearSorts:function(){this.sorts.length=0,this.last=this.dataSource},getValue:function(t,e){return this.last.getValue(t,e)},setValue:function(t,e,i){this.last.setValue(t,e,i)}});e.exports=r},{"./DataSourceIndexed":18,"./DataSourceSorter":19}],21:[function(t,e,i){"use strict";function n(){this.keys=[],this.data={},this.values=[]}function o(t){var e=typeof t;switch(e){case"number":case"string":case"boolean":case"symbol":return l+e+"_"+t;case"undefined":return"UNDEFINED";case"object":if(null===t)return"NULL";case"function":return t.___finhash=t.___finhash||l+a++}}function r(t){return t}function s(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!u(t[i],e););else i=[].indexOf.call(t,e);return i}n.prototype={constructor:n.prototype.constructor,set:function(t,e){var i=o(t);i in this.data||(this.keys.push(t),this.values.push(e)),this.data[i]=e},get:function(t){var e=o(t);return this.data[e]},getIfUndefined:function(t,e){var i=this.get(t);return void 0===i&&(i=e(t),this.set(t,i)),i},size:function(){return this.keys.length},clear:function(){this.keys.length=0,this.values.length=0,this.data={}},"delete":function(t){var e=o(t);if(void 0!==this.data[e]){var i=s(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},forEach:function(t){if("function"==typeof t){var e=this.keys,i=this;e.forEach(function(e){var n=i.get(e);t(n,e,i)})}},map:function(t){var e=this.keys,i=new n,o=this;return"function"!=typeof t&&(t=r),e.forEach(function(e){var n=o.get(e),r=t(n,e,o);i.set(e,r)}),i},copy:function(){var t=this.keys,e=new n,i=this;return t.forEach(function(t){var n=i.get(t);e.set(t,n)}),e}};var l=".~.#%_",a=0,u=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e};e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t){return t.getRowCount()}function o(t,e){for(var i=e.getRowCount(),n=0;i--;)n+=e.getValue(t,i);return n}function r(t,e,i,n){for(var o=n.getRowCount();o--;)i=e(i,n.getValue(t,o));return i}function s(t,e){return o(t,e)/e.getRowCount()}function l(t,e){return e.getValue(t,0)}function a(t,e){return e.getValue(t,e.getRowCount()-1)}function u(t,e){for(var i,n=e.getRowCount(),o=s(t,e),r=n,l=0;r--;l+=i*i)i=e.getValue(t,r)-o;return Math.sqrt(l/n)}e.exports={count:function(t){return n},sum:function(t){return o.bind(this,t)},min:function(t){return r.bind(this,t,Math.min,1/0)},max:function(t){return r.bind(this,t,Math.max,-(1/0))},avg:function(t){return s.bind(this,t)},first:function(t){return l.bind(this,t)},last:function(t){return a.bind(this,t)},stddev:function(t){return u.bind(this,t)}}},{}],23:[function(t,e,i){"use strict";function n(t){return(/[a-z]/.test(t)?t:t.toLowerCase()).replace(/[\s\-_]*([^\s\-_])([^\s\-_]+)/g,o).replace(/[A-Z]/g," $&").trim()}function o(t,e,i){return e.toUpperCase()+i}e.exports=n},{}],24:[function(t,e,i){"use strict";function n(t,e,i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}function o(t,e){return t-e}function r(t,e){return e-t}function s(t,e){return e>t?-1:1}function l(t,e){return t>e?-1:1}function a(t){return n.bind(this,"number"===t?o:s,!1)}function u(t){return n.bind(this,"number"===t?r:l,!0)}function c(t,e,i){var n,o;if(void 0===i&&(i=1),t.length){switch(i){case 0:return;case void 0:i=1;case 1:n=a(typeof e(0));break;case-1:n=u(typeof e(0))}var r=new Array(t.length);for(o=0;op&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=A.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+A.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),A=t("templex"),C=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:w[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=C,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=C,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=C;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":2,templex:31}],26:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(),this.checkColumnAutosizing(), -this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0, -this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0,this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){ -var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file +var d=!1;Object.defineProperty(o.prototype,"max",{set:function(t){(!t||"number"!=typeof t||0>=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],27:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return A[t]})}function a(e,i){function o(){if(m&&!A)for(;v.length;)delete f[v.pop()];else v=[];m=!1,A=!1}function r(t){if("string"==typeof t&&(t=t.split(w,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,A=!1;r(i||t.tags);for(var b,E,R,M,D,P,T=new h(e);!T.eos();){if(b=T.pos,R=T.scanUntil(l))for(var B=0,k=R.length;k>B;++B)M=R.charAt(B),s(M)?v.push(f.length):A=!0,f.push(["text",M,b,b+1]),b+=1,"\n"===M&&o();if(!T.scan(l))break;if(m=!0,E=T.scan(y)||"name",T.scan(C),"="===E?(R=T.scanUntil(S),T.scan(S),T.scanUntil(a)):"{"===E?(R=T.scanUntil(d),T.scan(x),T.scanUntil(a),E="&"):R=T.scanUntil(a),!T.scan(a))throw new Error("Unclosed tag at "+T.pos);if(D=[E,R,b,T.pos],f.push(D),"#"===E||"^"===E)g.push(D);else if("/"===E){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+b);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+b)}else"name"===E||"{"===E||"&"===E?A=!0:"="===E&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+T.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,A={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},C=/\s*/,w=/\s+/,S=/\s*=/,x=/\s*\}/,y=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var b=new g;t.clearCache=function(){return b.clearCache()},t.parse=function(t,e){return b.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return b.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],28:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],29:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],31:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i1&&i.unshift(s.pop()),s=[s.join(" ")],i.length&&(s=s.concat(r(t,e,i,n))),s}function s(t,e,i,n){return r(t,e,l(i).split(" "),n)}function l(t){return t.toString().trim().replace(/\s\s+/g," ")}function a(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}var u=t("extend-me").Base,c=u.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,u=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",a(t,s,l,u,c,h,d,!0);var g=(u-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,c=e.bounds.y,h=e.bounds.width,d=e.bounds.height,g=e.headerTextWrapping,f=2,p=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],"object"==typeof a&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle"),(e.backgroundColor||e.isSelected)&&(t.fillStyle=n(e,e.isSelected?e.backgroundSelectionColor:e.backgroundColor),t.fillRect(u,c,h,d));var v=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==v&&(t.fillStyle=v,t.strokeStyle=v),p&&g?this.renderMultiLineText(u,c,d,h,t,e,a):this.renderSingleLineText(u,c,d,h,t,e,a),e.isInCurrentSelectionRectangle&&(t.fillStyle="rgba(0, 0, 0, 0.2)",t.fillRect(u,c,h,d));var m=0;i&&(l=Math.round((d-i.height)/2),t.drawImage(i,u+f,c+l),m=Math.max(i.width+2)),o&&(l=Math.round((d-o.height)/2),s=0,t.drawImage(o,u+h-s-o.width,c+l),m=Math.max(o.width+2)),r&&(l=Math.round((d-r.height)/2),s=Math.round((h-r.width)/2),t.drawImage(r,u+h-s-r.width,c+l),m=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,c,h,d),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*m},renderMultiLineText:function(t,e,i,n,o,r,a){var u=s(o,r,a,n);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,l(a));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=n-c;break;case"center":h=n/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((i-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),o.save(),o.moveTo(t,e),o.lineTo(t+n,e),o.lineTo(t+n,e+i),o.lineTo(t,e+i),o.lineTo(t,e),o.closePath(),o.clip(),o.textAlign=g;for(var m=0;m-1,this.selectionModel=new w,this.selectionModel.getGrid=function(){return i},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(i)}),this.initRenderer(),this.initCanvas(),this.initScrollbars(),this.initGlobalCellEditors(),this.checkScrollbarVisibility(),document.body.addEventListener("copy",function(t){i.checkClipboardCopy(t)}),this.getCanvas().resize()}function o(t,e){if(null===e||void 0===e)return 0;if(e+="",0===e.length)return 0;var i=t.font+e,n=b.get(i);return n||(n=t.measureText(e).width,b.set(i,n)),n}function r(t){var e=r.fontData[t];if(e)return e;e={};var i=document.createElement("span");i.textContent="Hg",i.style.font=t;var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px";var o=document.createElement("div");o.appendChild(i),o.appendChild(n),o.style.position="absolute",document.body.appendChild(o);try{n.style.verticalAlign="baseline";var s=n.getBoundingClientRect(),l=i.getBoundingClientRect();e.ascent=s.top-l.top,n.style.verticalAlign="bottom",e.height=s.top-l.top,e.descent=e.height-e.ascent}finally{document.body.removeChild(o)}return 0!==e.height&&(r.fontData[t]=e),e}function s(){var t={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelectionColor:"rgb(25, 25, 25)",backgroundSelectionColor:"rgb(183, 219, 255)",columnHeaderFont:"12px Tahoma, Geneva, sans-serif",columnHeaderColor:"rgb(25, 25, 25)",columnHeaderBackgroundColor:"rgb(223, 227, 232)",columnHeaderForegroundSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",columnHeaderForegroundColumnSelectionColor:"rgb(25, 25, 25)",columnHeaderBackgroundColumnSelectionColor:"rgb(255, 180, 0)",rowHeaderFont:"12px Tahoma, Geneva, sans-serif",rowHeaderColor:"rgb(25, 25, 25)",rowHeaderBackgroundColor:"rgb(223, 227, 232)",rowHeaderForegroundSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundSelectionColor:"rgb(255, 220, 97)",rowHeaderForegroundRowSelectionColor:"rgb(25, 25, 25)",rowHeaderBackgroundRowSelectionColor:"rgb(255, 180, 0)",filterFont:"12px Tahoma, Geneva, sans-serif",filterColor:"rgb(25, 25, 25)",filterBackgroundColor:"white",filterForegroundSelectionColor:"rgb(25, 25, 25)",filterBackgroundSelectionColor:"rgb(255, 220, 97)",filterCellBorderStyle:"rgba(0,0,0,0.8)",filterCellBorderThickness:"0.4",treeColumnFont:"12px Tahoma, Geneva, sans-serif",treeColumnColor:"rgb(25, 25, 25)",treeColumnBackgroundColor:"rgb(223, 227, 232)",treeColumnForegroundSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundSelectionColor:"rgb(255, 220, 97)",treeColumnForegroundColumnSelectionColor:"rgb(25, 25, 25)",treeColumnBackgroundColumnSelectionColor:"rgb(255, 180, 0)",backgroundColor2:"rgb(201, 201, 201)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:!0,vScrollbarClassPrefix:"",hScrollbarClassPrefix:"",fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:!0,gridLinesV:!0,lineColor:"rgb(199, 199, 199)",lineWidth:.4,defaultRowHeight:15,defaultColumnWidth:100,repaintIntervalRate:60,repaintImmediately:!1,useBitBlit:!1,useHiDPI:!0,editorActivationKeys:["alt","esc"],readOnly:!1,getTextWidth:o,getTextHeight:r,fixedColumnCount:0,fixedRowCount:0,headerColumnCount:0,showRowNumbers:!0,showHeaderRow:!0,showFilterRow:!0,cellSelection:!0,columnSelection:!0,rowSelection:!0,singleRowSelectionMode:!0,columnAutosizing:!0,rowNumberAutosizing:!0,headerTextWrapping:!1,rowResize:!1,editOnDoubleClick:!0};return t}function l(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new v(n,o,r-n,s-o);return l}function a(){u(R);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);R.columnHeaderBackgroundColor=e.color,R.rowHeaderBackgroundColor=e.color,R.topLeftBackgroundColor=e.color,R.lineColor=e.backgroundColor,R.backgroundColor2=o.backgroundColor,R.color=n.color,R.fontFamily=n.fontFamily,R.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),R.columnHeaderColor=e.color,R.rowHeaderColor=e.color,R.topLeftColor=e.color,R.backgroundSelectionColor=e.backgroundColor,R.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),R.columnHeaderForegroundSelectionColor=e.color,R.columnHeaderBackgroundSelectionColor=e.backgroundColor,R.rowHeaderForegroundSelectionColor=e.color,R.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===R.columnHeaderBackgroundSelectionColor||"transparent"===R.lineColor)&&u(R),document.body.removeChild(t),document.body.removeChild(i)}function u(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function c(t){var e="function"==typeof t?t():t;return e||0===e?e:""}function h(){Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})}var d=t("extend-me"),g=t("finbars"),f=t("fincanvas"),p=t("rectangular").Point,v=t("rectangular").Rectangle,m=t("lru-cache"),A=t("object-iterators"),C=t("./Renderer"),w=t("./SelectionModel"),S=t("./stylesheets"),x={},y=!1,b=new m(2e3),E=s(),R=Object.create(E),M=Object.create(R);n.prototype={constructor:n.prototype.constructor,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){var t=this;this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(M),this.selectionModel=new w,this.selectionModel.getGrid=function(){return t},this.cellEditors=Object.create(x),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new p(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.getBehavior().reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},resetTextWidthCache:function(){b=new m(2e3)},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){var e=document.createElement("div");this.div.appendChild(e),x[t.alias]=t},initGlobalCellEditors:function(){if(!y){y=!0,a();var t=["Textfield","Choice","Color","Date","Slider","Spinner"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])})}},toggleColumnPicker:function(){this.getBehavior().toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i?i.x===t&&i.y===e:!1},isColumnHovered:function(t){var e=this.getHoverCell();return e?e.x===t:!1},isRowResizeable:function(){return this.resolveProperty("rowResize")},isRowHovered:function(t){var e=this.getHoverCell();return e?e.y===t:!1},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new p(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(M)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){A(t).each(function(t,e){M[e]=t})},addProperties:function(t){var e=this.getProperties();A(t).each(function(i,n){e[n]=t[n]}),this.refreshProperties()},refreshProperties:function(){this.checkScrollbarVisibility(),this.getBehavior().defaultRowHeight=null,this.isColumnAutosizing()&&this.getBehavior().autosizeAllColumns()},getPrivateState:function(){return this.getBehavior().getPrivateState()},setState:function(t){var e=this;this.getBehavior().setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.getBehavior().getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new p(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.getBehavior().getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(), +this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.getBehavior();t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){var t=this.getBehavior();t.setRenderedColumnCount(this.getVisibleColumns()+1),t.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.getSelectionModel().hasSelections():void 0},getSelectionAsTSV:function(){var t=this.getSelectionModel();if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear(),this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},clearMostRecentColumnSelection:function(){this.getSelectionModel().clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){this.getSelectionModel().clearMostRecentRowSelection()},select:function(t,e,i,n){0>t||0>e||this.getSelectionModel().select(t,e,i,n)},isSelected:function(t,e){return this.getSelectionModel().isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.getSelectionModel(),i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();if(t)return t.getBounds()},resolveProperty:function(t){return this.getProperties()[t]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(){var t=this,e=this.divCanvas=document.createElement("div");this.div.appendChild(e),this.canvas=new f(e,this.renderer);var i=e.style;i.position="absolute",i.top=0,i.right="-200px",i.bottom=0,i.left=0,this.canvas.resizeNotification=function(){t.resized()},this.addFinEventListener("fin-canvas-mousemove",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.keys=e.detail.keys,n.primitiveEvent=e,t.mouseDownState=n,t.delegateMouseDown(n),t.fireSyntheticMouseDownEvent(n),t.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!1,t.isScrollingNow()&&t.setScrollingNow(!1),t.columnDragAutoScrolling&&(t.columnDragAutoScrolling=!1);var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseUp(n),t.mouseDownState&&t.fireSyntheticButtonPressedEvent(t.mouseDownState),t.mouseDownState=null,t.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-tap",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,n.keys=e.detail.keys,t.fireSyntheticClickEvent(n),t.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(e){if(!t.resolveProperty("readOnly")){t.dragging=!0;var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeydownEvent(e),t.delegateKeyDown(e))}),this.addFinEventListener("fin-canvas-keyup",function(e){t.resolveProperty("readOnly")||(t.fireSyntheticKeyupEvent(e),t.delegateKeyUp(e))}),this.addFinEventListener("fin-canvas-track",function(e){if(!t.resolveProperty("readOnly")&&!t.dragging){var i=e.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?t.scrollVBy(-2):i.yDirection<-0&&t.scrollVBy(2):i.xDirection>0?t.scrollHBy(-1):i.xDirection<-0&&t.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-dblclick",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e,t.fireSyntheticDoubleClickEvent(n,e),t.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(e){if(!t.resolveProperty("readOnly")){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(e){var i=e.detail.mouse,n=t.getGridCellFromMousePoint(i);n.primitiveEvent=e.detail.primitiveEvent,t.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.getBehavior().convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.getBehavior().convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){var e=this.getBehavior();e.onWheelMoved(this,t)},delegateMouseExit:function(t){var e=this.getBehavior();e.handleMouseExit(this,t)},delegateContextMenu:function(t){var e=this.getBehavior();e.onContextMenu(this,t)},delegateMouseMove:function(t){var e=this.getBehavior();e.onMouseMove(this,t)},delegateMouseDown:function(t){var e=this.getBehavior();e.handleMouseDown(this,t)},delegateMouseUp:function(t){var e=this.getBehavior();e.onMouseUp(this,t)},delegateTap:function(t){var e=this.getBehavior();e.onTap(this,t)},delegateMouseDrag:function(t){var e=this.getBehavior();e.onMouseDrag(this,t)},delegateDoubleClick:function(t){var e=this.getBehavior();e.onDoubleClick(this,t)},delegateHoldPulse:function(t){var e=this.getBehavior();e.onHoldPulse(this,t)},delegateKeyDown:function(t){var e=this.getBehavior();e.onKeyDown(this,t)},delegateKeyUp:function(t){var e=this.getBehavior();e.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new v(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(!(0>n||0>o)){var r=new p(n,o);this.setMouseDown(r),this.setDragExtent(new p(0,0)),t.isAdded||(t.isAdded=!0,this.div.appendChild(t.getInput())),t.grid=this,t.beginEditAt(r)}},isColumnVisible:function(t){var e=this.getRenderer().isColumnVisible(t);return e},isDataRowVisible:function(t){var e=this.getRenderer().isRowVisible(t);return e},isDataVisible:function(t,e){var i=this.isDataRowVisible(e)&&this.isColumnVisible(t);return i},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t;return e>0&&n++,this.isColumnVisible(n)&&t!==i?!1:(this.scrollBy(e,0),!0)},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t;return e>0&&n++,this.isDataRowVisible(n)&&t!==i?!1:(this.scrollBy(0,e),!0)},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new v(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell,i=this.getColumnCount(),n=this.getRowCount();if(!(e.x>i||e.y>n)){var o=this.getHoverCell(),r=this.getVScrollValue(),s=o.x;o.y<0&&(r=0),o=new p(s,o.y+r),this.getBehavior().cellClicked(o,t)}},setTotalsValueNotification:function(t,e,i){this.fireSyntheticSetTotalsValue(t,e,i)},fireSyntheticSetTotalsValue:function(t,e,i){var n=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i}});this.canvas.dispatchEvent(n)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-key-up",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-key-down",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-key-press",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=c(n.getValue(e,t))}var e,i,n=this,o=this.getSelectionModel().getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=c(i.getValue(e,t))}var e,i=this,n=this.getSelectionModel().getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=c(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=c(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=l(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,r=t.origin.y,s={},a=0;i>a;a++){var u=new Array(n);for(s[this.getField(a+o)]=u,e=0;n>e;e++)u[e]=c(this.getValue(o+a,r+e))}return s},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=l(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,r=[],s=0;e>s;s++){var a=new Array(i);r[s]=a;for(var u=0;i>u;u++)a[u]=c(this.getValue(n+s,o+u))}return r},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.getSelectionModel().getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){var e=t.gridCell,i=this.getBehavior(),n={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};i.enhanceDoubleClickEvent(t);var o=new CustomEvent("fin-double-click",{detail:n});i.cellDoubleClicked(e,t),this.canvas.dispatchEvent(o)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.getBehavior()._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.getBehavior()._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor?this.cellEditor.isEditing:!1},initScrollbars:function(){var t=this,e=new g({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new g({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.getBehavior().getValue(t,e)},setValue:function(t,e,i){this.getBehavior().setValue(t,e,i)},getColumnAlignment:function(t){return this.getBehavior().getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getBehavior(),e=this.getFixedColumnCount(),i=this.getFixedRowCount(),n=this.getColumnCount(),o=this.getRowCount(),r=this.getBounds();if(r){for(var s=r.height-t.getFixedRowsMaxHeight()-15,l=r.width-200-t.getFixedColumnsMaxWidth()-15,a=0,u=0;n>a;a++){var c=this.getColumnWidth(n-a-1);if(u+=c,u>l)break}for(var h=0,d=0;o>h;h++){var g=this.getRowHeight(o-h-1);if(d+=g,d>s)break}var f=1+Math.max(0,n-e-a);this.setHScrollbarValues(f);var p=Math.max(0,o-i-h);this.setVScrollbarValues(p),this.setHScrollValue(Math.min(this.getHScrollValue(),f)),this.setVScrollValue(Math.min(this.getVScrollValue(),p)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new C(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.getBehavior().getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.getBehavior().setColumnWidth(t,e)},getColumnEdge:function(t){return this.getBehavior().getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.getBehavior().getFixedColumnsWidth()},getRowHeight:function(t){return this.getBehavior().getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.getBehavior().setRowHeight(t,e)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior().getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(t){this.getBehavior().topLeftClicked(this,t)},rowHeaderClicked:function(t){this.getBehavior().rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.getBehavior().columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){if(this.isEditable()||this.isFilterRow(e)){var i=this.getCellEditorAt(t,e);if(i){var n=i.editorPoint;if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}}},getCellEditorAt:function(t,e){return this.getBehavior().getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.getBehavior(),e=t.getCursorAt(-1,-1),i=this.getHoverCell();if(i&&i.x>-1&&i.y>-1){var n=i.x+this.getHScrollValue();e=t.getCursorAt(n,i.y+this.getVScrollValue())}this.beCursor(e)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.getBehavior(),i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.getSelectionModel().getSelections();if(t.length){for(var e=this.getBehavior(),i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.getBehavior().getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.getBehavior().swapColumns(t,e)},endDragColumnNotification:function(){this.getBehavior().endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.getBehavior().getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){var i=this.getFilterRowIndex()+1;if(!(i>t)){e=e||[];var n=this.isSingleRowSelectionMode(),o=this.getSelectionModel(),r=o.isRowSelected(t),s=e.indexOf("CTRL")>-1,l=e.indexOf("SHIFT")>-1;s||l?(s&&(r?o.deselectRow(t):(n&&o.clearRowSelection(),o.selectRow(t))),l&&(o.clear(),o.selectRow(this.lastEdgeSelection[1],t))):(o.clear(),r||o.selectRow(t)),r||l||(this.lastEdgeSelection[1]=t),this.repaint()}},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&0!==i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&0!==t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.getBehavior().getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.getBehavior().setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.getBehavior().hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()?0===t:!1},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.getSelectionModel().isColumnOrRowSelected()},selectColumn:function(t,e){this.getSelectionModel().selectColumn(t,e)},selectRow:function(t,e){this.isSingleRowSelectionMode()?(this.getSelectionModel().clearRowSelection(),t=e):e=e||t;var i=Math.min(t,e),n=Math.max(t,e),o=this.getFilterRowIndex()+1;o>i||this.getSelectionModel().selectRow(i,n)},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.getSelectionModel().isRowSelected(t)},isColumnSelected:function(t){return this.getSelectionModel().isColumnSelected(t)},lookupFeature:function(t){return this.getBehavior().lookupFeature(t)},getRow:function(t){return this.getBehavior().getRow(t)},getFieldName:function(t){return this.getBehavior().getFieldName(t)},getColumnIndex:function(t){return this.getBehavior().getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.getBehavior().getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.getBehavior().setGlobalFilter(t)},selectRowsFromCells:function(){var t=this.getSelectionModel();if(this.isSingleRowSelectionMode()){var e=t.getLastSelection();e?this.selectRow(null,e.corner.y):t.clearRowSelection()}else t.selectRowsFromCells()},selectColumnsFromCells:function(){this.getSelectionModel().selectColumnsFromCells()},getSelectedRows:function(){return this.getBehavior().getSelectedRows()},getSelectedColumns:function(){return this.getBehavior().getSelectedColumns()},getSelections:function(){return this.getBehavior().getSelections()},getLastSelectionType:function(){return this.getSelectionModel().getLastSelectionType()},isCellSelected:function(t,e){return this.getSelectionModel().isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.getSelectionModel().isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.getSelectionModel().selectAllRows()},areAllRowsSelected:function(){return this.getSelectionModel().areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.getSelectionModel().clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.getBehavior().getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new p(t,e)},newRectangle:function(t,e,i,n){return new v(t,e,i,n)}},r.fontData={},e.exports=n},{"./Renderer":34,"./SelectionModel":35,"./stylesheets":73,"extend-me":3,finbars:4,fincanvas:5,"lru-cache":26,"object-iterators":28,rectangular:29}],34:[function(t,e,i){"use strict";function n(t,e,i){var n=e.getColumnProperties(-1),o=n.rowHeader,r=e.getImage("checked");t.font=o.font,n.preferredWidth=r.width+7+o.getTextWidth(t,i+1)}var o=t("object-iterators"),r=t("extend-me").Base,s=r.extend("Renderer",{cell:{x:0,y:0,width:0,height:0},scrollHeight:0,viewHeight:0,reset:function(){this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[], +this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},initialize:function(t){this.grid=t,this.bounds={width:0,height:0},this.columnEdges=[],this.columnEdgesIndexMap={},this.renderedColumnMinWidths=[],this.renderedHeight=0,this.rowEdges=[],this.rowEdgesIndexMap={},this.visibleColumns=[],this.visibleRows=[],this.insertionBounds=[]},computeCellsBounds:function(){var t=this.getGrid(),e=this.getScrollTop(),i=this.getScrollLeft(),n=this.getColumnCount(),o=this.getFixedColumnCount(),r=this.getRowCount(),s=this.getFixedRowCount(),l=this.getBounds(),a=l.width;0===a&&(a=t.canvas.width);var u,c,h,d,g,f,p,v,m=l.height;this.getColumnEdges().length=0,this.rowEdges.length=0,this.columnEdges[0]=0,this.rowEdges[0]=0,this.scrollHeight=0,this.visibleColumns.length=0,this.visibleRows.length=0,this.columnEdgesIndexMap={},this.rowEdgesIndexMap={},this.insertionBounds=[];var A=0,C=0;u=0;var w,S,x,y,b=0;for(t.isShowRowNumbers()&&(b--,this.columnEdges[-1]=-1),h=b;n>h&&(g=h,h>=o&&(g+=i,void 0===w&&(w=g),S=g),!(u>a||g>=n));h++)p=this.getColumnWidth(g),u+=p,this.columnEdges[h+1]=Math.round(u),this.visibleColumns[h]=g,this.columnEdgesIndexMap[g]=h,A=A+Math.round(p/2)+C,this.insertionBounds.push(A),C=Math.round(p/2);for(c=0,d=0;r>d&&(f=d,d>=s&&(f+=e,void 0===x&&(x=f),y=f),!(c>m||f>=r));d++)v=this.getRowHeight(f),c+=v,this.rowEdges[d+1]=Math.round(c),this.visibleRows[d]=f,this.rowEdgesIndexMap[f]=d;this.viewHeight=m,this.dataWindow=t.newRectangle(w,x,S-w,y-x)},resolveProperty:function(t){return this.getGrid().resolveProperty(t)},getGrid:function(){return this.grid},_paint:function(t){this.grid&&(this.renderGrid(t),this.getGrid().gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){var t=this.getGrid(),e=t.getFixedRowsHeight();return this.viewHeight-e},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i=!1,n=!1,o=this.getColumnEdges(),r=this.getRowEdges(),s=this.columnEdgesIndexMap[t],l=this.rowEdgesIndexMap[e];void 0===s&&(s=this.columnEdgesIndexMap[t-1],i=!0),void 0===l&&(l=this.rowEdgesIndexMap[e-1],n=!0);var a=o[s],u=r[l],c=o[s+1],h=r[l+1],d=c-a,g=h-u,f=this.cell;return f.x=i?c:a,f.y=n?h:u,f.width=i?0:d,f.height=n?0:g,f},getColumnFromPixelX:function(t){var e,i=0,n=this.getGrid(),o=this.getFixedColumnCount(),r=n.getHScrollValue(),s=this.getColumnEdges();for(e=1;et)return e>o&&(e+=r),e-1;return e>o&&(e+=r),e-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.getGrid(),s=r.getBehavior(),l=0,a=0,u=0,c=this.getColumnEdges(),h=this.getFixedColumnCount(),d=this.getFixedRowCount(),g=this.getScrollLeft(),f=this.getScrollTop();for(n=0;n=h&&(n+=g),o>=d&&(o+=f);var v=-1,m=s.getColumn(n);return m&&(v=m.index),{gridCell:r.newPoint(n,o),mousePoint:r.newPoint(e,i),viewPoint:p,dataCell:r.newPoint(v,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundry:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.getGrid().isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.getGrid(),i=e.getSelectionModel().getSelections();if(i&&0!==i.length){var n=i[i.length-1],o=n.origin;if(-1!==o.x){var r=this.getVisibleColumns(),s=this.getVisibleRows(),l=r[r.length-1],a=s[s.length-1],u=n.extent,c=Math.min(o.x,o.x+u.x),h=Math.min(o.y,o.y+u.y);if(!(c>l||h>a)){var d=Math.max(o.x,o.x+u.x)+1;d=Math.min(d,1+l);var g=Math.max(o.y,o.y+u.y)+1;g=Math.min(g,1+a);var f=this._getBoundsOfCell(c,h),p=Math.round(void 0===f.x?e.getFixedColumnsWidth():f.x),v=Math.round(void 0===f.y?e.getFixedRowsHeight():f.y),m=this._getBoundsOfCell(d,g),A=Math.round(void 0===m.x?e.getFixedColumnsWidth():m.x),C=Math.round(void 0===m.y?e.getFixedRowsHeight():m.y),w=Math.min(p,A),S=Math.min(v,C),x=1+A-p,y=1+C-v;w===A&&(x=p-A),S===C&&(y=v-C),1>x*y||(t.rect(w,S,x,y),t.fillStyle="rgba(0, 0, 0, 0.2)",t.fill(),t.lineWidth=1,t.strokeStyle="black",t.stroke(),t.stroke())}}}},blankOutOverflow:function(t){var e=this.isLastColumnVisible(),i=e?1:0,n=this.getColumnEdges()[this.getColumnEdges().length-i],o=this.getBounds(),r=o.width-200-n,s=o.height;t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(n+1,0,r,s)},renderOverrides:function(t){var e=this.getGrid(),i=e.renderOverridesCache;for(var n in i)if(i.hasOwnProperty(n)){var o=i[n];o&&this.renderOverride(t,o)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},isHovered:function(t,e){return this.getGrid().isHovered(t,e)},isRowHovered:function(t){return this.getGrid().isRowHovered(t)},isColumnHovered:function(t){return this.getGrid().isColumnHovered(t)},paintCells:function(t){try{t.save(),this._paintCells(t)}catch(e){console.error(e)}finally{t.restore()}},isCellSelectedInRow:function(t){return this.getGrid().isCellSelectedInRow(t)},isCellSelectedInColumn:function(t){return this.getGrid().isCellSelectedInColumn(t)},getScrollTop:function(){var t=this.getGrid().getVScrollValue();return t},getScrollLeft:function(){var t=this.getGrid().getHScrollValue();return t},getBehavior:function(){return this.getGrid().getBehavior()},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},getRowHeight:function(t){var e=this.getBehavior().getRowHeight(t);return e},getColumnWidth:function(t){var e=this.getGrid().getColumnWidth(t);return e},isLastColumnVisible:function(){var t=this.getColumnCount()-1,e=-1!==this.visibleColumns.indexOf(t);return e},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.getGrid().getCanvas()},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){for(var t=this.getBehavior(),e=this.getVisibleScrollHeight(),i=this.getGrid().getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.getGrid().getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.getGrid().getColumnCount()},getRowCount:function(){return this.getGrid().getRowCount()},getFixedColumnCount:function(){return this.getGrid().getFixedColumnCount()},getFixedRowCount:function(){return this.getGrid().getFixedRowCount()},getHeaderRowCount:function(){return this.getGrid().getHeaderRowCount()},getHeaderColumnCount:function(){return this.getGrid().getHeaderColumnCount()},_paintCells:function(t){var e,i,o,r=0,s=this.getColumnEdges(),l=this.rowEdges;this.buttonCells={};var a=this.getVisibleColumns(),u=this.getVisibleRows(),c=s[s.length-1],h=l[l.length-1];t.moveTo(0,0),t.rect(0,0,c,h),t.stroke(),t.clip();var d=a.length,g=0;for(this.getGrid().isShowRowNumbers()&&g--,e=g;d>e;e++)for(o=a[e],this.renderedColumnMinWidths[o]=0,i=0;ii,d=n.isFilterRow(i),g=n.isHierarchyColumn(e),f=n.isRowSelected(i),p=n.isColumnSelected(e),v=n.isCellSelected(e,i),m=n.isCellSelectedInColumn(e),A=n.isCellSelectedInRow(i),C=n.areAllRowsSelected();c&&-1===e||g?(f?(s=s.rowHeaderRowSelection,l=Object.create(s),l.isSelected=!0):(s=s.rowHeader,l=Object.create(s),l.isSelected=A),l.isUserDataArea=!1):h?(d?(s=s.filterProperties,l=Object.create(s),l.isSelected=!1):p?(s=s.columnHeaderColumnSelection,l=Object.create(s),l.isSelected=!0):(s=s.columnHeader,l=Object.create(s),l.isSelected=m),l.isUserDataArea=!1):g?(s=s.rowHeader,l=Object.create(s),l.isSelected=A):(l=Object.create(s),l.isSelected=v||f||p,l.isUserDataArea=!0);var w=i-u+1;if(-1===e){var S=f?"checked":"unchecked";l.value=h?"":[r.getImage(S),w,null],0===i?(S=C?"checked":"unchecked",l.value=[r.getImage(S),"",null]):d&&(l.value=[r.getImage("filter-off"),"",null]),l.halign="right"}else l.value=n.getValue(e,i),l.halign=n.getColumnAlignment(e);l.isColumnHovered=this.isRowHovered(e,i),l.isRowHovered=this.isColumnHovered(e,i),l.bounds=this._getBoundsOfCell(e,i),l.isCellSelected=v,l.isRowSelected=f,l.isColumnSelected=p,l.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i);var x=n.mouseDownState;if(x){var y=x.gridCell;l.mouseDown=y.x===e&&y.y===i}l.x=e,l.y=i,r.cellPropertiesPrePaintNotification(l);var b=r.getCellRenderer(l,e,i),E=r.getCellProperties(e,i);o(l).extendOwn(E),l.buttonCells=this.buttonCells,b.paint(t,l),this.renderedColumnMinWidths[e]=Math.max(l.minWidth||0,this.renderedColumnMinWidths[e]),a.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=s},{"extend-me":3,"object-iterators":28}],35:[function(t,e,i){"use strict";function n(){this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={allRowsSelected:!1,getGrid:function(){return null},getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.getGrid().newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.getGrid().selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.getGrid().selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(){this.allRowsSelected=!1,this.selections.length=Math.max(0,this.selections.length-1),this.flattenedX.length=Math.max(0,this.flattenedX.length-1),this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(){this.allRowsSelected=!1,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.rowSelectionModel.clear(),this.columnSelectionModel.clear()},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.allRowsSelected=!0},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.getGrid(),e=t.getHeaderRowCount(),i=t.getRowCount()-e,n=new Array(i),o=0;i>o;o++)n[o]=o+e;return n}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t){t=t||0;var e=this.rowSelectionModel;this.allRowsSelected=!1,e.clear(),this.selections.forEach(function(i){var n=i.origin.y,o=i.extent.y;e.select(n+t,n+o+t)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;e.select(n+t,n+o+t)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":30}],36:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("extend-me").Base,r=t("./Column"),s=t("./images"),l=t("../CellProvider"),a=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&a.indexOf(i)>=0||e&&a.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!0),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.getGrid()._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState();if(e.rowHeights){var i=e.rowHeights[t];if(i)return i}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.getGrid().isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){var t=this.getFixedColumnsWidth();return t},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){this.featureChain&&this.featureChain.toggleColumnPicker(this.getGrid())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return{isNull:!0};var i=e.getProperties();return i?i:{isNull:!0}},setColumnProperties:function(t,e){var i=this.getColumnProperties(t);n(i).extendOwn(e),this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();for(var t=this.getPrivateState(),e=t.columnIndexes.length,i=[],n=0;e>n;n++){var o=t.columnIndexes[n];i.push({id:o,label:this.getHeader(o),field:this.getField(o)})}return i},getField:function(t){if(-1===t)return"tree";var e=this.getColumn(t);return e.getField()},getHeader:function(t){if(-1===t)return"Tree";var e=this.getColumn(t);return e.getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;no;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r}},getDefaultDataModel:function(){var t=new s,e=new r(this.getGrid(),t);return e.setComponent(t),e},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.getGrid().isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},getData:function(){return this.getDataModel().getData()},getCellEditorAt:function(t,e){var i=this.getGrid();return i.isFilterRow(e)?i.cellEditors.textfield:void 0},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},openEditor:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;i0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)}});e.exports=r},{"extend-me":3}],53:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return function(e){return e=n(e),(e+"").toLowerCase().search(t.toLowerCase())>-1}}var r=t("hyper-analytics"),s=t("./DataModel"),l="▲",a="▼",u={isNullObject:function(){return!0},getFields:function(){return[]},getHeaders:function(){return[]},getColumnCount:function(){return 0},getRowCount:function(){return 0},getGrandTotals:function(){return[]},hasAggregates:function(){return!1},hasGroups:function(){return!1},getRow:function(){return null}},c=s.extend("dataModels.JSON",{source:u,preglobalfilter:u,prefilter:u,presorter:u,analytics:u,postfilter:u,postsorter:u,topTotals:[],hasAggregates:function(){return this.analytics.hasAggregates()},hasGroups:function(){return this.analytics.hasGroups()},getDataSource:function(){return this.analytics},getFilterSource:function(){return this.prefilter},getSortingSource:function(){return this.presorter},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();return n&&-2===t&&(t=0),r>e?i=this.getHeaderRowValue(t,e):(n&&(e+=1),i=this.getDataSource().getValue(t,e-r))},getHeaderRowValue:function(t,e){if(void 0===e)return this.getHeaders()[Math.max(t,0)];var i=this.getGrid(),n=i.getBehavior(),o=i.isShowFilterRow(),r=i.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)return this.getTopTotals()[e-l][t];var a,u,c=this.getFilter(t),h=0===c.length?"filter-off":"filter-on";return s?0===e?(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null]):[null,c,n.getImage(h)]:o?[null,c,n.getImage(h)]:(a=this.getHeaders()[t],u=this.getSortImageForColumn(t,!0),u&&(a=u+a),[null,a,null])},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.getGrid(),r=o.getHeaderRowCount();if(n){if(-2===t)return;t+=1}r>e?this.setHeaderRowValue(t,e,i):n?e+=1:this.getDataSource().setValue(t,e-r,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.getGrid(),o=n.isShowFilterRow(),r=n.isShowHeaderRow(),s=o&&r,l=(o?1:0)+(r?1:0);if(e>=l)this.getTopTotals()[e-l][t]=i;else{if(-1===t)return;if(s){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!o)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.getBehavior().allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e=this.getColumnProperties(t);return e?e.filter||"":""},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){return this.analytics.getColumnCount()},getRowCount:function(){var t=this.getGrid(),e=this.getDataSource().getRowCount();return e+=t.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},getData:function(){return this.source},setData:function(t){this.source=new r.JSDataSource(t),this.preglobalfilter=new r.DataSourceGlobalFilter(this.source),this.prefilter=new r.DataSourceFilter(this.preglobalfilter),this.presorter=new r.DataSourceSorterComposite(this.prefilter),this.analytics=new r.DataSourceAggregator(this.presorter),this.applyAnalytics()},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setTopTotals:function(t){this.topTotals=t},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.getGrid().fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;or;r++){var s=t[r].index,l=this.getFilter(s);l.length>0&&i.add(s-n,o(l))}i.applyAll()},toggleSort:function(t,e){this.incrementSortState(t,e),this.applyAnalytics()},incrementSortState:function(t,e){t++;var i=this.getPrivateState(),n=e.indexOf("CTRL")>-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},applySorts:function(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;no&&(o=n.indexOf(-1*t),i=!1),0>o)return null;var r=n.length-o;if(e){var s=i?l:a;return r+s+" "}var u=r+(i?"-up":"-down");return this.getBehavior().getImage(u)},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.getGrid(),n=i.getHeaderRowCount(),o=e.gridCell.y-n+1;this.analytics.click(o),this.changed()}},getRow:function(t){var e=this.getGrid(),i=e.getHeaderRowCount();if(i>t&&!this.hasAggregates()){var n=this.getTopTotals();return n[t-(i-n.length)]}return this.getDataSource().getRow(t-i)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=o&&i.x>=r?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":63}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){var i=t.getBehavior(),n=i.getHeaderRowCount(),o=i.getHeaderColumnCount(),r=e.gridCell;r.x>=o&&r.y>=n?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)}});e.exports=o},{"./Feature.js":63}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=t.getBehavior(),o=e.gridCell,r=e.viewPoint,s=o.x,l=o.y,a=n.getHeaderRowCount(),u=n.getHeaderColumnCount(),c=n.getColumnCount(),h=r.x>=c,d=a>l||u>s;if(!t.isCellSelection()||i||d||h)this.next&&this.next.handleMouseDown(t,e);else{var g=t.getFixedColumnCount(),f=t.getFixedRowCount();r.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=-1!==i.indexOf("CTRL"),o=-1!==i.indexOf("SHIFT"),r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(), +t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":63}],58:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":63}],59:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.getBehavior().isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundry()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":63}],60:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":63}],61:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){return this.dragging&&(this.dragging=!1),this.next?void this.next.handleMouseUp(t,e):void 0},handleMouseDown:function(t,e){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowHeaderRow()&&0===s&&-1!==r;if(i||!l)this.next&&this.next.handleMouseDown(t,e);else{var a=t.getFixedColumnCount();o.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=o},{"./Feature.js":63}],62:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":63}],63:[function(t,e,i){"use strict";var n=t("extend-me").Base,o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},toggleColumnPicker:function(t){this.next&&this.next.toggleColumnPicker(t)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.y-1&&this.toggleColumnPicker(t)},toggleColumnPicker:function(t){this.isColumnPickerOpen(t)?this.closeColumnPicker(t):this.openColumnPicker(t)},isColumnPickerOpen:function(t){return"none"!==this.overlay.style.display},openColumnPicker:function(t){if(!this.isColumnPickerOpen()&&(this.openEditor=!0,t.getBehavior().openEditor(this.overlay)!==!1)){var e=this;this.overlay.style.backgroundColor=t.resolveProperty("backgroundColor"),this.overlay.style.top="0%",this.overlay.style.right="0%",this.overlay.style.bottom="0%",this.overlay.style.left="0%",this.overlay.style.marginTop="15px",this.overlay.style.marginRight="35px",this.overlay.style.marginBottom="35px",this.overlay.style.marginLeft="15px",e.overlay.style.display="",this._closer||(this._closer=function(i){var n=e.getCharFor(t,i.keyCode).toLowerCase(),o=t.resolveProperty("editorActivationKeys");(o.indexOf(n)>-1||27===i.keyCode)&&(i.preventDefault(),e.closeColumnPicker(t))}),requestAnimationFrame(function(){e.overlay.style.opacity=.95,document.addEventListener("keydown",e._closer,!1)}),setTimeout(function(){e.overlay.focus()},100)}},closeColumnPicker:function(t){if(this.isColumnPickerOpen()&&this.openEditor&&(this.openEditor=!1,t.getBehavior().closeEditor(this.overlay)!==!1)){document.removeEventListener("keydown",this._closer,!1);var e=this;requestAnimationFrame(function(){e.overlay.style.opacity=0}),setTimeout(function(){e.overlay.innerHTML="",e.overlay.style.display="none",t.takeFocus()},o)}},initializeOn:function(t){this.initializeOverlaySurface(t),this.next&&this.next.initializeOn(t)},initializeOverlaySurface:function(t){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.style.outline="none",this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",this.overlay.style.position="absolute",this.overlay.style.display="none",this.overlay.style.transition="opacity "+o+"ms ease-in",this.overlay.style.opacity=0,this.overlay.style.zIndex=10,t.div.appendChild(this.overlay)},getCharFor:function(t,e){var i=t.getCanvas().getCharMap();return i[e][0]}});e.exports=r},{"./Feature.js":63}],68:[function(t,e,i){"use strict";var n=t("./ColumnResizing"),o=n.extend("RowResizing",{alias:"RowResizing",dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.y},getGridCellValue:function(t){return t.x},getScrollValue:function(t){return t.getVScrollValue()},getAreaSize:function(t,e){return t.getRowHeight(e)},setAreaSize:function(t,e,i){t.setRowHeight(e,i)},overAreaDivider:function(t,e){return t.overRowDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedColumn(t,e)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(t,e){return t.getRenderedHeight(e)},getOtherFixedAreaCount:function(t){return t.getFixedColumnCount()},getFixedAreaCount:function(t){return t.getFixedRowCount()+t.getHeaderRowCount()},isEnabled:function(t){return t.isRowResizeable()}});e.exports=o},{"./ColumnResizing":60}],69:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("RowSelection",{alias:"RowSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,dragArmed:!1,handleMouseUp:function(t,e){this.dragArmed?(this.dragArmed=!1,-1===e.gridCell.x&&0===e.gridCell.y&&t.toggleSelectAllRows(),t.fireSyntheticRowSelectionChangedEvent()):this.dragging?(this.dragging=!1,t.fireSyntheticRowSelectionChangedEvent()):this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.isShowRowNumbers()&&0>r;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":63}],70:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":63}],71:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),Overlay:t("./Overlay"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":55,"./CellEditing":56,"./CellSelection":57,"./ColumnAutosizing":58,"./ColumnMoving":59,"./ColumnResizing":60,"./ColumnSelection":61,"./ColumnSorting":62,"./Feature":63,"./Filters":64,"./KeyPaging":65,"./OnHover":66,"./Overlay":67,"./RowResizing":68,"./RowSelection":69,"./ThumbwheelScrolling":70}],72:[function(t,e,i){"use strict";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e})},{}],73:[function(t,e,i){"use strict";function n(t,e){o(r[t],t,e)}var o=t("css-injector"),r={grid:["div#grid-container {"," position: relative;"," display: inline-block;"," -webkit-user-select: none;"," -moz-user-select: none;"," -ms-user-select: none;"," -o-user-select: none;"," user-select: none;"," overflow: hidden; }","visible { opacity: 0.75; }","hidden { opacity: 0.0; }","editor {"," position: absolute;"," display: none;"," border: solid 2px black;"," outline: 0;"," padding: 0;"," z-index: 1000; }"],"list-dragon":["div.dragon-list, li.dragon-pop {"," font-family: Roboto, sans-serif;"," text-transform: capitalize; }","div.dragon-list {"," position: absolute;"," top: 4%;"," left: 4%;"," height: 92%;"," width: 20%; }","div.dragon-list:nth-child(2) { left: 28%; }","div.dragon-list:nth-child(3) { left: 52%; }","div.dragon-list:nth-child(4) { left: 76%; }","div.dragon-list > div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":2}]},{},[54]); \ No newline at end of file