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

//# sourceMappingURL=MarkdownRenderer.js.map