const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
const require_IntlayerNode = require('./IntlayerNode.cjs');
const require_getMarkdownMetadata = require('./@intlayer/core/dist/esm/transpiler/markdown/getMarkdownMetadata.cjs');
const require_nodeType = require('./@intlayer/types/dist/esm/nodeType.cjs');
const require_ContentSelectorWrapper = require('./editor/ContentSelectorWrapper.cjs');
const require_useEditedContentRenderer = require('./editor/useEditedContentRenderer.cjs');
const require_MarkdownRenderer = require('./markdown/MarkdownRenderer.cjs');
const require_renderReactElement = require('./reactElement/renderReactElement.cjs');
let react_jsx_runtime = require("react/jsx-runtime");

//#region ../react-intlayer/dist/esm/plugins.mjs
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
const intlayerNodePlugins = {
	id: "intlayer-node-plugin",
	canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
	transform: (_node, { plugins,...rest }) => require_IntlayerNode.renderIntlayerNode({
		...rest,
		value: rest.children,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_useEditedContentRenderer.EditedContentRenderer, {
			...rest,
			children: rest.children
		})
	})
};
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
const reactNodePlugins = {
	id: "react-node-plugin",
	canHandle: (node) => typeof node === "object" && typeof node?.props !== "undefined" && typeof node.key !== "undefined",
	transform: (node, { plugins,...rest }) => require_IntlayerNode.renderIntlayerNode({
		...rest,
		value: "[[react-element]]",
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
			...rest,
			children: require_renderReactElement.renderReactElement(node)
		})
	})
};
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
const markdownStringPlugin = {
	id: "markdown-string-plugin",
	canHandle: (node) => typeof node === "string",
	transform: (node, props, deepTransformNode) => {
		const { plugins,...rest } = props;
		const metadataNodes = deepTransformNode(require_getMarkdownMetadata.getMarkdownMetadata(node), {
			plugins: [{
				id: "markdown-metadata-plugin",
				canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
				transform: (metadataNode, props$1) => require_IntlayerNode.renderIntlayerNode({
					...props$1,
					value: metadataNode,
					children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
						...rest,
						children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownRenderer.MarkdownMetadataRenderer, {
							...rest,
							metadataKeyPath: props$1.keyPath,
							children: node
						})
					})
				})
			}],
			dictionaryKey: rest.dictionaryKey,
			keyPath: []
		});
		return require_IntlayerNode.renderIntlayerNode({
			...props,
			value: node,
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
				...rest,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownRenderer.MarkdownRenderer, {
					...rest,
					children: node
				})
			}),
			additionalProps: { metadata: metadataNodes }
		});
	}
};
const markdownPlugin = {
	id: "markdown-plugin",
	canHandle: (node) => typeof node === "object" && node?.nodeType === require_nodeType.NodeType.Markdown,
	transform: (node, props, deepTransformNode) => {
		const newKeyPath = [...props.keyPath, { type: require_nodeType.NodeType.Markdown }];
		const children = node[require_nodeType.NodeType.Markdown];
		return deepTransformNode(children, {
			...props,
			children,
			keyPath: newKeyPath,
			plugins: [markdownStringPlugin, ...props.plugins ?? []]
		});
	}
};

//#endregion
exports.intlayerNodePlugins = intlayerNodePlugins;
exports.markdownPlugin = markdownPlugin;
exports.reactNodePlugins = reactNodePlugins;
//# sourceMappingURL=plugins.cjs.map