"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Favicon = void 0;
const react_1 = require("react");
const Avatar_1 = require("nice-ui/lib/1-inline/Avatar");
const Img_1 = require("../Img");
const util_1 = require("../../web/util");
const Favicon = (props) => {
    const { domain: _domain, url, size = 16, ...rest } = props;
    const domain = (0, react_1.useMemo)(() => _domain || (0, util_1.getDomain)(url || ''), [_domain, url]);
    if (!domain)
        return (0, react_1.createElement)(Avatar_1.Avatar, { name: url || domain, width: size, height: size, letters: 1 });
    return (0, react_1.createElement)(Img_1.Img, {
        ...rest,
        alt: domain + ' favicon',
        width: size,
        height: size,
        src: 'https://www.google.com/s2/favicons?domain=' + domain,
        renderError: () => (0, react_1.createElement)(Img_1.Img, {
            ...rest,
            alt: domain + ' favicon',
            width: size,
            height: size,
            src: 'https://' + domain + '/favicon.ico',
            renderError: () => (0, react_1.createElement)(Avatar_1.Avatar, { name: domain, width: size, height: size, letters: 1 }),
        }),
    });
};
exports.Favicon = Favicon;
//# sourceMappingURL=index.js.map