import { N5 as e } from "../../../node_modules/markdown-to-jsx/dist/index.js";
import { MarkdownArticleContainer as t } from "./components/MarkdownArticleContainer.js";
import { MarkdownBlockquote as n } from "./components/MarkdownBlockquote.js";
import { MarkdownCodeBlock as r } from "./components/MarkdownCodeBlock.js";
import { MarkdownDelete as i } from "./components/MarkdownDelete.js";
import { MarkdownEmphasis as a } from "./components/MarkdownEmphasis.js";
import { MarkdownSuperscript as o } from "./components/MarkdownSuperscript.js";
import { MarkdownFootnoteReference as s } from "./components/MarkdownFootnoteReference.js";
import { MarkdownFootnotesSection as c } from "./components/MarkdownFootnotesSection.js";
import { MarkdownHeading as l } from "./components/MarkdownHeading.js";
import { MarkdownHtmlFallback as u } from "./components/MarkdownHtmlFallback.js";
import { MarkdownImage as d } from "./components/MarkdownImage.js";
import { MarkdownInlineCode as f } from "./components/MarkdownInlineCode.js";
import { MarkdownLineBreak as p } from "./components/MarkdownLineBreak.js";
import { MarkdownLink as m } from "./components/MarkdownLink.js";
import { MarkdownList as h } from "./components/MarkdownList.js";
import { MarkdownListItem as g } from "./components/MarkdownListItem.js";
import { MarkdownMark as _ } from "./components/MarkdownMark.js";
import { MarkdownParagraph as v } from "./components/MarkdownParagraph.js";
import { MarkdownStrong as y } from "./components/MarkdownStrong.js";
import { MarkdownSubscript as ee } from "./components/MarkdownSubscript.js";
import { MarkdownTable as b } from "./components/MarkdownTable.js";
import { MarkdownTableBody as x } from "./components/MarkdownTableBody.js";
import { MarkdownTableCell as S } from "./components/MarkdownTableCell.js";
import { MarkdownTableHead as C } from "./components/MarkdownTableHead.js";
import { MarkdownTableHeaderCell as w } from "./components/MarkdownTableHeaderCell.js";
import { MarkdownTableRow as T } from "./components/MarkdownTableRow.js";
import { MarkdownTaskListItem as E } from "./components/MarkdownTaskListItem.js";
import { MarkdownText as D } from "./components/MarkdownText.js";
import { MarkdownThematicBreak as O } from "./components/MarkdownThematicBreak.js";
import { RuleType as k } from "./helpers/markdownRuleTypes.js";
import { __test as A, getNodeChildren as j, isCodeBlockNode as M, isCodeInlineNode as N, isFootnoteReferenceNode as P, isFormattedTextNode as te, isGfmTaskNode as F, isHeadingNode as I, isHtmlBlockNode as L, isHtmlSelfClosingNode as R, isImageNode as z, isLinkNode as B, isOrderedListNode as V, isParagraphNode as H, isTableNode as U, isTextNode as W, isUnorderedListNode as G, mapAlignment as K, renderChildrenSafe as q } from "./MarkdownRenderer.helpers.js";
import { Fragment as J, useDeferredValue as Y, useMemo as X } from "react";
import { jsx as Z, jsxs as Q } from "react/jsx-runtime";
//#region src/atomic/molecules/markdown/MarkdownRenderer.tsx
var ne = {
	[k.blockQuote]: (e, t, r, i) => /* @__PURE__ */ Z(n, { children: q(r, j(t), i) }, i.key),
	[k.breakLine]: (e, t, n, r) => /* @__PURE__ */ Z(p, {}, r.key),
	[k.breakThematic]: (e, t, n, r) => /* @__PURE__ */ Z(O, {}, r.key),
	[k.codeInline]: (e, t, n, r) => N(t) ? /* @__PURE__ */ Z(f, { text: t.text }, r.key) : null,
	[k.codeBlock]: (e, t, n, i) => M(t) ? /* @__PURE__ */ Z(r, {
		code: t.text,
		language: t.lang
	}, i.key) : null,
	[k.footnoteReference]: (e, t, n, r) => P(t) ? /* @__PURE__ */ Z(s, {
		href: t.target,
		label: t.text
	}, r.key) : null,
	[k.gfmTask]: () => null,
	[k.heading]: (e, t, n, r) => I(t) ? /* @__PURE__ */ Z(l, {
		id: t.id,
		level: t.level,
		children: q(n, t.children, r)
	}, r.key) : null,
	[k.htmlBlock]: (e, t, n, r) => {
		if (!L(t)) return null;
		let i = t.text, a = "";
		return typeof i == "string" && (a = i), /* @__PURE__ */ Z(u, { content: a }, r.key);
	},
	[k.htmlSelfClosing]: (e, t, n, r) => R(t) ? /* @__PURE__ */ Z(u, { content: `<${t.tag} />` }, r.key) : null,
	[k.image]: (e, t, n, r) => z(t) ? /* @__PURE__ */ Z(d, {
		alt: t.alt,
		src: t.target,
		title: t.title
	}, r.key) : null,
	[k.link]: (e, t, n, r) => {
		if (!B(t)) return null;
		let i = t.target;
		return i == null ? /* @__PURE__ */ Z(J, { children: q(n, t.children, r) }, r.key) : /* @__PURE__ */ Z(m, {
			href: i,
			title: t.title,
			children: q(n, t.children, r)
		}, r.key);
	},
	[k.orderedList]: (e, t, n, r) => V(t) ? /* @__PURE__ */ Z(h, {
		ordered: !0,
		start: t.start,
		children: t.items.map((e, t) => {
			let i = "ol";
			r.key != null && (i = String(r.key));
			let a = `${i}-${t}`, o = e[0];
			if (o != null && F(o)) {
				let t = e.slice(1);
				return /* @__PURE__ */ Z(E, {
					checked: o.completed,
					children: q(n, t, r)
				}, a);
			}
			return /* @__PURE__ */ Z(g, { children: q(n, e, r) }, a);
		})
	}, r.key) : null,
	[k.paragraph]: (e, t, n, r) => H(t) ? /* @__PURE__ */ Z(v, { children: q(n, t.children, r) }, r.key) : null,
	[k.table]: (e, t, n, r) => {
		if (!U(t)) return null;
		let i = null;
		return Array.isArray(t.header) && t.header.length > 0 && (i = /* @__PURE__ */ Z(C, { children: /* @__PURE__ */ Z(T, { children: t.header.map((e, i) => {
			let a;
			return Array.isArray(t.align) && (a = t.align[i]), /* @__PURE__ */ Z(w, {
				align: K(a),
				children: q(n, e, r)
			}, `header-${i}`);
		}) }) })), /* @__PURE__ */ Q(b, { children: [i, /* @__PURE__ */ Z(x, { children: t.cells.map((e, i) => /* @__PURE__ */ Z(T, { children: e.map((e, a) => {
			let o;
			return Array.isArray(t.align) && (o = t.align[a]), /* @__PURE__ */ Z(S, {
				align: K(o),
				children: q(n, e, r)
			}, `cell-${i}-${a}`);
		}) }, `row-${i}`)) })] }, r.key);
	},
	[k.text]: (e, t, n, r) => W(t) ? /* @__PURE__ */ Z(D, { text: t.text }, r.key) : null,
	[k.textFormatted]: (e, t, n, r) => {
		if (!te(t)) return e();
		let o = q(n, t.children, r);
		switch (t.tag) {
			case "strong":
			case "b": return /* @__PURE__ */ Z(y, { children: o }, r.key);
			case "em":
			case "i": return /* @__PURE__ */ Z(a, { children: o }, r.key);
			case "mark": return /* @__PURE__ */ Z(_, { children: o }, r.key);
			case "del":
			case "s": return /* @__PURE__ */ Z(i, { children: o }, r.key);
			default: return e();
		}
	},
	[k.unorderedList]: (e, t, n, r) => G(t) ? /* @__PURE__ */ Z(h, {
		ordered: !1,
		children: t.items.map((e, t) => {
			let i = "ul";
			r.key != null && (i = String(r.key));
			let a = `${i}-${t}`, o = e[0];
			if (o != null && F(o)) {
				let t = e.slice(1);
				return /* @__PURE__ */ Z(E, {
					checked: o.completed,
					children: q(n, t, r)
				}, a);
			}
			return /* @__PURE__ */ Z(g, { children: q(n, e, r) }, a);
		})
	}, r.key) : null
}, re = {
	disableParsingRawHTML: !0,
	forceBlock: !0,
	wrapper: J,
	overrides: {
		footer: { component: c },
		sup: { component: o },
		sub: { component: ee }
	},
	renderRule(e, t, n, r) {
		let { type: i } = t, a = ne[i];
		return a == null ? e() : a(e, t, n, r);
	}
}, $ = ({ content: n }) => {
	let r = Y(n);
	return /* @__PURE__ */ Z(t, { children: /* @__PURE__ */ Z(e, {
		options: re,
		children: X(() => r, [r])
	}) });
};
//#endregion
export { $ as MarkdownRenderer, $ as default, A as __test };

//# sourceMappingURL=MarkdownRenderer.js.map