<commit_before>/* eslint-disable react/no-multi-comp */
import React from 'react'
import UsersIcon from 'part:@sanity/base/users-icon'
import styles from './GlobalStatus.css'
import PopoverList from './PopoverList'
import {MAX_AVATARS} from './constants'
import {splitRight} from './utils'
import StackCounter from './StackCounter'
import {GlobalPresence, Size} from './types'
import UserAvatar from './UserAvatar'
import {IntentLink} from 'part:@sanity/base/router'
import {PresenceListItem} from './PresenceListItem'

interface Props {
  projectId: string
  presence: GlobalPresence[]
}

type GlobalPresenceListItemProps = {
  presence: GlobalPresence
  size?: Size
  onClick?: () => void
}

function GlobalPresenceListItem(props: GlobalPresenceListItemProps) {
  const {presence, onClick, size} = props
  const documentId = presence.locations.map(location => location.documentId)
  const item = (
    <PresenceListItem user={presence.user} status={presence.status} onClick={onClick} size={size} />
  )
  return documentId ? (
    <IntentLink className={styles.intentLink} intent="edit" params={{id: documentId}}>
      {item}
    </IntentLink>
  ) : (
    item
  )
}

export function GlobalStatus({projectId, presence}: Props) {
  const [hiddenUsers, visibleUsers] = splitRight(presence, MAX_AVATARS)
  const showCounter = hiddenUsers.length >= MAX_AVATARS - 1 || presence.length === 0
  return (
    <div className={styles.root}>
      <PopoverList
        items={presence}
        renderItem={item => <GlobalPresenceListItem presence={item} />}
        isGlobal
        projectId={projectId}
        trigger="click"
      >
        <div className={styles.inner} tabIndex={-1}>
          {/* Only show this on mobile */}
          <div className={styles.mobileContent}>
            <div className={styles.icon}><commit_msg>[components] use medium sized avatars in popover<commit_after>/* eslint-disable react/no-multi-comp */
import React from 'react'
import UsersIcon from 'part:@sanity/base/users-icon'
import styles from './GlobalStatus.css'
import PopoverList from './PopoverList'
import {MAX_AVATARS} from './constants'
import {splitRight} from './utils'
import StackCounter from './StackCounter'
import {GlobalPresence, Size} from './types'
import UserAvatar from './UserAvatar'
import {IntentLink} from 'part:@sanity/base/router'
import {PresenceListItem} from './PresenceListItem'

interface Props {
  projectId: string
  presence: GlobalPresence[]
}

type GlobalPresenceListItemProps = {
  presence: GlobalPresence
  size?: Size
  onClick?: () => void
}

function GlobalPresenceListItem(props: GlobalPresenceListItemProps) {
  const {presence, onClick, size} = props
  const documentId = presence.locations.map(location => location.documentId)
  const item = (
    <PresenceListItem user={presence.user} status={presence.status} onClick={onClick} size={size} />
  )
  return documentId ? (
    <IntentLink className={styles.intentLink} intent="edit" params={{id: documentId}}>
      {item}
    </IntentLink>
  ) : (
    item
  )
}

export function GlobalStatus({projectId, presence}: Props) {
  const [hiddenUsers, visibleUsers] = splitRight(presence, MAX_AVATARS)
  const showCounter = hiddenUsers.length >= MAX_AVATARS - 1 || presence.length === 0
  return (
    <div className={styles.root}>
      <PopoverList
        items={presence}
        renderItem={item => <GlobalPresenceListItem presence={item} size="medium" />}
        isGlobal
        projectId={projectId}
        trigger="click"
      >
        <div className={styles.inner} tabIndex={-1}>
          {/* Only show this on mobile */}
          <div className={styles.mobileContent}>
            <div className={styles.icon}>
{'fraction_non_alphanumeric': 0.12773426951120712, 'fraction_numerical': 0.0016203078584931137, 'mean_word_length': 4.018970189701897, 'pattern_counts': {'":': 0, '<': 21, '<?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': '6644339', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1092, 'n_words': 268}