<commit_before>import thunk from 'redux-thunk'
import createLogger from 'redux-logger'
import { browserHistory } from 'react-router'
import { routerMiddleware } from 'react-router-redux'
import { combineReducers, compose, createStore, applyMiddleware } from 'redux'
import { autoRehydrate } from 'redux-persist'
import { analytics, authentication, requester, uploader } from './middleware'
import * as reducers from './reducers'

const reducer = combineReducers({
  ...reducers,
})



const createBrowserStore = (history = browserHistory) => {
  const logger = createLogger({ collapsed: true, predicate: () => ENV.APP_DEBUG })
  const reduxRouterMiddleware = routerMiddleware(history)

  const store = compose(
    autoRehydrate(),
    applyMiddleware(
      thunk,
      authentication,
      reduxRouterMiddleware,
      uploader,
      requester,
      analytics,
      logger
    ),
  )(createStore)(reducer, window.__INITIAL_STATE__ || {})

  return store
}

const createServerStore = (history) => {
  const reduxRouterMiddleware = routerMiddleware(history)
  const store = compose(
    applyMiddleware(thunk, uploader, reduxRouterMiddleware, requester),
  )(createStore)(reducer, {})

  return store
}

const createElloStore = (history = null) => {
  if (typeof window !== 'undefined') return createBrowserStore()
  return createServerStore(history)
}

export { createElloStore }

export default createElloStore()<commit_msg>Clobber the prerendered router state (#538)<commit_after>import thunk from 'redux-thunk'
import createLogger from 'redux-logger'
import { browserHistory } from 'react-router'
import { routerMiddleware } from 'react-router-redux'
import { combineReducers, compose, createStore, applyMiddleware } from 'redux'
import { autoRehydrate } from 'redux-persist'
import { analytics, authentication, requester, uploader } from './middleware'
import * as reducers from './reducers'

const reducer = combineReducers({
  ...reducers,
})



const createBrowserStore = (history = browserHistory) => {
  const logger = createLogger({ collapsed: true, predicate: () => ENV.APP_DEBUG })
  const reduxRouterMiddleware = routerMiddleware(history)

  const initialState = window.__INITIAL_STATE__ || {}
  // react-router-redux doesn't know how to serialize
  // query params from server-side rendering, so we just kill it
  // and let the browser reconstruct the router state
  initialState.routing = {}

  const store = compose(
    autoRehydrate(),
    applyMiddleware(
      thunk,
      authentication,
      reduxRouterMiddleware,
      uploader,
      requester,
      analytics,
      logger
    ),
  )(createStore)(reducer, initialState || {})

  return store
}

const createServerStore = (history) => {
  const reduxRouterMiddleware = routerMiddleware(history)
  const store = compose(
    applyMiddleware(thunk, uploader, reduxRouterMiddleware, requester),
  )(createStore)(reducer, {})

  return store
}

const createElloStore = (history = null) => {
  if (typeof window !== 'undefined') return createBrowserStore()
  return createServerStore(history)
}

export { createElloStore }

export default createElloStore()
{'fraction_non_alphanumeric': 0.10491071428571429, 'fraction_numerical': 0.0009566326530612245, 'mean_word_length': 4.474694589877836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3162474', 'n_tokens_mistral': 912, 'n_tokens_neox': 895, 'n_words': 244}