import * as React from 'react';
import { Iconista } from 'nice-ui/lib/icons/Iconista';
import { Sidetip } from 'nice-ui/lib/1-inline/Sidetip';
import { renderIcon } from './renderIcon';
import { View } from './View';
import { Edit } from './Edit';
import { getDomain } from '../../../../../web/util';
export const behavior = {
    menu: {
        name: 'Link',
        icon: () => React.createElement(Iconista, { width: 15, height: 15, set: "lucide", icon: "link" }),
        // icon: () => <Iconista width={15} height={15} set="radix" icon="link-2" />,
        right: () => React.createElement(Sidetip, { small: true }, "\u2318 K"),
        keys: ['⌘', 'k'],
    },
    validate: (formatting) => {
        const obj = formatting.conf()?.view();
        if (!obj || typeof obj !== 'object')
            return [{ code: 'INVALID_CONFIG' }];
        const href = obj.href || '';
        if (typeof href !== 'string')
            return [{ code: 'INVALID_URL' }];
        if (href.length < 4)
            return 'empty';
        const domain = getDomain(href);
        return domain ? 'good' : 'fine';
    },
    previewText: (formatting) => {
        const data = formatting.conf()?.view();
        if (!data || typeof data !== 'object')
            return '';
        return (data.href || '').replace(/^(https?:\/\/)?(www\.)?/, '');
    },
    renderIcon,
    Edit,
    View,
};
//# sourceMappingURL=behavior.js.map