        <script type="text/javascript" src="{{ base_path() }}/{{ constant('GALETTE_THEME') }}ui/semantic.min.js"></script>
        <script type="text/javascript" src="{{ base_path() }}/assets/js/galette-main.bundle.min.js"></script>

        <script type="text/javascript">
            function csrfSafeMethod(method) {
                // these HTTP methods do not require CSRF protection
                return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
            }

            $(function(){
                $.ajaxPrefilter(function(options, originalOptions, jqXHR){
                    if (options.type.toLowerCase() === "post") {
                        // initialize `data` to empty string if it does not exist
                        options.data = options.data || "";

                        // add leading ampersand if `data` is non-empty
                        options.data += options.data?"&":"";

                        // add csrf
                        options.data += encodeURIComponent("{{ csrf_name_key }}") + "=" + encodeURIComponent("{{ csrf_name }}") + "&" + encodeURIComponent("{{ csrf_value_key }}") + "=" + encodeURIComponent("{{ csrf_value }}")
                    }
                });

    {% if autocomplete %}
                $('#ville_adh_field, #lieu_naissance_field').search({
                    apiSettings: {
                        url: '{{ url_for('suggestTown', {'term': '{query}'}) }}',
                        method: 'post',
                        onFailure: function(response, element, xhr) {
                            console.log(response);
                        },
                        onError: function(errorMessage, element, xhr) {
                            {% include "elements/js/modal.js.twig" with {
                                modal_title_twig: _T("An error occurred :(")|e("js"),
                                modal_content: "errorMessage",
                                modal_class: "tiny",
                                modal_content_class: "scrolling",
                                modal_deny_only: true,
                                modal_cancel_text: _T("Close")|e("js"),
                                modal_classname: "redalert",
                            } %}
                            console.log(xhr);
                        }
                    },
                    minCharacters : 2
                });
                $('#pays_adh_field').search({
                    apiSettings: {
                        url: '{{ url_for('suggestCountry', {'term': '{query}'}) }}',
                        method: 'post',
                        onFailure: function(response, element, xhr) {
                            console.log(response);
                        },
                        onError: function(errorMessage, element, xhr) {
                            {% include "elements/js/modal.js.twig" with {
                                modal_title_twig: _T("An error occurred :(")|e("js"),
                                modal_content: "errorMessage",
                                modal_class: "tiny",
                                modal_content_class: "scrolling",
                                modal_deny_only: true,
                                modal_cancel_text: _T("Close")|e("js"),
                                modal_classname: "redalert",
                            } %}
                            console.log(xhr);
                        }
                    },
                    minCharacters : 2
                });
    {% endif %}

            {% include "elements/js/calendar.js.twig" %}

    {% if renew_telemetry is defined %}
            {% include "modals/telemetry.html.twig" with {part: "jsdialog"} %}
    {% endif %}

            {% include "elements/js/messages.js.twig" %}

            });
        </script>
    {% if login.isLogged() %}
        <script type="module" src="{{ base_path() }}/assets/js/sortable.min.js"></script>
    {% endif %}
    {% if require_charts %}
        <script type="module" src="{{ base_path() }}/assets/js/chartjs.min.js"></script>
    {% endif %}
    {% if require_mass %}
        <script type="text/javascript" src="{{ base_path() }}/assets/js/masschanges.min.js"></script>
    {% endif %}
    {% if html_editor %}
        <script type="text/javascript" src="{{ base_path() }}/assets/js/codemirror.js"></script>
        <script type="text/javascript" src="{{ base_path() }}/assets/js/xml.js"></script>
        <script type="text/javascript" src="{{ base_path() }}/assets/js/formatting.js"></script>
        <script type="text/javascript" src="{{ base_path() }}/assets/js/summernote.min.js"></script>
        <script type="text/javascript" src="{{ base_path() }}/assets/js/lang/summernote-{{ i18n.getID()|replace({'_': '-'}) }}.min.js"></script>
        <script language="javascript">
            function activateMailingEditor() {
                if(!$('#mailing_html').attr('checked')){
                    $('#mailing_html').attr('checked', true);
                }

                $('input#html_editor_active').attr('value', '1');
                $('#activate_editor').remove();
                $('#summernote_toggler').html('<a class="ui blue tertiary button" href="javascript:deactivateMailingEditor();" id="deactivate_editor">{{ _T("Deactivate HTML editor") }}</a>');

                $('#mailing_corps').summernote({
                    lang: '{{ i18n.getID()|replace({'_': '-'}) }}',
                    disableDragAndDrop: true,
                    height: 240,
                    toolbar: [
                        ['style', ['style']],
                        ['font', ['bold', 'italic', 'strikethrough', 'clear']],
                        ['para', ['ul', 'ol', 'paragraph']],
                        ['insert', ['link', 'picture']],
                        ['view', ['codeview', 'help']]
                    ],
                    styleTags: [
                        'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
                    ],
                    callbacks: {
                        onImageUpload: function (data) {
                            //prevent image copypaste
                            data.pop();
                        }
                    }
                });
                $('#mailing_corps').summernote('focus');
            }
            function deactivateMailingEditor() {
                $('#mailing_corps').summernote('destroy');
                $('#deactivate_editor').remove();
                $('#summernote_toggler').html('<a class="ui blue tertiary button" href="javascript:activateMailingEditor();" id="activate_editor">{{ _T("Activate HTML editor") }}</a>');
            }
        {% if html_editor_active is defined and html_editor_active == 1 %}
            $(function(){
                activateMailingEditor();
            });
        {% endif %}
        </script>
    {% endif %}
    {% set localjstracking = constant('_CURRENT_THEME_PATH') ~ "tracking.js" %}
    {% if file_exists(localjstracking) %}
        <script type="text/javascript" src="{{ base_path() }}/{{ constant('GALETTE_THEME') }}tracking.js"></script>
    {% endif %}
