<commit_before>import { normalize, normalizeAll } from '../lib/normalizeStyles';

// Styled - helps with this.context.theme.styles

// It tracks four types of styles:
//   1. styles: runtime loaded styles
//   2. addedStyles: imperative styles added in component
//   3. propStyles: styles passed in with props
//   4. conditionalStyles: firstChild, lastChild

module.exports = {
  componentWillUpdate(nextProps) {
    this.setupStyles(nextProps);
  },

  componentWillMount() {
    this.setupStyles(this.props);

    if (this.context.theme && this.context.theme.styles)
      this.styles = this.context.theme.styles[this.name] || {};
  },

  setupStyles(props) {
    this.addedStyles = {};

    if (props.styles) {
      var pStyles;

      // normalize styles
      if (Array.isArray(props.styles))
        pStyles = props.styles.map(normalize);
      else
        pStyles = normalizeAll(props.styles);

      this.propStyles = pStyles;
      this.propAddedStyles = {};

      // props = Object.defineProperty(props, 'styles', { writeable: true });
      if (!Object.isFrozen(props)) {
        delete props.styles;
      }

    }
  },

  getPropStyles(ref) {
    return ref === 'self' && Array.isArray(this.propStyles) ?
      this.propStyles :
      this.propStyles && this.propStyles[ref];
  },

  getPropAddedStyles(ref) {
    return this.propAddedStyles && this.propAddedStyles[ref];
  },

  addStyleTo(obj, key, style) {
    obj[key] = (obj[key] || []).concat(style);
  },

  getStyles(ref, index) {
    if (!this.styles)
      return;

    ref = ref || 'self';

    return (
      (this.styles[ref] &&<commit_msg>Added fix for handling styling of frozen objects<commit_after>import { normalize, normalizeAll } from '../lib/normalizeStyles';

// Styled - helps with this.context.theme.styles

// It tracks four types of styles:
//   1. styles: runtime loaded styles
//   2. addedStyles: imperative styles added in component
//   3. propStyles: styles passed in with props
//   4. conditionalStyles: firstChild, lastChild

Object.unfreeze=function(o){
       var oo=undefined;
        if( o instanceof Array){
                oo=[];var clone=function(v){oo.push(v)};
                o.forEach(clone);
        }else if(o instanceof String){
           oo=new String(o).toString();
      }else  if(typeof o =='object'){

         oo={};
        for (var property in o){oo[property] = o[property];}


        }
        return oo;
 }

module.exports = {
  componentWillUpdate(nextProps) {
    this.setupStyles(nextProps);
  },

  componentWillMount() {
    this.setupStyles(this.props);

    if (this.context.theme && this.context.theme.styles)
      this.styles = this.context.theme.styles[this.name] || {};
  },

  setupStyles(props) {
    this.addedStyles = {};

    if (props.styles) {
      var pStyles;

      // normalize styles
      if (Array.isArray(props.styles))
        pStyles = props.styles.map(normalize);
      else
        pStyles = normalizeAll(props.styles);

      this.propStyles = pStyles;
      this.propAddedStyles = {};

      // props = Object.defineProperty(props, 'styles', { writeable: true });
      if (Object.isFrozen(props)) {
        props = Object.unfreeze(props);
      }
      delete props.styles;

    }
  },

  getPropStyles(ref) {
    return ref === 'self' && Array.isArray(this.propStyles) ?
      this.propStyles :
      this.propStyles && this.propStyles[ref];
  },

  getPropAddedStyles(ref) {
    return this.propAddedStyles && this.propAddedStyles[ref];
  },

  addStyleTo(obj, key, style) {
    obj[key] = (obj[key] || []).concat(style);
  },

  getStyles(ref, index) {
    if (!this.styles)
      return;

    ref = ref || 'self';

    return (
      (this.styles[ref] &&
{'fraction_non_alphanumeric': 0.14266523374529821, 'fraction_numerical': 0.0021493820526598604, 'mean_word_length': 2.6392961876832843, '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': '769707', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1184, 'n_words': 244}