"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.AlternatesMetadata = AlternatesMetadata;
var _react = _interopRequireDefault(require("react"));
var _resolveUrl = require("../resolvers/resolve-url");
function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function AlternateLink({ descriptor , ...props }) {
    if (!descriptor.url) return null;
    return /*#__PURE__*/ _react.default.createElement("link", Object.assign({}, props, descriptor.title && {
        title: descriptor.title
    }, {
        href: (0, _resolveUrl).resolveStringUrl(descriptor.url)
    }));
}
function AlternatesMetadata({ alternates  }) {
    if (!alternates) return null;
    const { canonical , languages , media , types  } = alternates;
    return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, canonical ? /*#__PURE__*/ _react.default.createElement(AlternateLink, {
        rel: "canonical",
        descriptor: canonical
    }) : null, languages ? Object.entries(languages).map(([locale, descriptors])=>{
        return descriptors == null ? void 0 : descriptors.map((descriptor, index)=>/*#__PURE__*/ _react.default.createElement(AlternateLink, {
                rel: "alternate",
                key: index,
                hrefLang: locale,
                descriptor: descriptor
            }));
    }) : null, media ? Object.entries(media).map(([mediaName, descriptors])=>{
        return descriptors == null ? void 0 : descriptors.map((descriptor, index)=>/*#__PURE__*/ _react.default.createElement(AlternateLink, {
                rel: "alternate",
                key: index,
                media: mediaName,
                descriptor: descriptor
            }));
    }) : null, types ? Object.entries(types).map(([type, descriptors])=>{
        return descriptors == null ? void 0 : descriptors.map((descriptor, index)=>/*#__PURE__*/ _react.default.createElement(AlternateLink, {
                rel: "alternate",
                key: index,
                type: type,
                descriptor: descriptor
            }));
    }) : null);
}

//# sourceMappingURL=alternate.js.map