'use client';


const require_useEditorLocale = require('../@intlayer/editor-react/dist/esm/useEditorLocale.cjs');
const require_getContent = require('../@intlayer/core/dist/esm/interpreter/getContent/getContent.cjs');
const require_getMarkdownMetadata = require('../@intlayer/core/dist/esm/transpiler/markdown/getMarkdownMetadata.cjs');
const require_useEditedContentRenderer = require('../editor/useEditedContentRenderer.cjs');
const require_getContentNodeByKeyPath = require('../@intlayer/core/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.cjs');
const require_MarkdownProvider = require('./MarkdownProvider.cjs');

//#region ../react-intlayer/dist/esm/markdown/MarkdownRenderer.mjs
const MarkdownRenderer = ({ dictionaryKey, keyPath, children, locale }) => {
	const { renderMarkdown } = require_MarkdownProvider.useMarkdownContext();
	const editedContentContext = require_useEditedContentRenderer.useEditedContentRenderer({
		dictionaryKey,
		keyPath,
		children
	});
	if (typeof editedContentContext !== "string") {
		const transformedEditedContent = require_getContent.getContent(editedContentContext, {
			dictionaryKey,
			keyPath
		}, locale);
		if (typeof transformedEditedContent !== "string") {
			console.error(`Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`);
			return renderMarkdown(children);
		}
		return renderMarkdown(transformedEditedContent);
	}
	return renderMarkdown(editedContentContext);
};
const MarkdownMetadataRenderer = ({ dictionaryKey, keyPath, children, metadataKeyPath }) => {
	const editedContentContext = require_useEditedContentRenderer.useEditedContentRenderer({
		dictionaryKey,
		keyPath,
		children
	});
	const currentLocale = require_useEditorLocale.useEditorLocale();
	return require_getContentNodeByKeyPath.getContentNodeByKeyPath(require_getMarkdownMetadata.getMarkdownMetadata(editedContentContext), metadataKeyPath, currentLocale);
};

//#endregion
exports.MarkdownMetadataRenderer = MarkdownMetadataRenderer;
exports.MarkdownRenderer = MarkdownRenderer;
//# sourceMappingURL=MarkdownRenderer.cjs.map