function isArray(obj) {
  return !!obj && obj.constructor === Array
}

const checkLanguage = (item, language) =>
  language.size === 0 || language.includes(item.language) || (item.translations && item.translations.some((translation) => language.includes(translation.language)))

export function getFilteredItems(items, filters) {
  return items.filter((item) => {
    const [...filterNames] = filters.keys()
    return filterNames.every((filterName) => {
      if (filterName === 'language') {
        return checkLanguage(item, filters.get('language'))
      } else if (filters.get(filterName).size === 0 || filters.get(filterName) === '') {
        return true
      } else if (typeof item[filterName] === 'string' || typeof item[filterName] === 'number') {
        return item[filterName] === filters.get(filterName) || filters.get(filterName).includes(item[filterName])
      } else if (isArray(item[filterName]) && item[filterName].length) {
        return item[filterName].some((keyItems) => filters.get(filterName).includes(keyItems))
      }
      return false
    })
  })
}
/*
export function getFilteredItems2(items, filters) {
  return items.filter((e) =>
    filters.map((value, key) => {
      console.log('valor ' + e[key])
      console.log('value '+ value)
      console.log('key '+ key)
      if (typeof e[key] === 'string') {
        return e[key] === value
      } else if (isArray(e[key])) {
        return e[key].includes(value)
      }
      return false
    })
  )
}
*/

@@ -1080,414 +1080,5 @@
 )%0A%7D%0A
-/*%0Aexport function getFilteredItems2(items, filters) %7B%0A  return items.filter((e) =%3E%0A    filters.map((value, key) =%3E %7B%0A      console.log('valor ' + e%5Bkey%5D)%0A      console.log('value '+ value)%0A      console.log('key '+ key)%0A      if (typeof e%5Bkey%5D === 'string') %7B%0A        return e%5Bkey%5D === value%0A      %7D else if (isArray(e%5Bkey%5D)) %7B%0A        return e%5Bkey%5D.includes(value)%0A      %7D%0A      return false%0A    %7D)%0A  )%0A%7D%0A*/
 %0A

remove comment code