<commit_before>import BungieImage from 'app/dim-ui/BungieImage';
import { craftingMaterialCountsSelector, materialsSelector } from 'app/inventory/selectors';
import { useD2Definitions } from 'app/manifest/selectors';
import { BucketHashes } from 'data/d2/generated-enums';
import spiderMats from 'data/d2/spider-mats.json';
import _ from 'lodash';
import React from 'react';
import { useSelector } from 'react-redux';
import styles from './MaterialCounts.m.scss';

const retiredMats = [31293053, 49145143, 1305274547, 2014411539];
const showMats = spiderMats.filter((m) => !retiredMats.includes(m));
const goodMats = [2979281381, 4257549984, 3853748946, 4257549985, 3702027555];
const seasonal = [747321467, 178490507];
const crafting = [2497395625, 353704689];

export function MaterialCounts() {
  const allMats = useSelector(materialsSelector);
  const craftingMaterialCounts = useSelector(craftingMaterialCountsSelector);
  const defs = useD2Definitions()!;
  const materials = _.groupBy(allMats, (m) => m.hash);
  const consumablesLabel = defs.InventoryBucket[BucketHashes.Consumables].displayProperties.name;

  return (
    <>
      {consumablesLabel}
      <hr />
      <div className={styles.materialCounts}>
        {[showMats, seasonal, goodMats, crafting].map((matgroup, i) => (
          <React.Fragment key={matgroup[0]}>
            {i > 0 && (
              <span className={styles.spanGrid}>
                <hr />
              </span>
            )}
            {/* tack on a special section when we hit the crafting mats group */}
            {matgroup.includes(353704689) && (
              <>
                {craftingMaterialCounts.map(([name, icon, count]) => (
                  <React.Fragment key={name}>
                    <span className={styles.amount}>{count.toLocaleString()}</span>
                    <BungieImage src={icon} />
                    <span>{name}</span>
                  </React.Fragment>
                ))}
              </>
            )}
            {matgroup.map((h) => {
              const items = materials[h];
              const amount = items.reduce((total, i) => total + i.amount, 0);
              const item = items[0];
              const materialName = item.name;
              const icon = item.icon;

              if (amount === undefined) {
                return null;<commit_msg>fix undefined error<commit_after>import BungieImage from 'app/dim-ui/BungieImage';
import { craftingMaterialCountsSelector, materialsSelector } from 'app/inventory/selectors';
import { useD2Definitions } from 'app/manifest/selectors';
import { BucketHashes } from 'data/d2/generated-enums';
import spiderMats from 'data/d2/spider-mats.json';
import _ from 'lodash';
import React from 'react';
import { useSelector } from 'react-redux';
import styles from './MaterialCounts.m.scss';

const retiredMats = [31293053, 49145143, 1305274547, 2014411539];
const showMats = spiderMats.filter((m) => !retiredMats.includes(m));
const goodMats = [2979281381, 4257549984, 3853748946, 4257549985, 3702027555];
const seasonal = [747321467, 178490507];
const crafting = [2497395625, 353704689];

export function MaterialCounts() {
  const allMats = useSelector(materialsSelector);
  const craftingMaterialCounts = useSelector(craftingMaterialCountsSelector);
  const defs = useD2Definitions()!;
  const materials = _.groupBy(allMats, (m) => m.hash);
  const consumablesLabel = defs.InventoryBucket[BucketHashes.Consumables].displayProperties.name;

  return (
    <>
      {consumablesLabel}
      <hr />
      <div className={styles.materialCounts}>
        {[showMats, seasonal, goodMats, crafting].map((matgroup, i) => (
          <React.Fragment key={matgroup[0]}>
            {i > 0 && (
              <span className={styles.spanGrid}>
                <hr />
              </span>
            )}
            {/* tack on a special section when we hit the crafting mats group */}
            {matgroup.includes(353704689) && (
              <>
                {craftingMaterialCounts.map(([name, icon, count]) => (
                  <React.Fragment key={name}>
                    <span className={styles.amount}>{count.toLocaleString()}</span>
                    <BungieImage src={icon} />
                    <span>{name}</span>
                  </React.Fragment>
                ))}
              </>
            )}
            {matgroup.map((h) => {
              const items = materials[h];
              if (!items) {
                return null;
              }
              const amount = items.reduce((total, i) => total + i.amount, 0);
              const item = items[0];
              const materialName = item.name;
              const icon = item.icon;

              if (amount === undefined) {
                return null;
{'fraction_non_alphanumeric': 0.1267517255804225, 'fraction_numerical': 0.05856515373352855, 'mean_word_length': 2.379505300353357, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 49, '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': '6256299', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1376, 'n_words': 301}