<commit_before>/* eslint-disable no-console */
import _ from 'lodash';
import * as redux from 'redux';
import csjs from 'csjs';
import insertCSS from 'insert-css';

import { makeReducer } from './reducer';
import { asyncMiddleware } from './middleware';
import { parseComponent } from './component';
import { makeImmutable, unwrapImmutable } from './update';
import { extendHyperscript } from './hyperscript';

const logger = store => next => action => {
  console.group(action.type);
  console.info('dispatching', action);
  const result = next(action);
  console.log('next state', store.getState());
  console.groupEnd(action.type);
  return result;
};

const usedStyles = {};

function createCSS (pieces, ...substitutions) {
  const styles = csjs(pieces, ...substitutions.map(x => {
    if (typeof x !== 'string') return x;
    if (!usedStyles.hasOwnProperty(x)) return x;
    return usedStyles[x];
  }));

  insertCSS(csjs.getCss(styles));

  _.assign(usedStyles, styles);

  return _.mapValues(styles, x => x.toString());
}

function createStore (rootComponent, opts) {<commit_msg>Fix style extend issue<commit_after>/* eslint-disable no-console */
import _ from 'lodash';
import * as redux from 'redux';
import csjs from 'csjs';
import insertCSS from 'insert-css';

import { makeReducer } from './reducer';
import { asyncMiddleware } from './middleware';
import { parseComponent } from './component';
import { makeImmutable, unwrapImmutable } from './update';
import { extendHyperscript } from './hyperscript';

const logger = store => next => action => {
  console.group(action.type);
  console.info('dispatching', action);
  const result = next(action);
  console.log('next state', store.getState());
  console.groupEnd(action.type);
  return result;
};

const usedStyles = {};

function substitueStyle (x) {
  if (typeof x !== 'string') return x;
  if (usedStyles.hasOwnProperty(x)) return usedStyles[x];
  return x;
}

function createCSS (pieces, ...substitutions) {
  const styles = csjs(pieces, ...substitutions.map(substitueStyle));

  insertCSS(csjs.getCss(styles));

  return _.mapValues(styles, x => {
    const generatedName = x.toString();
    usedStyles[generatedName] = x;
    return generatedName;
  });
}

function createStore (rootComponent, opts) {
{'fraction_non_alphanumeric': 0.15184859154929578, 'fraction_numerical': 0.0, 'mean_word_length': 4.557457212713937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '597688', 'n_tokens_mistral': 705, 'n_tokens_neox': 696, 'n_words': 190}