<commit_before>import React from "react";
import Translate from "react-translate-component";
import cnames from "classnames";
import {isFunction, isString} from "lodash-es";
import Icon from "../Icon/Icon";
import MenuItemType from "./MenuItemType";

class HeaderMenuItem extends React.Component {
    render() {
        const {
            target,
            currentPath,
            includePattern,
            excludePattern,
            hideClassName,
            icon,
            text,
            behavior,
            hidden
        } = this.props;

        // Either click handler or navigation path
        let clickHandler = undefined;
        if (isFunction(target)) {
            clickHandler = target;
        }

        let href = undefined;
        if (isString(target)) {
            href = target;
        }

        // Defalut icon title if not set
        if (!icon.title) {
            icon.title = "icons." + icon.name;
        }

        // Default icon size if not set
        if (!icon.size) {
            icon.size = "1_5x";
        }

        // Convert sigle strings to array
        let includePatternArray = includePattern;
        if (isString(includePattern)) {
            includePatternArray = [includePattern];
        }

        let excludePatternArray = excludePattern;
        if (isString(excludePattern)) {
            excludePatternArray = [excludePattern];
        }

        // Check patterns which decides should the class names be assigned or not
        let patternMatched = false;
        if (includePattern || excludePattern) {
            patternMatched = true;

            if (includePatternArray) {
                for (let i = 0; i < includePatternArray.length; i++) {
                    if (currentPath.indexOf(includePatternArray[i]) === -1) {
                        patternMatched = false;
                        break;
                    }
                }
            }

            if (excludePatternArray) {
                for (let i = 0; i < excludePatternArray.length; i++) {
                    if (currentPath.indexOf(excludePatternArray[i]) !== -1) {
                        patternMatched = false;
                        break;
                    }
                }
            }

            if (patternMatched) {
                actualHideClass = hideClassName;
            }
        }

        let actualHideClass = undefined;
        if (hideClassName && patternMatched) {
            actualHideClass = hideClassName;
        }

        // Choose a behavior, defaults to Always
        let actualBehavior = MenuItemType.Always;
        if (behavior) {
            actualBehavior = behavior;
        }

        // Show or hide element by it's behavior
        let actuallyHidden = true;
        if (<commit_msg>Fixed small bug with variable initialization.<commit_after>import React from "react";
import Translate from "react-translate-component";
import cnames from "classnames";
import {isFunction, isString} from "lodash-es";
import Icon from "../Icon/Icon";
import MenuItemType from "./MenuItemType";

class HeaderMenuItem extends React.Component {
    render() {
        const {
            target,
            currentPath,
            includePattern,
            excludePattern,
            hideClassName,
            icon,
            text,
            behavior,
            hidden
        } = this.props;

        // Either click handler or navigation path
        let clickHandler = undefined;
        if (isFunction(target)) {
            clickHandler = target;
        }

        let href = undefined;
        if (isString(target)) {
            href = target;
        }

        // Defalut icon title if not set
        if (!icon.title) {
            icon.title = "icons." + icon.name;
        }

        // Default icon size if not set
        if (!icon.size) {
            icon.size = "1_5x";
        }

        // Convert sigle strings to array
        let includePatternArray = includePattern;
        if (isString(includePattern)) {
            includePatternArray = [includePattern];
        }

        let excludePatternArray = excludePattern;
        if (isString(excludePattern)) {
            excludePatternArray = [excludePattern];
        }

        // Check patterns which decides should the class names be assigned or not
        let actualHideClass = undefined;
        let patternMatched = false;
        if (includePattern || excludePattern) {
            patternMatched = true;

            if (includePatternArray) {
                for (let i = 0; i < includePatternArray.length; i++) {
                    if (currentPath.indexOf(includePatternArray[i]) === -1) {
                        patternMatched = false;
                        break;
                    }
                }
            }

            if (excludePatternArray) {
                for (let i = 0; i < excludePatternArray.length; i++) {
                    if (currentPath.indexOf(excludePatternArray[i]) !== -1) {
                        patternMatched = false;
                        break;
                    }
                }
            }

            if (patternMatched) {
                actualHideClass = hideClassName;
            }
        }

        if (hideClassName && patternMatched) {
            actualHideClass = hideClassName;
        }

        // Choose a behavior, defaults to Always
        let actualBehavior = MenuItemType.Always;
        if (behavior) {
            actualBehavior = behavior;
        }

        // Show or hide element by it's behavior
        let actuallyHidden = true;
        if (
{'fraction_non_alphanumeric': 0.08428367783321454, 'fraction_numerical': 0.0021382751247327157, 'mean_word_length': 1.4372557533651757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '809748', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1300, 'n_words': 379}