<commit_before>import Cache from './Cache';

const media = decl => decl.hasOwnProperty('media') ? decl.media : 'all';

export default function createGetClassName({ calculateRule, mediaOrder, cache }) {
  cache = new Cache(cache);
  const sortMedia = (d1, d2) => mediaOrder.indexOf(media(d1)) - mediaOrder.indexOf(media(d2));

  return sheet => function getClassName(decls) {
    const result = cache.get(decls);

    if (result.hasOwnProperty('newDecls')) {
      for (const decl of (mediaOrder ? result.newDecls.sort(sortMedia) : result.newDecls)) {
        const rule = calculateRule(decl.prop, decl.val);
        sheet.insert(
          media(decl),
          `.${decl.className}${decl.sel || ''}`,
          rule
        );
      }
    }

    return result.className;
  }
}<commit_msg>Support new css declaration<commit_after>import Cache from './Cache';

const media = decl => decl.hasOwnProperty('media') ? decl.media : 'all';

export default function createGetClassName({ calculateRule, mediaOrder, cache }) {
  cache = new Cache(cache);
  const sortMedia = (d1, d2) => mediaOrder.indexOf(media(d1)) - mediaOrder.indexOf(media(d2));

  return sheet => function getClassName(decls) {
    const result = cache.get(decls);

    if (result.hasOwnProperty('newDecls')) {
      for (const decl of (mediaOrder ? result.newDecls.sort(sortMedia) : result.newDecls)) {
        const rule = calculateRule(decl.prop, decl.value);
        sheet.insert(
          media(decl),
          `.${decl.className}${decl.hasOwnProperty('sel') ? decl.sel : ''}`,
          rule
        );
      }
    }

    return result.className;
  }
}
{'fraction_non_alphanumeric': 0.14734895191122072, 'fraction_numerical': 0.004932182490752158, 'mean_word_length': 3.193798449612403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7627647', 'n_tokens_mistral': 490, 'n_tokens_neox': 485, 'n_words': 108}