<commit_before>define(function(require) {
    'use strict';

    var HighlightTextView;
    var $ = require('jquery');
    var _ = require('underscore');
    var mediator = require('oroui/js/mediator');
    var BaseView = require('oroui/js/app/views/base/view');
    var FuzzySearch = require('oroui/js/fuzzy-search');
    var persistentStorage = require('oroui/js/persistent-storage');
    var highlightSwitcherTemplate = require('tpl!oroui/templates/highlight-switcher.html');

    HighlightTextView = BaseView.extend({
        /**
         * @inheritDoc
         */
        optionNames: BaseView.prototype.optionNames.concat([
            'text', 'toggleSelectors', 'viewGroup', 'notFoundClass',
            'elementHighlightClass', 'foundClass', 'fuzzySearch',
            'highlightClass', 'highlightSelectors', 'highlightStateStorageKey',
            'highlightSwitcherContainer', 'highlightSwitcherElement',
            'highlightSwitcherTemplate', 'showNotFoundItems'
        ]),

        events: {
            'click [data-role="highlight-switcher"]': 'changeHighlightSwitcherState'
        },

        /**
         * @property {Function}
         */
        highlightSwitcherTemplate: highlightSwitcherTemplate,

        /**
         * @property {String}
         */
        highlightSwitcherElement: '[data-role="highlight-switcher"]',

        /**
         * @property {String}
         */
        highlightSwitcherContainer: null,

        /**
         * @property {String}
         */
        highlightStateStorageKey: null,

        /**
         * @property {String}
         */
        text: '',

        /**
         * @property {RegExp|null}
         */
        findText: null,

        /**
         * @property {Boolean}
         */
        fuzzySearch: false,

        /**
         * @property {Boolean}
         */
        showNotFoundItems: false,

        /**
         * @property {String}
         */
        highlightClass: 'highlight-text',

        /**
         * @property {String}
         */
        elementHighlightClass: 'highlight-element',

        /**
         * @property {String}
         */
        notFoundClass: 'highlight-not-found',

        /**
         * @property {String}
         */
        foundClass: 'highlight-found',

        /**
         * @property {String}
         */
        replaceBy: '',

        /**
         * @property {Array}
         */
        highlightSelectors: [],

        /**
         * @property {Array}
         */
        toggleSelectors: {},

        /**
         * @property {String}
         */
        viewGroup: '',

        /**
         * @inheritDoc
         */
        constructor: function HighlightTextView() {
            HighlightTextView.__super__.constructor.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            this.findHighlightClass = '.' + this.highlightClass;
            this.findElementHighlightClass = '.' + this.elementHighlightClass;
            this.findNotFoundClass = '.' + this.notFoundClass;
            this.findFoundClass = '.' + this.foundClass;
            this.replaceBy = '<span class="' + this.highlightClass + '">$&</span>';

            HighlightTextView.__super__.initialize.apply(this, arguments);

            this.renderHighlightSwitcher();
            this.update(this.text);

            mediator.on(this.viewGroup + ':highlight-text:update', this.update, this);
        },

        /**
         * @inheritDoc
         */
        render: function() {
            this.clear();
            this.highlightElements();
            this.toggleElements();
        },

        /**
         * Refresh highlight using new text
         *
         * @param {String} text
         * @param {Boolean|null} fuzzySearch
         */
        update: function(text, fuzzySearch) {
            if (fuzzySearch !== undefined) {
                this.fuzzySearch = fuzzySearch;
            }
            this.text = text;
            var regexp = this.text;

            if (this.fuzzySearch) {
                regexp = this.text.toLowerCase().replace(/\s/g, '').split('');
                regexp = '[' + this._escape(_.uniq(regexp).join('')) + ']';
            } else {
                regexp = this._escape(regexp);
            }
            this.findText = this.text.length ? new RegExp(regexp, 'gi') : null;

            this.render();
            this.toggleHighlightSwitcher();
        },

        /**
         * Highlight text in all found elements
         */
        highlightElements: function() {
            _.each(this.findElements(this.highlightSelectors), this.highlightElement, this);
        },

        /**
         * Toggle found/not-found class for all elements based on found highlighted elements
         */
        toggleElements: function() {
            _.each(this.findElements(_.keys(this.toggleSelectors)), this.toggleElement, this);
            if (this.isElementHighlighted(this.$el)) {
                _.each(this.findElements(_.keys(this.toggleSelectors)), this.toggleElement, this);
            }
        },

        /**
         * Return found elements with matched selector
         *
         * @param {Array} selectors
         * @return {Array}
         */
        findElements: function(selectors) {
            var elements = [];
            _.each(selectors, function(selector) {
                this.$(selector).each(function() {
                    elements.push({
                        selector: selector,
                        $el: $(this)
                    });
                });
            }, this);

            return elements;
        },

        /**<commit_msg>BAP-17525: Admin configuration search ignores mandatory fields (#19839)<commit_after>define(function(require) {
    'use strict';

    var HighlightTextView;
    var $ = require('jquery');
    var _ = require('underscore');
    var mediator = require('oroui/js/mediator');
    var BaseView = require('oroui/js/app/views/base/view');
    var FuzzySearch = require('oroui/js/fuzzy-search');
    var persistentStorage = require('oroui/js/persistent-storage');
    var highlightSwitcherTemplate = require('tpl!oroui/templates/highlight-switcher.html');

    HighlightTextView = BaseView.extend({
        /**
         * @inheritDoc
         */
        optionNames: BaseView.prototype.optionNames.concat([
            'text', 'toggleSelectors', 'viewGroup', 'notFoundClass',
            'elementHighlightClass', 'foundClass', 'fuzzySearch',
            'highlightClass', 'highlightSelectors', 'highlightStateStorageKey',
            'highlightSwitcherContainer', 'highlightSwitcherElement',
            'highlightSwitcherTemplate', 'showNotFoundItems'
        ]),

        events: {
            'click [data-role="highlight-switcher"]': 'changeHighlightSwitcherState'
        },

        /**
         * @property {Function}
         */
        highlightSwitcherTemplate: highlightSwitcherTemplate,

        /**
         * @property {String}
         */
        highlightSwitcherElement: '[data-role="highlight-switcher"]',

        /**
         * @property {String}
         */
        highlightSwitcherContainer: null,

        /**
         * @property {String}
         */
        highlightStateStorageKey: null,

        /**
         * @property {String}
         */
        text: '',

        /**
         * @property {RegExp|null}
         */
        findText: null,

        /**
         * @property {Boolean}
         */
        fuzzySearch: false,

        /**
         * @property {Boolean}
         */
        showNotFoundItems: false,

        /**
         * @property {String}
         */
        highlightClass: 'highlight-text',

        /**
         * @property {String}
         */
        elementHighlightClass: 'highlight-element',

        /**
         * @property {String}
         */
        notFoundClass: 'highlight-not-found',

        /**
         * @property {String}
         */
        foundClass: 'highlight-found',

        /**
         * @property {String}
         */
        groupedElementSelector: 'div[data-name="field__value"]',

        /**
         * @property {String}
         */
        replaceBy: '',

        /**
         * @property {Array}
         */
        highlightSelectors: [],

        /**
         * @property {Array}
         */
        toggleSelectors: {},

        /**
         * @property {String}
         */
        viewGroup: '',

        /**
         * @inheritDoc
         */
        constructor: function HighlightTextView() {
            HighlightTextView.__super__.constructor.apply(this, arguments);
        },

        /**
         * @inheritDoc
         */
        initialize: function(options) {
            this.findHighlightClass = '.' + this.highlightClass;
            this.findElementHighlightClass = '.' + this.elementHighlightClass;
            this.findNotFoundClass = '.' + this.notFoundClass;
            this.findFoundClass = '.' + this.foundClass;
            this.replaceBy = '<span class="' + this.highlightClass + '">$&</span>';

            HighlightTextView.__super__.initialize.apply(this, arguments);

            this.renderHighlightSwitcher();
            this.update(this.text);

            mediator.on(this.viewGroup + ':highlight-text:update', this.update, this);
        },

        /**
         * @inheritDoc
         */
        render: function() {
            this.clear();
            this.highlightElements();
            this.toggleElements();
        },

        /**
         * Refresh highlight using new text
         *
         * @param {String} text
         * @param {Boolean|null} fuzzySearch
         */
        update: function(text, fuzzySearch) {
            if (fuzzySearch !== undefined) {
                this.fuzzySearch = fuzzySearch;
            }
            this.text = text;
            var regexp = this.text;

            if (this.fuzzySearch) {
                regexp = this.text.toLowerCase().replace(/\s/g, '').split('');
                regexp = '[' + this._escape(_.uniq(regexp).join('')) + ']';
            } else {
                regexp = this._escape(regexp);
            }
            this.findText = this.text.length ? new RegExp(regexp, 'gi') : null;

            this.render();
            this.toggleHighlightSwitcher();
        },

        /**
         * Highlight text in all found elements
         */
        highlightElements: function() {
            _.each(this.findElements(this.highlightSelectors), this.highlightElement, this);
        },

        /**
         * Toggle found/not-found class for all elements based on found highlighted elements
         */
        toggleElements: function() {
            _.each(this.findElements(_.keys(this.toggleSelectors)), this.toggleElement, this);
            if (this.isElementHighlighted(this.$el)) {
                _.each(this.findElements(_.keys(this.toggleSelectors)), this.toggleElement, this);
            }

            _.each(this.$(this.groupedElementSelector), this.showGroupContainingHighlighted, this);
        },

        /**
         * Show whole subform if it contains at least one highlighted element.
         *
         * @param {Element} groupEl
         */
        showGroupContainingHighlighted: function(groupEl) {
            var $groupEl = $(groupEl);
            if (this.isElementHighlighted($groupEl)) {
                $groupEl.find(this.findNotFoundClass).removeClass(this.notFoundClass);
            }
        },

        /**
         * Return found elements with matched selector
         *
         * @param {Array} selectors
         * @return {Array}
         */
        findElements: function(selectors) {
            var elements = [];
            _.each(selectors, function(selector) {
                this.$(selector).each(function() {
                    elements.push({
                        selector: selector,
                        $el: $(this)
                    });
                });
            }, this);

            return elements;
        },

        /**
{'fraction_non_alphanumeric': 0.1301687065828647, 'fraction_numerical': 0.0008269930532583526, 'mean_word_length': 1.5856318152661963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6442633', 'n_tokens_mistral': 3224, 'n_tokens_neox': 3056, 'n_words': 520}