/* =============================================================================================================
Filters
=============================================================================================================
485409
function _applyFilters(rawdata, filterOptions) {
			var dataToWorkOn = (JSON.parse(JSON.stringify(rawdata)));
			var containerWidth = document.querySelector('#sapUiSupportPerfHeaderTimeline').offsetWidth - document.querySelector('#sapUiSupportPerfHeaderTimelineBarInfoWrapper').offsetWidth;
			var scrollWidth = 20;
			var filteredTime = 1;

			dataToWorkOn = _filterByTime(filterOptions.filterByTime, dataToWorkOn);
			dataToWorkOn = _sortBy(filterOptions.orderByValue, dataToWorkOn);
			dataToWorkOn = _filterMinValue(filterOptions.minValue, dataToWorkOn);

			if (dataToWorkOn.length) {
				filteredTime = filterOptions.filterByTime.end - filterOptions.filterByTime.start;
			}

			_widthSingleUnit = ((containerWidth - scrollWidth) / filteredTime); //ms in px

			return dataToWorkOn;
		}
338967
function (filters, tpl) {
      for (var i = 0; i < filters.length; ++i) {
        tpl = filters[i](tpl)
      }
      return tpl
    }
1045760
function filtered(js) {
  return js.substr(1).split('|').reduce(function(js, filter){
    var parts = filter.split(':')
      , name = parts.shift()
      , args = parts.shift() || '';
    if (args) args = ', ' + args;
    return 'filters.' + name + '(' + js + args + ')';
  });
}
861077
function setDefaults($defaultValues = null, $filter = null)
    {
        if (is_array($defaultValues)) {
            if (isset($filter)) {
                if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
                    foreach ($filter as $val) {
                        if (!is_callable($val)) {
                            return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
                        } else {
                            $defaultValues = $this->_recursiveFilter($val, $defaultValues);
                        }
                    }
                } elseif (!is_callable($filter)) {
                    return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
                } else {
                    $defaultValues = $this->_recursiveFilter($filter, $defaultValues);
                }
            }
            $this->_defaultValues = HTML_QuickForm::arrayMerge($this->_defaultValues, $defaultValues);
            foreach (array_keys($this->_elements) as $key) {
                $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
            }
        }
    }
999607
function(filter){
      filter = filter || this.filter;

      var cursor = this.cursor_ || this.root_;

      do
      {
        var node = cursor[this.a]; // next child
        while (!node)
        {
          if (cursor === this.root_)
            return this.cursor_ = null;

          node = cursor[this.b]; // next sibling

          if (!node)
            cursor = cursor[PARENT_NODE];
        }
      }
      while (!filter(cursor = node));

      return this.cursor_ = cursor;
    }
1321659
function _fnFeatureHtmlFilter ( settings )
	{
		var classes = settings.oClasses;
		var tableId = settings.sTableId;
		var previousSearch = settings.oPreviousSearch;
		var features = settings.aanFeatures;
		var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
	
		var str = settings.oLanguage.sSearch;
		str = str.match(/_INPUT_/) ?
			str.replace('_INPUT_', input) :
			str+input;
	
		var filter = $('<div/>', {
				'id': ! features.f ? tableId+'_filter' : null,
				'class': classes.sFilter
			} )
			.append( $('<label/>' ).append( str ) );
	
		var jqFilter = $('input[type="search"]', filter)
			.val( previousSearch.sSearch.replace('"','&quot;') )
			.bind( 'keyup.DT search.DT input.DT paste.DT cut.DT', function(e) {
				/* Update all other filter input elements for the new display */
				var n = features.f;
				var val = !this.value ? "" : this.value; // mental IE8 fix :-(
	
				/* Now do the filter */
				if ( val != previousSearch.sSearch ) {
					_fnFilterComplete( settings, {
						"sSearch": val,
						"bRegex": previousSearch.bRegex,
						"bSmart": previousSearch.bSmart ,
						"bCaseInsensitive": previousSearch.bCaseInsensitive
					} );
	
					// Need to redraw, without resorting
					settings._iDisplayStart = 0;
					_fnDraw( settings );
				}
			} )
			.bind( 'keypress.DT', function(e) {
				/* Prevent form submission */
				if ( e.keyCode == 13 ) {
					return false;
				}
			} )
			.attr('aria-controls', tableId);
	
		// Update the input elements whenever the table is filtered
		$(settings.nTable).on( 'filter.DT', function () {
			// IE9 throws an 'unknown error' if document.activeElement is used
			// inside an iframe or frame...
			try {
				if ( jqFilter[0] !== document.activeElement ) {
					jqFilter.val( previousSearch.sSearch );
				}
			}
			catch ( e ) {}
		} );
	
		return filter[0];
	}
380858
function filterOptions(options, filter, substitutions) {
    // If the filter is blank, return the full list of Options.
    if (!filter) {
        return options;
    }

    var cleanFilter = cleanUpText(filter, substitutions);
    return options
    // Filter out undefined or null Options.
    .filter(function (_ref) {
        var label = _ref.label,
            value = _ref.value;
        return label != null && value != null;
    })
    // Create a {score, Option} pair for each Option based on its label's
    // similarity to the filter text.
    .map(function (option) {
        return {
            option: option,
            score: typeaheadSimilarity(cleanUpText(option.label, substitutions), cleanFilter)
        };
    })
    // Only include matches of the entire substring, with a slight
    // affordance for transposition or extra characters.
    .filter(function (pair) {
        return pair.score >= cleanFilter.length - 2;
    })
    // Sort 'em by order of their score.
    .sort(function (a, b) {
        return b.score - a.score;
    })
    // …and grab the original Options back from their pairs.
    .map(function (pair) {
        return pair.option;
    });
}
1337359
function filter(rows = [], filters = [], filterText, columns) {
  let filteredRows = rows.slice(0);
  if (filters.length === 0 && !filterText) {
    return filteredRows;
  }

  const textFilters = [
    ...(filterText ? [filterText.toLowerCase()] : []),
    ...filters.filter(f => f.textFilter).map(f => f.value),
  ];

  const valueFilters = filters.filter(f => f.valueFilter);

  // apply text filters across all columns
  if (textFilters.length > 0) {
    filteredRows = _.filter(rows, row => _.some(columns, (column) => {
      if (!column.searchable) {
        return false;
      }
      const normalized = String(_.get(row, column.key)).toLowerCase();
      return _.every(textFilters, f => normalized.indexOf(f) > -1);
    }));
  }

  // apply value filters on filterable columns
  if (valueFilters.length > 0) {
    const groups = _.groupBy(valueFilters, 'key');
    filteredRows = _.filter(filteredRows, row => _.every(
      groups,
      (groupFilters, groupKey) => {
        const value = _.get(row, groupKey);
        return _.some(groupFilters, f => f.value === value);
      }
    ));
  }

  return filteredRows;
}
1099757
function updateFilter() {
            if (angular.isFunction(lxSelect.resetDropdownSize)) {
                lxSelect.resetDropdownSize();
            }

            if (angular.isDefined(lxSelect.filter)) {
                lxSelect.matchingPaths = lxSelect.filter({
                    newValue: lxSelect.filterModel
                });
            } else if (lxSelect.choicesViewMode === 'panes') {
                lxSelect.matchingPaths = lxSelect.searchPath(lxSelect.filterModel);
                _closePanes();
            }

            if (lxSelect.autocomplete) {
                lxSelect.activeChoiceIndex = -1;

                if (lxSelect.filterModel) {
                    LxDropdownService.open('dropdown-' + lxSelect.uuid, '#lx-select-selected-wrapper-' + lxSelect.uuid);
                } else {
                    LxDropdownService.close('dropdown-' + lxSelect.uuid);
                }
            }

            if (lxSelect.choicesViewMode === 'panes' && angular.isDefined(lxSelect.matchingPaths) && lxSelect.matchingPaths.length > 0) {
                var longest = _getLongestMatchingPath();
                if (!longest) {
                    return;
                }

                var longestPath = longest.split('.');
                if (longestPath.length === 0) {
                    return;
                }

                angular.forEach(longestPath, function forEachPartOfTheLongestPath(part, index) {
                    _openPane(index, part, index === (longestPath.length - 1));
                });
            }
        }
361237
function(uf, filters) {
			var i;

			if(modules.utils.isArray(filters) && filters.length > 0) {
				i = filters.length;
				while(i--) {
					if(uf.type[0] === filters[i]) {
						return true;
					}
				}
				return false;
			} else {
				return true;
			}
		}
1037493
function _fnFeatureHtmlFilter ( oSettings )
		{
			var oPreviousSearch = oSettings.oPreviousSearch;
			
			var sSearchStr = oSettings.oLanguage.sSearch;
			sSearchStr = (sSearchStr.indexOf('_INPUT_') !== -1) ?
			  sSearchStr.replace('_INPUT_', '<input type="text" />') :
			  sSearchStr==="" ? '<input type="text" />' : sSearchStr+' <input type="text" />';
			
			var nFilter = document.createElement( 'div' );
			nFilter.className = oSettings.oClasses.sFilter;
			nFilter.innerHTML = '<label>'+sSearchStr+'</label>';
			if ( !oSettings.aanFeatures.f )
			{
				nFilter.id = oSettings.sTableId+'_filter';
			}
			
			var jqFilter = $('input[type="text"]', nFilter);
		
			// Store a reference to the input element, so other input elements could be
			// added to the filter wrapper if needed (submit button for example)
			nFilter._DT_Input = jqFilter[0];
		
			jqFilter.val( oPreviousSearch.sSearch.replace('"','&quot;') );
			jqFilter.bind( 'keyup.DT', function(e) {
				/* Update all other filter input elements for the new display */
				var n = oSettings.aanFeatures.f;
				var val = this.value==="" ? "" : this.value; // mental IE8 fix :-(
		
				for ( var i=0, iLen=n.length ; i<iLen ; i++ )
				{
					if ( n[i] != $(this).parents('div.dataTables_filter')[0] )
					{
						$(n[i]._DT_Input).val( val );
					}
				}
				
				/* Now do the filter */
				if ( val != oPreviousSearch.sSearch )
				{
					_fnFilterComplete( oSettings, { 
						"sSearch": val, 
						"bRegex": oPreviousSearch.bRegex,
						"bSmart": oPreviousSearch.bSmart ,
						"bCaseInsensitive": oPreviousSearch.bCaseInsensitive 
					} );
				}
			} );
		
			jqFilter
				.attr('aria-controls', oSettings.sTableId)
				.bind( 'keypress.DT', function(e) {
					/* Prevent form submission */
					if ( e.keyCode == 13 )
					{
						return false;
					}
				}
			);
			
			return nFilter;
		}
461661
function buildFilters(filters) {
    var builtFilters = [];
    filters.forEach(function(filter) {
      builtFilters.push(MongoDatabase.buildFilter(filter));
    });
    return builtFilters;
  }
1298360
function (cb) {
                var filters = this._filters;
                var curFilter;
                var classpathsToLoad = [];
                for (var i = 0, l = filters.length; i < l; i++) {
                    curFilter = filters[i];
                    if (curFilter.obj == null) {
                        classpathsToLoad.push(curFilter.filterClasspath);
                    }
                }
                Aria.load({
                    classes : classpathsToLoad,
                    oncomplete : {
                        fn : this._continueLoadingMissingFilters,
                        scope : this,
                        args : {
                            cb : cb,
                            filters : filters,
                            nbFilters : filters.length
                        }
                    }
                });
            }
52796
function  buildSqlFilter(filter, columns)  {
	if (filter.op === 'and')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});
		
		var  len = clones.length;
		if (len < 1)
			return null;
		else
			return  len > 1  ?  {op: 'and', filters: clones} : clones[0];
	}
	else  if (filter.op === 'or')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});

		return  clones.length === filter.filters.length  ?  {op: 'or', filters: clones} : null;
	}

	var  cf = null,
		 colName = filter.name;
	if (columns.indexOf(colName) >= 0)
		cf = filter; //cloneObj( filter );


	return  cf;
}
137978
function createFilterFor(query) {
      var lowercaseQuery = query.toLowerCase();

      return function filterFn(vegetable) {
        return (vegetable._lowername.indexOf(lowercaseQuery) === 0) ||
            (vegetable._lowertype.indexOf(lowercaseQuery) === 0);
      };

    }
770339
function (orderBy) {

/*Line 195 - 'atom-filter.js' */            if (!AtomFilter.isString(orderBy)) {
/*Line 196 - 'atom-filter.js' */                return orderBy;
/*Line 197 - 'atom-filter.js' */            }

/*Line 199 - 'atom-filter.js' */            var fields = orderBy.split(',');
/*Line 200 - 'atom-filter.js' */            fields = fields.map(function (item) {
/*Line 201 - 'atom-filter.js' */                var tokens = item.split(' ');
/*Line 202 - 'atom-filter.js' */                var desc = tokens[1] || 'asc';
/*Line 203 - 'atom-filter.js' */                return {
/*Line 204 - 'atom-filter.js' */                    field: tokens[0],
/*Line 205 - 'atom-filter.js' */                    desc: /desc/i.test(desc),
/*Line 206 - 'atom-filter.js' */                    cs: /^cs/i.test(desc)
/*Line 207 - 'atom-filter.js' */                }
/*Line 208 - 'atom-filter.js' */            });

/*Line 210 - 'atom-filter.js' */            return function (a, b) {

/*Line 212 - 'atom-filter.js' */                if (a == null || a == undefined) {
/*Line 213 - 'atom-filter.js' */                    return b == null || b == undefined ? 0 : 1;
/*Line 214 - 'atom-filter.js' */                }
/*Line 215 - 'atom-filter.js' */                if (b == null || b == undefined) {
/*Line 216 - 'atom-filter.js' */                    return 1;
/*Line 217 - 'atom-filter.js' */                }

/*Line 219 - 'atom-filter.js' */                for (var i = 0; i < fields.length; i++) {
/*Line 220 - 'atom-filter.js' */                    var f = fields[i];
/*Line 221 - 'atom-filter.js' */                    var field = f.field;
/*Line 222 - 'atom-filter.js' */                    var af = a[field];
/*Line 223 - 'atom-filter.js' */                    var bf = b[field];
/*Line 224 - 'atom-filter.js' */                    if (f.desc) {
/*Line 225 - 'atom-filter.js' */                        var t = af;
/*Line 226 - 'atom-filter.js' */                        af = bf;
/*Line 227 - 'atom-filter.js' */                        bf = t;
/*Line 228 - 'atom-filter.js' */                    }
/*Line 229 - 'atom-filter.js' */                    if (af == bf)
/*Line 230 - 'atom-filter.js' */                        continue;
/*Line 231 - 'atom-filter.js' */                    if (!af) {
/*Line 232 - 'atom-filter.js' */                        return !bf ? 0 : -1;
/*Line 233 - 'atom-filter.js' */                    }
/*Line 234 - 'atom-filter.js' */                    if (!bf) {
/*Line 235 - 'atom-filter.js' */                        return !af ? 0 : 1;
/*Line 236 - 'atom-filter.js' */                    }
/*Line 237 - 'atom-filter.js' */                    if (AtomFilter.isString(af)) {
/*Line 238 - 'atom-filter.js' */                        if (f.cs) {
/*Line 239 - 'atom-filter.js' */                            return af.localeCompare(bf);
/*Line 240 - 'atom-filter.js' */                        } else {
/*Line 241 - 'atom-filter.js' */                            af = af.toLowerCase();
/*Line 242 - 'atom-filter.js' */                            bf = bf.toLowerCase();
/*Line 243 - 'atom-filter.js' */                            if (af == bf)
/*Line 244 - 'atom-filter.js' */                                continue;
/*Line 245 - 'atom-filter.js' */                            return af.localeCompare(bf);
/*Line 246 - 'atom-filter.js' */                        }
/*Line 247 - 'atom-filter.js' */                    }

/*Line 249 - 'atom-filter.js' */                }
/*Line 250 - 'atom-filter.js' */                return 0;
/*Line 251 - 'atom-filter.js' */            }
/*Line 252 - 'atom-filter.js' */        }
283882
public function onFilterGetOptions()
    {
        $this->defineFilterScopes();

        $searchQuery = post('search');
        if (!$scopeName = post('scopeName')) {
            return;
        }

        $scope = $this->getScope($scopeName);
        $activeKeys = $scope->value ? array_keys($scope->value) : [];
        $available = $this->getAvailableOptions($scope, $searchQuery);
        $active = $searchQuery ? [] : $this->filterActiveOptions($activeKeys, $available);

        return [
            'scopeName' => $scopeName,
            'options' => [
                'available' => $this->optionsToAjax($available),
                'active'    => $this->optionsToAjax($active),
            ]
        ];
    }