<commit_before>{% form_theme form with 'OroFormBundle:Form:fields.html.twig' %}
<div class="widget-content">
    {% if saved %}
        <script type="text/javascript">
        require([
            'orotranslation/js/translator',
            'oroui/js/widget-manager',
            'oroui/js/messenger',
            'oroui/js/mediator'
        ],
        function(__, widgetManager, messenger, mediator) {
            widgetManager.getWidgetInstance({{ app.request.get('_wid')|json_encode|raw }}, function(widget) {
                messenger.notificationFlashMessage('success', __('oro.user.change_password.flash.success'));
                mediator.trigger('widget_success:' + widget.getAlias());
                mediator.trigger('widget_success:' + widget.getWid());
                widget.remove();
            });
        });
        </script>
    {% else %}
        <script type="text/javascript">
        require([
            'jquery',
            'orotranslation/js/translator'
        ],
        function($, __) {
            var $passwordInput= $('[data-ftid=oro_set_password_form_password]');
            $passwordInput.after(
                    '<span class="icon-eye-close" id="show-hide-pass" style="cursor: pointer; font-size: 16px;" ' +
                    ' title="' + __("oro.user.show_hide_password.label") + '"/>'
            );
            $passwordInput.parent().after(
                '<div class="controls" style="margin-top: 5px;">' +
                    '<a href="#" id="generate-pass">' + __("oro.user.suggest_password.label") + '</a>' +
                '</div>'
            );

            $('#generate-pass').on('click', function(e){
                e.preventDefault();
                var getRnd = function(n) {
                    return Math.floor(Math.random() * (n + 1));
                };
                var requireLength = $passwordInput.data('suggest-length') || 1;
                var requirements = $passwordInput.data('suggest-rules') || '';
                var length = Math.max(requireLength, 8);
                var charsets = {
                    'lower_case': 'abcdefghijklnopqrstuvwxyz',
                    'upper_case':'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                    'numbers':'0123456789',
                    'special_chars':' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
                };
                var rules = requirements.split(',');
                var pass = '';

                // make sure we have at least one symbol for each rule
                rules.forEach(function(rule) {
                    if (charsets.hasOwnProperty(rule)) {
                        pass += charsets[rule].charAt(getRnd(charsets[rule].length));
                    }
                });

                // create a pool for picking random chars that is reasonably strong
                var charset = charsets['lower_case'] + charsets['upper_case'] + charsets['numbers'];

                // fill up to the minLength with random symbols
                for (var i = pass.length; i < length; ++i) {
                    var randChar = charset.charAt(getRnd(charset.length));
                    // make sure required chars are mixed
                    pass = !!getRnd(1) ? randChar + pass : pass + randChar;
                }

                $passwordInput.val(pass);
            });

            $('#show-hide-pass').on('click', function(e){
                var target = e.target || window.event.target;
                if($(target).hasClass('icon-eye-open')) {
                    $passwordInput.attr('type', 'password');
                    $(target).removeClass('icon-eye-open');
                    $(target).addClass('icon-eye-close');
                } else {
                    $passwordInput.attr('type', 'text');
                    $(target).removeClass('icon-eye-close');
                    $(target).addClass('icon-eye-open');
                }
            });
        });
        </script>
        <div class="form-container">
            <form id="{{ form.vars.id }}" name="{{ form.vars.name }}" action="{{ formAction }}" method="post" class="change-password-form">
                <fieldset class="form form-horizontal">
                    {{ form_row(form.password) }}
                    {% if not form.vars.valid and form.vars.errors|length %}
                        <div class="alert alert-error">
                            <div class="message"><commit_msg>BAP-10931: Tweak password generator<commit_after>{% form_theme form with 'OroFormBundle:Form:fields.html.twig' %}
<div class="widget-content">
    {% if saved %}
        <script type="text/javascript">
        require([
            'orotranslation/js/translator',
            'oroui/js/widget-manager',
            'oroui/js/messenger',
            'oroui/js/mediator'
        ],
        function(__, widgetManager, messenger, mediator) {
            widgetManager.getWidgetInstance({{ app.request.get('_wid')|json_encode|raw }}, function(widget) {
                messenger.notificationFlashMessage('success', __('oro.user.change_password.flash.success'));
                mediator.trigger('widget_success:' + widget.getAlias());
                mediator.trigger('widget_success:' + widget.getWid());
                widget.remove();
            });
        });
        </script>
    {% else %}
        <script type="text/javascript">
        require([
            'jquery',
            'orotranslation/js/translator'
        ],
        function($, __) {
            var $passwordInput= $('[data-ftid=oro_set_password_form_password]');
            $passwordInput.after(
                    '<span class="icon-eye-close" id="show-hide-pass" style="cursor: pointer; font-size: 16px;" ' +
                    ' title="' + __("oro.user.show_hide_password.label") + '"/>'
            );
            $passwordInput.parent().after(
                '<div class="controls" style="margin-top: 5px;">' +
                    '<a href="#" id="generate-pass">' + __("oro.user.suggest_password.label") + '</a>' +
                '</div>'
            );

            $('#generate-pass').on('click', function(e){
                e.preventDefault();
                var getRnd = function(n) {
                    return Math.floor(Math.random() * (n + 1));
                };
                var requireLength = $passwordInput.data('suggest-length') || 1;
                var requirements = $passwordInput.data('suggest-rules') || '';
                var length = Math.max(requireLength, 8);
                var charsets = {
                    'lower_case': 'abcdefghijklnopqrstuvwxyz',
                    'upper_case':'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                    'numbers':'0123456789',
                    'special_chars':' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
                };
                var rules = requirements.split(',');
                var pass = '';

                // make sure we have at least one symbol for each rule, shuffle them later
                rules.forEach(function(rule) {
                    if (charsets.hasOwnProperty(rule)) {
                        pass += charsets[rule].charAt(getRnd(charsets[rule].length));
                    }
                });

                // create a pool for picking random chars that is reasonably strong
                var charset = charsets['lower_case'] + charsets['upper_case'] + charsets['numbers'];

                // fill up to the minLength with random symbols
                for (var i = pass.length; i < length; ++i) {
                    pass = pass + charset.charAt(getRnd(charset.length));
                }

                // shuffle the password
                pass = pass.split('').sort(function() {
                    return 0.5 - Math.random()
                }).join('');

                $passwordInput.val(pass);
            });

            $('#show-hide-pass').on('click', function(e){
                var target = e.target || window.event.target;
                if($(target).hasClass('icon-eye-open')) {
                    $passwordInput.attr('type', 'password');
                    $(target).removeClass('icon-eye-open');
                    $(target).addClass('icon-eye-close');
                } else {
                    $passwordInput.attr('type', 'text');
                    $(target).removeClass('icon-eye-close');
                    $(target).addClass('icon-eye-open');
                }
            });
        });
        </script>
        <div class="form-container">
            <form id="{{ form.vars.id }}" name="{{ form.vars.name }}" action="{{ formAction }}" method="post" class="change-password-form">
                <fieldset class="form form-horizontal">
                    {{ form_row(form.password) }}
                    {% if not form.vars.valid and form.vars.errors|length %}
                        <div class="alert alert-error">
                            <div class="message">
{'fraction_non_alphanumeric': 0.1537427162707306, 'fraction_numerical': 0.0044822949350067235, 'mean_word_length': 1.5742717046437842, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 35, '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': '5833176', 'n_tokens_mistral': 2499, 'n_tokens_neox': 2276, 'n_words': 402}