/**
 * @public
 */
export var TextFormatters;
(function (TextFormatters) {
    /**
     * This function does not apply any formatting to the text.
     *
     * @public
     */
    TextFormatters.DEFAULT = (value) => value;
    /**
     * This function formats text to HTML by replacing common text formatting patterns with their HTML equivalents.
     * It supports:
     * - Italics: _value_
     * - Bold: *value*
     * - Strikethrough: ~value~
     * - Monospace: ```value```
     * - URLs: Converts HTTP/HTTPS/FTP links to clickable links
     * - Phone numbers: Converts phone numbers to tel: links
     * - Emails: Converts email addresses to mailto: links
     * - New lines to '\<br/>'
     *
     * @public
     */
    TextFormatters.RICHTEXT = (value) => value
        // Italics: _value_
        .replace(/_(\S(.*?\S)?)_/gm, '<em>$1</em>')
        // Bold: *value*
        .replace(/\*(\S(.*?\S)?)\*/gm, '<strong>$1</strong>')
        // Strikethrough: ~value~
        .replace(/\~(\S(.*?\S)?)\~/gm, '<del>$1</del>')
        // Monospace: ```value```
        .replace(/\```(\S(.*?\S)?)\```/gm, '<code>$1</code>')
        // // urls =  // http://, https://, ftp://
        // .replace(/\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim, x => `<a href="${x}">${x}</a>`)
        // // url // www. sans http:// or https://
        // .replace(/(^|[^\/])(www\.[\S]+(\b|$))/gim, x => `<a href="http://${x}">${x}</a>`)
        // URLs: Convert HTTP/HTTPS/FTP links to clickable links
        .replace(/\b((?:https?|ftp):\/\/\S*[\w\/])\b/gim, '<a href="$1">$1</a>')
        // // phone
        // .replace(/\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}/g, x => `<a href="tel:${x}">${x}</a>`)
        // Phone numbers: Convert phone numbers to tel: links (this is a simplistic pattern)
        .replace(/(\+?\d[\d\s\-]{8,}\d)/g, '<a href="tel:$1">$1</a>')
        // // email addresses
        // .replace(/[\w.]+@[a-zA-Z_-]+?(?:\.[a-zA-Z]{2,6})+/gim, x => `<a href="mailto:${x}">${x}</a>`)
        // Emails: Convert email addresses to mailto: links
        .replace(/(\w+@\w+\.\w+)/gim, '<a href="mailto:$1">$1</a>')
        // // new line
        // .replace(/(?:\r\n|\r|\n)/g, '<br>');
        // New line to <br>
        .replace(/\n/g, '<br>');
    /**
     * This function formats text to HTML using a simplified Markdown syntax.
     * It supports:
     * - Bold: **value** or __value__
     * - Italic: *value* or _value_
     * - Strikethrough: ~~value~~
     * - Code: `value`
     * - Image with specified width and height: ![alt text](http://example.com/image.jpg =100x20)
     * - Image with only width specified: ![alt text](http://example.com/image.jpg =250x)
     * - Image with only height specified: ![alt text](http://example.com/image.jpg =x250)
     * - Image: ![alt text](http://example.com/image.jpg)
     * - URLs: [example](http://example.com)
     * - Email: <example@example.com>
     * * - List: * item (unordered list) or 1. item (ordered list)
     * - Blockquote: > value
     * - Header: # Header 1 through ###### Header 6
     * - New lines to <br>
     * @public
     */
    TextFormatters.MARKDOWN = (value) => value
        // Bold: **value** or __value__
        .replace(/\*\*([\s\S]*?)\*\*/g, '<strong>$1</strong>')
        .replace(/__([\s\S]*?)__/g, '<strong>$1</strong>')
        // Italic: *value* or _value_
        .replace(/\*([\s\S]*?)\*/g, '<em>$1</em>')
        .replace(/_([\s\S]*?)_/g, '<em>$1</em>')
        // Strikethrough: ~~value~~
        .replace(/~~([\s\S]*?)~~/g, '<del>$1</del>')
        // Code: `value`
        .replace(/`([\s\S]*?)`/g, '<code>$1</code>')
        // Image with specified width and height: ![alt text](http://example.com/image.jpg =100x20)
        .replace(/!\[([\s\S]*?)\]\((http[s]?:\/\/.*?)\s*=\s*(\d*)x(\d*)\)/g, '<img src="$2" alt="$1" width="$3" height="$4" />')
        // Image with only width specified: ![alt text](http://example.com/image.jpg =250x)
        .replace(/!\[([\s\S]*?)\]\((http[s]?:\/\/.*?)\s*=\s*(\d*)x\)/g, '<img src="$2" alt="$1" width="$3" />')
        // Image with only height specified: ![alt text](http://example.com/image.jpg =x250)
        .replace(/!\[([\s\S]*?)\]\((http[s]?:\/\/.*?)\s*=x(\d*)\)/g, '<img src="$2" alt="$1" height="$3" />')
        // Image: ![alt text](http://example.com/image.jpg)
        .replace(/!\[([\s\S]*?)\]\((http[s]?:\/\/.*?)\)/g, '<img src="$2" alt="$1" />')
        // URLs: [example](http://example.com)
        .replace(/\[([\s\S]*?)\]\((http[s]?:\/\/.*?)\)/g, '<a href="$2">$1</a>')
        // Email: <example@example.com>
        .replace(/<([\w\.-]+@[\w\.-]+\.\w+)>/g, '<a href="mailto:$1">$1</a>')
        // List: * item (unordered list) or 1. item (ordered list)
        .replace(/(?:^\* (.*?)$)+/gm, (match) => `<ul>${match.replace(/^\* (.*?)$/gm, '<li>$1</li>')}</ul>`)
        .replace(/(?:^\d+\. (.*?)$)+/gm, (match) => `<ol>${match.replace(/^\d+\. (.*?)$/gm, '<li>$1</li>')}</ol>`)
        // Blockquote: > value
        .replace(/^> (.*$)/gm, '<blockquote>$1</blockquote>')
        // Header: # Header 1 through ###### Header 6
        .replace(/^# (.*$)/gm, '<h1>$1</h1>')
        .replace(/^## (.*$)/gm, '<h2>$1</h2>')
        .replace(/^### (.*$)/gm, '<h3>$1</h3>')
        .replace(/^#### (.*$)/gm, '<h4>$1</h4>')
        .replace(/^##### (.*$)/gm, '<h5>$1</h5>')
        .replace(/^###### (.*$)/gm, '<h6>$1</h6>')
        // Replace new lines with line breaks
        .replace(/(?:\r\n|\r|\n)/g, '<br>');
    /**
     * This function looks for BBCode tags such as
     * [b], [i], [u], [s], [code], [url], [img], [email], [color], [size], [list], [quote], and [*] for list items,
     * and replaces them with their HTML equivalents. It also handles conversion of new lines to HTML <br> tags.
     *
     * @public
     */
    TextFormatters.BBCODE = (value) => value
        // Bold: [b]value[/b]
        .replace(/\[b\]([\s\S]*?)\[\/b\]/gi, '<strong>$1</strong>')
        // Italics: [i]value[/i]
        .replace(/\[i\]([\s\S]*?)\[\/i\]/gi, '<em>$1</em>')
        // Underline: [u]value[/u]
        .replace(/\[u\]([\s\S]*?)\[\/u\]/gi, '<u>$1</u>')
        // Strikethrough: [s]value[/s]
        .replace(/\[s\]([\s\S]*?)\[\/s\]/gi, '<del>$1</del>')
        // Monospace/code: [code]value[/code]
        .replace(/\[code\]([\s\S]*?)\[\/code\]/gi, '<code>$1</code>')
        // URLs: [url=http://example.com]example[/url] or [url]http://example.com[/url]
        .replace(/\[url=(.*?)\](.*?)\[\/url\]/gi, '<a href="$1">$2</a>')
        .replace(/\[url\]([\s\S]*?)\[\/url\]/gi, '<a href="$1">$1</a>')
        // Image with specified width and height: [img width=100 height=20]http://example.com/image.jpg[/img]
        .replace(/\[img width=(\d*) height=(\d*)\](http[s]?:\/\/.*?)\[\/img\]/gi, '<img src="$3" width="$1" height="$2" />')
        // Image with only width specified: [img width=250]http://example.com/image.jpg[/img]
        .replace(/\[img width=(\d*)\](http[s]?:\/\/.*?)\[\/img\]/gi, '<img src="$2" width="$1" />')
        // Image with only height specified: [img height=250]http://example.com/image.jpg[/img]
        .replace(/\[img height=(\d*)\](http[s]?:\/\/.*?)\[\/img\]/gi, '<img src="$2" height="$1" />')
        // Images: [img]http://example.com/image.jpg[/img]
        .replace(/\[img\]([\s\S]*?)\[\/img\]/gi, '<img src="$1" alt=""/>')
        // Email: [email]example@example.com[/email]
        .replace(/\[email\]([\s\S]*?)\[\/email\]/gi, '<a href="mailto:$1">$1</a>')
        // Color: [color=red]value[/color]
        .replace(/\[color=(.*?)\](.*?)\[\/color\]/gi, '<span style="color:$1;">$2</span>')
        // Size: [size=3]value[/size] (The size value is assumed to be a multiplier for a base font size)
        .replace(/\[size=(.*?)\](.*?)\[\/size\]/gi, '<span style="font-size:$1em;">$2</span>')
        // Lists: [list][*]item[*]item[/list] or [list=1][*]item[*]item[/list]
        .replace(/\[list\]([\s\S]*?)\[\/list\]/gi, '<ul>$1</ul>')
        .replace(/\[list=1\]([\s\S]*?)\[\/list\]/gi, '<ol>$1</ol>')
        .replace(/\[\*\](.*?)\[\/\*\]/gi, '<li>$1</li>')
        // Quote: [quote]value[/quote]
        .replace(/\[quote\]([\s\S]*?)\[\/quote\]/gi, '<blockquote>$1</blockquote>')
        // Replace new lines with line breaks
        .replace(/(?:\r\n|\r|\n)/g, '<br>');
})(TextFormatters || (TextFormatters = {}));
//# sourceMappingURL=TextFormatter.js.map