"use strict";

import React from 'react';
import { LastRoomMessageContainer, LastRoomMessageName, LastRoomMessageText } from './StyledRoomComponents';
import { decodeHTMLEntities } from '../../../helpers/parseMessageBody';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const getPlainText = body => {
  if (!body || typeof body !== 'string') {
    return 'Chat created';
  }
  let text = decodeHTMLEntities(body);
  text = text.replace(/^#{1,6}\s+/gm, '');
  text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
  text = text.replace(/__([^_]+)__/g, '$1');
  text = text.replace(/\*([^*]+)\*/g, '$1');
  text = text.replace(/_([^_]+)_/g, '$1');
  text = text.replace(/~~([^~]+)~~/g, '$1');
  text = text.replace(/`([^`]+)`/g, '$1');
  text = text.replace(/\[([^\]]+)\]\([^\)]+\)/g, '$1');
  text = text.replace(/^[\s]*[-*+]\s+/gm, '');
  text = text.replace(/^\s*\d+\.\s+/gm, '');
  text = text.replace(/\|/g, ' ');
  text = text.replace(/```[\s\S]*?```/g, '');
  text = text.replace(/<[^>]+>/g, '');
  text = text.replace(/\s+/g, ' ');
  text = text.replace(/\n/g, ' ').trim();
  return text || 'Chat created';
};
const LastTextMessage = ({
  user,
  body
}) => {
  const plainText = getPlainText(body);
  return /*#__PURE__*/_jsxs(LastRoomMessageContainer, {
    children: [/*#__PURE__*/_jsx(LastRoomMessageName, {
      numberOfLines: 1,
      ellipsizeMode: "tail",
      children: user?.name
    }), /*#__PURE__*/_jsx(LastRoomMessageText, {
      numberOfLines: 1,
      ellipsizeMode: "tail",
      children: plainText
    })]
  });
};
export default LastTextMessage;
//# sourceMappingURL=LastTextMessage.js.map