<commit_before>// component-requires.js is a generated file in rsg.js that contains
// the list of required user-defined components
import Components from '../../res-tmp/component-requires'
import reactPropMeta from '../../res-tmp/propsdoc'

// for `commonStrict` module formatter
// https://babeljs.io/docs/usage/modules/#interop
let Contents = Components
  .map((Content) => Content.default || Content)
  .filter((Component) => Component.styleguide)
// compare index numbers
  .sort((a, b) => {
    a = a.styleguide.index
    b = b.styleguide.index

    return !a ? 1 : !b ? -1 : a.toString().localeCompare(b)
  })
  //create example readme if not included for ecology live demo
  .map((Component) => {
    if (reactPropMeta[Component.name]) {

        Component.styleguide.title = Component.styleguide.title || Component.name;
        var description = Component.styleguide.description || reactPropMeta[Component.name].description;
        var code = Component.styleguide.example || '\n<' + Component.name + '></' + Component.name + '>\n';
        Component.styleguide.readme =   '# ' + Component.styleguide.title + '\n' +
                                        '```playground\n' +
                                        code +
                                        '```\n' +
                                        description + '\n' +
                                        '### Props';
         return Component
    } else {
        return Component
    }
  });

export default {
  /**
   * @type {string[]}
   */
  navList: (() => {
    const components = {}

    const categories = Contents
      .map((Content) => {
        const styleguide = Content.styleguide

        components[styleguide.category] = components[styleguide.category] ? components[styleguide.category] : []
        components[styleguide.category].push(styleguide.title)

        return Content.styleguide.category
      })
      .filter((category, i, categories) => categories.indexOf(category) === i)

    return {
      categories: categories,
      components: components
    }
  })(),

  /**
   * @param {Object=} data
   * @param {string=} data.query
   * @param {string[]=} data.keys
   * @param {boolean=} data.exact
   * @returns {ReactClass[]}
   */
  search (data) {
    data = data || {}

    let query = (data.query || '').trim().toLowerCase()
    let keys = data.keys || []
    let exact = !!data.exact
    let phrases = !exact ? query.split(' ') : null

    if (query === '') {
      return Contents
    }

    return Contents.filter((Content) => {
      return keys
        .filter((key) => !!Content.styleguide[key])
        .some((key) => {<commit_msg>more dependency fixes<commit_after>// component-requires.js is a generated file in rsg.js that contains
// the list of required user-defined components
import Components from '../../res-tmp/component-requires'
import reactPropMeta from '../../res-tmp/propsdoc'

// for `commonStrict` module formatter
// https://babeljs.io/docs/usage/modules/#interop
let Contents = Components
  .map((Content) => Content.default || Content)
//  .filter((Component) => Component.styleguide)
//// compare index numbers
//  .sort((a, b) => {
//    a = a.styleguide.index
//    b = b.styleguide.index
//
//    return !a ? 1 : !b ? -1 : a.toString().localeCompare(b)
//  })
  //create example readme if not included for ecology live demo
  .map((Component) => {
    if (reactPropMeta[Component.name]) {
        var description;
        var code;

        Component.styleguide = Component.styleguide || {};

        if ( !Component.styleguide.title ) {
            Component.styleguide.title = Component.name;
        }

        if ( !Component.styleguide.description ) {
            description = reactPropMeta[Component.name].description;
        } else if (Component.styleguide.description) {
            description = Component.styleguide.description;
        }

        if ( !Component.styleguide.example ) {
            code = '\n<' + Component.name + '></' + Component.name + '>\n';
        } else if (Component.styleguide.example) {
            code = Component.styleguide.example;
        }


        Component.styleguide.readme =   '# ' + Component.styleguide.title + '\n' +
                                        '```playground\n' +
                                        code +
                                        '```\n' +
                                        description + '\n' +
                                        '### Props';
         return Component
    } else {
        return Component
    }
  });

export default {
  /**
   * @type {string[]}
   */
  navList: (() => {
    const components = {}

    const categories = Contents
      .map((Content) => {
        const styleguide = Content.styleguide;
        styleguide.category = styleguide.category ? styleguide.category : 'Misc. Component List';
        components[styleguide.category] = components[styleguide.category] ? components[styleguide.category] : [];
        components[styleguide.category].push(styleguide.title);

        return Content.styleguide.category
      })
      .filter((category, i, categories) => categories.indexOf(category) === i);

    return {
      categories: categories,
      components: components
    }
  })(),

  /**
   * @param {Object=} data
   * @param {string=} data.query
   * @param {string[]=} data.keys
   * @param {boolean=} data.exact
   * @returns {ReactClass[]}
   */
  search (data) {
    data = data || {}

    let query = (data.query || '').trim().toLowerCase()
    let keys = data.keys || []
    let exact = !!data.exact
    let phrases = !exact ? query.split(' ') : null

    if (query === '') {
      return Contents
    }

    return Contents.filter((Content) => {
      return keys
        .filter((key) => !!Content.styleguide[key])
        .some((key) => {
{'fraction_non_alphanumeric': 0.14768439108061748, 'fraction_numerical': 0.0006861063464837049, 'mean_word_length': 2.0608923884514434, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7518145', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1663, 'n_words': 359}