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

import { geoExtent, geoPointInPolygon } from '../geo';
import { modeSelect } from '../modes/select';
import { uiLasso } from '../ui/lasso';
import { utilArrayIntersection } from '../util/array';
import { utilGetAllNodes } from '../util/util';


export function behaviorLasso(context) {

    // use pointer events on supported platforms; fallback to mouse events
    var _pointerPrefix = 'PointerEvent' in window ? 'pointer' : 'mouse';

    var behavior = function(selection) {
        var lasso;


        function pointerdown() {
            var button = 0;  // left
            if (d3_event.button === button && d3_event.shiftKey === true) {
                lasso = null;

                d3_select(window)
                    .on(_pointerPrefix + 'move.lasso', pointermove)
                    .on(_pointerPrefix + 'up.lasso', pointerup);

                d3_event.stopPropagation();
            }
        }


        function pointermove() {
            if (!lasso) {
                lasso = uiLasso(context);
                context.surface().call(lasso);
            }

            lasso.p(context.map().mouse());
        }


        function normalize(a, b) {
            return [
                [Math.min(a[0], b[0]), Math.min(a[1], b[1])],
                [Math.max(a[0], b[0]), Math.max(a[1], b[1])]
            ];
        }


        function lassoed() {
            if (!lasso) return [];

            if (!context.map().editableDataEnabled(true /* skipZoomCheck */)) return [];

            var graph = context.graph();
            var bounds = lasso.extent().map(context.projection.invert);
            var extent = geoExtent(normalize(bounds[0], bounds[1]));

            var limitToNodes;

            if (context.map().isInWideSelection()) {
                // only select from the visible nodes
                limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), context.graph()));
            }

            var intersects = context.history().intersects(extent).filter(function(entity) {<commit_msg>Disable node lasso selection when zoomed out (re: #7728)<commit_after>import { event as d3_event, select as d3_select } from 'd3-selection';

import { geoExtent, geoPointInPolygon } from '../geo';
import { modeSelect } from '../modes/select';
import { uiLasso } from '../ui/lasso';
import { utilArrayIntersection } from '../util/array';
import { utilGetAllNodes } from '../util/util';


export function behaviorLasso(context) {

    // use pointer events on supported platforms; fallback to mouse events
    var _pointerPrefix = 'PointerEvent' in window ? 'pointer' : 'mouse';

    var behavior = function(selection) {
        var lasso;


        function pointerdown() {
            var button = 0;  // left
            if (d3_event.button === button && d3_event.shiftKey === true) {
                lasso = null;

                d3_select(window)
                    .on(_pointerPrefix + 'move.lasso', pointermove)
                    .on(_pointerPrefix + 'up.lasso', pointerup);

                d3_event.stopPropagation();
            }
        }


        function pointermove() {
            if (!lasso) {
                lasso = uiLasso(context);
                context.surface().call(lasso);
            }

            lasso.p(context.map().mouse());
        }


        function normalize(a, b) {
            return [
                [Math.min(a[0], b[0]), Math.min(a[1], b[1])],
                [Math.max(a[0], b[0]), Math.max(a[1], b[1])]
            ];
        }


        function lassoed() {
            if (!lasso) return [];

            var graph = context.graph();
            var limitToNodes;

            if (context.map().editableDataEnabled(true /* skipZoomCheck */) && context.map().isInWideSelection()) {
                // only select from the visible nodes
                limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
            } else if (!context.map().editableDataEnabled()) {
                return [];
            }

            var bounds = lasso.extent().map(context.projection.invert);
            var extent = geoExtent(normalize(bounds[0], bounds[1]));

            var intersects = context.history().intersects(extent).filter(function(entity) {
{'fraction_non_alphanumeric': 0.136090573012939, 'fraction_numerical': 0.009242144177449169, 'mean_word_length': 1.909274193548387, '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': '1174196', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1179, 'n_words': 274}