<commit_before>import hash from 'string-hash'
import * as CSS from 'csstype'
import { Options, Meta } from './types'

const invalidProps = ['excludedProps']

export { Options, Meta }

/**
 * @example p2,mx4,left10,spaceX4...
 * @example p-20,opacity-80
 */
export const digitReg =
  /^([mp][xytrbl]?|space[xy]?|top|right|bottom|left|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex|leading|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border[trbl]?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?-?\d+[a-z]*?|-auto)$/i

export class Atom {
  constructor(private readonly options: Options) {
    this.propKey = options.propKey
    this.propValue = options.propValue

    this.key = options.key || this.propKey
    this.value = options.propValue || this.propValue

    this.style = options.style
    this.className = options.className || ''

    this.handled = this.getInitialHandled()
    this.isValid = this.getIsValid()

    this.inserted = false

    // shallow clone it
    this.meta = { ...options.meta } || {}

    const { propKey, propValue } = this

    this.id =
      typeof propValue === 'boolean' && propValue === true
        ? propKey
        : `${propKey}-${String(propValue).replace(/\s/g, '-')}`
  }

  /**
   * string or number prop
   * @readonly
   * @memberof Atom
   */
  get isValueProp(): boolean {
    return typeof this.propValue === 'string' || typeof this.propValue == 'number'
  }

  /**
   * get style keys string
   * @readonlyReactElement
   * @memberof Atom
   * @example
   * { color: "#999"} -> color
   * { paddingTop: 10, paddingBottom: 10} -> paddingTop-paddingTop
   */<commit_msg>feat(atom): handle id for array propValue<commit_after>import hash from 'string-hash'
import * as CSS from 'csstype'
import { Options, Meta } from './types'

const invalidProps = ['excludedProps']

export { Options, Meta }

/**
 * @example p2,mx4,left10,spaceX4...
 * @example p-20,opacity-80
 */
export const digitReg =
  /^([mp][xytrbl]?|space[xy]?|top|right|bottom|left|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex|leading|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border[trbl]?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?-?\d+[a-z]*?|-auto)$/i

export class Atom {
  constructor(private readonly options: Options) {
    this.propKey = options.propKey
    this.propValue = options.propValue

    this.key = options.key || this.propKey
    this.value = options.propValue || this.propValue

    this.style = options.style
    this.className = options.className || ''

    this.handled = this.getInitialHandled()
    this.isValid = this.getIsValid()

    this.inserted = false

    // shallow clone it
    this.meta = { ...options.meta } || {}

    const { propKey, propValue } = this

    let id: string
    if (typeof propValue === 'boolean' && propValue === true) {
      id = propKey
    } else if (Array.isArray(propValue)) {
      const valueStr = propValue.join('-')
      id = `${propKey}-${valueStr}`
    } else {
      id = `${propKey}-${String(propValue).replace(/\s/g, '-')}`
    }

    this.id = id
  }

  /**
   * string or number prop
   * @readonly
   * @memberof Atom
   */
  get isValueProp(): boolean {
    return typeof this.propValue === 'string' || typeof this.propValue == 'number'
  }

  /**
   * get style keys string
   * @readonlyReactElement
   * @memberof Atom
   * @example
   * { color: "#999"} -> color
   * { paddingTop: 10, paddingBottom: 10} -> paddingTop-paddingTop
   */
{'fraction_non_alphanumeric': 0.17139767504731007, 'fraction_numerical': 0.008650986753176534, 'mean_word_length': 3.6540880503144653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1176502', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1256, 'n_words': 231}