import { findAndReplace } from "mdast-util-find-and-replace";
import { decode } from "nostr-tools/nip19";
import { Tokens } from "../helpers/regexp.js";
export function remarkNostrMentions() {
    return (tree) => {
        findAndReplace(tree, [
            Tokens.nostrLink,
            (_, $1) => {
                try {
                    return {
                        type: "link",
                        data: decode($1),
                        children: [],
                        url: "nostr:" + $1,
                    };
                }
                catch (error) { }
                return false;
            },
        ]);
    };
}
