"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CNTRLHead = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const html_react_parser_1 = __importDefault(require("html-react-parser"));
const head_1 = __importDefault(require("next/head"));
const sdk_1 = require("@cntrl-site/sdk");
const CNTRLHead = ({ meta, project }) => {
    const googleFonts = (0, html_react_parser_1.default)(project.fonts.google);
    const adobeFonts = (0, html_react_parser_1.default)(project.fonts.adobe);
    const parsedFonts = Object.assign(Object.assign({}, (typeof googleFonts === 'object' ? googleFonts : {})), (typeof adobeFonts === 'object' ? adobeFonts : {}));
    const customFonts = project.fonts.custom;
    const htmlHead = (0, html_react_parser_1.default)(project.html.head);
    const ffGenerator = new sdk_1.FontFaceGenerator(customFonts);
    const links = Object.values(parsedFonts).map((value) => {
        var _a, _b;
        if (!value)
            return;
        const rel = (value === null || value === void 0 ? void 0 : value.rel) || ((_a = value.props) === null || _a === void 0 ? void 0 : _a.rel);
        const href = (value === null || value === void 0 ? void 0 : value.href) || ((_b = value.props) === null || _b === void 0 ? void 0 : _b.href);
        if (!rel || !href)
            return;
        return ((0, jsx_runtime_1.jsx)("link", { rel: rel, href: href }, `link-${rel}-${href}`));
    });
    return ((0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: meta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: meta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: meta.keywords }), (0, jsx_runtime_1.jsx)("meta", { name: "og:image", content: meta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("meta", { name: "generator", content: "https://cntrl.site" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: meta.favicon }), customFonts.length > 0 && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: {
                    __html: ffGenerator.generate()
                } })), links, htmlHead] }));
};
exports.CNTRLHead = CNTRLHead;
