"use strict";
/* TODO auto-generated eslint ignore, please fix! */
/* eslint @typescript-eslint/no-var-requires: "off", @typescript-eslint/no-this-alias: "off", @typescript-eslint/no-inferrable-types: "off", no-var: 'off', prefer-arrow-callback: 'off', no-unused-vars: 'off', prefer-const: 'off', no-undef: 'off' */
/**
 * General UI logic for groups
 *
 *  Copyright (C) 2010-2019 R-T Specialty, LLC.
 *
 *  This file is part of liza.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @needsLove
 *   - References to "quote" should be replaced with generic terminology
 *     representing a document.
 *   - Dependencies need to be liberated: Styler; Group.
 *   - This class is doing too much.
 * @end needsLove
 */
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupUi = void 0;
var EventEmitter = require('events').EventEmitter;
/**
 * Styles a group for display in the UI
 */
var GroupUi = /** @class */ (function (_super) {
    __extends(GroupUi, _super);
    /**
     * Initializes GroupUi
     *
     * @todo remove root (DOM) context, and na field styler!
     *
     * @param group         - group to style
     * @param content       - the group content
     * @param styler        - styler to use to style elements
     * @param jquery        - jQuery-compatible object
     * @param context       - group context
     * @param rcontext      - root context
     * @param na_styler     - styler for fields that are N/A
     * @param feature_flag  - toggle access to new UI features
     * @param state_manager - state manager for the group
     */
    function GroupUi(group, content, styler, jquery, context, rcontext, _na_styler, _feature_flag, _state_manager) {
        var _this = _super.call(this) || this;
        _this._na_styler = _na_styler;
        _this._feature_flag = _feature_flag;
        _this._state_manager = _state_manager;
        /**
         * Raised when an index is added to the group (e.g. row addition)
         */
        _this.EVENT_INDEX_ADD = 'indexAdd';
        /**
         * Raised when an index is removed from the group (e.g. row deletion)
         */
        _this.EVENT_INDEX_REMOVE = 'indexRemove';
        /**
         * Raised when an index is reset rather than removed
         */
        _this.EVENT_INDEX_RESET = 'indexReset';
        /**
         * Emitted when a row/tab/etc is added to a group
         */
        _this.EVENT_POST_ADD_ROW = 'postAddRow';
        /**
         * An action taken by the user
         */
        _this.EVENT_ACTION = 'action';
        /**
         * Functions to call when group is invalidated
         * @type {Array.<Function>}
         */
        _this.invalidateHooks = [];
        /**
         * Whether the group is visible
         */
        _this._visible = true;
        /**
         * Number of indexes (1-based)
         */
        _this._indexCount = 0;
        /**
         * Whether the group is active (available for the user to interact with)
         */
        _this._active = false;
        /**
         * Continuation to perform on step visit
         * @type {function()}
         */
        _this._emptyOnVisit = null;
        /**
         * Field visibility cache by field id (reduces DOM lookups)
         */
        _this._visCache = {};
        /**
         * Number of visibile fields per index
         */
        _this._visCount = [];
        /**
         * Number of visibile fields, including multiple indexes
         */
        _this._visCountTotal = 0;
        /**
         * Number of unique fields, disregarding indexes
         */
        _this._rawFieldCount = 0;
        /**
         * An array of classifications with css classes we
         * would like to bind to them
         *
         * Structured: classification => css class
         */
        _this._bind_classes = [];
        /**
         * Root DOM context (deprecated)
         * @type {DomContext}
         */
        _this.rcontext = null;
        /**
         * Array of direct parent of field content per index
         */
        _this.fieldContentParent = [];
        /**
         * jQuery object
         */
        _this.jquery = null;
        /**
         * Whether or not we will determine visibility with classifications
         */
        _this._use_vis_class = true;
        _this.group = group;
        _this.content = content;
        _this.styler = styler;
        _this.jquery = jquery;
        _this.context = context;
        _this.rcontext = rcontext;
        // Todo: Transition away from jQuery
        _this.$content = _this.jquery(content);
        return _this;
    }
    GroupUi.prototype.init = function (quote) {
        var fields = this.group.getExclusiveFieldNames();
        var cmatch_fields = this.group.getExclusiveCmatchFieldNames();
        this.context.init(fields, cmatch_fields, this.content, this.group.isInternal());
        if (this.getDomPerfFlag() === true) {
            var detach_fields = this.supportsMultipleIndex()
                ? fields
                : cmatch_fields;
            this.context.detachStoreContent(detach_fields);
        }
        this._initActions();
        this._monitorIndexChange(quote);
        this.processContent(quote);
        // in an attempt to prevent memory leaks
        this._emptyOnVisit = null;
        // get the number of unique fields in the group
        this._rawFieldCount = this.group.getUserFieldNames().length;
        if (this.group.getWhenFieldName() === '') {
            this._use_vis_class = false;
        }
        this._bindClasses(quote);
        return this;
    };
    GroupUi.prototype._monitorIndexChange = function (quote) {
        var _self = this, first = this.getFirstElementName();
        quote.on('preDataUpdate', function (data) {
            // ignore if the data has not changed
            if (data[first] === undefined) {
                return;
            }
            // get the data from the bucket (the staging data is not useful for
            // determining the length, since it only includes what has changed,
            // which will be void of any higher, unchanged indexes)
            var blen = quote.getDataByName(first).length, dlen = _self._stripRm(data[first]).length, len = 0, rm = [];
            // did we remove an index? if so, then this represents the correct
            // length.
            if (dlen < data[first].length) {
                len = dlen;
                // keep a record of which indexes were removed
                var df = data[first];
                for (var i = 0, l = df.length; i < l; i++) {
                    if (df[i] === null) {
                        rm.push(i);
                    }
                }
            }
            else {
                // otherwise, it's a change; take the longer length
                len = blen > dlen ? blen : dlen;
            }
            if (len === _self.getCurrentIndexCount()) {
                return;
            }
            function doempty() {
                // TODO: knock it off.
                quote.visitData(function (_) {
                    // we cannot call preEmptyBucket because the bucket, at this
                    // point, has not yet been modified with the new data
                    _self._quickIndexChange(true, len, rm);
                });
            }
            // if we're not an active group, then theres little use in updating
            // ourselves; next time they visit the step, we can update ourselves
            // (not only does this help with performance, but it also eliminates
            // some problems that may occur due to us not being attached to the
            // DOM)
            if (!_self._active) {
                // store the latest continuation
                _self._emptyOnVisit = doempty;
                return;
            }
            doempty();
        });
    };
    /**
     * Strip removes from a data diff
     *
     * Removes are represented by nulls
     *
     * @param data - data diff
     *
     * @return data with nulls stripped
     */
    GroupUi.prototype._stripRm = function (data) {
        for (var i in data) {
            if (data[i] === null) {
                // null marks the end of the data
                return data.slice(0, i);
            }
        }
        return data;
    };
    /**
     * Performs any necessary processing on the content before its displayed
     *
     * Subtypes may override this for custom functionality
     */
    GroupUi.prototype.processContent = function (_quote) { };
    /**
     * Group types that can support multiple index
     */
    GroupUi.prototype.supportsMultipleIndex = function () {
        return true;
    };
    /**
     * Gets the DOM Performance Flag
     */
    GroupUi.prototype.getDomPerfFlag = function () {
        return this._feature_flag.isEnabled('dom_perf_flag');
    };
    /**
     * Trigger events on action interaction
     */
    GroupUi.prototype._initActions = function () {
        var _self = this;
        this.$content.find('.action').live('click', function (e) {
            e.preventDefault();
            // TODO: index
            var $this = _self.jquery(e.target), ref = $this.attr('data-ref'), type = $this.attr('data-type'), index = +$this.attr('data-index') || 0;
            _self.emit(_self.EVENT_ACTION, type, ref, index);
        });
    };
    /**
     * Attempts to return the group id of the group containing the given element
     *
     * This method will cache the value of the id upon the first request by
     * replacing itself with a function that returns only the value.
     *
     * @return group id or undefined if no group/id exists
     */
    GroupUi.prototype.getGroupId = function () {
        var id = this.$content.attr('id');
        return id;
    };
    /**
     * Sets the index (for the name attribute) of all given elements
     *
     * The name format is expected to be: name_i, where i is the index.
     *
     * @param elements - elements to set index on
     * @param index    - index to set
     */
    GroupUi.prototype.setElementIdIndexes = function (elements, index) {
        for (var i = 0; i < elements.length; i++) {
            var element = elements[i];
            var id = element.getAttribute('id') || '';
            var element_data = 0;
            // grab the index from the id if found
            if ((element_data = id.match(/^(.*?)(\d+)$/))) {
                // regenerate the id
                element.setAttribute('id', element_data[1] + index);
            }
            element.setAttribute('data-index', index);
        }
    };
    /**
     * Watches the first element for changes and invalidates the group when it
     * does
     *
     * This is used when groups base their row/tab/whatever count on the first
     * element to ensure that they are properly regenerated when the count
     * changes.
     */
    GroupUi.prototype.watchFirstElement = function ($base, quote) {
        var group = this, first_name = this.getFirstElementName($base);
        if (first_name) {
            quote.on('dataCommit', function (data) {
                var first_data = data[first_name];
                if (first_data === undefined) {
                    return;
                }
                group.invalidate();
            });
        }
    };
    /**
     * Retireve the current index count
     *
     * This should be one more than the current 0-based index (like an array
     * length). Subtypes may override this if they do not wish to use the
     * built-in index tracking.
     *
     * @return index count
     */
    GroupUi.prototype.getCurrentIndexCount = function () {
        return this._indexCount;
    };
    GroupUi.prototype.getCurrentIndex = function () {
        return this.getCurrentIndexCount() - 1;
    };
    /**
     * Allows groups to do any necessary processing before a bucket is emptied
     *
     * For example, a group may need to recreate rows in order to make room for
     * the values stored in the bucket.
     *
     * Subtypes are free to override this if the default functionality is
     * insufficient. Note that there are a number of methods used by this one
     * that too may be overridden to alter its functionality without overriding
     * this method.
     *
     * @param bucket  - bucket
     * @param updated - whether this is an update (rather than inital
     *                          append)
     */
    GroupUi.prototype.preEmptyBucket = function (bucket, updated) {
        var first = this.getFirstElementName(), flen = bucket.getDataByName(first).length;
        this._quickIndexChange(updated, flen);
        return this;
    };
    GroupUi.prototype._quickIndexChange = function (updated, len, rm) {
        if (rm === void 0) { rm = []; }
        var _self = this, curlen = this.getCurrentIndexCount();
        this.handleIndexChange(len, curlen, function __add(n) {
            do {
                _self.addIndex(len - n);
            } while (--n);
        }, function __rm(n) {
            while (n--) {
                _self.removeIndex(rm.pop());
            }
        });
        this.postPreEmptyBucket();
        if (!updated) {
            this.postPreEmptyBucketFirst();
        }
    };
    /**
     * Indicates that a tab/row/column/etc (representing an index) should be
     * added
     *
     * Subtypes may override this for custom functionality.
     *
     * @param index - index that has been added
     */
    GroupUi.prototype.addIndex = function (index) {
        this._indexCount++;
        this._recalcFieldCount(1, index);
        return this;
    };
    /**
     * Indicates that a tab/row/column/etc (representing an index) should be
     * removed
     *
     * The last index in the group should be removed.
     *
     * Subtypes may override this for custom functionality.
     *
     * @param index - index that has been removed
     */
    GroupUi.prototype.removeIndex = function (index) {
        var fields = this.group.getExclusiveFieldNames();
        for (var field in fields) {
            var cached = this._visCache[fields[field]];
            cached !== undefined && cached.pop();
        }
        this._indexCount--;
        this._recalcFieldCount(-1, index);
        return this;
    };
    /**
     * Allows for processing after preEmptyBucket() has been run without
     * overriding preEmptyBucket() itself
     */
    GroupUi.prototype.postPreEmptyBucket = function () {
        return this;
    };
    GroupUi.prototype.postPreEmptyBucketFirst = function () {
        return this;
    };
    /**
     * Invokes add/remove procedures based on what must be done given a number
     * of indexes and the current number of indexes
     *
     * If any indexes need to be added/removed (subject to min/max limits), the
     * appropriate callback will be called with the number of adds/removes to be
     * performed respectively. Otherwise, no callback will be called.
     *
     * @param n   - desired index count
     * @param cur - current index count
     * @param ca  - add continuation
     * @param crm - remove continuation
     */
    GroupUi.prototype.handleIndexChange = function (n, cur, ca, crm) {
        var min = this.group.minRows(), max = this.group.maxRows(), diff = n - cur, len = cur + diff;
        // restrict to min/max
        if (len < min) {
            len = min;
        }
        else if (max > 0 && len > max) {
            len = max;
        }
        // now that we have the desired length, calculate that difference (may
        // not differ from diff unless a max/min is hit)
        var truediff = len - cur;
        // we have nothing to do if the diff is 0
        if (truediff === 0) {
            return this;
        }
        // call the add/remove callback depending on our diff
        (truediff < 0 ? crm : ca)(Math.abs(truediff));
        return this;
    };
    /**
     * Initialize an index to be added to the group
     *
     * This action simply raises an event that hooks may properly handle---that
     * is, we're merely indicating our desire to add an index. Whether or not
     * it actually happens [correctly] is beyond our control.
     *
     * If properly handled, presumably the bucket will be updated with the new
     * index and that, in turn, will kick off the hooks to add the necessary UI
     * elements to reflect the addition.
     */
    GroupUi.prototype.initIndex = function () {
        this.emit(this.EVENT_INDEX_ADD, this.getCurrentIndexCount());
        return this;
    };
    /**
     * Initialize an index to be removed from the group
     *
     * This action simply raises an event that hooks may properly handle---that
     * is, were merely indicating our desire to remove an index. Whether or not
     * it actually happens [correctly] is beyond our control.
     *
     * If properly handled, presumably the bucket will be updated to reflect the
     * deletion and the hooks will then kick off the necessary UI updates.
     */
    GroupUi.prototype.destroyIndex = function (index) {
        index = index === undefined ? this.getCurrentIndex() : +index;
        this.emit(this.EVENT_INDEX_REMOVE, index);
        var fields = this.group.getExclusiveFieldNames();
        this.context.removeIndex(fields, index, this.getCurrentIndexCount());
        return this;
    };
    /**
     * Allows group to perform any necessary operations before an element is
     * scrolled to
     *
     * @param field_name - name of field to display
     * @param i          - index of field
     */
    GroupUi.prototype.preScrollTo = function (field_name, i) {
        // do not do anything if this group does not contain the requested field
        if (!this.group.hasExclusiveField(field_name)) {
            return this;
        }
        // let subtypes display the element in whatever manner makes sense
        this.displayField(field_name, i);
        return this;
    };
    /**
     * Display the requested field
     *
     * The field should not be given focus; it should just be brought to the
     * foreground.
     *
     * This is intended for groups that may conceal fields from the user (e.g.
     * tabbed groups).
     *
     * @param field_name - name of field to display
     * @param i          - index of field
     */
    GroupUi.prototype.displayField = function (_field_name, _i) {
        // subtypes must override this method if they have the ability to
        // conceal fields from the user (e.g. tabs)
        return this;
    };
    GroupUi.prototype.getId = function () {
        // return all but the beginning 'group_'
        return this.$content.attr('id').substring(6);
    };
    /**
     * Bind css classes to classifications
     *
     * @param quote - the quote to listen on
     */
    GroupUi.prototype._bindClasses = function (quote) {
        // Get the css classes that we would like to bind to classifications
        this._bind_classes = this._getBindClasses();
        var self = this;
        quote.onClassifyAndNow(function (classes) {
            var _a;
            for (var bind_class in self._bind_classes) {
                var css_class = self._bind_classes[bind_class];
                if (classes[bind_class] && classes[bind_class].is === true) {
                    self.content.classList.add(css_class);
                }
                else {
                    self.content.classList.remove(css_class);
                }
            }
            if (self._use_vis_class) {
                ((_a = classes[self.group.getWhenFieldName()]) === null || _a === void 0 ? void 0 : _a.is) === true
                    ? self.show()
                    : self.hide();
            }
            self.onClassify();
        });
    };
    /**
     * Called on quote classification
     *
     * Can be overridden in child classes
     *
     */
    GroupUi.prototype.onClassify = function () { };
    /**
     * Get the class attributes and their classifiers
     *
     * @return bound classes and their conditional classifications
     */
    GroupUi.prototype._getBindClasses = function () {
        // return all but the beginning group_
        var class_str = this.content.getAttribute('data-class-bind');
        if (!class_str) {
            return [];
        }
        var classes = [];
        class_str.split(' ').forEach(function (datum) {
            var kv = datum.split(':');
            if (!kv[0] || !kv[1]) {
                return;
            }
            // Add the classifications as the keys and the css class as value
            classes[kv[1]] = kv[0];
        });
        return classes;
    };
    /**
     * Gets the name of the first question or answer element available
     *
     * This method exists because answer elements cannot have name attributes.
     * Instead they store the reference name in a 'ref_id' data key.
     *
     * @param $parent - parent element to search
     *
     * @return String name, otherwise empty string
     */
    GroupUi.prototype.getFirstElementName = function (_$parent) {
        return this.group.getIndexFieldName();
    };
    /**
     * Hooks the event to be triggered when a row is added to a group
     *
     * Children should call this method when they add a new row.
     *
     * @param $element - element that was added
     * @param index    - index of the added element
     */
    GroupUi.prototype.postAddRow = function (_$element, index) {
        this.emit(this.EVENT_POST_ADD_ROW, index);
        return this;
    };
    GroupUi.prototype.hide = function () {
        this.$content.hide();
        this._visible = false;
        return this;
    };
    GroupUi.prototype.show = function () {
        this.$content.show();
        this._visible = true;
        return this;
    };
    /**
     * Hides the field based on field name and index
     *
     * @param field - field name
     * @param index - field index
     */
    GroupUi.prototype.hideField = function (field, index) {
        if (this.isFieldVisible(field, index) === false) {
            // nothing to do?
            return;
        }
        this._setFieldVisible(field, index, false);
        // can be overridden by subtypes
        this.doHideField(field, index);
    };
    GroupUi.prototype.doHideField = function (field, index) {
        this.getDomPerfFlag() === true
            ? this.context.hide(field, index)
            : this.rcontext.getFieldByName(field, index).applyStyle(this._na_styler);
    };
    /**
     * Returns a boolean depending on if there are visible fields
     * based off of the visCount
     *
     * @param index
     */
    GroupUi.prototype.hasVisibleField = function (index) {
        return this._visCount[index] > 0 ? true : false;
    };
    /**
     * Shows the field based on field name and index
     *
     * @param field
     * @param index
     */
    GroupUi.prototype.showField = function (field, index) {
        if (this.isFieldVisible(field, index) === true) {
            // nothing to do
            return;
        }
        this._setFieldVisible(field, index, true);
        // can be overridden by subtypes
        this.doShowField(field, index);
    };
    GroupUi.prototype.doShowField = function (field, index) {
        this.getDomPerfFlag() === true
            ? this.context.show(field, index, this.fieldContentParent[index])
            : this.rcontext.getFieldByName(field, index).revokeStyle(this._na_styler);
    };
    GroupUi.prototype.isFieldVisible = function (id, index) {
        if (index > this.getCurrentIndex()) {
            return false;
        }
        this._visCache[id] = this._visCache[id] || [];
        // if no index was provided, then determine if *any* of the indexes are
        // available
        if (index === undefined) {
            var result = false, i = this.getCurrentIndexCount();
            while (i--) {
                result = result || this.isFieldVisible(id, i);
            }
            return result;
        }
        // may be undefined
        return this._visCache[id][index];
    };
    GroupUi.prototype._setFieldVisible = function (id, index, visible) {
        var old = this._visCache[id][index];
        // should only ever be called after isFieldVisible(); if this is false,
        // initialize
        this._visCache[id][index] = !!visible;
        // we assume every field to be visible by default count-wise; as such,
        // if the original cache value is undefined (meaning we aren't sure if
        // it is visible or not), we do not want to increase the visibility
        // count
        this._incVis(index, visible ? (old === undefined ? 0 : 1) : -1);
        this._checkVisCount();
    };
    GroupUi.prototype._incVis = function (index, by) {
        if (this._visCount[index] === undefined) {
            this._visCount[index] = 0;
        }
        this._visCount[index] += by;
        this._visCountTotal += by;
    };
    GroupUi.prototype._recalcFieldCount = function (change, index) {
        var raw = this._rawFieldCount;
        var count = 0;
        if (change === -1) {
            count = this._visCount[index];
        }
        else {
            count = raw;
        }
        this._incVis(index, change * count);
        this._checkVisCount();
    };
    GroupUi.prototype._checkVisCount = function () {
        // if we have no fields, then ignore visibility checks
        if (this._rawFieldCount === 0) {
            return;
        }
        // XXX: ideally, < should never occur, but until this implementation is
        // finalized and all the bugs are worked out, it can :x
        if (this._visCountTotal <= 0 && this._visible) {
            this.onAllFieldsHidden();
        }
        else if (!this._visible && this._visCountTotal > 0) {
            this.onFieldsVisible();
        }
    };
    GroupUi.prototype.onAllFieldsHidden = function () {
        if (this._use_vis_class) {
            return;
        }
        // default action is to hide self
        this.hide();
    };
    GroupUi.prototype.onFieldsVisible = function () {
        if (this._use_vis_class) {
            return;
        }
        // default action is to show self
        this.show();
    };
    GroupUi.prototype.invalidate = function (hook) {
        if (hook instanceof Function) {
            this.invalidateHooks.push(hook);
            return this;
        }
        // call the hooks
        for (var i = 0, len = this.invalidateHooks.length; i < len; i++) {
            this.invalidateHooks[i]();
        }
        return this;
    };
    /**
     * Returns group object being styled
     */
    GroupUi.prototype.getGroup = function () {
        return this.group;
    };
    GroupUi.prototype.preRender = function () {
        if (this._emptyOnVisit === null) {
            return this;
        }
        // invoke the continuation
        this._emptyOnVisit();
        this._emptyOnVisit = null;
        return this;
    };
    GroupUi.prototype.visit = function () {
        return this;
    };
    /**
     * Returns whether the given name is a field
     *
     * If not a field, it could be another non-input element, such as a static
     * element.
     *
     * @param name - inquiry
     *
     * @return true if field, otherwise false
     */
    GroupUi.prototype.isAField = function (name) {
        return this.styler.isAField(name);
    };
    GroupUi.prototype.getContentByIndex = function (_name, _index) {
        return this.$content;
    };
    /**
     * Sets element value given a name and index
     *
     * This has the performance benefit of searching *only* within the group
     * rather than scanning the entire DOM (or a much larger subset)
     *
     * @param name         - element name
     * @param index        - index to set
     * @param value        - value to set
     * @param change_event - whether to trigger change event
     */
    GroupUi.prototype.setValueByName = function (name, index, value, change_event) {
        if (this.getDomPerfFlag() === true) {
            this.context.setValueByName(name, index, value);
        }
        else {
            this.styler.setValueByName(name, index, value, change_event, this.getContentByIndex(name, index));
        }
        return this;
    };
    GroupUi.prototype.setActive = function (active) {
        active = active === undefined ? true : !!active;
        this._active = active;
        return this;
    };
    GroupUi.prototype.disableField = function (name, index, disable) {
        disable = disable === undefined ? true : !!disable;
        this.styler.disableField(name, index, disable, this.getContentByIndex(name, index));
        return this;
    };
    GroupUi.prototype.setOptions = function (name, index, options, val) {
        if (this.getDomPerfFlag() === false) {
            this.styler.setOptions(name, index, options, val, this.getContentByIndex(name, index));
        }
        else {
            this.context.setOptions(name, index, options, val);
        }
        return this;
    };
    GroupUi.prototype.clearOptions = function (name, index) {
        this.setOptions(name, index, []);
        return this;
    };
    return GroupUi;
}(EventEmitter));
exports.GroupUi = GroupUi;
//# sourceMappingURL=data:application/json;base64, 