"use client";
import { jsx } from "react/jsx-runtime";
import { ReactExtension } from "@lexical/react/ReactExtension";
import { configExtension, defineExtension } from "lexical";
import { AutoLinkPlugin, createLinkMatcherWithRegExp } from "./auto-link-plugin.js";
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
const MATCHERS = [
    createLinkMatcherWithRegExp(URL_REGEX, (text)=>text.startsWith('http') ? text : `https://${text}`),
    createLinkMatcherWithRegExp(EMAIL_REGEX, (text)=>`mailto:${text}`)
];
function auto_link_extension_AutoLinkPlugin() {
    return /*#__PURE__*/ jsx(AutoLinkPlugin, {
        matchers: MATCHERS
    });
}
const AutoLinkExtension = defineExtension({
    name: '@byline/richtext-lexical/AutoLink',
    dependencies: [
        configExtension(ReactExtension, {
            decorators: [
                /*#__PURE__*/ jsx(auto_link_extension_AutoLinkPlugin, {}, "d")
            ]
        })
    ]
});
export { AutoLinkExtension, auto_link_extension_AutoLinkPlugin as AutoLinkPlugin };
