"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.parseLinks = void 0;
var _ui = require("@mirai/ui");
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const URL_REGEX = /(https?:\/\/[^\s]+)/g;
const parseLinks = text => {
  if (!text) return text;
  const parts = text.split(URL_REGEX);

  // If no URLs found, return original text
  if (parts.length === 1) return text;
  return parts.map((part, index) => {
    if (URL_REGEX.test(part)) {
      // Remove trailing punctuation from URL
      const cleanUrl = part.replace(/[.,!?;:]$/, '');
      return /*#__PURE__*/_react.default.createElement(_ui.Action, {
        key: index,
        href: cleanUrl,
        paragraph: true,
        rel: "noopener noreferrer",
        target: "_blank",
        underline: true
      }, cleanUrl);
    }
    return part;
  });
};
exports.parseLinks = parseLinks;
//# sourceMappingURL=parseLinks.js.map