<commit_before>// since typeof breaks module.exports with this version of webpack
const checkType = o => Object.prototype.toString.call(o).replace(/\[|object\s|\]/g, '').toLowerCase()

module.exports = {
  Plater: function (data) {
    if (checkType(data) !== 'object') {
      return []
    }
    var func = []
    if (data.type === 'script' || data['11']) { // Plater script      
      func.push({ id: 'Script', name: 'Constructor', path: '12', lua: data['12'] })
      func.push({ id: 'Script', name: 'On Show', path: '12', lua: data['14'] })
      func.push({ id: 'Script', name: 'On Update', path: '12', lua: data['11'] })
      func.push({ id: 'Script', name: 'On Hide', path: '12', lua: data['13'] })
      func.push({ id: 'Script', name: 'Initialization', path: '12', lua: data['15'] })
      return func
    }
    else if (data.type === 'hook' || data['9']) { // Plater hook
      for (hook in data['9']) {
        func.push({ id: 'Script', name: hook, path: '[9]["' + hook + '"]', lua: data['9'][hook] })
      }
      return func
    }

    // --- old format
    else if (checkType(data[8]) === 'number') { // Plater script - fallback
      func.push({ id: 'Script', name: 'Constructor', path: 11, lua: data['12'] })
      func.push({ id: 'Script', name: 'On Show', path: 13, lua: data['14'] })
      func.push({ id: 'Script', name: 'On Update', path: 10, lua: data['11'] })
      func.push({ id: 'Script', name: 'On Hide', path: 12, lua: data['13'] })
      func.push({ id: 'Script', name: 'Initialization', path: 14, lua: data['15'] })
      return func
    }
    else if (checkType(data[8]) === 'object') { // Plater hook - fallback
      for (hook in data[8]) {
        func.push({ id: 'Script', name: hook, path: '[8]["' + hook + '"]', lua: data[8][hook] })
      }
      return func
    }

    return []
  },

  WeakAura: function (data) {
    if (!data.d) {
      return []
    }
    var auras = [data.d].concat(data.c || [])
    var func = []
    // loop through each aura in array and look for pre-defined custom functions
    auras.forEach((item, key) => {
      var ix
      if (key === 0) {
        ix = {index: 0, table: 'd'}
      }
      else {
        ix = {index: key - 1, table: 'c'}
      }
      // actions functions
      if (item.actions) {
        // onInit
        if (item.actions.init && item.actions.init.do_custom && item.actions.init.custom.trim()) {
          func.push(item.id)
          func.push({id: item.id, name: 'onInit', ix: ix, path: 'actions.init.custom', lua: item.actions.init.custom})
        }
        // onShow
        if (item.actions.start && item.actions.start.do_custom && item.actions.start.custom.trim()) {
          if (func.indexOf(item.id) < 0) {
            func.push(item.id)
          }
          func.push({id: item.id, name: 'onShow', ix: ix, path: 'actions.start.custom', lua: item.actions.start.custom})
        }
        // onHide
        if (item.actions.finish && item.actions.finish.do_custom && item.actions.finish.custom.trim()) {
          if (func.indexOf(item.id) < 0) {
            func.push(item.id)
          }
          func.push({id: item.id, name: 'onHide', ix: ix, path: 'actions.finish.custom', lua: item.actions.finish.custom})
        }
      }
      // display text
      if (((checkType(item.displayText) === 'string' && item.displayText.match(/%c/)) ||
      (checkType(item.text1) === 'string' && item.text1.match(/%c/)) ||
      (checkType(item.text2) === 'string' && item.text2.match(/%c/)) ||
      (checkType(item.displayTextLeft) === 'string' && item.displayTextLeft.match(/%c/)) ||
      (checkType(item.displayTextRight) === 'string' && item.displayTextRight.match(/%c/)) &&
      item.customText.trim())) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Text', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})
      }
      // display stacks
      else if (checkType(item.displayStacks) === 'string' && item.displayStacks.match(/%c/) > -1 && item.customText.trim().length) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})
      }
      if (item.grow === 'CUSTOM' && item.customGrow.trim().length) {
        func.push({ id: item.id, name: 'Custom Grow', ix: ix, path: 'customGrow', lua: item.customGrow})
      }
      if (item.sort === 'custom' && item.customSort.trim().length) {
        func.push({ id: item.id, name: 'Custom Sort', ix: ix, path: 'customSort', lua: item.customSort})
      }
      if (item.anchorPerUnit === 'CUSTOM' && item.customAnchorPerUnit.trim().length) {
        func.push({ id: item.id, name: 'Custom Anchor', ix: ix, path: 'customAnchorPerUnit', lua: item.customAnchorPerUnit})
      }
      if (checkType(item.customText) === 'string' && item.subRegions && item.subRegions.length && item.customText.trim().length) {
        for (let n = 0; n < item.subRegions.length; n++) {
          if (item.subRegions[n].text_text && item.subRegions[n].text_text.match(/%c/)) {
            func.push({ id: item.id, name: 'Custom Text', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})<commit_msg>update to code detection<commit_after>// since typeof breaks module.exports with this version of webpack
const checkType = o => Object.prototype.toString.call(o).replace(/\[|object\s|\]/g, '').toLowerCase()

module.exports = {
  Plater: function (data) {
    if (checkType(data) !== 'object') {
      return []
    }
    var func = []
    if (data.type === 'script' || data['11']) { // Plater script      
      func.push({ id: 'Script', name: 'Constructor', path: '12', lua: data['12'] })
      func.push({ id: 'Script', name: 'On Show', path: '12', lua: data['14'] })
      func.push({ id: 'Script', name: 'On Update', path: '12', lua: data['11'] })
      func.push({ id: 'Script', name: 'On Hide', path: '12', lua: data['13'] })
      func.push({ id: 'Script', name: 'Initialization', path: '12', lua: data['15'] })
      return func
    }
    else if (data.type === 'hook' || data['9']) { // Plater hook
      for (hook in data['9']) {
        func.push({ id: 'Script', name: hook, path: '[9]["' + hook + '"]', lua: data['9'][hook] })
      }
      return func
    }

    // --- old format
    else if (checkType(data[8]) === 'number') { // Plater script - fallback
      func.push({ id: 'Script', name: 'Constructor', path: 11, lua: data['12'] })
      func.push({ id: 'Script', name: 'On Show', path: 13, lua: data['14'] })
      func.push({ id: 'Script', name: 'On Update', path: 10, lua: data['11'] })
      func.push({ id: 'Script', name: 'On Hide', path: 12, lua: data['13'] })
      func.push({ id: 'Script', name: 'Initialization', path: 14, lua: data['15'] })
      return func
    }
    else if (checkType(data[8]) === 'object') { // Plater hook - fallback
      for (hook in data[8]) {
        func.push({ id: 'Script', name: hook, path: '[8]["' + hook + '"]', lua: data[8][hook] })
      }
      return func
    }

    return []
  },

  WeakAura: function (data) {
    if (!data.d) {
      return []
    }
    var auras = [data.d].concat(data.c || [])
    var func = []
    // loop through each aura in array and look for pre-defined custom functions
    auras.forEach((item, key) => {
      var ix
      if (key === 0) {
        ix = {index: 0, table: 'd'}
      }
      else {
        ix = {index: key - 1, table: 'c'}
      }
      // actions functions
      if (item.actions) {
        // onInit
        if (item.actions.init && item.actions.init.do_custom && item.actions.init.custom && item.actions.init.custom.trim()) {
          func.push(item.id)
          func.push({id: item.id, name: 'onInit', ix: ix, path: 'actions.init.custom', lua: item.actions.init.custom})
        }
        // onShow
        if (item.actions.start && item.actions.start.do_custom && item.actions.start.custom && item.actions.start.custom.trim()) {
          if (func.indexOf(item.id) < 0) {
            func.push(item.id)
          }
          func.push({id: item.id, name: 'onShow', ix: ix, path: 'actions.start.custom', lua: item.actions.start.custom})
        }
        // onHide
        if (item.actions.finish && item.actions.finish.do_custom && item.actions.finish.custom && item.actions.finish.custom.trim()) {
          if (func.indexOf(item.id) < 0) {
            func.push(item.id)
          }
          func.push({id: item.id, name: 'onHide', ix: ix, path: 'actions.finish.custom', lua: item.actions.finish.custom})
        }
      }
      // display text
      if (checkType(item.displayText) === 'string' && item.displayText.match(/%c/) && item.displayText.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Text', ix: ix, path: 'displayText', lua: item.displayText, displayEveryFrame: item.customTextUpdate})
      }
      else if (checkType(item.text1) === 'string' && item.text1.match(/%c/) && item.text1.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'text1', lua: item.text1, displayEveryFrame: item.customTextUpdate})
      }
      else if (checkType(item.text2) === 'string' && item.text2.match(/%c/) && item.text2.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'text2', lua: item.text2, displayEveryFrame: item.customTextUpdate})
      }
      else if (checkType(item.displayTextLeft) === 'string' && item.displayTextLeft.match(/%c/) && item.displayTextLeft.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'displayTextLeft', lua: item.displayTextLeft, displayEveryFrame: item.customTextUpdate})
      }
      else if (checkType(item.displayTextRight) === 'string' && item.displayTextRight.match(/%c/) && item.displayTextRight.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'displayTextRight', lua: item.displayTextRight, displayEveryFrame: item.customTextUpdate})
      }
      else if (checkType(item.customText) === 'string' && item.customText.match(/%c/) && item.customText.trim()) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})
      }
      // display stacks
      else if (checkType(item.displayStacks) === 'string' && item.displayStacks.match(/%c/) > -1 && item.displayStacks.trim().length) {
        if (func.indexOf(item.id) < 0) {
          func.push(item.id)
        }
        func.push({ id: item.id, name: 'Display Stacks', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})
      }

      if (item.grow === 'CUSTOM' && item.customGrow && item.customGrow.trim().length) {
        func.push({ id: item.id, name: 'Custom Grow', ix: ix, path: 'customGrow', lua: item.customGrow})
      }
      if (item.sort === 'custom' && item.customSort && item.customSort.trim().length) {
        func.push({ id: item.id, name: 'Custom Sort', ix: ix, path: 'customSort', lua: item.customSort})
      }
      if (item.anchorPerUnit === 'CUSTOM' && item.customAnchorPerUnit && item.customAnchorPerUnit.trim().length) {
        func.push({ id: item.id, name: 'Custom Anchor', ix: ix, path: 'customAnchorPerUnit', lua: item.customAnchorPerUnit})
      }
      if (checkType(item.customText) === 'string' && item.subRegions && item.subRegions.length && item.customText && item.customText.trim().length) {
        for (let n = 0; n < item.subRegions.length; n++) {
          if (item.subRegions[n].text_text && item.subRegions[n].text_text.match(/%c/)) {
            func.push({ id: item.id, name: 'Custom Text', ix: ix, path: 'customText', lua: item.customText, displayEveryFrame: item.customTextUpdate})
{'fraction_non_alphanumeric': 0.19278083522175463, 'fraction_numerical': 0.011249595338297183, 'mean_word_length': 2.6184480234260614, 'pattern_counts': {'":': 0, '<': 18, '<?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': '927567', 'n_tokens_mistral': 4265, 'n_tokens_neox': 4077, 'n_words': 975}