<commit_before>/* @flow */

import setupColumnHeadersReducer from './column-headers'
import setupConfigReducer from './config'
import forcedScrollTopReducer from './forced-scroll-top'
import initialScanReducer from './initial-scan'
import paginationReducer from './pagination'
import setupNotesReducer from './notes'
import setupSifterResult from './sifter-result'
import setupVisibleRowsReducer from './visible-rows'

export default function setupRootReducer (columns: Columns, notesFields: NotesFields) {
  const columnHeadersReducer = setupColumnHeadersReducer(columns)
  const configReducer = setupConfigReducer()
  const notesReducer = setupNotesReducer(notesFields)
  const sifterResult = setupSifterResult(notesFields)
  const visibleRowsReducer = setupVisibleRowsReducer(columns)

  return function rootReducer (state: State, action: Action) {
    if (!state) {
      // initial state may be empty, if so make sure reducers return their individual defaults
      return rootReducer({}, action)
    }

    const config = configReducer(state.config, action)

    const newState: any = {
      columnHeaders: columnHeadersReducer(state.columnHeaders, action),
      config: config,
      forcedScrollTop: forcedScrollTopReducer(state.forcedScrollTop, action),
      initialScan: initialScanReducer(state.initialScan, action),
      notes: notesReducer(state.notes, action, state.initialScan && state.initialScan.rawFiles),
      pagination: paginationReducer(state.pagination, action, config),
      sifterResult: state.sifterResult,
      visibleRows: state.visibleRows
    }

    newState.sifterResult = sifterResult(state.sifterResult, action, newState)
    newState.visibleRows = visibleRowsReducer(state.visibleRows, action, newState)

    return newState
  }
}<commit_msg>:art: Rename cost to clarify intent<commit_after>/* @flow */

import setupColumnHeadersReducer from './column-headers'
import setupConfigReducer from './config'
import forcedScrollTopReducer from './forced-scroll-top'
import initialScanReducer from './initial-scan'
import paginationReducer from './pagination'
import setupNotesReducer from './notes'
import setupSifterResult from './sifter-result'
import setupVisibleRowsReducer from './visible-rows'

export default function setupRootReducer (columns: Columns, notesFields: NotesFields) {
  const columnHeadersReducer = setupColumnHeadersReducer(columns)
  const configReducer = setupConfigReducer()
  const notesReducer = setupNotesReducer(notesFields)
  const sifterResult = setupSifterResult(notesFields)
  const visibleRowsReducer = setupVisibleRowsReducer(columns)

  return function rootReducer (state: State, action: Action) {
    if (!state) {
      // initial state may be empty, if so make sure reducers return their individual defaults
      return rootReducer({}, action)
    }

    const config = configReducer(state.config, action)

    const nextState: any = {
      columnHeaders: columnHeadersReducer(state.columnHeaders, action),
      config: config,
      forcedScrollTop: forcedScrollTopReducer(state.forcedScrollTop, action),
      initialScan: initialScanReducer(state.initialScan, action),
      notes: notesReducer(state.notes, action, state.initialScan && state.initialScan.rawFiles),
      pagination: paginationReducer(state.pagination, action, config),
      sifterResult: state.sifterResult,
      visibleRows: state.visibleRows
    }

    nextState.sifterResult = sifterResult(state.sifterResult, action, nextState)
    nextState.visibleRows = visibleRowsReducer(state.visibleRows, action, nextState)

    return nextState
  }
}
{'fraction_non_alphanumeric': 0.08681135225375626, 'fraction_numerical': 0.0, 'mean_word_length': 4.991666666666666, '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': '2319407', 'n_tokens_mistral': 1037, 'n_tokens_neox': 952, 'n_words': 253}