<commit_before>export default (shower) => {
    const { stepSelector, activeSlideClass } = shower.options;

    let innerSteps;
    let innerAt;

    const getInnerSteps = () => {
        const { element } = shower.activeSlide;
        return [...element.querySelectorAll(stepSelector)];
    };

    const getInnerAt = () => {
        return innerSteps.filter((step) => {
            return step.classList.contains(activeSlideClass);
        }).length;
    };

    const setInnerStepsState = () => {
        if (shower.isListMode) return;

        innerSteps = getInnerSteps();
        innerAt = getInnerAt();

        const slide = shower.activeSlide;
        if (slide) {
            slide.state.innerStepCount = innerSteps.length;
        }
    };

    const toggleActive = () => {
        innerSteps.forEach((step, index) => {
            step.classList.toggle(activeSlideClass, index < innerAt);
        });
    };

    shower.addEventListener('start', setInnerStepsState);
    shower.addEventListener('modechange', setInnerStepsState);
    shower.addEventListener('slidechange', setInnerStepsState);

    shower.addEventListener('next', (event) => {
        if (event.defaultPrevented || !event.cancelable) return;
        if (shower.isListMode || innerAt === innerSteps.length) return;

        event.preventDefault();
        innerAt++;
        toggleActive();
    });

    shower.addEventListener('prev', (event) => {
        if (event.defaultPrevented || !event.cancelable) return;
        if (shower.isListMode || innerAt === innerSteps.length || !innerAt) return;

        event.preventDefault();
        innerAt--;
        toggleActive();
    });
};
<commit_msg>Mark only last open .next item as active (#140)<commit_after>export default (shower) => {
    const { stepSelector, activeSlideClass, visitedSlideClass } = shower.options;

    let innerSteps;
    let innerAt;

    const getInnerSteps = () => {
        const { element } = shower.activeSlide;
        return [...element.querySelectorAll(stepSelector)];
    };

    const getInnerAt = () => {
        return innerSteps.filter((step) => {
            return step.classList.contains(activeSlideClass);
        }).length;
    };

    const setInnerStepsState = () => {
        if (shower.isListMode) return;

        innerSteps = getInnerSteps();
        innerAt = getInnerAt();

        const slide = shower.activeSlide;
        if (slide) {
            slide.state.innerStepCount = innerSteps.length;
        }
    };

    const toggleActive = () => {
        innerSteps.forEach((step, index) => {
            step.classList.toggle(visitedSlideClass, index < innerAt);
            step.classList.toggle(activeSlideClass, index === innerAt - 1);
        });
    };

    shower.addEventListener('start', setInnerStepsState);
    shower.addEventListener('modechange', setInnerStepsState);
    shower.addEventListener('slidechange', setInnerStepsState);

    shower.addEventListener('next', (event) => {
        if (event.defaultPrevented || !event.cancelable) return;
        if (shower.isListMode || innerAt === innerSteps.length) return;

        event.preventDefault();
        innerAt++;
        toggleActive();
    });

    shower.addEventListener('prev', (event) => {
        if (event.defaultPrevented || !event.cancelable) return;
        if (shower.isListMode || innerAt === innerSteps.length || !innerAt) return;

        event.preventDefault();
        innerAt--;
        toggleActive();
    });
};

{'fraction_non_alphanumeric': 0.1353448275862069, 'fraction_numerical': 0.0011494252873563218, 'mean_word_length': 2.5960743801652892, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '1414476', 'n_tokens_mistral': 986, 'n_tokens_neox': 977, 'n_words': 179}