<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import TimeWithTooltip from 'components/time-with-tooltip';
import { observer } from 'mobx-react';
import Notification from 'models/notification';
import { NotificationContext } from 'notifications-context';
import NotificationDeleteButton from 'notifications/notification-delete-button';
import NotificationReadButton from 'notifications/notification-read-button';
import * as React from 'react';
import { classWithModifiers, mergeModifiers } from 'utils/css';

interface Props {
  canMarkAsRead?: boolean;
  delete?: () => void;
  expandButton?: React.ReactNode;
  icons?: string[];
  isDeleting?: boolean;
  isMarkingAsRead?: boolean;
  item: Notification;
  markRead?: () => void;
  message: string;
  modifiers: string[];
  url?: string;
  withCategory: boolean;
  withCoverImage: boolean;
}

@observer
export default class Item extends React.Component<Props> {
  static contextType = NotificationContext;
  declare context: React.ContextType<typeof NotificationContext>;

  private get canMarkAsRead() {
    return this.props.canMarkAsRead ?? this.props.item.canMarkRead;
  }

  render() {
    return (
      <div className={this.blockClass()}>
        <a className='notification-popup-item__link' href={this.props.url} onClick={this.props.markRead} />
        {this.renderCover()}
        <div className='notification-popup-item__main'>
          <div className='notification-popup-item__content'>
            {this.renderCategory()}
            {this.renderMessage()}
            {this.renderTime()}
            {this.renderExpandButton()}
          </div>
          {this.renderMarkAsReadButton()}
          {this.renderDeleteButton()}
        </div>
        {this.renderUnreadStripe()}
      </div>
    );
  }

  private blockClass() {
    const modifiers = mergeModifiers(
      this.props.modifiers,
      this.props.item.category,
      { read: this.props.item.isRead && !this.props.canMarkAsRead },
    );

    return classWithModifiers('notification-popup-item', modifiers);
  }

  private renderCategory() {
    if (!this.props.withCategory) {
      return null;
    }

    const label = osu.trans(`notifications.item.${this.props.item.displayType}.${this.props.item.category}._`);<commit_msg>helper method not doing much<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import TimeWithTooltip from 'components/time-with-tooltip';
import { observer } from 'mobx-react';
import Notification from 'models/notification';
import { NotificationContext } from 'notifications-context';
import NotificationDeleteButton from 'notifications/notification-delete-button';
import NotificationReadButton from 'notifications/notification-read-button';
import * as React from 'react';
import { classWithModifiers, mergeModifiers } from 'utils/css';

interface Props {
  canMarkAsRead?: boolean;
  delete?: () => void;
  expandButton?: React.ReactNode;
  icons?: string[];
  isDeleting?: boolean;
  isMarkingAsRead?: boolean;
  item: Notification;
  markRead?: () => void;
  message: string;
  modifiers: string[];
  url?: string;
  withCategory: boolean;
  withCoverImage: boolean;
}

@observer
export default class Item extends React.Component<Props> {
  static contextType = NotificationContext;
  declare context: React.ContextType<typeof NotificationContext>;

  private get canMarkAsRead() {
    return this.props.canMarkAsRead ?? this.props.item.canMarkRead;
  }

  render() {
    const modifiers = mergeModifiers(
      this.props.modifiers,
      this.props.item.category,
      { read: this.props.item.isRead && !this.props.canMarkAsRead },
    );

    return (
      <div className={classWithModifiers('notification-popup-item', modifiers)}>
        <a className='notification-popup-item__link' href={this.props.url} onClick={this.props.markRead} />
        {this.renderCover()}
        <div className='notification-popup-item__main'>
          <div className='notification-popup-item__content'>
            {this.renderCategory()}
            {this.renderMessage()}
            {this.renderTime()}
            {this.renderExpandButton()}
          </div>
          {this.renderMarkAsReadButton()}
          {this.renderDeleteButton()}
        </div>
        {this.renderUnreadStripe()}
      </div>
    );
  }

  private renderCategory() {
    if (!this.props.withCategory) {
      return null;
    }

    const label = osu.trans(`notifications.item.${this.props.item.displayType}.${this.props.item.category}._`);
{'fraction_non_alphanumeric': 0.12481551760489142, 'fraction_numerical': 0.000843348091924942, 'mean_word_length': 3.6192794547224927, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, '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': '6953927', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1348, 'n_words': 309}