import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import PaymentIcon from './Icons';
import { Tooltip } from '@mui/material';
import { fiatMethods, swapMethods } from './MethodList';
const ns = [{ name: 'not specified', icon: 'notspecified' }];
const methods = ns.concat(swapMethods).concat(fiatMethods);
interface Props {
othersText: string;
verbose: boolean;
size: number;
text: string;
}
const StringAsIcons: React.FC = ({ othersText, verbose, size, text = '' }: Props) => {
const { t } = useTranslation();
const parsedText = useMemo(() => {
const rows = [];
let customMethods = text.replace(
/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,
'',
); // Remove emojis
// Adds icons for each PaymentMethod that matches
methods.forEach((method, i) => {
const regex = new RegExp(`\\b${method.name}\\b`, 'g');
if (regex.test(customMethods)) {
customMethods = customMethods.replace(regex, '');
rows.push(