<commit_before>import {
    Box,
    Col,

    Icon, Row,
    Text
} from '@tlon/indigo-react';
import React from 'react';
import { Link } from 'react-router-dom';
import { uxToHex } from '~/logic/lib/util';
import { getTitleFromWorkspace } from '~/logic/lib/workspace';
import useMetadataState from '~/logic/state/metadata';
import { Workspace } from '~/types/workspace';
import { Dropdown } from '~/views/components/Dropdown';
import { MetadataIcon } from './MetadataIcon';

const GroupSwitcherItem = ({ to, children, bottom = false, ...rest }) => (
  <Link to={to}>
    <Box
      py={1}
      {...rest}
      borderBottom={bottom ? 0 : 1}
      borderBottomColor="lightGray"
    >
      <Row p={2} alignItems="center">
        {children}
      </Row>
    </Box>
  </Link>
);

function RecentGroups(props: { recent: string[] }) {
  const { recent } = props;
  if (recent.length < 2) {
    return null;
  }
  const associations = useMetadataState(state => state.associations);

  return (
    <Col borderBottom={1} borderBottomColor="lightGray" p={1}>
      <Box fontSize={0} px={1} py={2} color="gray">
        Recent Groups
      </Box>
      {props.recent.filter((e) => {
        return (e in associations?.groups);
      }).slice(0, 4).map((g) => {
        const assoc = associations.groups[g];
        const color = uxToHex(assoc?.metadata?.color || '0x0');
        return (
          <Link key={g} style={{ minWidth: 0 }} to={`/~landscape${g}`}>
          <Row px={1} pb={2} alignItems="center">
            <Box
              borderRadius={1}
              border={1}
              borderColor="lightGray"
              height="16px"
              width="16px"
              bg={`#${color}`}
              mr={2}
              display="block"
              flexShrink={0}
            />
              <Text verticalAlign='top' maxWidth='100%' overflow='hidden' display='inline-block' style={{ textOverflow: 'ellipsis', whiteSpace: 'pre' }}>{assoc?.metadata?.title}</Text>
            </Row>
          </Link>
        );
      })}
    </Col>
  );
}

export function GroupSwitcher(props: {
  workspace: Workspace;
  baseUrl: string;
  recentGroups: string[];
  isAdmin: any;
}) {
  const { workspace, isAdmin } = props;
  const associations = useMetadataState(state => state.associations);
  const title = getTitleFromWorkspace(associations, workspace);
  const metadata = (workspace.type === 'home' || workspace.type  === 'messages')
    ? undefined
    : associations.groups[workspace.group].metadata;
  const navTo = (to: string) => `${props.baseUrl}${to}`;
  return (
    <Row
      width="100%"
      alignItems="center"
      flexShrink={0}
      height='48px'
      backgroundColor="white"
      position="sticky"
      top="0px"
      pl={3}
      borderBottom='1px solid'
      borderColor='lightGray'
    >
      <Col
        bg="white"
        width="100%"
        height="100%"
      >
        <Row flexGrow={1} alignItems="center" justifyContent="space-between">
          <Dropdown
            width="auto"
            dropWidth="231px"
            alignY="top"
            options={
              <Col
                borderRadius={1}
                border={1}
                borderColor="lightGray"
                bg="white"
                width="100%"
                alignItems="stretch"
              >
                {(props.baseUrl === '/~landscape/home') ?
                  <GroupSwitcherItem to="">
                  <Icon
                    mr={2}
                    color="gray"
                    display="block"
                    icon="Groups"
                  />
                  <Text>All Groups</Text>
                </GroupSwitcherItem>
                :
                <GroupSwitcherItem to="/~landscape/home">
                  <Icon
                    mr={2}
                    color="gray"
                    display="block"
                    icon="Home"
                  />
                  <Text>My Channels</Text>
                </GroupSwitcherItem>}
                <RecentGroups
                  recent={props.recentGroups}
                />
                <GroupSwitcherItem to="/~landscape/new">
                  <Icon mr={2} color="gray" icon="CreateGroup" />
                  <Text> New Group</Text>
                </GroupSwitcherItem>
                <GroupSwitcherItem to="/~landscape/join">
                  <Icon mr={2} color="gray" icon="Plus" />
                  <Text> Join Group</Text>
                </GroupSwitcherItem>
                {workspace.type === 'group' && (
                  <>
                    <GroupSwitcherItem to={navTo('/popover/participants')}>
                      <Icon<commit_msg>interface: remove My Channels link from GroupSwitcher<commit_after>import {
    Box,
    Col,

    Icon, Row,
    Text
} from '@tlon/indigo-react';
import React from 'react';
import { Link } from 'react-router-dom';
import { uxToHex } from '~/logic/lib/util';
import { getTitleFromWorkspace } from '~/logic/lib/workspace';
import useMetadataState from '~/logic/state/metadata';
import { Workspace } from '~/types/workspace';
import { Dropdown } from '~/views/components/Dropdown';
import { MetadataIcon } from './MetadataIcon';

const GroupSwitcherItem = ({ to, children, bottom = false, ...rest }) => (
  <Link to={to}>
    <Box
      py={1}
      {...rest}
      borderBottom={bottom ? 0 : 1}
      borderBottomColor="lightGray"
    >
      <Row p={2} alignItems="center">
        {children}
      </Row>
    </Box>
  </Link>
);

function RecentGroups(props: { recent: string[] }) {
  const { recent } = props;
  if (recent.length < 2) {
    return null;
  }
  const associations = useMetadataState(state => state.associations);

  return (
    <Col borderBottom={1} borderBottomColor="lightGray" p={1}>
      <Box fontSize={0} px={1} py={2} color="gray">
        Recent Groups
      </Box>
      {props.recent.filter((e) => {
        return (e in associations?.groups);
      }).slice(0, 4).map((g) => {
        const assoc = associations.groups[g];
        const color = uxToHex(assoc?.metadata?.color || '0x0');
        return (
          <Link key={g} style={{ minWidth: 0 }} to={`/~landscape${g}`}>
          <Row px={1} pb={2} alignItems="center">
            <Box
              borderRadius={1}
              border={1}
              borderColor="lightGray"
              height="16px"
              width="16px"
              bg={`#${color}`}
              mr={2}
              display="block"
              flexShrink={0}
            />
              <Text verticalAlign='top' maxWidth='100%' overflow='hidden' display='inline-block' style={{ textOverflow: 'ellipsis', whiteSpace: 'pre' }}>{assoc?.metadata?.title}</Text>
            </Row>
          </Link>
        );
      })}
    </Col>
  );
}

export function GroupSwitcher(props: {
  workspace: Workspace;
  baseUrl: string;
  recentGroups: string[];
  isAdmin: any;
}) {
  const { workspace, isAdmin } = props;
  const associations = useMetadataState(state => state.associations);
  const title = getTitleFromWorkspace(associations, workspace);
  const metadata = (workspace.type === 'home' || workspace.type  === 'messages')
    ? undefined
    : associations.groups[workspace.group].metadata;
  const navTo = (to: string) => `${props.baseUrl}${to}`;
  return (
    <Row
      width="100%"
      alignItems="center"
      flexShrink={0}
      height='48px'
      backgroundColor="white"
      position="sticky"
      top="0px"
      pl={3}
      borderBottom='1px solid'
      borderColor='lightGray'
    >
      <Col
        bg="white"
        width="100%"
        height="100%"
      >
        <Row flexGrow={1} alignItems="center" justifyContent="space-between">
          <Dropdown
            width="auto"
            dropWidth="231px"
            alignY="top"
            options={
              <Col
                borderRadius={1}
                border={1}
                borderColor="lightGray"
                bg="white"
                width="100%"
                alignItems="stretch"
              >
                  <GroupSwitcherItem to="">
                  <Icon
                    mr={2}
                    color="gray"
                    display="block"
                    icon="Groups"
                  />
                  <Text>All Groups</Text>
                </GroupSwitcherItem>
                <RecentGroups
                  recent={props.recentGroups}
                />
                <GroupSwitcherItem to="/~landscape/new">
                  <Icon mr={2} color="gray" icon="CreateGroup" />
                  <Text> New Group</Text>
                </GroupSwitcherItem>
                <GroupSwitcherItem to="/~landscape/join">
                  <Icon mr={2} color="gray" icon="Plus" />
                  <Text> Join Group</Text>
                </GroupSwitcherItem>
                {workspace.type === 'group' && (
                  <>
                    <GroupSwitcherItem to={navTo('/popover/participants')}>
                      <Icon
{'fraction_non_alphanumeric': 0.14599911582670203, 'fraction_numerical': 0.01226790450928382, 'mean_word_length': 1.73136130395412, 'pattern_counts': {'":': 0, '<': 92, '<?xml version=': 0, '>': 98, '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': '3314408', 'n_tokens_mistral': 2695, 'n_tokens_neox': 2564, 'n_words': 511}