<commit_before>import Fuse from 'fuse.js';
import Store from './store/index.js';
import {
  addItem,
  removeItem,
  highlightItem,
  addChoice,
  filterChoices,
  activateChoices,
  addGroup,
  clearAll,
  clearChoices,
}
from './actions/index';
import {
  isScrolledIntoView,
  getAdjacentEl,
  wrap,
  isType,
  isElement,
  strToEl,
  extend,
  getWidthOfInput,
  sortByAlpha,
  sortByScore,
}
from './lib/utils.js';
import './lib/polyfills.js';


/**
 * Choices
 */
export default class Choices {
  constructor(element = '[data-choice]', userConfig = {}) {
    // If there are multiple elements, create a new instance
    // for each element besides the first one (as that already has an instance)
    if (isType('String', element)) {
      const elements = document.querySelectorAll(element);
      if (elements.length > 1) {
        for (let i = 1; i < elements.length; i++) {
          const el = elements[i];
          new Choices(el, userConfig);
        }
      }
    }

    const defaultConfig = {
      items: [],
      choices: [],
      maxItemCount: -1,
      addItems: true,
      removeItems: true,
      removeItemButton: false,
      editItems: false,
      duplicateItems: true,
      delimiter: ',',
      paste: true,
      search: true,
      flip: true,
      regexFilter: null,
      shouldSort: true,
      sortFilter: sortByAlpha,
      sortFields: ['label', 'value'],
      placeholder: true,
      placeholderValue: null,
      prependValue: null,
      appendValue: null,
      loadingText: 'Loading...',
      noResultsText: 'No results round',
      noChoicesText: 'No choices to choose from',
      itemSelectText: 'Press to select',
      classNames: {
        containerOuter: 'choices',
        containerInner: 'choices__inner',
        input: 'choices__input',
        inputCloned: 'choices__input--cloned',
        list: 'choices__list',
        listItems: 'choices__list--multiple',
        listSingle: 'choices__list--single',
        listDropdown: 'choices__list--dropdown',
        item: 'choices__item',
        itemSelectable: 'choices__item--selectable',
        itemDisabled: 'choices__item--disabled',
        itemChoice: 'choices__item--choice',
        placeholder: 'choices__placeholder',
        group: 'choices__group',
        groupHeading: 'choices__heading',
        button: 'choices__button',
        activeState: 'is-active',
        focusState: 'is-focused',
        openState: 'is-open',
        disabledState: 'is-disabled',
        highlightedState: 'is-highlighted',
        hiddenState: 'is-hidden',
        flippedState: 'is-flipped',
        loadingState: 'is-loading',
      },
      callbackOnInit: () => {},
      callbackOnAddItem: (id, value, passedInput) => {},
      callbackOnRemoveItem: (id, value, passedInput) => {},
      callbackOnHighlightItem: (id, value, passedInput) => {},
      callbackOnUnhighlightItem: (id, value, passedInput) => {},
      callbackOnChange: (value, passedInput) => {},
      callbackOnItemSearch: (value, fn, passedInput) => {},
    };

    // Merge options with user options
    this.config = extend(defaultConfig, userConfig);

    // Create data store
    this.store = new Store(this.render);

    // State tracking
    this.initialised = false;
    this.currentState = {};<commit_msg>- Bogus test on callback existence<commit_after>import Fuse from 'fuse.js';
import Store from './store/index.js';
import {
  addItem,
  removeItem,
  highlightItem,
  addChoice,
  filterChoices,
  activateChoices,
  addGroup,
  clearAll,
  clearChoices,
}
from './actions/index';
import {
  isScrolledIntoView,
  getAdjacentEl,
  wrap,
  isType,
  isElement,
  strToEl,
  extend,
  getWidthOfInput,
  sortByAlpha,
  sortByScore,
}
from './lib/utils.js';
import './lib/polyfills.js';


/**
 * Choices
 */
export default class Choices {
  constructor(element = '[data-choice]', userConfig = {}) {
    // If there are multiple elements, create a new instance
    // for each element besides the first one (as that already has an instance)
    if (isType('String', element)) {
      const elements = document.querySelectorAll(element);
      if (elements.length > 1) {
        for (let i = 1; i < elements.length; i++) {
          const el = elements[i];
          new Choices(el, userConfig);
        }
      }
    }

    const defaultConfig = {
      items: [],
      choices: [],
      maxItemCount: -1,
      addItems: true,
      removeItems: true,
      removeItemButton: false,
      editItems: false,
      duplicateItems: true,
      delimiter: ',',
      paste: true,
      search: true,
      flip: true,
      regexFilter: null,
      shouldSort: true,
      sortFilter: sortByAlpha,
      sortFields: ['label', 'value'],
      placeholder: true,
      placeholderValue: null,
      prependValue: null,
      appendValue: null,
      loadingText: 'Loading...',
      noResultsText: 'No results round',
      noChoicesText: 'No choices to choose from',
      itemSelectText: 'Press to select',
      classNames: {
        containerOuter: 'choices',
        containerInner: 'choices__inner',
        input: 'choices__input',
        inputCloned: 'choices__input--cloned',
        list: 'choices__list',
        listItems: 'choices__list--multiple',
        listSingle: 'choices__list--single',
        listDropdown: 'choices__list--dropdown',
        item: 'choices__item',
        itemSelectable: 'choices__item--selectable',
        itemDisabled: 'choices__item--disabled',
        itemChoice: 'choices__item--choice',
        placeholder: 'choices__placeholder',
        group: 'choices__group',
        groupHeading: 'choices__heading',
        button: 'choices__button',
        activeState: 'is-active',
        focusState: 'is-focused',
        openState: 'is-open',
        disabledState: 'is-disabled',
        highlightedState: 'is-highlighted',
        hiddenState: 'is-hidden',
        flippedState: 'is-flipped',
        loadingState: 'is-loading',
      },
      callbackOnInit: () => {},
      callbackOnAddItem: (id, value, passedInput) => {},
      callbackOnRemoveItem: (id, value, passedInput) => {},
      callbackOnHighlightItem: (id, value, passedInput) => {},
      callbackOnUnhighlightItem: (id, value, passedInput) => {},
      callbackOnChange: (value, passedInput) => {},
      callbackOnItemSearch: null,
    };

    // Merge options with user options
    this.config = extend(defaultConfig, userConfig);

    // Create data store
    this.store = new Store(this.render);

    // State tracking
    this.initialised = false;
    this.currentState = {};
{'fraction_non_alphanumeric': 0.12539899680802555, 'fraction_numerical': 0.0009119927040583675, 'mean_word_length': 2.6616583194212575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '6411710', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1949, 'n_words': 473}