<commit_before>import { dispatch as d3_dispatch } from 'd3-dispatch';
import {
    event as d3_event,
    select as d3_select
} from 'd3-selection';

import { t } from '../../util/locale';
import { utilRebind } from '../../util/rebind';


export function uiIntroWelcome(context, reveal) {
    var dispatch = d3_dispatch('done'),
        listener = clickListener();

    var chapter = {
        title: 'intro.welcome.title'
    };


    function welcome() {
        context.map().centerZoom([-85.63591, 41.94285], 19);
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.welcome'),
            { buttonText: t('intro.ok'), buttonCallback: practice }
        );
    }

    function practice() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.practice'),
            { buttonText: t('intro.ok'), buttonCallback: words }
        );
    }

    function words() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.words'),
            { buttonText: t('intro.ok'), buttonCallback: mouse }
        );
    }


    function mouse() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.mouse'),
            { buttonText: t('intro.ok'), buttonCallback: leftClick }
        );
    }


    function leftClick() {
        var counter = 0,
            times = 5;

        var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.leftclick', { num: times }),
            { tooltipClass: 'intro-mouse' }
        );

        tooltip.selectAll('.tooltip-inner')
            .insert('svg', 'span')
            .attr('class', 'tooltip-illustration')
            .append('use')
            .attr('xlink:href', '#walkthrough-mouse');

        tooltip
            .append('div')
            .attr('class', 'counter');

        tooltip.call(listener);

        listener.on('click', function(which) {
            if (which === 'left') {
                d3_select('.curtain-tooltip.intro-mouse .counter')
                    .text(String(++counter));

                if (counter === times) {
                    window.setTimeout(function() { continueTo(rightClick); }, 1000);
                }
            }
        });

        function continueTo(nextStep) {
            listener.on('click', null);
            tooltip.call(listener.off);
            tooltip.select('.counter').remove();
            nextStep();
        }
    }


    function rightClick() {
        var counter = 0,
            times = 5;

        var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.rightclick', { num: times }),
            { tooltipClass: 'intro-mouse' }
        );

        tooltip.selectAll('.tooltip-inner')
            .insert('svg', 'span')
            .attr('class', 'tooltip-illustration')
            .append('use')
            .attr('xlink:href', '#walkthrough-mouse');

        tooltip
            .append('div')
            .attr('class', 'counter');

        tooltip.call(listener);

        listener.on('click', function(which) {
            if (which === 'right') {
                d3_select('.curtain-tooltip.intro-mouse .counter')
                    .text(String(++counter));

                if (counter === times) {
                    window.setTimeout(function() { continueTo(chapters); }, 1000);
                }
            }
        });

        function continueTo(nextStep) {
            listener.on('click', null);
            tooltip.call(listener.off);
            tooltip.select('.counter').remove();
            nextStep();
        }
    }


    function chapters() {
        dispatch.call('done');
        reveal('.intro-nav-wrap .chapter-navigation',
            t('intro.welcome.chapters', { next: t('intro.navigation.title') })
        );
    }

    
    chapter.enter = function() {
        welcome();
    };


    chapter.exit = function() {
        listener.off();
        var tooltip = d3_select('.curtain-tooltip.intro-mouse')
            .selectAll('.counter')
            .remove();
    };


    chapter.restart = function() {
        chapter.exit();
        chapter.enter();
    };


    return utilRebind(chapter, dispatch, 'on');
}



function clickListener() {
    var dispatch = d3_dispatch('click'),
        minTime = 120,
        tooltip = d3_select(null),
        down = {};

    // `down` keeps track of which buttons/keys are down.
    // Setting a property in `down` happens immediately.
    // Unsetting a property in `down` is delayed because
    //   on Windows a contextmenu event happens after keyup/mouseup
<commit_msg>Remove unused var (eslint)<commit_after>import { dispatch as d3_dispatch } from 'd3-dispatch';
import {
    event as d3_event,
    select as d3_select
} from 'd3-selection';

import { t } from '../../util/locale';
import { utilRebind } from '../../util/rebind';


export function uiIntroWelcome(context, reveal) {
    var dispatch = d3_dispatch('done'),
        listener = clickListener();

    var chapter = {
        title: 'intro.welcome.title'
    };


    function welcome() {
        context.map().centerZoom([-85.63591, 41.94285], 19);
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.welcome'),
            { buttonText: t('intro.ok'), buttonCallback: practice }
        );
    }

    function practice() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.practice'),
            { buttonText: t('intro.ok'), buttonCallback: words }
        );
    }

    function words() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.words'),
            { buttonText: t('intro.ok'), buttonCallback: mouse }
        );
    }


    function mouse() {
        reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.mouse'),
            { buttonText: t('intro.ok'), buttonCallback: leftClick }
        );
    }


    function leftClick() {
        var counter = 0,
            times = 5;

        var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.leftclick', { num: times }),
            { tooltipClass: 'intro-mouse' }
        );

        tooltip.selectAll('.tooltip-inner')
            .insert('svg', 'span')
            .attr('class', 'tooltip-illustration')
            .append('use')
            .attr('xlink:href', '#walkthrough-mouse');

        tooltip
            .append('div')
            .attr('class', 'counter');

        tooltip.call(listener);

        listener.on('click', function(which) {
            if (which === 'left') {
                d3_select('.curtain-tooltip.intro-mouse .counter')
                    .text(String(++counter));

                if (counter === times) {
                    window.setTimeout(function() { continueTo(rightClick); }, 1000);
                }
            }
        });

        function continueTo(nextStep) {
            listener.on('click', null);
            tooltip.call(listener.off);
            tooltip.select('.counter').remove();
            nextStep();
        }
    }


    function rightClick() {
        var counter = 0,
            times = 5;

        var tooltip = reveal('.intro-nav-wrap .chapter-welcome',
            t('intro.welcome.rightclick', { num: times }),
            { tooltipClass: 'intro-mouse' }
        );

        tooltip.selectAll('.tooltip-inner')
            .insert('svg', 'span')
            .attr('class', 'tooltip-illustration')
            .append('use')
            .attr('xlink:href', '#walkthrough-mouse');

        tooltip
            .append('div')
            .attr('class', 'counter');

        tooltip.call(listener);

        listener.on('click', function(which) {
            if (which === 'right') {
                d3_select('.curtain-tooltip.intro-mouse .counter')
                    .text(String(++counter));

                if (counter === times) {
                    window.setTimeout(function() { continueTo(chapters); }, 1000);
                }
            }
        });

        function continueTo(nextStep) {
            listener.on('click', null);
            tooltip.call(listener.off);
            tooltip.select('.counter').remove();
            nextStep();
        }
    }


    function chapters() {
        dispatch.call('done');
        reveal('.intro-nav-wrap .chapter-navigation',
            t('intro.welcome.chapters', { next: t('intro.navigation.title') })
        );
    }


    chapter.enter = function() {
        welcome();
    };


    chapter.exit = function() {
        listener.off();
        d3_select('.curtain-tooltip.intro-mouse')
            .selectAll('.counter')
            .remove();
    };


    chapter.restart = function() {
        chapter.exit();
        chapter.enter();
    };


    return utilRebind(chapter, dispatch, 'on');
}



function clickListener() {
    var dispatch = d3_dispatch('click'),
        minTime = 120,
        tooltip = d3_select(null),
        down = {};

    // `down` keeps track of which buttons/keys are down.
    // Setting a property in `down` happens immediately.
    // Unsetting a property in `down` is delayed because
    //   on Windows a contextmenu event happens after keyup/mouseup

{'fraction_non_alphanumeric': 0.1524396840852537, 'fraction_numerical': 0.009087958455047063, 'mean_word_length': 1.7520095266448348, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4710103', 'n_tokens_mistral': 2728, 'n_tokens_neox': 2499, 'n_words': 487}